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

SCM Repository

[diderot] Diff of /trunk/src/compiler/tree-il/low-to-tree-fn.sml
ViewVC logotype

Diff of /trunk/src/compiler/tree-il/low-to-tree-fn.sml

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

revision 1130, Thu May 5 18:39:29 2011 UTC revision 1131, Thu May 5 18:53:48 2011 UTC
# Line 425  Line 425 
425                }                }
426            end            end
427    
428        fun checkProps strands = let
429              val hasDie = ref false
430              val hasNew = ref false
431              fun chkStm e = (case e
432                     of T.S_IfThen(_, b) => chkBlk b
433                      | T.S_IfThenElse(_, b1, b2) => (chkBlk b1; chkBlk b2)
434                      | T.S_New _ => (hasNew := true)
435                      | T.S_Die => (hasDie := true)
436                      | _ => ()
437                  (* end case *))
438              and chkBlk (T.Block{body, ...}) = List.app chkStm body
439              fun chkStrand (T.Strand{stateInit, methods, ...}) = let
440                    fun chkMeth (T.Method{body, ...}) = chkBlk body
441                    in
442                      chkBlk stateInit;
443                      List.app chkMeth methods
444                    end
445              fun condCons (x, v, l) = if !x then v::l else l
446              in
447                List.app chkStrand strands;
448                condCons (hasDie, T.StrandsMayDie,
449                condCons (hasNew, T.NewStrands, []))
450              end
451    
452      fun translate prog = let      fun translate prog = let
453          (* first we do a variable analysis pass on the Low IL *)          (* first we do a variable analysis pass on the Low IL *)
454            val prog as IL.Program{globalInit, initially, strands} = VA.optimize prog            val prog as IL.Program{globalInit, initially, strands} = VA.optimize prog
# Line 438  Line 462 
462            val globals = List.map            val globals = List.map
463                  (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)
464                    (IL.CFG.liveAtExit globalInit)                    (IL.CFG.liveAtExit globalInit)
465              val strands = List.map (trStrand env) strands
466            in            in
467              T.Program{              T.Program{
468                    props = checkProps strands,
469                  globals = globals,                  globals = globals,
470                  globalInit = trCFG (env, [], fn _ => [], globalInit),                  globalInit = trCFG (env, [], fn _ => [], globalInit),
471                  strands = List.map (trStrand env) strands,                  strands = strands,
472                  initially = trInitially (env, initially)                  initially = trInitially (env, initially)
473                }                }
474            end            end

Legend:
Removed from v.1130  
changed lines
  Added in v.1131

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