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

The following examples show how to use org.apache.bcel.Const#IOR . 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: IncompatMask.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void afterOpcode(int seen) {
    super.afterOpcode(seen);
    switch (seen) {
    case Const.IAND:
    case Const.LAND:
    case Const.IOR:
    case Const.LOR:
        if (stack.getStackDepth() > 0) {
            bitresultItem = stack.getStackItem(0);
        }
        break;
    default:
        break;
    }
}
 
Example 2
Source File: FindNullDerefsInvolvingNonShortCircuitEvaluation.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.IAND || seen == Const.IOR) {

        int nextOpcode = getCodeByte(getPC() + 1);
        if (nextOpcode == Const.IFEQ || nextOpcode == Const.IFNE) {
            OpcodeStack.Item left = stack.getStackItem(1);
            OpcodeStack.Item right = stack.getStackItem(0);
            checkForNullForcingABranch(seen, nextOpcode, left);
            checkForNullForcingABranch(seen, nextOpcode, right);
        }

    }
}
 
Example 3
Source File: FindNullDerefsInvolvingNonShortCircuitEvaluation.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
private boolean nullGuaranteesBranch(int seen, OpcodeStack.Item item) {
    return item.getSpecialKind() == OpcodeStack.Item.ZERO_MEANS_NULL && seen == Const.IAND
            || item.getSpecialKind() == OpcodeStack.Item.NONZERO_MEANS_NULL && seen == Const.IOR;
}
 
Example 4
Source File: Noise.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void sawOpcode(int seen) {
    int priority;
    switch (seen) {
    case Const.INVOKEINTERFACE:
    case Const.INVOKEVIRTUAL:
    case Const.INVOKESPECIAL:
    case Const.INVOKESTATIC:
        hq.pushHash(getClassConstantOperand());
        if (getNameConstantOperand().indexOf('$') == -1) {
            hq.pushHash(getNameConstantOperand());
        }
        hq.pushHash(getSigConstantOperand());

        priority = hq.getPriority();
        if (priority <= Priorities.LOW_PRIORITY) {
            accumulator.accumulateBug(new BugInstance(this, "NOISE_METHOD_CALL", priority).addClassAndMethod(this)
                    .addCalledMethod(this), this);
        }
        break;
    case Const.GETFIELD:
    case Const.PUTFIELD:
    case Const.GETSTATIC:
    case Const.PUTSTATIC:
        hq.pushHash(getClassConstantOperand());
        if (getNameConstantOperand().indexOf('$') == -1) {
            hq.pushHash(getNameConstantOperand());
        }
        hq.pushHash(getSigConstantOperand());
        priority = hq.getPriority();
        if (priority <= Priorities.LOW_PRIORITY) {
            accumulator.accumulateBug(new BugInstance(this, "NOISE_FIELD_REFERENCE", priority).addClassAndMethod(this)
                    .addReferencedField(this), this);
        }
        break;
    case Const.CHECKCAST:
    case Const.INSTANCEOF:
    case Const.NEW:
        hq.pushHash(getClassConstantOperand());
        break;
    case Const.IFEQ:
    case Const.IFNE:
    case Const.IFNONNULL:
    case Const.IFNULL:
    case Const.IF_ICMPEQ:
    case Const.IF_ICMPNE:
    case Const.IF_ICMPLE:
    case Const.IF_ICMPGE:
    case Const.IF_ICMPGT:
    case Const.IF_ICMPLT:
    case Const.IF_ACMPEQ:
    case Const.IF_ACMPNE:
    case Const.RETURN:
    case Const.ARETURN:
    case Const.IRETURN:
    case Const.MONITORENTER:
    case Const.MONITOREXIT:
    case Const.IINC:
    case Const.NEWARRAY:
    case Const.TABLESWITCH:
    case Const.LOOKUPSWITCH:
    case Const.LCMP:
    case Const.INEG:
    case Const.IADD:
    case Const.IMUL:
    case Const.ISUB:
    case Const.IDIV:
    case Const.IREM:
    case Const.IXOR:
    case Const.ISHL:
    case Const.ISHR:
    case Const.IUSHR:
    case Const.IAND:
    case Const.IOR:
    case Const.LAND:
    case Const.LOR:
    case Const.LADD:
    case Const.LMUL:
    case Const.LSUB:
    case Const.LDIV:
    case Const.LSHL:
    case Const.LSHR:
    case Const.LUSHR:
    case Const.AALOAD:
    case Const.AASTORE:
    case Const.IALOAD:
    case Const.IASTORE:
    case Const.BALOAD:
    case Const.BASTORE:
        hq.push(seen);
        priority = hq.getPriority();
        if (priority <= Priorities.LOW_PRIORITY) {
            accumulator.accumulateBug(
                    new BugInstance(this, "NOISE_OPERATION", priority).addClassAndMethod(this).addString(Const.getOpcodeName(seen)),
                    this);
        }
        break;
    default:
        break;
    }
}
 
