diff src/shake.sml @ 1080:a4979e31e4bf

Another try at reasonable Especialize, this time with a custom traversal
author Adam Chlipala <adamc@hcoop.net>
date Sun, 20 Dec 2009 15:17:43 -0500
parents 0657e5adc938
children 72670131dace
line wrap: on
line diff
--- a/src/shake.sml	Tue Dec 15 19:26:52 2009 -0500
+++ b/src/shake.sml	Sun Dec 20 15:17:43 2009 -0500
@@ -129,6 +129,9 @@
 
         and shakeCon s = U.Con.fold {kind = kind, con = con} s
 
+        (*val () = print "=====\nSHAKE\n=====\n"
+        val current = ref 0*)
+
         fun exp (e, s) =
             let
                 fun check n =
@@ -139,13 +142,16 @@
                             val s' = {exp = IS.add (#exp s, n),
                                       con = #con s}
                         in
-                            (*print ("Need " ^ Int.toString n ^ "\n");*)
+                            (*print ("Need " ^ Int.toString n ^ " <-- " ^ Int.toString (!current) ^ "\n");*)
                             case IM.find (edef, n) of
                                 NONE => s'
                               | SOME (ns, t, e) =>
                                 let
+                                    (*val old = !current
+                                    val () = current := n*)
                                     val s' = shakeExp (shakeCon s' t) e
                                 in
+                                    (*current := old;*)
                                     foldl (fn (n, s') => exp (ENamed n, s')) s' ns
                                 end
                         end
@@ -165,6 +171,7 @@
                                  NONE => raise Fail "Shake: Couldn't find 'val'"
                                | SOME (ns, t, e) =>
                                  let
+                                     (*val () = current := n*)
                                      val s = shakeExp (shakeCon s t) e
                                  in
                                      foldl (fn (n, s) => exp (ENamed n, s)) s ns