13 |
end = struct |
end = struct |
14 |
|
|
15 |
structure SrcIL = HighIL |
structure SrcIL = HighIL |
16 |
structure SrcOp = SrcIL.Op |
structure SrcOp = HighOps |
17 |
structure DstIL = MidIL |
structure DstIL = MidIL |
18 |
structure DstOp = DstIL.Op |
structure DstOp = MidOps |
19 |
structure VMap = SrcIL.Var.Map |
structure VMap = SrcIL.Var.Map |
20 |
|
|
21 |
|
fun lookupVar (env, x) = (case VMap.find(env, x) |
22 |
|
of SOME x' => x' |
23 |
|
| NONE => raise Fail("unknown variable "^SrcIL.Var.toString x) |
24 |
|
(* end case *)) |
25 |
|
|
26 |
(* expand the field Inside operator into a image-space test *) |
(* expand the field Inside operator into a image-space test *) |
27 |
fun expandInside (env, result, pos, fld) = let |
fun expandInside (env, result, pos, fld) = let |
28 |
val pos' = lookupVar (env, pos) |
val pos' = lookupVar (env, pos) |
31 |
| _ => raise Fail "bogus field binding" |
| _ => raise Fail "bogus field binding" |
32 |
(* end case *)) |
(* end case *)) |
33 |
fun expand (FieldDef.CONV(_, img, _)) = let |
fun expand (FieldDef.CONV(_, img, _)) = let |
34 |
val imgPos = newVar "x" |
val imgPos = DstIL.Var.new "x" |
35 |
in [ |
in [ |
36 |
(imgPos, DstIL.OP(DstOp.Transform img, [pos'])), |
(imgPos, DstIL.OP(DstOp.Transform img, [pos'])), |
37 |
(result, DstIL.OP(DstOp.Inside img, [imgPos])) |
(result, DstIL.OP(DstOp.Inside img, [imgPos])) |
42 |
expand fld |
expand fld |
43 |
end |
end |
44 |
|
|
45 |
|
val expandProbe = Probe.expand |
46 |
|
|
47 |
fun translate prog = raise Fail "FIXME" |
fun translate prog = raise Fail "FIXME" |
48 |
|
|
49 |
end |
end |