42 |
structure Ty = TreeIL.Ty |
structure Ty = TreeIL.Ty |
43 |
structure CL = CLang |
structure CL = CLang |
44 |
structure N = CNames |
structure N = CNames |
45 |
|
structure ToC = TreeToC |
46 |
structure TrTy = CTyTranslate |
structure TrTy = CTyTranslate |
47 |
|
|
48 |
type input_desc = (Ty.ty * string * string option * IL.exp option) |
type input_desc = (Ty.ty * string * string option * IL.exp option) |
200 |
(* the inputs pointer type *) |
(* the inputs pointer type *) |
201 |
fun check (ty, name, _, optDflt) = let |
fun check (ty, name, _, optDflt) = let |
202 |
val dfltStm = (case optDflt |
val dfltStm = (case optDflt |
203 |
of SOME v => CL.mkBlock[] (* FIXME: set global to default value *) |
of SOME v => (case ty |
204 |
|
of Ty.DynSeqTy _ => raise Fail "DynSeqTy" |
205 |
|
| Ty.ImageTy info => |
206 |
|
GenLoadNrrd.loadImage (global name, info, ToC.trExp(ToC.empty, v)) |
207 |
|
| _ => CL.mkBlock(ToC.trAssign(ToC.empty, global name, v)) |
208 |
|
(* end case *)) |
209 |
| NONE => CL.mkBlock[ |
| NONE => CL.mkBlock[ |
210 |
World.errorMsgAdd(CL.mkStr(concat["undefined input \"", name, "\"\n"])), |
World.errorMsgAdd(CL.mkStr(concat["undefined input \"", name, "\"\n"])), |
211 |
CL.mkReturn(SOME(CL.mkBool true)) |
CL.mkReturn(SOME(CL.mkBool true)) |
267 |
CL.D_Func( |
CL.D_Func( |
268 |
[], CL.boolTy, N.inputSetByName(tgt, name), |
[], CL.boolTy, N.inputSetByName(tgt, name), |
269 |
[wrldParam, CL.PARAM(["const"], CL.charPtr, "s")], |
[wrldParam, CL.PARAM(["const"], CL.charPtr, "s")], |
270 |
CL.mkBlock[ |
CL.appendStm( |
271 |
(* FIXME: we should also generate code to check that the loaded image has the right type, etc. *) |
GenLoadNrrd.loadImage (global name, info, CL.mkVar "s"), |
272 |
CL.mkReturn(SOME( |
CL.mkReturn(SOME(CL.mkBool false)))), |
|
CL.mkBinOp(CL.mkVar "DIDEROT_FAIL", CL.#==, |
|
|
CL.mkApply(N.loadImage dim, [ |
|
|
CL.mkCast(wrldPrefixTy, CL.mkVar "wrld"), |
|
|
CL.mkVar "s", CL.mkUnOp(CL.%&, global name) |
|
|
])))) |
|
|
]), |
|
273 |
CL.D_Func( |
CL.D_Func( |
274 |
[], CL.boolTy, N.inputSet(tgt, name), |
[], CL.boolTy, N.inputSet(tgt, name), |
275 |
[wrldParam, CL.PARAM([], nrrdPtrTy, "nin")], |
[wrldParam, CL.PARAM([], nrrdPtrTy, "nin")], |
276 |
CL.mkBlock[ |
CL.appendStm( |
277 |
(* FIXME: we should also generate code to check that the loaded image has the right type, etc. *) |
GenLoadNrrd.setImage (global name, info, CL.mkVar "nin"), |
278 |
CL.mkReturn(SOME( |
CL.mkReturn(SOME(CL.mkBool false)))) |
|
CL.mkBinOp(CL.mkVar "DIDEROT_FAIL", CL.#==, |
|
|
CL.mkApply(N.setImage dim, [ |
|
|
CL.mkCast(wrldPrefixTy, CL.mkVar "wrld"), |
|
|
CL.mkVar "nin", CL.mkUnOp(CL.%&, global name) |
|
|
])))) |
|
|
]) |
|
279 |
] end |
] end |
280 |
(* dynamic sequence loader prototype: |
(* dynamic sequence loader prototype: |
281 |
Diderot_DynSeq_t *Diderot_DynSeqLoadTY ( |
Diderot_DynSeq_t *Diderot_DynSeqLoadTY ( |