public void add(IfBlock block) { if (blocks.isEmpty()) { blocks.addLast(block); return; } IfBlock lastBlock = blocks.getLast(); if (block.getStart() > lastBlock.getEnd()) { blocks.addLast(block); } else { lastBlock.getSubIfBlocks().add(block); } }
public void add(IfBlock block) { if (blocks.isEmpty()) { blocks.addLast(block); return; } IfBlock lastBlock = blocks.getLast(); if (block.getStart() > lastBlock.getEnd()) { blocks.addLast(block); } else { lastBlock.getSubIfBlocks().add(block); } }
@Nullable public IfBlock getBlockAt(int pc) { if (blocks.isEmpty()) { return null; } Iterator<IfBlock> it = blocks.iterator(); while (it.hasNext()) { IfBlock block = it.next(); if ((pc >= block.getStart()) && (pc <= block.getEnd())) { if (block.hasSubBlocks()) { IfBlock foundBlock = block.getSubIfBlocks().getBlockAt(pc); if (foundBlock != null) { return foundBlock; } } return block; } } return null; }
if ((activeUnconditional != null) && !gotoBranchPCs.get(activeUnconditional.getEnd())) { int ifSize = activeUnconditional.getEnd() - activeUnconditional.getStart(); int elseSize = (getPC() - activeUnconditional.getEnd()) + 1; // +1 for the return itself 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 { IfBlock blockAtPC = ifBlocks.getBlockAt(getPC()); if ((blockAtPC != null) && (getNextPC() == blockAtPC.getEnd()) && !gotoAcrossPC(getNextPC())) { activeUnconditional = blockAtPC;
if ((activeUnconditional != null) && !gotoBranchPCs.get(activeUnconditional.getEnd())) { int ifSize = activeUnconditional.getEnd() - activeUnconditional.getStart(); int elseSize = (getPC() - activeUnconditional.getEnd()) + 1; // +1 for the return itself 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 { IfBlock blockAtPC = ifBlocks.getBlockAt(getPC()); if ((blockAtPC != null) && (getNextPC() == blockAtPC.getEnd()) && !gotoAcrossPC(getNextPC())) { activeUnconditional = blockAtPC;
/** * counts all blocks including nested block that are closed off at the current pc * * @param pc * the current pc * @return how many blocks have ended at the pc */ public int countBlockEndsAtPC(int pc) { if (blocks.isEmpty()) { return 0; } int count = 0; Iterator<IfBlock> it = blocks.iterator(); while (it.hasNext()) { IfBlock block = it.next(); if (pc >= block.getStart()) { if (block.hasSubBlocks()) { count += block.getSubIfBlocks().countBlockEndsAtPC(pc); } } if (pc == block.getEnd()) { count++; } } return count; }
/** * counts all blocks including nested block that are closed off at the current pc * * @param pc * the current pc * @return how many blocks have ended at the pc */ public int countBlockEndsAtPC(int pc) { if (blocks.isEmpty()) { return 0; } int count = 0; Iterator<IfBlock> it = blocks.iterator(); while (it.hasNext()) { IfBlock block = it.next(); if (pc >= block.getStart()) { if (block.hasSubBlocks()) { count += block.getSubIfBlocks().countBlockEndsAtPC(pc); } } if (pc == block.getEnd()) { count++; } } return count; }
@Nullable public IfBlock getBlockAt(int pc) { if (blocks.isEmpty()) { return null; } Iterator<IfBlock> it = blocks.iterator(); while (it.hasNext()) { IfBlock block = it.next(); if ((pc >= block.getStart()) && (pc <= block.getEnd())) { if (block.hasSubBlocks()) { IfBlock foundBlock = block.getSubIfBlocks().getBlockAt(pc); if (foundBlock != null) { return foundBlock; } } return block; } } return null; }