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

项目:OpenJSharp    文件:Mode.java   
/**
 * Compiles the default handling for DOM elements: traverse all children
 */
private InstructionList compileDefaultRecursion(ClassGenerator classGen,
                                                MethodGenerator methodGen,
                                                InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();
    final String applyTemplatesSig = classGen.getApplyTemplatesSig();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    final int applyTemplates = cpg.addMethodref(getClassName(),
                                                functionName(),
                                                applyTemplatesSig);
    il.append(classGen.loadTranslet());
    il.append(methodGen.loadDOM());

    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(new INVOKEINTERFACE(git, 2));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEVIRTUAL(applyTemplates));
    il.append(new GOTO_W(next));
    return il;
}
项目: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    文件:Mode.java   
/**
 * Compiles the default action for DOM text nodes and attribute nodes:
 * output the node's text value
 */
private InstructionList compileDefaultText(ClassGenerator classGen,
                                           MethodGenerator methodGen,
                                           InstructionHandle next) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = new InstructionList();

    final int chars = cpg.addInterfaceMethodref(DOM_INTF,
                                                CHARACTERS,
                                                CHARACTERS_SIG);
    il.append(methodGen.loadDOM());
    il.append(new ILOAD(_currentIndex));
    il.append(methodGen.loadHandler());
    il.append(new INVOKEINTERFACE(chars, 3));
    il.append(new GOTO_W(next));
    return il;
}
项目:OpenJSharp    文件:Sort.java   
/**
 * 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;
}
项目:OpenJSharp    文件:LocalNameCall.java   
/**
 * This method is called when the constructor is compiled in
 * Stylesheet.compileConstructor() and not as the syntax tree is traversed.
 */
public void translate(ClassGenerator classGen,
                      MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // Returns the name of a node in the DOM
    final int getNodeName = cpg.addInterfaceMethodref(DOM_INTF,
                                                      "getNodeName",
                                                      "(I)"+STRING_SIG);

    final int getLocalName = cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                              "getLocalName",
                                              "(Ljava/lang/String;)"+
                                              "Ljava/lang/String;");
    super.translate(classGen, methodGen);
    il.append(new INVOKEINTERFACE(getNodeName, 2));
    il.append(new INVOKESTATIC(getLocalName));
}
项目: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    文件:LastCall.java   
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();

    if (methodGen instanceof CompareGenerator) {
        il.append(((CompareGenerator)methodGen).loadLastNode());
    }
    else if (methodGen instanceof TestGenerator) {
        il.append(new ILOAD(LAST_INDEX));
    }
    else {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final int getLast = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                      "getLast",
                                                      "()I");
        il.append(methodGen.loadIterator());
        il.append(new INVOKEINTERFACE(getLast, 1));
    }
}
项目: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));
    }
}
项目:openjdk-jdk10    文件:LangCall.java   
/**
 * This method is called when the constructor is compiled in
 * Stylesheet.compileConstructor() and not as the syntax tree is traversed.
 */
public void translate(ClassGenerator classGen,
                      MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final int tst = cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                     "testLanguage",
                                     "("+STRING_SIG+DOM_INTF_SIG+"I)Z");
    _lang.translate(classGen,methodGen);
    il.append(methodGen.loadDOM());
    if (classGen instanceof FilterGenerator)
        il.append(new ILOAD(1));
    else
        il.append(methodGen.loadContextNode());
    il.append(new INVOKESTATIC(tst));
}
项目: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));
}
项目:openjdk-jdk10    文件:Sort.java   
/**
 * 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;
}
项目: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    文件:WithParam.java   
/**
 * 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;
    }
}
项目:openjdk-jdk10    文件:Mode.java   
public static void compileGetChildren(ClassGenerator classGen,
                                      MethodGenerator methodGen,
                                      int node) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final int git = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_CHILDREN,
                                              GET_CHILDREN_SIG);
    il.append(methodGen.loadDOM());
    il.append(new ILOAD(node));
    il.append(new INVOKEINTERFACE(git, 2));
}
项目:OpenJSharp    文件:Variable.java   
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach class for an explanation
 */
