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

SCM Repository

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

Diff of /branches/pure-cfg/src/compiler/mid-il/mid-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 MidOps =  structure MidOps =
12    struct    struct
13    
14      (* required helper functions for types *)
15      type ty = MidILTypes.ty      type ty = MidILTypes.ty
   
16      val samety = MidILTypes.same      val samety = MidILTypes.same
17      val hashty = MidILTypes.hash      val hashty = MidILTypes.hash
18      val tyToString = MidILTypes.toString      val tyToString = MidILTypes.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 79  Line 85 
85        | Inside of ImageInfo.info * int        | Inside of ImageInfo.info * int
86        | Input of ty * string * string        | Input of ty * string * string
87        | InputWithDefault of ty * string * string        | InputWithDefault of ty * string * string
88        | ToString of ty        | Print of tys
       | Print of int  
89    
90      fun resultArity (Add _) = 1      fun resultArity (Add _) = 1
91        | resultArity (Sub _) = 1        | resultArity (Sub _) = 1
# Line 133  Line 138 
138        | resultArity (Inside _) = 1        | resultArity (Inside _) = 1
139        | resultArity (Input _) = 1        | resultArity (Input _) = 1
140        | resultArity (InputWithDefault _) = 1        | resultArity (InputWithDefault _) = 1
       | resultArity (ToString _) = 1  
141        | resultArity (Print _) = 0        | resultArity (Print _) = 0
142    
143      fun arity (Add _) = 2      fun arity (Add _) = 2
# Line 187  Line 191 
191        | arity (Inside _) = 2        | arity (Inside _) = 2
192        | arity (Input _) = 0        | arity (Input _) = 0
193        | arity (InputWithDefault _) = 1        | arity (InputWithDefault _) = 1
       | arity (ToString _) = 1  
194        | arity (Print _) = ~1        | arity (Print _) = ~1
195    
196      fun same (Add(a0), Add(b0)) = samety(a0, b0)      fun same (Add(a0), Add(b0)) = samety(a0, b0)
# Line 241  Line 244 
244        | same (Inside(a0,a1), Inside(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)        | same (Inside(a0,a1), Inside(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)
245        | 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)
246        | 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)
247        | same (ToString(a0), ToString(b0)) = samety(a0, b0)        | same (Print(a0), Print(b0)) = sametys(a0, b0)
       | same (Print(a0), Print(b0)) = sameint(a0, b0)  
248        | same _ = false        | same _ = false
249    
250      fun hash (Add(a0)) = 0w3 + hashty a0      fun hash (Add(a0)) = 0w3 + hashty a0
# Line 296  Line 298 
298        | hash (Inside(a0,a1)) = 0w229 + ImageInfo.hash a0 + hashint a1        | hash (Inside(a0,a1)) = 0w229 + ImageInfo.hash a0 + hashint a1
299        | hash (Input(a0,a1,a2)) = 0w233 + hashty a0 + hashstring a1 + hashstring a2        | hash (Input(a0,a1,a2)) = 0w233 + hashty a0 + hashstring a1 + hashstring a2
300        | hash (InputWithDefault(a0,a1,a2)) = 0w239 + hashty a0 + hashstring a1 + hashstring a2        | hash (InputWithDefault(a0,a1,a2)) = 0w239 + hashty a0 + hashstring a1 + hashstring a2
301        | hash (ToString(a0)) = 0w241 + hashty a0        | hash (Print(a0)) = 0w241 + hashtys a0
       | hash (Print(a0)) = 0w251 + hashint a0  
302    
303      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
304        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
# Line 350  Line 351 
351        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]
352        | 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, ">"]
353        | 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, ">"]
354        | toString (ToString(a0)) = concat["ToString<", tyToString a0, ">"]        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]
       | toString (Print(a0)) = concat["Print<", intToString a0, ">"]  
355    
356    end    end
357    

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