com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL Java Examples

The following examples show how to use com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Sort.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Create a constructor for the new class. Updates the reference to the
 * collator in the super calls only when the stylesheet specifies a new
 * language in xsl:sort.
 */
private static MethodGenerator compileInit(NodeSortRecordGenerator sortRecord,
                                       ConstantPoolGen cpg,
                                       String className)
{
    final InstructionList il = new InstructionList();
    final MethodGenerator init =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>", className,
                            il, cpg);

    // Call the constructor in the NodeSortRecord superclass
    il.append(ALOAD_0);
    il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_RECORD,
                                                 "<init>", "()V")));



    il.append(RETURN);

    return init;
}
 
Example #2
Source File: Sort.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Create a constructor for the new class. Updates the reference to the
 * collator in the super calls only when the stylesheet specifies a new
 * language in xsl:sort.
 */
private static MethodGenerator compileInit(NodeSortRecordGenerator sortRecord,
                                       ConstantPoolGen cpg,
                                       String className)
{
    final InstructionList il = new InstructionList();
    final MethodGenerator init =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>", className,
                            il, cpg);

    // Call the constructor in the NodeSortRecord superclass
    il.append(ALOAD_0);
    il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_RECORD,
                                                 "<init>", "()V")));



    il.append(RETURN);

    return init;
}
 
Example #3
Source File: Sort.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a constructor for the new class. Updates the reference to the
 * collator in the super calls only when the stylesheet specifies a new
 * language in xsl:sort.
 */
private static MethodGenerator compileInit(NodeSortRecordGenerator sortRecord,
                                       ConstantPoolGen cpg,
                                       String className)
{
    final InstructionList il = new InstructionList();
    final MethodGenerator init =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>", className,
                            il, cpg);

    // Call the constructor in the NodeSortRecord superclass
    il.append(ALOAD_0);
    il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_RECORD,
                                                 "<init>", "()V")));



    il.append(RETURN);

    return init;
}
 
Example #4
Source File: Sort.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a constructor for the new class. Updates the reference to the
 * collator in the super calls only when the stylesheet specifies a new
 * language in xsl:sort.
 */
private static MethodGenerator compileInit(NodeSortRecordGenerator sortRecord,
                                       ConstantPoolGen cpg,
                                       String className)
{
    final InstructionList il = new InstructionList();
    final MethodGenerator init =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>", className,
                            il, cpg);

    // Call the constructor in the NodeSortRecord superclass
    il.append(ALOAD_0);
    il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_RECORD,
                                                 "<init>", "()V")));



    il.append(RETURN);

    return init;
}
 
Example #5
Source File: Sort.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a constructor for the new class. Updates the reference to the
 * collator in the super calls only when the stylesheet specifies a new
 * language in xsl:sort.
 */
private static MethodGenerator compileInit(Vector sortObjects,
                                       NodeSortRecordGenerator sortRecord,
                                       ConstantPoolGen cpg,
                                       String className)
{
    final InstructionList il = new InstructionList();
    final MethodGenerator init =
        new MethodGenerator(ACC_PUBLIC,
                            com.sun.org.apache.bcel.internal.generic.Type.VOID,
                            null, null, "<init>", className,
                            il, cpg);

    // Call the constructor in the NodeSortRecord superclass
    il.append(ALOAD_0);
    il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_RECORD,
                                                 "<init>", "()V")));



    il.append(RETURN);

    return init;
}
 
Example #6
Source File: NodeType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a node on the stack and pushes a boxed node. Boxed nodes
 * are represented by an instance of <code>com.sun.org.apache.xalan.internal.xsltc.dom.Node</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(RUNTIME_NODE_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new PUSH(cpg, _type));
    il.append(new INVOKESPECIAL(cpg.addMethodref(RUNTIME_NODE_CLASS,
                                                 "<init>", "(II)V")));
}
 
