public class ControlFlowGraph extends Object implements org.plumelib.util.UniqueId
The graph is represented by the successors (methods SingleSuccessorBlock.getSuccessor()
,
ConditionalBlock.getThenSuccessor()
, ConditionalBlock.getElseSuccessor()
, ExceptionBlock.getExceptionalSuccessors()
, RegularBlock.getRegularSuccessor()
) and
predecessors (method Block.getPredecessors()
) of the entry and exit blocks.
Modifier and Type | Field and Description |
---|---|
protected IdentityHashMap<Tree,Set<Node>> |
convertedTreeLookup
|
protected List<ClassTree> |
declaredClasses
Class declarations that have been encountered when building the control-flow graph for a
method.
|
protected List<LambdaExpressionTree> |
declaredLambdas
Lambdas encountered when building the control-flow graph for a method, variable initializer, or
initializer.
|
protected SpecialBlock |
entryBlock
The entry block of the control flow graph.
|
protected SpecialBlock |
exceptionalExitBlock
The exceptional exit block of the control flow graph.
|
protected IdentityHashMap<UnaryTree,BinaryTree> |
postfixNodeLookup
Map from postfix increment or decrement trees that are AST
UnaryTree s to the synthetic
tree that is v + 1 or v - 1 . |
protected SpecialBlock |
regularExitBlock
The regular exit block of the control flow graph.
|
protected List<ReturnNode> |
returnNodes
All return nodes (if any) encountered.
|
protected IdentityHashMap<Tree,Set<Node>> |
treeLookup
|
UnderlyingAST |
underlyingAST
The AST this CFG corresponds to.
|
Constructor and Description |
---|
ControlFlowGraph(SpecialBlock entryBlock,
SpecialBlockImpl regularExitBlock,
SpecialBlockImpl exceptionalExitBlock,
UnderlyingAST underlyingAST,
IdentityHashMap<Tree,Set<Node>> treeLookup,
IdentityHashMap<Tree,Set<Node>> convertedTreeLookup,
IdentityHashMap<UnaryTree,BinaryTree> postfixNodeLookup,
List<ReturnNode> returnNodes,
List<ClassTree> declaredClasses,
List<LambdaExpressionTree> declaredLambdas) |
Modifier and Type | Method and Description |
---|---|
Set<Block> |
getAllBlocks()
Returns the set of all basic blocks in this control flow graph.
|
List<Node> |
getAllNodes()
Returns all nodes in this control flow graph.
|
@Nullable ClassTree |
getContainingClass(Tree t)
|
@Nullable MethodTree |
getContainingMethod(Tree t)
|
List<ClassTree> |
getDeclaredClasses() |
List<LambdaExpressionTree> |
getDeclaredLambdas() |
List<Block> |
getDepthFirstOrderedBlocks()
Returns all basic blocks in this control flow graph, in reversed depth-first postorder.
|
SpecialBlock |
getEntryBlock()
Returns the entry block of the control flow graph.
|
SpecialBlock |
getExceptionalExitBlock() |
@Nullable Set<Node> |
getNodesCorrespondingToTree(Tree t)
|
UnmodifiableIdentityHashMap<UnaryTree,BinaryTree> |
getPostfixNodeLookup()
Returns an unmodifiable view of the lookup-map of the binary tree for a postfix expression.
|
SpecialBlock |
getRegularExitBlock() |
List<ReturnNode> |
getReturnNodes() |
UnmodifiableIdentityHashMap<Tree,Set<Node>> |
getTreeLookup()
Returns an unmodifiable view of the tree-lookup map.
|
long |
getUid() |
UnderlyingAST |
getUnderlyingAST()
Returns the AST this CFG corresponds to.
|
String |
toString() |
String |
toStringDebug()
Returns a verbose string representation of this, useful for debugging.
|
protected final SpecialBlock entryBlock
protected final SpecialBlock regularExitBlock
protected final SpecialBlock exceptionalExitBlock
public final UnderlyingAST underlyingAST
protected final IdentityHashMap<Tree,Set<Node>> treeLookup
Tree
s to sets of Node
s.
treeLookup
, while the
Node for the post-conversion value is stored in convertedTreeLookup
.
treeLookup
and convertedTreeLookup
) do
not appear in getAllNodes()
because their blocks are not reachable in the control flow
graph. Dataflow will not compute abstract values for these nodes.protected final IdentityHashMap<Tree,Set<Node>> convertedTreeLookup
protected final IdentityHashMap<UnaryTree,BinaryTree> postfixNodeLookup
UnaryTree
s to the synthetic
tree that is v + 1
or v - 1
.protected final List<ReturnNode> returnNodes
protected final List<ClassTree> declaredClasses
protected final List<LambdaExpressionTree> declaredLambdas
public ControlFlowGraph(SpecialBlock entryBlock, SpecialBlockImpl regularExitBlock, SpecialBlockImpl exceptionalExitBlock, UnderlyingAST underlyingAST, IdentityHashMap<Tree,Set<Node>> treeLookup, IdentityHashMap<Tree,Set<Node>> convertedTreeLookup, IdentityHashMap<UnaryTree,BinaryTree> postfixNodeLookup, List<ReturnNode> returnNodes, List<ClassTree> declaredClasses, List<LambdaExpressionTree> declaredLambdas)
public long getUid(@UnknownInitialization ControlFlowGraph this)
getUid
in interface org.plumelib.util.UniqueId
public SpecialBlock getEntryBlock()
public List<ReturnNode> getReturnNodes()
public SpecialBlock getRegularExitBlock()
public SpecialBlock getExceptionalExitBlock()
public UnderlyingAST getUnderlyingAST()
public Set<Block> getAllBlocks(@UnknownInitialization(value=ControlFlowGraph.class) ControlFlowGraph this)
public List<Node> getAllNodes(@UnknownInitialization(value=ControlFlowGraph.class) ControlFlowGraph this)
public List<Block> getDepthFirstOrderedBlocks()
public UnmodifiableIdentityHashMap<Tree,Set<Node>> getTreeLookup()
getNodesCorrespondingToTree(com.sun.source.tree.Tree)
uses that field.public UnmodifiableIdentityHashMap<UnaryTree,BinaryTree> getPostfixNodeLookup()
public @Nullable MethodTree getContainingMethod(Tree t)
public List<LambdaExpressionTree> getDeclaredLambdas()
public String toStringDebug()