diff lib/js/urweb.js @ 982:6934343267c0

Grid1 seems to work in latest Firefox
author Adam Chlipala <adamc@hcoop.net>
date Thu, 24 Sep 2009 15:36:44 -0400
parents 3612ff0c6a10
children 2cd8c1aa0d3a
line wrap: on
line diff
--- a/lib/js/urweb.js	Thu Sep 24 12:26:30 2009 -0400
+++ b/lib/js/urweb.js	Thu Sep 24 15:36:44 2009 -0400
@@ -211,8 +211,6 @@
 
 // Dynamic tree management
 
-var trace = "";
-
 function populate(node) {
   var s = node.signal;
   var oldSources = node.sources;
@@ -271,7 +269,7 @@
           cons({n:"data", v:{c:".", r:{c:"v", n:0}, f:"data"}}, null))}}}};
 }
 function scur(s) {
-  return exec(s).data;
+  return execF(s, null)._data;
 }
 
 function lastParent() {
@@ -566,7 +564,7 @@
     var l = uul(getToken, getData);
     return {_1:d, _2:l};
   } else
-    throw ("Can't unmarshal list (" + tok + ")");
+    whine("Can't unmarshal list (" + tok + ")");
 }
 
 function strcmp(str1, str2) {
@@ -592,7 +590,7 @@
       try {
         return new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e) {
-        throw "Your browser doesn't seem to support AJAX.";
+        whine("Your browser doesn't seem to support AJAX.");
       }
     }
   }
@@ -819,7 +817,7 @@
     }
   }
 
-  throw "Out-of-bounds Ur variable reference";
+  whine("Out-of-bounds Ur variable reference");
 }
 
 function execP(env, p, v) {
@@ -851,7 +849,7 @@
     }
     return env;
   default:
-    throw ("Unknown Ur pattern kind" + p.c);
+    whine("Unknown Ur pattern kind" + p.c);
   }
 }
 
@@ -881,7 +879,6 @@
           e = {c: "c", v: fr.f.apply(null, fr.args)};
           stack = stack.next;
         } else {
-          trace += "" + fr.pos;
           e = fr.a.data;
           fr.a = fr.a.next;
         }
@@ -892,7 +889,7 @@
         break;
       case "a2":
         if (fr.f == null)
-          throw "Ur: applying null function";
+          whine("Ur: applying null function");
         else if (fr.f.body) {
           stack = cons({c: "<", env: env}, stack.next);
           env = cons(v, fr.f.env);
@@ -942,10 +939,10 @@
           }
         }
         if (ps == null)
-          throw "Match failure in Ur interpretation";
+          whine("Match failure in Ur interpretation");
         break;
       default:
-        throw ("Unknown Ur continuation kind " + fr.c);
+        whine("Unknown Ur continuation kind " + fr.c);
       }
 
       break;
@@ -969,6 +966,7 @@
       else {
         var args = [];
         stack = cons({c: "f", f: e.f, args: args, pos: 0, a: e.a.next}, stack);
+        if (!e.a.data.c) alert("[2] fr.f = " + e.f + "; 0 = " + e.a.data);
         e = e.a.data;
       }
       break;
@@ -981,7 +979,7 @@
       break;
     case "r":
       if (e.l == null)
-        throw "Empty Ur record in interpretation";
+        whine("Empty Ur record in interpretation");
       var fs = {};
       stack = cons({c: "r", n: e.l.data.n, fs: fs, l: e.l.next}, stack);
       e = e.l.data.v;
@@ -1010,7 +1008,7 @@
       e = e.body;
       break;
     default:
-      throw ("Unknown Ur expression kind " + e.c);
+      whine("Unknown Ur expression kind " + e.c);
     }
   }
 }