bug fixes on the flow graph.
[IRC.git] / Robust / src / Analysis / SSJava / DeltaLocation.java
index 4ab5a1a71f07ae9a61b9a50506558d61f2655ca8..2a627ea057d60400fd05d973963d7f1ac36ae3d9 100644 (file)
@@ -1,57 +1,56 @@
 package Analysis.SSJava;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Vector;
-
-import IR.ClassDescriptor;
-import IR.TypeDescriptor;
-
 public class DeltaLocation extends CompositeLocation {
 
-  private TypeDescriptor refOperand = null;
+  private int numDelta;
 
-  public DeltaLocation(ClassDescriptor cd) {
-    super(cd);
+  public DeltaLocation() {
+    super();
   }
 
-  public DeltaLocation(ClassDescriptor cd, Set<Location> set) {
-    super(cd);
-    locTuple.addAll(set);
+  public DeltaLocation(CompositeLocation comp, int numDelta) {
+    super();
+    this.numDelta = numDelta;
+    this.locTuple.addAll(comp.getTuple());
   }
 
-  public DeltaLocation(ClassDescriptor cd, TypeDescriptor refOperand) {
-    super(cd);
-    this.refOperand = refOperand;
+  public int getNumDelta() {
+    return numDelta;
   }
 
-  public TypeDescriptor getRefLocationId() {
-    return this.refOperand;
+  public void setNumDelta(int d) {
+    numDelta = d;
   }
 
-  public void addDeltaOperand(Location op) {
-    locTuple.addElement(op);
-  }
+  public String toString() {
 
-  public NTuple<Location> getDeltaOperandLocationVec() {
-    return locTuple;
+    String rtr = "";
+    for (int i = 0; i < numDelta; i++) {
+      rtr += "DELTA[";
+    }
+
+    int tupleSize = locTuple.size();
+    for (int i = 0; i < tupleSize; i++) {
+      Location locElement = locTuple.get(i);
+      if (i != 0) {
+        rtr += ",";
+      }
+      rtr += locElement;
+    }
+
+    for (int i = 0; i < numDelta; i++) {
+      rtr += "]";
+    }
+
+    return rtr;
   }
 
-  // public Set<Location> getBaseLocationSet() {
-  //
-  // if (operandVec.size() == 1 && (operandVec.get(0) instanceof DeltaLocation))
-  // {
-  // // nested delta definition
-  // DeltaLocation deltaLoc = (DeltaLocation) operandVec.get(0);
-  // return deltaLoc.getBaseLocationSet();
-  // } else {
-  // Set<Location> set = new HashSet<Location>();
-  // set.addAll(operandVec);
-  // return set;
-  // }
-  //
-  // }
+  public CompositeLocation clone() {
+    DeltaLocation clone = new DeltaLocation();
+    clone.getTuple().addAll(locTuple);
+    clone.setNumDelta(numDelta);
+    return clone;
+  }
 
   public boolean equals(Object o) {
 
@@ -61,40 +60,16 @@ public class DeltaLocation extends CompositeLocation {
 
     DeltaLocation deltaLoc = (DeltaLocation) o;
 
-    if (deltaLoc.getDeltaOperandLocationVec().equals(getDeltaOperandLocationVec())) {
+    if (deltaLoc.getTuple().equals(getTuple()) && deltaLoc.getNumDelta() == numDelta) {
       return true;
-    }
-    return false;
-  }
-
-  public int hashCode() {
-    int hash = cd.hashCode();
-    hash += locTuple.hashCode();
-    if (refOperand != null) {
-      hash += refOperand.hashCode();
-    }
-    return hash;
-  }
-
-  public String toString() {
-    String rtr = "delta(";
-
-    if (locTuple.size() != 0) {
-      int tupleSize = locTuple.size();
-      for (int i = 0; i < tupleSize; i++) {
-        Location locElement = locTuple.at(i);
-        if (i != 0) {
-          rtr += ",";
-        }
-        rtr += locElement;
-      }
     } else {
-      rtr += "LOC_REF";
+      return false;
     }
 
-    rtr += ")";
+  }
 
-    return rtr;
+  public int hashCode() {
+    return locTuple.hashCode() + numDelta;
   }
 
 }