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 40 - (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 :     * Internal representation of Diderot types
7 :     *)
8 :    
9 :     structure Types =
10 :     struct
11 :    
12 :     datatype kind
13 :     = ScalarKind
14 :     | TypeKind
15 :    
16 :     and ty
17 :     = TyVar of ty_var
18 :     | TyBool
19 :     | TyInt
20 :     | TyReal
21 :     | TyString
22 :     | TyKernel of {diff : dim}
23 :     | TyField of {diff : dim, order : dim list, dim : dim}
24 :     | TyTensor of {order : dim list}
25 :     | TyImage of {order : dim list, dim : dim}
26 :     | TyArray of ty * dim list
27 :    
28 :     and dim
29 :     = DimConst of int (* i *)
30 :     | DimExp of (dim * int) (* d + i *)
31 :     | DimVar of dim_var
32 :    
33 :     fun dimToString (DimConst of n) = Int.toString n
34 :     | dimToString (DimExp(d, n)) =
35 :     if (n < 0)
36 :     then concat[dimToString d, "-", Int.toString(~n)]
37 :     else concat[dimToString d, "+", Int.toString n]
38 :     | dimToString (DimVar dv) = ??
39 :    
40 :     fun toString ty = (case ty
41 :     of TyVar tv => ??
42 :     | TyBool => "bool"
43 :     | TyInt => "int"
44 :     | TyReal => "real"
45 :     | TyString => "string"
46 :     | TyKernel{diff} => "kernel#" ^ dimToString diff
47 :     | TyField{diff, order, dim} =>
48 :     | TyTensor{order, dim} =>
49 :     | TyArray(ty, dim) =>
50 :     (* end case *))
51 :    
52 :     end

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