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;
12 private Hashtable<Integer, HashSet<EffectsKey>> strongUpdateTable;
15 readTable = new Hashtable<Integer, HashSet<EffectsKey>>();
16 writeTable = new Hashtable<Integer, HashSet<EffectsKey>>();
17 strongUpdateTable = new Hashtable<Integer, HashSet<EffectsKey>>();
20 public void addReadingVar(Integer idx, EffectsKey access) {
21 HashSet<EffectsKey> aSet = readTable.get(idx);
23 aSet = new HashSet<EffectsKey>();
27 readTable.put(idx, aSet);
30 public void addReadingEffectsSet(Integer idx, HashSet<EffectsKey> newSet) {
33 HashSet<EffectsKey> aSet = readTable.get(idx);
35 aSet = new HashSet<EffectsKey>();
38 readTable.put(idx, aSet);
43 public void addWritingEffectsSet(Integer idx, HashSet<EffectsKey> newSet) {
46 HashSet<EffectsKey> aSet = writeTable.get(idx);
48 aSet = new HashSet<EffectsKey>();
51 writeTable.put(idx, aSet);
56 public void addStrongUpdateEffectsSet(Integer idx, HashSet<EffectsKey> newSet) {
59 HashSet<EffectsKey> aSet = strongUpdateTable.get(idx);
61 aSet = new HashSet<EffectsKey>();
64 strongUpdateTable.put(idx, aSet);
70 public Hashtable<Integer, HashSet<EffectsKey>> getReadTable() {
74 public Hashtable<Integer, HashSet<EffectsKey>> getWriteTable() {
78 public Hashtable<Integer, HashSet<EffectsKey>> getStrongUpdateTable() {
79 return strongUpdateTable;
82 public void addWritingVar(Integer idx, EffectsKey access) {
83 HashSet<EffectsKey> aSet = writeTable.get(idx);
85 aSet = new HashSet<EffectsKey>();
88 writeTable.put(idx, aSet);
91 public void addStrongUpdateVar(Integer idx, EffectsKey access) {
92 HashSet<EffectsKey> aSet = strongUpdateTable.get(idx);
94 aSet = new HashSet<EffectsKey>();
97 strongUpdateTable.put(idx, aSet);
100 public Set<EffectsKey> getReadingSet(Integer idx) {
101 return readTable.get(idx);
104 public Set<EffectsKey> getWritingSet(Integer idx) {
105 return writeTable.get(idx);
108 public Set<EffectsKey> getStrongUpdateSet(Integer idx) {
109 return strongUpdateTable.get(idx);
112 public void printSet() {
113 System.out.println("writeTable=>" + writeTable.hashCode());
115 Set<Integer> keySet = readTable.keySet();
116 Iterator<Integer> iter = keySet.iterator();
117 while (iter.hasNext()) {
118 Integer idx = iter.next();
119 Set<EffectsKey> effectSet = readTable.get(idx);
121 if (effectSet != null) {
122 Iterator<EffectsKey> effectIter = effectSet.iterator();
123 while (effectIter.hasNext()) {
124 EffectsKey key = effectIter.next();
130 System.out.println("param" + idx + " R=" + keyStr);
133 keySet = writeTable.keySet();
134 System.out.println("# R keyset=" + keySet.size());
135 iter = keySet.iterator();
136 while (iter.hasNext()) {
137 Integer idx = iter.next();
138 Set<EffectsKey> effectSet = writeTable.get(idx);
140 if (effectSet != null) {
141 Iterator<EffectsKey> effectIter = effectSet.iterator();
142 while (effectIter.hasNext()) {
143 EffectsKey key = effectIter.next();
149 System.out.println("param" + idx + " W=" + keyStr);
154 public boolean equals(Object o) {
159 if (!(o instanceof EffectsSet)) {
163 EffectsSet in = (EffectsSet) o;
165 if (getReadTable().equals(in.getReadTable())
166 && getWriteTable().equals(in.getWriteTable())
167 && getStrongUpdateTable().equals(in.getStrongUpdateTable())) {
175 public int hashCode() {
178 hash += getReadTable().hashCode() + getWriteTable().hashCode() * 31 + getStrongUpdateTable().hashCode();