diff src/core_util.sml @ 110:3739af9e727a

Starting with closure links
author Adam Chlipala <adamc@hcoop.net>
date Sun, 13 Jul 2008 11:43:57 -0400
parents 813e5a52063d
children fd98dd10dce7
line wrap: on
line diff
--- a/src/core_util.sml	Sun Jul 13 10:17:06 2008 -0400
+++ b/src/core_util.sml	Sun Jul 13 11:43:57 2008 -0400
@@ -291,6 +291,11 @@
                 S.map2 (mfe ctx e,
                      fn e' =>
                         (EWrite e', loc))
+
+              | EClosure (n, es) =>
+                S.map2 (ListUtil.mapfold (mfe ctx) es,
+                     fn es' =>
+                        (EClosure (n, es'), loc))
     in
         mfe
     end
@@ -401,6 +406,14 @@
         S.Continue (_, s) => s
       | S.Return _ => raise Fail "CoreUtil.Decl.fold: Impossible"
 
+fun foldMap {kind, con, exp, decl} s d =
+    case mapfold {kind = fn k => fn s => S.Continue (kind (k, s)),
+                  con = fn c => fn s => S.Continue (con (c, s)),
+                  exp = fn e => fn s => S.Continue (exp (e, s)),
+                  decl = fn d => fn s => S.Continue (decl (d, s))} d s of
+        S.Continue v => v
+      | S.Return _ => raise Fail "CoreUtil.Decl.foldMap: Impossible"
+
 end
 
 structure File = struct
@@ -456,6 +469,14 @@
         S.Continue (_, s) => s
       | S.Return _ => raise Fail "CoreUtil.File.fold: Impossible"
 
+fun foldMap {kind, con, exp, decl} s d =
+    case mapfold {kind = fn k => fn s => S.Continue (kind (k, s)),
+                  con = fn c => fn s => S.Continue (con (c, s)),
+                  exp = fn e => fn s => S.Continue (exp (e, s)),
+                  decl = fn d => fn s => S.Continue (decl (d, s))} d s of
+        S.Continue v => v
+      | S.Return _ => raise Fail "CoreUtil.File.foldMap: Impossible"
+
 end
 
 end