public class CFGBuilder
extends java.lang.Object
The translation of the AST to the CFG is split into three phases:
CFGBuilder.ExtendedNode
s. An extended node can either be
a Node
, or one of several meta elements such as a conditional or unconditional jump
or a node with additional information about exceptions. Some of the extended nodes contain
labels (e.g., for the jump target), and phase one additionally creates a mapping from
labels to extended nodes. Finally, the list of leaders is computed: A leader is an extended
node which will give rise to a basic block in phase two.
Modifier and Type | Class and Description |
---|---|
class |
CFGBuilder.CFGTranslationPhaseOne
Class that performs phase one of the translation process.
|
static class |
CFGBuilder.CFGTranslationPhaseThree
Class that performs phase three of the translation process.
|
class |
CFGBuilder.CFGTranslationPhaseTwo
Class that performs phase two of the translation process.
|
protected static class |
CFGBuilder.ConditionalJump
An extended node of type
CFGBuilder.ExtendedNode.ExtendedNodeType.CONDITIONAL_JUMP . |
protected static class |
CFGBuilder.ExtendedNode
An extended node can be one of several things (depending on its
type ):
NODE. |
protected static class |
CFGBuilder.Label
A label is used to refer to other extended nodes using a mapping from labels to extended
nodes.
|
protected static class |
CFGBuilder.NodeHolder
An extended node of type
NODE . |
protected static class |
CFGBuilder.NodeWithExceptionsHolder
An extended node of type
EXCEPTION_NODE . |
protected static class |
CFGBuilder.PhaseOneResult
A wrapper object to pass around the result of phase one.
|
protected static class |
CFGBuilder.TryCatchFrame
A TryCatchFrame contains an ordered list of catch labels that apply to exceptions with
specific types.
|
protected static class |
CFGBuilder.TryFinallyFrame
A TryFinallyFrame applies to exceptions of any type
|
protected static interface |
CFGBuilder.TryFrame
A TryFrame takes a thrown exception type and maps it to a set of possible control-flow
successors.
|
protected static class |
CFGBuilder.TryStack
An exception stack represents the set of all try-catch blocks in effect at a given point in a
program.
|
protected static class |
CFGBuilder.Tuple<A,B,C>
Tuple class with up to three members.
|
protected static class |
CFGBuilder.UnconditionalJump
An extended node of type
CFGBuilder.ExtendedNode.ExtendedNodeType.UNCONDITIONAL_JUMP . |
Modifier and Type | Field and Description |
---|---|
protected boolean |
assumeAssertionsDisabled
Can assertions be assumed to be disabled?
|
protected boolean |
assumeAssertionsEnabled
Can assertions be assumed to be enabled?
|
protected java.util.List<com.sun.source.tree.ClassTree> |
declaredClasses
Class declarations that have been encountered when building the control-flow graph for a
method.
|
protected java.util.List<com.sun.source.tree.LambdaExpressionTree> |
declaredLambdas
Lambdas encountered when building the control-flow graph for a method, variable initializer,
or initializer.
|
protected CFGBuilder.Label |
exceptionalExitLabel
Special label to identify the exceptional exit.
|
protected CFGBuilder.Label |
regularExitLabel
Special label to identify the regular exit.
|
Constructor and Description |
---|
CFGBuilder(boolean assumeAssertionsEnabled,
boolean assumeAssertionsDisabled) |
Modifier and Type | Method and Description |
---|---|
static ControlFlowGraph |
build(com.sun.source.tree.CompilationUnitTree root,
javax.annotation.processing.ProcessingEnvironment env,
com.sun.source.tree.MethodTree tree,
com.sun.source.tree.ClassTree classTree)
Build the control flow graph of a method.
|
static ControlFlowGraph |
build(com.sun.source.tree.CompilationUnitTree root,
javax.annotation.processing.ProcessingEnvironment env,
com.sun.source.tree.MethodTree tree,
com.sun.source.tree.ClassTree classTree,
boolean assumeAssertionsEnabled,
boolean assumeAssertionsDisabled)
Build the control flow graph of a method.
|
static ControlFlowGraph |
build(com.sun.source.tree.CompilationUnitTree root,
javax.annotation.processing.ProcessingEnvironment env,
UnderlyingAST underlyingAST)
Build the control flow graph of some code.
|
static ControlFlowGraph |
build(com.sun.source.tree.CompilationUnitTree root,
javax.annotation.processing.ProcessingEnvironment env,
UnderlyingAST underlyingAST,
boolean assumeAssertionsEnabled,
boolean assumeAssertionsDisabled)
Build the control flow graph of some code.
|
static ControlFlowGraph |
build(com.sun.source.util.TreePath bodyPath,
javax.annotation.processing.ProcessingEnvironment env,
UnderlyingAST underlyingAST,
boolean assumeAssertionsEnabled,
boolean assumeAssertionsDisabled)
Build the control flow graph of some code (method, initializer block, ...).
|
java.util.List<com.sun.source.tree.ClassTree> |
getDeclaredClasses() |
java.util.List<com.sun.source.tree.LambdaExpressionTree> |
getDeclaredLambdas() |
protected static void |
printBlocks(java.util.Set<Block> blocks)
Print a set of
Block s and the edges between them. |
ControlFlowGraph |
run(com.sun.source.tree.CompilationUnitTree root,
javax.annotation.processing.ProcessingEnvironment env,
com.sun.source.tree.MethodTree tree,
com.sun.source.tree.ClassTree classTree)
Build the control flow graph of a method.
|
ControlFlowGraph |
run(com.sun.source.tree.CompilationUnitTree root,
javax.annotation.processing.ProcessingEnvironment env,
UnderlyingAST underlyingAST)
Build the control flow graph of some code.
|
ControlFlowGraph |
run(com.sun.source.util.TreePath bodyPath,
javax.annotation.processing.ProcessingEnvironment env,
UnderlyingAST underlyingAST)
Build the control flow graph of some code (method, initializer block, ...).
|
protected final boolean assumeAssertionsDisabled
protected final boolean assumeAssertionsEnabled
protected final java.util.List<com.sun.source.tree.ClassTree> declaredClasses
protected final java.util.List<com.sun.source.tree.LambdaExpressionTree> declaredLambdas
protected final CFGBuilder.Label exceptionalExitLabel
protected final CFGBuilder.Label regularExitLabel
public CFGBuilder(boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled)
public java.util.List<com.sun.source.tree.ClassTree> getDeclaredClasses()
public java.util.List<com.sun.source.tree.LambdaExpressionTree> getDeclaredLambdas()
public static ControlFlowGraph build(com.sun.source.tree.CompilationUnitTree root, javax.annotation.processing.ProcessingEnvironment env, UnderlyingAST underlyingAST, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled)
public static ControlFlowGraph build(com.sun.source.util.TreePath bodyPath, javax.annotation.processing.ProcessingEnvironment env, UnderlyingAST underlyingAST, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled)
public static ControlFlowGraph build(com.sun.source.tree.CompilationUnitTree root, javax.annotation.processing.ProcessingEnvironment env, com.sun.source.tree.MethodTree tree, com.sun.source.tree.ClassTree classTree, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled)
public static ControlFlowGraph build(com.sun.source.tree.CompilationUnitTree root, javax.annotation.processing.ProcessingEnvironment env, UnderlyingAST underlyingAST)
public static ControlFlowGraph build(com.sun.source.tree.CompilationUnitTree root, javax.annotation.processing.ProcessingEnvironment env, com.sun.source.tree.MethodTree tree, com.sun.source.tree.ClassTree classTree)
public ControlFlowGraph run(com.sun.source.tree.CompilationUnitTree root, javax.annotation.processing.ProcessingEnvironment env, UnderlyingAST underlyingAST)
public ControlFlowGraph run(com.sun.source.util.TreePath bodyPath, javax.annotation.processing.ProcessingEnvironment env, UnderlyingAST underlyingAST)
public ControlFlowGraph run(com.sun.source.tree.CompilationUnitTree root, javax.annotation.processing.ProcessingEnvironment env, com.sun.source.tree.MethodTree tree, com.sun.source.tree.ClassTree classTree)