diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-09-22 13:23:27 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-09-22 13:23:27 -0400 |
commit | 6bf1ca818a5c360d7ad81a22c40b89606e9b6f3a (patch) | |
tree | 77167ea45ccdc596f8476f0679530416e5b5bda0 /lib | |
parent | 950fc955467d28baa7557992dc73044e0826b262 (diff) |
Basic arithmetic working with interpretation
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/urweb.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index abdf2ab7..c11702a6 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -834,15 +834,20 @@ function exec0(env, e) { } break; case "a1": - if (v == null || !v.body) - throw "Ur: applying non-function"; - stack = cons({c: "a2", env: v.env, body: v.body}, stack.next); e = fr.x; + stack = cons({c: "a2", f: v}, stack.next); break; case "a2": - stack = cons({c: "a3", env: env}, stack.next); - env = cons(v, fr.env); - e = fr.body; + if (fr.f == null) + throw "Ur: applying null function"; + else if (fr.f.body) { + stack = cons({c: "a3", env: env}, stack.next); + env = cons(v, fr.f.env); + e = fr.f.body; + } else { + e = {c: "c", v: fr.f(v)}; + stack = stack.next; + } break; case "a3": env = fr.env; @@ -886,7 +891,7 @@ function exec0(env, e) { e = {c: "c", v: lookup(env, e.n)}; break; case "n": - e = {c: "c", v: urfuncs[e.n]}; + e = urfuncs[e.n]; break; case "s": stack = cons({c: "s"}, stack); |