public Tree syntaxTree() { if (block instanceof CFG.Block) { CFG.Block syntaxCFGblock = (CFG.Block) this.block; if (block.elements().isEmpty()) { return syntaxCFGblock.terminator(); } return syntaxCFGblock.elements().get(Math.min(i, syntaxCFGblock.elements().size() - 1)); } return null; } }
@Override public String toString() { String tree = ""; if (block instanceof CFG.Block) { List<Tree> elements = ((CFG.Block) block).elements(); if (i < elements.size()) { tree = "" + elements.get(i).kind() + elements.get(i).firstToken().line(); } } return "B" + block.id() + "." + i + " " + tree; }
if (otherBlocks.isEmpty()) { CFG.Block methodExit = node.programPoint.block.successors() .stream() .map(b -> (CFG.Block) b)
if (programPosition.block.successors().isEmpty()) { endOfExecutionPath.add(node); continue; if (programPosition.i < programPosition.block.elements().size()) { executeInstruction((Instruction) programPosition.block.elements().get(programPosition.i)); } else {
if (programPosition.block.successors().isEmpty()) { endOfExecutionPath.add(node); continue; if (programPosition.i < programPosition.block.elements().size()) { executeInstruction((Instruction) programPosition.block.elements().get(programPosition.i)); } else {
if (otherBlocks.isEmpty()) { CFG.Block methodExit = node.programPoint.block.successors() .stream() .map(b -> (CFG.Block) b)
private void enqueueExceptionHandlers(Type exceptionType, ProgramState ps) { List<BytecodeCFG.Block> blocksCatchingException = programPosition.block.successors().stream() .map(b -> (BytecodeCFG.Block) b) .filter(BytecodeCFG.Block::isCatchBlock) .filter(b -> isExceptionHandledByBlock(exceptionType, b)) .collect(Collectors.toList()); if (!blocksCatchingException.isEmpty()) { blocksCatchingException.forEach(b -> enqueue(new ProgramPoint(b), ps)); if (isCatchExhaustive(exceptionType, blocksCatchingException)) { return; } } // exception was not handled or was handled only partially, enqueue exit block with exceptional SV Preconditions.checkState(ps.peekValue() instanceof SymbolicValue.ExceptionalSymbolicValue, "Exception shall be on top of the stack"); ps.storeExitValue(); enqueue(new ProgramPoint(exitBlock), ps); }
private void enqueueExceptionHandlers(Type exceptionType, ProgramState ps) { List<BytecodeCFG.Block> blocksCatchingException = programPosition.block.successors().stream() .map(b -> (BytecodeCFG.Block) b) .filter(BytecodeCFG.Block::isCatchBlock) .filter(b -> isExceptionHandledByBlock(exceptionType, b)) .collect(Collectors.toList()); if (!blocksCatchingException.isEmpty()) { blocksCatchingException.forEach(b -> enqueue(new ProgramPoint(b), ps)); if (isCatchExhaustive(exceptionType, blocksCatchingException)) { return; } } // exception was not handled or was handled only partially, enqueue exit block with exceptional SV Preconditions.checkState(ps.peekValue() instanceof SymbolicValue.ExceptionalSymbolicValue, "Exception shall be on top of the stack"); ps.storeExitValue(); enqueue(new ProgramPoint(exitBlock), ps); }
@Override public String toString() { return "B" + programPoint.block.id() + "." + programPoint.i + ": " + programState; }
private void enqueueHappyPath(ProgramPoint programPosition) { programPosition.block.successors().stream() .map(b-> (BytecodeCFG.Block)b) .filter(b -> !b.isCatchBlock()) .forEach(b -> enqueue(new ProgramPoint(b), programState)); }
private boolean isMethodInvocationNode(ExplodedGraph.Node node) { // ProgramPoint#syntaxTree will not always return the correct tree, so we need to go to ProgramPoint#block directly ProgramPoint pp = node.programPoint; if (pp.i < pp.block.elements().size()) { Tree tree = ((CFG.Block) pp.block).elements().get(pp.i); return tree.is(Tree.Kind.METHOD_INVOCATION); } return false; }
@Override public String toString() { return "B" + programPoint.block.id() + "." + programPoint.i + ": " + programState; }
private void enqueueUncheckedExceptions() { programPosition.block.successors() .stream() .map(BytecodeCFG.Block.class::cast) .filter(this::isUncheckedExceptionCatchBlock) .forEach(b -> enqueue(new ProgramPoint(b), stateWithException(programState, b))); }
/** * {@code i == blockSize} means we are pointing to terminator block, {@code i == blockSize + 1} is valid if terminator block is branching * @see ExplodedGraphWalker#execute */ private ProgramPoint(CFG.IBlock<?> block, int i) { int blockSize = block.elements().size(); Preconditions.checkState(i < blockSize + 2, "CFG Block has %s elements but PP at %s was requested", blockSize, i); this.block = block; this.i = i; this.hashcode = block.id() * 31 + i; }
public Tree syntaxTree() { if (block instanceof CFG.Block) { CFG.Block syntaxCFGblock = (CFG.Block) this.block; if (block.elements().isEmpty()) { return syntaxCFGblock.terminator(); } return syntaxCFGblock.elements().get(Math.min(i, syntaxCFGblock.elements().size() - 1)); } return null; } }
private void enqueueHappyPath(ProgramPoint programPosition) { programPosition.block.successors().stream() .map(b-> (BytecodeCFG.Block)b) .filter(b -> !b.isCatchBlock()) .forEach(b -> enqueue(new ProgramPoint(b), programState)); }
private boolean isMethodInvocationNode(ExplodedGraph.Node node) { // ProgramPoint#syntaxTree will not always return the correct tree, so we need to go to ProgramPoint#block directly ProgramPoint pp = node.programPoint; if (pp.i < pp.block.elements().size()) { Tree tree = ((CFG.Block) pp.block).elements().get(pp.i); return tree.is(Tree.Kind.METHOD_INVOCATION); } return false; }
@Override public String toString() { String tree = ""; if (block instanceof CFG.Block) { List<Tree> elements = ((CFG.Block) block).elements(); if (i < elements.size()) { tree = "" + elements.get(i).kind() + elements.get(i).firstToken().line(); } } return "B" + block.id() + "." + i + " " + tree; }