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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/simplify/eval.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/simplify/eval.sml

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

revision 1685, Sun Jan 22 15:23:36 2012 UTC revision 1793, Thu Apr 5 09:53:28 2012 UTC
# Line 140  Line 140 
140            end            end
141    
142      fun loadImage ([Ty.DIM dim, Ty.SHAPE shp], SV filename) = let      fun loadImage ([Ty.DIM dim, Ty.SHAPE shp], SV filename) = let
143            val Ty.DimConst d = TypeUtil.resolveDim dim            val Ty.DimConst dim = TypeUtil.resolveDim dim
144            val dd = let            val dd = let
145                  val Ty.Shape dd = TypeUtil.resolveShape shp                  val Ty.Shape dd = TypeUtil.resolveShape shp
146                  fun doDim (Ty.DimConst d) = d                  fun doDim (Ty.DimConst d) = d
# Line 148  Line 148 
148                  in                  in
149                    List.map doDim dd                    List.map doDim dd
150                  end                  end
151            val info as ImageInfo.ImgInfo{dim, ty=(rng, _), ...} = ImageInfo.getInfo filename            val nrrd = NrrdInfo.getInfo filename
152              in
153                case ImageInfo.mkInfo (nrrd, dim, dd)
154                 of SOME info => info
155                  | NONE => let
156            fun rngToS [] = "real"            fun rngToS [] = "real"
157              | rngToS dd = concat["tensor[", String.concatWith "," (List.map Int.toString dd), "]"]              | rngToS dd = concat["tensor[", String.concatWith "," (List.map Int.toString dd), "]"]
158            fun error msg = raise Error("image file \"" :: filename :: "\" " :: msg)            fun error msg = raise Error("image file \"" :: filename :: "\" " :: msg)
159            in            in
160            (* check that the expected dimension and actual dimension match *)                    (* figure out what the mismatch is *)
161              if (d <> dim)                      if (NrrdInfo.dim nrrd <> dim)
162                then error ["has dimension ", Int.toString dim, ", expected ", Int.toString d]                        then error [
163            (* check that the expected shape and actual shape match *)                            "has dimension ", Int.toString(NrrdInfo.dim nrrd),
164              else if not(ListPair.allEq (op =) (dd, rng))                            ", expected ", Int.toString dim
165                then error ["has range ", rngToS rng, ", expected ", rngToS dd]                          ]
166                else ();                        else error ["has unexpected range ", rngToS dd]
167              info                    end
168                (* end case *)
169            end            end
170    
171      fun evalVar env x = (case VMap.find (env, x)      fun evalVar env x = (case VMap.find (env, x)

Legend:
Removed from v.1685  
changed lines
  Added in v.1793

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