Change to the spec...missed a consistency property. Adding timing option.
[repair.git] / Repair / RepairCompiler / MCC / IR / Binding.java
1 package MCC.IR;
2
3 class Binding {
4     VarDescriptor var;
5     SetDescriptor sd;
6     int position;
7     int type;
8     public static final int POSITION=1;
9     public static final int CREATE=2;
10     public static final int SEARCH=3;
11
12     public Binding(VarDescriptor vd,int pos) {
13         var=vd;
14         position=pos;
15         type=POSITION;
16     }
17
18     public Binding(VarDescriptor vd, SetDescriptor sd,boolean search) {
19         this.var=vd;
20         this.sd=sd;
21         if (search)
22             type=SEARCH;
23         else
24             type=CREATE;
25     }
26
27     public int getType() {
28         return type;
29     }
30
31     int getPosition() {
32         assert type==POSITION;
33         return position;
34     }
35
36     SetDescriptor getSet() {
37         assert type==CREATE||type==SEARCH;
38         return sd;
39     }
40
41     VarDescriptor getVar() {
42         return var;
43     }
44
45     public String toString() {
46         switch(type) {
47         case POSITION:
48             return var.toString()+"="+String.valueOf(position);
49         case CREATE:
50             return var.toString()+"=CREATE("+sd.toString()+")";
51         case SEARCH:
52             return var.toString()+"=SEARCH("+sd.toString()+")";
53         default:
54             return "UNRECOGNIZED Binding type";
55         }
56     }
57 }