当前位置: 首页>>代码示例>>Java>>正文


Java InstructionList.setPositions方法代码示例

本文整理汇总了Java中com.sun.org.apache.bcel.internal.generic.InstructionList.setPositions方法的典型用法代码示例。如果您正苦于以下问题:Java InstructionList.setPositions方法的具体用法?Java InstructionList.setPositions怎么用?Java InstructionList.setPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.org.apache.bcel.internal.generic.InstructionList的用法示例。


在下文中一共展示了InstructionList.setPositions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGeneratedMethods

import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
 * <p>Get all {@link Method}s generated by this {@link MethodGenerator}.
 * The {@link MethodGen#getMethod()} only returns a single
 * <code>Method</code> object.  This method takes into account the Java
 * Virtual Machine Specification limit of 64KB on the size of a method, and
 * may return more than one <code>Method</code>.</p>
 * <p>If the code associated with the <code>MethodGenerator</code> would
 * exceed the 64KB limit, this method will attempt to split the code in
 * the {@link InstructionList} associated with this
 * <code>MethodGenerator</code> into several methods.</p>
 * @param classGen the {@link ClassGenerator} of which these methods are
 *                 members
 * @return an array of all the <code>Method</code>s generated
 */
Method[] getGeneratedMethods(ClassGenerator classGen) {
    Method[] generatedMethods;
    InstructionList il = getInstructionList();
    InstructionHandle last = il.getEnd();

    il.setPositions();

    int instructionListSize =
                last.getPosition() + last.getInstruction().getLength();

    // Need to look for any branch target offsets that exceed the range
    // [-32768,32767]
    if (instructionListSize > MAX_BRANCH_TARGET_OFFSET) {
        boolean ilChanged = widenConditionalBranchTargetOffsets();

        // If any branch instructions needed widening, recompute the size
        // of the byte code for the method
        if (ilChanged) {
            il.setPositions();
            last = il.getEnd();
            instructionListSize =
                    last.getPosition() + last.getInstruction().getLength();
        }
    }

    if (instructionListSize > MAX_METHOD_SIZE) {
        generatedMethods = outlineChunks(classGen, instructionListSize);
    } else {
        generatedMethods = new Method[] {getThisMethod()};
    }
    return generatedMethods;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:47,代码来源:MethodGenerator.java

示例2: translate

import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_disabled) return;
    // bug fix #4433133, add a call to named template from applyTemplates
    String className = classGen.getClassName();

    if (_compiled && isNamed()){
        String methodName = Util.escape(_name.toString());
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                     methodName,
                                                     "("
                                                     + DOM_INTF_SIG
                                                     + NODE_ITERATOR_SIG
                                                     + TRANSLET_OUTPUT_SIG
                                                     + "I)V")));
        return;
    }

    if (_compiled) return;
    _compiled = true;

    // %OPT% Special handling for simple named templates.
    if (_isSimpleNamedTemplate && methodGen instanceof NamedMethodGenerator) {
        int numParams = _parameters.size();
        NamedMethodGenerator namedMethodGen = (NamedMethodGenerator)methodGen;

        // Update load/store instructions to access Params from the stack
        for (int i = 0; i < numParams; i++) {
            Param param = (Param)_parameters.elementAt(i);
            param.setLoadInstruction(namedMethodGen.loadParameter(i));
            param.setStoreInstruction(namedMethodGen.storeParameter(i));
        }
    }

    translateContents(classGen, methodGen);
    il.setPositions(true);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:Template.java


注:本文中的com.sun.org.apache.bcel.internal.generic.InstructionList.setPositions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。