1 package Analysis.Disjoint;
8 ///////////////////////////////////////////
10 // This class is an immutable Canonical, so
12 // 0) construct them with a factory pattern
13 // to ensure only canonical versions escape
15 // 1) any operation that modifies a Canonical
16 // is a static method in the Canonical class
18 // 2) operations that just read this object
19 // should be defined here
21 // 3) every Canonical subclass hashCode should
22 // throw an error if the hash ever changes
24 ///////////////////////////////////////////
26 // a reach touple is a pair that indicates a
27 // heap region node and an arity
29 public class ReachTuple extends Canonical {
31 // defined by the source heap region
32 protected Integer hrnID;
33 protected boolean isMultiObject;
35 // arity of reachability paths from the
37 public static final int ARITY_ZEROORMORE = 0;
38 public static final int ARITY_ONE = 1;
39 public static final int ARITY_ONEORMORE = 2;
42 // whether this represents heap regions out
43 // of the current calling context or not
44 protected boolean isOutOfContext;
47 public static ReachTuple factory(Integer hrnID,
48 boolean isMultiObject,
51 ReachTuple out = new ReachTuple(hrnID,
55 out = (ReachTuple) Canonical.makeCanonical(out);
59 public static ReachTuple factory(HeapRegionNode hrn) {
60 ReachTuple out = new ReachTuple(hrn.getID(),
61 !hrn.isSingleObject(),
64 out = (ReachTuple) Canonical.makeCanonical(out);
68 protected ReachTuple(Integer hrnID,
69 boolean isMultiObject,
75 this.isMultiObject = isMultiObject;
77 this.isOutOfContext = ooc;
79 // just make sure this stuff is true now
80 // that analysis doesn't use ONEORMORE
81 assert arity != ARITY_ONEORMORE;
82 if( !isMultiObject ) {
83 assert arity == ARITY_ONE;
88 public Integer getHrnID() {
92 public boolean isMultiObject() {
96 public int getArity() {
100 public boolean isOutOfContext() {
101 return isOutOfContext;
105 public boolean equalsSpecific(Object o) {
110 if( !(o instanceof ReachTuple) ) {
114 ReachTuple rt = (ReachTuple) o;
116 return hrnID.equals(rt.hrnID) &&
118 isOutOfContext == rt.isOutOfContext;
121 public int hashCodeSpecific() {
122 int hash = (hrnID.intValue() << 2) ^ arity;
123 if( isOutOfContext ) {
130 public String toString() {
131 String s = hrnID.toString();
133 if( isMultiObject ) {
137 if( isOutOfContext ) {
141 if( arity == ARITY_ZEROORMORE ) {
143 } else if( arity == ARITY_ONEORMORE ) {