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

SCM Repository

[diderot] Annotation of /branches/lamont_dev/src/compiler/translate/translate.sml
ViewVC logotype

Annotation of /branches/lamont_dev/src/compiler/translate/translate.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1864 - (view) (download)

1 : jhr 137 (* translate.sml
2 :     *
3 : jhr 435 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 137 * All rights reserved.
5 :     *
6 : jhr 1116 * Translate Simple-AST code into the IL representation. This translation is based on the
7 :     * algorithm described in
8 :     *
9 :     * Single-pass generation of static single assignment form for structured languages
10 :     * ACM TOPLAS, Nov. 1994
11 :     * by Brandis and MossenBock.
12 : jhr 137 *)
13 :    
14 :     structure Translate : sig
15 :    
16 : jhr 176 val translate : Simple.program -> HighIL.program
17 : jhr 137
18 :     end = struct
19 :    
20 : jhr 176 structure S = Simple
21 : jhr 394 structure Ty = Types
22 : jhr 137 structure VMap = Var.Map
23 : jhr 189 structure VSet = Var.Set
24 : jhr 168 structure IL = HighIL
25 : jhr 1640 structure Op = HighOps
26 : jhr 394 structure DstTy = HighILTypes
27 : jhr 1116 structure Census = HighILCensus
28 : jhr 137
29 : jhr 1640 val cvtTy = TranslateTy.tr
30 :    
31 : jhr 1116 (* maps from SimpleAST variables to the current corresponding SSA variable *)
32 : jhr 511 type env = IL.var VMap.map
33 :    
34 : jhr 1640 (* +DEBUG *)
35 :     fun prEnv (prefix, env) = let
36 :     val wid = ref 0
37 :     fun pr s = (print s; wid := !wid + size s)
38 :     fun nl () = if (!wid > 0) then (print "\n"; wid := 0) else ()
39 :     fun prElem (src, dst) = let
40 :     val s = String.concat [
41 :     " ", Var.uniqueNameOf src, "->", IL.Var.toString dst
42 :     ]
43 :     in
44 :     pr s;
45 :     if (!wid >= 100) then (nl(); pr " ") else ()
46 :     end
47 :     in
48 :     pr prefix; pr " ENV: {"; nl(); pr " ";
49 :     VMap.appi prElem env;
50 :     nl(); pr "}"; nl()
51 :     end
52 :     (* -DEBUG *)
53 :    
54 : jhr 197 fun lookup env x = (case VMap.find (env, x)
55 : jhr 176 of SOME x' => x'
56 :     | NONE => raise Fail(concat[
57 : jhr 197 "no binding for ", Var.uniqueNameOf x, " in environment"
58 : jhr 176 ])
59 :     (* end case *))
60 :    
61 : jhr 189 (* create a new instance of a variable *)
62 : jhr 394 fun newVar x = IL.Var.new (Var.nameOf x, cvtTy(Var.monoTypeOf x))
63 : jhr 189
64 : jhr 1116 (* generate fresh SSA variables and add them to the environment *)
65 :     fun freshVars (env, xs) = let
66 :     fun cvtVar (x, (env, xs)) = let
67 :     val x' = newVar x
68 :     in
69 :     (VMap.insert(env, x, x'), x'::xs)
70 :     end
71 :     val (env, xs) = List.foldl cvtVar (env, []) xs
72 :     in
73 :     (env, List.rev xs)
74 :     end
75 :    
76 :     (* a pending-join node tracks the phi nodes needed to join the assignments
77 :     * that flow into the join node.
78 :     *)
79 :     datatype join = JOIN of {
80 : jhr 1232 env : env, (* the environment that was current at the conditional *)
81 :     (* associated with this node. *)
82 : jhr 1116 arity : int ref, (* actual number of predecessors *)
83 :     nd : IL.node, (* the CFG node for this pending join *)
84 :     phiMap : IL.phi VMap.map ref, (* a mapping from Simple AST variables that are assigned *)
85 :     (* to their phi nodes. *)
86 :     predKill : bool array (* killed predecessor edges (because of DIE or STABILIZE *)
87 :     }
88 :    
89 :     (* a stack of pending joins. The first component specifies the path index of the current
90 :     * path to the join.
91 :     *)
92 :     type pending_joins = (int * join) list
93 :    
94 :     (* create a new pending-join node *)
95 : jhr 1232 fun newJoin (env, arity) = JOIN{
96 :     env = env, arity = ref arity, nd = IL.Node.mkJOIN [], phiMap = ref VMap.empty,
97 : jhr 1116 predKill = Array.array(arity, false)
98 :     }
99 : lamonts 1864 (* create a new pending-join node with a given CFG Node *)
100 :     fun newJoinWithNode (env, arity,node) = JOIN{
101 :     env = env, arity = ref arity, nd = node, phiMap = ref VMap.empty,
102 :     predKill = Array.array(arity, false)
103 :     }
104 : jhr 1116
105 :     (* record that a path to the top join in the stack has been killed because f DIE or STABILIZE *)
106 :     fun killPath ((i, JOIN{arity, predKill, ...}) :: _) = (
107 :     arity := !arity - 1;
108 :     Array.update (predKill, i, true))
109 :     | killPath _ = ()
110 :    
111 :     (* record an assignment to the IL variable dstVar (corresponding to the Simple AST variable
112 :     * srcVar) in the current pending-join node. The predIndex specifies which path into the
113 :     * JOIN node this assignment occurs on.
114 :     *)
115 : jhr 1232 fun recordAssign ([], _, _) = ()
116 :     | recordAssign ((predIndex, JOIN{env, phiMap, predKill, nd, ...})::_, srcVar, dstVar) = let
117 : jhr 1116 val arity = Array.length predKill (* the original arity before any killPath calls *)
118 :     val m = !phiMap
119 :     in
120 :     case VMap.find (env, srcVar)
121 :     of NONE => () (* local temporary *)
122 :     | SOME dstVar' => (case VMap.find (m, srcVar)
123 :     of NONE => let
124 :     val lhs = newVar srcVar
125 :     val rhs = List.tabulate (arity, fn i => if (i = predIndex) then dstVar else dstVar')
126 :     in
127 : jhr 1232 (*
128 :     print(concat["recordAssign: ", Var.uniqueNameOf srcVar, " --> ", IL.Var.toString lhs,
129 :     " @ ", IL.Node.toString nd, "\n"]);
130 :     *)
131 : jhr 1116 phiMap := VMap.insert (m, srcVar, (lhs, rhs))
132 :     end
133 :     | SOME(lhs, rhs) => let
134 :     fun update (i, l as x::r) = if (i = predIndex)
135 :     then dstVar::r
136 :     else x::update(i+1, r)
137 :     | update _ = raise Fail "invalid predecessor index"
138 :     in
139 :     phiMap := VMap.insert (m, srcVar, (lhs, update(0, rhs)))
140 :     end
141 :     (* end case *))
142 :     (* end case *)
143 :     end
144 :    
145 :     (* complete a pending join operation by filling in the phi nodes from the phi map and
146 :     * updating the environment.
147 :     *)
148 : jhr 1232 fun commitJoin (joinStk, JOIN{env, arity, nd, phiMap, predKill}) = (case !arity
149 : jhr 1116 of 0 => (env, NONE)
150 :     | 1 => (* there is only one path to the join, so we do not need phi nodes *)
151 :     (env, SOME nd)
152 :     | n => if (n = Array.length predKill)
153 :     then let
154 :     val IL.ND{kind=IL.JOIN{phis, ...}, ...} = nd
155 :     fun doVar (srcVar, phi as (dstVar, _), (env, phis)) = (
156 : jhr 1232 (*
157 :     print(concat["doVar (", Var.uniqueNameOf srcVar, ", ", IL.phiToString phi, ", _) @ ", IL.Node.toString nd, "\n"]);
158 :     *)
159 :     recordAssign (joinStk, srcVar, dstVar);
160 : jhr 1116 (VMap.insert (env, srcVar, dstVar), phi::phis))
161 :     val (env, phis') = VMap.foldli doVar (env, []) (!phiMap)
162 :     in
163 :     phis := phis';
164 :     (env, SOME nd)
165 :     end
166 :     else raise Fail "FIXME: prune killed paths."
167 :     (* end case *))
168 :    
169 : jhr 168 (* expression translation *)
170 : jhr 1116 fun cvtExp (env : env, lhs, exp) = (case exp
171 : jhr 1640 of S.E_Var x => [IL.ASSGN(lhs, IL.VAR(lookup env x))]
172 :     | S.E_Lit lit => [IL.ASSGN(lhs, IL.LIT lit)]
173 : lamonts 1832 | S.E_RadiusQuery (S.E_Lit lit) => [IL.ASSGN(lhs,IL.RQUERY lit)]
174 : jhr 176 | S.E_Tuple xs => raise Fail "E_Tuple not implemeted"
175 : jhr 188 | S.E_Apply(f, tyArgs, args, ty) => let
176 :     val args' = List.map (lookup env) args
177 :     in
178 :     TranslateBasis.translate (lhs, f, tyArgs, args')
179 :     end
180 : jhr 1640 | S.E_Cons args => [IL.ASSGN(lhs, IL.CONS(IL.Var.ty lhs, List.map (lookup env) args))]
181 : jhr 400 | S.E_Slice(x, indices, ty) => let
182 :     val x = lookup env x
183 :     val mask = List.map isSome indices
184 :     fun cvt NONE = NONE
185 :     | cvt (SOME x) = SOME(lookup env x)
186 :     val indices = List.mapPartial cvt indices
187 :     in
188 :     if List.all (fn b => b) mask
189 : jhr 1640 then [IL.ASSGN(lhs, IL.OP(HighOps.TensorSub(IL.Var.ty x), x::indices))]
190 :     else [IL.ASSGN(lhs, IL.OP(HighOps.Slice(IL.Var.ty lhs, mask), x::indices))]
191 : jhr 400 end
192 : jhr 1301 | S.E_Input(_, name, desc, NONE) =>
193 : jhr 1640 [IL.ASSGN(lhs, IL.OP(HighOps.Input(IL.Var.ty lhs, name, desc), []))]
194 : jhr 1301 | S.E_Input(_, name, desc, SOME dflt) =>
195 : jhr 1640 [IL.ASSGN(lhs, IL.OP(HighOps.InputWithDefault(IL.Var.ty lhs, name, desc), [lookup env dflt]))]
196 :     | S.E_LoadImage(info, name) => [IL.ASSGN(lhs, IL.OP(HighOps.LoadImage info, [lookup env name]))]
197 : jhr 176 (* end case *))
198 : jhr 168
199 : jhr 1640 (* add nodes to save the strand state, followed by an exit node *)
200 :     fun saveStrandState (env, (srcState, dstState), exit) = let
201 :     val stateOut = List.map (lookup env) srcState
202 :     fun save (x, x', cfg) = IL.CFG.appendNode (cfg, IL.Node.mkSAVE(x, x'))
203 :     in
204 :     IL.CFG.appendNode (
205 :     ListPair.foldlEq save IL.CFG.empty (dstState, stateOut),
206 :     exit)
207 :     end
208 :     handle ex => raise ex
209 :    
210 : jhr 1116 fun cvtBlock (state, env : env, joinStk, S.Block stms) = let
211 :     fun cvt (env : env, cfg, []) = (cfg, env)
212 :     | cvt (env, cfg, stm::stms) = (case stm
213 :     of S.S_Var x => let
214 :     val x' = newVar x
215 :     in
216 :     cvt (VMap.insert (env, x, x'), cfg, stms)
217 :     end
218 :     | S.S_Assign(lhs, rhs) => let
219 :     val lhs' = newVar lhs
220 :     val assigns = cvtExp (env, lhs', rhs)
221 :     in
222 : jhr 1232 (*
223 :     print "doAssign\n";
224 :     *)
225 :     recordAssign (joinStk, lhs, lhs');
226 : jhr 1116 cvt (
227 :     VMap.insert(env, lhs, lhs'),
228 :     IL.CFG.concat(cfg, IL.CFG.mkBlock assigns),
229 :     stms)
230 :     end
231 :     | S.S_IfThenElse(x, b0, b1) => let
232 : jhr 192 val x' = lookup env x
233 : jhr 1232 val join = newJoin (env, 2)
234 : jhr 1116 val (cfg0, _) = cvtBlock (state, env, (0, join)::joinStk, b0)
235 :     val (cfg1, _) = cvtBlock (state, env, (1, join)::joinStk, b1)
236 :     val cond = IL.Node.mkCOND {
237 :     cond = x',
238 :     trueBranch = IL.Node.dummy,
239 :     falseBranch = IL.Node.dummy
240 :     }
241 : jhr 190 in
242 : jhr 1116 IL.Node.addEdge (IL.CFG.exit cfg, cond);
243 : jhr 1232 case commitJoin (joinStk, join)
244 : jhr 1116 of (env, SOME joinNd) => (
245 :     if IL.CFG.isEmpty cfg0
246 :     then (
247 :     IL.Node.setTrueBranch (cond, joinNd);
248 :     IL.Node.setPred (joinNd, cond))
249 :     else (
250 :     IL.Node.setTrueBranch (cond, IL.CFG.entry cfg0);
251 :     IL.Node.setPred (IL.CFG.entry cfg0, cond);
252 :     IL.Node.addEdge (IL.CFG.exit cfg0, joinNd));
253 :     if IL.CFG.isEmpty cfg1
254 :     then (
255 :     IL.Node.setFalseBranch (cond, joinNd);
256 :     IL.Node.setPred (joinNd, cond))
257 :     else (
258 :     IL.Node.setFalseBranch (cond, IL.CFG.entry cfg1);
259 :     IL.Node.setPred (IL.CFG.entry cfg1, cond);
260 :     IL.Node.addEdge (IL.CFG.exit cfg1, joinNd));
261 :     cvt (
262 :     env,
263 : jhr 1339 IL.CFG.concat (
264 :     cfg,
265 :     IL.CFG{entry = cond, exit = joinNd}),
266 : jhr 1116 stms))
267 :     (* the join node has only zero predecessors, so
268 :     * it was killed.
269 :     *)
270 :     | (env, NONE) => raise Fail "unimplemented" (* FIXME *)
271 : jhr 192 (* end case *)
272 : jhr 190 end
273 : lamonts 1864 | S.S_Foreach(x,blk) => let
274 :     val x' = lookup env x
275 :     val forNode = IL.Node.mkFOREACH{
276 :     cond = x',
277 :     stmBranch = IL.Node.dummy
278 :     }
279 :     val join = newJoinWithNode(env, 1,forNode)
280 :     val (cfg0, _) = cvtBlock (state, env, (0, join)::joinStk, blk)
281 : lamonts 1832 in
282 : lamonts 1864 case commitJoin (joinStk, join)
283 :     of (env, SOME joinNd) => (
284 :     if IL.CFG.isEmpty cfg0
285 :     then (
286 :     IL.Node.addEdge (IL.CFG.exit cfg, joinNd);
287 :     IL.Node.setPred (joinNd, IL.CFG.exit cfg))
288 :     else (
289 :     IL.Node.addEdge (IL.CFG.exit cfg, joinNd);
290 :     IL.Node.setPred (IL.CFG.entry cfg0, joinNd);
291 :     IL.Node.setStmBranch(forNode, IL.CFG.entry cfg0);
292 :     IL.Node.addEdge (IL.CFG.exit cfg0, joinNd));
293 :     cvt (
294 :     env,
295 :     IL.CFG.concat (
296 :     cfg,
297 :     IL.CFG{entry = joinNd, exit = joinNd}),
298 :     stms))
299 :     (* the join node has only zero predecessors, so
300 :     * it was killed.
301 :     *)
302 :     | (env, NONE) => raise Fail "unimplemented" (* FIXME *)
303 :     (* end case *)
304 : lamonts 1832 end
305 :    
306 : jhr 1116 | S.S_New(strandId, args) => let
307 :     val nd = IL.Node.mkNEW{
308 :     strand = strandId,
309 :     args = List.map (lookup env) args
310 :     }
311 : jhr 192 in
312 : jhr 1116 cvt (env, IL.CFG.appendNode (cfg, nd), stms)
313 : jhr 194 end
314 : jhr 1116 | S.S_Die => (
315 :     killPath joinStk;
316 :     (IL.CFG.appendNode (cfg, IL.Node.mkDIE ()), env))
317 : jhr 1640 | S.S_Stabilize => (
318 :     killPath joinStk;
319 :     (IL.CFG.concat (cfg, saveStrandState (env, state, IL.Node.mkSTABILIZE())), env))
320 :     | S.S_Print args => let
321 :     val args = List.map (lookup env) args
322 :     val nd = IL.Node.mkMASSIGN([], Op.Print(List.map IL.Var.ty args), args)
323 :     in
324 :     cvt (env, IL.CFG.appendNode (cfg, nd), stms)
325 :     end
326 : jhr 192 (* end case *))
327 :     in
328 : jhr 1116 cvt (env, IL.CFG.empty, stms)
329 : jhr 192 end
330 : jhr 1339 (*DEBUG*)handle ex => raise ex
331 : jhr 168
332 : jhr 1232 fun cvtTopLevelBlock (env, blk, mkExit) = let
333 : jhr 1640 val (cfg, env) = cvtBlock (([], []), env, [], blk)
334 :     val cfg = IL.CFG.prependNode (IL.Node.mkENTRY(), cfg)
335 :     val cfg = IL.CFG.concat (cfg, mkExit env)
336 : jhr 256 in
337 : jhr 1640 (cfg, env)
338 : jhr 256 end
339 : jhr 1339 (*DEBUG*)handle ex => raise ex
340 : jhr 256
341 : jhr 1116 (* FIXME: the following function could be refactored with cvtTopLevelBlock to share code *)
342 : jhr 1232 fun cvtFragmentBlock (env0, blk) = let
343 : jhr 1640 val (cfg, env) = cvtBlock (([], []), env0, [], blk)
344 : jhr 1116 val entry = IL.Node.mkENTRY ()
345 : jhr 1232 (* the live variables out are those that were not live coming in *)
346 :     val liveOut = VMap.foldli
347 :     (fn (x, x', xs) => if VMap.inDomain(env0, x) then xs else x'::xs)
348 :     [] env
349 :     val exit = IL.Node.mkFRAGMENT liveOut
350 : jhr 1116 in
351 :     if IL.CFG.isEmpty cfg
352 :     then IL.Node.addEdge (entry, exit)
353 :     else (
354 :     IL.Node.addEdge (entry, IL.CFG.entry cfg);
355 : jhr 1232 IL.Node.addEdge (IL.CFG.exit cfg, exit));
356 : jhr 1116 (IL.CFG{entry = entry, exit = exit}, env)
357 :     end
358 : jhr 1339 (*DEBUG*)handle ex => raise ex
359 : jhr 1116
360 : jhr 1640 fun cvtMethod (env, name, state, svars, blk) = let
361 :     (* load the state into fresh variables *)
362 :     val (env, loadCFG) = let
363 :     (* allocate shadow variables for the state variables *)
364 :     val (env, stateIn) = freshVars (env, state)
365 :     fun load (x, x') = IL.ASSGN(x, IL.STATE x')
366 :     in
367 :     (env, IL.CFG.mkBlock (ListPair.map load (stateIn, svars)))
368 :     end
369 : jhr 1116 (* convert the body of the method *)
370 : jhr 1640 val (cfg, env) = cvtBlock ((state, svars), env, [], blk)
371 : jhr 1116 (* add the entry/exit nodes *)
372 :     val entry = IL.Node.mkENTRY ()
373 : jhr 1640 val loadCFG = IL.CFG.prependNode (entry, loadCFG)
374 : jhr 1444 val exit = (case name
375 : jhr 1640 of StrandUtil.Update => IL.Node.mkACTIVE ()
376 :     | StrandUtil.Stabilize => IL.Node.mkRETURN []
377 : jhr 1444 (* end case *))
378 : jhr 1640 val body = IL.CFG.concat (loadCFG, cfg)
379 :     (*DEBUG**val _ = prEnv (StrandUtil.nameToString name, env);*)
380 :     (* FIXME: the following code doesn't work properly *)
381 :     val body = if IL.Node.hasSucc(IL.CFG.exit body)
382 :     then IL.CFG.concat (body, saveStrandState (env, (state, svars), exit))
383 :     else IL.CFG{entry = IL.CFG.entry body, exit = exit}
384 : jhr 1116 in
385 :     IL.Method{
386 :     name = name,
387 : jhr 1640 body = body
388 : jhr 1116 }
389 :     end
390 : jhr 1640 (*DEBUG*)handle ex => (print(concat["error in cvtMethod(", StrandUtil.nameToString name, ", ...)\n"]); raise ex)
391 : jhr 1116
392 :     (* convert the initially code *)
393 :     fun cvtInitially (env, S.Initially{isArray, rangeInit, create, iters}) = let
394 :     val S.C_Create{argInit, name, args} = create
395 :     fun cvtIter ({param, lo, hi}, (env, iters)) = let
396 :     val param' = newVar param
397 :     val env = VMap.insert (env, param, param')
398 :     val iter = (param', lookup env lo, lookup env hi)
399 : jhr 256 in
400 : jhr 1116 (env, iter::iters)
401 : jhr 256 end
402 : jhr 1116 val (cfg, env) = cvtFragmentBlock (env, rangeInit)
403 :     val (env, iters) = List.foldl cvtIter (env, []) iters
404 :     val (argInitCFG, env) = cvtFragmentBlock (env, argInit)
405 : jhr 256 in
406 : jhr 1116 IL.Initially{
407 :     isArray = isArray,
408 :     rangeInit = cfg,
409 :     iters = List.rev iters,
410 :     create = (argInitCFG, name, List.map (lookup env) args)
411 :     }
412 : jhr 256 end
413 :    
414 : jhr 1640 (* check strands for properties *)
415 :     fun checkProps strands = let
416 :     val hasDie = ref false
417 :     val hasNew = ref false
418 :     fun chkStm e = (case e
419 :     of S.S_IfThenElse(_, b1, b2) => (chkBlk b1; chkBlk b2)
420 :     | S.S_New _ => (hasNew := true)
421 :     | S.S_Die => (hasDie := true)
422 :     | _ => ()
423 :     (* end case *))
424 :     and chkBlk (S.Block body) = List.app chkStm body
425 :     fun chkStrand (S.Strand{stateInit, methods, ...}) = let
426 :     fun chkMeth (S.Method(_, body)) = chkBlk body
427 :     in
428 :     chkBlk stateInit;
429 :     List.app chkMeth methods
430 :     end
431 :     fun condCons (x, v, l) = if !x then v::l else l
432 :     in
433 :     List.app chkStrand strands;
434 :     condCons (hasDie, StrandUtil.StrandsMayDie,
435 :     condCons (hasNew, StrandUtil.NewStrands, []))
436 :     end
437 :    
438 : jhr 1116 fun translate (S.Program{globals, globalInit, init, strands}) = let
439 : jhr 1640 val (globalInit, env) = let
440 :     fun mkExit env = let
441 :     val nd = IL.Node.mkRETURN(VMap.listItems env)
442 :     in
443 :     IL.CFG{entry = nd, exit = nd}
444 :     end
445 :     in
446 :     cvtTopLevelBlock (VMap.empty, globalInit, mkExit)
447 :     end
448 : jhr 1116 (* construct a reduced environment that just defines the globals. *)
449 :     val env = let
450 : jhr 200 val lookup = lookup env
451 : jhr 1116 fun cvtVar (x, env) = VMap.insert(env, x, lookup x)
452 :     val env = List.foldl cvtVar VMap.empty globals
453 : jhr 200 in
454 : jhr 1116 env
455 : jhr 200 end
456 : jhr 1116 val init = cvtInitially (env, init)
457 : jhr 511 fun cvtStrand (S.Strand{name, params, state, stateInit, methods}) = let
458 : jhr 1232 (* extend the global environment with the strand's parameters *)
459 : jhr 200 val (env, params) = let
460 :     fun cvtParam (x, (env, xs)) = let
461 :     val x' = newVar x
462 :     in
463 :     (VMap.insert(env, x, x'), x'::xs)
464 :     end
465 :     val (env, params) = List.foldl cvtParam (env, []) params
466 :     in
467 :     (env, List.rev params)
468 :     end
469 : jhr 1640 (* create the state variables *)
470 :     val svars = let
471 :     fun newSVar x = IL.StateVar.new (
472 :     Var.kindOf x = S.StrandOutputVar,
473 :     Var.nameOf x, cvtTy(Var.monoTypeOf x))
474 :     in
475 :     List.map newSVar state
476 :     end
477 : jhr 1232 (* convert the state initialization code *)
478 :     val (stateInit, env) = let
479 : jhr 1640 fun mkExit env = saveStrandState (env, (state, svars), IL.Node.mkSINIT())
480 : jhr 1232 in
481 :     cvtTopLevelBlock (env, stateInit, mkExit)
482 :     end
483 : jhr 1640 fun cvtMeth (S.Method(name, blk)) = cvtMethod (env, name, state, svars, blk)
484 : jhr 200 in
485 : jhr 511 IL.Strand{
486 : jhr 200 name = name,
487 :     params = params,
488 : jhr 1640 state = svars,
489 : jhr 200 stateInit = stateInit,
490 : jhr 1116 methods = List.map cvtMeth methods
491 : jhr 200 }
492 :     end
493 : jhr 511 val prog = IL.Program{
494 : jhr 1640 props = checkProps strands,
495 : jhr 1116 globalInit = globalInit,
496 :     initially = init,
497 :     strands = List.map cvtStrand strands
498 :     }
499 : jhr 511 in
500 :     Census.init prog;
501 :     prog
502 : jhr 200 end
503 : jhr 176
504 : jhr 137 end

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