changes.
authoryeom <yeom>
Mon, 11 Apr 2011 18:30:31 +0000 (18:30 +0000)
committeryeom <yeom>
Mon, 11 Apr 2011 18:30:31 +0000 (18:30 +0000)
Robust/src/Analysis/SSJava/CompositeLocation.java
Robust/src/Analysis/SSJava/DeltaLocation.java
Robust/src/Analysis/SSJava/FlowDownCheck.java
Robust/src/Analysis/SSJava/NTuple.java

index dac3471ea169713e404d5b0d81993bb6862d1c9c..b9eb5f86bacef688f07b65043e89e4d136ee2032 100644 (file)
@@ -72,6 +72,25 @@ public class CompositeLocation extends Location {
     return cd2loc;
 
   }
+  
+  public NTuple<Location> getBaseLocationTuple() {
+    
+    NTuple<Location> baseLocationTuple = new NTuple<Location>();
+    int tupleSize = locTuple.size();
+    for (int i = 0; i < tupleSize; i++) {
+      Location locElement = locTuple.at(i);
+
+      if (locElement instanceof DeltaLocation) {
+        // baseLocationSet.addAll(((DeltaLocation)
+        // locElement).getDeltaOperandLocationVec());
+        baseLocationTuple.addAll(((DeltaLocation) locElement).getBaseLocationTuple());
+      } else {
+        baseLocationTuple.addElement(locElement);
+      }
+    }
+    return baseLocationTuple;
+    
+  }
 
   public Set<Location> getBaseLocationSet() {
 
index 45e7e55c4e176e6392f49646df572f58ebc87189..4ab5a1a71f07ae9a61b9a50506558d61f2655ca8 100644 (file)
@@ -18,7 +18,7 @@ public class DeltaLocation extends CompositeLocation {
 
   public DeltaLocation(ClassDescriptor cd, Set<Location> set) {
     super(cd);
-    locTuple.addSet(set);
+    locTuple.addAll(set);
   }
 
   public DeltaLocation(ClassDescriptor cd, TypeDescriptor refOperand) {
index a5077c69f4679383af4ccafa2b970ea944561e2c..2c89481c03577c478a6998f7551095f0913a4747 100644 (file)
@@ -740,10 +740,35 @@ public class FlowDownCheck {
       Map<ClassDescriptor, Location> cd2loc1 = compLoc1.getCd2Loc();
       Map<ClassDescriptor, Location> cd2loc2 = compLoc2.getCd2Loc();
 
-      // compare base locations by class descriptor
+      // start to compare the first item of tuples:
+      // assumes that the first item has priority than other items.
 
-      Set<ClassDescriptor> keySet1 = cd2loc1.keySet();
+      NTuple<Location> locTuple1 = compLoc1.getBaseLocationTuple();
+      NTuple<Location> locTuple2 = compLoc2.getBaseLocationTuple();
+
+      Location priorityLoc1 = locTuple1.at(0);
+      Location priorityLoc2 = locTuple2.at(0);
+
+      assert (priorityLoc1.getClassDescriptor().equals(priorityLoc2.getClassDescriptor()));
+
+      ClassDescriptor cd = priorityLoc1.getClassDescriptor();
+      Lattice<String> locationOrder = (Lattice<String>) state.getCd2LocationOrder().get(cd);
+
+      if (priorityLoc1.getLocIdentifier().equals(priorityLoc2.getLocIdentifier())) {
+        // have the same level of local hierarchy
+      } else if (locationOrder.isGreaterThan(priorityLoc1.getLocIdentifier(), priorityLoc2
+          .getLocIdentifier())) {
+        // if priority loc of compLoc1 is higher than compLoc2
+        // then, compLoc 1 is higher than compLoc2
+        return ComparisonResult.GREATER;
+      } else {
+        // if priority loc of compLoc1 is NOT higher than compLoc2
+        // then, compLoc 1 is NOT higher than compLoc2
+        return ComparisonResult.LESS;
+      }
 
+      // compare base locations except priority by class descriptor
+      Set<ClassDescriptor> keySet1 = cd2loc1.keySet();
       int numEqualLoc = 0;
 
       for (Iterator iterator = keySet1.iterator(); iterator.hasNext();) {
@@ -752,19 +777,19 @@ public class FlowDownCheck {
         Location loc1 = cd2loc1.get(cd1);
         Location loc2 = cd2loc2.get(cd1);
 
-        System.out.println("from " + cd1 + " loc1=" + loc1 + " loc2=" + loc2);
+        if (priorityLoc1.equals(loc1)) {
+          continue;
+        }
 
         if (loc2 == null) {
-          // if comploc2 doesn't have corresponding location, then ignore this
-          // element
-          numEqualLoc++;
-          continue;
+          // if comploc2 doesn't have corresponding location,
+          // then we determines that comploc1 is lower than comploc 2
+          return ComparisonResult.LESS;
         }
 
         System.out.println("lattice comparison:" + loc1.getLocIdentifier() + " ? "
             + loc2.getLocIdentifier());
-
-        Lattice<String> locationOrder = (Lattice<String>) state.getCd2LocationOrder().get(cd1);
+        locationOrder = (Lattice<String>) state.getCd2LocationOrder().get(cd1);
         if (loc1.getLocIdentifier().equals(loc2.getLocIdentifier())) {
           // have the same level of local hierarchy
           numEqualLoc++;
index c95bc6019d1e51843810496802224300cff0ea06..29f1edfa9ac8c1852be61b277ac574bb5bd4de0a 100644 (file)
@@ -2,8 +2,8 @@ package Analysis.SSJava;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
-import java.util.Set;
 
 public class NTuple<T> {
 
@@ -33,8 +33,14 @@ public class NTuple<T> {
     this.elements.add(newElement);
   }
 
-  public void addSet(Set<T> set) {
-    this.elements.addAll(set);
+  public void addAll(Collection<T> all) {
+    this.elements.addAll(all);
+  }
+
+  public void addAll(NTuple<T> tuple) {
+    for (int i = 0; i < tuple.size(); i++) {
+      elements.add(tuple.at(i));
+    }
   }
 
   public boolean equals(Object o) {