int index = cpg.addInterfaceMethodref(DOM_INTF,
"getResultTreeFrag",
"(IZ)" + DOM_INTF_SIG);
il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
il.append(new PUSH(cpg, false));
il.append(new INVOKEINTERFACE(index,3));
il.append(DUP);
// 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.addInterfaceMethodref(DOM_INTF,
"getOutputDomBuilder",
"()" + TRANSLET_OUTPUT_SIG);
il.append(new INVOKEINTERFACE(index,1));
//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
il.append(new ALOAD(newDom.getIndex()));
}
}