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

SCM Repository

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

Diff of /trunk/src/compiler/simplify/eval.sml

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

revision 1116, Thu May 5 04:49:02 2011 UTC revision 1140, Fri May 6 14:16:00 2011 UTC
# Line 8  Line 8 
8    
9  structure Eval : sig  structure Eval : sig
10    
11      (* raised if there is an error due to faulty code or input values (e.g., loading an
12       * image of the wrong shape.
13       *)
14        exception Error of string list
15    
16      datatype value      datatype value
17        = BV of bool        = BV of bool
18        | SV of string        | SV of string
# Line 27  Line 32 
32      structure VSet = Var.Set      structure VSet = Var.Set
33      structure VTbl = Var.Tbl      structure VTbl = Var.Tbl
34    
35        exception Error of string list
36    
37      datatype value      datatype value
38        = BV of bool        = BV of bool
39        | SV of string        | SV of string
# Line 134  Line 141 
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 d = TypeUtil.resolveDim dim
144              val dd = let
145            val Ty.Shape dd = TypeUtil.resolveShape shp            val Ty.Shape dd = TypeUtil.resolveShape shp
146            val info as ImageInfo.ImgInfo{dim, ...} = ImageInfo.getInfo filename                  fun doDim (Ty.DimConst d) = d
147                      | doDim (Ty.DimVar d) = let val Ty.DimConst d = TypeUtil.resolveDim d in d end
148                    in
149                      List.map doDim dd
150                    end
151              val info as ImageInfo.ImgInfo{dim, ty=(rng, _), ...} = ImageInfo.getInfo filename
152              fun rngToS [] = "real"
153                | rngToS dd = concat["tensor[", String.concatWith "," (List.map Int.toString dd), "]"]
154              fun error msg = raise Error("image file \"" :: filename :: "\" " :: msg)
155            in            in
156            (* check that the expected dimension and actual dimension match *)            (* check that the expected dimension and actual dimension match *)
157              if (d <> dim)              if (d <> dim)
158                then raise Fail(concat["image file \"", filename, "\" has wrong dimension"])                then error ["has dimension ", Int.toString dim, ", expected ", Int.toString d]
               else ();  
159            (* check that the expected shape and actual shape match *)            (* check that the expected shape and actual shape match *)
160  (* FIXME *)              else if not(ListPair.allEq (op =) (dd, rng))
161                  then error ["has range ", rngToS rng, ", expected ", rngToS dd]
162                  else ();
163              info              info
164            end            end
165    
# Line 164  Line 181 
181                       of SOME evalFn => SOME(evalFn (List.map (evalVar env) xs))                       of SOME evalFn => SOME(evalFn (List.map (evalVar env) xs))
182                        | NONE => NONE                        | NONE => NONE
183                      (* end case *))                      (* end case *))
184                  ) handle ex => (                  ) handle ex as Error msg => raise ex
185                           | ex => (
186                    TextIO.output (TextIO.stdErr, concat [                    TextIO.output (TextIO.stdErr, concat [
187                        Var.uniqueNameOf f, "(",                        Var.uniqueNameOf f, "(",
188                        String.concatWith "," (List.map Var.uniqueNameOf xs),                        String.concatWith "," (List.map Var.uniqueNameOf xs),

Legend:
Removed from v.1116  
changed lines
  Added in v.1140

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