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


Java Rop.BRANCH_IF属性代码示例

本文整理汇总了Java中com.android.dx.rop.code.Rop.BRANCH_IF属性的典型用法代码示例。如果您正苦于以下问题:Java Rop.BRANCH_IF属性的具体用法?Java Rop.BRANCH_IF怎么用?Java Rop.BRANCH_IF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.android.dx.rop.code.Rop的用法示例。


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

示例1: outputBlock

/**
 * Helper for {@link #outputInstructions}, which does the processing
 * and output of one block.
 *
 * @param block {@code non-null;} the block to process and output
 * @param nextLabel {@code >= -1;} the next block that will be processed, or
 * {@code -1} if there is no next block
 */
private void outputBlock(BasicBlock block, int nextLabel) {
    // Append the code address for this block.
    CodeAddress startAddress = addresses.getStart(block);
    output.add(startAddress);

    // Append the local variable state for the block.
    if (locals != null) {
        RegisterSpecSet starts = locals.getStarts(block);
        output.add(new LocalSnapshot(startAddress.getPosition(),
                                     starts));
    }

    /*
     * Choose and append an output instruction for each original
     * instruction.
     */
    translationVisitor.setBlock(block, addresses.getLast(block));
    block.getInsns().forEach(translationVisitor);

    // Insert the block end code address.
    output.add(addresses.getEnd(block));

    // Set up for end-of-block activities.

    int succ = block.getPrimarySuccessor();
    Insn lastInsn = block.getLastInsn();

    /*
     * Check for (and possibly correct for) a non-optimal choice of
     * which block will get output next.
     */

    if ((succ >= 0) && (succ != nextLabel)) {
        /*
         * The block has a "primary successor" and that primary
         * successor isn't the next block to be output.
         */
        Rop lastRop = lastInsn.getOpcode();
        if ((lastRop.getBranchingness() == Rop.BRANCH_IF) &&
                (block.getSecondarySuccessor() == nextLabel)) {
            /*
             * The block ends with an "if" of some sort, and its
             * secondary successor (the "then") is in fact the
             * next block to output. So, reverse the sense of
             * the test, so that we can just emit the next block
             * without an interstitial goto.
             */
            output.reverseBranch(1, addresses.getStart(succ));
        } else {
            /*
             * Our only recourse is to add a goto here to get the
             * flow to be correct.
             */
            TargetInsn insn =
                new TargetInsn(Dops.GOTO, lastInsn.getPosition(),
                        RegisterSpecList.EMPTY,
                        addresses.getStart(succ));
            output.add(insn);
        }
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:69,代码来源:RopTranslator.java

示例2: visitPlainInsn

/** {@inheritDoc} */
public void visitPlainInsn(PlainInsn insn) {
    Rop rop = insn.getOpcode();
    if (rop.getOpcode() == RegOps.MARK_LOCAL) {
        /*
         * Ignore these. They're dealt with by
         * the LocalVariableAwareTranslationVisitor
         */
        return;
    }
    if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) {
        // These get skipped
        return;
    }

    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    DalvInsn di;

    switch (rop.getBranchingness()) {
        case Rop.BRANCH_NONE:
        case Rop.BRANCH_RETURN:
        case Rop.BRANCH_THROW: {
            di = new SimpleInsn(opcode, pos, getRegs(insn));
            break;
        }
        case Rop.BRANCH_GOTO: {
            /*
             * Code in the main translation loop will emit a
             * goto if necessary (if the branch isn't to the
             * immediately subsequent block).
             */
            return;
        }
        case Rop.BRANCH_IF: {
            int target = block.getSuccessors().get(1);
            di = new TargetInsn(opcode, pos, getRegs(insn),
                                addresses.getStart(target));
            break;
        }
        default: {
            throw new RuntimeException("shouldn't happen");
        }
    }

    addOutput(di);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:47,代码来源:RopTranslator.java

示例3: addInstruction

/**
 * @param branch the branches to follow; interpretation depends on the
 *     instruction's branchingness.
 */
private void addInstruction(Insn insn, Label branch) {
    if (currentLabel == null || !currentLabel.marked) {
        throw new IllegalStateException("no current label");
    }
    currentLabel.instructions.add(insn);

    switch (insn.getOpcode().getBranchingness()) {
    case BRANCH_NONE:
        if (branch != null) {
            throw new IllegalArgumentException("unexpected branch: " + branch);
        }
        return;

    case BRANCH_RETURN:
        if (branch != null) {
            throw new IllegalArgumentException("unexpected branch: " + branch);
        }
        currentLabel = null;
        break;

    case BRANCH_GOTO:
        if (branch == null) {
            throw new IllegalArgumentException("branch == null");
        }
        currentLabel.primarySuccessor = branch;
        currentLabel = null;
        break;

    case Rop.BRANCH_IF:
        if (branch == null) {
            throw new IllegalArgumentException("branch == null");
        }
        splitCurrentLabel(branch, Collections.<Label>emptyList());
        break;

    case Rop.BRANCH_THROW:
        if (branch != null) {
            throw new IllegalArgumentException("unexpected branch: " + branch);
        }
        splitCurrentLabel(null, new ArrayList<Label>(catchLabels));
        break;

    default:
        throw new IllegalArgumentException();
    }
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:50,代码来源:Code.java


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