Class CFGTranslationPhaseOne
- All Implemented Interfaces:
TreeVisitor<Node,Void>
- Direct Known Subclasses:
CFCFGBuilder.CFCFGTranslationPhaseOne
- A sequence of extended nodes.
- A set of bindings from
Labels 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
Nodes.
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).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AnnotationProviderThe annotation provider, e.g., a type factory.protected final TypeMirrorThe ArithmeticException type.protected final Set<TypeMirror> Exceptions that can be thrown by array access "a[i]".protected final TypeMirrorThe ArrayIndexOutOfBoundsException type.protected final TypeMirrorThe AssertionError type.protected final booleanTrue if assertions can be assumed to be disabled.protected final booleanTrue if assertions can be assumed to be enabled.protected final TypeMirrorThe ClassCastException type.protected final @Nullable TypeMirrorThe ClassCircularityError type.protected final @Nullable TypeMirrorThe ClassFormatError type.protected VariableTreeTheVariableTreethat indicates whether assertions are enabled or not.protected final ElementsThe javac element utilities.protected final ProcessingEnvironmentAnnotation processing environment and its associated type and tree utilities.protected final TypeMirrorThe Iterable type (erased).protected final TypeMirrorThe NegativeArraySizeException type.protected final Set<TypeMirror> Exceptions that can be thrown by array creation "new SomeType[]".protected final @Nullable TypeMirrorThe NoClassDefFoundError type.protected final TypeMirrorThe NullPointerException type.protected final @Nullable TypeMirrorThe OutOfMemoryError type.protected final TypeMirrorThe String type.protected final TreeBuilderThe tree builder.protected final TreesThe javac tree utilities.protected final TypesThe javac type utilities.protected static final AtomicLongThe UID for the next unique name.protected final Set<TypeMirror> Supertypes of all unchecked exceptions. -
Constructor Summary
ConstructorsConstructorDescriptionCFGTranslationPhaseOne(TreeBuilder treeBuilder, AnnotationProvider annotationProvider, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, ProcessingEnvironment env) Creates aCFGTranslationPhaseOne. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds the labellto the extended node that will be placed next in the sequence.protected voidaddToImplicitlyConvertedLookupMap(Tree tree, Node node) Adds a node to the lookup map for implicitly converted values.protected voidAdds a node to the lookup map for implicitly converted values.protected voidaddToLookupMap(Node node) Adds a node to the lookup map if it is not already present.protected NodeassignConvert(Node node, TypeMirror varType) Performs assignment conversion so that the node can be assigned to a variable of the given type.protected booleanReturns true if assertions should be assumed to be executed for a givenAssertTree.protected NodebinaryNumericPromotion(Node node, TypeMirror exprType) Performs binary numeric promotion on the input node to make it match the expression type.protected TypeMirrorbinaryPromotedType(TypeMirror left, TypeMirror right) Computes the type to which two numeric types must be promoted before performing a binary numeric operation on them.protected NodeIf the input node is an unboxed primitive type, inserts a call to the appropriate valueOf method; otherwise, leaves it alone.protected NodecommonConvert(Node node, TypeMirror varType, boolean contextAllowsNarrowing) Assignment conversion and method invocation conversion are almost identical, except that assignment conversion allows narrowing.protected NodeconditionalExprPromotion(Node node, TypeMirror destType) Converts an operand of a conditional expression to the type of the whole expression.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, returns a list ofNodes representing the arguments converted for a call of the method.protected NodeconvertNarrowableConstant(Node node, TypeMirror varType) Converts the given compile-time constant to the given type, which is byte, short, char, Byte, Short, or Character, as assignment conversion does (JLS 5.2).protected VariableTreecreateEnhancedForLoopArrayVariable(ExpressionTree expression, VariableElement variableElement) Returns the declaration of a new, uniquely named variable that holds the array of an enhanced for loop over an array.protected VariableTreecreateEnhancedForLoopIteratorVariable(MethodInvocationTree iteratorCall, VariableElement variableElement) Returns the declaration of a new, uniquely named variable that holds the iterator of an enhanced for loop over anIterable.protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolderExtends the list of extended nodes with a ClassName node.protected voidExtends the list of extended nodes with an extended node.protected voidextendWithNode(Node node) Extends the list of extended nodes with a node.protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolderextendWithNodeWithException(Node node, TypeMirror cause) Extends the list of extended nodes with a node, wherenodemight throw the exceptioncause.protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolderextendWithNodeWithExceptions(Node node, Set<TypeMirror> causes) Extends the list of extended nodes with a node, wherenodemight throw any of the exceptions incauses.protected VariableTreeReturns a syntheticVariableTreethat indicates whether assertions are enabled or not.protected org.checkerframework.dataflow.cfg.builder.CFGTranslationPhaseOne.AssertMethodTupleReturns the AssertMethodTuple formethod.Returns the current path for the tree currently being scanned.Returns the labelNameof the leaf in the argument path, or null if the leaf is not a labeled statement.protected TypeMirrorgetTypeMirror(Class<?> clazz) Returns the TypeMirror for the given class.voidhandleArtificialTree(Tree tree) Performs any actions required when CFG translation creates a new Tree that is not part of the original AST.protected voidinsertExtendedNodeAfter(ExtendedNode n, Node pred) Insertsnafter the nodepredin the list of extended nodes, or appendsnifpredis not present.protected <T extends Node>
TinsertNodeAfter(T node, Node pred) Insertsnodeafterpredin the list of extended nodes, or appends to the list ifpredis not present.protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolderinsertNodeWithExceptionsAfter(Node node, Set<TypeMirror> causes, Node pred) Inserts anodethat might throw the exceptions incausesafterpredin the list of extended nodes, or appends to the list ifpredis not present.protected booleanisNarrowableConstantConversion(Node node, TypeMirror varType) Returns true if the node is a compile-time constant of type byte, short, char, or int, and varType is byte, short, char, Byte, Short, or Character.protected booleanisNumericOrBoxed(TypeMirror type) Returns true if the argument type is a numeric primitive or a boxed numeric primitive and false otherwise.protected @Nullable TypeMirrormaybeGetTypeMirror(Class<?> clazz) Returns the TypeMirror for the given class, ornullif the type is not present.protected NodemethodInvocationConvert(Node node, TypeMirror formalType) Performs method invocation conversion so that the node can be passed as a formal parameter of the given type.protected Nodenarrow(Node node, TypeMirror destType) Performs narrowing conversion (JLS 5.1.3), or the widening and narrowing conversion from byte to char (JLS 5.1.4), on the input node to make it match the destination type.protected NodenarrowAndBox(Node node, TypeMirror destType) Performs narrowing conversion and optionally boxing conversion on the input node to make it match the destination type.process(CompilationUnitTree root, UnderlyingAST underlyingAST) Processes 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 NodestringConversion(Node node) Converts the input node to String type, if it isn't already.protected voidTranslates an assertion statement to the correct CFG nodes.protected AssignmentNodetranslateAssignment(Tree tree, Node target, ExpressionTree rhs) Translates an assignment.protected AssignmentNodetranslateAssignment(Tree tree, Node target, Node expression) Translates an assignment where the RHS has already been scanned.protected voidtreatMethodAsAssert(MethodInvocationTree tree, org.checkerframework.dataflow.cfg.builder.CFGTranslationPhaseOne.AssertMethodTuple assertMethodTuple, Node condition) Translates a method marked asAssertMethodinto CFG nodes corresponding to anassertstatement.protected NodeunaryNumericPromotion(Node node) Performs unary numeric promotion on the input node.protected NodeIf the input node is a boxed type, unboxes it; otherwise, leaves it alone.protected StringuniqueName(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) visitBindingPattern(BindingPatternTree bindingPatternTree, Void unused) visitBlock(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) Visits 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) visitSwitchExpression(SwitchExpressionTree switchExpressionTree, Void p) Visits a SwitchExpressionTree.visitSynchronized(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) visitYield(YieldTree yieldTree, Void p) Visits a YieldTree.protected Nodewiden(Node node, TypeMirror destType) Performs widening primitive conversion on the input node to make it match the destination type.protected Tree.KindwithoutAssignment(Tree.Kind kind) Maps an operation with assignment to the corresponding operation without assignment.Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, visitAnyPattern, visitConstantCaseLabel, visitDeconstructionPattern, visitDefaultCaseLabel, visitExports, visitIntersectionType, visitModule, visitOpens, visitPackage, visitPatternCaseLabel, visitProvides, visitRequires, visitStringTemplate, visitUses
-
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 assumeAssertionsDisabledTrue if assertions can be assumed to be disabled. -
assumeAssertionsEnabled
protected final boolean assumeAssertionsEnabledTrue if assertions can 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 ClassFormatError type. -
noClassDefFoundErrorType
The NoClassDefFoundError type. -
stringType
The String type. -
uncheckedExceptionTypes
Supertypes of all unchecked exceptions. The size is 2 and the contents areRuntimeExceptionandError. -
newArrayExceptionTypes
Exceptions that can be thrown by array creation "new SomeType[]". The size is 2 and the contents areNegativeArraySizeExceptionandOutOfMemoryError. This list comes from JLS 15.10.1 "Run-Time Evaluation of Array Creation Expressions". -
arrayAccessExceptionTypes
Exceptions that can be thrown by array access "a[i]". The size is 2 and the contents areArrayIndexOutOfBoundsExceptionandNullPointerException. -
uid
The UID for the next unique name.This is static so that names are unique across all CFGs, not just within one CFG. Therefore, a client can use the name of a temporary variable to identify it, even in a data structure that holds the temporary variables of more than one method.
-
ea
TheVariableTreethat indicates whether assertions are enabled or not.
-
-
Constructor Details
-
CFGTranslationPhaseOne
public CFGTranslationPhaseOne(TreeBuilder treeBuilder, AnnotationProvider annotationProvider, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, ProcessingEnvironment env) Creates aCFGTranslationPhaseOne.- Parameters:
treeBuilder- builder for new AST nodesannotationProvider- extracts annotations from AST nodesassumeAssertionsEnabled- true if assertions can be assumed to be enabledassumeAssertionsDisabled- true if assertions can be assumed to be disabledenv- 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
Processes 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
Performs 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:
scanin classTreeScanner<Node,Void>
-
addToLookupMap
Adds a node to the lookup map if it is not already present.- Parameters:
node- the node to add to the lookup map
-
addToImplicitlyConvertedLookupMap
Adds a node to the lookup map for implicitly converted values. The node should refer to a Tree and that Tree should already be in the lookup map for values before implicit conversion. This method is used to update the Tree-Node mapping with implicit conversion nodes.- Parameters:
node- the node to add to the lookup map
-
addToImplicitlyConvertedLookupMap
Adds a node to the lookup map for implicitly converted values. The tree argument should already be in the lookup map for values before implicit conversion. This method is used to update the Tree-Node mapping with implicit conversion nodes.- Parameters:
tree- the tree used as a key in the mapnode- the node to add to the lookup map
-
extendWithNode
Extends 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) Extends the list of extended nodes with a node, wherenodemight 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) Extends the list of extended nodes with a node, wherenodemight throw any of the exceptions incauses.- Parameters:
node- the node to addcauses- the set of exceptions that the node might throw- Returns:
- the node holder
-
extendWithClassNameNode
protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithClassNameNode(ClassNameNode node) Extends the 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
Insertsnodeafterpredin the list of extended nodes, or appends to the list ifpredis not present.- Type Parameters:
T- the type of the node- Parameters:
node- the node to addpred- the desired predecessor of node- Returns:
node
-
insertNodeWithExceptionsAfter
protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder insertNodeWithExceptionsAfter(Node node, Set<TypeMirror> causes, Node pred) Inserts anodethat might throw the exceptions incausesafterpredin the list of extended nodes, or appends to the list ifpredis not present.- Parameters:
node- the node to addcauses- the set of exceptions that the node might throwpred- the desired predecessor of node- Returns:
- the node holder
-
extendWithExtendedNode
Extends the list of extended nodes with an extended node.- Parameters:
n- the extended node
-
insertExtendedNodeAfter
Insertsnafter the nodepredin the list of extended nodes, or appendsnifpredis not present.- Parameters:
n- the extended nodepred- the desired predecessor
-
addLabelForNextNode
Adds the labellto the extended node that will be placed next in the sequence.- Parameters:
l- the label 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, inserts a call to the appropriate valueOf method; otherwise, leaves it alone.- Parameters:
node- an input node- Returns:
- a Node representing the boxed version of the input, which might simply be the input node
-
unbox
If the input node is a boxed type, unboxes it; otherwise, leaves it alone.- Parameters:
node- an input node- Returns:
- a Node representing the unboxed version of the input, which might simply be the input node
-
stringConversion
Converts 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 might be the input node
-
unaryNumericPromotion
Performs 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 int, long, float, or double; might be the input node
-
isNumericOrBoxed
Returns true if the argument type is a numeric primitive or a boxed numeric primitive and false otherwise. -
binaryPromotedType
Computes 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
Performs 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 might be the input node
-
widen
Performs 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 destType, which might be the input node
-
narrow
Performs narrowing conversion (JLS 5.1.3), or the widening and narrowing conversion from byte to char (JLS 5.1.4), on the input node to make it match the destination type. Does nothing if the conversion from the type of the node to the destination type is an identity or widening conversion.- Parameters:
node- a node producing a value of numeric primitive typedestType- the numeric primitive type to narrow the value to- Returns:
- a Node with the value narrowed to the destType, which might be the input node
-
narrowAndBox
Performs 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 might be the input node
-
isNarrowableConstantConversion
Returns true if the node is a compile-time constant of type byte, short, char, or int, and varType is byte, short, char, Byte, Short, or Character. Assignment conversion converts such a constant to the primitive type of varType, even by a narrowing conversion, before boxing it if varType is a boxed type (JLS 5.2), as inbyte b = 1;,Byte b = 'a';, andShort s = (byte) 1;.- Parameters:
node- a node whose value is being convertedvarType- the type of a variable (or general LHS) to be converted to- Returns:
- true if the node is a compile-time constant of type byte, short, char, or int, and varType is byte, short, char, Byte, Short, or Character
-
convertNarrowableConstant
Converts the given compile-time constant to the given type, which is byte, short, char, Byte, Short, or Character, as assignment conversion does (JLS 5.2). The conversion widens or narrows the constant to the primitive type of varType, then boxes it if varType is a boxed type. For example, it boxes(byte) 1byShort.valueOf()inShort s = (byte) 1;.- Parameters:
node- a node producing a compile-time constant of type byte, short, char, or intvarType- the type to convert the constant to: byte, short, char, Byte, Short, or Character- Returns:
- a Node with the value converted to varType, which might be the input node
- See Also:
-
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- if true, allow narrowing (for assignment conversion); if false, do not (for method invocation conversion)- Returns:
- a Node with the value converted to the type of the variable, which might be the input node itself
-
assignConvert
Performs assignment conversion so that the node 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 might be the input node itself
-
methodInvocationConvert
Performs 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 might 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, returns a list ofNodes representing the arguments converted for a call of the method. This method applies to both method invocations and constructor calls.For
outer.new Inner(...) {...}, the anonymous constructor's first parameter is the enclosing instanceouter, which is not amongactualExprs. This method skips that parameter and matches the remaining formal parameters withactualExprs; seeTreeUtils.parametersForArguments(javax.lang.model.element.ExecutableElement, com.sun.source.tree.Tree, java.util.List<T>).- 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 call. For an anonymous constructor with an explicit enclosing expression, its first parameter type is that of the enclosing instance.actualExprs- a List of argument expressions to a call- Returns:
- a List of
Nodes representing arguments after conversions required by a call to this method
-
getAssertMethodTuple
protected org.checkerframework.dataflow.cfg.builder.CFGTranslationPhaseOne.AssertMethodTuple getAssertMethodTuple(ExecutableElement method) Returns the AssertMethodTuple formethod. Ifmethodis not an assert method, thenCFGTranslationPhaseOne.AssertMethodTuple.NONEis returned.- Parameters:
method- a method element that might be an assert method- Returns:
- the AssertMethodTuple for
method
-
conditionalExprPromotion
Converts 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 might be the input node
-
getLabel
Returns the labelNameof the leaf in the argument path, or null if the leaf is not a labeled statement. -
visitCompilationUnit
- Specified by:
visitCompilationUnitin interfaceTreeVisitor<Node,Void> - Overrides:
visitCompilationUnitin classTreeScanner<Node,Void>
-
visitImport
- Specified by:
visitImportin interfaceTreeVisitor<Node,Void> - Overrides:
visitImportin classTreeScanner<Node,Void>
-
visitClass
- Specified by:
visitClassin interfaceTreeVisitor<Node,Void> - Overrides:
visitClassin classTreeScanner<Node,Void>
-
visitMethod
- Specified by:
visitMethodin interfaceTreeVisitor<Node,Void> - Overrides:
visitMethodin classTreeScanner<Node,Void>
-
visitVariable
- Specified by:
visitVariablein interfaceTreeVisitor<Node,Void> - Overrides:
visitVariablein classTreeScanner<Node,Void>
-
visitEmptyStatement
- Specified by:
visitEmptyStatementin interfaceTreeVisitor<Node,Void> - Overrides:
visitEmptyStatementin classTreeScanner<Node,Void>
-
visitBlock
- Specified by:
visitBlockin interfaceTreeVisitor<Node,Void> - Overrides:
visitBlockin classTreeScanner<Node,Void>
-
visitDoWhileLoop
- Specified by:
visitDoWhileLoopin interfaceTreeVisitor<Node,Void> - Overrides:
visitDoWhileLoopin classTreeScanner<Node,Void>
-
visitWhileLoop
- Specified by:
visitWhileLoopin interfaceTreeVisitor<Node,Void> - Overrides:
visitWhileLoopin classTreeScanner<Node,Void>
-
visitForLoop
- Specified by:
visitForLoopin interfaceTreeVisitor<Node,Void> - Overrides:
visitForLoopin classTreeScanner<Node,Void>
-
visitEnhancedForLoop
- Specified by:
visitEnhancedForLoopin interfaceTreeVisitor<Node,Void> - Overrides:
visitEnhancedForLoopin classTreeScanner<Node,Void>
-
createEnhancedForLoopIteratorVariable
protected VariableTree createEnhancedForLoopIteratorVariable(MethodInvocationTree iteratorCall, VariableElement variableElement) Returns the declaration of a new, uniquely named variable that holds the iterator of an enhanced for loop over anIterable.- Parameters:
iteratorCall- a call toiterator()on the iterable expression of an enhanced for loop; the call initializes the new variablevariableElement- the element of the loop variable of the enhanced for loop; the new variable has the same enclosing element- Returns:
- the declaration of the new iterator variable
-
createEnhancedForLoopArrayVariable
protected VariableTree createEnhancedForLoopArrayVariable(ExpressionTree expression, VariableElement variableElement) Returns the declaration of a new, uniquely named variable that holds the array of an enhanced for loop over an array.- Parameters:
expression- the expression, of array type, that an enhanced for loop iterates over; the expression initializes the new variablevariableElement- the element of the loop variable of the enhanced for loop; the new variable has the same enclosing element- Returns:
- the declaration of the new array variable
-
visitLabeledStatement
- Specified by:
visitLabeledStatementin interfaceTreeVisitor<Node,Void> - Overrides:
visitLabeledStatementin classTreeScanner<Node,Void>
-
visitSwitch
- Specified by:
visitSwitchin interfaceTreeVisitor<Node,Void> - Overrides:
visitSwitchin classTreeScanner<Node,Void>
-
visitSwitchExpression
Visits a SwitchExpressionTree.- Specified by:
visitSwitchExpressionin interfaceTreeVisitor<Node,Void> - Overrides:
visitSwitchExpressionin classTreeScanner<Node,Void> - Parameters:
switchExpressionTree- a SwitchExpressionTree, typed as Tree to be backward-compatiblep- parameter- Returns:
- the result of visiting the switch expression tree
-
visitCase
- Specified by:
visitCasein interfaceTreeVisitor<Node,Void> - Overrides:
visitCasein classTreeScanner<Node,Void>
-
visitSynchronized
- Specified by:
visitSynchronizedin interfaceTreeVisitor<Node,Void> - Overrides:
visitSynchronizedin classTreeScanner<Node,Void>
-
visitTry
- Specified by:
visitTryin interfaceTreeVisitor<Node,Void> - Overrides:
visitTryin classTreeScanner<Node,Void>
-
visitCatch
- Specified by:
visitCatchin interfaceTreeVisitor<Node,Void> - Overrides:
visitCatchin classTreeScanner<Node,Void>
-
visitConditionalExpression
- Specified by:
visitConditionalExpressionin interfaceTreeVisitor<Node,Void> - Overrides:
visitConditionalExpressionin classTreeScanner<Node,Void>
-
visitIf
- Specified by:
visitIfin interfaceTreeVisitor<Node,Void> - Overrides:
visitIfin classTreeScanner<Node,Void>
-
visitExpressionStatement
- Specified by:
visitExpressionStatementin interfaceTreeVisitor<Node,Void> - Overrides:
visitExpressionStatementin classTreeScanner<Node,Void>
-
visitBreak
- Specified by:
visitBreakin interfaceTreeVisitor<Node,Void> - Overrides:
visitBreakin classTreeScanner<Node,Void>
-
visitContinue
- Specified by:
visitContinuein interfaceTreeVisitor<Node,Void> - Overrides:
visitContinuein classTreeScanner<Node,Void>
-
visitReturn
- Specified by:
visitReturnin interfaceTreeVisitor<Node,Void> - Overrides:
visitReturnin classTreeScanner<Node,Void>
-
visitThrow
- Specified by:
visitThrowin interfaceTreeVisitor<Node,Void> - Overrides:
visitThrowin classTreeScanner<Node,Void>
-
visitAssert
- Specified by:
visitAssertin interfaceTreeVisitor<Node,Void> - Overrides:
visitAssertin classTreeScanner<Node,Void>
-
assumeAssertionsEnabledFor
Returns true if assertions should be assumed to be executed for a givenAssertTree. False by default.- Parameters:
tree- an assert tree- Returns:
- true if assertions should be assumed to be executed for
tree
-
getAssertionsEnabledVariable
Returns a syntheticVariableTreethat indicates whether assertions are enabled or not.- Returns:
- a synthetic variable 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 (or the assertion contains "@AssumeAssertion" in its message).- Parameters:
tree- an assertion
-
treatMethodAsAssert
protected void treatMethodAsAssert(MethodInvocationTree tree, org.checkerframework.dataflow.cfg.builder.CFGTranslationPhaseOne.AssertMethodTuple assertMethodTuple, Node condition) Translates a method marked asAssertMethodinto CFG nodes corresponding to anassertstatement.- Parameters:
tree- the method invocation tree for a method marked asAssertMethodassertMethodTuple- the assert method tuple for the methodcondition- the boolean expression node for the argument that the method tests
-
visitMethodInvocation
- Specified by:
visitMethodInvocationin interfaceTreeVisitor<Node,Void> - Overrides:
visitMethodInvocationin classTreeScanner<Node,Void>
-
visitNewClass
- Specified by:
visitNewClassin interfaceTreeVisitor<Node,Void> - Overrides:
visitNewClassin classTreeScanner<Node,Void>
-
visitNewArray
- Specified by:
visitNewArrayin interfaceTreeVisitor<Node,Void> - Overrides:
visitNewArrayin classTreeScanner<Node,Void>
-
visitLambdaExpression
- Specified by:
visitLambdaExpressionin interfaceTreeVisitor<Node,Void> - Overrides:
visitLambdaExpressionin classTreeScanner<Node,Void>
-
visitParenthesized
- Specified by:
visitParenthesizedin interfaceTreeVisitor<Node,Void> - Overrides:
visitParenthesizedin classTreeScanner<Node,Void>
-
visitAssignment
- Specified by:
visitAssignmentin interfaceTreeVisitor<Node,Void> - Overrides:
visitAssignmentin classTreeScanner<Node,Void>
-
translateAssignment
Translates an assignment.- Parameters:
tree- the assignment or variable declaration treetarget- the target of the assignmentrhs- the right-hand side of the assignment, which is not yet scanned- Returns:
- the node for the assignment
-
translateAssignment
Translates an assignment where the RHS has already been scanned.- Parameters:
tree- the assignment or variable declaration treetarget- the target of the assignmentexpression- the node for the right-hand side, which has already been scanned- Returns:
- the node for the assignment
-
withoutAssignment
Maps 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:
visitCompoundAssignmentin interfaceTreeVisitor<Node,Void> - Overrides:
visitCompoundAssignmentin classTreeScanner<Node,Void>
-
visitUnary
- Specified by:
visitUnaryin interfaceTreeVisitor<Node,Void> - Overrides:
visitUnaryin classTreeScanner<Node,Void>
-
visitBinary
- Specified by:
visitBinaryin interfaceTreeVisitor<Node,Void> - Overrides:
visitBinaryin classTreeScanner<Node,Void>
-
visitTypeCast
- Specified by:
visitTypeCastin interfaceTreeVisitor<Node,Void> - Overrides:
visitTypeCastin classTreeScanner<Node,Void>
-
visitInstanceOf
- Specified by:
visitInstanceOfin interfaceTreeVisitor<Node,Void> - Overrides:
visitInstanceOfin classTreeScanner<Node,Void>
-
visitBindingPattern
- Specified by:
visitBindingPatternin interfaceTreeVisitor<Node,Void> - Overrides:
visitBindingPatternin classTreeScanner<Node,Void>
-
visitDeconstructionPattern21
Visits 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
-
visitArrayAccess
- Specified by:
visitArrayAccessin interfaceTreeVisitor<Node,Void> - Overrides:
visitArrayAccessin classTreeScanner<Node,Void>
-
visitMemberSelect
- Specified by:
visitMemberSelectin interfaceTreeVisitor<Node,Void> - Overrides:
visitMemberSelectin classTreeScanner<Node,Void>
-
visitMemberReference
- Specified by:
visitMemberReferencein interfaceTreeVisitor<Node,Void> - Overrides:
visitMemberReferencein classTreeScanner<Node,Void>
-
visitIdentifier
- Specified by:
visitIdentifierin interfaceTreeVisitor<Node,Void> - Overrides:
visitIdentifierin classTreeScanner<Node,Void>
-
visitLiteral
- Specified by:
visitLiteralin interfaceTreeVisitor<Node,Void> - Overrides:
visitLiteralin classTreeScanner<Node,Void>
-
visitPrimitiveType
- Specified by:
visitPrimitiveTypein interfaceTreeVisitor<Node,Void> - Overrides:
visitPrimitiveTypein classTreeScanner<Node,Void>
-
visitArrayType
- Specified by:
visitArrayTypein interfaceTreeVisitor<Node,Void> - Overrides:
visitArrayTypein classTreeScanner<Node,Void>
-
visitParameterizedType
- Specified by:
visitParameterizedTypein interfaceTreeVisitor<Node,Void> - Overrides:
visitParameterizedTypein classTreeScanner<Node,Void>
-
visitUnionType
- Specified by:
visitUnionTypein interfaceTreeVisitor<Node,Void> - Overrides:
visitUnionTypein classTreeScanner<Node,Void>
-
visitTypeParameter
- Specified by:
visitTypeParameterin interfaceTreeVisitor<Node,Void> - Overrides:
visitTypeParameterin classTreeScanner<Node,Void>
-
visitWildcard
- Specified by:
visitWildcardin interfaceTreeVisitor<Node,Void> - Overrides:
visitWildcardin classTreeScanner<Node,Void>
-
visitModifiers
- Specified by:
visitModifiersin interfaceTreeVisitor<Node,Void> - Overrides:
visitModifiersin classTreeScanner<Node,Void>
-
visitAnnotation
- Specified by:
visitAnnotationin interfaceTreeVisitor<Node,Void> - Overrides:
visitAnnotationin classTreeScanner<Node,Void>
-
visitAnnotatedType
- Specified by:
visitAnnotatedTypein interfaceTreeVisitor<Node,Void> - Overrides:
visitAnnotatedTypein classTreeScanner<Node,Void>
-
visitOther
- Specified by:
visitOtherin interfaceTreeVisitor<Node,Void> - Overrides:
visitOtherin classTreeScanner<Node,Void>
-
visitErroneous
- Specified by:
visitErroneousin interfaceTreeVisitor<Node,Void> - Overrides:
visitErroneousin 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, ornullif 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
nullif the type is not present
-
visitYield
Visits a YieldTree.- Specified by:
visitYieldin interfaceTreeVisitor<Node,Void> - Overrides:
visitYieldin classTreeScanner<Node,Void> - Parameters:
yieldTree- a YieldTree, typed as Tree to be backward-compatiblep- parameter- Returns:
- the result of visiting the yield tree
-