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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/simplify/simple-contract.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/simplify/simple-contract.sml

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

revision 3485, Sun Dec 6 13:48:48 2015 UTC revision 3501, Thu Dec 17 20:07:13 2015 UTC
# Line 57  Line 57 
57    
58    (* analyze a block for unused variables *)    (* analyze a block for unused variables *)
59      fun analyzeBlock blk = let      fun analyzeBlock blk = let
60            fun analyzeBlk (S.Block stms) = List.app analyzeStm stms            fun analyzeBlk (S.Block{code, ...}) = List.app analyzeStm code
61            and analyzeStm stm = (case stm            and analyzeStm stm = (case stm
62                   of S.S_Var(x, NONE) => ()                   of S.S_Var(x, NONE) => ()
63                    | S.S_Var(x, SOME e) => analyzeExp e                    | S.S_Var(x, SOME e) => analyzeExp e
# Line 123  Line 123 
123                    | S.E_LoadSeq _ => ()                    | S.E_LoadSeq _ => ()
124                    | S.E_LoadImage _ => ()                    | S.E_LoadImage _ => ()
125                  (* end case *))                  (* end case *))
126            fun contractBlk (S.Block stms) = let            fun contractBlk (S.Block{props, code}) = let
127                  fun contractStms [] = []                  fun contractStms [] = []
128                    | contractStms (stm::stms) = (case stm                    | contractStms (stm::stms) = (case stm
129                         of S.S_Var(x, NONE) => if isUsed x                         of S.S_Var(x, NONE) => if isUsed x
# Line 137  Line 137 
137                              else (ST.tick cntDeadAssign; delete e; contractStms stms)                              else (ST.tick cntDeadAssign; delete e; contractStms stms)
138                          | S.S_IfThenElse(x, b1, b2) => (                          | S.S_IfThenElse(x, b1, b2) => (
139                              case (contractBlk b1, contractBlk b2)                              case (contractBlk b1, contractBlk b2)
140                               of (S.Block[], S.Block[]) => (                               of (S.Block{code=[], ...} S.Block{code=[], ...}) => (
141                                    ST.tick cntDeadIf; unuse x; contractStms stms)                                    ST.tick cntDeadIf; unuse x; contractStms stms)
142                                | (b1, b2) => S.S_IfThenElse(x, b1, b2) :: contractStms stms                                | (b1, b2) => S.S_IfThenElse(x, b1, b2) :: contractStms stms
143                              (* end case *))                              (* end case *))
144                          | S.S_Foreach(x, xs, blk) => (                          | S.S_Foreach(x, xs, blk) => (
145                              case contractBlk blk                              case contractBlk blk
146                               of S.Block[] => (                               of S.Block{code=[], ...} => (
147                                    ST.tick cntDeadForeach; unuse xs; contractStms stms)                                    ST.tick cntDeadForeach; unuse xs; contractStms stms)
148                                | blk => S.S_Foreach(x, xs, blk) :: contractStms stms                                | blk => S.S_Foreach(x, xs, blk) :: contractStms stms
149                              (* end case *))                              (* end case *))
150                          | _ => stm :: contractStms stms                          | _ => stm :: contractStms stms
151                        (* end case *))                        (* end case *))
152                  in                  in
153                    S.Block (contractStms stms)                    S.Block{props = props, code = contractStms code}
154                  end                  end
155            fun loop (nChanges, blk) = let            fun loop (nChanges, blk) = let
156                  val blk = contractBlk blk                  val blk = contractBlk blk

Legend:
Removed from v.3485  
changed lines
  Added in v.3501

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