Example #7
Source File: NodeType.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Expects a node on the stack and pushes a singleton node-set. Singleton
 * iterators are already started after construction.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        NodeSetType type) {
    ConstantPoolGen cpg = classGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();

    // Create a new instance of SingletonIterator
    il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
    il.append(DUP_X1);
    il.append(SWAP);
    final int init = cpg.addMethodref(SINGLETON_ITERATOR, "<init>",
                                      "(" + NODE_SIG +")V");
    il.append(new INVOKESPECIAL(init));
}
 
Example #8
Source File: NodeType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a node on the stack and pushes a singleton node-set. Singleton
 * iterators are already started after construction.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        NodeSetType type) {
    ConstantPoolGen cpg = classGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();

    // Create a new instance of SingletonIterator
    il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
    il.append(DUP_X1);
    il.append(SWAP);
    final int init = cpg.addMethodref(SINGLETON_ITERATOR, "<init>",
                                      "(" + NODE_SIG +")V");
    il.append(new INVOKESPECIAL(init));
}
 
Example #9
Source File: BooleanType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a boolean on the stack and pushes a boxed boolean.
 * Boxed booleans are represented by an instance of
 * <code>java.lang.Boolean</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(BOOLEAN_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(BOOLEAN_CLASS,
                                                 "<init>",
                                                 "(Z)V")));
}
 
Example #10
Source File: RealType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a double on the stack and pushes a boxed double. Boxed
 * double are represented by an instance of <code>java.lang.Double</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
    il.append(DUP_X2);
    il.append(DUP_X2);
    il.append(POP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(DOUBLE_CLASS,
                                                 "<init>", "(D)V")));
}
 
Example #11
Source File: IntType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects an integer on the stack and pushes a boxed integer.
 * Boxed integers are represented by an instance of
 * <code>java.lang.Integer</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(INTEGER_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(INTEGER_CLASS,
                                                 "<init>", "(I)V")));
}
 
Example #12
Source File: UseAttributeSets.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a call to the method compiled for this attribute set
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final SymbolTable symbolTable = getParser().getSymbolTable();

    // Go through each attribute set and generate a method call
    for (int i=0; i<_sets.size(); i++) {
        // Get the attribute set name
        final QName name = (QName)_sets.elementAt(i);
        // Get the AttributeSet reference from the symbol table
        final AttributeSet attrs = symbolTable.lookupAttributeSet(name);
        // Compile the call to the set's method if the set exists
        if (attrs != null) {
            final String methodName = attrs.getMethodName();
            il.append(classGen.loadTranslet());
            il.append(methodGen.loadDOM());
            il.append(methodGen.loadIterator());
            il.append(methodGen.loadHandler());
            il.append(methodGen.loadCurrentNode());
            final int method = cpg.addMethodref(classGen.getClassName(),
                                                methodName, ATTR_SET_SIG);
            il.append(new INVOKESPECIAL(method));
        }
        // Generate an error if the attribute set does not exist
        else {
            final Parser parser = getParser();
            final String atrs = name.toString();
            reportError(this, parser, ErrorMsg.ATTRIBSET_UNDEF_ERR, atrs);
        }
    }
}
 
Example #13
Source File: BooleanType.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Expects a boolean on the stack and pushes a boxed boolean.
 * Boxed booleans are represented by an instance of
 * <code>java.lang.Boolean</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(BOOLEAN_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(BOOLEAN_CLASS,
                                                 "<init>",
                                                 "(Z)V")));
}
 
Example #14
Source File: NodeType.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Expects a node on the stack and pushes a singleton node-set. Singleton
 * iterators are already started after construction.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        NodeSetType type) {
    ConstantPoolGen cpg = classGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();

    // Create a new instance of SingletonIterator
    il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
    il.append(DUP_X1);
    il.append(SWAP);
    final int init = cpg.addMethodref(SINGLETON_ITERATOR, "<init>",
                                      "(" + NODE_SIG +")V");
    il.append(new INVOKESPECIAL(init));
}
 
