43 |
(* nesting depths of scopes *) |
(* nesting depths of scopes *) |
44 |
val undefinedScope = 0 |
val undefinedScope = 0 |
45 |
val globalScope = 1 (* global initialization *) |
val globalScope = 1 (* global initialization *) |
46 |
val initiallyScope = 2 (* initial strand creation *) |
val inputScope = 2 (* global inputs *) |
47 |
val paramScope = 2 (* strand parameter *) |
val initiallyScope = 3 (* initial strand creation *) |
48 |
val strandScope = 3 (* strand initialization *) |
val paramScope = 3 (* strand parameter *) |
49 |
val methodScope = 4 (* defined/used in a strand method *) |
val strandScope = 4 (* strand initialization *) |
50 |
val methodStateScope = 5 (* state variable in a strand method *) |
val methodScope = 5 (* defined/used in a strand method *) |
51 |
|
val methodStateScope = 6 (* state variable in a strand method *) |
52 |
|
|
53 |
(* property that maps variables to the depth where they are bound *) |
(* property that maps variables to the depth where they are bound *) |
54 |
val {getFn=getBindDepth : IL.var -> int, setFn=setBindDepth, clrFn=clrBindDepth, ...} = |
val {getFn=getBindDepth : IL.var -> int, setFn=setBindDepth, clrFn=clrBindDepth, ...} = |
81 |
List.app (setMaxUse depth) (IL.Node.uses nd); |
List.app (setMaxUse depth) (IL.Node.uses nd); |
82 |
List.app (fn x => setBindDepth(x, depth)) (IL.Node.defs nd)) |
List.app (fn x => setBindDepth(x, depth)) (IL.Node.defs nd)) |
83 |
(* end case *)) |
(* end case *)) |
84 |
|
fun doGlobalInitNode nd = (case IL.Node.kind nd |
85 |
|
of IL.ASSIGN{stm=(x, IL.OP(LowOps.Input _, _)), ...} => setMaxUse inputScope x |
86 |
|
| _ => doNode globalScope nd |
87 |
|
(* end case *)) |
88 |
fun doCFG (depth, cfg) = IL.CFG.apply (doNode depth) cfg |
fun doCFG (depth, cfg) = IL.CFG.apply (doNode depth) cfg |
89 |
fun assignDepthsForMethod state (IL.Method{body, ...}) = let |
fun assignDepthsForMethod state (IL.Method{body, ...}) = let |
90 |
(* check to see which state variables are invariant *) |
(* check to see which state variables are invariant *) |
127 |
(* examine the methods *) |
(* examine the methods *) |
128 |
List.app (assignDepthsForMethod state) methods) |
List.app (assignDepthsForMethod state) methods) |
129 |
in |
in |
130 |
doCFG (globalScope, globalInit); |
IL.CFG.apply doGlobalInitNode globalInit; |
131 |
(* do initially code *) |
(* do initially code *) |
132 |
doCFG (initiallyScope, rangeInit); |
doCFG (initiallyScope, rangeInit); |
133 |
List.app |
List.app |