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

The following examples show how to use com.sun.org.apache.bcel.internal.generic.ConstantPoolGen. 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: ReferenceType.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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));
}
 
Example #2
Source File: StringType.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a string.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateFrom
 */
public void translateFrom(ClassGenerator classGen,
    MethodGenerator methodGen, Class clazz)
{
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (clazz.getName().equals("java.lang.String")) {
        // same internal representation, convert null to ""
        il.append(DUP);
        final BranchHandle ifNonNull = il.append(new IFNONNULL(null));
        il.append(POP);
        il.append(new PUSH(cpg, ""));
        ifNonNull.setTarget(il.append(NOP));
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #3
Source File: Text.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Generates code that loads the array that will contain the character
 * data represented by this Text node, followed by the offset of the
 * data from the start of the array, and then the length of the data.
 *
 * The pre-condition to calling this method is that
 * canLoadAsArrayOffsetLength() returns true.
 * @see #canLoadArrayOffsetLength()
 */
public void loadAsArrayOffsetLength(ClassGenerator classGen,
                                    MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final XSLTC xsltc = classGen.getParser().getXSLTC();

    // The XSLTC object keeps track of character data
    // that is to be stored in char arrays.
    final int offset = xsltc.addCharacterData(_text);
    final int length = _text.length();
    String charDataFieldName =
        STATIC_CHAR_DATA_FIELD + (xsltc.getCharacterDataCount()-1);

    il.append(new GETSTATIC(cpg.addFieldref(xsltc.getClassName(),
                                   charDataFieldName,
                                   STATIC_CHAR_DATA_FIELD_SIG)));
    il.append(new PUSH(cpg, offset));
    il.append(new PUSH(cpg, _text.length()));
}
 
Example #4
Source File: Text.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates code that loads the array that will contain the character
 * data represented by this Text node, followed by the offset of the
 * data from the start of the array, and then the length of the data.
 *
 * The pre-condition to calling this method is that
 * canLoadAsArrayOffsetLength() returns true.
 * @see #canLoadArrayOffsetLength()
 */
public void loadAsArrayOffsetLength(ClassGenerator classGen,
                                    MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final XSLTC xsltc = classGen.getParser().getXSLTC();

    // The XSLTC object keeps track of character data
    // that is to be stored in char arrays.
    final int offset = xsltc.addCharacterData(_text);
    final int length = _text.length();
    String charDataFieldName =
        STATIC_CHAR_DATA_FIELD + (xsltc.getCharacterDataCount()-1);

    il.append(new GETSTATIC(cpg.addFieldref(xsltc.getClassName(),
                                   charDataFieldName,
                                   STATIC_CHAR_DATA_FIELD_SIG)));
    il.append(new PUSH(cpg, offset));
    il.append(new PUSH(cpg, _text.length()));
}
 
Example #5
Source File: XslElement.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method is called when the name of the element is known at compile time.
 * In this case, there is no need to inspect the element name at runtime to
 * determine if a prefix exists, needs to be generated, etc.
 */
public void translateLiteral(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (!_ignore) {
        il.append(methodGen.loadHandler());
        _name.translate(classGen, methodGen);
        il.append(DUP2);
        il.append(methodGen.startElement());

        if (_namespace != null) {
            il.append(methodGen.loadHandler());
            il.append(new PUSH(cpg, _prefix));
            _namespace.translate(classGen,methodGen);
            il.append(methodGen.namespace());
        }
    }

    translateContents(classGen, methodGen);

    if (!_ignore) {
        il.append(methodGen.endElement());
    }
}
 
Example #6
Source File: CompareGenerator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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());
}
 
Example #7
Source File: ObjectType.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expects an integer on the stack and pushes its string value by calling
 * <code>Integer.toString(int i)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(DUP);
    final BranchHandle ifNull = il.append(new IFNULL(null));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                                                "toString",
                                                "()" + STRING_SIG)));
    final BranchHandle gotobh = il.append(new GOTO(null));
    ifNull.setTarget(il.append(POP));
    il.append(new PUSH(cpg, ""));
    gotobh.setTarget(il.append(NOP));
}
 
