Java 类com.sun.org.apache.bcel.internal.generic.PUSH 实例源码

项目:OpenJSharp    文件:Predicate.java   
/**
 * Translate a predicate expression. If non of the optimizations apply
 * then this translation pushes two references on the stack: a reference
 * to a newly created filter object and a reference to the predicate's
 * closure. See class <code>Step</code> for further details.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_nthPositionFilter || _nthDescendant) {
        _exp.translate(classGen, methodGen);
    }
    else if (isNodeValueTest() && (getParent() instanceof Step)) {
        _value.translate(classGen, methodGen);
        il.append(new CHECKCAST(cpg.addClass(STRING_CLASS)));
        il.append(new PUSH(cpg, ((EqualityExpr)_exp).getOp()));
    }
    else {
        translateFilter(classGen, methodGen);
    }
}
项目:OpenJSharp    文件:WithParam.java   
/**
 * Compile the value of the parameter, which is either in an expression in
 * a 'select' attribute, or in the with-param element's body
 */
public void translateValue(ClassGenerator classGen,
                           MethodGenerator methodGen) {
    // Compile expression is 'select' attribute if present
    if (_select != null) {
        _select.translate(classGen, methodGen);
        _select.startIterator(classGen, methodGen);
    }
    // If not, compile result tree from parameter body if present.
    else if (hasContents()) {
        compileResultTree(classGen, methodGen);
    }
    // If neither are present then store empty string in parameter slot
    else {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
        il.append(new PUSH(cpg, Constants.EMPTYSTRING));
    }
}
项目:OpenJSharp    文件:UnsupportedElement.java   
/**
 * Translate the fallback element (if any).
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    if (_fallbacks != null) {
        int count = _fallbacks.size();
        for (int i = 0; i < count; i++) {
            Fallback fallback = (Fallback)_fallbacks.elementAt(i);
            fallback.translate(classGen, methodGen);
        }
    }
    // We only go into the else block in forward-compatibility mode, when
    // the unsupported element has no fallback.
    else {
        // If the unsupported element does not have any fallback child, then
        // at runtime, a runtime error should be raised when the unsupported
        // element is instantiated. Otherwise, no error is thrown.
        ConstantPoolGen cpg = classGen.getConstantPool();
        InstructionList il = methodGen.getInstructionList();

        final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF",
                                                     "(" + STRING_SIG + "Z)V");
        il.append(new PUSH(cpg, getQName().toString()));
        il.append(new PUSH(cpg, _isExtension));
        il.append(new INVOKESTATIC(unsupportedElem));
    }
}
项目:OpenJSharp    文件:XslElement.java   
/**
 * 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());
    }
}
项目:OpenJSharp    文件:StringType.java   
/**
 * 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);
    }
}
项目:OpenJSharp    文件:ObjectType.java   
/**
 * 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));
}
项目:OpenJSharp    文件:ReferenceType.java   
/**
 * Translates reference into 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,
                        StringType type) {
    final int current = methodGen.getLocalIndex("current");
    ConstantPoolGen cpg = classGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();

    // If no current, conversion is a top-level
    if (current < 0) {
        il.append(new PUSH(cpg, DTM.ROOT_NODE));  // push root node
    }
    else {
        il.append(new ILOAD(current));
    }
    il.append(methodGen.loadDOM());
    final int stringF = cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                         "stringF",
                                         "("
                                         + OBJECT_SIG
                                         + NODE_SIG
                                         + DOM_INTF_SIG
                                         + ")" + STRING_SIG);
    il.append(new INVOKESTATIC(stringF));
}
项目:OpenJSharp    文件:Text.java   
/**
 * 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()));
}
项目:openjdk-jdk10    文件:Predicate.java   
/**
 * Translate a predicate expression. If non of the optimizations apply
 * then this translation pushes two references on the stack: a reference
 * to a newly created filter object and a reference to the predicate's
 * closure. See class <code>Step</code> for further details.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_nthPositionFilter || _nthDescendant) {
        _exp.translate(classGen, methodGen);
    }
    else if (isNodeValueTest() && (getParent() instanceof Step)) {
        _value.translate(classGen, methodGen);
        il.append(new CHECKCAST(cpg.addClass(STRING_CLASS)));
        il.append(new PUSH(cpg, ((EqualityExpr)_exp).getOp()));
    }
    else {
        translateFilter(classGen, methodGen);
    }
}
项目:openjdk-jdk10    文件:UnsupportedElement.java   
/**
 * Translate the fallback element (if any).
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    if (_fallbacks != null) {
        int count = _fallbacks.size();
        for (int i = 0; i < count; i++) {
            Fallback fallback = (Fallback)_fallbacks.elementAt(i);
            fallback.translate(classGen, methodGen);
        }
    }
    // We only go into the else block in forward-compatibility mode, when
    // the unsupported element has no fallback.
    else {
        // If the unsupported element does not have any fallback child, then
        // at runtime, a runtime error should be raised when the unsupported
        // element is instantiated. Otherwise, no error is thrown.
        ConstantPoolGen cpg = classGen.getConstantPool();
        InstructionList il = methodGen.getInstructionList();

        final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF",
                                                     "(" + STRING_SIG + "Z)V");
        il.append(new PUSH(cpg, getQName().toString()));
        il.append(new PUSH(cpg, _isExtension));
        il.append(new INVOKESTATIC(unsupportedElem));
    }
}
项目:openjdk-jdk10    文件:XslElement.java   
/**
 * 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());
    }
}
项目:openjdk-jdk10    文件:StringType.java   
/**
 * 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);
    }
}
项目:openjdk-jdk10    文件:ObjectType.java   
/**
 * 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));
}
项目:openjdk-jdk10    文件:ReferenceType.java   
/**
 * Translates reference into 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,
                        StringType type) {
    final int current = methodGen.getLocalIndex("current");
    ConstantPoolGen cpg = classGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();

    // If no current, conversion is a top-level
    if (current < 0) {
        il.append(new PUSH(cpg, DTM.ROOT_NODE));  // push root node
    }
    else {
        il.append(new ILOAD(current));
    }
    il.append(methodGen.loadDOM());
    final int stringF = cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                         "stringF",
                                         "("
                                         + OBJECT_SIG
                                         + NODE_SIG
                                         + DOM_INTF_SIG
                                         + ")" + STRING_SIG);
    il.append(new INVOKESTATIC(stringF));
}
项目:openjdk-jdk10    文件:Text.java   
/**
 * 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()));
}
项目:openjdk9    文件:Predicate.java   
/**
 * Translate a predicate expression. If non of the optimizations apply
 * then this translation pushes two references on the stack: a reference
 * to a newly created filter object and a reference to the predicate's
 * closure. See class <code>Step</code> for further details.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_nthPositionFilter || _nthDescendant) {
        _exp.translate(classGen, methodGen);
    }
    else if (isNodeValueTest() && (getParent() instanceof Step)) {
        _value.translate(classGen, methodGen);
        il.append(new CHECKCAST(cpg.addClass(STRING_CLASS)));
        il.append(new PUSH(cpg, ((EqualityExpr)_exp).getOp()));
    }
    else {
        translateFilter(classGen, methodGen);
    }
}
项目:openjdk9    文件:UnsupportedElement.java   
/**
 * Translate the fallback element (if any).
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    if (_fallbacks != null) {
        int count = _fallbacks.size();
        for (int i = 0; i < count; i++) {
            Fallback fallback = (Fallback)_fallbacks.elementAt(i);
            fallback.translate(classGen, methodGen);
        }
    }
    // We only go into the else block in forward-compatibility mode, when
    // the unsupported element has no fallback.
    else {
        // If the unsupported element does not have any fallback child, then
        // at runtime, a runtime error should be raised when the unsupported
        // element is instantiated. Otherwise, no error is thrown.
        ConstantPoolGen cpg = classGen.getConstantPool();
        InstructionList il = methodGen.getInstructionList();

        final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF",
                                                     "(" + STRING_SIG + "Z)V");
        il.append(new PUSH(cpg, getQName().toString()));
        il.append(new PUSH(cpg, _isExtension));
        il.append(new INVOKESTATIC(unsupportedElem));
    }
}
项目:openjdk9    文件:XslElement.java   
/**
 * 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());
    }
}
项目:openjdk9    文件:StringType.java   
/**
 * 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);
    }
}
项目:openjdk9    文件:ObjectType.java   
/**
 * 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));
}
项目:openjdk9    文件:ReferenceType.java   
/**
 * Translates reference into 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,
                        StringType type) {
    final int current = methodGen.getLocalIndex("current");
    ConstantPoolGen cpg = classGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();

    // If no current, conversion is a top-level
    if (current < 0) {
        il.append(new PUSH(cpg, DTM.ROOT_NODE));  // push root node
    }
    else {
        il.append(new ILOAD(current));
    }
    il.append(methodGen.loadDOM());
    final int stringF = cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                         "stringF",
                                         "("
                                         + OBJECT_SIG
                                         + NODE_SIG
                                         + DOM_INTF_SIG
                                         + ")" + STRING_SIG);
    il.append(new INVOKESTATIC(stringF));
}
项目:openjdk9    文件:Text.java   
/**
 * 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()));
}
项目:lookaside_java-1.8.0-openjdk    文件:Predicate.java   
/**
 * Translate a predicate expression. If non of the optimizations apply
 * then this translation pushes two references on the stack: a reference
 * to a newly created filter object and a reference to the predicate's
 * closure. See class <code>Step</code> for further details.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_nthPositionFilter || _nthDescendant) {
        _exp.translate(classGen, methodGen);
    }
    else if (isNodeValueTest() && (getParent() instanceof Step)) {
        _value.translate(classGen, methodGen);
        il.append(new CHECKCAST(cpg.addClass(STRING_CLASS)));
        il.append(new PUSH(cpg, ((EqualityExpr)_exp).getOp()));
    }
    else {
        translateFilter(classGen, methodGen);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:UnsupportedElement.java   
/**
 * Translate the fallback element (if any).
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    if (_fallbacks != null) {
        int count = _fallbacks.size();
        for (int i = 0; i < count; i++) {
            Fallback fallback = (Fallback)_fallbacks.elementAt(i);
            fallback.translate(classGen, methodGen);
        }
    }
    // We only go into the else block in forward-compatibility mode, when
    // the unsupported element has no fallback.
    else {
        // If the unsupported element does not have any fallback child, then
        // at runtime, a runtime error should be raised when the unsupported
        // element is instantiated. Otherwise, no error is thrown.
        ConstantPoolGen cpg = classGen.getConstantPool();
        InstructionList il = methodGen.getInstructionList();

        final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF",
                                                     "(" + STRING_SIG + "Z)V");
        il.append(new PUSH(cpg, getQName().toString()));
        il.append(new PUSH(cpg, _isExtension));
        il.append(new INVOKESTATIC(unsupportedElem));
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:XslElement.java   
/**
 * 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());
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:StringType.java   
/**
 * 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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ObjectType.java   
/**
 * 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));
}
项目:lookaside_java-1.8.0-openjdk    文件:ReferenceType.java   
/**
 * Translates reference into 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,
                        StringType type) {
    final int current = methodGen.getLocalIndex("current");
    ConstantPoolGen cpg = classGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();

    // If no current, conversion is a top-level
    if (current < 0) {
        il.append(new PUSH(cpg, DTM.ROOT_NODE));  // push root node
    }
    else {
        il.append(new ILOAD(current));
    }
    il.append(methodGen.loadDOM());
    final int stringF = cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                         "stringF",
                                         "("
                                         + OBJECT_SIG
                                         + NODE_SIG
                                         + DOM_INTF_SIG
                                         + ")" + STRING_SIG);
    il.append(new INVOKESTATIC(stringF));
}
项目:lookaside_java-1.8.0-openjdk    文件:Text.java   
/**
 * 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()));
}
项目:infobip-open-jdk-8    文件:Predicate.java   
/**
 * Translate a predicate expression. If non of the optimizations apply
 * then this translation pushes two references on the stack: a reference
 * to a newly created filter object and a reference to the predicate's
 * closure. See class <code>Step</code> for further details.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_nthPositionFilter || _nthDescendant) {
        _exp.translate(classGen, methodGen);
    }
    else if (isNodeValueTest() && (getParent() instanceof Step)) {
        _value.translate(classGen, methodGen);
        il.append(new CHECKCAST(cpg.addClass(STRING_CLASS)));
        il.append(new PUSH(cpg, ((EqualityExpr)_exp).getOp()));
    }
    else {
        translateFilter(classGen, methodGen);
    }
}
项目:infobip-open-jdk-8    文件:WithParam.java   
/**
 * Compile the value of the parameter, which is either in an expression in
 * a 'select' attribute, or in the with-param element's body
 */
