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 // acutally, multiple-object regions can be arity-many
22 // so isNewSummary actually means "multi-object" in
23 // this class. CHANGE THIS SOMETIME!
24 public static final int ARITY_ONE = 1;
25 public static final int ARITY_MANY = 2;
29 public TokenTuple(HeapRegionNode hrn) {
33 isNewSummary = hrn.isNewSummary();
37 public TokenTuple(Integer token,
43 this.isNewSummary = isNewSummary;
48 public TokenTuple makeCanonical() {
49 return (TokenTuple) Canonical.makeCanonical(this);
53 public Integer getToken() {
56 public int getArity() {
61 public TokenTuple increaseArity() {
63 return (TokenTuple) Canonical.makeCanonical(
64 new TokenTuple(token, isNewSummary, ARITY_MANY)
71 public TokenTuple changeTokenTo(Integer tokenToChangeTo) {
72 assert tokenToChangeTo != null;
74 return new TokenTuple(tokenToChangeTo,
76 arity).makeCanonical();
80 public boolean equals(Object o) {
85 if( !(o instanceof TokenTuple) ) {
89 TokenTuple tt = (TokenTuple) o;
91 return token.equals(tt.getToken() ) &&
92 arity == tt.getArity();
95 public int hashCode() {
96 return token.intValue()*31 + arity;
100 public String toString() {
101 String s = token.toString();
107 if( arity == ARITY_MANY ) {