Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
FunctionDefinition.cpp
Go to the documentation of this file.
3
6
7namespace storm {
8namespace jani {
9
11 std::vector<storm::expressions::Variable> const& parameters, storm::expressions::Expression const& functionBody)
12 : name(name), type(type), parameters(parameters), functionBody(functionBody) {
13 // Intentionally left empty.
14}
15
16std::string const& FunctionDefinition::getName() const {
17 return name;
18}
19
21 return type;
22}
23
24std::vector<storm::expressions::Variable> const& FunctionDefinition::getParameters() const {
25 return parameters;
26}
27
29 return functionBody;
30}
31
32storm::expressions::Expression FunctionDefinition::call(std::vector<std::shared_ptr<storm::expressions::BaseExpression const>> const& arguments) const {
33 // substitute the parameters in the function body
34 STORM_LOG_THROW(arguments.size() == parameters.size(), storm::exceptions::InvalidArgumentException,
35 "The number of arguments does not match the number of parameters.");
36 const bool substituteTranscendentalNumbers = true;
37 std::unordered_map<storm::expressions::Variable, storm::expressions::Expression> parameterSubstitution;
38 for (uint64_t i = 0; i < arguments.size(); ++i) {
39 parameterSubstitution.emplace(parameters[i], arguments[i]);
40 }
41 return substituteJaniExpression(functionBody, parameterSubstitution, substituteTranscendentalNumbers);
42}
43
44void FunctionDefinition::substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution,
45 bool const substituteTranscendentalNumbers) {
46 this->setFunctionBody(substituteJaniExpression(this->getFunctionBody(), substitution, substituteTranscendentalNumbers));
47}
48
50 functionBody = body;
51}
52} // namespace jani
53} // namespace storm
storm::expressions::Expression const & getFunctionBody() const
Retrieves the expression that defines the function.
void substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution, bool const substituteTranscendentalNumbers)
storm::expressions::Expression call(std::vector< std::shared_ptr< storm::expressions::BaseExpression const > > const &arguments) const
Calls the function with the given arguments.
std::string const & getName() const
Retrieves the name of the function.
std::vector< storm::expressions::Variable > const & getParameters() const
Retrieves the parameters of the function.
FunctionDefinition(std::string const &name, storm::expressions::Type const &type, std::vector< storm::expressions::Variable > const &parameters, storm::expressions::Expression const &functionBody)
Creates a functionDefinition.
storm::expressions::Type const & getType() const
Retrieves the type of the function.
void setFunctionBody(storm::expressions::Expression const &body)
sets the expression that defines the function
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
storm::expressions::Expression substituteJaniExpression(storm::expressions::Expression const &expression, std::map< storm::expressions::Variable, storm::expressions::Expression > const &identifierToExpressionMap, bool const substituteTranscendentalNumbers)
LabParser.cpp.
Definition cli.cpp:18