Package it.unive.lisa.symbolic
Class SymbolicExpression
- java.lang.Object
-
- it.unive.lisa.symbolic.SymbolicExpression
-
- Direct Known Subclasses:
HeapExpression
,ValueExpression
public abstract class SymbolicExpression extends java.lang.Object
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
getDynamicType()
Yields the dynamic type of this expression, that is, the most specific common supertype of all its runtime types (available throughgetRuntimeTypes(TypeSystem)
.java.util.Set<Type>
getRuntimeTypes(TypeSystem types)
Yields the runtime types of this expression.Type
getStaticType()
Yields the static type of this expression.int
hashCode()
boolean
hasRuntimeTypes()
Yieldstrue
if this expression's runtime types have been set (even to the empty set).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.void
setRuntimeTypes(java.util.Set<Type> types)
Sets the runtime types to the given set of types.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 expressionlocation
- the code location of the statement that has generated this expression
-
-
Method Detail
-
getStaticType
public Type getStaticType()
Yields the static type of this expression.- Returns:
- the static type
-
getRuntimeTypes
public final java.util.Set<Type> getRuntimeTypes(TypeSystem types)
Yields the runtime types of this expression. IfsetRuntimeTypes(Set)
has never been called before, this method will return all instances of the static type.- Parameters:
types
- the type system that knows about the types of the program point where this method is called. IfhasRuntimeTypes()
returnstrue
, this parameter can benull
- Returns:
- the runtime types
-
setRuntimeTypes
public void setRuntimeTypes(java.util.Set<Type> types)
Sets the runtime types to the given set of types.- Parameters:
types
- the runtime types
-
hasRuntimeTypes
public boolean hasRuntimeTypes()
Yieldstrue
if this expression's runtime types have been set (even to the empty set). If this method returnsfalse
, thengetDynamicType()
will yield the same asgetStaticType()
, andgetRuntimeTypes(TypeSystem)
returns all possible instances of the static type.- Returns:
- whether or not runtime types are set for this expression
-
getDynamicType
public final Type getDynamicType()
Yields the dynamic type of this expression, that is, the most specific common supertype of all its runtime types (available throughgetRuntimeTypes(TypeSystem)
. IfsetRuntimeTypes(Set)
has never been called before, this method will return the static type.- Returns:
- the dynamic type of this expression
-
pushScope
public abstract SymbolicExpression pushScope(ScopeToken token) throws SemanticException
Pushes a new scope, identified by the give token, in the expression. This causes allVariable
s to becomeOutOfScopeIdentifier
s associated with the given token.- 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 (i.e.Variable
s) again.- 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
-
-