1. Paweł Wieczorek
  2. Opifex

Commits

Paweł Wieczorek  committed 5ea2c2a

analysis gives function instead of functional-monoid

  • Participants
  • Parent commits 947a904
  • Branches default

Comments (0)

Files changed (2)

File src/Analysis/CWCPS/CWCPS_VariableUsageAnalysis.ml

View file
  • Ignore whitespace
 
 module VariableUsageCount_FunMonoid = PreparedMonoids.SumInt_FunMonoid(VariableOrderedType)
 
-module Counting = struct
+module UsageCounting = struct
 
     let handle_values xs =
         xs
             [arg1; arg2]
             |> handle_values
 
-    let analyze =
+    let analyze tm =
         let module M = MonoidBased(VariableUsageCount_FunMonoid) in
-        Util.marshal "counting" (M.Gather.gather __analyze)
+        M.Gather.gather __analyze tm
+        |> VariableUsageCount_FunMonoid.call
 
 end
 
             (EscapingVariable_FunMonoid)
 
     let __analyze = Monoid.combine
-        Counting.__analyze
+        UsageCounting.__analyze
         EscapingVariables.__analyze
 
     let analyze tm =

File src/Transformation/CWCPS/CWCPS_RemoveDeadCode.ml

View file
  • Ignore whitespace
  ************************************************************************************************)
 
 module UnusedDefinitions = struct
-    module D = CWCPS_VariableUsageAnalysis.VariableUsageCount_FunMonoid
 
     let substitute_vexpr result i = Transformation.Substitute [ (result, i) ]
 
     let substitute_int result i   = substitute_vexpr result (VEXPR_Integer i)
 
-    let is_var_used varUsageCount var = 
-        D.call varUsageCount var > 0
+    let is_var_used usage_count var = usage_count var > 0
 
-    let try_remove_definition varUsageCount var in_expr =
-        Formatter.print_document
-            [ Formatter.Word "removing"
-            ; Formatter.Var var
-            ; Formatter.Word "if"
-            ; Formatter.Bool (is_var_used varUsageCount var)
-            ];
-        if is_var_used varUsageCount var
+    let try_remove_definition usage_count var in_expr =
+        if is_var_used usage_count var
         then Transformation.NoChange 
         else Transformation.Replace in_expr
 
-    let transformation varUsageCount = function
+    let transformation usage_count = function
 
         (* optimalize unused fixs *)
 
             Transformation.Replace in_expr
 
         | EXPR_Fix (reclabel, definitions, in_expr) ->
-            let definitions' = List.filter (is_var_used varUsageCount  -| get_name_from_fixdef) definitions in
+            let definitions' = List.filter (is_var_used usage_count  -| get_name_from_fixdef) definitions in
             if List.length definitions = List.length definitions'
             then Transformation.NoChange
             else Transformation.Replace (EXPR_Fix (reclabel, definitions', in_expr))
 
         | EXPR_ArithmeticBinaryPrimOp (_, _, _, _, result, in_expr) 
         | EXPR_ArithmeticUnaryPrimOp (_, _, _, result, in_expr) ->
-            try_remove_definition varUsageCount result in_expr 
+            try_remove_definition usage_count result in_expr 
 
             
         | _ ->
 
 let bottomup =
     Transformation.bottomups_with_analysis
-        CWCPS_VariableUsageAnalysis.Counting.analyze
+        CWCPS_VariableUsageAnalysis.UsageCounting.analyze
         bottomup_transformations