final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
if (_left != null) {
if (_left instanceof StepPattern) {
final LocalVariableGen local =
// absolute path pattern temporary
methodGen.addLocalVariable2("apptmp",
Util.getJCRefType(NODE_SIG),
il.getEnd());
il.append(DUP);
il.append(new ISTORE(local.getIndex()));
_left.translate(classGen, methodGen);
il.append(methodGen.loadDOM());
local.setEnd(il.append(new ILOAD(local.getIndex())));
methodGen.removeLocalVariable(local);
}
else {
_left.translate(classGen, methodGen);
}
}
final int getParent = cpg.addInterfaceMethodref(DOM_INTF,
GET_PARENT,
GET_PARENT_SIG);
final int getType = cpg.addInterfaceMethodref(DOM_INTF,
"getExpandedTypeID",
"(I)I");
InstructionHandle begin = il.append(methodGen.loadDOM());
il.append(SWAP);
il.append(new INVOKEINTERFACE(getParent, 2));
if (_left instanceof AncestorPattern) {
il.append(methodGen.loadDOM());
il.append(SWAP);
}
il.append(new INVOKEINTERFACE(getType, 2));
il.append(new PUSH(cpg, DTM.DOCUMENT_NODE));
final BranchHandle skip = il.append(new IF_ICMPEQ(null));
_falseList.add(il.append(new GOTO_W(null)));
skip.setTarget(il.append(NOP));
if (_left != null) {
_left.backPatchTrueList(begin);
/*
* If _left is an ancestor pattern, backpatch this pattern's false
* list to the loop that searches for more ancestors.
*/
if (_left instanceof AncestorPattern) {
final AncestorPattern ancestor = (AncestorPattern) _left;
_falseList.backPatch(ancestor.getLoopHandle()); // clears list
}
_falseList.append(_left._falseList);
}