/** * Compiles the default handling for DOM elements: traverse all children */ private InstructionList compileDefaultRecursion(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle next) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final String applyTemplatesSig = classGen.getApplyTemplatesSig(); final int git = cpg.addInterfaceMethodref(DOM_INTF, GET_CHILDREN, GET_CHILDREN_SIG); final int applyTemplates = cpg.addMethodref(getClassName(), functionName(), applyTemplatesSig); il.append(classGen.loadTranslet()); il.append(methodGen.loadDOM()); il.append(methodGen.loadDOM()); il.append(new ILOAD(_currentIndex)); il.append(new INVOKEINTERFACE(git, 2)); il.append(methodGen.loadHandler()); il.append(new INVOKEVIRTUAL(applyTemplates)); il.append(new GOTO_W(next)); return il; }
/** * Compiles the default action for DOM text nodes and attribute nodes: * output the node's text value */ private InstructionList compileDefaultText(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle next) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = new InstructionList(); final int chars = cpg.addInterfaceMethodref(DOM_INTF, CHARACTERS, CHARACTERS_SIG); il.append(methodGen.loadDOM()); il.append(new ILOAD(_currentIndex)); il.append(methodGen.loadHandler()); il.append(new INVOKEINTERFACE(chars, 3)); il.append(new GOTO_W(next)); return il; }
/** * This method is called when the constructor is compiled in * Stylesheet.compileConstructor() and not as the syntax tree is traversed. */ public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Returns the name of a node in the DOM final int getNodeName = cpg.addInterfaceMethodref(DOM_INTF, "getNodeName", "(I)"+STRING_SIG); final int getLocalName = cpg.addMethodref(BASIS_LIBRARY_CLASS, "getLocalName", "(Ljava/lang/String;)"+ "Ljava/lang/String;"); super.translate(classGen, methodGen); il.append(new INVOKEINTERFACE(getNodeName, 2)); il.append(new INVOKESTATIC(getLocalName)); }
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); if (methodGen instanceof CompareGenerator) { il.append(((CompareGenerator)methodGen).loadLastNode()); } else if (methodGen instanceof TestGenerator) { il.append(new ILOAD(LAST_INDEX)); } else { final ConstantPoolGen cpg = classGen.getConstantPool(); final int getLast = cpg.addInterfaceMethodref(NODE_ITERATOR, "getLast", "()I"); il.append(methodGen.loadIterator()); il.append(new INVOKEINTERFACE(getLast, 1)); } }
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); if (methodGen instanceof CompareGenerator) { il.append(((CompareGenerator)methodGen).loadCurrentNode()); } else if (methodGen instanceof TestGenerator) { il.append(new ILOAD(POSITION_INDEX)); } else { final ConstantPoolGen cpg = classGen.getConstantPool(); final int index = cpg.addInterfaceMethodref(NODE_ITERATOR, "getPosition", "()I"); il.append(methodGen.loadIterator()); il.append(new INVOKEINTERFACE(index,1)); } }
/** * Casts a reference into a NodeIterator. * * @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, NodeSetType type) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToNodeSet", "(" + OBJECT_SIG + ")" + NODE_ITERATOR_SIG); il.append(new INVOKESTATIC(index)); // Reset this iterator index = cpg.addInterfaceMethodref(NODE_ITERATOR, RESET, RESET_SIG); il.append(new INVOKEINTERFACE(index, 1)); }
/** * Remove the mapping of this variable to a register. * Called when we leave the AST scope of the variable's declaration */ public void unmapRegister(ClassGenerator classGen, MethodGenerator methodGen) { if (_local != null) { if (_type instanceof ResultTreeType) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) { final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V"); il.append(methodGen.loadDOM()); il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS))); il.append(loadInstruction()); il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS))); il.append(new INVOKEVIRTUAL(removeDA)); } final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V"); il.append(loadInstruction()); il.append(new INVOKEINTERFACE(release, 1)); } _local.setEnd(methodGen.getInstructionList().getEnd()); methodGen.removeLocalVariable(_local); _refs = null; _local = null; } }
/** * Release the compiled result tree. */ public void releaseResultTree(ClassGenerator classGen, MethodGenerator methodGen) { if (_domAdapter != null) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) { final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V"); il.append(methodGen.loadDOM()); il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS))); il.append(new ALOAD(_domAdapter.getIndex())); il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS))); il.append(new INVOKEVIRTUAL(removeDA)); } final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V"); il.append(new ALOAD(_domAdapter.getIndex())); il.append(new INVOKEINTERFACE(release, 1)); _domAdapter = null; } }