public class RepairGenerator {
State state;
- java.io.PrintWriter outputrepair = null;
- java.io.PrintWriter outputaux = null;
- java.io.PrintWriter outputhead = null;
+ PrintWrapper outputrepair = null;
+ PrintWrapper outputaux = null;
+ PrintWrapper outputhead = null;
String name="foo";
String headername;
static VarDescriptor oldmodel=null;
}
public void generate(OutputStream outputrepair, OutputStream outputaux,OutputStream outputhead, String st) {
- this.outputrepair = new java.io.PrintWriter(outputrepair, true);
- this.outputaux = new java.io.PrintWriter(outputaux, true);
- this.outputhead = new java.io.PrintWriter(outputhead, true);
+ this.outputrepair = new PrintWrapper(new java.io.PrintWriter(outputrepair, true));
+ this.outputaux = new PrintWrapper(new java.io.PrintWriter(outputaux, true));
+ this.outputhead = new PrintWrapper(new java.io.PrintWriter(outputhead, true));
headername=st;
name_updates();
generate_teardown();
CodeWriter crhead = new StandardCodeWriter(this.outputhead);
craux = new StandardCodeWriter(this.outputaux);
- craux.outputline("}");
+ craux.emptyBuffer();
+ craux.endblock();
if (Compiler.GENERATEDEBUGHOOKS) {
crhead.outputline("void debughook();");
craux.outputline("void "+methodname+"(struct "+name+"_state * "+ststate+", struct "+name+" * "+stmodel+", struct RepairHash * "+strepairtable+", int "+stleft+")");
}
craux.startblock();
- craux.outputline("int maybe=0;");
+ craux.startBuffer();
+ craux.addDeclaration("int","maybe");
+ craux.outputline("maybe=0;");
if (Compiler.GENERATEINSTRUMENT)
craux.outputline("updatecount++;");
};
un.generate(cr, false, false, stleft,stright, null,this);
craux.outputline("if (maybe) printf(\"REALLY BAD\");");
+ craux.emptyBuffer();
craux.endblock();
break;
case MultUpdateNode.REMOVE: {
crhead.outputline(methodcall+";");
craux.outputline(methodcall);
craux.startblock();
- craux.outputline("int maybe=0;");
+ craux.startBuffer();
+ craux.addDeclaration("int","maybe");
+ craux.outputline("maybe=0;");
if (Compiler.GENERATEINSTRUMENT)
craux.outputline("updatecount++;");
final SymbolTable st2 = un.getRule().getSymbolTable();
};
un.generate(cr2, true, false, null,null, null,this);
craux.outputline("if (maybe) printf(\"REALLY BAD\");");
+ craux.emptyBuffer();
craux.endblock();
}
break;
crhead.outputline(methodcall+";");
craux.outputline(methodcall);
craux.startblock();
+ craux.startBuffer();
craux.outputline("int maybe=0;");
if (Compiler.GENERATEINSTRUMENT)
craux.outputline("updatecount++;");
};
un.generate(cr2, false, true, stleft, stright, stnew, this);
craux.outputline("if (maybe) printf(\"REALLY BAD\");");
+ craux.emptyBuffer();
craux.endblock();
}
break;
private void generate_call() {
CodeWriter cr = new StandardCodeWriter(outputrepair);
VarDescriptor vdstate=VarDescriptor.makeNew("repairstate");
- cr.outputline("struct "+ name+"_state * "+vdstate.getSafeSymbol()+"=allocate"+name+"_state();");
+ cr.addDeclaration("struct "+ name+"_state *", vdstate.getSafeSymbol());
+ cr.outputline(vdstate.getSafeSymbol()+"=allocate"+name+"_state();");
Iterator globals=state.stGlobals.descriptors();
while (globals.hasNext()) {
VarDescriptor vd=(VarDescriptor) globals.next();
public SymbolTable getSymbolTable() { return st; }
};
- cr.outputline("void "+name+"_statecomputesizes(struct "+name+"_state * thisvar,int *sizearray,int **numele) {");
- cr.outputline("int maybe=0;");
+ cr.outputline("void "+name+"_statecomputesizes(struct "+name+"_state * thisvar,int *sizearray,int **numele)");
+ cr.startblock();
+ cr.startBuffer();
+ cr.addDeclaration("int","maybe");
+ cr.outputline("maybe=0;");
for(int i=0;i<max;i++) {
TypeDescriptor td=tdarray[i];
Expr size=td.getSizeExpr();
}
}
cr.outputline("if (maybe) printf(\"BAD ERROR\");");
- cr.outputline("}");
+ cr.emptyBuffer();
+ cr.endblock();
}
private void generate_recomputesizes() {
CodeWriter cr = new StandardCodeWriter(outputaux) {
public SymbolTable getSymbolTable() { return st; }
};
- cr.outputline("void "+name+"_staterecomputesizes(struct "+name+"_state * thisvar) {");
- cr.outputline("int maybe=0;");
+ cr.outputline("void "+name+"_staterecomputesizes(struct "+name+"_state * thisvar)");
+ cr.startblock();
+ cr.startBuffer();
+ cr.addDeclaration("int","maybe");
+ cr.outputline("maybe=0;");
for(int i=0;i<max;i++) {
TypeDescriptor td=tdarray[i];
Expr size=td.getSizeExpr();
}
}
cr.outputline("if (maybe) printf(\"BAD ERROR\");");
- cr.outputline("}");
+ cr.emptyBuffer();
+ cr.endblock();
}
}
}
}
- craux.outputline("struct "+ name+"* "+name+"() {");
+ craux.outputline("struct "+ name+"* "+name+"()");
+ craux.startblock();
craux.outputline("/* creating hashtables */");
/* build sets */
Iterator sets = state.stSets.descriptors();
- craux.outputline("struct "+name+"* thisvar=(struct "+name+"*) malloc(sizeof(struct "+name+"));");
+ craux.addDeclaration("struct "+name+"*", "thisvar");
+ craux.outputline("thisvar=(struct "+name+"*) malloc(sizeof(struct "+name+"));");
/* first pass create all the hash tables */
while (sets.hasNext()) {
}
}
- craux.outputline("}");
+ craux.endblock();
crhead.outputline("};");
- craux.outputline("void free"+name+"(struct "+ name +"* thisvar) {");
+ craux.outputline("void free"+name+"(struct "+ name +"* thisvar)");
+ craux.startblock();
craux.outputline("/* deleting hashtables */");
/* build destructor */
}
}
craux.outputline("free(thisvar);");
- craux.outputline("}");
+ craux.endblock();
}
private void generate_start() {
crhead.outputline("void doanalysis(struct "+name+"_state *);");
craux.outputline("void doanalysis(struct "+name+"_state * thisvar)");
craux.startblock();
+ craux.startBuffer();
if (Compiler.TIME) {
craux.outputline("struct timeval _begin_time,_end_time;");
craux.outputline("gettimeofday(&_begin_time,NULL);");
craux.outputline("rebuildcount=0;");
craux.outputline("abstractcount=0;");
}
- craux.outputline("int highmark;");
- craux.outputline("struct "+name+ " * "+oldmodel.getSafeSymbol()+"=0;");
- craux.outputline("struct WorkList * "+worklist.getSafeSymbol()+" = allocateWorkList();");
- craux.outputline("struct RepairHash * "+repairtable.getSafeSymbol()+"=0;");
+ craux.addDeclaration("int","highmark");
+
+ craux.addDeclaration("struct "+name+ " * ",oldmodel.getSafeSymbol());
+ craux.outputline(oldmodel.getSafeSymbol()+"=0;");
+ craux.addDeclaration("struct WorkList * ",worklist.getSafeSymbol());
+ craux.outputline(worklist.getSafeSymbol()+" = allocateWorkList();");
+ craux.addDeclaration("struct RepairHash * ",repairtable.getSafeSymbol());
+ craux.outputline(repairtable.getSafeSymbol()+"=0;");
craux.outputline("initializestack(&highmark);");
craux.outputline("computesizes(thisvar);");
craux.outputline(name+"_staterecomputesizes(thisvar);");
craux.outputline("while (1)");
craux.startblock();
- craux.outputline("struct "+name+ " * "+newmodel.getSafeSymbol()+"=allocate"+name+"();");
+ craux.addDeclaration("struct "+name+ " * ",newmodel.getSafeSymbol());
+ craux.outputline(newmodel.getSafeSymbol()+"=allocate"+name+"();");
craux.outputline("WorkListreset("+worklist.getSafeSymbol()+");");
if (Compiler.GENERATEINSTRUMENT)
craux.outputline("rebuildcount++;");
cr.startblock();
cr.outputline("/* printing set " + setname+"*/");
cr.outputline("printf(\"\\nPrinting set " + sd.getSymbol() + " - %d elements \\n\", SimpleHashcountset("+setname+"_hash));");
- cr.outputline("struct SimpleIterator __setiterator;");
- cr.outputline("SimpleHashiterator(&"+setname+"_hash,__setiterator);");
+ cr.addDeclaration("struct SimpleIterator","__setiterator");
+ cr.outputline("SimpleHashiterator("+setname+"_hash,&__setiterator);");
cr.outputline("while (hasNext(&__setiterator))");
cr.startblock();
- cr.outputline("int __setval = (int) next(&__setiterator);");
+ cr.addDeclaration("int","__setval");
+ cr.outputline("__setval = (int) next(&__setiterator);");
TypeDescriptor td = sd.getType();
if (td instanceof StructureTypeDescriptor) {
cr.outputline("/* build " +escape(rule.toString())+"*/");
cr.startblock();
- cr.outputline("int maybe=0;");
+ cr.addDeclaration("int","maybe");
+ cr.outputline("maybe=0;");
Expr ruleexpr=rule.getGuardExpr();
HashSet invariantvars=new HashSet();
VarDescriptor tmpvd=VarDescriptor.makeNew("tmpvar");
VarDescriptor maybevd=VarDescriptor.makeNew("maybevar");
invexpr.generate(cr,tmpvd);
- cr.outputline("int "+maybevd.getSafeSymbol()+"=maybe;");
+ cr.addDeclaration("int ",maybevd.getSafeSymbol());
+ cr.outputline(maybevd.getSafeSymbol()+"=maybe;");
cr.outputline("maybe=0;");
ivalue.assignPair(invexpr,tmpvd,maybevd);
openparencount++;
cr2.outputline("while (WorkListhasMoreElements("+worklist.getSafeSymbol()+"))");
cr2.startblock();
VarDescriptor idvar=VarDescriptor.makeNew("id");
- cr2.outputline("int "+idvar.getSafeSymbol()+"=WorkListgetid("+worklist.getSafeSymbol()+");");
+ cr2.addDeclaration("int ",idvar.getSafeSymbol());
+ cr2.outputline(idvar.getSafeSymbol()+"=WorkListgetid("+worklist.getSafeSymbol()+");");
String elseladder = "if";
cr.indent();
cr.outputline(elseladder + " ("+idvar.getSafeSymbol()+" == " + dispatchid + ")");
cr.startblock();
- cr.outputline("int maybe=0;");
+ cr.addDeclaration("int","maybe");
+ cr.outputline("maybe=0;");
VarDescriptor typevar=VarDescriptor.makeNew("type");
VarDescriptor leftvar=VarDescriptor.makeNew("left");
VarDescriptor rightvar=VarDescriptor.makeNew("right");
- cr.outputline("int "+typevar.getSafeSymbol()+"= WorkListgettype("+worklist.getSafeSymbol()+");");
- cr.outputline("int "+leftvar.getSafeSymbol()+"= WorkListgetlvalue("+worklist.getSafeSymbol()+");");
- cr.outputline("int "+rightvar.getSafeSymbol()+"= WorkListgetrvalue("+worklist.getSafeSymbol()+");");
+ cr.addDeclaration("int",typevar.getSafeSymbol());
+ cr.outputline(typevar.getSafeSymbol()+"= WorkListgettype("+worklist.getSafeSymbol()+");");
+ cr.addDeclaration("int",leftvar.getSafeSymbol());
+ cr.outputline(leftvar.getSafeSymbol()+"= WorkListgetlvalue("+worklist.getSafeSymbol()+");");
+ cr.addDeclaration("int",rightvar.getSafeSymbol());
+ cr.outputline(rightvar.getSafeSymbol()+"= WorkListgetrvalue("+worklist.getSafeSymbol()+");");
cr.outputline("/* build " +escape(rule.toString())+"*/");
quantifier.generate_open(cr);
}
- cr.outputline("int maybe = 0;");
+ cr.addDeclaration("int","maybe");
+ cr.outputline("maybe = 0;");
/* now we have to generate the guard test */
dnfconst.addAll((Set)termination.conjunctionmap.get(constraint));
if (dnfconst.size()<=1) {
- cr.outputline("int "+mincostindex.getSafeSymbol()+"=0;");
+ cr.addDeclaration("int",mincostindex.getSafeSymbol());
+ cr.outputline(mincostindex.getSafeSymbol()+"=0;");
}
if (dnfconst.size()>1) {
- cr.outputline("int "+mincostindex.getSafeSymbol()+";");
+ cr.addDeclaration("int",mincostindex.getSafeSymbol());
boolean first=true;
for(int j=0;j<dnfconst.size();j++) {
GraphNode gn=(GraphNode)dnfconst.get(j);
boolean negate=dpred.isNegated();
VarDescriptor predvalue=VarDescriptor.makeNew("Predicatevalue");
p.generate(cr,predvalue);
- if (k==0)
- cr.outputline("int "+costvar.getSafeSymbol()+"=0;");
-
+ if (k==0) {
+ cr.addDeclaration("int",costvar.getSafeSymbol());
+ cr.outputline(costvar.getSafeSymbol()+"=0;");
+ }
if (negate)
cr.outputline("if (maybe||"+predvalue.getSafeSymbol()+")");
else
first=false;
}
}
- cr.outputline("switch("+mincostindex.getSafeSymbol()+") {");
+ cr.outputline("switch("+mincostindex.getSafeSymbol()+")");
+ cr.startblock();
for(int j=0;j<dnfconst.size();j++) {
GraphNode gn=(GraphNode)dnfconst.get(j);
Conjunction conj=((TermNode)gn.getOwner()).getConjunction();
cr.endblock();
cr.outputline("break;");
}
- cr.outputline("}");
+ cr.endblock();
cr.outputline("if ("+oldmodel.getSafeSymbol()+")");
cr.outputline("free"+name+"("+oldmodel.getSafeSymbol()+");");
System.out.println("Warning: need to have individual remove operations for"+dpred.name());
needremoveloop=false;
}
- if (needremoveloop)
- cr.outputline("while (1) {");
-
+ if (needremoveloop) {
+ cr.outputline("while (1)");
+ cr.startblock();
+ }
if (!inverted) {
((RelationExpr)expr.getLeftExpr()).getExpr().generate(cr,leftside);
expr.getRightExpr().generate(cr,newvalue);
- cr.outputline(rd.getRange().getType().getGenerateType().getSafeSymbol()+" "+rightside.getSafeSymbol()+";");
+ cr.addDeclaration(rd.getRange().getType().getGenerateType().getSafeSymbol(),rightside.getSafeSymbol());
cr.outputline("SimpleHashget("+rd.getSafeSymbol()+"_hash,"+leftside.getSafeSymbol()+", &"+rightside.getSafeSymbol()+");");
} else {
((RelationExpr)expr.getLeftExpr()).getExpr().generate(cr,rightside);
if (needremoveloop) {
if (!inverted) {
- cr.outputline("if (SimpleHashcontainskey("+rd.getSafeSymbol()+"_hash, "+leftside.getSafeSymbol()+")) {");
+ cr.outputline("if (SimpleHashcontainskey("+rd.getSafeSymbol()+"_hash, "+leftside.getSafeSymbol()+"))");
+ cr.startblock();
} else {
- cr.outputline("if (SimpleHashcontainskey("+rd.getSafeSymbol()+"_hashinv, "+rightside.getSafeSymbol()+")) {");
+ cr.outputline("if (SimpleHashcontainskey("+rd.getSafeSymbol()+"_hashinv, "+rightside.getSafeSymbol()+"))");
+ cr.startblock();
}
for(int i=0;i<state.vRules.size();i++) {
Rule r=(Rule)state.vRules.get(i);
}
}
cr.outputline("continue;");
- cr.outputline("}");
+ cr.endblock();
}
if (usageimage) {
}
if (needremoveloop) {
cr.outputline("break;");
- cr.outputline("}");
+ cr.endblock();
}
}
VarDescriptor sizevar=VarDescriptor.makeNew("size");
((OpExpr)expr).left.generate(cr, sizevar);
VarDescriptor change=VarDescriptor.makeNew("change");
- cr.outputline("int "+change.getSafeSymbol()+";");
+ cr.addDeclaration("int",change.getSafeSymbol());
boolean generateadd=false;
boolean generateremove=false;
if (opcode==Opcode.GT) {
if (d instanceof RelationDescriptor) {
if (ep.inverted()) {
((ImageSetExpr)((SizeofExpr)expr.left).setexpr).generate_leftside(cr,rightvar);
- cr.outputline("int "+leftvar.getSafeSymbol()+";");
+ cr.addDeclaration("int",leftvar.getSafeSymbol());
cr.outputline("SimpleHashget("+d.getSafeSymbol()+"_hashinv,(int)"+rightvar.getSafeSymbol()+", &"+leftvar.getSafeSymbol()+");");
} else {
((ImageSetExpr)((SizeofExpr)expr.left).setexpr).generate_leftside(cr,leftvar);
- cr.outputline("int "+rightvar.getSafeSymbol()+"=0;");
+ cr.addDeclaration("int",rightvar.getSafeSymbol());
cr.outputline("SimpleHashget("+d.getSafeSymbol()+"_hash ,(int)"+leftvar.getSafeSymbol()+", &"+rightvar.getSafeSymbol()+");");
}
} else {
- cr.outputline("int "+leftvar.getSafeSymbol()+"= SimpleHashfirstkey("+d.getSafeSymbol()+"_hash);");
+ cr.addDeclaration("int",leftvar.getSafeSymbol());
+ cr.outputline(leftvar.getSafeSymbol()+"= SimpleHashfirstkey("+d.getSafeSymbol()+"_hash);");
}
/* Generate abstract remove instruction */
if (d instanceof RelationDescriptor) {
/* Set Source */
SetDescriptor sd=termination.sources.relgetSourceSet(rd,!ep.inverted());
VarDescriptor iterator=VarDescriptor.makeNew("iterator");
- cr.outputline(sd.getType().getGenerateType().getSafeSymbol() +" "+newobject.getSafeSymbol()+";");
- cr.outputline("struct SimpleIterator "+iterator.getSafeSymbol()+";");
- cr.outputline("for(SimpleHashiterator(& "+sd.getSafeSymbol()+"_hash ,"+ iterator.getSafeSymbol() +");"+iterator.getSafeSymbol()+".hasNext();)");
+ cr.addDeclaration(sd.getType().getGenerateType().getSafeSymbol(),newobject.getSafeSymbol());
+ cr.addDeclaration("struct SimpleIterator",iterator.getSafeSymbol());
+ cr.outputline("for(SimpleHashiterator("+sd.getSafeSymbol()+"_hash , &"+ iterator.getSafeSymbol() +"); hasNext(&"+iterator.getSafeSymbol()+");)");
cr.startblock();
if (ep.inverted()) {
cr.outputline("if (!SimpleHashcontainskeydata("+rd.getSafeSymbol()+"_hashinv,"+iterator.getSafeSymbol()+".key(),"+otherside.getSafeSymbol()+"))");
} else {
cr.outputline("if (!SimpleHashcontainskeydata("+rd.getSafeSymbol()+"_hash, "+otherside.getSafeSymbol()+","+iterator.getSafeSymbol()+".key()))");
}
- cr.outputline(newobject.getSafeSymbol()+"=key("+iterator.getSafeSymbol()+");");
- cr.outputline("next("+iterator.getSafeSymbol()+");");
+ cr.outputline(newobject.getSafeSymbol()+"=key(&"+iterator.getSafeSymbol()+");");
+ cr.outputline("next(&"+iterator.getSafeSymbol()+");");
cr.endblock();
} else if (termination.sources.relallocSource(rd,!ep.inverted())) {
/* Allocation Source*/
/* Set Source */
SetDescriptor sourcesd=termination.sources.getSourceSet(sd);
VarDescriptor iterator=VarDescriptor.makeNew("iterator");
- cr.outputline(sourcesd.getType().getGenerateType().getSafeSymbol() +" "+newobject.getSafeSymbol()+";");
- cr.outputline("SimpleIterator "+iterator.getSafeSymbol()+";");
- cr.outputline("for(SimpleHashiterator("+sourcesd.getSafeSymbol()+"_hash, "+iterator.getSafeSymbol()+");"+iterator.getSafeSymbol()+".hasNext();)");
+ cr.addDeclaration(sourcesd.getType().getGenerateType().getSafeSymbol(), newobject.getSafeSymbol());
+ cr.addDeclaration("struct SimpleIterator",iterator.getSafeSymbol());
+ cr.outputline("for(SimpleHashiterator("+sourcesd.getSafeSymbol()+"_hash, &"+iterator.getSafeSymbol()+"); hasNext(&"+iterator.getSafeSymbol()+");)");
cr.startblock();
- cr.outputline("if (!SimpleHashcontainskey("+sd.getSafeSymbol()+"_hash, key("+iterator.getSafeSymbol()+")))");
- cr.outputline(newobject.getSafeSymbol()+"=key("+iterator.getSafeSymbol()+");");
- cr.outputline("next("+iterator.getSafeSymbol()+");");
+ cr.outputline("if (!SimpleHashcontainskey("+sd.getSafeSymbol()+"_hash, key(&"+iterator.getSafeSymbol()+")))");
+ cr.outputline(newobject.getSafeSymbol()+"=key(&"+iterator.getSafeSymbol()+");");
+ cr.outputline("next(&"+iterator.getSafeSymbol()+");");
cr.endblock();
} else if (termination.sources.allocSource(sd)) {
/* Allocation Source*/
/* Have update to call into */
VarDescriptor mdfyptr=VarDescriptor.makeNew("modifyptr");
VarDescriptor ismdfyptr=VarDescriptor.makeNew("ismodifyptr");
- cr.outputline("int "+ismdfyptr.getSafeSymbol()+"=RepairHashismodify("+repairtable.getSafeSymbol()+","+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
+ cr.addDeclaration("int ",ismdfyptr.getSafeSymbol());
+ cr.outputline(ismdfyptr.getSafeSymbol()+"=RepairHashismodify("+repairtable.getSafeSymbol()+","+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
else
parttype=parttype+", int";
}
- VarDescriptor funptr=VarDescriptor.makeNew("updateptr");
+
VarDescriptor tmpptr=VarDescriptor.makeNew("tempupdateptr");
- String methodcall="("+funptr.getSafeSymbol()+") (thisvar,"+oldmodel.getSafeSymbol()+","+repairtable.getSafeSymbol();
+ String methodcall="(thisvar,"+oldmodel.getSafeSymbol()+","+repairtable.getSafeSymbol();
for(int i=0;i<currentrule.numQuantifiers();i++) {
Quantifier q=currentrule.getQuantifier(i);
if (q instanceof SetQuantifier) {
- cr.outputline("void *"+tmpptr.getSafeSymbol()+"=");
+ cr.addDeclaration("void *",tmpptr.getSafeSymbol());
+ cr.outputline(tmpptr.getSafeSymbol()+"=");
cr.outputline("(void *) RepairHashgetrelation("+repairtable.getSafeSymbol()+","+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
cr.outputline("if ("+ismdfyptr.getSafeSymbol()+")");
{
+ VarDescriptor funptr=VarDescriptor.makeNew("updateptr");
+ String methodcallprefix="("+funptr.getSafeSymbol()+") ";
cr.startblock();
- cr.outputline("int "+mdfyptr.getSafeSymbol()+"=RepairHashgetrelation2("+repairtable.getSafeSymbol()+","+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
- cr.outputline("void (*"+funptr.getSafeSymbol()+") (struct "+name+"_state *, struct "+name+"*, struct RepairHash *"+parttype+",int,int,int)="+"(void (*) (struct "+name+"_state *, struct "+name+"*, struct RepairHash *"+parttype+",int,int,int)) "+tmpptr.getSafeSymbol()+";");
- cr.outputline(methodcall+","+leftvar+", "+rightvar+", "+mdfyptr.getSafeSymbol() +");");
+ cr.addDeclaration("int",mdfyptr.getSafeSymbol());
+ cr.outputline(mdfyptr.getSafeSymbol()+"=RepairHashgetrelation2("+repairtable.getSafeSymbol()+","+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
+ cr.addDeclaration("void (*"+funptr.getSafeSymbol()+") (struct "+name+"_state *, struct "+name+"*, struct RepairHash *"+parttype+",int,int,int);");
+ cr.outputline(funptr.getSafeSymbol()+"="+"(void (*) (struct "+name+"_state *, struct "+name+"*, struct RepairHash *"+parttype+",int,int,int)) "+tmpptr.getSafeSymbol()+";");
+ cr.outputline(methodcallprefix+methodcall+","+leftvar+", "+rightvar+", "+mdfyptr.getSafeSymbol() +");");
cr.endblock();
}
cr.outputline("else ");
{
+ VarDescriptor funptr=VarDescriptor.makeNew("updateptr");
+ String methodcallprefix="("+funptr.getSafeSymbol()+") ";
cr.startblock();
- cr.outputline("void (*"+funptr.getSafeSymbol()+") (struct "+name+"_state *, struct "+name+"*,struct RepairHash *"+parttype+")="+"(void (*) (struct "+name+"_state *,struct "+name+"*,struct RepairHash *"+parttype+")) "+tmpptr.getSafeSymbol()+";");
- cr.outputline(methodcall+");");
+ cr.addDeclaration("void (*"+funptr.getSafeSymbol()+") (struct "+name+"_state *, struct "+name+"*,struct RepairHash *"+parttype+");");
+ cr.outputline(funptr.getSafeSymbol()+"="+"(void (*) (struct "+name+"_state *,struct "+name+"*,struct RepairHash *"+parttype+")) "+tmpptr.getSafeSymbol()+";");
+ cr.outputline(methodcallprefix+methodcall+");");
cr.endblock();
}
cr.outputline("free"+name+"("+newmodel.getSafeSymbol()+");");
String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
cr.startblock();
- cr.outputline("int " + addeditem + "=0;");
+ cr.addDeclaration("int" , addeditem);
+ cr.outputline(addeditem + "=0;");
String ifstring="if (!maybe";
if (rd.getDomain().getType() instanceof StructureTypeDescriptor) {
else
parttype=parttype+", int";
}
- cr.outputline("void (*"+funptr.getSafeSymbol()+") (struct "+name+"_state *,struct "+name+"*,struct RepairHash *"+parttype+")=");
+ cr.addDeclaration("void (*"+funptr.getSafeSymbol()+") (struct "+name+"_state *,struct "+name+"*,struct RepairHash *"+parttype+");");
+ cr.outputline(funptr.getSafeSymbol()+"=");
cr.outputline("(void (*) (struct "+name+"_state *,struct "+name+"*,struct RepairHash *"+parttype+")) RepairHashgetset("+repairtable.getSafeSymbol()+","+sd.getNum()+","+currentrule.getNum()+","+setvar+");");
String methodcall="("+funptr.getSafeSymbol()+") (thisvar,"+oldmodel.getSafeSymbol()+","+
repairtable.getSafeSymbol();
cr.startblock();
String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
- cr.outputline("int " + addeditem + " = 0;");
+ cr.addDeclaration("int", addeditem);
+ cr.outputline(addeditem + " = 0;");
if (sd.getType() instanceof StructureTypeDescriptor) {
cr.outputline("if (!maybe&&"+setvar+")");
} else