Package it.unive.lisa.symbolic.value
Class Identifier
- java.lang.Object
-
- it.unive.lisa.symbolic.SymbolicExpression
-
- it.unive.lisa.symbolic.value.ValueExpression
-
- it.unive.lisa.symbolic.value.Identifier
-
- All Implemented Interfaces:
ScopedObject<SymbolicExpression>
- Direct Known Subclasses:
HeapLocation
,MemoryPointer
,OutOfScopeIdentifier
,Variable
public abstract class Identifier extends ValueExpression
An identifier of a program variable, representing either a program variable (as an instance ofVariable
), or a resolved memory location (as an instance ofHeapLocation
).
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Identifier(Type staticType, java.lang.String name, boolean weak, Annotations annotations, CodeLocation location)
Builds the identifier.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addAnnotation(Annotation ann)
Adds an annotation to the annotations of this identifier.abstract boolean
canBeScoped()
Yieldstrue
if a call toSymbolicExpression.pushScope(ScopeToken)
on this identifier yields a newOutOfScopeIdentifier
associated with the given scope, that can then be removed bySymbolicExpression.popScope(ScopeToken)
.boolean
equals(java.lang.Object obj)
Annotations
getAnnotations()
Yields the annotations of this identifier.java.lang.String
getName()
Yields the name of this identifier.int
hashCode()
boolean
isScopedByCall()
Yieldstrue
if this is anOutOfScopeIdentifier
whose (i) scope was introduced by a call, or (ii) inner identifier is anOutOfScopeIdentifier
such thatinner.isScopedByCall()
holds.boolean
isWeak()
Yields whether or not this identifier is weak.Identifier
lub(Identifier other)
Yields the least upper bounds between two identifiers.boolean
mightNeedRewriting()
Yields whether or not this expression can be considered safe to be processed by domains that only focus onValueExpression
s, or if it might need rewriting.-
Methods inherited from class it.unive.lisa.symbolic.value.ValueExpression
removeNegations
-
Methods inherited from class it.unive.lisa.symbolic.SymbolicExpression
accept, getCodeLocation, getStaticType, popScope, pushScope, toString
-
-
-
-
Constructor Detail
-
Identifier
protected Identifier(Type staticType, java.lang.String name, boolean weak, Annotations annotations, CodeLocation location)
Builds the identifier.- Parameters:
staticType
- the static type of this expressionname
- the name of the identifierweak
- whether or not this identifier is weak, meaning that it should only receive weak assignmentsannotations
- the annotations of this identifierlocation
- the code location of the statement that has generated this identifier
-
-
Method Detail
-
getName
public java.lang.String getName()
Yields the name of this identifier.- Returns:
- the name
-
isWeak
public boolean isWeak()
Yields whether or not this identifier is weak. Weak identifiers should only receive weak assignments, that is, the value of the identifier after the assignment should be the least upper bound between its old value and the fresh value being assigned. With strong identifiers instead, the new value corresponds to the freshly provided value.- Returns:
true
if this identifier is weak,false
otherwise
-
isScopedByCall
public boolean isScopedByCall()
Yieldstrue
if this is anOutOfScopeIdentifier
whose (i) scope was introduced by a call, or (ii) inner identifier is anOutOfScopeIdentifier
such thatinner.isScopedByCall()
holds.- Returns:
true
if that condition holds
-
canBeScoped
public abstract boolean canBeScoped()
Yieldstrue
if a call toSymbolicExpression.pushScope(ScopeToken)
on this identifier yields a newOutOfScopeIdentifier
associated with the given scope, that can then be removed bySymbolicExpression.popScope(ScopeToken)
. If this method returnsfalse
, thenSymbolicExpression.pushScope(ScopeToken)
andSymbolicExpression.popScope(ScopeToken)
will always return this identifier instead.- Returns:
true
if that condition holds
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classSymbolicExpression
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classSymbolicExpression
-
getAnnotations
public Annotations getAnnotations()
Yields the annotations of this identifier.- Returns:
- the annotations of this identifier
-
addAnnotation
public void addAnnotation(Annotation ann)
Adds an annotation to the annotations of this identifier.- Parameters:
ann
- the annotation to be added
-
lub
public Identifier lub(Identifier other) throws SemanticException
Yields the least upper bounds between two identifiers.- Parameters:
other
- the other identifier- Returns:
- the least upper bounds between two identifiers.
- Throws:
SemanticException
- if this and other are not equal.
-
mightNeedRewriting
public boolean mightNeedRewriting()
Description copied from class:SymbolicExpression
Yields whether or not this expression can be considered safe to be processed by domains that only focus onValueExpression
s, or if it might need rewriting. This is a definite answer: if this method returnstrue
, than this expression is sure to not contain anything that deals with, or points to, the memory.- Specified by:
mightNeedRewriting
in classSymbolicExpression
- Returns:
- whether or not this expression might need rewriting
-
-