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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/high-il/high-il.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/high-il/high-il.sml

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

revision 1623, Fri Nov 11 21:58:50 2011 UTC revision 1624, Sat Nov 12 16:50:10 2011 UTC
# Line 11  Line 11 
11  structure HighOps =  structure HighOps =
12    struct    struct
13    
14      (* required helper functions for types *)
15      type ty = HighILTypes.ty      type ty = HighILTypes.ty
   
16      val samety = HighILTypes.same      val samety = HighILTypes.same
17      val hashty = HighILTypes.hash      val hashty = HighILTypes.hash
18      val tyToString = HighILTypes.toString      val tyToString = HighILTypes.toString
19    
20      (* required helper functions for type lists *)
21        type tys = ty list
22        fun sametys (tys1, tys2) = ListPair.allEq samety (tys1, tys2)
23        fun hashtys tys = List.foldl (fn (ty, s) => hashty ty + 0w3 * s) 0w0 tys
24        fun tysToString tys = String.concat["[", String.concatWith "," (List.map tyToString tys), "]" ]
25    
26    (* required helper functions for the int type *)    (* required helper functions for the int type *)
27      fun sameint (i1 : int, i2) = (i1 = i2)      fun sameint (i1 : int, i2) = (i1 = i2)
28      fun hashint i = Word.fromInt i      fun hashint i = Word.fromInt i
# Line 91  Line 97 
97        | DiffField        | DiffField
98        | Input of ty * string * string        | Input of ty * string * string
99        | InputWithDefault of ty * string * string        | InputWithDefault of ty * string * string
100        | ToString of ty        | Print of tys
       | Print of int  
101    
102      fun resultArity (Add _) = 1      fun resultArity (Add _) = 1
103        | resultArity (Sub _) = 1        | resultArity (Sub _) = 1
# Line 148  Line 153 
153        | resultArity DiffField = 1        | resultArity DiffField = 1
154        | resultArity (Input _) = 1        | resultArity (Input _) = 1
155        | resultArity (InputWithDefault _) = 1        | resultArity (InputWithDefault _) = 1
       | resultArity (ToString _) = 1  
156        | resultArity (Print _) = 0        | resultArity (Print _) = 0
157    
158      fun arity (Add _) = 2      fun arity (Add _) = 2
# Line 205  Line 209 
209        | arity DiffField = 1        | arity DiffField = 1
210        | arity (Input _) = 0        | arity (Input _) = 0
211        | arity (InputWithDefault _) = 1        | arity (InputWithDefault _) = 1
       | arity (ToString _) = 1  
212        | arity (Print _) = ~1        | arity (Print _) = ~1
213    
214      fun same (Add(a0), Add(b0)) = samety(a0, b0)      fun same (Add(a0), Add(b0)) = samety(a0, b0)
# Line 262  Line 265 
265        | same (DiffField, DiffField) = true        | same (DiffField, DiffField) = true
266        | same (Input(a0,a1,a2), Input(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)        | same (Input(a0,a1,a2), Input(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)
267        | same (InputWithDefault(a0,a1,a2), InputWithDefault(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)        | same (InputWithDefault(a0,a1,a2), InputWithDefault(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)
268        | same (ToString(a0), ToString(b0)) = samety(a0, b0)        | same (Print(a0), Print(b0)) = sametys(a0, b0)
       | same (Print(a0), Print(b0)) = sameint(a0, b0)  
269        | same _ = false        | same _ = false
270    
271      fun hash (Add(a0)) = 0w3 + hashty a0      fun hash (Add(a0)) = 0w3 + hashty a0
# Line 320  Line 322 
322        | hash DiffField = 0w241        | hash DiffField = 0w241
323        | hash (Input(a0,a1,a2)) = 0w251 + hashty a0 + hashstring a1 + hashstring a2        | hash (Input(a0,a1,a2)) = 0w251 + hashty a0 + hashstring a1 + hashstring a2
324        | hash (InputWithDefault(a0,a1,a2)) = 0w257 + hashty a0 + hashstring a1 + hashstring a2        | hash (InputWithDefault(a0,a1,a2)) = 0w257 + hashty a0 + hashstring a1 + hashstring a2
325        | hash (ToString(a0)) = 0w263 + hashty a0        | hash (Print(a0)) = 0w263 + hashtys a0
       | hash (Print(a0)) = 0w269 + hashint a0  
326    
327      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
328        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
# Line 377  Line 378 
378        | toString DiffField = "DiffField"        | toString DiffField = "DiffField"
379        | toString (Input(a0,a1,a2)) = concat["Input<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]        | toString (Input(a0,a1,a2)) = concat["Input<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]
380        | toString (InputWithDefault(a0,a1,a2)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]        | toString (InputWithDefault(a0,a1,a2)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]
381        | toString (ToString(a0)) = concat["ToString<", tyToString a0, ">"]        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]
       | toString (Print(a0)) = concat["Print<", intToString a0, ">"]  
382    
383    end    end
384    

Legend:
Removed from v.1623  
changed lines
  Added in v.1624

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