il.append(methodGen.loadCurrentNode());
il.append(methodGen.setStartNode());
il.append(methodGen.storeIterator());
// Loop for traversing all nodes in the DOM
final BranchHandle nextNode = il.append(new GOTO(null));
final InstructionHandle loop = il.append(NOP);
// Check if the current node matches the pattern in "match"
il.append(methodGen.loadCurrentNode());
_match.translate(classGen, methodGen);
_match.synthesize(classGen, methodGen); // Leaves 0 or 1 on stack
final BranchHandle skipNode = il.append(new IFEQ(null));
// If this is a node-set we must go through each node in the set
if (_useType instanceof NodeSetType) {
// Pass current node as parameter (we're indexing on that node)
il.append(methodGen.loadCurrentNode());
traverseNodeSet(classGen, methodGen, key);
}
else {
il.append(classGen.loadTranslet());
il.append(DUP);
il.append(new PUSH(cpg, _name.toString()));
il.append(DUP_X1);
il.append(methodGen.loadCurrentNode());
_use.translate(classGen, methodGen);
il.append(new INVOKEVIRTUAL(key));
il.append(methodGen.loadDOM());
il.append(new INVOKEVIRTUAL(keyDom));
}
// Get the next node from the iterator and do loop again...
final InstructionHandle skip = il.append(NOP);
il.append(methodGen.loadIterator());
il.append(methodGen.nextNode());
il.append(DUP);
il.append(methodGen.storeCurrentNode());
il.append(new IFGT(loop));
// Restore current node and current iterator from the stack
il.append(methodGen.storeIterator());
il.append(methodGen.storeCurrentNode());
nextNode.setTarget(skip);
skipNode.setTarget(skip);
}