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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/mid-to-low/mid-to-low.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/mid-to-low/mid-to-low.sml

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

revision 612, Sat Mar 12 17:56:24 2011 UTC revision 613, Sat Mar 12 19:29:23 2011 UTC
# Line 32  Line 32 
32            (* end case *))            (* end case *))
33      fun renameList (env, xs) = List.map (fn x => rename(env, x)) xs      fun renameList (env, xs) = List.map (fn x => rename(env, x)) xs
34    
     fun setBindings (bind, xs) = (List.app (fn x => DstIL.Var.setBinding(x, bind)) xs; xs)  
   
35    (* convert a rational to a FloatLit.float value.  We do this by long division    (* convert a rational to a FloatLit.float value.  We do this by long division
36     * with a cutoff when we get to 12 digits.     * with a cutoff when we get to 12 digits.
37     *)     *)
# Line 304  Line 302 
302          type var_env = var_env          type var_env = var_env
303    
304          val rename = rename          val rename = rename
305            val renameList = renameList
306          val expand = DstIL.CFG.mkBlock o expand          val expand = DstIL.CFG.mkBlock o expand
307        end)        end)
308    
309      fun translate (SrcIL.Program{globals, globalInit, strands}) = let      fun translate prog = let
310            val env = VTbl.mkTable (256, Fail "env")            val prog = Trans.translate prog
           fun transMethod (SrcIL.Method{name, stateIn, stateOut, body}) =  
                 DstIL.Method{  
                     name = name,  
                     stateIn = setBindings (DstIL.VB_STATE_VAR, renameList (env, stateIn)),  
                     stateOut = renameList (env, stateOut),  
                     body = Trans.translate (env, body)  
                   }  
           fun transStrand (SrcIL.Strand{name, params, state, stateInit, methods}) =  
                 DstIL.Strand{  
                     name = name,  
                     params = setBindings (DstIL.VB_PARAM, renameList (env, params)),  
                     state = renameList (env, state),  
                     stateInit = Trans.translate (env, stateInit),  
                     methods = List.map transMethod methods  
                   }  
           val prog = DstIL.Program{  
                   globals = renameList (env, globals),  
                   globalInit = Trans.translate (env, globalInit),  
                   strands = List.map transStrand strands  
                 }  
311            in            in
312              LowILCensus.init prog;              LowILCensus.init prog;
313              prog              prog

Legend:
Removed from v.612  
changed lines
  Added in v.613

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