Package it.unive.lisa.symbolic.value
Class BinaryExpression
- java.lang.Object
-
- it.unive.lisa.symbolic.SymbolicExpression
-
- it.unive.lisa.symbolic.value.ValueExpression
-
- it.unive.lisa.symbolic.value.BinaryExpression
-
- All Implemented Interfaces:
ScopedObject<SymbolicExpression>
public class BinaryExpression extends ValueExpression
A bynary expression that applies aBinaryOperator
to twoSymbolicExpression
s.
-
-
Constructor Summary
Constructors Constructor Description BinaryExpression(Type staticType, SymbolicExpression left, SymbolicExpression right, BinaryOperator operator, CodeLocation location)
Builds the binary expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
accept(ExpressionVisitor<T> visitor, java.lang.Object... params)
Accepts anExpressionVisitor
, visiting this expression recursively.boolean
equals(java.lang.Object obj)
SymbolicExpression
getLeft()
Yields the left-hand side operand of this expression.BinaryOperator
getOperator()
Yields the operator that is applied togetLeft()
andgetRight()
.SymbolicExpression
getRight()
Yields the right-hand side operand of this expression.int
hashCode()
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.SymbolicExpression
popScope(ScopeToken token)
Pops the scope identified by the given token from the expression.SymbolicExpression
pushScope(ScopeToken token)
Pushes a new scope, identified by the give token, in the expression.java.lang.String
toString()
-
Methods inherited from class it.unive.lisa.symbolic.value.ValueExpression
removeNegations
-
Methods inherited from class it.unive.lisa.symbolic.SymbolicExpression
getCodeLocation, getStaticType
-
-
-
-
Constructor Detail
-
BinaryExpression
public BinaryExpression(Type staticType, SymbolicExpression left, SymbolicExpression right, BinaryOperator operator, CodeLocation location)
Builds the binary expression.- Parameters:
staticType
- the static type of this expressionleft
- the left-hand side operand of this expressionright
- the right-hand side operand of this expressionoperator
- the operator to applylocation
- the code location of the statement that has generated this expression
-
-
Method Detail
-
getLeft
public SymbolicExpression getLeft()
Yields the left-hand side operand of this expression.- Returns:
- the left operand
-
getRight
public SymbolicExpression getRight()
Yields the right-hand side operand of this expression.- Returns:
- the right operand
-
getOperator
public BinaryOperator getOperator()
Yields the operator that is applied togetLeft()
andgetRight()
.- Returns:
- the operator to apply
-
pushScope
public SymbolicExpression pushScope(ScopeToken token) throws SemanticException
Description copied from class:SymbolicExpression
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>
- Specified by:
pushScope
in classSymbolicExpression
- 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 SymbolicExpression popScope(ScopeToken token) throws SemanticException
Description copied from class:SymbolicExpression
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>
- Specified by:
popScope
in classSymbolicExpression
- 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
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classSymbolicExpression
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classSymbolicExpression
-
toString
public java.lang.String toString()
- Specified by:
toString
in classSymbolicExpression
-
accept
public <T> T accept(ExpressionVisitor<T> visitor, java.lang.Object... params) throws SemanticException
Description copied from class:SymbolicExpression
Accepts anExpressionVisitor
, visiting this expression recursively.- Specified by:
accept
in classSymbolicExpression
- 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
-
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
-
-