ilLoop.append(DUP);
ilLoop.append(new ISTORE(_currentIndex));
// The body of this code can get very large - large than can be handled
// by a single IFNE(body.getStart()) instruction - need workaround:
final BranchHandle ifeq = ilLoop.append(new IFLT(null));
final BranchHandle loop = ilLoop.append(new GOTO_W(null));
ifeq.setTarget(ilLoop.append(RETURN)); // applyTemplates() ends here!
final InstructionHandle ihLoop = ilLoop.getStart();
// Compile default handling of elements (traverse children)
InstructionList ilRecurse =
compileDefaultRecursion(classGen, methodGen, ihLoop);
InstructionHandle ihRecurse = ilRecurse.getStart();
// Compile default handling of text/attribute nodes (output text)
InstructionList ilText =
compileDefaultText(classGen, methodGen, ihLoop);
InstructionHandle ihText = ilText.getStart();
// Distinguish attribute/element/namespace tests for further processing
final int[] types = new int[DTM.NTYPES + names.size()];
for (int i = 0; i < types.length; i++) {
types[i] = i;
}
// Initialize isAttribute[] and isNamespace[] arrays
final boolean[] isAttribute = new boolean[types.length];
final boolean[] isNamespace = new boolean[types.length];
for (int i = 0; i < names.size(); i++) {
final String name = (String)names.elementAt(i);
isAttribute[i + DTM.NTYPES] = isAttributeName(name);
isNamespace[i + DTM.NTYPES] = isNamespaceName(name);
}
// Compile all templates - regardless of pattern type
compileTemplates(classGen, methodGen, ihLoop);
// Handle template with explicit "*" pattern
final TestSeq elemTest = _testSeq[DTM.ELEMENT_NODE];
InstructionHandle ihElem = ihRecurse;
if (elemTest != null)
ihElem = elemTest.compile(classGen, methodGen, ihRecurse);
// Handle template with explicit "@*" pattern
final TestSeq attrTest = _testSeq[DTM.ATTRIBUTE_NODE];
InstructionHandle ihAttr = ihText;
if (attrTest != null)
ihAttr = attrTest.compile(classGen, methodGen, ihAttr);
// Do tests for id() and key() patterns first
InstructionList ilKey = null;
if (_idxTestSeq != null) {
loop.setTarget(_idxTestSeq.compile(classGen, methodGen, body.getStart()));
ilKey = _idxTestSeq.getInstructionList();
}
else {
loop.setTarget(body.getStart());
}
// If there is a match on node() we need to replace ihElem
// and ihText if the priority of node() is higher
if (_childNodeTestSeq != null) {