1 package Analysis.SSJava;
3 import java.util.HashSet;
4 import java.util.Iterator;
9 public class SSJavaLattice<T> extends Lattice<T> {
12 public static int seed = 0;
14 public SSJavaLattice(T top, T bottom) {
16 sharedLocSet = new HashSet<T>();
19 public Set<T> getSharedLocSet() {
23 public void addSharedLoc(T loc) {
24 sharedLocSet.add(loc);
27 public boolean isSharedLoc(T loc) {
28 return sharedLocSet.contains(loc);
31 public boolean addRelationHigherToLower(T higher, T lower) {
33 System.out.println("add a relation: " + lower + "<" + higher);
35 return put(higher, lower);
38 public void insertNewLocationAtOneLevelHigher(T lowerLoc, T newLoc) {
39 // first identifying which location is connected to the input loc
40 Set<T> keySet = getKeySet();
41 Set<T> oneLevelHigherLocSet = new HashSet<T>();
43 for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
44 T locKey = (T) iterator.next();
45 Set<T> conntectedSet = get(locKey);
46 for (Iterator iterator2 = conntectedSet.iterator(); iterator2.hasNext();) {
47 T connectedLoc = (T) iterator2.next();
48 if (connectedLoc.equals(lowerLoc)) {
49 oneLevelHigherLocSet.add(locKey);
55 addRelationHigherToLower(newLoc, lowerLoc);
57 for (Iterator iterator = oneLevelHigherLocSet.iterator(); iterator.hasNext();) {
58 T higherLoc = (T) iterator.next();
59 // remove an existing edge between the higher loc and the input loc
60 get(higherLoc).remove(lowerLoc);
61 // add a new edge from the higher loc to the new location
62 put(higherLoc, newLoc);