diff --git a/src/storage/expressions/ExprtkExpressionEvaluator.cpp b/src/storage/expressions/ExprtkExpressionEvaluator.cpp old mode 100644 new mode 100755 index 4e79a8dc0..1d225ec12 --- a/src/storage/expressions/ExprtkExpressionEvaluator.cpp +++ b/src/storage/expressions/ExprtkExpressionEvaluator.cpp @@ -23,10 +23,10 @@ namespace storm { template bool ExprtkExpressionEvaluatorBase::asBool(Expression const& expression) const { - BaseExpression const* expressionPtr = expression.getBaseExpressionPointer().get(); - auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer().get()); + std::shared_ptr expressionPtr = expression.getBaseExpressionPointer(); + auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer()); if (expressionPair == this->compiledExpressions.end()) { - CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expressionPtr); + CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expression); return compiledExpression.value() == ValueType(1); } return expressionPair->second.value() == ValueType(1); @@ -34,22 +34,22 @@ namespace storm { template int_fast64_t ExprtkExpressionEvaluatorBase::asInt(Expression const& expression) const { - BaseExpression const* expressionPtr = expression.getBaseExpressionPointer().get(); - auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer().get()); + std::shared_ptr expressionPtr = expression.getBaseExpressionPointer(); + auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer()); if (expressionPair == this->compiledExpressions.end()) { - CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expressionPtr); + CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expression); return static_cast(compiledExpression.value()); } return static_cast(expressionPair->second.value()); } template - typename ExprtkExpressionEvaluatorBase::CompiledExpressionType& ExprtkExpressionEvaluatorBase::getCompiledExpression(BaseExpression const* expression) const { - std::pair result = this->compiledExpressions.emplace(expression, CompiledExpressionType()); + typename ExprtkExpressionEvaluatorBase::CompiledExpressionType& ExprtkExpressionEvaluatorBase::getCompiledExpression(storm::expressions::Expression const& expression) const { + std::pair result = this->compiledExpressions.emplace(expression.getBaseExpressionPointer(), CompiledExpressionType()); CompiledExpressionType& compiledExpression = result.first->second; compiledExpression.register_symbol_table(symbolTable); bool parsingOk = parser.compile(ToExprtkStringVisitor().toString(expression), compiledExpression); - STORM_LOG_ASSERT(parsingOk, "Expression was not properly parsed by ExprTk: " << *expression); + STORM_LOG_ASSERT(parsingOk, "Expression was not properly parsed by ExprTk: " << expression); return compiledExpression; } @@ -73,10 +73,10 @@ namespace storm { } double ExprtkExpressionEvaluator::asRational(Expression const& expression) const { - BaseExpression const* expressionPtr = expression.getBaseExpressionPointer().get(); - auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer().get()); + std::shared_ptr expressionPtr = expression.getBaseExpressionPointer(); + auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer()); if (expressionPair == this->compiledExpressions.end()) { - CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expressionPtr); + CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expression); return static_cast(compiledExpression.value()); } return static_cast(expressionPair->second.value()); diff --git a/src/storage/expressions/ExprtkExpressionEvaluator.h b/src/storage/expressions/ExprtkExpressionEvaluator.h old mode 100644 new mode 100755 index 77fc94993..2ae6800ba --- a/src/storage/expressions/ExprtkExpressionEvaluator.h +++ b/src/storage/expressions/ExprtkExpressionEvaluator.h @@ -1,6 +1,7 @@ #ifndef STORM_STORAGE_EXPRESSIONS_EXPRTKEXPRESSIONEVALUATOR_H_ #define STORM_STORAGE_EXPRESSIONS_EXPRTKEXPRESSIONEVALUATOR_H_ +#include #include #include @@ -26,14 +27,14 @@ namespace storm { protected: typedef double ValueType; typedef exprtk::expression CompiledExpressionType; - typedef std::unordered_map CacheType; + typedef std::unordered_map, CompiledExpressionType> CacheType; /*! * Adds a compiled version of the given expression to the internal storage. * * @param expression The expression that is to be compiled. */ - CompiledExpressionType& getCompiledExpression(BaseExpression const* expression) const; + CompiledExpressionType& getCompiledExpression(storm::expressions::Expression const& expression) const; // The parser used. mutable exprtk::parser parser;