diff options
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r-- | lib/js/urweb.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 62f94f52..ba1e9625 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -891,8 +891,27 @@ function exec1(env, stack, e) { case "f": fr.args[fr.pos++] = v; if (fr.a == null) { + var res; stack = stack.next; - e = {c: "c", v: fr.f.apply(null, fr.args)}; + + if (fr.f.apply) + res = fr.f.apply(null, fr.args); + else if (fr.args.length == 0) + res = fr.f(); + else if (fr.args.length == 1) + res = fr.f(fr.args[0]); + else if (fr.args.length == 2) + res = fr.f(fr.args[0], fr.args[1]); + else if (fr.args.length == 3) + res = fr.f(fr.args[0], fr.args[1], fr.args[2]); + else if (fr.args.length == 4) + res = fr.f(fr.args[0], fr.args[1], fr.args[2], fr.args[3]); + else if (fr.args.length == 5) + res = fr.f(fr.args[0], fr.args[1], fr.args[2], fr.args[3], fr.args[4]); + else + whine("Native function has " + fr.args.length + " args, but there is no special case for that count."); + + e = {c: "c", v: res}; if (usedK) return null; } else { e = fr.a.data; |