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 change tuple is a pair that indicates if the
27 // first ReachState is found in a ReachSet,
28 // then the second ReachState should be added
30 public class ChangeTuple extends Canonical
32 protected ReachState toMatch;
33 protected ReachState toAdd;
35 public static ChangeTuple factory(ReachState toMatch,
37 // we don't care about the predicates hanging on
38 // change tuple states, so always set them to empty
39 // to ensure change tuple sets work out
40 ReachState toMatchNoPreds =
41 ReachState.factory(toMatch.reachTuples,
42 ExistPredSet.factory()
44 ReachState toAddNoPreds =
45 ReachState.factory(toAdd.reachTuples,
46 ExistPredSet.factory()
48 ChangeTuple out = new ChangeTuple(toMatchNoPreds,
50 out = (ChangeTuple) Canonical.makeCanonical(out);
54 protected ChangeTuple(ReachState toMatch,
56 this.toMatch = toMatch;
60 public ReachState getStateToMatch() {
63 public ReachState getStateToAdd() {
68 public boolean equalsSpecific(Object o) {
73 if( !(o instanceof ChangeTuple) ) {
77 ChangeTuple ct = (ChangeTuple) o;
79 toMatch.equals(ct.toMatch) &&
80 toAdd.equals(ct.toAdd);
83 public int hashCodeSpecific() {
89 public String toString() {
90 return new String("("+toMatch+" -> "+toAdd+")");