/** * Helper method to generate an instance of a subclass of * {@link LoadInstruction} based on the specified {@link Type} that will * load the specified local variable * @param index the JVM stack frame index of the variable that is to be * loaded * @param type the {@link Type} of the variable * @return the generated {@link LoadInstruction} */ private static Instruction loadLocal(int index, Type type) { if (type == Type.BOOLEAN) { return new ILOAD(index); } else if (type == Type.INT) { return new ILOAD(index); } else if (type == Type.SHORT) { return new ILOAD(index); } else if (type == Type.LONG) { return new LLOAD(index); } else if (type == Type.BYTE) { return new ILOAD(index); } else if (type == Type.CHAR) { return new ILOAD(index); } else if (type == Type.FLOAT) { return new FLOAD(index); } else if (type == Type.DOUBLE) { return new DLOAD(index); } else { return new ALOAD(index); } }
public CompareGenerator(int access_flags, Type return_type, Type[] arg_types, String[] arg_names, String method_name, String class_name, InstructionList il, ConstantPoolGen cp) { super(access_flags, return_type, arg_types, arg_names, method_name, class_name, il, cp); _iloadCurrent = new ILOAD(CURRENT_INDEX); _istoreCurrent = new ISTORE(CURRENT_INDEX); _aloadDom = new ALOAD(DOM_INDEX); _iloadLast = new ILOAD(LAST_INDEX); LocalVariableGen iterator = addLocalVariable("iterator", Util.getJCRefType(Constants.NODE_ITERATOR_SIG), null, null); ITERATOR_INDEX = iterator.getIndex(); _aloadIterator = new ALOAD(ITERATOR_INDEX); _astoreIterator = new ASTORE(ITERATOR_INDEX); il.append(new ACONST_NULL()); il.append(storeIterator()); }
/** * 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; } }
public FilterGenerator(String className, String superClassName, String fileName, int accessFlags, String[] interfaces, Stylesheet stylesheet) { super(className, superClassName, fileName, accessFlags, interfaces, stylesheet); _aloadTranslet = new ALOAD(TRANSLET_INDEX); }
public ClassGenerator(String class_name, String super_class_name, String file_name, int access_flags, String[] interfaces, Stylesheet stylesheet) { super(class_name, super_class_name, file_name, access_flags, interfaces); _stylesheet = stylesheet; _parser = stylesheet.getParser(); _aloadTranslet = new ALOAD(TRANSLET_INDEX); if (stylesheet.isMultiDocument()) { _domClass = "com.sun.org.apache.xalan.internal.xsltc.dom.MultiDOM"; _domClassSig = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM;"; } else { _domClass = "com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter"; _domClassSig = "Lcom/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter;"; } _applyTemplatesSig = "(" + Constants.DOM_INTF_SIG + Constants.NODE_ITERATOR_SIG + Constants.TRANSLET_OUTPUT_SIG + ")V"; _applyTemplatesSigForImport = "(" + Constants.DOM_INTF_SIG + Constants.NODE_ITERATOR_SIG + Constants.TRANSLET_OUTPUT_SIG + Constants.NODE_FIELD_SIG + ")V"; }
public NodeSortRecordGenerator(String className, String superClassName, String fileName, int accessFlags, String[] interfaces, Stylesheet stylesheet) { super(className, superClassName, fileName, accessFlags, interfaces, stylesheet); _aloadTranslet = new ALOAD(TRANSLET_INDEX); }
public RtMethodGenerator(int access_flags, Type return_type, Type[] arg_types, String[] arg_names, String method_name, String class_name, InstructionList il, ConstantPoolGen cp) { super(access_flags, return_type, arg_types, arg_names, method_name, class_name, il, cp); _astoreHandler = new ASTORE(HANDLER_INDEX); _aloadHandler = new ALOAD(HANDLER_INDEX); }
public TestGenerator(int access_flags, Type return_type, Type[] arg_types, String[] arg_names, String method_name, String class_name, InstructionList il, ConstantPoolGen cp) { super(access_flags, return_type, arg_types, arg_names, method_name, class_name, il, cp); _iloadCurrent = new ILOAD(CURRENT_NODE_INDEX); _istoreCurrent = new ISTORE(CURRENT_NODE_INDEX); _iloadContext = new ILOAD(CONTEXT_NODE_INDEX); _istoreContext = new ILOAD(CONTEXT_NODE_INDEX); _astoreIterator = new ASTORE(ITERATOR_INDEX); _aloadIterator = new ALOAD(ITERATOR_INDEX); }
/** * 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.setEnd(il.getEnd()); methodGen.removeLocalVariable(_domAdapter); _domAdapter = null; } }
/** * Compiles a constructor for the class <tt>_className</tt> that * inherits from {Any,Single,Multiple}NodeCounter. This constructor * simply calls the same constructor in the super class. */ private void compileConstructor(ClassGenerator classGen) { MethodGenerator cons; final InstructionList il = new InstructionList(); final ConstantPoolGen cpg = classGen.getConstantPool(); cons = new MethodGenerator(ACC_PUBLIC, com.sun.org.apache.bcel.internal.generic.Type.VOID, new com.sun.org.apache.bcel.internal.generic.Type[] { Util.getJCRefType(TRANSLET_INTF_SIG), Util.getJCRefType(DOM_INTF_SIG), Util.getJCRefType(NODE_ITERATOR_SIG), com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN }, new String[] { "dom", "translet", "iterator", "hasFrom" }, "<init>", _className, il, cpg); il.append(ALOAD_0); // this il.append(ALOAD_1); // translet il.append(ALOAD_2); // DOM il.append(new ALOAD(3)); // iterator il.append(new ILOAD(4)); // hasFrom int index = cpg.addMethodref(ClassNames[_level], "<init>", "(" + TRANSLET_INTF_SIG + DOM_INTF_SIG + NODE_ITERATOR_SIG + "Z)V"); il.append(new INVOKESPECIAL(index)); il.append(RETURN); classGen.addMethod(cons); }