mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Implement missing overrides and relax smtAsserts
This commit is contained in:
parent
347c966f08
commit
c1720e62aa
@ -123,7 +123,7 @@ public:
|
||||
explicit Expression(std::shared_ptr<SortSort> _sort, std::string _name = ""): Expression(std::move(_name), {}, _sort) {}
|
||||
explicit Expression(std::string _name, std::vector<Expression> _arguments, SortPointer _sort):
|
||||
name(std::move(_name)), arguments(std::move(_arguments)), sort(std::move(_sort)) {}
|
||||
Expression(size_t _number): Expression(std::to_string(_number), {}, SortProvider::sintSort) {}
|
||||
Expression(size_t _number): Expression(std::to_string(_number), {}, SortProvider::uintSort) {}
|
||||
Expression(u256 const& _number): Expression(_number.str(), {}, SortProvider::sintSort) {}
|
||||
Expression(s256 const& _number): Expression(
|
||||
_number >= 0 ? _number.str() : "-",
|
||||
@ -189,6 +189,9 @@ public:
|
||||
|
||||
static Expression ite(Expression _condition, Expression _trueValue, Expression _falseValue)
|
||||
{
|
||||
if (_trueValue.sort->kind == Kind::Int)
|
||||
smtAssert(_trueValue.sort->kind == _falseValue.sort->kind, "");
|
||||
else
|
||||
smtAssert(*_trueValue.sort == *_falseValue.sort, "");
|
||||
SortPointer sort = _trueValue.sort;
|
||||
return Expression("ite", std::vector<Expression>{
|
||||
@ -213,6 +216,9 @@ public:
|
||||
std::shared_ptr<ArraySort> arraySort = std::dynamic_pointer_cast<ArraySort>(_array.sort);
|
||||
smtAssert(arraySort, "");
|
||||
smtAssert(_index.sort, "");
|
||||
if (arraySort->domain->kind == Kind::Int)
|
||||
smtAssert(arraySort->domain->kind == _index.sort->kind, "");
|
||||
else
|
||||
smtAssert(*arraySort->domain == *_index.sort, "");
|
||||
return Expression(
|
||||
"select",
|
||||
@ -230,6 +236,9 @@ public:
|
||||
smtAssert(_index.sort, "");
|
||||
smtAssert(_element.sort, "");
|
||||
smtAssert(*arraySort->domain == *_index.sort, "");
|
||||
if (arraySort->domain->kind == Kind::Int)
|
||||
smtAssert(arraySort->range->kind == _element.sort->kind, "");
|
||||
else
|
||||
smtAssert(*arraySort->range == *_element.sort, "");
|
||||
return Expression(
|
||||
"store",
|
||||
@ -245,6 +254,9 @@ public:
|
||||
auto arraySort = std::dynamic_pointer_cast<ArraySort>(sortSort->inner);
|
||||
smtAssert(sortSort && arraySort, "");
|
||||
smtAssert(_value.sort, "");
|
||||
if (arraySort->domain->kind == Kind::Int)
|
||||
smtAssert(arraySort->range->kind == _value.sort->kind, "");
|
||||
else
|
||||
smtAssert(*arraySort->range == *_value.sort, "");
|
||||
return Expression(
|
||||
"const_array",
|
||||
|
@ -57,9 +57,14 @@ struct IntSort: public Sort
|
||||
isSigned(_signed)
|
||||
{}
|
||||
|
||||
bool operator==(IntSort const& _other) const
|
||||
bool operator==(Sort const& _other) const override
|
||||
{
|
||||
return Sort::operator==(_other) && isSigned == _other.isSigned;
|
||||
if (!Sort::operator==(_other))
|
||||
return false;
|
||||
|
||||
auto otherIntSort = dynamic_cast<IntSort const*>(&_other);
|
||||
smtAssert(otherIntSort);
|
||||
return isSigned == otherIntSort->isSigned;
|
||||
}
|
||||
|
||||
bool isSigned;
|
||||
@ -72,9 +77,14 @@ struct BitVectorSort: public Sort
|
||||
size(_size)
|
||||
{}
|
||||
|
||||
bool operator==(BitVectorSort const& _other) const
|
||||
bool operator==(Sort const& _other) const override
|
||||
{
|
||||
return Sort::operator==(_other) && size == _other.size;
|
||||
if (!Sort::operator==(_other))
|
||||
return false;
|
||||
|
||||
auto otherBitVectorSort = dynamic_cast<BitVectorSort const*>(&_other);
|
||||
smtAssert(otherBitVectorSort);
|
||||
return size == otherBitVectorSort->size;
|
||||
}
|
||||
|
||||
unsigned size;
|
||||
|
Loading…
Reference in New Issue
Block a user