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


Java InstructionList.getStart方法代码示例

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


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

示例1: compile

import com.sun.org.apache.bcel.internal.generic.InstructionList; //导入方法依赖的package包/类
/**
 * Compile the code for this test sequence. Compile patterns
 * from highest to lowest priority. Note that since patterns
 * can be share by multiple test sequences, instruction lists
 * must be copied before backpatching.
 */
public InstructionHandle compile(ClassGenerator classGen,
                                 MethodGenerator methodGen,
                                 InstructionHandle continuation)
{
    // Returned cached value if already compiled
    if (_start != null) {
        return _start;
    }

    // If not patterns, then return handle for default template
    final int count = _patterns.size();
    if (count == 0) {
        return (_start = getTemplateHandle(_default));
    }

    // Init handle to jump when all patterns failed
    InstructionHandle fail = (_default == null) ? continuation
        : getTemplateHandle(_default);

    // Compile all patterns in reverse order
    for (int n = count - 1; n >= 0; n--) {
        final LocationPathPattern pattern = getPattern(n);
        final Template template = pattern.getTemplate();
        final InstructionList il = new InstructionList();

        // Patterns expect current node on top of stack
        il.append(methodGen.loadCurrentNode());

        // Apply the test-code compiled for the pattern
        InstructionList ilist = methodGen.getInstructionList(pattern);
        if (ilist == null) {
            ilist = pattern.compile(classGen, methodGen);
            methodGen.addInstructionList(pattern, ilist);
        }

        // Make a copy of the instruction list for backpatching
        InstructionList copyOfilist = ilist.copy();

        FlowList trueList = pattern.getTrueList();
        if (trueList != null) {
            trueList = trueList.copyAndRedirect(ilist, copyOfilist);
        }
        FlowList falseList = pattern.getFalseList();
        if (falseList != null) {
            falseList = falseList.copyAndRedirect(ilist, copyOfilist);
        }

        il.append(copyOfilist);

        // On success branch to the template code
        final InstructionHandle gtmpl = getTemplateHandle(template);
        final InstructionHandle success = il.append(new GOTO_W(gtmpl));

        if (trueList != null) {
            trueList.backPatch(success);
        }
        if (falseList != null) {
            falseList.backPatch(fail);
        }

        // Next pattern's 'fail' target is this pattern's first instruction
        fail = il.getStart();

        // Append existing instruction list to the end of this one
        if (_instructionList != null) {
            il.append(_instructionList);
        }

        // Set current instruction list to be this one
        _instructionList = il;
    }
    return (_start = fail);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:80,代码来源:TestSeq.java


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