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


Java CFG.outgoingEdgeIterator方法代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.ba.CFG.outgoingEdgeIterator方法的典型用法代码示例。如果您正苦于以下问题:Java CFG.outgoingEdgeIterator方法的具体用法?Java CFG.outgoingEdgeIterator怎么用?Java CFG.outgoingEdgeIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.umd.cs.findbugs.ba.CFG的用法示例。


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

示例1: findThenFinish

import edu.umd.cs.findbugs.ba.CFG; //导入方法依赖的package包/类
private InstructionHandle findThenFinish(CFG cfg, BasicBlock thenBB, int elsePos) {
    InstructionHandle inst = thenBB.getFirstInstruction();
    while (inst == null) {
        Iterator<Edge> ie = cfg.outgoingEdgeIterator(thenBB);
        while (ie.hasNext()) {
            Edge e = ie.next();
            if (e.getType() == EdgeTypes.FALL_THROUGH_EDGE) {
                thenBB = e.getTarget();
                break;
            }
        }
        inst = thenBB.getFirstInstruction();
    }

    InstructionHandle lastIns = inst;
    while (inst.getPosition() < elsePos) {
        lastIns = inst;
        inst = inst.getNext();
    }

    return lastIns;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:23,代码来源:DuplicateBranches.java

示例2: getDeepFirstInstruction

import edu.umd.cs.findbugs.ba.CFG; //导入方法依赖的package包/类
/**
 * Like bb.getFirstInstruction() except that if null is returned it will
 * follow the FALL_THROUGH_EDGE (if any)
 */
private static InstructionHandle getDeepFirstInstruction(CFG cfg, BasicBlock bb) {
    InstructionHandle ih = bb.getFirstInstruction();
    if (ih != null)
        return ih;
    Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb);
    while (iei.hasNext()) {
        Edge e = iei.next();
        String edgeString = e.toString();
        if (EdgeTypes.FALL_THROUGH_EDGE == e.getType())
            return getDeepFirstInstruction(cfg, e.getTarget());
    }
    return null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:18,代码来源:DuplicateBranches.java

示例3: findIfElseDuplicates

import edu.umd.cs.findbugs.ba.CFG; //导入方法依赖的package包/类
private void findIfElseDuplicates(CFG cfg, Method method, BasicBlock bb) {
    BasicBlock thenBB = null, elseBB = null;

    Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb);
    while (iei.hasNext()) {
        Edge e = iei.next();
        if (e.getType() == EdgeTypes.IFCMP_EDGE) {
            elseBB = e.getTarget();
        } else if (e.getType() == EdgeTypes.FALL_THROUGH_EDGE) {
            thenBB = e.getTarget();
        }
    }

    if ((thenBB == null) || (elseBB == null))
        return;
    InstructionHandle thenStartHandle = getDeepFirstInstruction(cfg, thenBB);
    InstructionHandle elseStartHandle = getDeepFirstInstruction(cfg, elseBB);
    if ((thenStartHandle == null) || (elseStartHandle == null))
        return;

    int thenStartPos = thenStartHandle.getPosition();
    int elseStartPos = elseStartHandle.getPosition();

    InstructionHandle thenFinishIns = findThenFinish(cfg, thenBB, elseStartPos);
    int thenFinishPos = thenFinishIns.getPosition();

    if (!(thenFinishIns.getInstruction() instanceof GotoInstruction))
        return;

    InstructionHandle elseFinishHandle = ((GotoInstruction) thenFinishIns.getInstruction()).getTarget();
    int elseFinishPos = elseFinishHandle.getPosition();

    if (thenFinishPos >= elseStartPos)
        return;

    if ((thenFinishPos - thenStartPos) != (elseFinishPos - elseStartPos))
        return;

    if (thenFinishPos <= thenStartPos)
        return;

    byte[] thenBytes = getCodeBytes(method, thenStartPos, thenFinishPos);
    byte[] elseBytes = getCodeBytes(method, elseStartPos, elseFinishPos);

    if (!Arrays.equals(thenBytes, elseBytes))
        return;

    // adjust elseFinishPos to be inclusive (for source line attribution)
    InstructionHandle elseLastIns = elseFinishHandle.getPrev();
    if (elseLastIns != null)
        elseFinishPos = elseLastIns.getPosition();

    pendingBugs.add(new BugInstance(this, "DB_DUPLICATE_BRANCHES", NORMAL_PRIORITY)
            .addClassAndMethod(classContext.getJavaClass(), method)
            .addSourceLineRange(classContext, this, thenStartPos, thenFinishPos)
            .addSourceLineRange(classContext, this, elseStartPos, elseFinishPos));
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:58,代码来源:DuplicateBranches.java


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