Java Code Examples for org.apache.bcel.Const#ISTORE_2

The following examples show how to use org.apache.bcel.Const#ISTORE_2 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DismantleBytecode.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean isRegisterStore(int opcode) {
    switch (opcode) {
    case Const.ISTORE_0:
    case Const.ISTORE_1:
    case Const.ISTORE_2:
    case Const.ISTORE_3:

    case Const.ASTORE_0:
    case Const.ASTORE_1:
    case Const.ASTORE_2:
    case Const.ASTORE_3:

    case Const.FSTORE_0:
    case Const.FSTORE_1:
    case Const.FSTORE_2:
    case Const.FSTORE_3:

    case Const.DSTORE_0:
    case Const.DSTORE_1:
    case Const.DSTORE_2:
    case Const.DSTORE_3:

    case Const.LSTORE_0:
    case Const.LSTORE_1:
    case Const.LSTORE_2:
    case Const.LSTORE_3:

    case Const.ISTORE:
    case Const.FSTORE:
    case Const.ASTORE:
    case Const.LSTORE:
    case Const.DSTORE:
        return true;
    default:
        return false;
    }
}
 
Example 2
Source File: FindBadForLoop.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void sawOpcode(int seen) {
    if (seen == Const.ISTORE || seen == Const.ISTORE_0 || seen == Const.ISTORE_1 || seen == Const.ISTORE_2 || seen == Const.ISTORE_3) {
        lastRegStore = getRegisterOperand();
    }
    if (lineNumbers != null
            && stack.getStackDepth() >= 2
            && (seen == Const.IF_ICMPGE || seen == Const.IF_ICMPGT || seen == Const.IF_ICMPLT || seen == Const.IF_ICMPLE
                    || seen == Const.IF_ICMPNE || seen == Const.IF_ICMPEQ)) {
        OpcodeStack.Item item0 = stack.getStackItem(0);
        OpcodeStack.Item item1 = stack.getStackItem(1);
        int r0 = item0.getRegisterNumber();
        int r1 = item1.getRegisterNumber();
        int rMin = Math.min(r0, r1);
        int rMax = Math.max(r0, r1);
        int branchTarget = getBranchTarget();
        if (rMin == -1 && rMax > 0 && rMax == lastRegStore && branchTarget - 6 > getPC()) {
            int beforeTarget = getCodeByte(branchTarget - 3);
            int beforeGoto = getCodeByte(branchTarget - 6);
            if (beforeTarget == Const.GOTO && beforeGoto == Const.IINC) {
                int offset1 = (byte) getCodeByte(branchTarget - 2);
                int offset2 = getCodeByte(branchTarget - 1);
                int offset = offset1 << 8 | offset2;
                int backTarget = branchTarget - 3 + offset;
                int reg = getCodeByte(branchTarget - 5);
                int testLineNumber = lineNumbers.getSourceLine(getPC());
                int incLineNumber = lineNumbers.getSourceLine(branchTarget - 6);
                int beforeIncLineNumber = lineNumbers.getSourceLine(branchTarget - 7);
                if (backTarget < getPC() && getPC() - 8 < backTarget && reg != rMax && incLineNumber < testLineNumber + 3
                        && beforeIncLineNumber > incLineNumber) {

                    bugReporter.reportBug(new BugInstance(this, "QF_QUESTIONABLE_FOR_LOOP", NORMAL_PRIORITY)
                            .addClassAndMethod(this).addSourceLine(this));
                }
            }

        }
    }
}