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

SCM Repository

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

Diff of /trunk/src/compiler/simplify/simplify.sml

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

revision 185, Wed Jul 28 17:11:09 2010 UTC revision 197, Mon Aug 2 20:51:47 2010 UTC
# Line 22  Line 22 
22      end      end
23    
24    (* 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 *)
25      fun mkBlock stms = let      fun mkBlock stms = S.Block(List.rev stms)
           fun flatten [] = []  
             | flatten (S.S_Block stms :: r) = stms @ flatten r  
             | flatten (stm :: r) = stm :: flatten r  
           in  
             S.S_Block(flatten (List.rev stms))  
           end  
26    
27      fun transform (AST.Program dcls) = let      fun transform (AST.Program dcls) = let
28            val globals = ref []            val globals = ref []
# Line 93  Line 87 
87            end            end
88    
89      and simplifyMethod (AST.M_Method(name, body)) =      and simplifyMethod (AST.M_Method(name, body)) =
90            S.M_Method(name, simplifyBlock body)            S.Method(name, simplifyBlock body)
91    
92    (* simplify a statement into a single statement (i.e., a block if it expands into more    (* simplify a statement into a single statement (i.e., a block if it expands into more
93     * than one new statement.     * than one new statement.
# Line 135  Line 129 
129    
130      and simplifyExp (exp, stms) = (      and simplifyExp (exp, stms) = (
131            case exp            case exp
132             of AST.E_Var x => (stms, S.E_Var x)             of AST.E_Var x => (case Var.kindOf x
133                     of Var.BasisVar => let
134                          val ty = Var.monoTypeOf x
135                          val x' = newTemp ty
136                          val stm = S.S_Assign(x', S.E_Apply(x, [], [], ty))
137                          in
138                            (stm::stms, S.E_Var x')
139                          end
140                      | _ => (stms, S.E_Var x)
141                    (* end case *))
142              | AST.E_Lit lit => (stms, S.E_Lit lit)              | AST.E_Lit lit => (stms, S.E_Lit lit)
143              | AST.E_Tuple es => raise Fail "E_Tuple not yet implemented"              | AST.E_Tuple es => raise Fail "E_Tuple not yet implemented"
144              | AST.E_Apply(f, tyArgs, args, ty) => let              | AST.E_Apply(f, tyArgs, args, ty) => let

Legend:
Removed from v.185  
changed lines
  Added in v.197

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