public void initialize(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(),
                                                 _type.toJCType(),
                                                 null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) ||
            (_type instanceof NodeType) ||
            (_type instanceof BooleanType))
            il.append(new ICONST(0)); // 0 for node-id, integer and boolean
        else if (_type instanceof RealType)
            il.append(new DCONST(0)); // 0.0 for floating point numbers
        else
            il.append(new ACONST_NULL()); // and 'null' for anything else

        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));

    }
}
项目:OpenJSharp    文件:NameBase.java   
/**
 * Translate the code required for getting the node for which the
 * QName, local-name or namespace URI should be extracted.
 */
public void translate(ClassGenerator classGen,
                      MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(methodGen.loadDOM());

    // Function was called with no parameters
    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
    }
    // Function was called with node parameter
    else if (_paramType == Type.Node) {
        _param.translate(classGen, methodGen);
    }
    else if (_paramType == Type.Reference) {
        _param.translate(classGen, methodGen);
        il.append(new INVOKESTATIC(cpg.addMethodref
                                   (BASIS_LIBRARY_CLASS,
                                    "referenceToNodeSet",
                                    "("
                                    + OBJECT_SIG
                                    + ")"
                                    + NODE_ITERATOR_SIG)));
        il.append(methodGen.nextNode());
    }
    // Function was called with node-set parameter
    else {
        _param.translate(classGen, methodGen);
        _param.startIterator(classGen, methodGen);
        il.append(methodGen.nextNode());
    }
}
项目:openjdk-jdk10    文件:UseAttributeSets.java   
/**
 * 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);
        }
    }
}
项目:openjdk-jdk10    文件:NodeType.java   
/**
 * 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(RUNTIME_NODE_CLASS)));
    il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS,
                                           NODE_FIELD,
                                           NODE_FIELD_SIG)));
}
项目:openjdk-jdk10    文件:StringLengthCall.java   
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    if (argumentCount() > 0) {
        argument().translate(classGen, methodGen);
    }
    else {
        il.append(methodGen.loadContextNode());
        Type.Node.translateTo(classGen, methodGen, Type.String);
    }
    il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                                 "getStringLength",
                                                 "(Ljava/lang/String;)I")));
}
项目:OpenJSharp    文件:FormatNumberCall.java   
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    _value.translate(classGen, methodGen);
    _format.translate(classGen, methodGen);

    final int fn3arg = cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                        "formatNumber",
                                        "(DLjava/lang/String;"+
                                        "Ljava/text/DecimalFormat;)"+
                                        "Ljava/lang/String;");
    final int get = cpg.addMethodref(TRANSLET_CLASS,
                                     "getDecimalFormat",
                                     "(Ljava/lang/String;)"+
                                     "Ljava/text/DecimalFormat;");

    il.append(classGen.loadTranslet());
    if (_name == null) {
        il.append(new PUSH(cpg, EMPTYSTRING));
    }
    else if (_resolvedQName != null) {
        il.append(new PUSH(cpg, _resolvedQName.toString()));
    }
    else {
        _name.translate(classGen, methodGen);
    }
    il.append(new INVOKEVIRTUAL(get));
    il.append(new INVOKESTATIC(fn3arg));
}
项目:openjdk-jdk10    文件:NameCall.java   
/**
 * Translate code that leaves a node's QName (as a String) on the stack
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final int getName = cpg.addInterfaceMethodref(DOM_INTF,
                                                  GET_NODE_NAME,
                                                  GET_NODE_NAME_SIG);
    super.translate(classGen, methodGen);
    il.append(new INVOKEINTERFACE(getName, 2));
}
项目:openjdk-jdk10    文件:NamespaceUriCall.java   
/**
 * 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));
}
项目:OpenJSharp    文件:RelationalExpr.java   
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    if (hasNodeSetArgs() || hasReferenceArgs()) {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();

        // Call compare() from the BasisLibrary
        _left.translate(classGen, methodGen);
        _left.startIterator(classGen, methodGen);
        _right.translate(classGen, methodGen);
        _right.startIterator(classGen, methodGen);

        il.append(new PUSH(cpg, _op));
        il.append(methodGen.loadDOM());

        int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "compare",
                                     "("
                                     + _left.getType().toSignature()
                                     + _right.getType().toSignature()
                                     + "I"
                                     + DOM_INTF_SIG
                                     + ")Z");
        il.append(new INVOKESTATIC(index));
    }
    else {
        translateDesynthesized(classGen, methodGen);
        synthesize(classGen, methodGen);
    }
}
项目:OpenJSharp    文件:CastCall.java   
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    _right.translate(classGen, methodGen);
    il.append(new CHECKCAST(cpg.addClass(_className)));
}
项目:openjdk-jdk10    文件:UnparsedEntityUriCall.java   
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));
}
项目:OpenJSharp    文件:UnionPathExpr.java   
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));

    }
}
项目:openjdk-jdk10    文件:BooleanType.java   
/**
 * 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")));
}
项目:openjdk-jdk10    文件:RealType.java   
/**
 * Expects a real on the stack and pushes a truncated integer value
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        IntType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                                "realToInt","(D)I")));
}
项目:OpenJSharp    文件:Expression.java   
/**
 * 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));
}
项目:OpenJSharp    文件:RoundCall.java   
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // Get two copies of the argument on the stack
    argument().translate(classGen, methodGen);
            il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                                        "roundF", "(D)D")));
}
项目:openjdk-jdk10    文件:ReferenceType.java   
/**
 * 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));
}
项目:OpenJSharp    文件:FunctionCall.java   
/**
 * Translate code to call the BasisLibrary.unallowed_extensionF(String)
 * method.
 */
