diff --git a/src/storm/storage/expressions/ToRationalNumberVisitor.cpp b/src/storm/storage/expressions/ToRationalNumberVisitor.cpp index 26ad15b5a..c8931c7f3 100644 --- a/src/storm/storage/expressions/ToRationalNumberVisitor.cpp +++ b/src/storm/storage/expressions/ToRationalNumberVisitor.cpp @@ -7,6 +7,11 @@ namespace storm { namespace expressions { + template + ToRationalNumberVisitor::ToRationalNumberVisitor() : ExpressionVisitor() { + // Intentionally left empty. + } + template ToRationalNumberVisitor::ToRationalNumberVisitor(ExpressionEvaluatorBase const& evaluator) : ExpressionVisitor(), evaluator(evaluator) { // Intentionally left empty. @@ -19,7 +24,13 @@ namespace storm { template boost::any ToRationalNumberVisitor::visit(IfThenElseExpression const& expression, boost::any const& data) { - bool conditionValue = evaluator.asBool(expression.getCondition()); + bool conditionValue; + if (evaluator) { + conditionValue = evaluator->asBool(expression.getCondition()); + } else { + // no evaluator, fall back to evaluateBool + conditionValue = expression.getCondition()->evaluateAsBool(); + } if (conditionValue) { return expression.getThenExpression()->accept(*this, data); } else { diff --git a/src/storm/storage/expressions/ToRationalNumberVisitor.h b/src/storm/storage/expressions/ToRationalNumberVisitor.h index 89cb9f81f..55576e5ad 100644 --- a/src/storm/storage/expressions/ToRationalNumberVisitor.h +++ b/src/storm/storage/expressions/ToRationalNumberVisitor.h @@ -16,7 +16,8 @@ namespace storm { template class ToRationalNumberVisitor : public ExpressionVisitor { public: - ToRationalNumberVisitor(ExpressionEvaluatorBase const& evaluator); + ToRationalNumberVisitor(); + ToRationalNumberVisitor(ExpressionEvaluatorBase const& evaluator); RationalNumberType toRationalNumber(Expression const& expression); @@ -36,8 +37,8 @@ namespace storm { private: std::unordered_map valueMapping; - // A reference to an expression evaluator (mainly for resolving the boolean condition in IfThenElse expressions) - ExpressionEvaluatorBase const& evaluator; + // An optional reference to an expression evaluator (mainly for resolving the boolean condition in IfThenElse expressions) + boost::optional const&> evaluator; }; } }