Mercurial > urweb
changeset 1262:003df929ee08
Switch to strings and eval for thunkifying JavaScripted functions
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 22 May 2010 16:29:54 -0400 |
parents | 04e9885cbe56 |
children | be2ef50780ed |
files | lib/js/urweb.js src/jscomp.sml |
diffstat | 2 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/js/urweb.js Sat May 22 14:14:02 2010 -0400 +++ b/lib/js/urweb.js Sat May 22 16:29:54 2010 -0400 @@ -1078,7 +1078,7 @@ var idx = e.n; e = urfuncs[idx]; if (e.c == "t") - e = urfuncs[idx] = e.f(); + e = urfuncs[idx] = eval("(" + e.f + ")"); break; case "s": stack = cons({c: "s"}, stack);
--- a/src/jscomp.sml Sat May 22 14:14:02 2010 -0400 +++ b/src/jscomp.sml Sat May 22 16:29:54 2010 -0400 @@ -564,9 +564,12 @@ val old = e val (e, st) = jsExp mode [] (e, st) val e = deStrcat 0 e + val e = String.translate (fn #"'" => "\\'" + | #"\\" => "\\\\" + | ch => String.str ch) e - val sc = "urfuncs[" ^ Int.toString n ^ "] = {c:\"t\",f:function(){return " - ^ e ^ "}};\n" + val sc = "urfuncs[" ^ Int.toString n ^ "] = {c:\"t\",f:'" + ^ e ^ "'};\n" in (*Print.prefaces "jsify'" [("old", MonoPrint.p_exp MonoEnv.empty old), ("new", MonoPrint.p_exp MonoEnv.empty new)];*)