From 80d2a4213dbb9ef67d75e46c505c17e357e70a31 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 5 Nov 2013 11:58:52 -0500 Subject: Identify more local definitions as functions that should be lifted to the top level, which has synergistic effects on inlining later --- src/unnest.sml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/unnest.sml') 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 () -- cgit v1.2.3