rewriting of callee tokens into caller tokens was incorrect
[IRC.git] / Robust / src / Analysis / OwnershipAnalysis / ChangeTupleSet.java
1 package Analysis.OwnershipAnalysis;
2
3 import IR.*;
4 import IR.Flat.*;
5 import java.util.*;
6 import java.io.*;
7
8
9 public class ChangeTupleSet extends Canonical {
10
11   private HashSet<ChangeTuple> changeTuples;
12
13   public ChangeTupleSet() {
14     changeTuples = new HashSet<ChangeTuple>();
15   }
16
17   public ChangeTupleSet(ChangeTuple ct) {
18     this();
19     changeTuples.add(ct);
20   }
21
22   public ChangeTupleSet(ChangeTupleSet cts) {
23     changeTuples = (HashSet<ChangeTuple>)cts.changeTuples.clone();
24   }
25
26   public ChangeTupleSet makeCanonical() {
27     return (ChangeTupleSet) Canonical.makeCanonical(this);
28   }
29
30   public Iterator iterator() {
31     return changeTuples.iterator();
32   }
33
34   public int size() {
35     return changeTuples.size();
36   }
37
38   public ChangeTupleSet union(ChangeTupleSet ctsIn) {
39     assert ctsIn != null;
40
41     ChangeTupleSet ctsOut = new ChangeTupleSet(this);
42     ctsOut.changeTuples.addAll(ctsIn.changeTuples);
43     return ctsOut.makeCanonical();
44   }
45
46   public ChangeTupleSet union(ChangeTuple ctIn) {
47     assert ctIn != null;
48
49     ChangeTupleSet ctsOut = new ChangeTupleSet(this);
50     ctsOut.changeTuples.add(ctIn);
51     return ctsOut.makeCanonical();
52   }
53
54   public boolean isEmpty() {
55     return changeTuples.isEmpty();
56   }
57
58   public boolean isSubset(ChangeTupleSet ctsIn) {
59     assert ctsIn != null;
60     return ctsIn.changeTuples.containsAll(this.changeTuples);
61   }
62
63   public boolean equals(Object o) {
64     if( o == null ) {
65       return false;
66     }
67
68     if( !(o instanceof ChangeTupleSet) ) {
69       return false;
70     }
71
72     ChangeTupleSet cts = (ChangeTupleSet) o;
73     return changeTuples.equals(cts.changeTuples);
74   }
75
76   public int hashCode() {
77     return changeTuples.hashCode();
78   }
79
80   public String toString() {
81     String s = "[";
82
83     Iterator i = this.iterator();
84     while( i.hasNext() ) {
85       s += "\n  "+i.next();
86     }
87
88     s += "\n]";
89
90     return s;
91   }
92 }