1 package Analysis.OwnershipAnalysis;
3 import java.util.HashSet;
4 import java.util.Hashtable;
5 import java.util.Iterator;
8 public class EffectsSet {
10 private Hashtable<Integer, HashSet<EffectsKey>> readTable;
11 private Hashtable<Integer, HashSet<EffectsKey>> writeTable;
14 readTable = new Hashtable<Integer, HashSet<EffectsKey>>();
15 writeTable = new Hashtable<Integer, HashSet<EffectsKey>>();
18 public void addReadingVar(Integer idx, EffectsKey access) {
19 HashSet<EffectsKey> aSet = readTable.get(idx);
21 aSet = new HashSet<EffectsKey>();
25 readTable.put(idx, aSet);
28 public void addReadingEffectsSet(Integer idx, HashSet<EffectsKey> newSet) {
31 HashSet<EffectsKey> aSet = readTable.get(idx);
33 aSet = new HashSet<EffectsKey>();
36 readTable.put(idx, aSet);
41 public void addWritingEffectsSet(Integer idx, HashSet<EffectsKey> newSet) {
44 HashSet<EffectsKey> aSet = writeTable.get(idx);
46 aSet = new HashSet<EffectsKey>();
49 writeTable.put(idx, aSet);
54 public Hashtable<Integer, HashSet<EffectsKey>> getReadTable() {
58 public Hashtable<Integer, HashSet<EffectsKey>> getWriteTable() {
62 public void addWritingVar(Integer idx, EffectsKey access) {
63 HashSet<EffectsKey> aSet = writeTable.get(idx);
65 aSet = new HashSet<EffectsKey>();
68 writeTable.put(idx, aSet);
71 public Set<EffectsKey> getReadingSet(Integer idx) {
72 return readTable.get(idx);
75 public Set<EffectsKey> getWritingSet(Integer idx) {
76 return writeTable.get(idx);
79 public void printSet() {
80 System.out.println("writeTable=>" + writeTable.hashCode());
82 Set<Integer> keySet = readTable.keySet();
83 Iterator<Integer> iter = keySet.iterator();
84 while (iter.hasNext()) {
85 Integer idx = iter.next();
86 Set<EffectsKey> effectSet = readTable.get(idx);
88 if (effectSet != null) {
89 Iterator<EffectsKey> effectIter = effectSet.iterator();
90 while (effectIter.hasNext()) {
91 EffectsKey key = effectIter.next();
97 System.out.println("param" + idx + " R=" + keyStr);
100 keySet = writeTable.keySet();
101 System.out.println("# R keyset=" + keySet.size());
102 iter = keySet.iterator();
103 while (iter.hasNext()) {
104 Integer idx = iter.next();
105 Set<EffectsKey> effectSet = writeTable.get(idx);
107 if (effectSet != null) {
108 Iterator<EffectsKey> effectIter = effectSet.iterator();
109 while (effectIter.hasNext()) {
110 EffectsKey key = effectIter.next();
116 System.out.println("param" + idx + " W=" + keyStr);
121 public boolean equals(Object o) {
126 if (!(o instanceof EffectsSet)) {
130 EffectsSet in = (EffectsSet) o;
132 if (getReadTable().equals(in.getReadTable())
133 && getWriteTable().equals(in.getWriteTable())) {
141 public int hashCode() {
144 hash += getReadTable().hashCode() + getWriteTable().hashCode() * 31;