diff src/iflow.sml @ 1235:a7b773f1d053

Command-line use of Iflow
author Adam Chlipala <adamc@hcoop.net>
date Tue, 13 Apr 2010 11:34:59 -0400
parents e799c8df3146
children d5ecceb7d1a1
line wrap: on
line diff
--- a/src/iflow.sml	Tue Apr 13 11:15:43 2010 -0400
+++ b/src/iflow.sml	Tue Apr 13 11:34:59 2010 -0400
@@ -502,7 +502,7 @@
     case !(#Rep (unNode n)) of
         SOME n => p_rep n
       | NONE =>
-        box [string (Int.toString (Unsafe.cast n) ^ ":"),
+        box [string (Int.toString 0(*Unsafe.cast n*) ^ ":"),
              space,
              case #Variety (unNode n) of
                  Nothing => string "?"
@@ -2182,7 +2182,7 @@
                 (Func (Other ("Cl" ^ Int.toString n), es), st)
             end
 
-          | EQuery {query = q, body = b, initial = i, ...} =>
+          | EQuery {query = q, body = b, initial = i, state = state, ...} =>
             let
                 val (_, st) = evalExp env (q, st)
                 val (i, st) = evalExp env (i, st)
@@ -2203,23 +2203,28 @@
                                       end)
                               (AllCols (Var r)) q
 
-                val (st, res) = if varInP acc (St.ambient st') then
-                                    let
-                                        val (st, r) = St.nextVar st
-                                    in
-                                        (st, Var r)
-                                    end
-                                else
-                                    let
-                                        val (st', out) = St.nextVar st'
-                                                  
-                                        val p = And (St.ambient st,
-                                                     Or (Reln (Eq, [Var out, i]),
-                                                         And (Reln (Eq, [Var out, b]),
-                                                              And (qp, amb))))
-                                    in
-                                        (St.setAmbient (st', p), Var out)
-                                    end
+                val (st, res) =
+                    case #1 state of
+                        TRecord [] =>
+                        (st, Func (DtCon0 "unit", []))
+                      | _ =>
+                        if varInP acc (St.ambient st') then
+                            let
+                                val (st, r) = St.nextVar st
+                            in
+                                (st, Var r)
+                            end
+                        else
+                            let
+                                val (st', out) = St.nextVar st'
+                                                 
+                                val p = And (St.ambient st,
+                                             Or (Reln (Eq, [Var out, i]),
+                                                 And (Reln (Eq, [Var out, b]),
+                                                      And (qp, amb))))
+                            in
+                                (St.setAmbient (st', p), Var out)
+                            end
 
                 val sent = map (fn ((loc, e, p), fl) => ((loc, e, And (qp, p)), fl)) (St.sent st')