1 package Analysis.OwnershipAnalysis;
9 // a token touple is a pair that indicates a
10 // heap region node and an arity
12 // THIS CLASS IS IMMUTABLE!
14 public class TokenTuple extends Canonical {
16 private Integer token;
17 private boolean isNewSummary;
20 // only summary tokens should have ARITY_MANY?
21 public static final int ARITY_ONE = 1;
22 public static final int ARITY_MANY = 2;
26 public TokenTuple(HeapRegionNode hrn) {
30 isNewSummary = hrn.isNewSummary();
34 public TokenTuple(Integer token,
40 this.isNewSummary = isNewSummary;
45 public TokenTuple makeCanonical() {
46 return (TokenTuple) Canonical.makeCanonical(this);
50 public Integer getToken() {
53 public int getArity() {
58 public TokenTuple increaseArity() {
60 return (TokenTuple) Canonical.makeCanonical(
61 new TokenTuple(token, isNewSummary, ARITY_MANY)
68 public TokenTuple changeTokenTo(Integer tokenToChangeTo) {
69 assert tokenToChangeTo != null;
70 assert isNewSummary == false;
72 return new TokenTuple(tokenToChangeTo,
74 arity).makeCanonical();
78 public boolean equals(Object o) {
83 if( !(o instanceof TokenTuple) ) {
87 TokenTuple tt = (TokenTuple) o;
89 return token.equals(tt.getToken() ) &&
90 arity == tt.getArity();
93 public int hashCode() {
94 return token.intValue()*31 + arity;
98 public String toString() {
99 String s = token.toString();
105 if( arity == ARITY_MANY ) {