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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/cxx-util/gen-load-nrrd.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/cxx-util/gen-load-nrrd.sml

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

revision 3894, Sun May 22 14:51:27 2016 UTC revision 3906, Mon May 23 22:09:41 2016 UTC
# Line 8  Line 8 
8    
9  structure GenLoadNrrd : sig  structure GenLoadNrrd : sig
10    
11    (* loadImage (lhs, dim, name)    (* loadImage (img, arg)
12     *    returns code to load an image from a Nrrd file, where "lhs" is the l-value to hold     *    returns code to load an image from either a Nrrd file or an in-memory Nrrd, where
13     *    the image, "dim" specifies the dimension of the image format, and "name" specifies     *    "lhs" is the image object and arg specifies either the file or nrrd.
14     *    the file name.  The generated code check the status of the load attempt and will     *    The generated code check the status of the load attempt and will return "true"
15     *    return "true" (i.e., error) if the load fails.     *    (i.e., error) if the load fails.
16     *)     *)
17      val loadImage : CLang.exp * int * CLang.exp -> CLang.stm      val loadImage : CLang.exp * CLang.exp -> CLang.stm
   
   (* setImage (lhs, info, nrrd)  
    *    returns code to initialize an image from a Nrrd, where "lhs" is the l-value to hold  
    *    the image, "dim" specifies the dimension of the image format, and "nrrd" specifies  
    *    the nrrd.  The generated code check the status of the initialization and will  
    *    return "true" (i.e., error) if the load fails.  
    *)  
     val setImage : CLang.exp * int * CLang.exp -> CLang.stm  
18    
19      val loadSeqFromFile : CLang.exp * APITypes.t * CLang.exp -> CLang.stm      val loadSeqFromFile : CLang.exp * APITypes.t * CLang.exp -> CLang.stm
20      val loadSeq : CLang.exp * APITypes.t * CLang.exp -> CLang.stm      val loadSeq : CLang.exp * APITypes.t * CLang.exp -> CLang.stm
# Line 30  Line 22 
22    end = struct    end = struct
23    
24      structure CL = CLang      structure CL = CLang
25      structure RN = RuntimeNames      structure RN = CxxNames
26      structure Ty = APITypes      structure Ty = APITypes
27    
28      val wrldPrefixTy = CL.T_Ptr(CL.T_Named "WorldBase")      val wrldPrefixTy = CL.T_Ptr(CL.T_Named "WorldBase")
29    
30      fun doImage imageFn (lhs, dim, arg) = let      fun loadImage (img, arg) = let
31            val loadExp = CL.mkApply(imageFn dim, [            val loadExp = CL.mkApplyExp(CL.mkSelect(img, "load"), [CL.mkVar "wrld", arg])
                   CL.mkCast(wrldPrefixTy, CL.mkVar "wrld"),  
                   arg,  
                   CL.mkUnOp(CL.%&, lhs)  
                 ])  
32            in            in
33  (* FIXME: we should also generate code to check that the loaded image has the right type, etc. *)  (* FIXME: we should also generate code to check that the loaded image has the right type, etc. *)
34              CL.mkIfThen(loadExp, CL.mkReturn(SOME(CL.mkVar "true")))              CL.mkIfThen(loadExp, CL.mkReturn(SOME(CL.mkVar "true")))
35            end            end
36    
     val loadImage = doImage RN.loadImage  
     val setImage = doImage RN.setImage  
   
37      fun doSeq loadFn (lhs, elemTy, arg) = let      fun doSeq loadFn (lhs, elemTy, arg) = let
38            val (nDims, dimInit, dimExp, elemTy) = (case elemTy            val (nDims, dimInit, dimExp, elemTy) = (case elemTy
39                   of Ty.TensorTy(dims as _::_) => let                   of Ty.TensorTy(dims as _::_) => let

Legend:
Removed from v.3894  
changed lines
  Added in v.3906

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