3#include <unordered_map>
10template<
typename MapType>
15template<
typename MapType>
20template<
typename MapType>
22 std::shared_ptr<BaseExpression const> conditionExpression =
23 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getCondition()->accept(*
this, data));
24 std::shared_ptr<BaseExpression const> thenExpression =
25 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getThenExpression()->accept(*
this, data));
26 std::shared_ptr<BaseExpression const> elseExpression =
27 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getElseExpression()->accept(*
this, data));
34 return std::const_pointer_cast<BaseExpression const>(std::shared_ptr<BaseExpression>(
39template<
typename MapType>
41 std::shared_ptr<BaseExpression const> firstExpression =
42 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getFirstOperand()->accept(*
this, data));
43 std::shared_ptr<BaseExpression const> secondExpression =
44 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getSecondOperand()->accept(*
this, data));
55template<
typename MapType>
57 std::shared_ptr<BaseExpression const> firstExpression =
58 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getFirstOperand()->accept(*
this, data));
59 std::shared_ptr<BaseExpression const> secondExpression =
60 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getSecondOperand()->accept(*
this, data));
71template<
typename MapType>
73 std::shared_ptr<BaseExpression const> firstExpression =
74 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getFirstOperand()->accept(*
this, data));
75 std::shared_ptr<BaseExpression const> secondExpression =
76 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getSecondOperand()->accept(*
this, data));
82 return std::const_pointer_cast<BaseExpression const>(std::shared_ptr<BaseExpression>(
87template<
typename MapType>
90 auto const& nameExpressionPair = this->variableToExpressionMapping.find(expression.
getVariable());
91 if (nameExpressionPair != this->variableToExpressionMapping.end()) {
92 return nameExpressionPair->second.getBaseExpressionPointer();
98template<
typename MapType>
100 std::shared_ptr<BaseExpression const> operandExpression =
101 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getOperand()->accept(*
this, data));
104 if (operandExpression.get() == expression.
getOperand().get()) {
107 return std::const_pointer_cast<BaseExpression const>(std::shared_ptr<BaseExpression>(
112template<
typename MapType>
114 std::shared_ptr<BaseExpression const> operandExpression =
115 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getOperand()->accept(*
this, data));
118 if (operandExpression.get() == expression.
getOperand().get()) {
121 return std::const_pointer_cast<BaseExpression const>(std::shared_ptr<BaseExpression>(
126template<
typename MapType>
128 bool changed =
false;
129 std::vector<std::shared_ptr<BaseExpression const>> newExpressions;
130 for (uint64_t i = 0; i < expression.
getArity(); ++i) {
131 newExpressions.push_back(boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getOperand(i)->accept(*
this, data)));
132 if (!changed && newExpressions.back() != expression.
getOperand(i)) {
141 return std::const_pointer_cast<BaseExpression const>(std::shared_ptr<BaseExpression>(
146template<
typename MapType>
151template<
typename MapType>
156template<
typename MapType>
virtual boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const =0
Accepts the given visitor by calling its visit method.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
Type const & getType() const
Retrieves the type of the expression.
std::shared_ptr< BaseExpression const > getSharedPointer() const
Retrieves a shared pointer to this expression.
OperatorType getOperatorType() const
Retrieves the operator associated with the expression.
std::shared_ptr< BaseExpression const > const & getSecondOperand() const
Retrieves the second operand of the expression.
std::shared_ptr< BaseExpression const > const & getFirstOperand() const
Retrieves the first operand of the expression.
OperatorType getOperatorType() const
Retrieves the operator associated with the expression.
RelationType getRelationType() const
Retrieves the relation associated with the expression.
BaseExpression const & getBaseExpression() const
Retrieves the base expression underlying this expression object.
std::shared_ptr< BaseExpression const > getElseExpression() const
Retrieves the else expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getCondition() const
Retrieves the condition expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getThenExpression() const
Retrieves the then expression of the if-then-else expression.
The base class of all binary expressions.
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
PredicateType getPredicateType() const
Retrieves the relation associated with the expression.
virtual uint_fast64_t getArity() const override
Returns the arity of the expression.
Expression substitute(Expression const &expression)
Substitutes the identifiers in the given expression according to the previously given map and returns...
virtual boost::any visit(IfThenElseExpression const &expression, boost::any const &data) override
SubstitutionVisitor(MapType const &variableToExpressionMapping)
Creates a new substitution visitor that uses the given map to replace variables.
OperatorType getOperatorType() const
Retrieves the operator associated with this expression.
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
OperatorType getOperatorType() const
Retrieves the operator associated with this expression.
Variable const & getVariable() const
Retrieves the variable associated with this expression.