Small changes to allow:
[repair.git] / Repair / RepairCompiler / MCC / IR / Binding.java
index 652c849a16e12b564a9c43be1cbec6c5d23f2d4b..33e9bae5f141a37b564d0820347843060380d5f5 100755 (executable)
@@ -2,23 +2,56 @@ package MCC.IR;
 
 class Binding {
     VarDescriptor var;
+    SetDescriptor sd;
     int position;
-    boolean search;
+    int type;
+    public static final int POSITION=1;
+    public static final int CREATE=2;
+    public static final int SEARCH=3;
+
     public Binding(VarDescriptor vd,int pos) {
        var=vd;
        position=pos;
-       search=false;
+       type=POSITION;
     }
 
-    public Binding(VarDescriptor vd) {
-       var=vd;
-       search=true;
+    public Binding(VarDescriptor vd, SetDescriptor sd,boolean search) {
+       this.var=vd;
+       this.sd=sd;
+       if (search)
+           type=SEARCH;
+       else
+           type=CREATE;
     }
+
+    public int getType() {
+       return type;
+    }
+
     int getPosition() {
+       assert type==POSITION;
        return position;
     }
+
+    SetDescriptor getSet() {
+       assert type==CREATE||type==SEARCH;
+       return sd;
+    }
+
     VarDescriptor getVar() {
        return var;
     }
 
+    public String toString() {
+       switch(type) {
+       case POSITION:
+           return var.toString()+"="+String.valueOf(position);
+       case CREATE:
+           return var.toString()+"=CREATE("+sd.toString()+")";
+       case SEARCH:
+           return var.toString()+"=SEARCH("+sd.toString()+")";
+       default:
+           return "UNRECOGNIZED Binding type";
+       }
+    }
 }