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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/simplify/inliner.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/simplify/inliner.sml

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

revision 3450, Fri Nov 20 22:08:20 2015 UTC revision 3451, Sat Nov 21 21:11:21 2015 UTC
# Line 65  Line 65 
65            and doExp env exp = (case exp            and doExp env exp = (case exp
66                   of S.E_Var x => S.E_Var(rename env x)                   of S.E_Var x => S.E_Var(rename env x)
67                    | S.E_Lit _ => exp                    | S.E_Lit _ => exp
                   | S.E_Tuple xs => S.E_Tuple(List.map (rename env) xs)  
68                    | S.E_Apply(f, xs, ty) => S.E_Apply(f, List.map (rename env) xs, ty)                    | S.E_Apply(f, xs, ty) => S.E_Apply(f, List.map (rename env) xs, ty)
69                    | S.E_Prim(f, tys, xs, ty) =>                    | S.E_Prim(f, tys, xs, ty) =>
70                        S.E_Prim(f, tys, List.map (rename env) xs, ty)                        S.E_Prim(f, tys, List.map (rename env) xs, ty)
71                    | S.E_Cons xs => S.E_Cons(List.map (rename env) xs)                    | S.E_Cons(xs, ty) => S.E_Cons(List.map (rename env) xs, ty)
72                    | S.E_Seq(xs, ty) => S.E_Seq(List.map (rename env) xs, ty)                    | S.E_Seq(xs, ty) => S.E_Seq(List.map (rename env) xs, ty)
73                    | S.E_Slice(x, xs, ty) =>                    | S.E_Slice(x, xs, ty) =>
74                        S.E_Slice(rename env x, List.map (Option.map (rename env)) xs, ty)                        S.E_Slice(rename env x, List.map (Option.map (rename env)) xs, ty)
# Line 120  Line 119 
119    
120      fun expandStrand funcTbl = let      fun expandStrand funcTbl = let
121            val expandBlock = expandBlock funcTbl            val expandBlock = expandBlock funcTbl
122            fun expandMeth (S.Method(m, blk)) = S.Method(m, expandBlock blk)            fun expand (S.Strand{name, params, state, stateInit, initM, updateM, stabilizeM}) =
123            fun expand (S.Strand{name, params, state, stateInit, methods}) = S.Strand{                  S.Strand{
124                    name = name,                    name = name,
125                    params = params,                    params = params,
126                    state = state,                    state = state,
127                    stateInit = expandBlock stateInit,                    stateInit = expandBlock stateInit,
128                    methods = List.map expandMeth methods                      initM = Option.map expandBlock initM,
129                        updateM = expandBlock updateM,
130                        stabilizeM = Option.map expandBlock stabilizeM
131                  }                  }
132            in            in
133              expand              expand
134            end            end
135    
     fun expandInit funcTbl (S.Initially{isArray, rangeInit, iters, create}) = let  
           val expandBlock = expandBlock funcTbl  
           fun expandCreate (S.C_Create{argInit, name, args}) = S.C_Create{  
                   argInit = expandBlock argInit,  
                   name = name, args = args  
                 }  
           in  
             S.Initially{  
                 isArray = isArray,  
                 rangeInit = expandBlock rangeInit,  
                 iters = iters,  
                 create = expandCreate create  
               }  
           end  
   
136      fun transform (prog as S.Program{funcs=[], ...}) = prog      fun transform (prog as S.Program{funcs=[], ...}) = prog
137        | transform (S.Program{props, inputDefaults, inputs, globals, globalInit, funcs, strands, init}) = let        | transform prog = let
138              val S.Program{props, inputs, globals, funcs, init, strand, create, update} = prog
139          (* a table that maps function names to their definitions *)          (* a table that maps function names to their definitions *)
140            val funcTbl = V.Tbl.mkTable (List.length funcs, Fail "funcTbl")            val funcTbl = V.Tbl.mkTable (List.length funcs, Fail "funcTbl")
141          (* first we inline expand the function bodies in definition order *)          (* first we inline expand the function bodies in definition order *)
# Line 157  Line 144 
144            in            in
145              S.Program{              S.Program{
146                  props = props,                  props = props,
                 inputDefaults = inputDefaults,  
147                  inputs = inputs,                  inputs = inputs,
148                  globals = globals,                  globals = globals,
149                  globalInit = expandBlock globalInit,                  init = expandBlock init,
150                  funcs = [],                  funcs = [],
151                  strands = List.map (expandStrand funcTbl) strands,                  strand = expandStrand funcTbl strand,
152                  init = expandInit funcTbl init                  create = expandBlock create,
153                    update = Option.map expandBlock update
154                }                }
155            end            end
156    

Legend:
Removed from v.3450  
changed lines
  Added in v.3451

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