binding.put(b.getVar(),b);
}
+ public int numBindings() {
+ return bindings.size();
+ }
+
+ public Binding getBinding(int i) {
+ return (Binding)bindings.get(i);
+ }
+
public Binding getBinding(VarDescriptor vd) {
if (binding.containsKey(vd))
return (Binding)binding.get(vd);
return mun;
}
- public void generate_abstract(CodeWriter cr, boolean removal, String slot0, String slot1, Updates u, RepairGenerator rg) {
+ public void generate_abstract(CodeWriter cr, Updates u, RepairGenerator rg) {
State state=rg.state;
Expr abstractexpr=u.getLeftExpr();
boolean negated=u.negate;
left=toe.left;
right=toe.right;
istuple=true;
- } else if (abstractexpr instanceof TupleOfExpr) {
+ } else if (abstractexpr instanceof ElementOfExpr) {
ElementOfExpr eoe=(ElementOfExpr) abstractexpr;
d=eoe.set;
left=eoe.element;
Rule r=(Rule)state.vRules.get(i);
if (r.getInclusion().getTargetDescriptors().contains(sd)) {
for(int j=0;j<mun.numUpdates();j++) {
- UpdateNode un=mun.getUpdate(i);
+ UpdateNode un=mun.getUpdate(j);
if (un.getRule()==r) {
/* Update for rule rule r */
String name=(String)rg.updatenames.get(un);
}
- public void generate(CodeWriter cr, boolean removal, String slot0, String slot1, RepairGenerator rg) {
- if (!removal)
+ public void generate(CodeWriter cr, boolean removal, boolean modify, String slot0, String slot1, String slot2, RepairGenerator rg) {
+ if (!removal&&!modify)
generate_bindings(cr, slot0,slot1);
for(int i=0;i<updates.size();i++) {
Updates u=(Updates)updates.get(i);
VarDescriptor right=VarDescriptor.makeNew("right");
if (u.getType()==Updates.ABSTRACT) {
- generate_abstract(cr, removal, slot0, slot1, u, rg);
+ generate_abstract(cr, u, rg);
+ return;
}
switch(u.getType()) {
u.getRightExpr().generate(cr,right);
break;
case Updates.POSITION:
+ case Updates.ACCESSPATH:
if (u.getRightPos()==0)
cr.outputline("int "+right.getSafeSymbol()+"="+slot0+";");
else if (u.getRightPos()==1)
cr.outputline("int "+right.getSafeSymbol()+"="+slot1+";");
+ else if (u.getRightPos()==2)
+ cr.outputline("int "+right.getSafeSymbol()+"="+slot2+";");
else throw new Error("Error w/ Position");
break;
default:
throw new Error();
}
+
+ if (u.getType()==Updates.ACCESSPATH) {
+ VarDescriptor newright=VarDescriptor.makeNew("right");
+ /* Need to do the modulo computation here...FIXME */
+ right=newright;
+ }
VarDescriptor left=VarDescriptor.makeNew("left");
u.getLeftExpr().generate(cr,left);
Opcode op=u.getOpcode();
private void generate_bindings(CodeWriter cr, String slot0, String slot1) {
for(int i=0;i<bindings.size();i++) {
Binding b=(Binding)bindings.get(i);
- if (b.search)
- throw new Error("Search not implemented for bindings");
- VarDescriptor vd=b.getVar();
- switch(b.getPosition()) {
- case 0:
- cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"="+slot0+";");
- break;
- case 1:
- cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"="+slot1+";");
- break;
- default:
- throw new Error("Slot >1 doesn't exist.");
+
+ if (b.getType()==Binding.SEARCH) {
+ VarDescriptor vd=b.getVar();
+ cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"="+b.getSet().getSafeSymbol()+"->firstkey();");
+ } else if (b.getType()==Binding.CREATE) {
+ throw new Error("Creation not supported");
+ // source.generateSourceAlloc(cr,vd,b.getSet());
+ } else {
+ VarDescriptor vd=b.getVar();
+ switch(b.getPosition()) {
+ case 0:
+ cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"="+slot0+";");
+ break;
+ case 1:
+ cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"="+slot1+";");
+ break;
+ default:
+ throw new Error("Slot >1 doesn't exist.");
+ }
}
}
}