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 3797, Mon May 2 21:10:12 2016 UTC revision 3995, Sat Jun 18 20:00:19 2016 UTC
# Line 106  Line 106 
106            Option.app analyzeBlock stabilizeM)            Option.app analyzeBlock stabilizeM)
107    
108    (* an initial pass to count the variable uses over the entire program *)    (* an initial pass to count the variable uses over the entire program *)
109      fun analyze (S.Program{constInit, init, strand, create, update, ...}) = (      fun analyze (S.Program{constInit, globInit, strand, create, init, update, ...}) = (
110            analyzeBlock constInit;            analyzeBlock constInit;
111            analyzeBlock init;            analyzeBlock globInit;
112            analyzeStrand strand;            analyzeStrand strand;
113            case create of S.Create{code, ...} => analyzeBlock code;            case create of S.Create{code, ...} => analyzeBlock code;
114              Option.app analyzeBlock init;
115            Option.app analyzeBlock update)            Option.app analyzeBlock update)
116    
117    (* rewrite a block and remove references to unused variables *)    (* rewrite a block and remove references to unused variables *)
# Line 183  Line 184 
184    (* contract a program *)    (* contract a program *)
185      fun contractProg (nChanges, prog) = let      fun contractProg (nChanges, prog) = let
186            val S.Program{            val S.Program{
187                    props, consts, inputs, constInit, globals, funcs, init, strand, create, update                    props, consts, inputs, constInit, globals, funcs,
188                      globInit, strand, create, init, update
189                  } = prog                  } = prog
190            val constInit = contractBlock constInit            val constInit = contractBlock constInit
191            val init = contractBlock init            val globInit = contractBlock globInit
192            val strand = contractStrand strand            val strand = contractStrand strand
193              val init = Option.map contractBlock init
194            val update = Option.map contractBlock update            val update = Option.map contractBlock update
195            val n = sumChanges()            val n = sumChanges()
196            in            in
# Line 196  Line 199 
199                else (n, S.Program{                else (n, S.Program{
200                    props = props, consts = consts, inputs = inputs,                    props = props, consts = consts, inputs = inputs,
201                    constInit = constInit, globals = globals, funcs = funcs,                    constInit = constInit, globals = globals, funcs = funcs,
202                    init = init, strand = strand, create = create, update = update                    globInit = globInit, strand = strand, create = create,
203                      init = init, update = update
204                  })                  })
205            end            end
206    
# Line 220  Line 224 
224    (* remove unused constant, global, and state variables from the program *)    (* remove unused constant, global, and state variables from the program *)
225      fun finishProg prog = let      fun finishProg prog = let
226            val S.Program{            val S.Program{
227                    props, consts, inputs, constInit, globals, funcs, init, strand, create, update                    props, consts, inputs, constInit, globals, funcs,
228                      globInit, strand, create, init, update
229                  } = prog                  } = prog
230            fun removeUnused cntr x = if isUsed x            fun removeUnused cntr x = if isUsed x
231                  then true                  then true
# Line 232  Line 237 
237                    constInit = constInit,                    constInit = constInit,
238                    globals = List.filter (removeUnused cntUnusedGlobal) globals,                    globals = List.filter (removeUnused cntUnusedGlobal) globals,
239                    funcs = funcs,                    funcs = funcs,
240                    init = init,                    globInit = globInit,
241                    strand = finishStrand strand,                    strand = finishStrand strand,
242                    create = create,                    create = create,
243                      init = init,
244                    update = update                    update = update
245                  }                  }
246            in            in

Legend:
Removed from v.3797  
changed lines
  Added in v.3995

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