Commits

Paweł Wieczorek  committed c27a3a0

removed unused CWCPS_BasicAnalysis

  • Participants
  • Parent commits 5ea2c2a

Comments (0)

Files changed (2)

File src/Analysis/CWCPS/CWCPS_BasicAnalysis.ml

-(*
- * Opifex
- *
- * Copyrights(C) 2012 by Pawel Wieczorek <wieczyk at gmail>
- *)
-
-open CWCPS_AST
-open CWCPS_Transformation
-open Batteries
-open Algebra_Monoid
-
-(*
-(*************************************************************************************************
- * BoundBy
- ************************************************************************************************)
-
-module BoundBy = struct 
-
-    type t
-        = BOUNDBY_ArithmeticBinaryPrimOp of label * arithmetic_binary_primitive_operation 
-        | BOUNDBY_ArithmeticUnaryPrimOp of label * arithmetic_unary_primitive_operation 
-        | BOUNDBY_FixDef of label * label
-        | BOUNDBY_FixDefArg of label * variable * label
-
-    let compare = compare
-
-end
-
-open BoundBy
-
-module EmbededBoundBy         = EmbededTypeMonoid(BoundBy)
-module BoundBy_MapMonoid      = MapMonoid(VariableOrdType)(EmbededBoundBy)
-
-
-(*************************************************************************************************
- * KnownFunctions
- ************************************************************************************************)
-
-module UsedVariables_SetMonoid = SetMonoid(VariableOrdType)
-
-(*************************************************************************************************
- * Helpers
- ************************************************************************************************)
-
-let singleton k v = BoundBy_MapMonoid.singleton k (EmbededBoundBy.embed v)
-
-(*************************************************************************************************
- * Basic analysis
- ************************************************************************************************)
-
-let __analyze_bound_by = function
-    | EXPR_App (label, fun_val, arg_vals) ->
-        BoundBy_MapMonoid.bot
-
-    | EXPR_Switch (label, sel_val, default_branch, branches) ->
-        BoundBy_MapMonoid.bot
-
-    | EXPR_Fix (reclabel, definitions, in_expr) ->
-        let f_def (deflabel, defname, defargs, defexpr) =
-            let f_defarg arg =
-                BOUNDBY_FixDefArg (reclabel, defname, deflabel) 
-                |> singleton arg 
-                in
-
-            let defbby         = BOUNDBY_FixDef (reclabel, deflabel) in
-            let result_def     = singleton defname defbby in
-            let result_defargs = BoundBy_MapMonoid.join_map f_defarg defargs in
-            BoundBy_MapMonoid.joins [result_def; result_defargs]
-            in
-        BoundBy_MapMonoid.join_map f_def definitions
-
-    | EXPR_ArithmeticBinaryPrimOp (label, primop, arg1, arg2, result, in_expr) ->
-        BOUNDBY_ArithmeticBinaryPrimOp (label, primop)
-        |> singleton result
-
-    | EXPR_ArithmeticUnaryPrimOp (label, primop, arg, result, in_expr) ->
-        BOUNDBY_ArithmeticUnaryPrimOp (label, primop)
-        |> singleton result
-
-    | EXPR_ConditionPrimOp (label, primop, arg1, arg2, then_branch, else_branch) ->
-        BoundBy_MapMonoid.bot
-
-(*************************************************************************************************
- * Used variables
- ************************************************************************************************)
-
-let __used_variables = function
-    | EXPR_App (label, fun_val, arg_vals) ->
-        fun_val::arg_vals
-        |> List.filter_map get_variable
-        |> UsedVariables_SetMonoid.from_list
-
-    | EXPR_Switch (label, sel_val, default_branch, branches) ->
-        [sel_val]
-        |> List.filter_map get_variable
-        |> UsedVariables_SetMonoid.from_list
-
-    | EXPR_Fix (reclabel, definitions, in_expr) ->
-        let f (deflabel, defname, defargs, defbody) = defname in
-        List.map f definitions
-        |> UsedVariables_SetMonoid.from_list
-
-    | EXPR_ArithmeticBinaryPrimOp (label, primop, arg1, arg2, result, in_expr) ->
-        [arg1; arg2]
-        |> List.filter_map get_variable
-        |> UsedVariables_SetMonoid.from_list
-
-    | EXPR_ArithmeticUnaryPrimOp (label, primop, arg, result, in_expr) ->
-        [arg]
-        |> List.filter_map get_variable
-        |> UsedVariables_SetMonoid.from_list
-
-    | EXPR_ConditionPrimOp (label, primop, arg1, arg2, then_branch, else_branch) ->
-        [arg1; arg2]
-        |> List.filter_map get_variable
-        |> UsedVariables_SetMonoid.from_list
-
-(*************************************************************************************************
- * Used variables
- ************************************************************************************************)
-
-let analyze_bound_by =
-    let module M = MonoidBased(BoundBy_MapMonoid) in
-    M.Gather.gather __analyze_bound_by
-*)
-

File src/Analysis/CWCPS/CWCPS_VariableUsageAnalysis.ml

     type t =
         { usage_count : variable -> int
         ; escapes     : variable -> bool
+        ; known       : variable -> bool
         }
 
     module Monoid = Tuple2Monoid
         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
+        ; known         = EscapingVariable_FunMonoid.call   mon_escapes |- not
         }
 
 end