diff lib/js/urweb.js @ 975:8fe576c0bee9

Quoting JavaScript working
author Adam Chlipala <adamc@hcoop.net>
date Tue, 22 Sep 2009 15:12:09 -0400
parents b851675a2c3d
children 68eda5b0636d
line wrap: on
line diff
--- a/lib/js/urweb.js	Tue Sep 22 14:15:29 2009 -0400
+++ b/lib/js/urweb.js	Tue Sep 22 15:12:09 2009 -0400
@@ -181,7 +181,7 @@
 }
 
 function cr(n) {
-  return closures[n]();
+  return closures[n];
 }
 
 function flatten(cls, tr) {
@@ -863,6 +863,7 @@
           stack = stack.next;
         } else {
           e = fr.a.data;
+          if (e == null) alert("Oh no!");
           fr.a = fr.a.next;
         }
         break;
@@ -983,9 +984,11 @@
       e = e.e;
       break;
     case "e":
-      var env0 = env;
-      var e0 = e.e;
-      e = {c: "c", v: cs(function() { return exec0(env0, e0); })};
+      e = {c: "c", v: cs({c: "wc", env: env, body: e.e})};
+      break;
+    case "wc":
+      env = e.env;
+      e = e.body;
       break;
     default:
       throw ("Unknown Ur expression kind " + e.c);
@@ -996,7 +999,7 @@
 function exec(e) {
   var r = exec0(null, e);
 
-  if (r != null && r.body)
+  if (r != null && r.body != null)
     return function(v) { return exec0(cons(v, r.env), r.body); };
   else
     return r;