public void translateValue(ClassGenerator classGen,
                           MethodGenerator methodGen) {
    // Compile expression is 'select' attribute if present
    if (_select != null) {
        _select.translate(classGen, methodGen);
        _select.startIterator(classGen, methodGen);
    }
    // If not, compile result tree from parameter body if present.
    else if (hasContents()) {
        compileResultTree(classGen, methodGen);
    }
    // If neither are present then store empty string in parameter slot
    else {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
        il.append(new PUSH(cpg, Constants.EMPTYSTRING));
    }
}
项目:infobip-open-jdk-8    文件:UnsupportedElement.java   
/**
 * Translate the fallback element (if any).
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    if (_fallbacks != null) {
        int count = _fallbacks.size();
        for (int i = 0; i < count; i++) {
            Fallback fallback = (Fallback)_fallbacks.elementAt(i);
            fallback.translate(classGen, methodGen);
        }
    }
    // We only go into the else block in forward-compatibility mode, when
    // the unsupported element has no fallback.
    else {
        // If the unsupported element does not have any fallback child, then
        // at runtime, a runtime error should be raised when the unsupported
        // element is instantiated. Otherwise, no error is thrown.
        ConstantPoolGen cpg = classGen.getConstantPool();
        InstructionList il = methodGen.getInstructionList();

        final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF",
                                                     "(" + STRING_SIG + "Z)V");
        il.append(new PUSH(cpg, getQName().toString()));
        il.append(new PUSH(cpg, _isExtension));
        il.append(new INVOKESTATIC(unsupportedElem));
    }
}
项目:infobip-open-jdk-8    文件:XslElement.java   
/**
 * 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());
    }
}
项目:infobip-open-jdk-8    文件:StringType.java   
/**
 * 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);
    }
}
项目:infobip-open-jdk-8    文件:ObjectType.java   
/**
 * 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));
}
项目:infobip-open-jdk-8    文件:ReferenceType.java   
/**
 * Translates reference into 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,
                        StringType type) {
    final int current = methodGen.getLocalIndex("current");
    ConstantPoolGen cpg = classGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();

    // If no current, conversion is a top-level
    if (current < 0) {
        il.append(new PUSH(cpg, DTM.ROOT_NODE));  // push root node
    }
    else {
        il.append(new ILOAD(current));
    }
    il.append(methodGen.loadDOM());
    final int stringF = cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                         "stringF",
                                         "("
                                         + OBJECT_SIG
                                         + NODE_SIG
                                         + DOM_INTF_SIG
                                         + ")" + STRING_SIG);
    il.append(new INVOKESTATIC(stringF));
}
项目:infobip-open-jdk-8    文件:Text.java   
/**
 * 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()));
}
项目:OLD-OpenJDK8    文件:Predicate.java   
/**
 * Translate a predicate expression. If non of the optimizations apply
 * then this translation pushes two references on the stack: a reference
 * to a newly created filter object and a reference to the predicate's
 * closure. See class <code>Step</code> for further details.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_nthPositionFilter || _nthDescendant) {
        _exp.translate(classGen, methodGen);
    }
    else if (isNodeValueTest() && (getParent() instanceof Step)) {
        _value.translate(classGen, methodGen);
        il.append(new CHECKCAST(cpg.addClass(STRING_CLASS)));
        il.append(new PUSH(cpg, ((EqualityExpr)_exp).getOp()));
    }
    else {
        translateFilter(classGen, methodGen);
    }
}
项目:OLD-OpenJDK8    文件:WithParam.java   
/**
 * Compile the value of the parameter, which is either in an expression in
 * a 'select' attribute, or in the with-param element's body
 */
