edge merge
authorjjenista <jjenista>
Mon, 8 Mar 2010 21:14:09 +0000 (21:14 +0000)
committerjjenista <jjenista>
Mon, 8 Mar 2010 21:14:09 +0000 (21:14 +0000)
Robust/src/Analysis/Disjoint/CanonicalWrapper.java [deleted file]
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Tests/disjoint/predicateTest2/test.java

diff --git a/Robust/src/Analysis/Disjoint/CanonicalWrapper.java b/Robust/src/Analysis/Disjoint/CanonicalWrapper.java
deleted file mode 100644 (file)
index 9082c00..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package Analysis.Disjoint;
-
-public class CanonicalWrapper {
-    Canonical a;
-    public Canonical b;
-    
-    public CanonicalWrapper(Canonical a) {
-       assert a.canonicalvalue!=0;
-       this.a=a;
-    }
-    public int hashCode() {
-       return a.canonicalvalue;
-    }
-    public boolean equals(Object o) {
-       CanonicalWrapper ro=(CanonicalWrapper)o;
-       return ro.a.canonicalvalue==a.canonicalvalue;
-    }
-}
\ No newline at end of file
index ee47e9aaf1c796b2895ab7658a03a0449a8e7ace..a2a3fdcf5bd63d174f2aacb129ae01b04006cc4e 100644 (file)
@@ -161,6 +161,15 @@ public class ReachGraph {
     assert edge.getSrc() == referencer;
     assert edge.getDst() == referencee;
 
+
+    if( referencer.getReferenceTo( referencee,
+                                   edge.getType(),
+                                   edge.getField()
+                                   ) != null
+        ) {
+      System.out.println( "  edge being added again: "+edge );
+    }
+
     // edges are getting added twice to graphs now, the
     // kind that should have abstract facts merged--use
     // this check to prevent that
@@ -1493,6 +1502,7 @@ public class ReachGraph {
     }
 
 
+
     // 3. callee elements with satisfied preds come in
 
     // 3.a) nodes
@@ -1528,6 +1538,7 @@ public class ReachGraph {
       hrnCaller.setPreds( predsTrue );
     }
 
+
     // 3.b) callee -> callee edges
     Iterator<RefEdge> reItr = calleeEdgesSatisfied.iterator();
     while( reItr.hasNext() ) {
@@ -1568,7 +1579,30 @@ public class ReachGraph {
                                       rsetEmpty,
                                       predsTrue
                                       );
-      addRefEdge( rsnCaller, hrnDstCaller, reCaller ); 
+
+
+      // look to see if an edge with same field exists
+      // and merge with it, otherwise just add the edge
+      RefEdge edgeExisting = rsnCaller.getReferenceTo( hrnDstCaller, 
+                                                       reCallee.getType(),
+                                                       reCallee.getField()
+                                                       );      
+      if( edgeExisting != null ) {
+        edgeExisting.setBeta(
+                             Canonical.union( edgeExisting.getBeta(),
+                                              reCaller.getBeta()
+                                              )
+                             );
+        edgeExisting.setPreds(
+                              Canonical.join( edgeExisting.getPreds(),
+                                              reCaller.getPreds()
+                                              )
+                              );
+       
+      } else {                   
+        addRefEdge( rsnCaller, hrnDstCaller, reCaller );       
+      }
+      
     }
 
     // 3.c) resolve out-of-context -> callee edges
@@ -1576,9 +1610,9 @@ public class ReachGraph {
     
 
     // 4.
-    /*
     globalSweep();
-    */
+    
+
 
     if( writeDebugDOTs ) {
       try {
@@ -1587,7 +1621,6 @@ public class ReachGraph {
                     null, null );
       } catch( IOException e ) {}
     }
-
   } 
 
   
index 7f8eb32e6a33d5b8cc5213657ecf7a55edac1fb4..deec67596adbbfde356d1b10bc3d042b31118873 100644 (file)
@@ -13,11 +13,9 @@ public class Test {
 
     Foo f1 = new Foo();
     addSomething( f1 );
-
-    /*
+    
     Foo f2 = new Foo();
-    addSomething( f2 );
-    */
+    addSomething( f2 );    
   }   
 
   public static void addSomething( Foo f ) {