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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/simplify/simplify.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/simplify/simplify.sml

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

revision 2154, Mon Feb 18 16:54:22 2013 UTC revision 2328, Fri Mar 22 18:21:07 2013 UTC
# Line 16  Line 16 
16      structure S = Simple      structure S = Simple
17      structure InP = Inputs      structure InP = Inputs
18    
19      (* the SimpleAST and AST currently use the same type representation, but
20       * we prune out meta variables.
21       *)
22        val cvtTy = TypeUtil.prune
23    
24      local      local
25        val tempName = Atom.atom "_t"        val tempName = Atom.atom "_t"
26      in      in
27      fun newTemp ty = Var.new (tempName, AST.LocalVar, ty)      fun newTemp ty = Var.new (tempName, AST.LocalVar, cvtTy ty)
28      end      end
29    
30    (* make a block out of a list of statements that are in reverse order *)    (* make a block out of a list of statements that are in reverse order *)
# Line 68  Line 73 
73    
74    (* is the given statement's continuation the syntactically following statement? *)    (* is the given statement's continuation the syntactically following statement? *)
75      fun contIsNext (AST.S_Block stms) = List.all contIsNext stms      fun contIsNext (AST.S_Block stms) = List.all contIsNext stms
76        | contIsNext (AST.IfThenElse(_, s1, s2)) = contIsNext s1 orelse contIsNext s2        | contIsNext (AST.S_IfThenElse(_, s1, s2)) = contIsNext s1 orelse contIsNext s2
77        | contIsNext AST.S_Die = false        | contIsNext AST.S_Die = false
78        | contIsNext AST.S_Stabilize = false        | contIsNext AST.S_Stabilize = false
79        | contIsNext (AST.S_Return _) = false        | contIsNext (AST.S_Return _) = false
# Line 186  Line 191 
191                }                }
192            end            end
193    
194      and simplifyStrand {name, params, state, methods} = let      and simplifyStrand (AST.Strand{name, params, state, methods}) = let
195            fun simplifyState ([], xs, stms) = (List.rev xs, mkBlock stms)            fun simplifyState ([], xs, stms) = (List.rev xs, mkBlock stms)
196              | simplifyState (AST.VD_Decl(x, e) :: r, xs, stms) = let              | simplifyState (AST.VD_Decl(x, e) :: r, xs, stms) = let
197                  val (stms, e') = simplifyExp (e, stms)                  val (stms, e') = simplifyExp (e, stms)
# Line 335  Line 340 
340              | AST.E_Coerce{srcTy, dstTy, e} => let              | AST.E_Coerce{srcTy, dstTy, e} => let
341                  val (stms, x) = simplifyExpToVar (e, stms)                  val (stms, x) = simplifyExpToVar (e, stms)
342                  val result = newTemp dstTy                  val result = newTemp dstTy
343                    val rhs = S.E_Coerce{srcTy = cvtTy srcTy, dstTy = cvtTy dstTy, x = x}
344                  in                  in
345                    (S.S_Assign(result, S.E_Coerce{srcTy=srcTy, dstTy=dstTy, x=x})::stms, S.E_Var result)                    (S.S_Assign(result, rhs)::stms, S.E_Var result)
346                  end                  end
347            (* end case *))            (* end case *))
348    

Legend:
Removed from v.2154  
changed lines
  Added in v.2328

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