changeset 1854:bddd0ec5d3da

Tweak to 'let' inlining behavior
author Adam Chlipala <adam@chlipala.net>
date Sun, 02 Jun 2013 10:17:52 -0400
parents f405dfe1f1e1
children 0480b8f29a47
files src/mono_reduce.sml
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/mono_reduce.sml	Sun Apr 21 13:32:10 2013 -0400
+++ b/src/mono_reduce.sml	Sun Jun 02 10:17:52 2013 -0400
@@ -564,16 +564,19 @@
                                 #1 (reduceExp env r)
                             end
 
-                        fun trySub () =
+                        fun trySub pure =
                             ((*Print.prefaces "trySub"
                                             [("e", MonoPrint.p_exp env (e, ErrorMsg.dummySpan))];*)
                              case t of
                                  (TFfi ("Basis", "string"), _) => doSub ()
                                | (TSignal _, _) => e
                                | _ =>
-                                 case e' of
-                                     (ECase _, _) => e
-                                   | _ => doSub ())
+                                 if pure then
+                                     doSub ()
+                                 else
+                                     case e' of
+                                         (ECase _, _) => e
+                                       | _ => doSub ())
                     in
                         if impure env e' then
                             let
@@ -628,14 +631,14 @@
                                               | _ => false))
                                    andalso countFree 0 0 b = 1
                                    andalso not (freeInAbs b) then
-                                    trySub ()
+                                    trySub (List.null effs_e')
                                 else
                                     e
                             end
                         else if countFree 0 0 b > 1 andalso not (!fullMode) andalso not (passive e') then
                             e
                         else
-                            trySub ()
+                            trySub true
                     end
 
                 val r =