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

SCM Repository

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

Annotation of /trunk/src/ast/types.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 73 - (view) (download)

1 : jhr 40 (* types.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *
6 : jhr 63 * Internal representation of Diderot types. These are the types produced
7 :     * by the type checker.
8 : jhr 40 *)
9 :    
10 :     structure Types =
11 :     struct
12 :    
13 : jhr 61 (* kinds for type variables *)
14 : jhr 40 datatype kind
15 : jhr 61 = TK_NAT (* ranges over natural numbers (0, 1, 2, ...) *)
16 : jhr 63 | TK_SHAPE (* ranges over tensor shapes *)
17 : jhr 61 | TK_TYPE (* ranges over types *)
18 : jhr 40
19 : jhr 73 (*
20 : jhr 61 (* raw numeric types as supported by NRRD *)
21 :     datatype raw_ty
22 :     = RT_Int8 | RT_UInt8
23 :     | RT_Int16 | RT_UInt16
24 :     | RT_Int32 | RT_UInt32
25 :     | RT_Int64 | RT_UInt64
26 :     | RT_Float | RT_Double
27 :     | RT_Var of var
28 : jhr 73 *)
29 : jhr 61
30 : jhr 73 datatype ty
31 : jhr 61 = T_Var of var
32 :     | T_Bool
33 :     | T_Int
34 : jhr 63 | T_String
35 :     (* convolution kernel; argument is number of levels of differentiation *)
36 :     | T_Kernel of nat
37 :     (* scalars, vectors, matrices, etc.; argument is tensor shape *)
38 :     | T_Tensor of shape
39 : jhr 61 (* data sets from NRRD *)
40 :     | T_Image of {
41 :     dim : nat, (* 2D or 3D data set *)
42 : jhr 63 shape : shape (* tensor shape; order is length of list *)
43 : jhr 61 }
44 :     (* continuous field reconstructed from a data set *)
45 :     | T_Field of {
46 :     diff : nat, (* number of levels of differentiation supported *)
47 : jhr 62 dim : nat, (* dimension of domain (2D or 3D field) *)
48 : jhr 63 shape : shape (* shape of tensors in range; order is length of list *)
49 : jhr 61 }
50 : jhr 63 | T_Fun of ty list * ty list
51 : jhr 40
52 : jhr 63 and shape
53 :     = Shape of nat list
54 :     | ShapeVar of var
55 :     | ShapeExt of shape * nat (* extension of shape (i.e., for D operator) *)
56 :    
57 : jhr 61 and nat
58 :     = NatConst of int (* i *)
59 : jhr 69 | NatExp of (nat * int) (* d + i; for diff fields only *)
60 : jhr 61 | NatVar of var
61 : jhr 40
62 : jhr 61 (* type variables; the kind field restricts their range *)
63 :     and var = TV of {
64 :     kind : kind,
65 :     stamp : Stamp.stamp
66 :     }
67 : jhr 40
68 : jhr 63 type scheme = var list * ty
69 :    
70 : jhr 61 (* useful types *)
71 : jhr 63 val realTy = T_Tensor(Shape[])
72 : jhr 70 fun vecTy n = T_Tensor(Shape[NatConst n])
73 :     val vec2Ty = vecTy 2
74 :     val vec3Ty = vecTy 3
75 :     val vec4Ty = vecTy 4
76 : jhr 40
77 :     end

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