final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final int init = cpg.addMethodref(UNION_ITERATOR_CLASS,
"<init>",
"("+DOM_INTF_SIG+")V");
final int iter = cpg.addMethodref(UNION_ITERATOR_CLASS,
ADD_ITERATOR,
ADD_ITERATOR_SIG);
// Create the UnionIterator and leave it on the stack
il.append(new NEW(cpg.addClass(UNION_ITERATOR_CLASS)));
il.append(DUP);
il.append(methodGen.loadDOM());
il.append(new INVOKESPECIAL(init));
// Add the various iterators to the UnionIterator
final int length = _components.length;
for (int i = 0; i < length; i++) {
_components[i].translate(classGen, methodGen);
il.append(new INVOKEVIRTUAL(iter));
}
// Order the iterator only if strictly needed
if (_reverse) {
final int order = cpg.addInterfaceMethodref(DOM_INTF,
ORDER_ITERATOR,
ORDER_ITERATOR_SIG);
il.append(methodGen.loadDOM());
il.append(SWAP);
il.append(methodGen.loadContextNode());
il.append(new INVOKEINTERFACE(order, 3));
}