6 changed files with 181 additions and 33 deletions
-
85src/storm/storage/jani/ArrayEliminator.cpp
-
4src/storm/storage/jani/TemplateEdge.cpp
-
1src/storm/storage/jani/TemplateEdge.h
-
4src/storm/storage/jani/expressions/JaniExpressionVisitor.h
-
102src/storm/storage/jani/traverser/ArrayExpressionFinder.cpp
-
18src/storm/storage/jani/traverser/ArrayExpressionFinder.h
@ -0,0 +1,102 @@ |
|||
#include "storm/storage/jani/traverser/ArrayExpressionFinder.h"
|
|||
|
|||
#include "storm/storage/jani/traverser/JaniTraverser.h"
|
|||
#include "storm/storage/jani/expressions/JaniExpressionVisitor.h"
|
|||
#include "storm/storage/jani/expressions/JaniExpressions.h"
|
|||
#include "storm/storage/jani/Model.h"
|
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
namespace detail { |
|||
class ArrayExpressionFinderExpressionVisitor : public storm::expressions::ExpressionVisitor, public storm::expressions::JaniExpressionVisitor { |
|||
public: |
|||
virtual boost::any visit(storm::expressions::IfThenElseExpression const& expression, boost::any const& data) override { |
|||
return |
|||
boost::any_cast<bool>(expression.getCondition()->accept(*this, data)) || |
|||
boost::any_cast<bool>(expression.getThenExpression()->accept(*this, data)) || |
|||
boost::any_cast<bool>(expression.getElseExpression()->accept(*this, data)); |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::BinaryBooleanFunctionExpression const& expression, boost::any const& data) override { |
|||
return |
|||
boost::any_cast<bool>(expression.getFirstOperand()->accept(*this, data)) || |
|||
boost::any_cast<bool>(expression.getSecondOperand()->accept(*this, data)); |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::BinaryNumericalFunctionExpression const& expression, boost::any const& data) override { |
|||
return |
|||
boost::any_cast<bool>(expression.getFirstOperand()->accept(*this, data)) || |
|||
boost::any_cast<bool>(expression.getSecondOperand()->accept(*this, data)); |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::BinaryRelationExpression const& expression, boost::any const& data) override { |
|||
return |
|||
boost::any_cast<bool>(expression.getFirstOperand()->accept(*this, data)) || |
|||
boost::any_cast<bool>(expression.getSecondOperand()->accept(*this, data)); |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::VariableExpression const& expression, boost::any const&) override { |
|||
return false; |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::UnaryBooleanFunctionExpression const& expression, boost::any const& data) override { |
|||
return expression.getOperand()->accept(*this, data); |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::UnaryNumericalFunctionExpression const& expression, boost::any const& data) override { |
|||
return expression.getOperand()->accept(*this, data); |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::BooleanLiteralExpression const& expression, boost::any const&) override { |
|||
return false; |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::IntegerLiteralExpression const& expression, boost::any const&) override { |
|||
return false; |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::RationalLiteralExpression const& expression, boost::any const&) override { |
|||
return false; |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::ValueArrayExpression const& expression, boost::any const& data) override { |
|||
return true; |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::ConstructorArrayExpression const& expression, boost::any const& data) override { |
|||
return true; |
|||
} |
|||
|
|||
virtual boost::any visit(storm::expressions::ArrayAccessExpression const& expression, boost::any const& data) override { |
|||
return true; |
|||
} |
|||
}; |
|||
|
|||
class ArrayExpressionFinderTraverser : public ConstJaniTraverser { |
|||
public: |
|||
virtual void traverse(Model const& model, boost::any const& data) override { |
|||
ConstJaniTraverser::traverse(model, data); |
|||
} |
|||
|
|||
virtual void traverse(storm::expressions::Expression const& expression, boost::any const& data) override { |
|||
auto& res = *boost::any_cast<bool*>(data); |
|||
res = res || containsArrayExpression(expression); |
|||
} |
|||
}; |
|||
} |
|||
|
|||
|
|||
bool containsArrayExpression(Model const& model) { |
|||
bool result = false; |
|||
detail::ArrayExpressionFinderTraverser().traverse(model, &result); |
|||
return result; |
|||
} |
|||
|
|||
bool containsArrayExpression(storm::expressions::Expression const& expression) { |
|||
detail::ArrayExpressionFinderExpressionVisitor v; |
|||
return boost::any_cast<bool>(expression.accept(v, boost::none)); |
|||
} |
|||
} |
|||
} |
|||
|
@ -0,0 +1,18 @@ |
|||
#pragma once |
|||
|
|||
|
|||
namespace storm { |
|||
|
|||
namespace expressions { |
|||
class Expression; |
|||
} |
|||
|
|||
namespace jani { |
|||
|
|||
class Model; |
|||
|
|||
bool containsArrayExpression(Model const& model); |
|||
bool containsArrayExpression(storm::expressions::Expression const& expr); |
|||
} |
|||
} |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue