aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/unnest.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2013-11-05 11:58:52 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2013-11-05 11:58:52 -0500
commit80d2a4213dbb9ef67d75e46c505c17e357e70a31 (patch)
tree6a8b212460a433e9f5233546f3e70c2dfd2b9812 /src/unnest.sml
parente9b71baa2477fda7f38e6cbabad121e8e3c2c49c (diff)
Identify more local definitions as functions that should be lifted to the top level, which has synergistic effects on inlining later
Diffstat (limited to 'src/unnest.sml')
-rw-r--r--src/unnest.sml18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/unnest.sml b/src/unnest.sml
index 52d729d7..17bfd39f 100644
--- a/src/unnest.sml
+++ b/src/unnest.sml
@@ -171,6 +171,8 @@ type state = {
fun kind (_, k, st) = (k, st)
+val basis = ref 0
+
fun exp ((ks, ts), e as old, st : state) =
case e of
ELet (eds, e, t) =>
@@ -186,6 +188,21 @@ fun exp ((ks, ts), e as old, st : state) =
liftExpInExp (~by) (length subs) e
end
+ fun functionInside (t : con) =
+ case #1 t of
+ TFun _ => true
+ | CApp ((CModProj (basis', [], "transaction"), _), _) => basis' = !basis
+ | _ => false
+
+ val eds = map (fn ed =>
+ case #1 ed of
+ EDVal ((PVar (x, _), _), t, e) =>
+ if functionInside t then
+ (EDValRec [(x, t, E.liftExpInExp 0 e)], #2 ed)
+ else
+ ed
+ | _ => ed) eds
+
val (eds, (ts, maxName, ds, subs, by)) =
ListUtil.foldlMapConcat
(fn (ed, (ts, maxName, ds, subs, by)) =>
@@ -422,6 +439,7 @@ fun unnest file =
in
([(DStr (x, n, sgn, str), loc)], st)
end
+ | DFfiStr ("Basis", n, _) => (basis := n; default ())
| DFfiStr _ => default ()
| DConstraint _ => default ()
| DExport _ => default ()