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() { return token; }
51 public int getArity() { return arity; }
54 public TokenTuple increaseArity() {
56 return (TokenTuple) Canonical.makeCanonical(
57 new TokenTuple( token, isNewSummary, ARITY_MANY )
64 public TokenTuple changeTokenTo( Integer tokenToChangeTo ) {
65 assert tokenToChangeTo != null;
66 assert isNewSummary == false;
68 return new TokenTuple( tokenToChangeTo,
70 arity ).makeCanonical();
74 public boolean equals( Object o ) {
79 if( !(o instanceof TokenTuple) ) {
83 TokenTuple tt = (TokenTuple) o;
85 return token.equals( tt.getToken() ) &&
86 arity == tt.getArity();
89 public int hashCode() {
90 return token.intValue()*31 + arity;
94 public String toString() {
95 String s = token.toString();
101 if( arity == ARITY_MANY ) {