make sure straight union of reach states or reach sets is never done, reach tuples...
[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 REACHSTATE_ATTACH_EXISTPREDSET       = 0x8358;
12   public static final int REACHSTATE_UNION_REACHSTATE          = 0x5678;
13   public static final int REACHSTATE_ADD_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_UNIONORPREDS_REACHSET       = 0x2131;
18   public static final int REACHSET_INTERSECTION_REACHSET       = 0x3361;
19   public static final int REACHSET_REMOVE_REACHSTATE           = 0x9391;
20   public static final int REACHSET_APPLY_CHANGESET             = 0x1d55;
21   public static final int REACHSET_UNIONTOCHANGESET_REACHSET   = 0x46a9;
22   public static final int REACHSET_AGETUPLESFROM_ALLOCSITE     = 0x22bb;
23   public static final int REACHSET_PRUNEBY_REACHSET            = 0xd774;
24   public static final int CHANGESET_UNION_CHANGESET            = 0x53b3;
25   public static final int CHANGESET_UNION_CHANGETUPLE          = 0x9ee4;
26   public static final int EXISTPREDSET_JOIN_EXISTPREDSET       = 0x8a21;
27   public static final int EXISTPREDSET_ADD_EXISTPRED           = 0xba5f;
28   public static final int PRIM_OP_UNUSED                       = 0xef01;
29   public static final int REACHSET_TOCALLEECONTEXT_ALLOCSITE   = 0x56f6;
30   public static final int REACHSTATE_TOCALLEECONTEXT_ALLOCSITE = 0x7faf;
31   public static final int REACHSET_TOCALLERCONTEXT_ALLOCSITE   = 0x2f6a;
32   public static final int REACHSTATE_TOCALLERCONTEXT_ALLOCSITE = 0xb2b1;
33   public static final int REACHSET_UNSHADOW_ALLOCSITE          = 0x1049;
34   public static final int REACHSTATE_UNSHADOW_ALLOCSITE        = 0x08ef;
35
36   protected int opCode;
37   protected Canonical operand1;
38   protected Canonical operand2;
39   protected int       operand3;
40
41   public CanonicalOp( int       opc,
42                       Canonical op1, 
43                       Canonical op2 ) {
44     this( opc, op1, op2, PRIM_OP_UNUSED );
45   }
46
47   public CanonicalOp( int       opc,
48                       Canonical op1, 
49                       Canonical op2,
50                       int       op3 ) {
51     assert op1.isCanonical();
52     assert op2.isCanonical();
53     opCode   = opc;
54     operand1 = op1;
55     operand2 = op2;
56     operand3 = op3;
57   }
58   
59   public int hashCode() {
60     return opCode ^
61       (operand1.getCanonicalValue() << 2) ^
62       (operand2.getCanonicalValue() << 1) ^
63       (operand3 << 3);
64   }
65
66   public boolean equals( Object o ) {
67     if( o == null ) {
68       return false;
69     }
70
71     CanonicalOp co = (CanonicalOp) o;
72     return opCode == co.opCode &&
73       (operand1.getCanonicalValue() == co.operand1.getCanonicalValue()) &&
74       (operand2.getCanonicalValue() == co.operand2.getCanonicalValue()) &&
75       operand3 == co.operand3;
76   }
77 }