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

项目: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;
}
项目: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    文件: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    文件:VariableBase.java   
/**
 * Remove the mapping of this variable to a register.
 * Called when we leave the AST scope of the variable's declaration
 */
public void unmapRegister(ClassGenerator classGen, MethodGenerator methodGen) {
    if (_local != null) {
        if (_type instanceof ResultTreeType) {
            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(loadInstruction());
                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(loadInstruction());
            il.append(new INVOKEINTERFACE(release, 1));
        }

        _local.setEnd(methodGen.getInstructionList().getEnd());
        methodGen.removeLocalVariable(_local);
        _refs = null;
        _local = null;
    }
}
项目: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));
}
项目:openjdk9    文件: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;
}
项目:openjdk9    文件:VariableBase.java   
/**
 * Remove the mapping of this variable to a register.
 * Called when we leave the AST scope of the variable's declaration
 */
public void unmapRegister(ClassGenerator classGen, MethodGenerator methodGen) {
    if (_local != null) {
        if (_type instanceof ResultTreeType) {
            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(loadInstruction());
                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(loadInstruction());
            il.append(new INVOKEINTERFACE(release, 1));
        }

        _local.setEnd(methodGen.getInstructionList().getEnd());
        methodGen.removeLocalVariable(_local);
        _refs = null;
        _local = null;
    }
}
项目:openjdk9    文件: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 = null;
     }
 }
项目: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));
}
项目:lookaside_java-1.8.0-openjdk    文件: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;
}
项目:lookaside_java-1.8.0-openjdk    文件:VariableBase.java   
/**
 * Remove the mapping of this variable to a register.
 * Called when we leave the AST scope of the variable's declaration
 */
public void unmapRegister(ClassGenerator classGen, MethodGenerator methodGen) {
    if (_local != null) {
        if (_type instanceof ResultTreeType) {
            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(loadInstruction());
                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(loadInstruction());
            il.append(new INVOKEINTERFACE(release, 1));
        }

        _local.setEnd(methodGen.getInstructionList().getEnd());
        methodGen.removeLocalVariable(_local);
        _refs = null;
        _local = null;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件: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 = null;
     }
 }
项目: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));
}
项目:infobip-open-jdk-8    文件: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;
}
项目: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));
}
项目:OLD-OpenJDK8    文件: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;
}
项目:OLD-OpenJDK8    文件: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-icedtea7    文件: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-icedtea7    文件: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    文件: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));
}
项目: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));

    }
}
项目:OpenJSharp    文件:ContainsCall.java   
/**
 * 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)));
}
项目:OpenJSharp    文件:WithParam.java   
/**
 * This code generates a sequence of bytecodes that call the
 * addParameter() method in AbstractTranslet. The method call will add
 * (or update) the parameter frame with the new parameter value.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // Translate the value and put it on the stack
    if (_doParameterOptimization) {
        translateValue(classGen, methodGen);
        return;
    }

    // Make name acceptable for use as field name in class
    String name = Util.escape(getEscapedName());

    // Load reference to the translet (method is in AbstractTranslet)
    il.append(classGen.loadTranslet());

    // Load the name of the parameter
    il.append(new PUSH(cpg, name)); // TODO: namespace ?
    // Generete the value of the parameter (use value in 'select' by def.)
    translateValue(classGen, methodGen);
    // Mark this parameter value is not being the default value
    il.append(new PUSH(cpg, false));
    // Pass the parameter to the template
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));
    il.append(POP); // cleanup stack
}
项目:OpenJSharp    文件: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)));
}
项目:OpenJSharp    文件:IntType.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(INTEGER_CLASS)));
    final int index = cpg.addMethodref(INTEGER_CLASS,
                                       INT_VALUE,
                                       INT_VALUE_SIG);
    il.append(new INVOKEVIRTUAL(index));
}
项目:OpenJSharp    文件:RealType.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(DOUBLE_CLASS)));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOUBLE_CLASS,
                                                 DOUBLE_VALUE,
                                                 DOUBLE_VALUE_SIG)));
}
项目:OpenJSharp    文件: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)));
}
项目:OpenJSharp    文件:StartsWithCall.java   
/**
 * Compile the expression - leave boolean expression on stack
 */
public void translate(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,
                                                 "startsWith",
                                                 "("+STRING_SIG+")Z")));
}
项目:openjdk-jdk10    文件: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    文件: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    文件:ContainsCall.java   
/**
 * 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)));
}
项目:openjdk-jdk10    文件:WithParam.java   
/**
 * This code generates a sequence of bytecodes that call the
 * addParameter() method in AbstractTranslet. The method call will add
 * (or update) the parameter frame with the new parameter value.
 */
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // Translate the value and put it on the stack
    if (_doParameterOptimization) {
        translateValue(classGen, methodGen);
        return;
    }

    // Make name acceptable for use as field name in class
    String name = Util.escape(getEscapedName());

    // Load reference to the translet (method is in AbstractTranslet)
    il.append(classGen.loadTranslet());

    // Load the name of the parameter
    il.append(new PUSH(cpg, name)); // TODO: namespace ?
    // Generete the value of the parameter (use value in 'select' by def.)
    translateValue(classGen, methodGen);
    // Mark this parameter value is not being the default value
    il.append(new PUSH(cpg, false));
    // Pass the parameter to the template
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));
    il.append(POP); // cleanup stack
}
项目: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    文件:FunctionCall.java   
private void generateAddReads(ClassGenerator classGen, MethodGenerator methodGen,
                      String clazz) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // Generate call to Module.addReads:
    //   <TransletClass>.class.getModule().addReads(
    //        Class.forName(<clazz>).getModule());
    // Class.forName may throw ClassNotFoundException.
    // This is OK as it will caught higher up the stack in
    // TransformerImpl.transform() and wrapped into a
    // TransformerException.
    methodGen.markChunkStart();

    int index = cpg.addMethodref(CLASS_CLASS,
                                 GET_MODULE,
                                 GET_MODULE_SIG);
    int index2 = cpg.addMethodref(CLASS_CLASS,
                                  FOR_NAME,
                                  FOR_NAME_SIG);
    il.append(new LDC(cpg.addString(classGen.getClassName())));
    il.append(new INVOKESTATIC(index2));
    il.append(new INVOKEVIRTUAL(index));
    il.append(new LDC(cpg.addString(clazz)));
    il.append(new INVOKESTATIC(index2));
    il.append(new INVOKEVIRTUAL(index));
    index = cpg.addMethodref(MODULE_CLASS,
                             ADD_READS,
                             ADD_READS_SIG);
    il.append(new INVOKEVIRTUAL(index));
    il.append(InstructionConst.POP);

    methodGen.markChunkEnd();
}
项目: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    文件:IntType.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(INTEGER_CLASS)));
    final int index = cpg.addMethodref(INTEGER_CLASS,
                                       INT_VALUE,
                                       INT_VALUE_SIG);
    il.append(new INVOKEVIRTUAL(index));
}
项目:openjdk-jdk10    文件:RealType.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(DOUBLE_CLASS)));
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOUBLE_CLASS,
                                                 DOUBLE_VALUE,
                                                 DOUBLE_VALUE_SIG)));
}
项目: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    文件:StartsWithCall.java   
/**
 * Compile the expression - leave boolean expression on stack
 */
public void translate(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,
                                                 "startsWith",
                                                 "("+STRING_SIG+")Z")));
}
项目:openjdk9    文件: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));
}