Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/codegen/classify-state.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/codegen/classify-state.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 651, Sun Mar 20 16:53:55 2011 UTC revision 654, Mon Mar 21 17:10:54 2011 UTC
# Line 31  Line 31 
31      val {getFn = varClass : V.var -> state_var_class, setFn = setClass, ...} =      val {getFn = varClass : V.var -> state_var_class, setFn = setClass, ...} =
32            V.newProp (fn x => raise Fail(V.toString x ^ " not a state variable"))            V.newProp (fn x => raise Fail(V.toString x ^ " not a state variable"))
33    
34        fun join (UNIFORM, cls) = cls
35          | join (cls, UNIFORM) = cls
36          | join (INVARIANT, cls) = cls
37          | join (cls, INVARIANT) = cls
38          | join (VARYING, VARYING) = VARYING
39    
40        fun analyseCFG () = let
41              val anyChange = ref false
42              fun mark (x, cls) = (case (varClass x, cls)
43                     of (UNIFORM, cls) => (setClass(x, cls); anyChange := true)
44                      | (INVARIANT, VARYING) => (setClass(x, cls); anyChange := true)
45                      | _ => () (* no change *)
46                    (* end case *))
47              fun loopToFixPt () = (
48                    anyChange := false;
49                    analyse();
50                    if (! anyChange)
51                      then loopToFixPt ()
52                      else ())
53              in
54                loopToFixPt ()
55              end
56    
57    (* analyse a strand *)    (* analyse a strand *)
58      fun analyseStrand (IL.Strand{name, params, state, stateInit, methods}) = let      fun analyseStrand (IL.Strand{name, params, state, stateInit, methods}) = let
59            in            in
60            (* initially, we mark all state variables as UNIFORM *)            (* initially, we mark all state variables as UNIFORM and parameters as INVARIANT *)
61              List.app (fn x => setClass(x, UNIFORM)) state;              List.app (fn x => setClass(x, UNIFORM)) state;
62                List.app (fn x => setClass(x, INVARIANT)) params;
63            end            end
64    
65    end    end

Legend:
Removed from v.651  
changed lines
  Added in v.654

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0