/** * Transforms the already calculated term into a new term which "includes" the given if statement. */ @Override public Statement astIf(IfBlock ifBlock) { wp = new Or( new And(ifBlock.getCondition(), wp(ifBlock.getThenBlock(), wp)), new And(new Not(ifBlock.getCondition()), wp(ifBlock.getElseBlock(), wp))); return null; }
@Override public void sawOpcode(int seen) { try { int removed = 0; if (!ifBlocks.isEmpty()) { Iterator<IfBlock> it = ifBlocks.iterator(); while (it.hasNext()) { IfBlock block = it.next(); if ((getPC() >= block.getEnd())) { it.remove(); removed++; } } } if (removed > 1) { activeUnconditional = null; } if (!casePositions.isEmpty() && (casePositions.getFirst().intValue() == getPC())) { casePositions.removeFirst(); activeUnconditional = null; lookingForResetOp = true; } if (lookingForResetOp) { if (isResetOp(seen)) { lookingForResetOp = false; } else { return; } } if (isBranch(seen)) { if (activeUnconditional != null) { activeUnconditional = null; if (!ifBlocks.isEmpty()) { ifBlocks.removeLast(); } lookingForResetOp = true; } int target = getBranchTarget(); if (getBranchOffset() > 0) { if ((seen == GOTO) || (seen == GOTO_W)) { gotoBranchPCs.set(target); } else if ((catchPCs == null) || !catchPCs.get(getNextPC())) { ifBlocks.addLast(new IfBlock(getNextPC(), target)); } } else { removeLoopBlocks(target); } } else if (isReturn(seen)) { if ((activeUnconditional != null) && !gotoBranchPCs.get(activeUnconditional.getEnd())) { int ifSize = activeUnconditional.getEnd() - activeUnconditional.getStart(); int elseSize = getPC() - activeUnconditional.getEnd(); double ratio = (double) ifSize / (double) elseSize; if (ratio > lowBugRatioLimit) { bugReporter.reportBug( new BugInstance( this, BugType.BL_BURYING_LOGIC.name(), ratio > normalBugRatioLimit ? NORMAL_PRIORITY : LOW_PRIORITY) .addClass(this) .addMethod(this) .addSourceLineRange( this, activeUnconditional.getStart(), activeUnconditional.getEnd())); throw new StopOpcodeParsingException(); } } else if (!ifBlocks.isEmpty() && (getNextPC() == ifBlocks.getFirst().getEnd()) && !gotoAcrossPC(getNextPC())) { activeUnconditional = ifBlocks.getFirst(); } } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) { int[] offsets = getSwitchOffsets(); int pc = getPC(); for (int offset : offsets) { casePositions.addFirst(Integer.valueOf(pc + offset)); } } } finally { stack.sawOpcode(this, seen); } }