34 |
| String of string (* strings *) |
| String of string (* strings *) |
35 |
| Bool of bool (* booleans *) |
| Bool of bool (* booleans *) |
36 |
|
|
|
fun utf8ToStr s = |
|
|
concat(rev(UTF8.fold (fn (w, l) => wcharToStr w :: l) [] s)) |
|
|
|
|
37 |
fun toString (Int i) = IntegerLit.toString i |
fun toString (Int i) = IntegerLit.toString i |
38 |
| toString (Float flt) = FloatLit.toString flt |
| toString (Float flt) = FloatLit.toString flt |
39 |
| toString (String s) = concat["\"", String.toCString s, "\""] |
| toString (String s) = concat["\"", String.toCString s, "\""] |
48 |
|
|
49 |
fun compare (Int i1, Int i2) = IntegerLit.compare(i1, i2) |
fun compare (Int i1, Int i2) = IntegerLit.compare(i1, i2) |
50 |
| compare (Float f1, Float f2) = FloatLit.compare(f1, f2) |
| compare (Float f1, Float f2) = FloatLit.compare(f1, f2) |
|
| compare (Char c1, Char c2) = Word.compare(c1, c2) |
|
51 |
| compare (String s1, String s2) = String.compare(s1, s2) |
| compare (String s1, String s2) = String.compare(s1, s2) |
52 |
| compare (Bool false, Bool true) = LESS |
| compare (Bool false, Bool true) = LESS |
53 |
| compare (Bool true, Bool false) = GREATER |
| compare (Bool true, Bool false) = GREATER |
56 |
| compare (_, Int _) = GREATER |
| compare (_, Int _) = GREATER |
57 |
| compare (Float _, _) = LESS |
| compare (Float _, _) = LESS |
58 |
| compare (_, Float _) = GREATER |
| compare (_, Float _) = GREATER |
|
| compare (Char _, _) = LESS |
|
|
| compare (_, Char _) = GREATER |
|
59 |
| compare (String _, _) = LESS |
| compare (String _, _) = LESS |
60 |
| compare (_, String _) = GREATER |
| compare (_, String _) = GREATER |
61 |
|
|
63 |
local |
local |
64 |
val intCd = 0w5 |
val intCd = 0w5 |
65 |
val floatCd = 0w7 |
val floatCd = 0w7 |
|
val charCd = 0w11 |
|
66 |
val stringCd = 0w13 |
val stringCd = 0w13 |
67 |
val boolCd = 0w17 |
val boolCd = 0w17 |
68 |
fun h (hash, base) = Word.<<(hash, 0w4) + base |
fun h (hash, base) = Word.<<(hash, 0w4) + base |
69 |
in |
in |
70 |
fun hash (Int i) = h(IntegerLit.hash i, intCd) |
fun hash (Int i) = h(IntegerLit.hash i, intCd) |
71 |
| hash (Float f) = h(FloatLit.hash f, floatCd) |
| hash (Float f) = h(FloatLit.hash f, floatCd) |
|
| hash (Char c) = h(c, charCd) |
|
72 |
| hash (String s) = h(HashString.hashString s, stringCd) |
| hash (String s) = h(HashString.hashString s, stringCd) |
73 |
| hash (Bool false) = h(0w1, boolCd) |
| hash (Bool false) = h(0w1, boolCd) |
74 |
| hash (Bool true) = h(0w3, boolCd) |
| hash (Bool true) = h(0w3, boolCd) |