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

SCM Repository

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

Diff of /branches/pure-cfg/src/compiler/translate/translate.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 257  Line 257 
257      fun cvtTopLevelBlock (env, blk) = let      fun cvtTopLevelBlock (env, blk) = let
258            val (cfg, env) = cvtBlock ([], env, [], blk)            val (cfg, env) = cvtBlock ([], env, [], blk)
259            val entry = IL.Node.mkENTRY ()            val entry = IL.Node.mkENTRY ()
260            val exit = IL.Node.mkRETURN []            val exit = IL.Node.mkRETURN (VMap.listItems env)
261            in            in
262              if IL.CFG.isEmpty cfg              if IL.CFG.isEmpty cfg
263                then IL.Node.addEdge (entry, exit)                then IL.Node.addEdge (entry, exit)
# Line 308  Line 308 
308              IL.Method{              IL.Method{
309                  name = name,                  name = name,
310                  stateIn = stateIn,                  stateIn = stateIn,
                 stateOut = stateOut,  
311                  body = IL.CFG{entry = entry, exit = exit}                  body = IL.CFG{entry = entry, exit = exit}
312                }                }
313            end            end
# Line 337  Line 336 
336    
337      fun translate (S.Program{globals, globalInit, init, strands}) = let      fun translate (S.Program{globals, globalInit, init, strands}) = let
338            val (globalInit, env) = cvtTopLevelBlock (VMap.empty, globalInit)            val (globalInit, env) = cvtTopLevelBlock (VMap.empty, globalInit)
339          (* get the SSA names for the globals and a reduced environment that just defines          (* construct a reduced environment that just defines the globals. *)
340           * the globals.            val env = let
          *)  
           val (env, globs) = let  
341                  val lookup = lookup env                  val lookup = lookup env
342                  fun cvtVar (x, (env, globs)) = let                  fun cvtVar (x, env) = VMap.insert(env, x, lookup x)
343                        val x' = lookup x                  val env = List.foldl cvtVar VMap.empty globals
                       in  
                         (VMap.insert(env, x, x'), x'::globs)  
                       end  
                 val (env, globs) = List.foldl cvtVar (VMap.empty, []) globals  
344                  in                  in
345                    (env, List.rev globs)                    env
346                  end                  end
347            val init = cvtInitially (env, init)            val init = cvtInitially (env, init)
348            fun cvtStrand (S.Strand{name, params, state, stateInit, methods}) = let            fun cvtStrand (S.Strand{name, params, state, stateInit, methods}) = let
# Line 380  Line 373 
373                      }                      }
374                  end                  end
375            val prog = IL.Program{            val prog = IL.Program{
                   globals = globs,  
376                    globalInit = globalInit,                    globalInit = globalInit,
377                    initially = init,                    initially = init,
378                    strands = List.map cvtStrand strands                    strands = List.map cvtStrand strands

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