il.append(new NEW(cpg.addClass(NTH_ITERATOR_CLASS)));
il.append(DUP);
il.append(new ALOAD(iteratorTemp.getIndex()));
il.append(new ILOAD(predicateValueTemp.getIndex()));
il.append(new INVOKESPECIAL(idx));
}
else {
idx = cpg.addMethodref(CURRENT_NODE_LIST_ITERATOR,
"<init>",
"("
+ NODE_ITERATOR_SIG
+ CURRENT_NODE_LIST_FILTER_SIG
+ NODE_SIG
+ TRANSLET_SIG
+ ")V");
// Backwards branches are prohibited if an uninitialized object
// is on the stack by section 4.9.4 of the JVM Specification,
// 2nd Ed. We don't know whether this code might contain
// backwards branches, so we mustn't create the new object until
// after we've created the suspect arguments to its constructor.
// Instead we calculate the values of the arguments to the
// constructor first, store them in temporary variables, create
// the object and reload the arguments from the temporaries to
// avoid the problem.
translatePredicates(classGen, methodGen); // recursive call
LocalVariableGen iteratorTemp
= methodGen.addLocalVariable("step_tmp1",
Util.getJCRefType(NODE_ITERATOR_SIG),
il.getEnd(), null);
il.append(new ASTORE(iteratorTemp.getIndex()));
predicate.translateFilter(classGen, methodGen);
LocalVariableGen filterTemp
= methodGen.addLocalVariable("step_tmp2",
Util.getJCRefType(CURRENT_NODE_LIST_FILTER_SIG),
il.getEnd(), null);
il.append(new ASTORE(filterTemp.getIndex()));
// create new CurrentNodeListIterator
il.append(new NEW(cpg.addClass(CURRENT_NODE_LIST_ITERATOR)));
il.append(DUP);
il.append(new ALOAD(iteratorTemp.getIndex()));
il.append(new ALOAD(filterTemp.getIndex()));
il.append(methodGen.loadCurrentNode());
il.append(classGen.loadTranslet());
if (classGen.isExternal()) {
final String className = classGen.getClassName();
il.append(new CHECKCAST(cpg.addClass(className)));
}
il.append(new INVOKESPECIAL(idx));
}
}
}