changeset 973:e30c2409c9d0

More interpreter debugging
author Adam Chlipala <adamc@hcoop.net>
date Tue, 22 Sep 2009 13:41:23 -0400
parents 733f67bb64e7
children b851675a2c3d
files lib/js/urweb.js src/jscomp.sml tests/jscomp.ur
diffstat 3 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lib/js/urweb.js	Tue Sep 22 13:27:47 2009 -0400
+++ b/lib/js/urweb.js	Tue Sep 22 13:41:23 2009 -0400
@@ -883,7 +883,7 @@
         stack = cons({c: "a3", env: env}, stack.next);
         break;
       default:
-        throw "Unknown Ur continuation kind";
+        throw ("Unknown Ur continuation kind " + fr.c);
       }
 
       break;
@@ -922,7 +922,7 @@
         throw "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;
+      e = e.l.data.v;
       break;
     case ".":
       stack = cons({c: ".", f: e.f}, stack);
@@ -942,7 +942,7 @@
       e = {c: "c", v: cs(function() { return exec0(env0, e0); })};
       break;
     default:
-      throw "Unknown Ur expression kind";
+      throw ("Unknown Ur expression kind " + e.c);
     }
   }
 }
--- a/src/jscomp.sml	Tue Sep 22 13:27:47 2009 -0400
+++ b/src/jscomp.sml	Tue Sep 22 13:41:23 2009 -0400
@@ -690,7 +690,7 @@
 
                                 val (e, st) = jsE inner (e, st)
                             in
-                                (strcat [str ("{c:\"f\",f:" ^ name ^ ",:a:cons("),
+                                (strcat [str ("{c:\"f\",f:" ^ name ^ ",a:cons("),
                                          e,
                                          str ",null)}"],
                                  st)
@@ -728,7 +728,7 @@
                                               let
                                                   val (e, st) = jsE inner (e, st)
                                               in
-                                                  (strcat [str ("cons({n:\"" ^ x ^ ",v:"),
+                                                  (strcat [str ("cons({n:\"" ^ x ^ "\",v:"),
                                                            e,
                                                            str "},",
                                                            es,
--- a/tests/jscomp.ur	Tue Sep 22 13:27:47 2009 -0400
+++ b/tests/jscomp.ur	Tue Sep 22 13:41:23 2009 -0400
@@ -1,15 +1,30 @@
+fun fst [a] [b] (x : a) (y : b) = x
+fun snd [a] [b] (x : a) (y : b) = y
+
 fun main () =
     s <- source "";
-    f <- source (plus 1); 
+    s' <- source "";
+    f <- source (plus 1);
+    f2 <- source fst;
+    r <- source {A = "x", B = "y"};
 
     return <xml><body>
-      <ctextbox source={s}/><br/><br/>
+      <ctextbox source={s}/> <ctextbox source={s'}/><br/><br/>
 
       Function: <button value="+1" onclick={set f (plus 1)}/>
       <button value="*3" onclick={set f (times 3)}/><br/><br/>
 
+      Function2: <button value="Fst" onclick={set f2 fst}/>
+      <button value="Snd" onclick={set f2 snd}/><br/><br/>
+
       <button value="Echo" onclick={s <- get s; alert s}/>
+      <button value="-" onclick={s <- get s; alert (show (-(readError s : int)))}/>
       <button value="+1" onclick={s <- get s; alert (show (readError s + 1))}/>
       <button value="*3" onclick={s <- get s; alert (show ((readError s) * 3))}/>
-      <button value="f" onclick={s <- get s; f <- get f; alert (show (f (readError s)))}/>
+      <button value="f" onclick={s <- get s; f <- get f; alert (show (f (readError s)))}/><br/><br/>
+
+      <button value="f2" onclick={s <- get s; s' <- get s'; f2 <- get f2; alert (f2 s s')}/><br/><br/>
+
+      <button value="A" onclick={r <- get r; alert r.A}/>
+      <button value="B" onclick={r <- get r; alert r.B}/>
     </body></xml>