Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BinaryExpression.cpp
Go to the documentation of this file.
2
5
6namespace storm {
7namespace expressions {
8BinaryExpression::BinaryExpression(ExpressionManager const& manager, Type const& type, std::shared_ptr<BaseExpression const> const& firstOperand,
9 std::shared_ptr<BaseExpression const> const& secondOperand)
10 : BaseExpression(manager, type), firstOperand(firstOperand), secondOperand(secondOperand) {
11 // Intentionally left empty.
12}
13
15 return true;
16}
17
19 return this->getFirstOperand()->containsVariables() || this->getSecondOperand()->containsVariables();
20}
21
22void BinaryExpression::gatherVariables(std::set<storm::expressions::Variable>& variables) const {
23 this->getFirstOperand()->gatherVariables(variables);
24 this->getSecondOperand()->gatherVariables(variables);
25}
26
27std::shared_ptr<BaseExpression const> const& BinaryExpression::getFirstOperand() const {
28 return this->firstOperand;
29}
30
31std::shared_ptr<BaseExpression const> const& BinaryExpression::getSecondOperand() const {
32 return this->secondOperand;
33}
34
35uint_fast64_t BinaryExpression::getArity() const {
36 return 2;
37}
38
39std::shared_ptr<BaseExpression const> BinaryExpression::getOperand(uint_fast64_t operandIndex) const {
40 STORM_LOG_THROW(operandIndex < 2, storm::exceptions::InvalidAccessException, "Unable to access operand " << operandIndex << " in expression of arity 2.");
41 if (operandIndex == 0) {
42 return this->getFirstOperand();
43 } else {
44 return this->getSecondOperand();
45 }
46}
47} // namespace expressions
48} // namespace storm
The base class of all expression classes.
virtual bool containsVariables() const
Retrieves whether the expression contains a variable.
virtual uint_fast64_t getArity() const override
Returns the arity of the expression.
virtual bool containsVariables() const override
Retrieves whether the expression contains a variable.
std::shared_ptr< BaseExpression const > const & getSecondOperand() const
Retrieves the second operand of the expression.
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
std::shared_ptr< BaseExpression const > const & getFirstOperand() const
Retrieves the first operand of the expression.
virtual void gatherVariables(std::set< storm::expressions::Variable > &variables) const override
Retrieves the set of all variables that appear in the expression.
virtual bool isFunctionApplication() const override
Checks if the expression is a function application (of any sort).
BinaryExpression(ExpressionManager const &manager, Type const &type, std::shared_ptr< BaseExpression const > const &firstOperand, std::shared_ptr< BaseExpression const > const &secondOperand)
Constructs a binary expression with the given return type and operands.
This class is responsible for managing a set of typed variables and all expressions using these varia...
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18