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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (view) (download)
Original Path: trunk/src/ast/types.sml

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 61 (* raw numeric types as supported by NRRD *)
20 :     datatype raw_ty
21 :     = RT_Int8 | RT_UInt8
22 :     | RT_Int16 | RT_UInt16
23 :     | RT_Int32 | RT_UInt32
24 :     | RT_Int64 | RT_UInt64
25 :     | RT_Float | RT_Double
26 :     | RT_Var of var
27 :    
28 : jhr 40 and ty
29 : jhr 61 = T_Var of var
30 :     | T_Bool
31 :     | T_Int
32 : jhr 63 | T_String
33 :     (* convolution kernel; argument is number of levels of differentiation *)
34 :     | T_Kernel of nat
35 :     (* scalars, vectors, matrices, etc.; argument is tensor shape *)
36 :     | T_Tensor of shape
37 : jhr 61 (* data sets from NRRD *)
38 :     | T_Image of {
39 :     dim : nat, (* 2D or 3D data set *)
40 : jhr 63 shape : shape (* tensor shape; order is length of list *)
41 : jhr 61 }
42 :     (* continuous field reconstructed from a data set *)
43 :     | T_Field of {
44 :     diff : nat, (* number of levels of differentiation supported *)
45 : jhr 62 dim : nat, (* dimension of domain (2D or 3D field) *)
46 : jhr 63 shape : shape (* shape of tensors in range; order is length of list *)
47 : jhr 61 }
48 : jhr 63 | T_Fun of ty list * ty list
49 : jhr 40
50 : jhr 63 and shape
51 :     = Shape of nat list
52 :     | ShapeVar of var
53 :     | ShapeExt of shape * nat (* extension of shape (i.e., for D operator) *)
54 :    
55 : jhr 61 and nat
56 :     = NatConst of int (* i *)
57 : jhr 69 | NatExp of (nat * int) (* d + i; for diff fields only *)
58 : jhr 61 | NatVar of var
59 : jhr 40
60 : jhr 61 (* type variables; the kind field restricts their range *)
61 :     and var = TV of {
62 :     kind : kind,
63 :     stamp : Stamp.stamp
64 :     }
65 : jhr 40
66 : jhr 63 type scheme = var list * ty
67 :    
68 : jhr 61 (* useful types *)
69 : jhr 63 val realTy = T_Tensor(Shape[])
70 : jhr 70 fun vecTy n = T_Tensor(Shape[NatConst n])
71 :     val vec2Ty = vecTy 2
72 :     val vec3Ty = vecTy 3
73 :     val vec4Ty = vecTy 4
74 : jhr 40
75 :     end

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