a start on reachability, not fully functioning yet
[IRC.git] / Robust / src / Analysis / Disjoint / CanonicalOp.java
1 package Analysis.Disjoint;
2
3 // a CanonicalOperation defines an operation on 
4 // Canonical objects.  The Canonical class maps
5 // an op to its result, so when you ask the
6 // Canonical static methods to do an op that is
7 // non-trivial, it will generate one of these
8 // first and do a result look-up
9 public class CanonicalOp {
10
11   public static final int REACHTUPLE_UNIONARITY_REACHTUPLE   = 0x1a34;
12   public static final int REACHSTATE_UNION_REACHSTATE        = 0x5678;
13   public static final int REACHSTATE_UNION_REACHTUPLE        = 0x32b6;
14   public static final int REACHSTATE_UNIONUPARITY_REACHSTATE = 0x9152;
15   public static final int REACHSTATE_REMOVE_REACHTUPLE       = 0x8173;
16   public static final int REACHSTATE_AGETUPLESFROM_ALLOCSITE = 0x4f65;
17   public static final int REACHSET_UNION_REACHSET            = 0x2131;
18   public static final int REACHSET_UNION_REACHSTATE          = 0xe3c8;
19   public static final int REACHSET_INTERSECTION_REACHSET     = 0x3361;
20   public static final int REACHSET_REMOVE_REACHSTATE         = 0x9391;
21   public static final int REACHSET_APPLY_CHANGESET           = 0x1d55;
22   public static final int REACHSET_UNIONTOCHANGESET_REACHSET = 0x46a9;
23   public static final int REACHSET_AGETUPLESFROM_ALLOCSITE   = 0x22bb;
24   public static final int REACHSET_PRUNEBY_REACHSET          = 0xd774;
25   public static final int CHANGESET_UNION_CHANGESET          = 0x53b3;
26   public static final int CHANGESET_UNION_CHANGETUPLE        = 0x9ee4;
27   public static final int EXISTPREDSET_JOIN_EXISTPREDSET     = 0x8a21;
28   public static final int EXISTPREDSET_ADD_EXISTPRED         = 0xba5f;
29   public static final int PRIM_OP_UNUSED                     = 0xef01;
30   public static final int REACHSET_TOCALLEECONTEXT_ALLOCSITE = 0x56f6;
31   public static final int REACHSTATE_TOCALLEECONTEXT_ALLOCSITE = 0x7faf;
32
33   protected int opCode;
34   protected Canonical operand1;
35   protected Canonical operand2;
36   protected int       operand3;
37
38   public CanonicalOp( int       opc,
39                       Canonical op1, 
40                       Canonical op2 ) {
41     this( opc, op1, op2, PRIM_OP_UNUSED );
42   }
43
44   public CanonicalOp( int       opc,
45                       Canonical op1, 
46                       Canonical op2,
47                       int       op3 ) {
48     assert op1.isCanonical();
49     assert op2.isCanonical();
50     opCode   = opc;
51     operand1 = op1;
52     operand2 = op2;
53     operand3 = op3;
54   }
55   
56   public int hashCode() {
57     return opCode ^
58       (operand1.getCanonicalValue() << 2) ^
59       (operand2.getCanonicalValue() << 1) ^
60       (operand3 << 3);
61   }
62
63   public boolean equals( Object o ) {
64     if( o == null ) {
65       return false;
66     }
67
68     CanonicalOp co = (CanonicalOp) o;
69     return opCode == co.opCode &&
70       (operand1.getCanonicalValue() == co.operand1.getCanonicalValue()) &&
71       (operand2.getCanonicalValue() == co.operand2.getCanonicalValue()) &&
72       operand3 == co.operand3;
73   }
74 }