/** * Does this block throw an unhandled exception? */ public boolean isUnhandledExceptionBlock(BasicBlock block) { return unhandledExceptionBlockSet.get(block.getLabel()); }
/** * Indicate that the method returns at the end of the given block. * * @param block * the returning block */ public void setReturnBlock(BasicBlock block) { returnBlockSet.set(block.getLabel()); }
/** * Indicate that an unhandled exception may be thrown by the given * block. * * @param block * the block throwing an unhandled exception */ public void setUnhandledExceptionBlock(BasicBlock block) { unhandledExceptionBlockSet.set(block.getLabel()); }
/** * Get the basic block's integer label. * * @deprecated call getLabel() instead * @return the BasicBlock's integer label */ @Deprecated public int getId() { return getLabel(); }
/** * Indicate that System.exit() is called at the end of the given block. * * @param block * the exiting block */ public void setExitBlock(BasicBlock block) { exitBlockSet.set(block.getLabel()); }
/** * Is System.exit() called at the end of this block? */ public boolean isExitBlock(BasicBlock block) { return exitBlockSet.get(block.getLabel()); }
/** * Does the method return at the end of this block? */ public boolean isReturnBlock(BasicBlock block) { return returnBlockSet.get(block.getLabel()); }
@Override public String toString() { return "block " + String.valueOf(getLabel()); }
/** * @return a compact string of the form "bb:xx", where "bb" is the basic * block number and "xx" is the bytecode offset */ public String toCompactString() { return basicBlock.getLabel() + ":" + handle.getPosition(); } }
@Override public String toString() { return handle.toString() + " in basic block " + basicBlock.getLabel(); }
/** * Look up a BasicBlock by its unique label. * * @param blockLabel * the label of a BasicBlock * @return the BasicBlock with the given label, or null if there is no such * BasicBlock */ public BasicBlock lookupBlockByLabel(int blockLabel) { for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock basicBlock = i.next(); if (basicBlock.getLabel() == blockLabel) { return basicBlock; } } return null; }
/** * Get Collection of basic blocks whose IDs are specified by given BitSet. * * @param labelSet * BitSet of block labels * @return a Collection containing the blocks whose IDs are given */ public Collection<BasicBlock> getBlocks(BitSet labelSet) { LinkedList<BasicBlock> result = new LinkedList<>(); for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock block = i.next(); if (labelSet.get(block.getLabel())) { result.add(block); } } return result; }
@Override public void transfer(BasicBlock basicBlock, @CheckForNull InstructionHandle end, BitSet start, BitSet result) throws DataflowAnalysisException { // Start with intersection of dominators of predecessors copy(start, result); if (!isTop(result)) { // Every block dominates itself result.set(basicBlock.getLabel()); } }
@Override public int hashCode() { return System.identityHashCode(method) ^ getBasicBlock().getLabel() ^ System.identityHashCode(location.getHandle()); }
private void endTransfer(BasicBlock basicBlock, @CheckForNull InstructionHandle end, StateSet result) { // Append this block id to the Paths of all States for (Iterator<State> i = result.stateIterator(); i.hasNext();) { State state = i.next(); state.getPath().append(basicBlock.getLabel()); } }
public void checkIntegrity() { // Ensure that basic blocks have only consecutive instructions for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock basicBlock = i.next(); InstructionHandle prev = null; for (Iterator<InstructionHandle> j = basicBlock.instructionIterator(); j.hasNext();) { InstructionHandle handle = j.next(); if (prev != null && prev.getNext() != handle) { throw new IllegalStateException("Non-consecutive instructions in block " + basicBlock.getLabel() + ": prev=" + prev + ", handle=" + handle); } prev = handle; } } }
@Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append("[basicBlock="); buf.append(getBasicBlock().getLabel()); if (next != null) { buf.append(", next=" + next); } else if (getBasicBlock().isExceptionThrower()) { buf.append(", check for" + getBasicBlock().getExceptionThrower()); } else { buf.append(", end"); } buf.append(']'); return buf.toString(); } }