private void translateUnallowedExtension(ConstantPoolGen cpg,
                                         InstructionList il) {
    int index = cpg.addMethodref(BASIS_LIBRARY_CLASS,
                                 "unallowed_extension_functionF",
                                 "(Ljava/lang/String;)V");
    il.append(new PUSH(cpg, _fname.toString()));
    il.append(new INVOKESTATIC(index));
}
项目:openjdk-jdk10    文件:StringType.java   
/**
 * Translates a string into a non-synthesized boolean. It does not push a
 * 0 or a 1 but instead returns branchhandle list to be appended to the
 * false list.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateToDesynthesized
 */
public FlowList translateToDesynthesized(ClassGenerator classGen,
                                         MethodGenerator methodGen,
                                         BooleanType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS,
                                                 "length", "()I")));
    return new FlowList(il.append(new IFEQ(null)));
}
项目:openjdk-jdk10    文件:BooleanType.java   
/**
 * 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(BOOLEAN_CLASS)));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(BOOLEAN_CLASS,
                                                 BOOLEAN_VALUE,
                                                 BOOLEAN_VALUE_SIG)));
}
项目:openjdk-jdk10    文件:MatchGenerator.java   
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);
}
项目:OpenJSharp    文件:NameCall.java   
/**
 * Translate code that leaves a node's QName (as a String) on the stack
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    final int getName = cpg.addInterfaceMethodref(DOM_INTF,
                                                  GET_NODE_NAME,
                                                  GET_NODE_NAME_SIG);
    super.translate(classGen, methodGen);
    il.append(new INVOKEINTERFACE(getName, 2));
}
项目:OpenJSharp    文件:NamespaceUriCall.java   
/**
 * 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));
}
项目:OpenJSharp    文件:CastExpr.java   
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);
            }
        }
    }
}
项目:OpenJSharp    文件:UseAttributeSets.java   
/**
 * 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);
        }
    }
}