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 2140, Thu Feb 14 23:58:15 2013 UTC revision 2154, Mon Feb 18 16:54:22 2013 UTC
# Line 68  Line 68 
68    
69    (* is the given statement's continuation the syntactically following statement? *)    (* is the given statement's continuation the syntactically following statement? *)
70      fun contIsNext (AST.S_Block stms) = List.all contIsNext stms      fun contIsNext (AST.S_Block stms) = List.all contIsNext stms
71          | contIsNext (AST.IfThenElse(_, s1, s2)) = contIsNext s1 orelse contIsNext s2
72        | contIsNext AST.S_Die = false        | contIsNext AST.S_Die = false
73        | contIsNext AST.S_Stabilize = false        | contIsNext AST.S_Stabilize = false
74        | contIsNext (AST.S_Return _) = false        | contIsNext (AST.S_Return _) = false
# Line 210  Line 211 
211     *)     *)
212      and simplifyBlock stm = mkBlock (simplifyStmt (stm, []))      and simplifyBlock stm = mkBlock (simplifyStmt (stm, []))
213    
214      (* simplify the statement stm where stms is a reverse-order list of preceeding simplified
215       * statements.  This function returns a reverse-order list of simplified statements.
216       * Note that error reporting is done in the typechecker, but it does not prune unreachable
217       * code.
218       *)
219      and simplifyStmt (stm, stms) = (case stm      and simplifyStmt (stm, stms) = (case stm
220             of AST.S_Block body => let             of AST.S_Block body => let
 (* FIXME: we should probably prune unreachable code in the typechecker and issue a warning! *)  
221                  fun simplify ([], stms) = stms                  fun simplify ([], stms) = stms
222                    | simplify (stm::r, stms) = if contIsNext stm                    | simplify (stm::r, stms) = if contIsNext stm
223                        then simplify (r, simplifyStmt (stm, stms))                        then simplify (r, simplifyStmt (stm, stms))
224                        else simplify (r, [])  (* prune unreachable statements *)                        else simplifyStmt (stm, stms)  (* prune unreachable statements *)
225                  in                  in
226                    simplify (body, stms)                    simplify (body, stms)
227                  end                  end
# Line 361  Line 366 
366    
367      fun transform (errStrm, ast) = let      fun transform (errStrm, ast) = let
368            val simple = simplifyProgram ast            val simple = simplifyProgram ast
369            val _ = SimplePP.output (Log.logFile(), simple)       (* DEBUG *)            val _ = SimplePP.output (Log.logFile(), "simplify", simple)   (* DEBUG *)
370              val simple = Inliner.transform simple
371              val _ = SimplePP.output (Log.logFile(), "inlining", simple)   (* DEBUG *)
372  (*  (*
373            val simple = Lift.transform simple            val simple = Lift.transform simple
374                  handle Eval.Error msg => (Error.error(errStrm, msg); simple)                  handle Eval.Error msg => (Error.error(errStrm, msg); simple)

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

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