SCM Repository
Annotation of /trunk/src/compiler/fields/raw-types.sml
Parent Directory
|
Revision Log
Revision 282 - (view) (download)
1 : | jhr | 141 | (* raw-types.sml |
2 : | * | ||
3 : | * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) | ||
4 : | * All rights reserved. | ||
5 : | * | ||
6 : | * This file defines the representation of the raw scalar types used to | ||
7 : | * define image data in the NRRD file format. | ||
8 : | *) | ||
9 : | |||
10 : | structure RawTypes = | ||
11 : | struct | ||
12 : | |||
13 : | (* raw numeric types as supported by NRRD *) | ||
14 : | datatype ty | ||
15 : | = RT_Int8 | RT_UInt8 | ||
16 : | | RT_Int16 | RT_UInt16 | ||
17 : | | RT_Int32 | RT_UInt32 | ||
18 : | | RT_Int64 | RT_UInt64 | ||
19 : | | RT_Float | RT_Double | ||
20 : | |||
21 : | jhr | 282 | fun same (a : ty, b) = (a = b) |
22 : | |||
23 : | fun hash RT_Int8 = 0w17 | ||
24 : | | hash RT_UInt8 = 0w59 | ||
25 : | | hash RT_Int16 = 0w103 | ||
26 : | | hash RT_UInt16 = 0w157 | ||
27 : | | hash RT_Int32 = 0w211 | ||
28 : | | hash RT_UInt32 = 0w269 | ||
29 : | | hash RT_Int64 = 0w331 | ||
30 : | | hash RT_UInt64 = 0w389 | ||
31 : | | hash RT_Float = 0w449 | ||
32 : | | hash RT_Double = 0w509 | ||
33 : | |||
34 : | jhr | 239 | fun fromString ty = (case ty |
35 : | of "signed char" => RT_Int8 | ||
36 : | | "unsigned char" => RT_UInt8 | ||
37 : | | "short" => RT_Int16 | ||
38 : | | "unsigned short" => RT_UInt16 | ||
39 : | | "int" => RT_Int32 | ||
40 : | | "unsigned int" => RT_UInt32 | ||
41 : | | "long long int" => RT_Int64 | ||
42 : | | "unsigned long long int" => RT_UInt64 | ||
43 : | | "float" => RT_Float | ||
44 : | | "double" => RT_Double | ||
45 : | | _ => raise Fail("unknown raw type "^ty) | ||
46 : | (* end case *)) | ||
47 : | |||
48 : | jhr | 282 | fun toString ty = (case ty |
49 : | of RT_Int8 => "signed char" | ||
50 : | | RT_UInt8 => "unsigned char" | ||
51 : | | RT_Int16 => "short" | ||
52 : | | RT_UInt16 => "unsigned short" | ||
53 : | | RT_Int32 => "int" | ||
54 : | | RT_UInt32 => "unsigned int" | ||
55 : | | RT_Int64 => "long long int" | ||
56 : | | RT_UInt64 => "unsigned long long int" | ||
57 : | | RT_Float => "float" | ||
58 : | | RT_Double => "double" | ||
59 : | (* end case *)) | ||
60 : | |||
61 : | jhr | 141 | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |