summaryrefslogtreecommitdiff
path: root/src/mono_reduce.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-09-22 15:12:09 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-09-22 15:12:09 -0400
commitee1639d9e3afa41c85382ab991e2229a91be4c21 (patch)
tree53528b85a9933aa85de2178d4f23249408427d4c /src/mono_reduce.sml
parent5053cc1cc65d193cc4d3298a9d2485c0139a9bf9 (diff)
Quoting JavaScript working
Diffstat (limited to 'src/mono_reduce.sml')
-rw-r--r--src/mono_reduce.sml18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mono_reduce.sml b/src/mono_reduce.sml
index 5904ce65..07e54b4d 100644
--- a/src/mono_reduce.sml
+++ b/src/mono_reduce.sml
@@ -282,7 +282,18 @@ val countFree = U.Exp.foldB {typ = fn (_, n) => n,
bind = fn (n, b) =>
case b of
U.Exp.RelE _ => n + 1
- | _ => n} 0 0
+ | _ => n}
+
+val freeInAbs = U.Exp.existsB {typ = fn _ => false,
+ exp = fn (n, e) =>
+ case e of
+ EAbs (_, _, _, b) => countFree n 0 b > 0
+ | EJavaScript (_, b) => countFree n 0 b > 0
+ | _ => false,
+ bind = fn (n, b) =>
+ case b of
+ U.Exp.RelE _ => n + 1
+ | _ => n} 0
fun reduce file =
let
@@ -457,7 +468,7 @@ fun reduce 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 e1 > 1 then
+ if impure env e2 orelse countFree 0 0 e1 > 1 then
#1 (reduceExp env (ELet (x, t, e2, e1), loc))
else
#1 (reduceExp env (subExpInExp (0, e2) e1)))
@@ -608,7 +619,8 @@ fun reduce file =
orelse (case effs_b of
UseRel :: effs => List.all verifyUnused effs
| _ => false))
- andalso countFree b = 1 then
+ andalso countFree 0 0 b = 1
+ andalso not (freeInAbs b) then
trySub ()
else
e