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/low-to-tree-fn.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/codegen/low-to-tree-fn.sml

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

revision 1016, Fri Apr 29 21:59:23 2011 UTC revision 1017, Sun May 1 03:06:05 2011 UTC
# Line 84  Line 84 
84                (* if this is the last use of x, then remove it from the table *)                (* if this is the last use of x, then remove it from the table *)
85                  if (decCount x) then ignore(VT.remove tbl x) else ();                  if (decCount x) then ignore(VT.remove tbl x) else ();
86                  e)                  e)
87              | NONE => raise Fail(concat ["useVar(", V.toString x, ")"])              | NONE => (
88    print "*** dump environment\n";
89    VT.appi (fn (x, _) => print(concat["  ", IL.Var.toString x, "\n"])) tbl;
90    print "***\n";
91    raise Fail(concat ["useVar(", V.toString x, ")"])
92    )
93            (* end case *))            (* end case *))
94    
95    (* record a local variable *)    (* record a local variable *)
# Line 115  Line 120 
120              end              end
121    
122      fun bind (env, lhs, rhs) = (case peekGlobal (env, lhs)      fun bind (env, lhs, rhs) = (case peekGlobal (env, lhs)
123             of SOME x => (rename(env, lhs, x), [T.S_Assign(x, rhs)])             of SOME x => (env, [T.S_Assign(x, rhs)])
124              | NONE => bindLocal (env, lhs, rhs)              | NONE => bindLocal (env, lhs, rhs)
125            (* end case *))            (* end case *))
126    
127    (* set the definition of a variable, where the RHS is either a literal constant or a variable *)    (* set the definition of a variable, where the RHS is either a literal constant or a variable *)
128      fun setDef (env as E{tbl, ...}, lhs, rhs) = (case peekGlobal (env, lhs)      fun setDef (env as E{tbl, ...}, lhs, rhs) = (
129             of SOME x => (rename(env, lhs, x), [T.S_Assign(x, rhs)])            case peekGlobal (env, lhs)
130               of SOME x => (env, [T.S_Assign(x, rhs)])
131              | NONE => (VT.insert tbl (lhs, DEF rhs); (env, []))              | NONE => (VT.insert tbl (lhs, DEF rhs); (env, []))
132            (* end case *))            (* end case *))
133    
# Line 354  Line 360 
360              args = List.map (useVar env) args              args = List.map (useVar env) args
361            } end            } end
362    
363      fun trMethod (env, stateVars) (IL.Method{name, stateIn, stateOut, body}) = let      fun trMethod (env, stateVars) (IL.Method{name, stateIn, body}) = let
364            fun bindStateVar (x, (_, x'), (env, stms)) = let            fun bindStateVar (x, (_, x'), (env, stms)) = let
365                  val (env, stms') = bindLocal(env, x, T.E_Var x')                  val (env, stms') = bindLocal(env, x, T.E_Var x')
366                  in                  in
# Line 385  Line 391 
391                }                }
392            end            end
393    
394      fun translate (IL.Program{globals, globalInit, initially, strands}) = let      fun translate (IL.Program{globalInit, initially, strands}) = let
395            val env = newEnv()            val env = newEnv()
396            val globals = List.map            val globals = List.map
397                  (fn x => let val x' = newGlobal x in global(env, x, x'); x' end)                  (fn x => let val x' = newGlobal x in global(env, x, x'); x' end)
398                    globals                    (IL.CFG.liveAtExit globalInit)
399            in            in
400              T.Program{              T.Program{
401                  globals = globals,                  globals = globals,

Legend:
Removed from v.1016  
changed lines
  Added in v.1017

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