- /* Have update to call into */
- VarDescriptor mdfyptr=VarDescriptor.makeNew("modifyptr");
- cr.outputline("int "+mdfyptr.getSafeSymbol()+"="+repairtable.getSafeSymbol()+"->getrelation2("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
-
- String parttype="";
- for(int i=0;i<currentrule.numQuantifiers();i++) {
- if (currentrule.getQuantifier(i) instanceof RelationQuantifier)
- parttype=parttype+", int, int";
- else
- parttype=parttype+", int";
- }
- VarDescriptor funptr=VarDescriptor.makeNew("updateptr");
- VarDescriptor tmpptr=VarDescriptor.makeNew("tempupdateptr");
-
- String methodcall="("+funptr.getSafeSymbol()+") (this,"+oldmodel.getSafeSymbol()+","+repairtable.getSafeSymbol();
- for(int i=0;i<currentrule.numQuantifiers();i++) {
- Quantifier q=currentrule.getQuantifier(i);
- if (q instanceof SetQuantifier) {
- SetQuantifier sq=(SetQuantifier) q;
- methodcall+=","+sq.getVar().getSafeSymbol();
- } else if (q instanceof RelationQuantifier) {
- RelationQuantifier rq=(RelationQuantifier) q;
- methodcall+=","+rq.x.getSafeSymbol();
- methodcall+=","+rq.y.getSafeSymbol();
- } else if (q instanceof ForQuantifier) {
- ForQuantifier fq=(ForQuantifier) q;
- methodcall+=","+fq.getVar().getSafeSymbol();
+ /* Adding new item */
+ /* Perform safety checks */
+ cr.outputline("if ("+repairtable.getSafeSymbol()+"&&");
+ cr.outputline(repairtable.getSafeSymbol()+"->containsrelation("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+"))");
+ cr.startblock(); {
+ /* Have update to call into */
+ VarDescriptor mdfyptr=VarDescriptor.makeNew("modifyptr");
+ cr.outputline("int "+mdfyptr.getSafeSymbol()+"="+repairtable.getSafeSymbol()+"->getrelation2("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
+
+ String parttype="";
+ for(int i=0;i<currentrule.numQuantifiers();i++) {
+ if (currentrule.getQuantifier(i) instanceof RelationQuantifier)
+ parttype=parttype+", int, int";
+ else
+ parttype=parttype+", int";
+ }
+ VarDescriptor funptr=VarDescriptor.makeNew("updateptr");
+ VarDescriptor tmpptr=VarDescriptor.makeNew("tempupdateptr");
+
+ String methodcall="("+funptr.getSafeSymbol()+") (this,"+oldmodel.getSafeSymbol()+","+repairtable.getSafeSymbol();
+ for(int i=0;i<currentrule.numQuantifiers();i++) {
+ Quantifier q=currentrule.getQuantifier(i);
+ if (q instanceof SetQuantifier) {
+ SetQuantifier sq=(SetQuantifier) q;
+ methodcall+=","+sq.getVar().getSafeSymbol();
+ } else if (q instanceof RelationQuantifier) {
+ RelationQuantifier rq=(RelationQuantifier) q;
+ methodcall+=","+rq.x.getSafeSymbol();
+ methodcall+=","+rq.y.getSafeSymbol();
+ } else if (q instanceof ForQuantifier) {
+ ForQuantifier fq=(ForQuantifier) q;
+ methodcall+=","+fq.getVar().getSafeSymbol();
+ }
+ }
+
+
+
+ cr.outputline("void *"+tmpptr.getSafeSymbol()+"=");
+ cr.outputline("(void *) "+repairtable.getSafeSymbol()+"->getrelation("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
+ cr.outputline("if ("+mdfyptr.getSafeSymbol()+")");
+ {
+ cr.startblock();
+ cr.outputline("void (*"+funptr.getSafeSymbol()+") ("+name+"_state *,"+name+"*,RepairHash *"+parttype+",int,int,int)="+"(void (*) ("+name+"_state *,"+name+"*,RepairHash *"+parttype+",int,int,int)) "+tmpptr.getSafeSymbol()+";");
+ cr.outputline(methodcall+","+leftvar+", "+rightvar+", "+mdfyptr.getSafeSymbol() +");");
+ cr.endblock();