From bd3688e0c9c8b9b5fddd7c4affa0cd31d5ce5547 Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 8 Mar 2010 21:14:09 +0000 Subject: [PATCH] edge merge --- .../Analysis/Disjoint/CanonicalWrapper.java | 18 -------- Robust/src/Analysis/Disjoint/ReachGraph.java | 41 +++++++++++++++++-- .../Tests/disjoint/predicateTest2/test.java | 6 +-- 3 files changed, 39 insertions(+), 26 deletions(-) delete mode 100644 Robust/src/Analysis/Disjoint/CanonicalWrapper.java diff --git a/Robust/src/Analysis/Disjoint/CanonicalWrapper.java b/Robust/src/Analysis/Disjoint/CanonicalWrapper.java deleted file mode 100644 index 9082c003..00000000 --- a/Robust/src/Analysis/Disjoint/CanonicalWrapper.java +++ /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 diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index ee47e9aa..a2a3fdcf 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -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 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 ) {} } - } diff --git a/Robust/src/Tests/disjoint/predicateTest2/test.java b/Robust/src/Tests/disjoint/predicateTest2/test.java index 7f8eb32e..deec6759 100644 --- a/Robust/src/Tests/disjoint/predicateTest2/test.java +++ b/Robust/src/Tests/disjoint/predicateTest2/test.java @@ -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 ) { -- 2.34.1