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;
19 // only summary tokens should have ARITY_MANY?
20 public static final int ARITY_ONE = 1;
21 public static final int ARITY_MANY = 2;
24 public TokenTuple( HeapRegionNode hrn ) {
26 isNewSummary = hrn.isNewSummary();
30 public TokenTuple( Integer token,
34 this.isNewSummary = isNewSummary;
38 public TokenTuple makeCanonical() {
39 return (TokenTuple) Canonical.makeCanonical( this );
42 public Integer getToken() { return token; }
43 public int getArity() { return arity; }
45 public TokenTuple increaseArity() {
47 return (TokenTuple) Canonical.makeCanonical(
48 new TokenTuple( token, isNewSummary, ARITY_MANY )
54 public TokenTuple changeTokenTo( Integer tokenToChangeTo ) {
55 assert isNewSummary == false;
57 return new TokenTuple( tokenToChangeTo,
59 arity ).makeCanonical();
62 public boolean equals( Object o ) {
67 if( !(o instanceof TokenTuple) ) {
71 TokenTuple tt = (TokenTuple) o;
73 return token.equals( tt.getToken() ) &&
74 arity == tt.getArity();
77 public int hashCode() {
78 return token.intValue();
81 public String toString() {
88 if( arity == ARITY_MANY ) {
92 return new String( token+s+t );