Example #15
Source File: RealType.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Expects a double on the stack and pushes a boxed double. Boxed
 * double are represented by an instance of <code>java.lang.Double</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
    il.append(DUP_X2);
    il.append(DUP_X2);
    il.append(POP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(DOUBLE_CLASS,
                                                 "<init>", "(D)V")));
}
 
Example #16
Source File: UseAttributeSets.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Generate a call to the method compiled for this attribute set
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final SymbolTable symbolTable = getParser().getSymbolTable();

    // Go through each attribute set and generate a method call
    for (int i=0; i<_sets.size(); i++) {
        // Get the attribute set name
        final QName name = (QName)_sets.elementAt(i);
        // Get the AttributeSet reference from the symbol table
        final AttributeSet attrs = symbolTable.lookupAttributeSet(name);
        // Compile the call to the set's method if the set exists
        if (attrs != null) {
            final String methodName = attrs.getMethodName();
            il.append(classGen.loadTranslet());
            il.append(methodGen.loadDOM());
            il.append(methodGen.loadIterator());
            il.append(methodGen.loadHandler());
            il.append(methodGen.loadCurrentNode());
            final int method = cpg.addMethodref(classGen.getClassName(),
                                                methodName, ATTR_SET_SIG);
            il.append(new INVOKESPECIAL(method));
        }
        // Generate an error if the attribute set does not exist
        else {
            final Parser parser = getParser();
            final String atrs = name.toString();
            reportError(this, parser, ErrorMsg.ATTRIBSET_UNDEF_ERR, atrs);
        }
    }
}
 
Example #17
Source File: BooleanType.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Expects a boolean on the stack and pushes a boxed boolean.
 * Boxed booleans are represented by an instance of
 * <code>java.lang.Boolean</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(BOOLEAN_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(BOOLEAN_CLASS,
                                                 "<init>",
                                                 "(Z)V")));
}
 
Example #18
Source File: RealType.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Expects a double on the stack and pushes a boxed double. Boxed
 * double are represented by an instance of <code>java.lang.Double</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
    il.append(DUP_X2);
    il.append(DUP_X2);
    il.append(POP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(DOUBLE_CLASS,
                                                 "<init>", "(D)V")));
}
 
Example #19
Source File: IntType.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Expects an integer on the stack and pushes a boxed integer.
 * Boxed integers are represented by an instance of
 * <code>java.lang.Integer</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(INTEGER_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(INTEGER_CLASS,
                                                 "<init>", "(I)V")));
}
 
Example #20
Source File: UseAttributeSets.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Generate a call to the method compiled for this attribute set
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final SymbolTable symbolTable = getParser().getSymbolTable();

    // Go through each attribute set and generate a method call
    for (int i=0; i<_sets.size(); i++) {
        // Get the attribute set name
        final QName name = (QName)_sets.elementAt(i);
        // Get the AttributeSet reference from the symbol table
        final AttributeSet attrs = symbolTable.lookupAttributeSet(name);
        // Compile the call to the set's method if the set exists
        if (attrs != null) {
            final String methodName = attrs.getMethodName();
            il.append(classGen.loadTranslet());
            il.append(methodGen.loadDOM());
            il.append(methodGen.loadIterator());
            il.append(methodGen.loadHandler());
            il.append(methodGen.loadCurrentNode());
            final int method = cpg.addMethodref(classGen.getClassName(),
                                                methodName, ATTR_SET_SIG);
            il.append(new INVOKESPECIAL(method));
        }
        // Generate an error if the attribute set does not exist
        else {
            final Parser parser = getParser();
            final String atrs = name.toString();
            reportError(this, parser, ErrorMsg.ATTRIBSET_UNDEF_ERR, atrs);
        }
    }
}
 
Example #21
Source File: UnionPathExpr.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    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));

    }
}
 