Example #8
Source File: ReferenceType.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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));
}
 
Example #9
Source File: StringType.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a string.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateFrom
 */
public void translateFrom(ClassGenerator classGen,
    MethodGenerator methodGen, Class clazz)
{
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (clazz.getName().equals("java.lang.String")) {
        // same internal representation, convert null to ""
        il.append(DUP);
        final BranchHandle ifNonNull = il.append(new IFNONNULL(null));
        il.append(POP);
        il.append(new PUSH(cpg, ""));
        ifNonNull.setTarget(il.append(NOP));
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #10
Source File: PositionCall.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
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));
    }
}
 
Example #11
Source File: StringType.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a string.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateFrom
 */
public void translateFrom(ClassGenerator classGen,
    MethodGenerator methodGen, Class clazz)
{
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (clazz.getName().equals("java.lang.String")) {
        // same internal representation, convert null to ""
        il.append(DUP);
        final BranchHandle ifNonNull = il.append(new IFNONNULL(null));
        il.append(POP);
        il.append(new PUSH(cpg, ""));
        ifNonNull.setTarget(il.append(NOP));
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #12
Source File: RealType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a real on the stack and pushes its string value by calling
 * <code>Double.toString(double d)</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                                "realToString",
                                                "(D)" + STRING_SIG)));
}
 
Example #13
Source File: ResultTreeType.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects an result tree on the stack and pushes a boolean.
 * Translates a result tree to a boolean by first converting it to string.
 *
 * @param classGen A BCEL class generator
 * @param methodGen A BCEL method generator
 * @param type An instance of BooleanType (any)
 * @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        BooleanType type) {
    // A result tree is always 'true' when converted to a boolean value,
    // since the tree always has at least one node (the root).
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(POP);      // don't need the DOM reference
    il.append(ICONST_1); // push 'true' on the stack
}
 
Example #14
Source File: NamespaceUriCall.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Translate code that leaves a node's namespace URI (as a String)
 * on the stack
 */
public void translate(ClassGenerator classGen,
                      MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // Returns the string value for a node in the DOM
    final int getNamespace = cpg.addInterfaceMethodref(DOM_INTF,
                                                       "getNamespaceName",
                                                       "(I)"+STRING_SIG);
    super.translate(classGen, methodGen);
    il.append(new INVOKEINTERFACE(getNamespace, 2));
}
 
Example #15
Source File: RealType.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Translates an object of this type to its unboxed representation.
 */
public void translateUnBox(ClassGenerator classGen,
                           MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new CHECKCAST(cpg.addClass(DOUBLE_CLASS)));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOUBLE_CLASS,
                                                 DOUBLE_VALUE,
                                                 DOUBLE_VALUE_SIG)));
}
 
Example #16
Source File: UnparsedEntityUriCall.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // Feck the this pointer on the stack...
    il.append(methodGen.loadDOM());
    // ...then the entity name...
    _entity.translate(classGen, methodGen);
    // ...to get the URI from the DOM object.
    il.append(new INVOKEINTERFACE(
                     cpg.addInterfaceMethodref(DOM_INTF,
                                               GET_UNPARSED_ENTITY_URI,
                                               GET_UNPARSED_ENTITY_URI_SIG),
                     2));
}
 
Example #17
Source File: ReferenceType.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Casts a reference into a ResultTree.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        ResultTreeType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToResultTree",
                                 "(" + OBJECT_SIG + ")" + DOM_INTF_SIG);
    il.append(new INVOKESTATIC(index));
}
 
Example #18
Source File: ResultTreeType.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Expects an result tree on the stack and pushes a boolean.
 * Translates a result tree to a boolean by first converting it to string.
 *
 * @param classGen A BCEL class generator
 * @param methodGen A BCEL method generator
 * @param type An instance of BooleanType (any)
 * @see com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        BooleanType type) {
    // A result tree is always 'true' when converted to a boolean value,
    // since the tree always has at least one node (the root).
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(POP);      // don't need the DOM reference
    il.append(ICONST_1); // push 'true' on the stack
}
 
