if (_methodName == null) {
il.append(NOP);
}
else {
LocalVariableGen domBuilder, newDom;
final String className = classGen.getClassName();
final int current = methodGen.getLocalIndex("current");
// Push required parameters
il.append(classGen.loadTranslet());
if (classGen.isExternal()) {
il.append(new CHECKCAST(cpg.addClass(className)));
}
il.append(methodGen.loadDOM());
// Create new instance of DOM class
int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
il.append(new NEW(cpg.addClass(DOM_IMPL)));
il.append(DUP);
il.append(DUP);
il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
il.append(new INVOKESPECIAL(index));
// Store new DOM into a local variable
newDom = methodGen.addLocalVariable("rt_to_reference_dom",
Util.getJCRefType(DOM_INTF_SIG),
null, null);
il.append(new CHECKCAST(cpg.addClass(DOM_INTF_SIG)));
il.append(new ASTORE(newDom.getIndex()));
// Overwrite old handler with DOM handler
index = cpg.addMethodref(DOM_IMPL,
"getOutputDomBuilder",
"()" + TRANSLET_OUTPUT_SIG);
il.append(new INVOKEVIRTUAL(index));
il.append(DUP);
il.append(DUP);
// Store DOM handler in a local in order to call endDocument()
domBuilder =
methodGen.addLocalVariable("rt_to_reference_handler",
Util.getJCRefType(TRANSLET_OUTPUT_SIG),
null, null);
il.append(new ASTORE(domBuilder.getIndex()));
// Call startDocument on the new handler
index = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
"startDocument", "()V");
il.append(new INVOKEINTERFACE(index, 1));
// Call the method that implements this result tree
index = cpg.addMethodref(className,
_methodName,
"("
+ DOM_INTF_SIG
+ TRANSLET_OUTPUT_SIG
+")V");
il.append(new INVOKEVIRTUAL(index));
// Call endDocument on the DOM handler
il.append(new ALOAD(domBuilder.getIndex()));
index = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
"endDocument", "()V");
il.append(new INVOKEINTERFACE(index, 1));
// Push the new DOM on the stack