Remove Type from SolverInterface

This commit is contained in:
Leonardo Alt 2020-05-19 14:23:41 +02:00
parent 45eba27424
commit 7a91c9b971
3 changed files with 7 additions and 8 deletions

View File

@ -19,7 +19,6 @@
#include <libsmtutil/Sorts.h>
#include <libsolidity/ast/Types.h>
#include <liblangutil/Exceptions.h>
#include <libsolutil/Common.h>
#include <libsolutil/Exceptions.h>
@ -54,17 +53,13 @@ enum class CheckResult
SATISFIABLE, UNSATISFIABLE, UNKNOWN, CONFLICTING, ERROR
};
// Forward declaration.
SortPointer smtSort(frontend::Type const& _type);
/// C++ representation of an SMTLIB2 expression.
class Expression
{
friend class SolverInterface;
public:
explicit Expression(bool _v): Expression(_v ? "true" : "false", Kind::Bool) {}
explicit Expression(frontend::TypePointer _type): Expression(_type->toString(true), {}, std::make_shared<SortSort>(smtSort(*_type))) {}
explicit Expression(std::shared_ptr<SortSort> _sort): Expression("", {}, _sort) {}
explicit Expression(std::shared_ptr<SortSort> _sort, std::string _name = ""): Expression(std::move(_name), {}, _sort) {}
Expression(size_t _number): Expression(std::to_string(_number), Kind::Int) {}
Expression(u256 const& _number): Expression(_number.str(), Kind::Int) {}
Expression(s256 const& _number): Expression(_number.str(), Kind::Int) {}

View File

@ -1061,8 +1061,9 @@ void SMTEncoder::arrayIndexAssignment(Expression const& _expr, smtutil::Expressi
{
auto symbArray = dynamic_pointer_cast<smt::SymbolicArrayVariable>(m_context.expression(*base));
solAssert(symbArray, "");
auto baseType = base->annotation().type;
toStore = smtutil::Expression::tuple_constructor(
smtutil::Expression(base->annotation().type),
smtutil::Expression(make_shared<smtutil::SortSort>(smt::smtSort(*baseType)), baseType->toString(true)),
{smtutil::Expression::store(symbArray->elements(), expr(*indexAccess->indexExpression()), toStore), symbArray->length()}
);
indexAccess = base;

View File

@ -385,7 +385,10 @@ smtutil::Expression zeroValue(frontend::TypePointer const& _type)
solAssert(false, "");
solAssert(zeroArray, "");
return smtutil::Expression::tuple_constructor(smtutil::Expression(_type), vector<smtutil::Expression>{*zeroArray, length});
return smtutil::Expression::tuple_constructor(
smtutil::Expression(std::make_shared<SortSort>(smtSort(*_type)), _type->toString(true)),
vector<smtutil::Expression>{*zeroArray, length}
);
}
solAssert(false, "");