64761bc5b038180e593188e9373d0f6c5d5286ad
[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_ADDUPARITY_REACHTUPLE     = 0x0a34;
16   public static final int REACHSTATE_REMOVE_REACHTUPLE         = 0x8173;
17   public static final int REACHSTATE_AGETUPLESFROM_ALLOCSITE   = 0x4f65;
18   public static final int REACHSET_UNIONORPREDS_REACHSET       = 0x2131;
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   public static final int REACHSET_TOCALLERCONTEXT_ALLOCSITE   = 0x2f6a;
33   public static final int REACHSTATE_TOCALLERCONTEXT_ALLOCSITE = 0xb2b1;
34   public static final int REACHSET_UNSHADOW_ALLOCSITE          = 0x1049;
35   public static final int REACHSTATE_UNSHADOW_ALLOCSITE        = 0x08ef;
36   public static final int REACHSTATE_CHANGEPREDSTO_EXISTPREDSET= 0x0b9c;
37   public static final int REACHSET_CHANGEPREDSTO_EXISTPREDSET  = 0xdead;
38   public static final int TAINT_ATTACH_EXISTPREDSET            = 0xcce2;
39   public static final int TAINTSET_ADD_TAINT                   = 0xcd17;
40   public static final int TAINTSET_UNION_TAINTSET              = 0xa835;
41   public static final int TAINTSET_UNIONORPREDS_TAINTSET       = 0x204f;
42   public static final int TAINT_CHANGEPREDSTO_EXISTPREDSET     = 0x3ab4;
43   public static final int TAINTSET_CHANGEPREDSTO_EXISTPREDSET  = 0x2ff1;
44   public static final int TAINTSET_REMOVESTALLSITETAINTS       = 0xb69c;
45
46   protected int opCode;
47   protected Canonical operand1;
48   protected Canonical operand2;
49   protected int       operand3;
50
51   public CanonicalOp( int       opc,
52                       Canonical op1, 
53                       Canonical op2 ) {
54     this( opc, op1, op2, PRIM_OP_UNUSED );
55   }
56
57   public CanonicalOp( int       opc,
58                       Canonical op1, 
59                       Canonical op2,
60                       int       op3 ) {
61     assert op1.isCanonical();
62     assert op2.isCanonical();
63     opCode   = opc;
64     operand1 = op1;
65     operand2 = op2;
66     operand3 = op3;
67   }
68   
69   public int hashCode() {
70     return opCode ^
71       (operand1.getCanonicalValue() << 2) ^
72       (operand2.getCanonicalValue() << 1) ^
73       (operand3 << 3);
74   }
75
76   public boolean equals( Object o ) {
77     if( o == null ) {
78       return false;
79     }
80
81     CanonicalOp co = (CanonicalOp) o;
82     return opCode == co.opCode &&
83       (operand1.getCanonicalValue() == co.operand1.getCanonicalValue()) &&
84       (operand2.getCanonicalValue() == co.operand2.getCanonicalValue()) &&
85       operand3 == co.operand3;
86   }
87 }