Package it.unive.lisa.symbolic
Class SymbolicExpression
- java.lang.Object
-
- it.unive.lisa.symbolic.SymbolicExpression
-
- All Implemented Interfaces:
ScopedObject<SymbolicExpression>
- Direct Known Subclasses:
HeapExpression
,ValueExpression
public abstract class SymbolicExpression extends java.lang.Object implements ScopedObject<SymbolicExpression>
A symbolic expression that can be evaluated bySemanticDomain
s.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SymbolicExpression(Type staticType, CodeLocation location)
Builds the symbolic expression.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <T> T
accept(ExpressionVisitor<T> visitor, java.lang.Object... params)
Accepts anExpressionVisitor
, visiting this expression recursively.boolean
equals(java.lang.Object obj)
CodeLocation
getCodeLocation()
Yields the code location of the statement that has generated this symbolic expression.Type
getStaticType()
Yields the static type of this expression, as provided during construction.int
hashCode()
abstract 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.abstract SymbolicExpression
popScope(ScopeToken token)
Pops the scope identified by the given token from the expression.abstract SymbolicExpression
pushScope(ScopeToken token)
Pushes a new scope, identified by the give token, in the expression.abstract java.lang.String
toString()
-
-
-
Constructor Detail
-
SymbolicExpression
protected SymbolicExpression(Type staticType, CodeLocation location)
Builds the symbolic expression.- Parameters:
staticType
- the static type of this expression, determined at its constructionlocation
- the code location of the statement that has generated this expression
-
-
Method Detail
-
getStaticType
public Type getStaticType()
Yields the static type of this expression, as provided during construction. The returned type should (but might not) be a supertype of all the runtime types determined during the analysis, with the exception ofHeapLocation
s representing more memory locations.- Returns:
- the static type
-
pushScope
public abstract SymbolicExpression pushScope(ScopeToken token) throws SemanticException
Pushes a new scope, identified by the give token, in the expression. This causes allIdentifier
s whereIdentifier.canBeScoped()
holds to becomeOutOfScopeIdentifier
s associated with the given token.- Specified by:
pushScope
in interfaceScopedObject<SymbolicExpression>
- Parameters:
token
- the token identifying the scope to push- Returns:
- a copy of this expression where the local variables have gone out of scope
- Throws:
SemanticException
- if an error occurs during the computation
-
popScope
public abstract SymbolicExpression popScope(ScopeToken token) throws SemanticException
Pops the scope identified by the given token from the expression. This causes all the invisible variables (i.e.OutOfScopeIdentifier
s) mapped to the given scope to become visible (e.g.Variable
s) again. Note that invoking this method onIdentifier
s whereIdentifier.canBeScoped()
holds will returnnull
if (i) the identifier is not scoped, or (ii) the identifier is scoped by a different token.- Specified by:
popScope
in interfaceScopedObject<SymbolicExpression>
- Parameters:
token
- the token of the scope to be restored- Returns:
- a copy of this expression where the local variables associated with the given scope are visible again
- Throws:
SemanticException
- if an error occurs during the computation
-
accept
public abstract <T> T accept(ExpressionVisitor<T> visitor, java.lang.Object... params) throws SemanticException
Accepts anExpressionVisitor
, visiting this expression recursively.- Type Parameters:
T
- the type of value produced by the visiting callbacks- Parameters:
visitor
- the visitorparams
- additional optional parameters to pass to each visiting callback- Returns:
- the value produced by the visiting operation
- Throws:
SemanticException
- if an error occurs during the visiting
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getCodeLocation
public CodeLocation getCodeLocation()
Yields the code location of the statement that has generated this symbolic expression. The code location is not used for the equality between two symbolic expressions.- Returns:
- the code location of the statement that has generated this symbolic expression
-
toString
public abstract java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
mightNeedRewriting
public abstract 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. 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.- Returns:
- whether or not this expression might need rewriting
-
-