summaryrefslogtreecommitdiff
path: root/src/mono_reduce.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2013-04-21 13:03:20 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2013-04-21 13:03:20 -0400
commit52a39c41846b52cd9b93bf53fb709eea75704cca (patch)
treee3bfbf4b7ed4c4dd06ff2fb3675f12b681aab5db /src/mono_reduce.sml
parenteb7b751e19b527f8d72ba9b24a3158afb192750f (diff)
Get Iflow working again
Diffstat (limited to 'src/mono_reduce.sml')
-rw-r--r--src/mono_reduce.sml36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/mono_reduce.sml b/src/mono_reduce.sml
index 73adafa3..5bac235c 100644
--- a/src/mono_reduce.sml
+++ b/src/mono_reduce.sml
@@ -31,6 +31,8 @@ structure MonoReduce :> MONO_REDUCE = struct
open Mono
+val fullMode = ref false
+
structure E = MonoEnv
structure U = MonoUtil
@@ -531,27 +533,27 @@ fun reduce (file : file) =
simpleImpure (timpures, impures) env e andalso impure e
andalso not (List.null (summarize ~1 e))
+ fun passive (e : exp) =
+ case #1 e of
+ EPrim _ => true
+ | ERel _ => true
+ | ENamed _ => true
+ | ECon (_, _, NONE) => true
+ | ECon (_, _, SOME e) => passive e
+ | ENone _ => true
+ | ESome (_, e) => passive e
+ | EFfi _ => true
+ | EAbs _ => true
+ | ERecord xets => List.all (passive o #2) xets
+ | EField (e, _) => passive e
+ | _ => false
+
fun exp env e =
let
(*val () = Print.prefaces "exp" [("e", MonoPrint.p_exp env (e, ErrorMsg.dummySpan))]*)
fun doLet (x, t, e', b) =
let
- fun passive (e : exp) =
- case #1 e of
- EPrim _ => true
- | ERel _ => true
- | ENamed _ => true
- | ECon (_, _, NONE) => true
- | ECon (_, _, SOME e) => passive e
- | ENone _ => true
- | ESome (_, e) => passive e
- | EFfi _ => true
- | EAbs _ => true
- | ERecord xets => List.all (passive o #2) xets
- | EField (e, _) => passive e
- | _ => false
-
fun doSub () =
let
val r = subExpInExp (0, e') b
@@ -630,7 +632,7 @@ fun reduce (file : file) =
else
e
end
- else if countFree 0 0 b > 1 andalso not (passive e') then
+ else if countFree 0 0 b > 1 andalso not (!fullMode) andalso not (passive e') then
e
else
trySub ()
@@ -653,7 +655,7 @@ fun reduce (file : file) =
((*Print.prefaces "Considering" [("e1", MonoPrint.p_exp (E.pushERel env x t NONE) e1),
("e2", MonoPrint.p_exp env e2),
("sub", MonoPrint.p_exp env (reduceExp env (subExpInExp (0, e2) e1)))];*)
- if impure env e2 orelse countFree 0 0 e1 > 1 then
+ if impure env e2 orelse (not (!fullMode) andalso countFree 0 0 e1 > 1) then
#1 (reduceExp env (ELet (x, t, e2, e1), loc))
else
#1 (reduceExp env (subExpInExp (0, e2) e1)))