public interface WholeProgramInference
WholeProgramInference
is misleading.
This interface has update* methods that should be called at certain (pseudo-)assignments, and they may update the type of the LHS of the (pseudo-)assignment based on the type of the RHS. In case the element on the LHS already had an inferred type, its new type will be the LUB between the previous and new types.
Modifier and Type | Interface and Description |
---|---|
static class |
WholeProgramInference.OutputFormat
The kinds of output that whole-program inference can produce.
|
Modifier and Type | Method and Description |
---|---|
void |
updateFromFieldAssignment(Node field,
Node rhs,
ClassTree classTree,
AnnotatedTypeFactory atf)
Updates the type of
field based on an assignment of rhs to field . |
void |
updateFromLocalAssignment(LocalVariableNode lhs,
Node rhs,
ClassTree classTree,
MethodTree methodTree,
AnnotatedTypeFactory atf)
Updates the type of
lhs based on an assignment of rhs to lhs . |
void |
updateFromMethodInvocation(MethodInvocationNode methodInvNode,
Tree receiverTree,
ExecutableElement methodElt,
AnnotatedTypeFactory atf)
Updates the parameter types of the method
methodElt based on the arguments in the
method invocation methodInvNode . |
void |
updateFromObjectCreation(ObjectCreationNode objectCreationNode,
ExecutableElement constructorElt,
AnnotatedTypeFactory atf)
Updates the parameter types of the constructor
constructorElt based on the arguments
in objectCreationNode . |
void |
updateFromOverride(MethodTree methodTree,
ExecutableElement methodElt,
AnnotatedTypeMirror.AnnotatedExecutableType overriddenMethod,
AnnotatedTypeFactory atf)
Updates the parameter types (including the receiver) of the method
methodTree based
on the parameter types of the overridden method overriddenMethod . |
void |
updateFromReturn(ReturnNode retNode,
com.sun.tools.javac.code.Symbol.ClassSymbol classSymbol,
MethodTree methodTree,
Map<AnnotatedTypeMirror.AnnotatedDeclaredType,ExecutableElement> overriddenMethods,
AnnotatedTypeFactory atf)
Updates the return type of the method
methodTree based on returnedExpression . |
void |
writeResultsToFile(WholeProgramInference.OutputFormat format,
BaseTypeChecker checker)
Writes the inferred results to a file.
|
void updateFromObjectCreation(ObjectCreationNode objectCreationNode, ExecutableElement constructorElt, AnnotatedTypeFactory atf)
constructorElt
based on the arguments
in objectCreationNode
.
For each parameter in constructorElt:
objectCreationNode
- the Node that invokes the constructorconstructorElt
- the Element of the constructoratf
- the annotated type factory of a given type system, whose type hierarchy will be
used to update the constructor's parameters' typesvoid updateFromMethodInvocation(MethodInvocationNode methodInvNode, Tree receiverTree, ExecutableElement methodElt, AnnotatedTypeFactory atf)
methodElt
based on the arguments in the
method invocation methodInvNode
.
For each formal parameter in methodElt (including the receiver):
methodInvNode
- the node representing a method invocationreceiverTree
- the Tree of the class that contains the method being invokedmethodElt
- the element of the method being invokedatf
- the annotated type factory of a given type system, whose type hierarchy will be
used to update the method parameters' typesvoid updateFromOverride(MethodTree methodTree, ExecutableElement methodElt, AnnotatedTypeMirror.AnnotatedExecutableType overriddenMethod, AnnotatedTypeFactory atf)
methodTree
based
on the parameter types of the overridden method overriddenMethod
.
For each formal parameter in methodElt:
methodTree
- the tree of the method that contains the parameter(s)methodElt
- the element of the methodoverriddenMethod
- the AnnotatedExecutableType of the overridden methodatf
- the annotated type factory of a given type system, whose type hierarchy will be
used to update the parameter typevoid updateFromLocalAssignment(LocalVariableNode lhs, Node rhs, ClassTree classTree, MethodTree methodTree, AnnotatedTypeFactory atf)
lhs
based on an assignment of rhs
to lhs
.
lhs
- the node representing the local variable, such as a formal parameterrhs
- the node being assigned to the parameter in the method bodyclassTree
- the tree of the class that contains the parametermethodTree
- the tree of the method that contains the parameteratf
- the annotated type factory of a given type system, whose type hierarchy will be
used to update the parameter typevoid updateFromFieldAssignment(Node field, Node rhs, ClassTree classTree, AnnotatedTypeFactory atf)
field
based on an assignment of rhs
to field
. If
the field has a declaration annotation with the IgnoreInWholeProgramInference
meta-annotation, no type annotation will be inferred for that field.
If there is no stored entry for the field lhs, the entry will be created and its type will be the type of rhs. If there is a stored entry/type for lhs, its new type will be the LUB between the previous type and the type of rhs.
field
- the field whose type will be refined. Must be either a FieldAccessNode or a
LocalVariableNode whose element kind is FIELD.rhs
- the expression being assigned to the fieldclassTree
- the ClassTree for the enclosing class of the assignmentatf
- the annotated type factory of a given type system, whose type hierarchy will be
used to update the field's typevoid updateFromReturn(ReturnNode retNode, com.sun.tools.javac.code.Symbol.ClassSymbol classSymbol, MethodTree methodTree, Map<AnnotatedTypeMirror.AnnotatedDeclaredType,ExecutableElement> overriddenMethods, AnnotatedTypeFactory atf)
methodTree
based on returnedExpression
.
Also updates the return types of any methods that this method overrides that are available as
source code.
If there is no stored annotated return type for the method methodTree, then the type of the return expression will be added to the return type of that method. If there is a stored annotated return type for the method methodTree, its new type will be the LUB between the previous type and the type of the return expression.
retNode
- the node that contains the expression returnedclassSymbol
- the symbol of the class that contains the methodmethodTree
- the tree of the method whose return type may be updatedoverriddenMethods
- the methods that the given method return overrides, indexed by the
annotated type of the superclass in which each method is definedatf
- the annotated type factory of a given type system, whose type hierarchy will be
used to update the method's return typevoid writeResultsToFile(WholeProgramInference.OutputFormat format, BaseTypeChecker checker)
format
- the file format in which to write the resultschecker
- the checker from which this method is called, for naming stub files