Class LocalVariable
- java.lang.Object
-
- org.checkerframework.dataflow.expression.JavaExpression
-
- org.checkerframework.dataflow.expression.LocalVariable
-
public class LocalVariable extends JavaExpression
A local variable.This class also represents a formal parameter expressed using its name. Class
FormalParameter
represents a formal parameter expressed using the "#2" notation.
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.lang.model.element.VariableElement
element
The element for this local variable.-
Fields inherited from class org.checkerframework.dataflow.expression.JavaExpression
type
-
-
Constructor Summary
Constructors Constructor Description LocalVariable(javax.lang.model.element.VariableElement element)
Creates a new LocalVariable.LocalVariable(LocalVariableNode localVar)
Creates a new LocalVariable.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,P>
Raccept(JavaExpressionVisitor<R,P> visitor, P p)
Accept method of the visitor pattern.boolean
containsOfClass(java.lang.Class<? extends JavaExpression> clazz)
boolean
containsSyntacticEqualJavaExpression(JavaExpression other)
Returns true if and only if this contains a JavaExpression that is syntactically equal toother
.boolean
equals(@Nullable java.lang.Object obj)
javax.lang.model.element.VariableElement
getElement()
Returns the element for this variable.int
hashCode()
boolean
isDeterministic(AnnotationProvider provider)
Returns true if the expression is deterministic.boolean
isUnassignableByOtherCode()
Returns true if and only if the value this expression stands for cannot be changed (with respect to ==) by a method call.boolean
isUnmodifiableByOtherCode()
Returns true if and only if the value this expression stands for cannot be changed by a method call, including changes to any of its fields.protected static boolean
sameElement(javax.lang.model.element.VariableElement element1, javax.lang.model.element.VariableElement element2)
Returns true if the two elements are the same.boolean
syntacticEquals(JavaExpression je)
Returns true if and only if the two Java expressions are syntactically identical.java.lang.String
toString()
java.lang.String
toStringDebug()
Format this verbosely, for debugging.-
Methods inherited from class org.checkerframework.dataflow.expression.JavaExpression
atConstructorInvocation, atFieldAccess, atMethodBody, atMethodInvocation, atMethodInvocation, containsModifiableAliasOf, containsUnknown, fromArrayAccess, fromNode, fromNodeFieldAccess, fromTree, fromVariableTree, getFormalParameters, getImplicitReceiver, getParametersAsLocalVariables, getPseudoReceiver, getReceiver, getType, listContainsSyntacticEqualJavaExpression, listIsDeterministic, syntacticEqualsList
-
-
-
-
Constructor Detail
-
LocalVariable
public LocalVariable(LocalVariableNode localVar)
Creates a new LocalVariable.- Parameters:
localVar
- a CFG local variable
-
LocalVariable
public LocalVariable(javax.lang.model.element.VariableElement element)
Creates a new LocalVariable.- Parameters:
element
- the element for the local variable
-
-
Method Detail
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
sameElement
protected static boolean sameElement(javax.lang.model.element.VariableElement element1, javax.lang.model.element.VariableElement element2)
Returns true if the two elements are the same.- Parameters:
element1
- the first element to compareelement2
- the second element to compare- Returns:
- true if the two elements are the same
-
getElement
public javax.lang.model.element.VariableElement getElement()
Returns the element for this variable.- Returns:
- the element for this variable
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toStringDebug
public java.lang.String toStringDebug()
Description copied from class:JavaExpression
Format this verbosely, for debugging.- Overrides:
toStringDebug
in classJavaExpression
- Returns:
- a verbose string representation of this
-
containsOfClass
public boolean containsOfClass(java.lang.Class<? extends JavaExpression> clazz)
- Specified by:
containsOfClass
in classJavaExpression
-
isDeterministic
public boolean isDeterministic(AnnotationProvider provider)
Description copied from class:JavaExpression
Returns true if the expression is deterministic.- Specified by:
isDeterministic
in classJavaExpression
- Parameters:
provider
- an annotation provider (a type factory)- Returns:
- true if this expression is deterministic
-
syntacticEquals
public boolean syntacticEquals(JavaExpression je)
Description copied from class:JavaExpression
Returns true if and only if the two Java expressions are syntactically identical.This exists for use by
JavaExpression.containsSyntacticEqualJavaExpression(org.checkerframework.dataflow.expression.JavaExpression)
.- Specified by:
syntacticEquals
in classJavaExpression
- Parameters:
je
- the other Java expression to compare to this one- Returns:
- true if and only if the two Java expressions are syntactically identical
-
containsSyntacticEqualJavaExpression
public boolean containsSyntacticEqualJavaExpression(JavaExpression other)
Description copied from class:JavaExpression
Returns true if and only if this contains a JavaExpression that is syntactically equal toother
.- Specified by:
containsSyntacticEqualJavaExpression
in classJavaExpression
- Parameters:
other
- the JavaExpression to search for- Returns:
- true if and only if this contains a JavaExpression that is syntactically equal to
other
-
isUnassignableByOtherCode
public boolean isUnassignableByOtherCode()
Description copied from class:JavaExpression
Returns true if and only if the value this expression stands for cannot be changed (with respect to ==) by a method call. This is the case for local variables, the self reference, final field accesses whose receiver isJavaExpression.isUnassignableByOtherCode()
, and operations whose operands are allJavaExpression.isUnmodifiableByOtherCode()
.- Specified by:
isUnassignableByOtherCode
in classJavaExpression
- See Also:
JavaExpression.isUnmodifiableByOtherCode()
-
isUnmodifiableByOtherCode
public boolean isUnmodifiableByOtherCode()
Description copied from class:JavaExpression
Returns true if and only if the value this expression stands for cannot be changed by a method call, including changes to any of its fields.Approximately, this returns true if the expression is
JavaExpression.isUnassignableByOtherCode()
and its type is immutable.- Specified by:
isUnmodifiableByOtherCode
in classJavaExpression
- See Also:
JavaExpression.isUnassignableByOtherCode()
-
accept
public <R,P> R accept(JavaExpressionVisitor<R,P> visitor, P p)
Description copied from class:JavaExpression
Accept method of the visitor pattern.- Specified by:
accept
in classJavaExpression
- Type Parameters:
R
- result type of the operationP
- parameter type- Parameters:
visitor
- the visitor to be applied to this JavaExpressionp
- the parameter for this operation- Returns:
- the result of visiting this
-
-