changes
[IRC.git] / Robust / src / Analysis / OwnershipAnalysis / SubstitutionTuple.java
1 package Analysis.OwnershipAnalysis;
2
3 import IR.*;
4 import IR.Flat.*;
5 import java.util.*;
6 import java.io.*;
7
8
9 // a change touple is a pair that indicates if the
10 // first TokenTupleSet is found in a ReachabilitySet,
11 // then the second TokenTupleSet should be added
12
13 // THIS CLASS IS IMMUTABLE!
14
15 public class ChangeTuple extends Canonical
16 {
17   private TokenTupleSet toMatch;
18   private TokenTupleSet toAdd;
19
20   public ChangeTuple(TokenTupleSet toMatch,
21                      TokenTupleSet toAdd) {
22     this.toMatch = toMatch;
23     this.toAdd   = toAdd;
24   }
25
26   public ChangeTuple makeCanonical() {
27     return (ChangeTuple) Canonical.makeCanonical(this);
28   }
29
30   public TokenTupleSet getSetToMatch() {
31     return toMatch;
32   }
33   public TokenTupleSet getSetToAdd() {
34     return toAdd;
35   }
36
37   public boolean equals(Object o) {
38     if( o == null ) {
39       return false;
40     }
41
42     if( !(o instanceof ChangeTuple) ) {
43       return false;
44     }
45
46     ChangeTuple ct = (ChangeTuple) o;
47
48     return toMatch.equals(ct.getSetToMatch() ) &&
49            toAdd.equals(ct.getSetToAdd()   );
50   }
51
52   public int hashCode() {
53     return toMatch.hashCode() + toAdd.hashCode();
54   }
55
56   public String toString() {
57     return new String("<"+toMatch+" -> "+toAdd+">");
58   }
59 }