summaryrefslogtreecommitdiff
path: root/src/shake.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-07-13 10:17:06 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-07-13 10:17:06 -0400
commit3316f3c317e587a5fc2ecf38f061a72b48e3b94e (patch)
treefae8c92c195e5f7976352a337017d285e729f859 /src/shake.sml
parent7281dbb2fc2a5f50c1049bad629f330e2ff3f7ca (diff)
Remove closure conversion in favor of zany fun with modules, which also replaces 'page'
Diffstat (limited to 'src/shake.sml')
-rw-r--r--src/shake.sml24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/shake.sml b/src/shake.sml
index 36657dfc..b7ce58d7 100644
--- a/src/shake.sml
+++ b/src/shake.sml
@@ -43,13 +43,13 @@ type free = {
fun shake file =
let
- val (page_cs, page_es) = List.foldl
- (fn ((DPage (c, e), _), (cs, es)) => (c :: cs, e :: es)
- | (_, acc) => acc) ([], []) file
+ val page_es = List.foldl
+ (fn ((DExport n, _), page_es) => n :: page_es
+ | (_, page_es) => page_es) [] file
val (cdef, edef) = foldl (fn ((DCon (_, n, _, c), _), (cdef, edef)) => (IM.insert (cdef, n, c), edef)
- | ((DVal (_, n, t, e), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e)))
- | ((DPage _, _), acc) => acc)
+ | ((DVal (_, n, t, e, _), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e)))
+ | ((DExport _, _), acc) => acc)
(IM.empty, IM.empty) file
fun kind (_, s) = s
@@ -90,14 +90,16 @@ fun shake file =
and shakeExp s = U.Exp.fold {kind = kind, con = con, exp = exp} s
- val s = {con = IS.empty, exp = IS.empty}
-
- val s = foldl (fn (c, s) => U.Con.fold {kind = kind, con = con} s c) s page_cs
- val s = foldl (fn (e, s) => U.Exp.fold {kind = kind, con = con, exp = exp} s e) s page_es
+ val s = {con = IS.empty, exp = IS.addList (IS.empty, page_es)}
+
+ val s = foldl (fn (n, s) =>
+ case IM.find (edef, n) of
+ NONE => raise Fail "Shake: Couldn't find 'val'"
+ | SOME (t, e) => shakeExp (shakeCon s t) e) s page_es
in
List.filter (fn (DCon (_, n, _, _), _) => IS.member (#con s, n)
- | (DVal (_, n, _, _), _) => IS.member (#exp s, n)
- | (DPage _, _) => true) file
+ | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n)
+ | (DExport _, _) => true) file
end
end