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

SCM Repository

[diderot] Annotation of /branches/lamont/src/compiler/high-il/high-il-types.sml
ViewVC logotype

Annotation of /branches/lamont/src/compiler/high-il/high-il-types.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 395 - (view) (download)
Original Path: trunk/src/compiler/high-il/high-il-types.sml

1 : jhr 393 (* high-il-types.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure HighILTypes =
8 :     struct
9 :    
10 : jhr 394 datatype ty
11 :     = BoolTy | StringTy | IntTy
12 :     | TensorTy of int list
13 :     | KernelTy | ImageTy | FieldTy
14 : jhr 393
15 :     fun same (ty1 : ty, ty2) = (ty1 = ty2)
16 :    
17 :     fun hash BoolTy = 0w1
18 :     | hash StringTy = 0w2
19 :     | hash IntTy = 0w3
20 :     | hash (TensorTy dd) = List.foldl (fn (d, s) => Word.fromInt d + s) 0w4 dd
21 : jhr 395 | hash KernelTy = 0w5
22 :     | hash ImageTy = 0w6
23 :     | hash FieldTy = 0w7
24 : jhr 393
25 :     fun toString BoolTy = "bool"
26 :     | toString StringTy = "string"
27 :     | toString IntTy = "int"
28 :     | toString (TensorTy[]) = "real"
29 :     | toString (TensorTy dd) = String.concat[
30 :     "tensor[", String.concatWith "," (List.map Int.toString dd), "]"
31 :     ]
32 : jhr 395 | toString KernelTy = "kernel"
33 :     | toString ImageTy = "image"
34 :     | toString FieldTy = "field"
35 : jhr 393
36 :     end

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