Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ArrayAccessExpression.cpp
Go to the documentation of this file.
3
6namespace storm {
7namespace expressions {
8
9ArrayAccessExpression::ArrayAccessExpression(ExpressionManager const& manager, Type const& type, std::shared_ptr<BaseExpression const> const& arrayExpression,
10 std::shared_ptr<BaseExpression const> const& indexExpression)
11 : BinaryExpression(manager, type, arrayExpression, indexExpression) {
12 // Assert correct types
13 STORM_LOG_ASSERT(getFirstOperand()->getType().isArrayType(), "ArrayAccessExpression for an expression of type " << getFirstOperand()->getType() << ".");
14 STORM_LOG_ASSERT(type == getFirstOperand()->getType().getElementType(),
15 "The ArrayAccessExpression should have type " << getFirstOperand()->getType().getElementType() << " but has " << type << " instead.");
16 STORM_LOG_ASSERT(getSecondOperand()->getType().isIntegerType(), "The index expression does not have an integer type.");
17}
18
19std::shared_ptr<BaseExpression const> ArrayAccessExpression::simplify() const {
20 return std::shared_ptr<BaseExpression const>(
22}
23
24boost::any ArrayAccessExpression::accept(ExpressionVisitor& visitor, boost::any const& data) const {
25 auto janiVisitor = dynamic_cast<JaniExpressionVisitor*>(&visitor);
26 STORM_LOG_ASSERT(janiVisitor != nullptr, "Visitor of jani expression should be of type JaniVisitor.");
27 STORM_LOG_THROW(janiVisitor != nullptr, storm::exceptions::UnexpectedException, "Visitor of jani expression should be of type JaniVisitor.");
28 return janiVisitor->visit(*this, data);
29}
30
31void ArrayAccessExpression::printToStream(std::ostream& stream) const {
32 if (getFirstOperand()->isVariable()) {
33 stream << *getFirstOperand();
34 } else {
35 stream << "(" << *getFirstOperand() << ")";
36 }
37 stream << "[" << *getSecondOperand() << "]";
38}
39} // namespace expressions
40} // namespace storm
virtual void printToStream(std::ostream &stream) const override
Prints the expression to the given stream.
ArrayAccessExpression(ExpressionManager const &manager, Type const &type, std::shared_ptr< BaseExpression const > const &arrayExpression, std::shared_ptr< BaseExpression const > const &indexExpression)
virtual boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const override
Accepts the given visitor by calling its visit method.
virtual std::shared_ptr< BaseExpression const > simplify() const override
Simplifies the expression according to some simple rules.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
virtual bool isVariable() const
Retrieves whether the expression is a variable.
Type const & getType() const
Retrieves the type of the expression.
The base class of all binary expressions.
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.
This class is responsible for managing a set of typed variables and all expressions using these varia...
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18