Example 5
Source File: FindNonShortCircuit.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void scanForShortCircuit(int seen) {
    switch (seen) {
    case Const.IAND:
    case Const.IOR:

        // System.out.println("Saw IOR or IAND at distance " + distance);
        OpcodeStack.Item item0 = stack.getStackItem(0);
        OpcodeStack.Item item1 = stack.getStackItem(1);
        if (item0.getConstant() == null && item1.getConstant() == null && distance < 4) {
            //                if (item0.getRegisterNumber() >= 0 && item1.getRegisterNumber() >= 0) {
            //                    if (false) {
            //                        clearAll();
            //                    }
            //                }
            operator = seen;
            stage2 = 1;
        } else {
            stage2 = 0;
        }
        break;
    case Const.IFEQ:
    case Const.IFNE:
        if (stage2 == 1) {
            // System.out.println("Found nsc");
            reportBug();
        }
        stage2 = 0;
        break;
    case Const.PUTFIELD:
    case Const.PUTSTATIC:
    case Const.IRETURN:
        if (operator == Const.IAND && stage2 == 1) {
            reportBug();
        }
        stage2 = 0;
        break;
    default:
        stage2 = 0;
        break;
    }
}
 
Example 6
Source File: FindNonShortCircuit.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void scanForBooleanValue(int seen) {
    switch (seen) {

    case Const.IAND:
    case Const.IOR:
        switch (prevOpcode) {
        case Const.ILOAD:
        case Const.ILOAD_0:
        case Const.ILOAD_1:
        case Const.ILOAD_2:
        case Const.ILOAD_3:
            clearAll();
            break;
        default:
            break;
        }
        break;
    case Const.ICONST_1:
        stage1 = 1;
        switch (prevOpcode) {
        case Const.IFNONNULL:
        case Const.IFNULL:
            sawNullTest = true;
            break;
        case Const.IF_ICMPGT:
        case Const.IF_ICMPGE:
        case Const.IF_ICMPLT:
        case Const.IF_ICMPLE:
            sawNumericTest = true;
            break;
        }

        break;
    case Const.GOTO:
        if (stage1 == 1) {
            stage1 = 2;
        } else {
            stage1 = 0;
            clearAll();
        }
        break;
    case Const.ICONST_0:
        if (stage1 == 2) {
            sawBooleanValue();
        }
        stage1 = 0;
        break;
    case Const.INVOKEINTERFACE:
    case Const.INVOKEVIRTUAL:
    case Const.INVOKESPECIAL:
    case Const.INVOKESTATIC:
        String sig = getSigConstantOperand();
        if (sig.endsWith(")Z")) {
            sawBooleanValue();
        }
        stage1 = 0;
        break;
    default:
        stage1 = 0;
    }
}
 
Example 7
Source File: ArithmeticInstruction.java    From commons-bcel with Apache License 2.0 4 votes vote down vote up
/** @return type associated with the instruction
 */
@Override
public Type getType( final ConstantPoolGen cp ) {
    final short _opcode = super.getOpcode();
    switch (_opcode) {
        case Const.DADD:
        case Const.DDIV:
        case Const.DMUL:
        case Const.DNEG:
        case Const.DREM:
        case Const.DSUB:
            return Type.DOUBLE;
        case Const.FADD:
        case Const.FDIV:
        case Const.FMUL:
        case Const.FNEG:
        case Const.FREM:
        case Const.FSUB:
            return Type.FLOAT;
        case Const.IADD:
        case Const.IAND:
        case Const.IDIV:
        case Const.IMUL:
        case Const.INEG:
        case Const.IOR:
        case Const.IREM:
        case Const.ISHL:
        case Const.ISHR:
        case Const.ISUB:
        case Const.IUSHR:
        case Const.IXOR:
            return Type.INT;
        case Const.LADD:
        case Const.LAND:
        case Const.LDIV:
        case Const.LMUL:
        case Const.LNEG:
        case Const.LOR:
        case Const.LREM:
        case Const.LSHL:
        case Const.LSHR:
        case Const.LSUB:
        case Const.LUSHR:
        case Const.LXOR:
            return Type.LONG;
        default: // Never reached
            throw new ClassGenException("Unknown type " + _opcode);
    }
}