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 3502, Thu Dec 17 23:13:35 2015 UTC revision 3509, Fri Dec 18 15:01:54 2015 UTC
# Line 63  Line 63 
63                    | S.S_Var(x, SOME e) => analyzeExp e                    | S.S_Var(x, SOME e) => analyzeExp e
64                    | S.S_Assign(x, e) => analyzeExp e                    | S.S_Assign(x, e) => analyzeExp e
65                    | S.S_IfThenElse(x, b1, b2) => (markUsed x; analyzeBlk b1; analyzeBlk b2)                    | S.S_IfThenElse(x, b1, b2) => (markUsed x; analyzeBlk b1; analyzeBlk b2)
66                    | S.S_Foreach(x, xs, blk) => analyzeBlk blk                    | S.S_Foreach(x, xs, blk) => (markUsed xs; analyzeBlk blk)
67                    | S.S_New(strnd, xs) => List.app markUsed xs                    | S.S_New(strnd, xs) => List.app markUsed xs
68                    | S.S_Continue => ()                    | S.S_Continue => ()
69                    | S.S_Die => ()                    | S.S_Die => ()
# Line 205  Line 205 
205              List.app clrUsedMark used;              List.app clrUsedMark used;
206              if List.null unused              if List.null unused
207                then strand                then strand
208                else S.Strand{                else (
209                    List.app (fn _ => ST.tick cntUnusedState) unused;
210                    S.Strand{
211                    name = name, params = params, state = used,                    name = name, params = params, state = used,
212                    stateInit = stateInit,                    stateInit = stateInit,
213                    initM = initM, updateM = updateM, stabilizeM = stabilizeM                    initM = initM, updateM = updateM, stabilizeM = stabilizeM
214                  }                    })
215            end            end
216    
217    (* remove unused constant, global, and state variables from the program *)    (* remove unused constant, global, and state variables from the program *)
# Line 217  Line 219 
219            val S.Program{            val S.Program{
220                    props, consts, inputs, constInit, globals, funcs, init, strand, create, update                    props, consts, inputs, constInit, globals, funcs, init, strand, create, update
221                  } = prog                  } = prog
222              fun removeUnused cntr x = if isUsed x
223                    then true
224                    else (ST.tick cntr; false)
225            in            in
226              S.Program{              S.Program{
227                  props = props,                  props = props,
228                  consts = List.filter isUsed consts,                  consts = List.filter (removeUnused cntUnusedConst) consts,
229                  inputs = inputs,                  inputs = inputs,
230                  constInit = constInit,                  constInit = constInit,
231                  globals = List.filter isUsed globals,                  globals = List.filter (removeUnused cntUnusedGlobal) globals,
232                  funcs = funcs,                  funcs = funcs,
233                  init = init,                  init = init,
234                  strand = finishStrand strand,                  strand = finishStrand strand,

Legend:
Removed from v.3502  
changed lines
  Added in v.3509

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