236 |
IL.Node.addEdge (IL.CFG.exit cfg1, joinNd)); |
IL.Node.addEdge (IL.CFG.exit cfg1, joinNd)); |
237 |
cvt ( |
cvt ( |
238 |
env, |
env, |
239 |
IL.CFG{entry = IL.CFG.entry cfg, exit = joinNd}, |
IL.CFG.concat ( |
240 |
|
cfg, |
241 |
|
IL.CFG{entry = cond, exit = joinNd}), |
242 |
stms)) |
stms)) |
243 |
(* the join node has only zero predecessors, so |
(* the join node has only zero predecessors, so |
244 |
* it was killed. |
* it was killed. |
267 |
in |
in |
268 |
cvt (env, IL.CFG.empty, stms) |
cvt (env, IL.CFG.empty, stms) |
269 |
end |
end |
270 |
|
(*DEBUG*)handle ex => raise ex |
271 |
|
|
272 |
fun cvtTopLevelBlock (env, blk, mkExit) = let |
fun cvtTopLevelBlock (env, blk, mkExit) = let |
273 |
val (cfg, env) = cvtBlock ([], env, [], blk) |
val (cfg, env) = cvtBlock ([], env, [], blk) |
284 |
IL.Node.addEdge (IL.CFG.exit cfg, exit) handle _ => ()); |
IL.Node.addEdge (IL.CFG.exit cfg, exit) handle _ => ()); |
285 |
(IL.CFG{entry = entry, exit = exit}, env) |
(IL.CFG{entry = entry, exit = exit}, env) |
286 |
end |
end |
287 |
|
(*DEBUG*)handle ex => raise ex |
288 |
|
|
289 |
(* FIXME: the following function could be refactored with cvtTopLevelBlock to share code *) |
(* FIXME: the following function could be refactored with cvtTopLevelBlock to share code *) |
290 |
fun cvtFragmentBlock (env0, blk) = let |
fun cvtFragmentBlock (env0, blk) = let |
303 |
IL.Node.addEdge (IL.CFG.exit cfg, exit)); |
IL.Node.addEdge (IL.CFG.exit cfg, exit)); |
304 |
(IL.CFG{entry = entry, exit = exit}, env) |
(IL.CFG{entry = entry, exit = exit}, env) |
305 |
end |
end |
306 |
|
(*DEBUG*)handle ex => raise ex |
307 |
|
|
308 |
fun cvtMethod (env, name, state, blk) = let |
fun cvtMethod (env, name, state, blk) = let |
309 |
(* allocate fresh variables for the state variables *) |
(* allocate fresh variables for the state variables *) |
329 |
body = IL.CFG{entry = entry, exit = exit} |
body = IL.CFG{entry = entry, exit = exit} |
330 |
} |
} |
331 |
end |
end |
332 |
|
(*DEBUG*)handle ex => (print(concat["error in cvtMethod(", Atom.toString name, ", ...)\n"]); raise ex) |
333 |
|
|
334 |
(* convert the initially code *) |
(* convert the initially code *) |
335 |
fun cvtInitially (env, S.Initially{isArray, rangeInit, create, iters}) = let |
fun cvtInitially (env, S.Initially{isArray, rangeInit, create, iters}) = let |