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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/mid-to-low/lowSet.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/mid-to-low/lowSet.sml

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

revision 3541, Mon Jan 4 18:03:27 2016 UTC revision 3542, Mon Jan 4 19:47:38 2016 UTC
# Line 17  Line 17 
17      fun hash (_,DstIL.OP(op1,_))=DstOp.hash op1      fun hash (_,DstIL.OP(op1,_))=DstOp.hash op1
18        | hash(_,DstIL.LIT m)=Literal.hash m        | hash(_,DstIL.LIT m)=Literal.hash m
19        | hash (_,DstIL.CONS _ )=0w17        | hash (_,DstIL.CONS _ )=0w17
   
20     fun cmp(e1,e2)=Word.compare(hash e1, hash e2)     fun cmp(e1,e2)=Word.compare(hash e1, hash e2)
21    
22     structure OprKey =     structure OprKey =
# Line 30  Line 29 
29      fun allEq([], []) = true      fun allEq([], []) = true
30        | allEq(x::xs, y::ys) = DstIL.Var.same(x,y) andalso allEq (xs,ys)        | allEq(x::xs, y::ys) = DstIL.Var.same(x,y) andalso allEq (xs,ys)
31        | allEq _ = false        | allEq _ = false
   
32      fun setFind (tbl,DstIL.OP(op0,arg0))= (      fun setFind (tbl,DstIL.OP(op0,arg0))= (
33          LowSet.find(          LowSet.find(
34              (fn (_,DstIL.OP(op1,arg1))=>(DstOp.same(op0,op1) andalso allEq(arg0,arg1)) | _ => false)              (fn (_,DstIL.OP(op1,arg1))=>(DstOp.same(op0,op1) andalso allEq(arg0,arg1)) | _ => false)
# Line 39  Line 37 
37          LowSet.find(          LowSet.find(
38              (fn (_,DstIL.LIT m)=> Literal.same(n,m)              (fn (_,DstIL.LIT m)=> Literal.same(n,m)
39              | _ => false))) tbl              | _ => false))) tbl
        (* | setFind (tbl,DstIL.CONS(ty0,arg0))= (  
             LowSet.find(  
             (fn (_,DstIL.CONS(ty1,arg1))=>(LowILTypes.same(ty0,ty1) andalso allEq(arg0,arg1)) | _ => false)  
                 )) tbl*)  
40        | setFind (tbl, e)= NONE        | setFind (tbl, e)= NONE
   
41      fun rtnVar (tbl,(lhs,rhs))=(case setFind(tbl,rhs)      fun rtnVar (tbl,(lhs,rhs))=(case setFind(tbl,rhs)
42          of NONE     => (LowSet.add(tbl,(lhs,rhs)), NONE)          of NONE     => (LowSet.add(tbl,(lhs,rhs)), NONE)
43          | SOME(v1,e1) =>(tbl,SOME v1)          | SOME(v1,e1) =>(tbl,SOME v1)
44          (*end case*))          (*end case*))
   
45      fun filter(tbl,(lhs,rhs))=(case rhs      fun filter(tbl,(lhs,rhs))=(case rhs
46          of DstIL.OP _ => rtnVar(tbl,(lhs,rhs))          of DstIL.OP _ => rtnVar(tbl,(lhs,rhs))
47          | DstIL.LIT _ => rtnVar(tbl,(lhs,rhs))          | DstIL.LIT _ => rtnVar(tbl,(lhs,rhs))

Legend:
Removed from v.3541  
changed lines
  Added in v.3542

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