public void translateValue(ClassGenerator classGen,
                           MethodGenerator methodGen) {
    // Compile expression is 'select' attribute if present
    if (_select != null) {
        _select.translate(classGen, methodGen);
        _select.startIterator(classGen, methodGen);
    }
    // If not, compile result tree from parameter body if present.
    else if (hasContents()) {
        compileResultTree(classGen, methodGen);
    }
    // If neither are present then store empty string in parameter slot
    else {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
        il.append(new PUSH(cpg, Constants.EMPTYSTRING));
    }
}
项目:OLD-OpenJDK8    文件:UnsupportedElement.java   
/**
 * Translate the fallback element (if any).
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    if (_fallbacks != null) {
        int count = _fallbacks.size();
        for (int i = 0; i < count; i++) {
            Fallback fallback = (Fallback)_fallbacks.elementAt(i);
            fallback.translate(classGen, methodGen);
        }
    }
    // We only go into the else block in forward-compatibility mode, when
    // the unsupported element has no fallback.
    else {
        // If the unsupported element does not have any fallback child, then
        // at runtime, a runtime error should be raised when the unsupported
        // element is instantiated. Otherwise, no error is thrown.
        ConstantPoolGen cpg = classGen.getConstantPool();
        InstructionList il = methodGen.getInstructionList();

        final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF",
                                                     "(" + STRING_SIG + "Z)V");
        il.append(new PUSH(cpg, getQName().toString()));
        il.append(new PUSH(cpg, _isExtension));
        il.append(new INVOKESTATIC(unsupportedElem));
    }
}