16 |
|
|
17 |
structure PP = SSAPPFn(DstIL) |
structure PP = SSAPPFn(DstIL) |
18 |
|
|
19 |
|
local |
20 |
|
structure VSet = DstIL.Var.Set |
21 |
|
in |
22 |
|
fun checkCode (result, code, pos) = let |
23 |
|
fun checkVar bvs x = if VSet.member(bvs, x) |
24 |
|
then () |
25 |
|
else print(concat["variable ", DstIL.Var.toString x, " used before definition\n"]) |
26 |
|
fun chkAssign ((y, rhs), bvs) = ( |
27 |
|
case rhs |
28 |
|
of DstIL.VAR x => checkVar bvs x |
29 |
|
| DstIL.LIT _ => () |
30 |
|
| DstIL.OP(_, xs) => List.app (checkVar bvs) xs |
31 |
|
| DstIL.CONS xs => List.app (checkVar bvs) xs |
32 |
|
(* end case *); |
33 |
|
VSet.add (bvs, y)) |
34 |
|
val bvs = List.foldl chkAssign (VSet.singleton pos) code |
35 |
|
in |
36 |
|
checkVar bvs result |
37 |
|
end |
38 |
|
end |
39 |
|
|
40 |
fun expand fld = let |
fun expand fld = let |
41 |
val code = Probe.expand (DstIL.Var.new "result", fld, DstIL.Var.new "pos") |
val result = DstIL.Var.new "result" |
42 |
|
val pos = DstIL.Var.new "pos" |
43 |
|
val code = Probe.expand (result, fld, pos) |
44 |
in |
in |
45 |
print(concat["expand (", FD.toString fld, "):\n"]); |
print(concat["expand (", FD.toString fld, "):\n"]); |
46 |
List.app (fn s => print("\t" ^ PP.assignToString s ^ "\n")) code |
List.app (fn s => print("\t" ^ PP.assignToString s ^ "\n")) code; |
47 |
|
checkCode (result, code, pos) |
48 |
end |
end |
49 |
|
|
50 |
(* fake 2D image info *) |
(* fake 2D image info *) |