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;
73 assert isNewSummary == false;
75 return new TokenTuple(tokenToChangeTo,
77 arity).makeCanonical();
81 public boolean equals(Object o) {
86 if( !(o instanceof TokenTuple) ) {
90 TokenTuple tt = (TokenTuple) o;
92 return token.equals(tt.getToken() ) &&
93 arity == tt.getArity();
96 public int hashCode() {
97 return token.intValue()*31 + arity;
101 public String toString() {
102 String s = token.toString();
108 if( arity == ARITY_MANY ) {