TimQu
6 years ago
19 changed files with 770 additions and 291 deletions
-
600src/storm-parsers/parser/JaniParser.cpp
-
62src/storm-parsers/parser/JaniParser.h
-
17src/storm/storage/jani/Automaton.cpp
-
20src/storm/storage/jani/Automaton.h
-
30src/storm/storage/jani/FunctionDefinition.cpp
-
61src/storm/storage/jani/FunctionDefinition.h
-
84src/storm/storage/jani/JSONExporter.cpp
-
6src/storm/storage/jani/JSONExporter.h
-
15src/storm/storage/jani/Model.cpp
-
19src/storm/storage/jani/Model.h
-
6src/storm/storage/jani/ModelFeatures.cpp
-
3src/storm/storage/jani/ModelFeatures.h
-
75src/storm/storage/jani/expressions/FunctionCallExpression.cpp
-
42src/storm/storage/jani/expressions/FunctionCallExpression.h
-
9src/storm/storage/jani/expressions/JaniExpressionSubstitutionVisitor.cpp
-
1src/storm/storage/jani/expressions/JaniExpressionSubstitutionVisitor.h
-
1src/storm/storage/jani/expressions/JaniExpressionVisitor.h
-
1src/storm/storage/jani/expressions/JaniExpressions.h
-
9src/storm/storage/jani/traverser/ArrayExpressionFinder.cpp
600
src/storm-parsers/parser/JaniParser.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,30 @@ |
|||
#include "storm/storage/jani/FunctionDefinition.h"
|
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
FunctionDefinition::FunctionDefinition(std::string const& name, storm::expressions::Type const& type, std::vector<storm::expressions::Variable> const& parameters, storm::expressions::Expression const& functionBody) : name(name), type(type), parameters(parameters), functionBody(functionBody) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
std::string const& FunctionDefinition::getName() const { |
|||
return name; |
|||
} |
|||
|
|||
storm::expressions::Type const& FunctionDefinition::getType() const { |
|||
return type; |
|||
} |
|||
|
|||
std::vector<storm::expressions::Variable> const& FunctionDefinition::getParameters() const { |
|||
return parameters; |
|||
} |
|||
|
|||
storm::expressions::Expression const& FunctionDefinition::getFunctionBody() const { |
|||
return functionBody; |
|||
} |
|||
|
|||
void FunctionDefinition::setFunctionBody(storm::expressions::Expression const& body) { |
|||
functionBody = body; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,61 @@ |
|||
#pragma once |
|||
|
|||
#include <string> |
|||
#include <vector> |
|||
|
|||
#include <boost/optional.hpp> |
|||
|
|||
#include "storm/storage/expressions/Variable.h" |
|||
#include "storm/storage/expressions/Expression.h" |
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
class FunctionDefinition { |
|||
public: |
|||
/*! |
|||
* Creates a functionDefinition. |
|||
*/ |
|||
FunctionDefinition(std::string const& name, storm::expressions::Type const& type, std::vector<storm::expressions::Variable> const& parameters, storm::expressions::Expression const& functionBody); |
|||
|
|||
/*! |
|||
* Retrieves the name of the function. |
|||
*/ |
|||
std::string const& getName() const; |
|||
|
|||
/*! |
|||
* Retrieves the type of the function. |
|||
*/ |
|||
storm::expressions::Type const& getType() const; |
|||
|
|||
/*! |
|||
* Retrieves the parameters of the function |
|||
*/ |
|||
std::vector<storm::expressions::Variable> const& getParameters() const; |
|||
|
|||
/*! |
|||
* Retrieves the expression that defines the function |
|||
*/ |
|||
storm::expressions::Expression const& getFunctionBody() const; |
|||
|
|||
/*! |
|||
* sets the expression that defines the function |
|||
*/ |
|||
void setFunctionBody(storm::expressions::Expression const& body); |
|||
|
|||
private: |
|||
// The name of the function. |
|||
std::string name; |
|||
|
|||
// The type of the function |
|||
storm::expressions::Type type; |
|||
|
|||
// The parameters |
|||
std::vector<storm::expressions::Variable> parameters; |
|||
|
|||
// The body of the function |
|||
storm::expressions::Expression functionBody; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,75 @@ |
|||
#include "storm/storage/jani/expressions/FunctionCallExpression.h"
|
|||
|
|||
#include "storm/storage/jani/expressions/JaniExpressionVisitor.h"
|
|||
#include "storm/storage/expressions/ExpressionManager.h"
|
|||
|
|||
#include "storm/exceptions/InvalidArgumentException.h"
|
|||
#include "storm/exceptions/UnexpectedException.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
|
|||
FunctionCallExpression::FunctionCallExpression(ExpressionManager const& manager, Type const& type, std::string const& functionIdentifier, std::vector<std::shared_ptr<BaseExpression const>> const& arguments) : BaseExpression(manager, type), identifier(functionIdentifier), arguments(arguments) { |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
void FunctionCallExpression::gatherVariables(std::set<storm::expressions::Variable>& variables) const { |
|||
for (auto const& a : arguments) { |
|||
a->gatherVariables(variables); |
|||
} |
|||
} |
|||
|
|||
bool FunctionCallExpression::containsVariables() const { |
|||
for (auto const& a : arguments) { |
|||
if (a->containsVariables()) { |
|||
return true; |
|||
} |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
std::shared_ptr<BaseExpression const> FunctionCallExpression::simplify() const { |
|||
std::vector<std::shared_ptr<BaseExpression const>> simplifiedArguments; |
|||
simplifiedArguments.reserve(arguments.size()); |
|||
for (auto const& a : arguments) { |
|||
simplifiedArguments.push_back(a->simplify()); |
|||
} |
|||
return std::shared_ptr<BaseExpression const>(new FunctionCallExpression(getManager(), getType(), identifier, simplifiedArguments)); |
|||
} |
|||
|
|||
boost::any FunctionCallExpression::accept(ExpressionVisitor& visitor, boost::any const& data) const { |
|||
auto janiVisitor = dynamic_cast<JaniExpressionVisitor*>(&visitor); |
|||
STORM_LOG_THROW(janiVisitor != nullptr, storm::exceptions::UnexpectedException, "Visitor of jani expression should be of type JaniVisitor."); |
|||
return janiVisitor->visit(*this, data); |
|||
} |
|||
|
|||
void FunctionCallExpression::printToStream(std::ostream& stream) const { |
|||
stream << identifier; |
|||
if (getNumberOfArguments() > 0) { |
|||
stream << "("; |
|||
bool first = true; |
|||
for (auto const& a : arguments) { |
|||
stream << *a; |
|||
if (!first) { |
|||
stream << ", "; |
|||
} |
|||
first = false; |
|||
} |
|||
stream << ")"; |
|||
} |
|||
} |
|||
|
|||
std::string const& FunctionCallExpression::getFunctionIdentifier() const { |
|||
return identifier; |
|||
} |
|||
|
|||
uint64_t FunctionCallExpression::getNumberOfArguments() const { |
|||
return arguments.size(); |
|||
} |
|||
|
|||
std::shared_ptr<BaseExpression const> FunctionCallExpression::getArgument(uint64_t i) const { |
|||
STORM_LOG_THROW(i < arguments.size(), storm::exceptions::InvalidArgumentException, "Tried to access the argument with index " << i << " of a function call with " << arguments.size() << " arguments."); |
|||
return arguments[i]; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,42 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/storage/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
/*! |
|||
* Represents an array with a given list of elements. |
|||
*/ |
|||
class FunctionCallExpression : public BaseExpression { |
|||
public: |
|||
|
|||
FunctionCallExpression(ExpressionManager const& manager, Type const& type, std::string const& functionIdentifier, std::vector<std::shared_ptr<BaseExpression const>> const& arguments); |
|||
|
|||
|
|||
// Instantiate constructors and assignments with their default implementations. |
|||
FunctionCallExpression(FunctionCallExpression const& other) = default; |
|||
FunctionCallExpression& operator=(FunctionCallExpression const& other) = delete; |
|||
FunctionCallExpression(FunctionCallExpression&&) = default; |
|||
FunctionCallExpression& operator=(FunctionCallExpression&&) = delete; |
|||
|
|||
virtual ~FunctionCallExpression() = default; |
|||
|
|||
virtual void gatherVariables(std::set<storm::expressions::Variable>& variables) const override; |
|||
virtual bool containsVariables() const override; |
|||
virtual std::shared_ptr<BaseExpression const> simplify() const override; |
|||
virtual boost::any accept(ExpressionVisitor& visitor, boost::any const& data) const override; |
|||
|
|||
std::string const& getFunctionIdentifier() const; |
|||
uint64_t getNumberOfArguments() const; |
|||
std::shared_ptr<BaseExpression const> getArgument(uint64_t i) const; |
|||
|
|||
|
|||
protected: |
|||
virtual void printToStream(std::ostream& stream) const override; |
|||
|
|||
private: |
|||
std::string identifier; |
|||
std::vector<std::shared_ptr<BaseExpression const>> arguments; |
|||
}; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue