Commits

Paweł Wieczorek  committed 947a904

minor

  • Participants
  • Parent commits 3ac3aa5

Comments (0)

Files changed (5)

File src/Analysis/CWCPS/CWCPS_VariableUsageAnalysis.ml

 module Compose = struct
 
     type t =
-        { varEscapes    : variable -> bool
-        ; varUsageCount : variable -> int
+        { usage_count : variable -> int
+        ; escapes     : variable -> bool
         }
 
     module Monoid = Tuple2Monoid
         Counting.__analyze
         EscapingVariables.__analyze
 
-    let analyze =
+    let analyze tm =
         let module M = MonoidBased(Monoid) in
-        M.Gather.gather __analyze
+        let (mon_usage_count, mon_escapes) = M.Gather.gather __analyze tm in
+        { usage_count   = VariableUsageCount_FunMonoid.call mon_usage_count
+        ; escapes       = EscapingVariable_FunMonoid.call   mon_escapes
+        }
 
 end
 

File src/Language/CWCPS/CWCPS_Transformation.ml

                         let s = (subst sb' ) in
                         apply_transforms fs (apply_on_subexpr s tm)
                     | Replace tm' ->
-                        apply_transforms (f::fs) tm'
+                        apply_transforms fs tm'
 
     let rec topdowns fs tm =
         apply_on_subexpr (topdowns fs) (apply_transforms fs tm)
         let result = analize tm in
         let fs'    = List.map (Util.revapply result) fs in
         topdowns fs' tm 
+
+    let bottomups_with_analysis analize fs tm =
+        let result = analize tm in
+        let fs'    = List.map (Util.revapply result) fs in
+        bottomups fs' tm 
 end
 

File src/Lib/Algebra/Algebra_Monoid.ml

         List.fold_right SV.add xs SV.empty 
         |> embed_botset
 
+    let from_singleton = function
+        | BotSet m when SV.cardinal m > 1 ->
+            failwith "MakeSetMonoid.from_singleton"
+
+        | BotSet m ->
+            m
+            |> SV.enum
+            |> Enum.get
+
 end
 
 module SetMonoid (V : Set.OrderedType) = struct
             let res = CWCPS_ConstantFolding.topdown res in
             CWCPS_driver.pretty_expr res;
             Util.print_words_ln [ "-"; "transform RemoveDeadCode" ];
-            let res = CWCPS_RemoveDeadCode.topdown res in
+            let res = CWCPS_RemoveDeadCode.bottomup res in
             CWCPS_driver.pretty_expr res;
             ()
         with

File src/Transformation/CWCPS/CWCPS_RemoveDeadCode.ml

  * 
  ************************************************************************************************)
 
-let topdown_transformations = 
+let bottomup_transformations = 
     [ UnusedDefinitions.transformation
     ]
 
-let topdown =
-    Transformation.topdowns_with_analysis
+let bottomup =
+    Transformation.bottomups_with_analysis
         CWCPS_VariableUsageAnalysis.Counting.analyze
-        topdown_transformations 
+        bottomup_transformations