Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/c-util/gen-inputs.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/c-util/gen-inputs.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2707, Sat Sep 20 15:11:18 2014 UTC revision 2708, Sat Sep 20 18:46:49 2014 UTC
# Line 50  Line 50 
50      val nrrdPtrTy = CL.T_Ptr(CL.T_Named "Nrrd")      val nrrdPtrTy = CL.T_Ptr(CL.T_Named "Nrrd")
51      val wrldPrefixTy = CL.T_Ptr(CL.T_Named "WorldPrefix_t")      val wrldPrefixTy = CL.T_Ptr(CL.T_Named "WorldPrefix_t")
52    
53      (* world pointer cast to the world prefix type *)
54        val wrldPrefix = CL.mkCast(wrldPrefixTy, CL.mkVar "wrld")
55    
56      type props = Properties.props      type props = Properties.props
57    
58    (* translate a TreeIL type to the C types used to represent it in the external API *)    (* translate a TreeIL type to the C types used to represent it in the external API *)
# Line 104  Line 107 
107                      in                      in
108                        lp(0, es)                        lp(0, es)
109                      end                      end
110                    | (Ty.DynSeqTy _, _) => simpleInit ()
111                  | _ => raise Fail(concat["CTyTranslate.initC(", Ty.toString ty, ") not supported yet"])                  | _ => raise Fail(concat["CTyTranslate.initC(", Ty.toString ty, ") not supported yet"])
112                (* end case *)                (* end case *)
113              end              end
# Line 162  Line 166 
166          (* some common variables *)          (* some common variables *)
167            val inpV = CL.mkVar "inp"            val inpV = CL.mkVar "inp"
168            val optsV = CL.mkVar "opts"            val optsV = CL.mkVar "opts"
169            (* set to true if the initialization code uses a status variable *)
170              val usesStatus = ref false
171          (* initialize a given input global; for sequences and images, this requires          (* initialize a given input global; for sequences and images, this requires
172           * loading the value from the specified nrrd file, while for other types           * loading the value from the specified nrrd file, while for other types
173           * we just copy the values.           * we just copy the values.
174           *)           *)
175            fun initInput ((Ty.DynSeqTy elemTy, name, desc, optDflt), stms) = CL.mkCall("dummy", [            fun initInput ((Ty.DynSeqTy elemTy, name, desc, optDflt), stms) = let
176                    optsV, CL.mkStr name, CL.mkStr(Option.getOpt(desc, "")),                  val (loadFn, nDims, dims) = (case elemTy
177                    CL.mkUnOp(CL.%&, global name),                         of Ty.BoolTy => ("Diderot_DynSeqLoadBoolFromFile", CL.mkInt 0, CL.mkInt 0)
178                    CL.mkBool(Option.isSome optDflt)                          | Ty.IntTy => ("Diderot_DynSeqLoadIntFromFile", CL.mkInt 0, CL.mkInt 0)
179                  ]) :: stms                          | Ty.TensorTy[] => ("Diderot_DynSeqLoadRealFromFile", CL.mkInt 0, CL.mkInt 0)
180              | initInput ((Ty.ImageTy info, name, desc, optDflt), stms) = CL.mkCall("dummy", [                          | Ty.TensorTy _ => raise Fail "TODO: sequences of tensors"
181                    optsV, CL.mkStr name, CL.mkStr(Option.getOpt(desc, "")),                          | Ty.SeqTy elemTy => raise Fail "TODO: sequences of sequences"
182                    CL.mkUnOp(CL.%&, global name),                          | _ => raise Fail "unsupported dynamic sequence type"
183                    CL.mkBool(Option.isSome optDflt)                        (* end case *))
184                    in
185                      CL.mkAssign(global name,
186                        CL.mkApply(loadFn, [
187                            wrldPrefix, CL.mkIndirect(inpV, name), nDims, dims
188                          ])) :: stms
189                    end
190                | initInput ((Ty.ImageTy info, name, desc, optDflt), stms) = let
191                    val loadFn = (case ImageInfo.dim info
192                           of 1 => "Diderot_LoadImage1D"
193                            | 2 => "Diderot_LoadImage2D"
194                            | 3 => "Diderot_LoadImage3D"
195                            | _ => raise Fail "image with dimension > 3"
196                          (* end case *))
197                    in
198                      CL.mkCall(loadFn, [
199                          wrldPrefix, CL.mkIndirect(inpV, name), CL.mkAddrOf(global name)
200                  ]) :: stms                  ]) :: stms
201                    end
202              | initInput ((ty, name, _, _), stms) =              | initInput ((ty, name, _, _), stms) =
203                  TrTy.copyFromC{ty=ty, dst=global name, src=CL.mkIndirect(inpV, name)} @ stms                  TrTy.copyFromC{ty=ty, dst=global name, src=CL.mkIndirect(inpV, name)} @ stms
204            in            in

Legend:
Removed from v.2707  
changed lines
  Added in v.2708

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0