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

SCM Repository

[diderot] Diff of /trunk/src/compiler/IL/expr-fn.sml
ViewVC logotype

Diff of /trunk/src/compiler/IL/expr-fn.sml

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

revision 1116, Thu May 5 04:49:02 2011 UTC revision 1232, Mon May 16 23:37:52 2011 UTC
# Line 19  Line 19 
19        | OP of Op.rator * expr list        | OP of Op.rator * expr list
20        | APPLY of ILBasis.name * expr list        | APPLY of ILBasis.name * expr list
21        | CONS of IL.Ty.ty * expr list        | CONS of IL.Ty.ty * expr list
22          | PHI of expr list
23    
24      withtype expr = expr_nd HashCons.obj      withtype expr = expr_nd HashCons.obj
25    
# Line 27  Line 28 
28    (* hash-cons construction of expressions *)    (* hash-cons construction of expressions *)
29      type tbl      type tbl
30    
31        val new : unit -> tbl
32    
33      val mkVAR  : tbl -> IL.var -> expr      val mkVAR  : tbl -> IL.var -> expr
34      val mkLIT  : tbl -> Literal.literal -> expr      val mkLIT  : tbl -> Literal.literal -> expr
35      val mkAPP  : tbl -> Op.rator * expr list -> expr      val mkOP    : tbl -> Op.rator * expr list -> expr
36        val mkAPPLY : tbl -> ILBasis.name * expr list -> expr
37      val mkCONS : tbl -> IL.Ty.ty * expr list -> expr      val mkCONS : tbl -> IL.Ty.ty * expr list -> expr
38        val mkPHI   : tbl -> expr list -> expr
39    
40    (* tables, sets, and maps *)    (* tables, sets, and maps *)
41      structure Tbl : MONO_HASH_TABLE where type Key.hash_key = expr      structure Tbl : MONO_HASH_TABLE where type Key.hash_key = expr
# Line 52  Line 57 
57        | OP of Op.rator * expr list        | OP of Op.rator * expr list
58        | APPLY of ILBasis.name * expr list        | APPLY of ILBasis.name * expr list
59        | CONS of IL.Ty.ty * expr list        | CONS of IL.Ty.ty * expr list
60          | PHI of expr list
61    
62      withtype expr = expr_nd HashCons.obj      withtype expr = expr_nd HashCons.obj
63    
# Line 62  Line 68 
68        | sameNd (LIT a, LIT b) = Literal.same(a, b)        | sameNd (LIT a, LIT b) = Literal.same(a, b)
69        | sameNd (OP(op1, args1), OP(op2, args2)) =        | sameNd (OP(op1, args1), OP(op2, args2)) =
70            Op.same(op1, op2) andalso same'(args1, args2)            Op.same(op1, op2) andalso same'(args1, args2)
71        | sameNd (CONS args1, CONS args2) = same'(args1, args2)        | sameNd (APPLY(f1, args1), APPLY(f2, args2)) =
72              ILBasis.same(f1, f2) andalso same'(args1, args2)
73          | sameNd (CONS(_, args1), CONS(_, args2)) = same'(args1, args2)
74          | sameNd (PHI args1, PHI args2) = same'(args1, args2)
75        | sameNd _ = false        | sameNd _ = false
76    
77    (* hash-cons construction of expressions *)    (* hash-cons construction of expressions *)
# Line 72  Line 81 
81    
82      fun mkVAR (Tbl tbl) x = HC.cons0 tbl (0w7919 + IL.Var.hash x, VAR x)      fun mkVAR (Tbl tbl) x = HC.cons0 tbl (0w7919 + IL.Var.hash x, VAR x)
83      fun mkLIT (Tbl tbl) a = HC.cons0 tbl (0w6997 + Literal.hash a, LIT a)      fun mkLIT (Tbl tbl) a = HC.cons0 tbl (0w6997 + Literal.hash a, LIT a)
84      fun mkAPP (Tbl tbl) (rator, args) =      fun mkOP (Tbl tbl) (rator, args) =
           HC.consList tbl (Op.hash rator, fn args => OP(rator, args)) args  
     fun mkAPP (Tbl tbl) (rator, args) =  
85            HC.consList tbl (Op.hash rator, fn args => OP(rator, args)) args            HC.consList tbl (Op.hash rator, fn args => OP(rator, args)) args
86      fun mkCONS (Tbl tbl) args = HC.consList tbl (0w5987, CONS) args      fun mkAPPLY (Tbl tbl) (f, args) =
87              HC.consList tbl (ILBasis.hash f, fn args => APPLY(f, args)) args
88        fun mkCONS (Tbl tbl) (ty, args) =
89              HC.consList tbl (0w5987, fn args => CONS(ty, args)) args
90        fun mkPHI (Tbl tbl) args = HC.consList tbl (0w6079, PHI) args
91    
92    (* hash tables *)    (* hash tables *)
93      structure Tbl = HashTableFn (      structure Tbl = HashTableFn (

Legend:
Removed from v.1116  
changed lines
  Added in v.1232

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