diff options
-rw-r--r-- | lib/js/urweb.js | 19 | ||||
-rw-r--r-- | tests/jscomp.ur | 10 | ||||
-rw-r--r-- | tests/jscomp.urp | 3 | ||||
-rw-r--r-- | tests/jscomp.urs | 1 |
4 files changed, 26 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); diff --git a/tests/jscomp.ur b/tests/jscomp.ur new file mode 100644 index 00000000..a11c0088 --- /dev/null +++ b/tests/jscomp.ur @@ -0,0 +1,10 @@ +fun main () = + s <- source ""; + + return <xml><body> + <ctextbox source={s}/><br/> + + <button value="Echo" onclick={s <- get s; alert s}/> + <button value="+1" onclick={s <- get s; alert (show (readError s + 1))}/> + <button value="*3" onclick={s <- get s; alert (show ((readError s) * 3))}/> + </body></xml> diff --git a/tests/jscomp.urp b/tests/jscomp.urp new file mode 100644 index 00000000..ac207143 --- /dev/null +++ b/tests/jscomp.urp @@ -0,0 +1,3 @@ +debug + +jscomp diff --git a/tests/jscomp.urs b/tests/jscomp.urs new file mode 100644 index 00000000..6ac44e0b --- /dev/null +++ b/tests/jscomp.urs @@ -0,0 +1 @@ +val main : unit -> transaction page |