Example #22
Source File: BooleanType.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a boolean on the stack and pushes a boxed boolean.
 * Boxed booleans are represented by an instance of
 * <code>java.lang.Boolean</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(BOOLEAN_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(BOOLEAN_CLASS,
                                                 "<init>",
                                                 "(Z)V")));
}
 
Example #23
Source File: RealType.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a double on the stack and pushes a boxed double. Boxed
 * double are represented by an instance of <code>java.lang.Double</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
    il.append(DUP_X2);
    il.append(DUP_X2);
    il.append(POP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(DOUBLE_CLASS,
                                                 "<init>", "(D)V")));
}
 
Example #24
Source File: UseAttributeSets.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a call to the method compiled for this attribute set
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final SymbolTable symbolTable = getParser().getSymbolTable();

    // Go through each attribute set and generate a method call
    for (int i=0; i<_sets.size(); i++) {
        // Get the attribute set name
        final QName name = (QName)_sets.elementAt(i);
        // Get the AttributeSet reference from the symbol table
        final AttributeSet attrs = symbolTable.lookupAttributeSet(name);
        // Compile the call to the set's method if the set exists
        if (attrs != null) {
            final String methodName = attrs.getMethodName();
            il.append(classGen.loadTranslet());
            il.append(methodGen.loadDOM());
            il.append(methodGen.loadIterator());
            il.append(methodGen.loadHandler());
            il.append(methodGen.loadCurrentNode());
            final int method = cpg.addMethodref(classGen.getClassName(),
                                                methodName, ATTR_SET_SIG);
            il.append(new INVOKESPECIAL(method));
        }
        // Generate an error if the attribute set does not exist
        else {
            final Parser parser = getParser();
            final String atrs = name.toString();
            reportError(this, parser, ErrorMsg.ATTRIBSET_UNDEF_ERR, atrs);
        }
    }
}
 
Example #25
Source File: IntType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects an integer on the stack and pushes a boxed integer.
 * Boxed integers are represented by an instance of
 * <code>java.lang.Integer</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(INTEGER_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(INTEGER_CLASS,
                                                 "<init>", "(I)V")));
}
 
Example #26
Source File: RealType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a double on the stack and pushes a boxed double. Boxed
 * double are represented by an instance of <code>java.lang.Double</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
    il.append(DUP_X2);
    il.append(DUP_X2);
    il.append(POP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(DOUBLE_CLASS,
                                                 "<init>", "(D)V")));
}
 
Example #27
Source File: BooleanType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a boolean on the stack and pushes a boxed boolean.
 * Boxed booleans are represented by an instance of
 * <code>java.lang.Boolean</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(BOOLEAN_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new INVOKESPECIAL(cpg.addMethodref(BOOLEAN_CLASS,
                                                 "<init>",
                                                 "(Z)V")));
}
 
Example #28
Source File: NodeType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a node on the stack and pushes a singleton node-set. Singleton
 * iterators are already started after construction.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        NodeSetType type) {
    ConstantPoolGen cpg = classGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();

    // Create a new instance of SingletonIterator
    il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
    il.append(DUP_X1);
    il.append(SWAP);
    final int init = cpg.addMethodref(SINGLETON_ITERATOR, "<init>",
                                      "(" + NODE_SIG +")V");
    il.append(new INVOKESPECIAL(init));
}
 
Example #29
Source File: NodeType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a node on the stack and pushes a boxed node. Boxed nodes
 * are represented by an instance of <code>com.sun.org.apache.xalan.internal.xsltc.dom.Node</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ReferenceType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new NEW(cpg.addClass(RUNTIME_NODE_CLASS)));
    il.append(DUP_X1);
    il.append(SWAP);
    il.append(new PUSH(cpg, _type));
    il.append(new INVOKESPECIAL(cpg.addMethodref(RUNTIME_NODE_CLASS,
                                                 "<init>", "(II)V")));
}
 
Example #30
Source File: UnionPathExpr.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    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));

    }
}