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

SCM Repository

[diderot] Diff of /trunk/src/compiler/ast/types.sml
ViewVC logotype

Diff of /trunk/src/compiler/ast/types.sml

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

revision 40, Wed Mar 3 14:51:38 2010 UTC revision 61, Tue May 11 16:02:48 2010 UTC
# Line 9  Line 9 
9  structure Types =  structure Types =
10    struct    struct
11    
12      (* kinds for type variables *)
13      datatype kind      datatype kind
14        = ScalarKind        = TK_NAT          (* ranges over natural numbers (0, 1, 2, ...) *)
15        | TypeKind        | TK_INT          (* ranges over integer types *)
16          | TK_FLT          (* ranges over floating-point types *)
17          | TK_RAW          (* ranges over raw (scalar) types *)
18          | TK_TYPE         (* ranges over types *)
19    (* Question: do we want kinds for tensors of different orders (e.g., TK_TENSOR of word?);
20     * Then TK_RAW would be TK_TENSOR of 0w0.
21     *)
22    
23      (* raw numeric types as supported by NRRD *)
24        datatype raw_ty
25          = RT_Int8 | RT_UInt8
26          | RT_Int16 | RT_UInt16
27          | RT_Int32 | RT_UInt32
28          | RT_Int64 | RT_UInt64
29          | RT_Float | RT_Double
30          | RT_Var of var
31    
32      and ty      and ty
33        = TyVar of ty_var        = T_Var of var
34        | TyBool        | T_Bool
35        | TyInt        | T_Int
36        | TyReal      (* scalars, vectors, matrices, etc. *)
37        | TyString        | T_Tensor of nat list    (* tensor shape *)
38        | TyKernel of {diff : dim}      (* data sets from NRRD *)
39        | TyField of {diff : dim, order : dim list, dim : dim}        | T_Image of {
40        | TyTensor of {order : dim list}            dim : nat,            (* 2D or 3D data set *)
41        | TyImage of {order : dim list, dim : dim}            shape : nat list      (* tensor shape; order is length of list *)
42        | TyArray of ty * dim list          }
43        (* continuous field reconstructed from a data set *)
44      and dim        | T_Field of {
45        = DimConst of int                 (* i *)            diff : nat,           (* number of levels of differentiation supported *)
46        | DimExp of (dim * int)           (* d + i *)            dim : nat,            (* 2D or 3D field *)
47        | DimVar of dim_var            shape : nat list      (* tensor shape; order is length of list *)
48            }
49      fun dimToString (DimConst of n) = Int.toString n  
50        | dimToString (DimExp(d, n)) =      and nat
51            if (n < 0)        = NatConst of int                 (* i *)
52              then concat[dimToString d, "-", Int.toString(~n)]        | NatExp of (nat * int)           (* d + i *)
53              else concat[dimToString d, "+", Int.toString n]        | NatVar of var
54        | dimToString (DimVar dv) = ??  
55      (* type variables; the kind field restricts their range *)
56      fun toString ty = (case ty      and var = TV of {
57             of TyVar tv => ??            kind : kind,
58              | TyBool => "bool"            stamp : Stamp.stamp
59              | TyInt => "int"          }
60              | TyReal => "real"  
61              | TyString => "string"    (* useful types *)
62              | TyKernel{diff} => "kernel#" ^ dimToString diff      val realTy = T_Tensor[]
63              | TyField{diff, order, dim} =>      fun vec2Ty = T_Tensor[NatConst 2]
64              | TyTensor{order, dim} =>      fun vec3Ty = T_Tensor[NatConst 3]
65              | TyArray(ty, dim) =>      fun vec4Ty = T_Tensor[NatConst 4]
           (* end case *))  
66    
67    end    end

Legend:
Removed from v.40  
changed lines
  Added in v.61

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