From: yeom Date: Mon, 11 Apr 2011 18:30:31 +0000 (+0000) Subject: changes. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a458f6c3db672f74f68fb9521503103dfc72f1ab;p=IRC.git changes. --- diff --git a/Robust/src/Analysis/SSJava/CompositeLocation.java b/Robust/src/Analysis/SSJava/CompositeLocation.java index dac3471e..b9eb5f86 100644 --- a/Robust/src/Analysis/SSJava/CompositeLocation.java +++ b/Robust/src/Analysis/SSJava/CompositeLocation.java @@ -72,6 +72,25 @@ public class CompositeLocation extends Location { return cd2loc; } + + public NTuple getBaseLocationTuple() { + + NTuple baseLocationTuple = new NTuple(); + 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 getBaseLocationSet() { diff --git a/Robust/src/Analysis/SSJava/DeltaLocation.java b/Robust/src/Analysis/SSJava/DeltaLocation.java index 45e7e55c..4ab5a1a7 100644 --- a/Robust/src/Analysis/SSJava/DeltaLocation.java +++ b/Robust/src/Analysis/SSJava/DeltaLocation.java @@ -18,7 +18,7 @@ public class DeltaLocation extends CompositeLocation { public DeltaLocation(ClassDescriptor cd, Set set) { super(cd); - locTuple.addSet(set); + locTuple.addAll(set); } public DeltaLocation(ClassDescriptor cd, TypeDescriptor refOperand) { diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index a5077c69..2c89481c 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -740,10 +740,35 @@ public class FlowDownCheck { Map cd2loc1 = compLoc1.getCd2Loc(); Map 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 keySet1 = cd2loc1.keySet(); + NTuple locTuple1 = compLoc1.getBaseLocationTuple(); + NTuple locTuple2 = compLoc2.getBaseLocationTuple(); + + Location priorityLoc1 = locTuple1.at(0); + Location priorityLoc2 = locTuple2.at(0); + + assert (priorityLoc1.getClassDescriptor().equals(priorityLoc2.getClassDescriptor())); + + ClassDescriptor cd = priorityLoc1.getClassDescriptor(); + Lattice locationOrder = (Lattice) 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 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 locationOrder = (Lattice) state.getCd2LocationOrder().get(cd1); + locationOrder = (Lattice) state.getCd2LocationOrder().get(cd1); if (loc1.getLocIdentifier().equals(loc2.getLocIdentifier())) { // have the same level of local hierarchy numEqualLoc++; diff --git a/Robust/src/Analysis/SSJava/NTuple.java b/Robust/src/Analysis/SSJava/NTuple.java index c95bc601..29f1edfa 100644 --- a/Robust/src/Analysis/SSJava/NTuple.java +++ b/Robust/src/Analysis/SSJava/NTuple.java @@ -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 { @@ -33,8 +33,14 @@ public class NTuple { this.elements.add(newElement); } - public void addSet(Set set) { - this.elements.addAll(set); + public void addAll(Collection all) { + this.elements.addAll(all); + } + + public void addAll(NTuple tuple) { + for (int i = 0; i < tuple.size(); i++) { + elements.add(tuple.at(i)); + } } public boolean equals(Object o) {