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

SCM Repository

[diderot] Diff of /trunk/src/common/literal.sml
ViewVC logotype

Diff of /trunk/src/common/literal.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 28, Tue Feb 9 02:55:41 2010 UTC revision 29, Wed Feb 10 21:45:00 2010 UTC
# Line 34  Line 34 
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, "\""]
# Line 51  Line 48 
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
# Line 60  Line 56 
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    
# Line 69  Line 63 
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)

Legend:
Removed from v.28  
changed lines
  Added in v.29

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