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 2135, Mon Feb 11 12:33:24 2013 UTC revision 2154, Mon Feb 18 16:54:22 2013 UTC
# Line 66  Line 66 
66              (* end case *)              (* end case *)
67            end            end
68    
69      (* is the given statement's continuation the syntactically following statement? *)
70        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
73          | contIsNext AST.S_Stabilize = false
74          | contIsNext (AST.S_Return _) = false
75          | contIsNext _ = true
76    
77      fun simplifyProgram (AST.Program dcls) = let      fun simplifyProgram (AST.Program dcls) = let
78            val inputs = ref []            val inputs = ref []
79            val globals = ref []            val globals = ref []
# Line 203  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
221                  fun simplify ([], stms) = stms                  fun simplify ([], stms) = stms
222                    | simplify (stm::r, stms) = simplify (r, simplifyStmt (stm, stms))                    | simplify (stm::r, stms) = if contIsNext stm
223                          then simplify (r, simplifyStmt (stm, stms))
224                          else simplifyStmt (stm, stms)  (* prune unreachable statements *)
225                  in                  in
226                    simplify (body, stms)                    simplify (body, stms)
227                  end                  end
# Line 351  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.2135  
changed lines
  Added in v.2154

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