for (LoopRecoverer.Block block : v.blocks) {
switch (block.blockType) {
case UNKNOWN:
for (String a : block.assignments)
System.err.println(" " + a);
throw new InvalidGrammarException("Unknown block type");
case LOOP:
openLoopClean(cls, block.maybeLoopVar, sched, block, exprToCall, exprPrinter, visit);
for (String lhs : block.assignments) {
if (lhs.contains("_recur")) {
String childName = lhs.split("_")[0].replace("unrolln", "");
//System.err.println("Recur child name: "+ childName);
if (childrenContains(sched._ast.extendedClasses.get(cls).multiChildren.keySet(), childName)) {
visit.put(cls, visit.get(cls) + backend.childrenRecur(cls, childName, visitNum, sched._ast));
visit.put(cls, visit.get(cls) + backend.logStmt(6, 2, "resume loop visit " + cls.getName(), "" + visitNum));
} else {
throw new InvalidGrammarException(cls.getName() + "::" + lhs + ": Cannot do a single child recursion (" + lhs + ") within a loop (" + block.maybeLoopVar + ")");
}
} else {
if (lhs.contains("_step1") || lhs.contains("_step2")) continue;
visitStatement(cls, sched, visit, lhs, true, exprToCall, exprPrinter);
}
}
closeLoopClean(cls, block.maybeLoopVar, sched, block, exprToCall, exprPrinter, visit);
break;
case STATEMENT:
for (String lhs : block.assignments) {
if (lhs.contains("_recur")) {
String childName = lhs.split("_")[0].replace("unrolln", "");
if (childrenContains(sched._ast.extendedClasses.get(cls).multiChildren.keySet(), childName)) {
throw new InvalidGrammarException(cls.getName() + "::" + lhs + ": Cannot do an array recursion (" + lhs + ") outside of a loop");
} else {
visit.put(cls, visit.get(cls) + " " + backend.childRecur(cls, childName, visitNum));
visit.put(cls, visit.get(cls) + backend.logStmt(2, 2, "resume visit " + cls.getName(), "" + visitNum));
}