Class CFGTranslationPhaseOne
- All Implemented Interfaces:
TreeVisitor<Node,
Void>
- Direct Known Subclasses:
CFCFGBuilder.CFCFGTranslationPhaseOne
- A sequence of extended nodes.
- A set of bindings from
Label
s to positions in the node sequence. - A set of leader nodes that give rise to basic blocks in phase two.
- A mapping from AST tree nodes to
Node
s.
The return type of this scanner is Node
. For expressions, the corresponding node is
returned to allow linking between different nodes.
However, for statements there is usually no single Node
that is created, and thus null
is returned.
Every visit*
method is assumed to add at least one extended node to the list of nodes
(which might only be a jump).
The entry point to process a single body (e.g., method, lambda, top-level block) is process(TreePath, UnderlyingAST)
.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Holds the elements of anAssertMethod
annotation. -
Field Summary
Modifier and TypeFieldDescriptionprotected final AnnotationProvider
The annotation provider, e.g., a type factory.protected final TypeMirror
The ArithmeticException type.protected final TypeMirror
The ArrayIndexOutOfBoundsException type.protected final TypeMirror
The AssertionError type.protected final boolean
Can assertions be assumed to be disabled?protected final boolean
Can assertions be assumed to be enabled?protected final TypeMirror
The ClassCastException type .protected final @Nullable TypeMirror
The ClassCircularityError type.protected final @Nullable TypeMirror
The ClassFormatErrorType type.protected VariableTree
TheVariableTree
that indicates whether assertions are enabled or not.protected final Elements
The javac element utilities.protected final ProcessingEnvironment
Annotation processing environment and its associated type and tree utilities.protected final TypeMirror
The Iterable type (erased).protected final TypeMirror
The NegativeArraySizeException type.protected final Set<TypeMirror>
Exceptions that can be thrown by array creation "new SomeType[]".protected final @Nullable TypeMirror
The NoClassDefFoundError type.protected final TypeMirror
The NullPointerException type .protected final @Nullable TypeMirror
The OutOfMemoryError type.protected final TypeMirror
The String type.protected final TypeMirror
The Throwable type.protected final TreeBuilder
The tree builder.protected final Trees
The javac tree utilities.protected final Types
The javac type utilities.protected long
The UID for the next unique name.protected final Set<TypeMirror>
Supertypes of all unchecked exceptions. -
Constructor Summary
ConstructorDescriptionCFGTranslationPhaseOne
(TreeBuilder treeBuilder, AnnotationProvider annotationProvider, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, ProcessingEnvironment env) CreatesCFGTranslationPhaseOne
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Add the labell
to the extended node that will be placed next in the sequence.protected void
addToConvertedLookupMap
(Tree tree, Node node) Add a node in the post-conversion lookup map.protected void
addToConvertedLookupMap
(Node node) Add a node in the post-conversion lookup map.protected void
addToLookupMap
(Node node) Add a node to the lookup map if it not already present.protected Node
assignConvert
(Node node, TypeMirror varType) Perform assignment conversion so that it can be assigned to a variable of the given type.protected boolean
Should assertions be assumed to be executed for a givenAssertTree
? False by default.protected Node
binaryNumericPromotion
(Node node, TypeMirror exprType) Perform binary numeric promotion on the input node to make it match the expression type.protected TypeMirror
binaryPromotedType
(TypeMirror left, TypeMirror right) Compute the type to which two numeric types must be promoted before performing a binary numeric operation on them.protected Node
If the input node is an unboxed primitive type, insert a call to the appropriate valueOf method, otherwise leave it alone.protected Node
commonConvert
(Node node, TypeMirror varType, boolean contextAllowsNarrowing) Assignment conversion and method invocation conversion are almost identical, except that assignment conversion allows narrowing.protected Node
conditionalExprPromotion
(Node node, TypeMirror destType) Convert an operand of a conditional expression to the type of the whole expression.protected boolean
conversionRequiresNarrowing
(TypeMirror varType, Node node) Return whether a conversion from the type of the node to varType requires narrowing.convertCallArguments
(ExpressionTree tree, ExecutableElement method, ExecutableType methodType, List<? extends ExpressionTree> actualExprs) Given a method element, its type at the call site, and a list of argument expressions, return a list ofNode
s representing the arguments converted for a call of the method.protected VariableTree
createEnhancedForLoopArrayVariable
(ExpressionTree expression, VariableElement variableElement) protected VariableTree
createEnhancedForLoopIteratorVariable
(MethodInvocationTree iteratorCall, VariableElement variableElement) protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder
Extend a list of extended nodes with a ClassName node.protected void
Extend the list of extended nodes with an extended node.protected void
extendWithNode
(Node node) Extend the list of extended nodes with a node.protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder
extendWithNodeWithException
(Node node, TypeMirror cause) Extend the list of extended nodes with a node, wherenode
might throw the exceptioncause
.protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder
extendWithNodeWithExceptions
(Node node, Set<TypeMirror> causes) Extend the list of extended nodes with a node, wherenode
might throw any of the exceptions incauses
.protected VariableTree
Get a syntheticVariableTree
that indicates whether assertions are enabled or not.protected CFGTranslationPhaseOne.AssertMethodTuple
Returns the AssertMethodTuple formethod
.Returns the current path for the tree currently being scanned.Returns the labelName
of the leaf in the argument path, or null if the leaf is not a labeled statement.protected TypeMirror
getTypeMirror
(Class<?> clazz) Returns the TypeMirror for the given class.void
handleArtificialTree
(Tree tree) Perform any actions required when CFG translation creates a new Tree that is not part of the original AST.protected void
insertExtendedNodeAfter
(ExtendedNode n, Node pred) Insertn
after the nodepred
in the list of extended nodes, or appendn
ifpred
is not present.protected <T extends Node>
TinsertNodeAfter
(T node, Node pred) Insertnode
afterpred
in the list of extended nodes, or append to the list ifpred
is not present.protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder
insertNodeWithExceptionsAfter
(Node node, Set<TypeMirror> causes, Node pred) Insert anode
that might throw the exceptions incauses
afterpred
in the list of extended nodes, or append to the list ifpred
is not present.protected boolean
isNumericOrBoxed
(TypeMirror type) Returns true if the argument type is a numeric primitive or a boxed numeric primitive and false otherwise.protected @Nullable TypeMirror
maybeGetTypeMirror
(Class<?> clazz) Returns the TypeMirror for the given class, ornull
if the type is not present.protected Node
methodInvocationConvert
(Node node, TypeMirror formalType) Perform method invocation conversion so that the node can be passed as a formal parameter of the given type.protected Node
narrow
(Node node, TypeMirror destType) Perform narrowing conversion on the input node to make it match the destination type.protected Node
narrowAndBox
(Node node, TypeMirror destType) Perform narrowing conversion and optionally boxing conversion on the input node to make it match the destination type.process
(CompilationUnitTree root, UnderlyingAST underlyingAST) Process a single body withinroot
.process
(TreePath bodyPath, UnderlyingAST underlyingAST) Performs the actual work of phase one: processing a single body (of a method, lambda, top-level block, etc.).protected Node
stringConversion
(Node node) Convert the input node to String type, if it isn't already.protected void
Translates an assertion statement to the correct CFG nodes.protected AssignmentNode
translateAssignment
(Tree tree, Node target, ExpressionTree rhs) Translate an assignment.protected AssignmentNode
translateAssignment
(Tree tree, Node target, Node expression) Translate an assignment where the RHS has already been scanned.protected void
treatMethodAsAssert
(MethodInvocationTree tree, CFGTranslationPhaseOne.AssertMethodTuple assertMethodTuple, Node condition) Translates a method marked asAssertMethod
into CFG nodes corresponding to anassert
statement.protected Node
unaryNumericPromotion
(Node node) Perform unary numeric promotion on the input node.protected Node
If the input node is a boxed type, unbox it, otherwise leave it alone.protected String
uniqueName
(String prefix) Returns a unique name starting withprefix
.visitAnnotatedType
(AnnotatedTypeTree tree, Void p) visitAnnotation
(AnnotationTree tree, Void p) visitArrayAccess
(ArrayAccessTree tree, Void p) visitArrayType
(ArrayTypeTree tree, Void p) visitAssert
(AssertTree tree, Void p) visitAssignment
(AssignmentTree tree, Void p) visitBinary
(BinaryTree tree, Void p) visitBindingPattern17
(Tree bindingPatternTree, Void p) Visit a BindingPatternTreevisitBlock
(BlockTree tree, Void p) visitBreak
(BreakTree tree, Void p) visitCatch
(CatchTree tree, Void p) visitClass
(ClassTree tree, Void p) visitCompilationUnit
(CompilationUnitTree tree, Void p) visitContinue
(ContinueTree tree, Void p) visitDeconstructionPattern21
(Tree deconstructionPatternTree, Void p) Visit a DeconstructionPatternTree.visitDoWhileLoop
(DoWhileLoopTree tree, Void p) visitEmptyStatement
(EmptyStatementTree tree, Void p) visitEnhancedForLoop
(EnhancedForLoopTree tree, Void p) visitErroneous
(ErroneousTree tree, Void p) visitForLoop
(ForLoopTree tree, Void p) visitIdentifier
(IdentifierTree tree, Void p) visitImport
(ImportTree tree, Void p) visitInstanceOf
(InstanceOfTree tree, Void p) visitLiteral
(LiteralTree tree, Void p) visitMemberReference
(MemberReferenceTree tree, Void p) visitMemberSelect
(MemberSelectTree tree, Void p) visitMethod
(MethodTree tree, Void p) visitModifiers
(ModifiersTree tree, Void p) visitNewArray
(NewArrayTree tree, Void p) visitNewClass
(NewClassTree tree, Void p) visitOther
(Tree tree, Void p) visitParenthesized
(ParenthesizedTree tree, Void p) visitPrimitiveType
(PrimitiveTypeTree tree, Void p) visitReturn
(ReturnTree tree, Void p) visitSwitch
(SwitchTree tree, Void p) visitSwitchExpression17
(Tree switchExpressionTree, Void p) Visit a SwitchExpressionTreevisitSynchronized
(SynchronizedTree tree, Void p) visitThrow
(ThrowTree tree, Void p) visitTypeCast
(TypeCastTree tree, Void p) visitTypeParameter
(TypeParameterTree tree, Void p) visitUnary
(UnaryTree tree, Void p) visitUnionType
(UnionTypeTree tree, Void p) visitVariable
(VariableTree tree, Void p) visitWhileLoop
(WhileLoopTree tree, Void p) visitWildcard
(WildcardTree tree, Void p) visitYield17
(Tree yieldTree, Void p) Visit a SwitchExpressionTree.protected Node
widen
(Node node, TypeMirror destType) Perform widening primitive conversion on the input node to make it match the destination type.protected Tree.Kind
withoutAssignment
(Tree.Kind kind) Map an operation with assignment to the corresponding operation without assignment.Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, visitBindingPattern, visitDefaultCaseLabel, visitExports, visitGuardedPattern, visitIntersectionType, visitModule, visitOpens, visitPackage, visitParenthesizedPattern, visitProvides, visitRequires, visitSwitchExpression, visitUses, visitYield
-
Field Details
-
env
Annotation processing environment and its associated type and tree utilities. -
elements
The javac element utilities. -
types
The javac type utilities. -
trees
The javac tree utilities. -
treeBuilder
The tree builder. -
annotationProvider
The annotation provider, e.g., a type factory. -
assumeAssertionsDisabled
protected final boolean assumeAssertionsDisabledCan assertions be assumed to be disabled? -
assumeAssertionsEnabled
protected final boolean assumeAssertionsEnabledCan assertions be assumed to be enabled? -
arithmeticExceptionType
The ArithmeticException type. -
arrayIndexOutOfBoundsExceptionType
The ArrayIndexOutOfBoundsException type. -
assertionErrorType
The AssertionError type. -
classCastExceptionType
The ClassCastException type . -
iterableType
The Iterable type (erased). -
negativeArraySizeExceptionType
The NegativeArraySizeException type. -
nullPointerExceptionType
The NullPointerException type . -
outOfMemoryErrorType
The OutOfMemoryError type. -
classCircularityErrorType
The ClassCircularityError type. -
classFormatErrorType
The ClassFormatErrorType type. -
noClassDefFoundErrorType
The NoClassDefFoundError type. -
stringType
The String type. -
throwableType
The Throwable type. -
uncheckedExceptionTypes
Supertypes of all unchecked exceptions. The size is 2 and the contents areRuntimeException
andError
. -
newArrayExceptionTypes
Exceptions that can be thrown by array creation "new SomeType[]". The size is 2 and the contents areNegativeArraySizeException
andOutOfMemoryError
. This list comes from JLS 15.10.1 "Run-Time Evaluation of Array Creation Expressions". -
uid
protected long uidThe UID for the next unique name. -
ea
TheVariableTree
that indicates whether assertions are enabled or not.
-
-
Constructor Details
-
CFGTranslationPhaseOne
public CFGTranslationPhaseOne(TreeBuilder treeBuilder, AnnotationProvider annotationProvider, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, ProcessingEnvironment env) CreatesCFGTranslationPhaseOne
.- Parameters:
treeBuilder
- builder for new AST nodesannotationProvider
- extracts annotations from AST nodesassumeAssertionsDisabled
- can assertions be assumed to be disabled?assumeAssertionsEnabled
- can assertions be assumed to be enabled?env
- annotation processing environment containing type utilities
-
-
Method Details
-
process
Performs the actual work of phase one: processing a single body (of a method, lambda, top-level block, etc.).- Parameters:
bodyPath
- path to the body of the underlying AST's methodunderlyingAST
- the AST for which the CFG is to be built- Returns:
- the result of phase one
-
process
Process a single body withinroot
. This method does not process the entire given CompilationUnitTree. Rather, it processes one body (of a method/lambda/etc.) within it, which corresponds tounderlyingAST
.- Parameters:
root
- the compilation unitunderlyingAST
- the AST corresponding to the body to process- Returns:
- a PhaseOneResult
-
handleArtificialTree
Perform any actions required when CFG translation creates a new Tree that is not part of the original AST.- Parameters:
tree
- the newly created Tree
-
getCurrentPath
Returns the current path for the tree currently being scanned.- Returns:
- the current path
-
scan
- Overrides:
scan
in classTreeScanner<Node,
Void>
-
visitYield17
Visit a SwitchExpressionTree.- Parameters:
yieldTree
- a YieldTree, typed as Tree to be backward-compatiblep
- parameter- Returns:
- the result of visiting the switch expression tree
-
visitSwitchExpression17
Visit a SwitchExpressionTree- Parameters:
switchExpressionTree
- a SwitchExpressionTree, typed as Tree to be backward-compatiblep
- parameter- Returns:
- the result of visiting the switch expression tree
-
visitBindingPattern17
Visit a BindingPatternTree- Parameters:
bindingPatternTree
- a BindingPatternTree, typed as Tree to be backward-compatiblep
- parameter- Returns:
- the result of visiting the binding pattern tree
-
visitDeconstructionPattern21
Visit a DeconstructionPatternTree.- Parameters:
deconstructionPatternTree
- a DeconstructionPatternTree, typed as Tree so the Checker Framework compiles under JDK 20 and earlierp
- an unused parameter- Returns:
- the result of visiting the tree
-
addToLookupMap
Add a node to the lookup map if it not already present.- Parameters:
node
- the node to add to the lookup map
-
addToConvertedLookupMap
Add a node in the post-conversion lookup map. The node should refer to a Tree and that Tree should already be in the pre-conversion lookup map. This method is used to update the Tree-Node mapping with conversion nodes.- Parameters:
node
- the node to add to the lookup map
-
addToConvertedLookupMap
Add a node in the post-conversion lookup map. The tree argument should already be in the pre-conversion lookup map. This method is used to update the Tree-Node mapping with conversion nodes.- Parameters:
tree
- the tree used as a key in the mapnode
- the node to add to the lookup map
-
extendWithNode
Extend the list of extended nodes with a node.- Parameters:
node
- the node to add
-
extendWithNodeWithException
protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithNodeWithException(Node node, TypeMirror cause) Extend the list of extended nodes with a node, wherenode
might throw the exceptioncause
.- Parameters:
node
- the node to addcause
- an exception that the node might throw- Returns:
- the node holder
-
extendWithNodeWithExceptions
protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithNodeWithExceptions(Node node, Set<TypeMirror> causes) Extend the list of extended nodes with a node, wherenode
might throw any of the exceptions incauses
.- Parameters:
node
- the node to addcauses
- set of exceptions that the node might throw- Returns:
- the node holder
-
extendWithClassNameNode
protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithClassNameNode(ClassNameNode node) Extend a list of extended nodes with a ClassName node.Evaluating a class literal kicks off class loading (JLS 15.8.2) which can fail and throw one of the specified subclasses of a LinkageError or an OutOfMemoryError (JLS 12.2.1).
- Parameters:
node
- the ClassName node to add- Returns:
- the node holder
-
insertNodeAfter
Insertnode
afterpred
in the list of extended nodes, or append to the list ifpred
is not present.- Parameters:
node
- the node to addpred
- the desired predecessor of node- Returns:
- the node holder
-
insertNodeWithExceptionsAfter
protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder insertNodeWithExceptionsAfter(Node node, Set<TypeMirror> causes, Node pred) Insert anode
that might throw the exceptions incauses
afterpred
in the list of extended nodes, or append to the list ifpred
is not present.- Parameters:
node
- the node to addcauses
- set of exceptions that the node might throwpred
- the desired predecessor of node- Returns:
- the node holder
-
extendWithExtendedNode
Extend the list of extended nodes with an extended node.- Parameters:
n
- the extended node
-
insertExtendedNodeAfter
Insertn
after the nodepred
in the list of extended nodes, or appendn
ifpred
is not present.- Parameters:
n
- the extended nodepred
- the desired predecessor
-
addLabelForNextNode
Add the labell
to the extended node that will be placed next in the sequence.- Parameters:
l
- the node to add to the forthcoming extended node
-
uniqueName
Returns a unique name starting withprefix
.- Parameters:
prefix
- the prefix of the unique name- Returns:
- a unique name starting with
prefix
-
box
If the input node is an unboxed primitive type, insert a call to the appropriate valueOf method, otherwise leave it alone.- Parameters:
node
- in input node- Returns:
- a Node representing the boxed version of the input, which may simply be the input node
-
unbox
If the input node is a boxed type, unbox it, otherwise leave it alone.- Parameters:
node
- in input node- Returns:
- a Node representing the unboxed version of the input, which may simply be the input node
-
stringConversion
Convert the input node to String type, if it isn't already.- Parameters:
node
- an input node- Returns:
- a Node with the value promoted to String, which may be the input node
-
unaryNumericPromotion
Perform unary numeric promotion on the input node.- Parameters:
node
- a node producing a value of numeric primitive or boxed type- Returns:
- a Node with the value promoted to the int, long, float, or double; may return be the input node
-
isNumericOrBoxed
Returns true if the argument type is a numeric primitive or a boxed numeric primitive and false otherwise. -
binaryPromotedType
Compute the type to which two numeric types must be promoted before performing a binary numeric operation on them. The input types must both be numeric and the output type is primitive.- Parameters:
left
- the type of the left operandright
- the type of the right operand- Returns:
- a TypeMirror representing the binary numeric promoted type
-
binaryNumericPromotion
Perform binary numeric promotion on the input node to make it match the expression type.- Parameters:
node
- a node producing a value of numeric primitive or boxed typeexprType
- the type to promote the value to- Returns:
- a Node with the value promoted to the exprType, which may be the input node
-
widen
Perform widening primitive conversion on the input node to make it match the destination type.- Parameters:
node
- a node producing a value of numeric primitive typedestType
- the type to widen the value to- Returns:
- a Node with the value widened to the exprType, which may be the input node
-
narrow
Perform narrowing conversion on the input node to make it match the destination type.- Parameters:
node
- a node producing a value of numeric primitive typedestType
- the type to narrow the value to- Returns:
- a Node with the value narrowed to the exprType, which may be the input node
-
narrowAndBox
Perform narrowing conversion and optionally boxing conversion on the input node to make it match the destination type.- Parameters:
node
- a node producing a value of numeric primitive typedestType
- the type to narrow the value to (possibly boxed)- Returns:
- a Node with the value narrowed and boxed to the destType, which may be the input node
-
conversionRequiresNarrowing
Return whether a conversion from the type of the node to varType requires narrowing.- Parameters:
varType
- the type of a variable (or general LHS) to be converted tonode
- a node whose value is being converted- Returns:
- whether this conversion requires narrowing to succeed
-
commonConvert
Assignment conversion and method invocation conversion are almost identical, except that assignment conversion allows narrowing. We factor out the common logic here.- Parameters:
node
- a Node producing a valuevarType
- the type of a variablecontextAllowsNarrowing
- whether to allow narrowing (for assignment conversion) or not (for method invocation conversion)- Returns:
- a Node with the value converted to the type of the variable, which may be the input node itself
-
assignConvert
Perform assignment conversion so that it can be assigned to a variable of the given type.- Parameters:
node
- a Node producing a valuevarType
- the type of a variable- Returns:
- a Node with the value converted to the type of the variable, which may be the input node itself
-
methodInvocationConvert
Perform method invocation conversion so that the node can be passed as a formal parameter of the given type.- Parameters:
node
- a Node producing a valueformalType
- the type of a formal parameter- Returns:
- a Node with the value converted to the type of the formal, which may be the input node itself
-
convertCallArguments
protected List<Node> convertCallArguments(ExpressionTree tree, ExecutableElement method, ExecutableType methodType, List<? extends ExpressionTree> actualExprs) Given a method element, its type at the call site, and a list of argument expressions, return a list ofNode
s representing the arguments converted for a call of the method. This method applies to both method invocations and constructor calls.- Parameters:
tree
- the invocation tree for the callmethod
- an ExecutableElement representing a method to be calledmethodType
- an ExecutableType representing the type of the method call; the type must be viewpoint-adapted to the callactualExprs
- a List of argument expressions to a call- Returns:
- a List of
Node
s representing arguments after conversions required by a call to this method
-
getAssertMethodTuple
Returns the AssertMethodTuple formethod
. Ifmethod
is not an assert method, thenCFGTranslationPhaseOne.AssertMethodTuple.NONE
is returned.- Parameters:
method
- a method element that might be an assert method- Returns:
- the AssertMethodTuple for
method
-
conditionalExprPromotion
Convert an operand of a conditional expression to the type of the whole expression.- Parameters:
node
- a node occurring as the second or third operand of a conditional expressiondestType
- the type to promote the value to- Returns:
- a Node with the value promoted to the destType, which may be the input node
-
getLabel
Returns the labelName
of the leaf in the argument path, or null if the leaf is not a labeled statement. -
visitAnnotatedType
- Specified by:
visitAnnotatedType
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitAnnotatedType
in classTreeScanner<Node,
Void>
-
visitAnnotation
- Specified by:
visitAnnotation
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitAnnotation
in classTreeScanner<Node,
Void>
-
visitMethodInvocation
- Specified by:
visitMethodInvocation
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitMethodInvocation
in classTreeScanner<Node,
Void>
-
visitAssert
- Specified by:
visitAssert
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitAssert
in classTreeScanner<Node,
Void>
-
assumeAssertionsEnabledFor
Should assertions be assumed to be executed for a givenAssertTree
? False by default. -
getAssertionsEnabledVariable
Get a syntheticVariableTree
that indicates whether assertions are enabled or not. -
translateAssertWithAssertionsEnabled
Translates an assertion statement to the correct CFG nodes. The translation assumes that assertions are enabled. -
treatMethodAsAssert
protected void treatMethodAsAssert(MethodInvocationTree tree, CFGTranslationPhaseOne.AssertMethodTuple assertMethodTuple, Node condition) Translates a method marked asAssertMethod
into CFG nodes corresponding to anassert
statement.- Parameters:
tree
- the method invocation tree for a method marked asAssertMethod
assertMethodTuple
- the assert method tuple for the methodcondition
- the boolean expression node for the argument that the method tests
-
visitAssignment
- Specified by:
visitAssignment
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitAssignment
in classTreeScanner<Node,
Void>
-
translateAssignment
Translate an assignment. -
translateAssignment
Translate an assignment where the RHS has already been scanned. -
withoutAssignment
Map an operation with assignment to the corresponding operation without assignment.- Parameters:
kind
- a Tree.Kind representing an operation with assignment- Returns:
- the Tree.Kind for the same operation without assignment
-
visitCompoundAssignment
- Specified by:
visitCompoundAssignment
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitCompoundAssignment
in classTreeScanner<Node,
Void>
-
visitBinary
- Specified by:
visitBinary
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitBinary
in classTreeScanner<Node,
Void>
-
visitBlock
- Specified by:
visitBlock
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitBlock
in classTreeScanner<Node,
Void>
-
visitBreak
- Specified by:
visitBreak
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitBreak
in classTreeScanner<Node,
Void>
-
visitSwitch
- Specified by:
visitSwitch
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitSwitch
in classTreeScanner<Node,
Void>
-
visitCase
- Specified by:
visitCase
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitCase
in classTreeScanner<Node,
Void>
-
visitCatch
- Specified by:
visitCatch
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitCatch
in classTreeScanner<Node,
Void>
-
visitClass
- Specified by:
visitClass
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitClass
in classTreeScanner<Node,
Void>
-
visitConditionalExpression
- Specified by:
visitConditionalExpression
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitConditionalExpression
in classTreeScanner<Node,
Void>
-
visitContinue
- Specified by:
visitContinue
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitContinue
in classTreeScanner<Node,
Void>
-
visitDoWhileLoop
- Specified by:
visitDoWhileLoop
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitDoWhileLoop
in classTreeScanner<Node,
Void>
-
visitErroneous
- Specified by:
visitErroneous
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitErroneous
in classTreeScanner<Node,
Void>
-
visitExpressionStatement
- Specified by:
visitExpressionStatement
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitExpressionStatement
in classTreeScanner<Node,
Void>
-
visitEnhancedForLoop
- Specified by:
visitEnhancedForLoop
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitEnhancedForLoop
in classTreeScanner<Node,
Void>
-
createEnhancedForLoopIteratorVariable
protected VariableTree createEnhancedForLoopIteratorVariable(MethodInvocationTree iteratorCall, VariableElement variableElement) -
createEnhancedForLoopArrayVariable
protected VariableTree createEnhancedForLoopArrayVariable(ExpressionTree expression, VariableElement variableElement) -
visitForLoop
- Specified by:
visitForLoop
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitForLoop
in classTreeScanner<Node,
Void>
-
visitIdentifier
- Specified by:
visitIdentifier
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitIdentifier
in classTreeScanner<Node,
Void>
-
visitIf
- Specified by:
visitIf
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitIf
in classTreeScanner<Node,
Void>
-
visitImport
- Specified by:
visitImport
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitImport
in classTreeScanner<Node,
Void>
-
visitArrayAccess
- Specified by:
visitArrayAccess
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitArrayAccess
in classTreeScanner<Node,
Void>
-
visitLabeledStatement
- Specified by:
visitLabeledStatement
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitLabeledStatement
in classTreeScanner<Node,
Void>
-
visitLiteral
- Specified by:
visitLiteral
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitLiteral
in classTreeScanner<Node,
Void>
-
visitMethod
- Specified by:
visitMethod
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitMethod
in classTreeScanner<Node,
Void>
-
visitModifiers
- Specified by:
visitModifiers
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitModifiers
in classTreeScanner<Node,
Void>
-
visitNewArray
- Specified by:
visitNewArray
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitNewArray
in classTreeScanner<Node,
Void>
-
visitNewClass
- Specified by:
visitNewClass
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitNewClass
in classTreeScanner<Node,
Void>
-
visitParenthesized
- Specified by:
visitParenthesized
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitParenthesized
in classTreeScanner<Node,
Void>
-
visitReturn
- Specified by:
visitReturn
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitReturn
in classTreeScanner<Node,
Void>
-
visitMemberSelect
- Specified by:
visitMemberSelect
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitMemberSelect
in classTreeScanner<Node,
Void>
-
visitEmptyStatement
- Specified by:
visitEmptyStatement
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitEmptyStatement
in classTreeScanner<Node,
Void>
-
visitSynchronized
- Specified by:
visitSynchronized
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitSynchronized
in classTreeScanner<Node,
Void>
-
visitThrow
- Specified by:
visitThrow
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitThrow
in classTreeScanner<Node,
Void>
-
visitCompilationUnit
- Specified by:
visitCompilationUnit
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitCompilationUnit
in classTreeScanner<Node,
Void>
-
visitTry
- Specified by:
visitTry
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitTry
in classTreeScanner<Node,
Void>
-
visitParameterizedType
- Specified by:
visitParameterizedType
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitParameterizedType
in classTreeScanner<Node,
Void>
-
visitUnionType
- Specified by:
visitUnionType
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitUnionType
in classTreeScanner<Node,
Void>
-
visitArrayType
- Specified by:
visitArrayType
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitArrayType
in classTreeScanner<Node,
Void>
-
visitTypeCast
- Specified by:
visitTypeCast
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitTypeCast
in classTreeScanner<Node,
Void>
-
visitPrimitiveType
- Specified by:
visitPrimitiveType
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitPrimitiveType
in classTreeScanner<Node,
Void>
-
visitTypeParameter
- Specified by:
visitTypeParameter
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitTypeParameter
in classTreeScanner<Node,
Void>
-
visitInstanceOf
- Specified by:
visitInstanceOf
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitInstanceOf
in classTreeScanner<Node,
Void>
-
visitUnary
- Specified by:
visitUnary
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitUnary
in classTreeScanner<Node,
Void>
-
visitVariable
- Specified by:
visitVariable
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitVariable
in classTreeScanner<Node,
Void>
-
visitWhileLoop
- Specified by:
visitWhileLoop
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitWhileLoop
in classTreeScanner<Node,
Void>
-
visitLambdaExpression
- Specified by:
visitLambdaExpression
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitLambdaExpression
in classTreeScanner<Node,
Void>
-
visitMemberReference
- Specified by:
visitMemberReference
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitMemberReference
in classTreeScanner<Node,
Void>
-
visitWildcard
- Specified by:
visitWildcard
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitWildcard
in classTreeScanner<Node,
Void>
-
visitOther
- Specified by:
visitOther
in interfaceTreeVisitor<Node,
Void> - Overrides:
visitOther
in classTreeScanner<Node,
Void>
-
getTypeMirror
Returns the TypeMirror for the given class.- Parameters:
clazz
- a class- Returns:
- the TypeMirror for the class
-
maybeGetTypeMirror
Returns the TypeMirror for the given class, ornull
if the type is not present.This can be used to handle system types that are not present. For example, in Java code that is translated to JavaScript using j2cl, the custom bootclasspath contains APIs that are emulated in JavaScript, so some types such as OutOfMemoryError are deliberately not present.
- Parameters:
clazz
- a class, which must have a canonical name- Returns:
- the TypeMirror for the class, or
null
if the type is not present
-