Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
FunctionCallExpression.cpp
Go to the documentation of this file.
2
5
8
9namespace storm {
10namespace expressions {
11
12FunctionCallExpression::FunctionCallExpression(ExpressionManager const& manager, Type const& type, std::string const& functionIdentifier,
13 std::vector<std::shared_ptr<BaseExpression const>> const& arguments)
14 : BaseExpression(manager, type), identifier(functionIdentifier), arguments(arguments) {
15 // Intentionally left empty
16}
17
18void FunctionCallExpression::gatherVariables(std::set<storm::expressions::Variable>& variables) const {
19 for (auto const& a : arguments) {
20 a->gatherVariables(variables);
21 }
22}
23
25 for (auto const& a : arguments) {
26 if (a->containsVariables()) {
27 return true;
28 }
29 }
30 return false;
31}
32
33std::shared_ptr<BaseExpression const> FunctionCallExpression::simplify() const {
34 std::vector<std::shared_ptr<BaseExpression const>> simplifiedArguments;
35 simplifiedArguments.reserve(arguments.size());
36 for (auto const& a : arguments) {
37 simplifiedArguments.push_back(a->simplify());
38 }
39 return std::shared_ptr<BaseExpression const>(new FunctionCallExpression(getManager(), getType(), identifier, simplifiedArguments));
40}
41
42boost::any FunctionCallExpression::accept(ExpressionVisitor& visitor, boost::any const& data) const {
43 auto janiVisitor = dynamic_cast<JaniExpressionVisitor*>(&visitor);
44 STORM_LOG_THROW(janiVisitor != nullptr, storm::exceptions::UnexpectedException, "Visitor of jani expression should be of type JaniVisitor.");
45 return janiVisitor->visit(*this, data);
46}
47
48void FunctionCallExpression::printToStream(std::ostream& stream) const {
49 stream << identifier;
50 if (getNumberOfArguments() > 0) {
51 stream << "(";
52 bool first = true;
53 for (auto const& a : arguments) {
54 if (!first) {
55 stream << ", ";
56 }
57 first = false;
58 stream << *a;
59 }
60 stream << ")";
61 }
62}
63
65 return identifier;
66}
67
69 return arguments.size();
70}
71
72std::shared_ptr<BaseExpression const> FunctionCallExpression::getArgument(uint64_t i) const {
73 STORM_LOG_THROW(i < arguments.size(), storm::exceptions::InvalidArgumentException,
74 "Tried to access the argument with index " << i << " of a function call with " << arguments.size() << " arguments.");
75 return arguments[i];
76}
77
78std::vector<std::shared_ptr<BaseExpression const>> const& FunctionCallExpression::getArguments() const {
79 return arguments;
80}
81
82} // namespace expressions
83} // namespace storm
The base class of all expression classes.
virtual void gatherVariables(std::set< storm::expressions::Variable > &variables) const =0
Retrieves the set of all variables that appear in the expression.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
Type const & getType() const
Retrieves the type of the expression.
This class is responsible for managing a set of typed variables and all expressions using these varia...
Represents an array with a given list of elements.
FunctionCallExpression(ExpressionManager const &manager, Type const &type, std::string const &functionIdentifier, std::vector< std::shared_ptr< BaseExpression const > > const &arguments)
virtual void gatherVariables(std::set< storm::expressions::Variable > &variables) const override
Retrieves the set of all variables that appear in the expression.
virtual bool containsVariables() const override
Retrieves whether the expression contains a variable.
std::vector< std::shared_ptr< BaseExpression const > > const & getArguments() const
virtual boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const override
Accepts the given visitor by calling its visit method.
std::shared_ptr< BaseExpression const > getArgument(uint64_t i) const
virtual void printToStream(std::ostream &stream) const override
Prints the expression to the given stream.
virtual std::shared_ptr< BaseExpression const > simplify() const override
Simplifies the expression according to some simple rules.
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18