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 73, Sun May 23 22:54:59 2010 UTC revision 74, Mon May 24 16:38:42 2010 UTC
# Line 10  Line 10 
10  structure Types =  structure Types =
11    struct    struct
12    
13    (* kinds for type variables *)    (* union type for meta variables and meta-variable bindings *)
14      datatype kind      datatype ('ty, 'diff, 'shape, 'dim) kind
15        = TK_NAT          (* ranges over natural numbers (0, 1, 2, ...) *)        = TYPE of 'ty             (* ranges over types *)
16        | TK_SHAPE        (* ranges over tensor shapes *)        | DIFF of 'diff           (* ranges of differentiation levels (0, 1, ...) *)
17        | TK_TYPE         (* ranges over types *)        | SHAPE of 'shape         (* ranges over tensor shapes *)
18          | DIM of 'dim             (* ranges over dimensions (1, 2, ...) *)
19    
20  (*  (*
21    (* raw numeric types as supported by NRRD *)    (* raw numeric types as supported by NRRD *)
# Line 33  Line 34 
34        | T_Int        | T_Int
35        | T_String        | T_String
36      (* convolution kernel; argument is number of levels of differentiation *)      (* convolution kernel; argument is number of levels of differentiation *)
37        | T_Kernel of nat        | T_Kernel of diff
38      (* scalars, vectors, matrices, etc.; argument is tensor shape *)      (* scalars, vectors, matrices, etc.; argument is tensor shape *)
39        | T_Tensor of shape        | T_Tensor of shape
40      (* data sets from NRRD *)      (* data sets from NRRD *)
41        | T_Image of {        | T_Image of {
42            dim : nat,            (* 2D or 3D data set *)            dim : dim,            (* 2D or 3D data set *)
43            shape : shape         (* tensor shape; order is length of list *)            shape : shape         (* tensor shape; order is length of list *)
44          }          }
45      (* continuous field reconstructed from a data set *)      (* continuous field reconstructed from a data set *)
46        | T_Field of {        | T_Field of {
47            diff : nat,           (* number of levels of differentiation supported *)            diff : diff,          (* number of levels of differentiation supported *)
48            dim : nat,            (* dimension of domain (2D or 3D field) *)            dim : dim,            (* dimension of domain (2D or 3D field) *)
49            shape : shape         (* shape of tensors in range; order is length of list *)            shape : shape         (* shape of tensors in range; order is length of list *)
50          }          }
51        | T_Fun of ty list * ty list        | T_Fun of ty list * ty list
52    
53      (* type variables; the kind field restricts their range *)
54        and ty_var = TV of {
55              id : Stamp.stamp,
56              bind : ty option ref
57            }
58    
59      (* levels of differentiation *)
60        and diff
61          = DiffConst of int                (* i *)
62          | DiffVar of (diff_var * int)     (* d + i (i >= 0) *)
63    
64        and diff_var = DfV of {
65              id : Stamp.stamp,
66              bound : int ref,              (* lower bound of differentiation *)
67              bind : diff option ref
68            }
69    
70      (* tensor shapes *)
71      and shape      and shape
72        = Shape of nat list        = Shape of dim list
73        | ShapeVar of var        | ShapeVar of shape_var
74        | ShapeExt of shape * nat         (* extension of shape (i.e., for D operator) *)        | ShapeExt of shape * nat         (* extension of shape (i.e., for D operator) *)
75    
76      and nat      and shape_var = SV of {
77        = NatConst of int                 (* i *)            id : Stamp.stamp,
78        | NatExp of (nat * int)           (* d + i; for diff fields only *)            bind : shape option ref
79        | NatVar of var          }
80    
81    (* type variables; the kind field restricts their range *)    (* dimensions *)
82      and var = TV of {      and dim
83            kind : kind,        = DimConst of int                 (* i *)
84            stamp : Stamp.stamp        | DimVar of dim_var
85    
86        and dim_var = DV of {
87              id : Stamp.stamp,
88              bind : dim option ref
89          }          }
90    
91      type scheme = var list * ty      type meta_var = (ty_var, diff_var, shape_var, dim_var) kind
92        type var_bind = (ty, diff, shape, dim) kind
93    
94        type scheme = meta_var list * ty
95    
96    (* useful types *)    (* useful types *)
97      val realTy = T_Tensor(Shape[])      val realTy = T_Tensor(Shape[])

Legend:
Removed from v.73  
changed lines
  Added in v.74

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