diff src/mono_reduce.sml @ 1854:bddd0ec5d3da

Tweak to 'let' inlining behavior
author Adam Chlipala <adam@chlipala.net>
date Sun, 02 Jun 2013 10:17:52 -0400
parents 3c93e91e97da
children 0480b8f29a47
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 =