From: jjenista <jjenista>
Date: Mon, 22 Feb 2010 22:21:29 +0000 (+0000)
Subject: bug fix, was too aggressive with equals method for canonical objects, have to do... 
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5e556a9bcff1d74eb0cda59cdf62aa68d7a36cfb;p=IRC.git

bug fix, was too aggressive with equals method for canonical objects, have to do full compare otherwise you can't compare an object to something in the canon in order to retrieve the canonical version
---

diff --git a/Robust/src/Analysis/Disjoint/Canonical.java b/Robust/src/Analysis/Disjoint/Canonical.java
index 6465366a..317a9b4f 100644
--- a/Robust/src/Analysis/Disjoint/Canonical.java
+++ b/Robust/src/Analysis/Disjoint/Canonical.java
@@ -36,8 +36,7 @@ abstract public class Canonical {
 
   public static Canonical makeCanonical( Canonical c ) {
 
-    if( c.isCanonical() ) {
-      assert canon.containsKey( c );
+    if( canon.containsKey( c ) ) {
       return canon.get( c );
     }
     
diff --git a/Robust/src/Analysis/Disjoint/ChangeSet.java b/Robust/src/Analysis/Disjoint/ChangeSet.java
index ecd551de..50d4a151 100644
--- a/Robust/src/Analysis/Disjoint/ChangeSet.java
+++ b/Robust/src/Analysis/Disjoint/ChangeSet.java
@@ -74,9 +74,7 @@ public class ChangeSet extends Canonical {
     }
 
     ChangeSet cts = (ChangeSet) o;
-    assert this.isCanonical();
-    assert cts.isCanonical();
-    return this == cts;
+    return changeTuples.equals( cts.changeTuples );
   }
 
   public int hashCodeSpecific() {
diff --git a/Robust/src/Analysis/Disjoint/ChangeTuple.java b/Robust/src/Analysis/Disjoint/ChangeTuple.java
index d192d217..01bff33b 100644
--- a/Robust/src/Analysis/Disjoint/ChangeTuple.java
+++ b/Robust/src/Analysis/Disjoint/ChangeTuple.java
@@ -64,9 +64,9 @@ public class ChangeTuple extends Canonical
     }
 
     ChangeTuple ct = (ChangeTuple) o;
-    assert this.isCanonical();
-    assert ct.isCanonical();
-    return this == ct;
+    return
+      toMatch.equals( ct.toMatch ) &&
+      toAdd.equals( ct.toAdd );
   }
 
   public int hashCodeSpecific() {
diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java
index 656610ec..23ed5ade 100644
--- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java
+++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java
@@ -588,17 +588,7 @@ public class DisjointAnalysis {
       ReachGraph heapForThisCall_cur = rg.makeCalleeView( fc, 
                                                           fmCallee );
 
-      
-      try {
-        heapForThisCall_old.writeGraph( "old_"+fc+"TO"+mdCallee, true, false, false, false, false, false );
-        heapForThisCall_cur.writeGraph( "cur_"+fc+"TO"+mdCallee, true, false, false, false, false, false );
-      } catch( IOException e ) {}
-
-
-      if( !heapForThisCall_cur.equals( heapForThisCall_old ) ) {
-
-        System.out.println( fc+"TO"+mdCallee+" not equal" );
-
+      if( !heapForThisCall_cur.equals( heapForThisCall_old ) ) {        
         // if heap at call site changed, update the contribution,
         // and reschedule the callee for analysis
         addIHMcontribution( mdCallee, fc, heapForThisCall_cur );        
diff --git a/Robust/src/Analysis/Disjoint/ExistPred.java b/Robust/src/Analysis/Disjoint/ExistPred.java
index 404632f7..97daffd3 100644
--- a/Robust/src/Analysis/Disjoint/ExistPred.java
+++ b/Robust/src/Analysis/Disjoint/ExistPred.java
@@ -78,12 +78,21 @@ public class ExistPred extends Canonical {
   
   protected ExistPred() {
     this.predType = TYPE_TRUE;
+    ne_state   = null;
+    n_hrnID    = null;
+    e_tdSrc    = null;
+    e_hrnSrcID = null;
+    e_hrnDstID = null;
+    e_type     = null;
+    e_field    = null;
   }
 
   // node predicates
   public static ExistPred factory( Integer    hrnID, 
                                    ReachState state ) {
+
     ExistPred out = new ExistPred( hrnID, state );
+
     out = (ExistPred) Canonical.makeCanonical( out );
     return out;
   }
@@ -94,6 +103,11 @@ public class ExistPred extends Canonical {
     this.n_hrnID  = hrnID;
     this.ne_state = state;
     this.predType = TYPE_NODE;
+    e_tdSrc    = null;
+    e_hrnSrcID = null;
+    e_hrnDstID = null;
+    e_type     = null;
+    e_field    = null;
   }
 
   // edge predicates
@@ -103,12 +117,14 @@ public class ExistPred extends Canonical {
                                    TypeDescriptor type,    
                                    String         field,   
                                    ReachState     state ) {
+
     ExistPred out = new ExistPred( tdSrc,   
                                    hrnSrcID,
                                    hrnDstID,
                                    type,    
                                    field,   
                                    state );
+
     out = (ExistPred) Canonical.makeCanonical( out );
     return out;
   }
@@ -135,6 +151,7 @@ public class ExistPred extends Canonical {
     this.e_field    = field;
     this.ne_state   = state;
     this.predType   = TYPE_EDGE;
+    n_hrnID = null;
   }
 
 
@@ -211,6 +228,7 @@ public class ExistPred extends Canonical {
   }
 
 
+
   public boolean equals( Object o ) {
     if( o == null ) {
       return false;
@@ -221,82 +239,69 @@ public class ExistPred extends Canonical {
     }
 
     ExistPred pred = (ExistPred) o;
-    assert this.isCanonical();
-    assert pred.isCanonical();
-    return this == pred;
-  }
-  /*
-  public boolean equals( Object o ) {
-    if( o == null ) {
-      return false;
-    }
 
-    if( !(o instanceof ExistPredNode) ) {
+    if( this.predType != pred.predType ) {
       return false;
     }
 
-    ExistPredNode epn = (ExistPredNode) o;
-
-    if( !hrnID.equals( epn.hrnID ) ) {
-      return false;
-    }
-
-    // ReachState objects are canonical
-    return state == epn.state;
-  }
-
-  public boolean equals( Object o ) {
-    if( o == null ) {
-      return false;
-    }
-
-    if( !(o instanceof ExistPredEdge) ) {
+    if( ne_state == null ) {
+      if( pred.ne_state != null ) {
+        return false;
+      }
+    } else if( !ne_state.equals( pred.ne_state ) ) {
       return false;
     }
-
-    ExistPredEdge epn = (ExistPredEdge) o;
-
-    this.tdSrc    = tdSrc;
-    this.hrnSrcID = hrnSrcID;
-    this.hrnDstID = hrnDstID;
-    this.type     = type;
-    this.field    = field;
-    this.state    = state;
-
-    if( tdSrc == null && epn.tdSrc != null ) {
-      return false;
-    } else if( !tdSrc.equals( epn.tdSrc ) ) {
+    
+    if( n_hrnID == null ) {
+      if( pred.n_hrnID != null ) {
+        return false;
+      }
+    } else if( !n_hrnID.equals( pred.n_hrnID ) ) {
       return false;
     }
-
-    if( hrnSrcID == null && epn.hrnSrcID != null ) {
-      return false;
-    } else if( !hrnSrcID.equals( epn.hrnSrcID ) ) {
+    
+    if( e_tdSrc == null ) {
+      if( pred.e_tdSrc != null ) {
+        return false;
+      }
+    } else if( !e_tdSrc.equals( pred.e_tdSrc ) ) {
       return false;
     }
 
-    if( !hrnDstID.equals( epn.hrnDstID ) ) {
+    if( e_hrnSrcID == null ) {
+      if( pred.e_hrnSrcID != null ) {
+        return false;
+      }
+    } else if( !e_hrnSrcID.equals( pred.e_hrnSrcID ) ) {
       return false;
     }
 
-    if( !type.equals( epn.type ) ) {
+    if( e_hrnDstID == null ) {
+      if( pred.e_hrnDstID != null ) {
+        return false;
+      }
+    } else if( !e_hrnDstID.equals( pred.e_hrnDstID ) ) {
       return false;
     }
-
-    if( field == null ) {
-      if( epn.field != null ) {
+    
+    if( e_type == null ) {
+      if( pred.e_type != null ) {
         return false;
       }
-    } else {
-      if( !field.equals( epn.field ) ) {
+    } else if( !e_type.equals( pred.e_type ) ) {
+      return false;
+    }
+    
+    if( e_field == null ) {
+      if( pred.e_field != null ) {
         return false;
       }
+    } else if( !e_field.equals( pred.e_field ) ) {
+      return false;
     }
 
-    // ReachState objects are cannonical
-    return state == epn.state;
+    return true;
   }
-  */  
 
 
   public int hashCodeSpecific() {
diff --git a/Robust/src/Analysis/Disjoint/ExistPredSet.java b/Robust/src/Analysis/Disjoint/ExistPredSet.java
index 50c7edd6..124cec68 100644
--- a/Robust/src/Analysis/Disjoint/ExistPredSet.java
+++ b/Robust/src/Analysis/Disjoint/ExistPredSet.java
@@ -71,9 +71,8 @@ public class ExistPredSet extends Canonical {
     }
 
     ExistPredSet eps = (ExistPredSet) o;
-    assert this.isCanonical();
-    assert eps.isCanonical();
-    return this == eps;
+
+    return preds.equals( eps.preds );
   }
 
 
diff --git a/Robust/src/Analysis/Disjoint/HeapRegionNode.java b/Robust/src/Analysis/Disjoint/HeapRegionNode.java
index 0b190fc6..b0a4d44a 100644
--- a/Robust/src/Analysis/Disjoint/HeapRegionNode.java
+++ b/Robust/src/Analysis/Disjoint/HeapRegionNode.java
@@ -94,6 +94,7 @@ public class HeapRegionNode extends RefSrcNode {
   // fixed point, so use this method to determine if
   // a node is "equal" to some previous visit, basically
   public boolean equalsIncludingAlphaAndPreds( HeapRegionNode hrn ) {
+
     return equals( hrn ) && 
       alpha.equals( hrn.alpha ) && 
       preds.equals( hrn.preds );
diff --git a/Robust/src/Analysis/Disjoint/ReachSet.java b/Robust/src/Analysis/Disjoint/ReachSet.java
index 0af32efa..62f60df3 100644
--- a/Robust/src/Analysis/Disjoint/ReachSet.java
+++ b/Robust/src/Analysis/Disjoint/ReachSet.java
@@ -158,9 +158,7 @@ public class ReachSet extends Canonical {
     }
 
     ReachSet rs = (ReachSet) o;
-    assert this.isCanonical();
-    assert rs.isCanonical();
-    return this == rs;
+    return reachStates.equals( rs.reachStates );
   }
 
 
diff --git a/Robust/src/Analysis/Disjoint/ReachState.java b/Robust/src/Analysis/Disjoint/ReachState.java
index e5052028..22e7e79b 100644
--- a/Robust/src/Analysis/Disjoint/ReachState.java
+++ b/Robust/src/Analysis/Disjoint/ReachState.java
@@ -97,9 +97,7 @@ public class ReachState extends Canonical {
     }
 
     ReachState rs = (ReachState) o;
-    assert this.isCanonical();
-    assert rs.isCanonical();
-    return this == rs;
+    return reachTuples.equals( rs.reachTuples );
   }
 
 
diff --git a/Robust/src/Analysis/Disjoint/ReachTuple.java b/Robust/src/Analysis/Disjoint/ReachTuple.java
index 4a472cfa..70982d32 100644
--- a/Robust/src/Analysis/Disjoint/ReachTuple.java
+++ b/Robust/src/Analysis/Disjoint/ReachTuple.java
@@ -99,9 +99,9 @@ public class ReachTuple extends Canonical {
     }
 
     ReachTuple rt = (ReachTuple) o;
-    assert this.isCanonical();
-    assert rt.isCanonical();
-    return this == rt;
+    return 
+      hrnID.equals( rt.hrnID ) &&
+      arity == rt.arity;
   }
 
   public int hashCodeSpecific() {