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 61 - (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 :     * Internal representation of Diderot types
7 :     *)
8 :    
9 :     structure Types =
10 :     struct
11 :    
12 : jhr 61 (* kinds for type variables *)
13 : jhr 40 datatype kind
14 : jhr 61 = TK_NAT (* ranges over natural numbers (0, 1, 2, ...) *)
15 :     | 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 : jhr 40
23 : jhr 61 (* 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 : jhr 40 and ty
33 : jhr 61 = T_Var of var
34 :     | T_Bool
35 :     | T_Int
36 :     (* scalars, vectors, matrices, etc. *)
37 :     | T_Tensor of nat list (* tensor shape *)
38 :     (* data sets from NRRD *)
39 :     | T_Image of {
40 :     dim : nat, (* 2D or 3D data set *)
41 :     shape : nat list (* tensor shape; order is length of list *)
42 :     }
43 :     (* continuous field reconstructed from a data set *)
44 :     | T_Field of {
45 :     diff : nat, (* number of levels of differentiation supported *)
46 :     dim : nat, (* 2D or 3D field *)
47 :     shape : nat list (* tensor shape; order is length of list *)
48 :     }
49 : jhr 40
50 : jhr 61 and nat
51 :     = NatConst of int (* i *)
52 :     | NatExp of (nat * int) (* d + i *)
53 :     | NatVar of var
54 : jhr 40
55 : jhr 61 (* type variables; the kind field restricts their range *)
56 :     and var = TV of {
57 :     kind : kind,
58 :     stamp : Stamp.stamp
59 :     }
60 : jhr 40
61 : jhr 61 (* useful types *)
62 :     val realTy = T_Tensor[]
63 :     fun vec2Ty = T_Tensor[NatConst 2]
64 :     fun vec3Ty = T_Tensor[NatConst 3]
65 :     fun vec4Ty = T_Tensor[NatConst 4]
66 : jhr 40
67 :     end

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