_step.translate(classGen, methodGen);
InstructionHandle iterStore = il.append(new ASTORE(iter.getIndex()));
// If in the main class update the field too
if (!classGen.isExternal()) {
il.append(new ALOAD(iter.getIndex()));
il.append(new PUTFIELD(iteratorIndex));
ifBlock.setTarget(il.append(NOP));
} else {
// If class is not external, start of range for iter variable was
// set above
iter.setStart(iterStore);
}
// Get the parent of the node on the stack
il.append(methodGen.loadDOM());
il.append(new ILOAD(node.getIndex()));
int index = cpg.addInterfaceMethodref(DOM_INTF,
GET_PARENT, GET_PARENT_SIG);
il.append(new INVOKEINTERFACE(index, 2));
// Initialize the iterator with the parent
il.append(new ALOAD(iter.getIndex()));
il.append(SWAP);
il.append(methodGen.setStartNode());
/*
* Inline loop:
*
* int node2;
* while ((node2 = iter.next()) != NodeIterator.END
* && node2 < node);
* return node2 == node;
*/
BranchHandle skipNext;
InstructionHandle begin, next;
node2 = methodGen.addLocalVariable("step_pattern_tmp3",
Util.getJCRefType(NODE_SIG),
null, null);
skipNext = il.append(new GOTO(null));
next = il.append(new ALOAD(iter.getIndex()));
node2.setStart(next);
begin = il.append(methodGen.nextNode());
il.append(DUP);
il.append(new ISTORE(node2.getIndex()));
_falseList.add(il.append(new IFLT(null))); // NodeIterator.END