(* test.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. * * Test driver to the generation of probe code *) structure Test = struct structure II = ImageInfo structure FD = FieldDef structure K = Kernel structure DstIL = MidIL structure PP = SSAPPFn(DstIL) local structure VSet = DstIL.Var.Set in fun checkCode (result, code, pos) = let fun checkVar bvs x = if VSet.member(bvs, x) then () else print(concat["variable ", DstIL.Var.toString x, " used before definition\n"]) fun chkAssign ((y, rhs), bvs) = ( case rhs of DstIL.VAR x => checkVar bvs x | DstIL.LIT _ => () | DstIL.OP(_, xs) => List.app (checkVar bvs) xs | DstIL.CONS xs => List.app (checkVar bvs) xs (* end case *); VSet.add (bvs, y)) val bvs = List.foldl chkAssign (VSet.singleton pos) code in checkVar bvs result end end fun expand fld = let val result = DstIL.Var.new "result" val pos = DstIL.Var.new "pos" val code = Probe.expand (result, fld, pos) in print(concat["expand (", FD.toString fld, "):\n"]); List.app (fn s => print("\t" ^ PP.assignToString s ^ "\n")) code; checkCode (result, code, pos) end (* fake 2D image info *) val img2d = II.ImgInfo{ id = OS.FileSys.fileId "/dev/null", dim = 2, ty = ([], RawTypes.RT_Float), origin = [], sizes = [] } (* fake 3D image info *) val img3d = II.ImgInfo{ id = OS.FileSys.fileId "/dev/null", dim = 3, ty = ([], RawTypes.RT_Float), origin = [], sizes = [] } val fld2d = FD.convolve(img2d, K.bspln3) val fld2d' = FD.diff(FD.convolve(img2d, K.bspln3)) val fld3d = FD.convolve(img3d, K.bspln3) end