Example #19
Source File: Expression.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Synthesize a boolean expression, i.e., either push a 0 or 1 onto the
 * operand stack for the next statement to succeed. Returns the handle
 * of the instruction to be backpatched.
 */
public void synthesize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    _trueList.backPatch(il.append(ICONST_1));
    final BranchHandle truec = il.append(new GOTO_W(null));
    _falseList.backPatch(il.append(ICONST_0));
    truec.setTarget(il.append(NOP));
}
 
Example #20
Source File: BooleanType.java    From openjdk-jdk8u-backup 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 #21
Source File: Fallback.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Translate contents only if this fallback element is put in place of
 * some unsupported element or non-XSLTC extension element
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_active) translateContents(classGen, methodGen);
}
 
Example #22
Source File: CastExpr.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    FlowList fl;
    final Type ltype = _left.getType();

    // This is a special case for the self:: axis. Instead of letting
    // the Step object create and iterator that we cast back to a single
    // node, we simply ask the DOM for the node type.
    if (_typeTest) {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();

        final int idx = cpg.addInterfaceMethodref(DOM_INTF,
                                                  "getExpandedTypeID",
                                                  "(I)I");
        il.append(new SIPUSH((short)((Step)_left).getNodeType()));
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadContextNode());
        il.append(new INVOKEINTERFACE(idx, 2));
        _falseList.add(il.append(new IF_ICMPNE(null)));
    }
    else {

        _left.translate(classGen, methodGen);
        if (_type != ltype) {
            _left.startIterator(classGen, methodGen);
            if (_type instanceof BooleanType) {
                fl = ltype.translateToDesynthesized(classGen, methodGen,
                                                    _type);
                if (fl != null) {
                    _falseList.append(fl);
                }
            }
            else {
                ltype.translateTo(classGen, methodGen, _type);
            }
        }
    }
}
 
Example #23
Source File: RealType.java    From openjdk-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 #24
Source File: RtMethodGenerator.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #25
Source File: WithParam.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example #26
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 its string value.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    switch (_type) {
    case NodeTest.ROOT:
    case NodeTest.ELEMENT:
        il.append(methodGen.loadDOM());
        il.append(SWAP); // dom ref must be below node index
        int index = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_ELEMENT_VALUE,
                                              GET_ELEMENT_VALUE_SIG);
        il.append(new INVOKEINTERFACE(index, 2));
        break;

    case NodeTest.ANODE:
    case NodeTest.COMMENT:
    case NodeTest.ATTRIBUTE:
    case NodeTest.PI:
        il.append(methodGen.loadDOM());
        il.append(SWAP); // dom ref must be below node index
        index = cpg.addInterfaceMethodref(DOM_INTF,
                                          GET_NODE_VALUE,
                                          GET_NODE_VALUE_SIG);
        il.append(new INVOKEINTERFACE(index, 2));
        break;

    default:
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
        break;
    }
}
 
Example #27
Source File: ContainsCall.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Compile expression and update true/false-lists
 */
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    _base.translate(classGen, methodGen);
    _token.translate(classGen, methodGen);
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS,
                                                 "indexOf",
                                                 "("+STRING_SIG+")I")));
    _falseList.add(il.append(new IFLT(null)));
}
 
Example #28
Source File: Fallback.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Translate contents only if this fallback element is put in place of
 * some unsupported element or non-XSLTC extension element
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_active) translateContents(classGen, methodGen);
}
 
Example #29
Source File: ReferenceType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Translates a reference into an object of internal type <code>type</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        RealType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(methodGen.loadDOM());
    int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "numberF",
                                 "("
                                 + OBJECT_SIG
                                 + DOM_INTF_SIG
                                 + ")D");
    il.append(new INVOKESTATIC(index));
}
 
Example #30
Source File: MatchGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public MatchGenerator(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);
}