# HG changeset patch # User Adam Chlipala # Date 1274560194 14400 # Node ID 003df929ee08ac2764d98eaf6c3d1a09f79131c8 # Parent 04e9885cbe56aec64e5aea3f447318492b96f846 Switch to strings and eval for thunkifying JavaScripted functions diff -r 04e9885cbe56 -r 003df929ee08 lib/js/urweb.js --- 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); diff -r 04e9885cbe56 -r 003df929ee08 src/jscomp.sml --- 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)];*)