null, null);
match.setStart(il.append(new ISTORE(match.getIndex())));
// If pattern not reduced then check kernel
if (!_isEpsilon) {
il.append(new ILOAD(match.getIndex()));
translateKernel(classGen, methodGen);
}
// Push current iterator and current node on the stack
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadIterator());
// Create a new matching iterator using the matching node
index = cpg.addMethodref(MATCHING_ITERATOR, "<init>",
"(I" + NODE_ITERATOR_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.
_step.translate(classGen, methodGen);
LocalVariableGen stepIteratorTemp =
methodGen.addLocalVariable("step_pattern_tmp2",
Util.getJCRefType(NODE_ITERATOR_SIG),
null, null);
stepIteratorTemp.setStart(
il.append(new ASTORE(stepIteratorTemp.getIndex())));
il.append(new NEW(cpg.addClass(MATCHING_ITERATOR)));
il.append(DUP);
il.append(new ILOAD(match.getIndex()));
stepIteratorTemp.setEnd(
il.append(new ALOAD(stepIteratorTemp.getIndex())));
il.append(new INVOKESPECIAL(index));
// Get the parent of the matching node
il.append(methodGen.loadDOM());
il.append(new ILOAD(match.getIndex()));
index = cpg.addInterfaceMethodref(DOM_INTF, GET_PARENT, GET_PARENT_SIG);
il.append(new INVOKEINTERFACE(index, 2));
// Start the iterator with the parent
il.append(methodGen.setStartNode());
// Overwrite current iterator and current node
il.append(methodGen.storeIterator());
match.setEnd(il.append(new ILOAD(match.getIndex())));
il.append(methodGen.storeCurrentNode());
// Translate the expression of the predicate
Predicate pred = (Predicate) _predicates.elementAt(0);
Expression exp = pred.getExpr();