@@ -1626,16 +1626,14 @@ void SMTEncoder::defineGlobalVariable(string const& _name, Expression const& _ex
1626
1626
1627
1627
bool SMTEncoder::shortcutRationalNumber (Expression const & _expr)
1628
1628
{
1629
- auto type = isConstant (_expr);
1630
- if (!type )
1629
+ RationalNumberType const * rationalType = isConstant (_expr);
1630
+ if (!rationalType )
1631
1631
return false ;
1632
1632
1633
- solAssert (type->category () == Type::Category::RationalNumber, " " );
1634
- auto const & rationalType = dynamic_cast <RationalNumberType const &>(*type);
1635
- if (rationalType.isNegative ())
1636
- defineExpr (_expr, smtutil::Expression (u2s (rationalType.literalValue (nullptr ))));
1633
+ if (rationalType->isNegative ())
1634
+ defineExpr (_expr, smtutil::Expression (u2s (rationalType->literalValue (nullptr ))));
1637
1635
else
1638
- defineExpr (_expr, smtutil::Expression (rationalType. literalValue (nullptr )));
1636
+ defineExpr (_expr, smtutil::Expression (rationalType-> literalValue (nullptr )));
1639
1637
return true ;
1640
1638
}
1641
1639
@@ -2658,20 +2656,20 @@ map<ContractDefinition const*, vector<ASTPointer<frontend::Expression>>> SMTEnco
2658
2656
return baseArgs;
2659
2657
}
2660
2658
2661
- TypePointer SMTEncoder::isConstant (Expression const & _expr)
2659
+ RationalNumberType const * SMTEncoder::isConstant (Expression const & _expr)
2662
2660
{
2663
- if (
2664
- auto type = _expr.annotation ().type ;
2665
- type->category () == Type::Category::RationalNumber
2666
- )
2661
+ if (auto type = dynamic_cast <RationalNumberType const *>(_expr.annotation ().type ))
2667
2662
return type;
2668
2663
2669
2664
// _expr may not be constant evaluable.
2670
2665
// In that case we ignore any warnings emitted by the constant evaluator,
2671
2666
// as it will return nullptr in case of failure.
2672
2667
ErrorList l;
2673
2668
ErrorReporter e (l);
2674
- return ConstantEvaluator (e).evaluate (_expr);
2669
+ if (auto t = ConstantEvaluator::evaluate (e, _expr))
2670
+ return TypeProvider::rationalNumber (t->value );
2671
+
2672
+ return nullptr ;
2675
2673
}
2676
2674
2677
2675
void SMTEncoder::createReturnedExpressions (FunctionCall const & _funCall)
0 commit comments