diff options
author | chriseth <chris@ethereum.org> | 2017-10-13 21:19:53 +0800 |
---|---|---|
committer | Leonardo Alt <leo@ethereum.org> | 2018-11-23 16:43:49 +0800 |
commit | bb10be789c269927e593b41d37aa0637db68bbe1 (patch) | |
tree | 63a015ca51e9eb1dbf043172c632d2665e62fb46 /libsolidity/formal/SMTLib2Interface.cpp | |
parent | 9217fbb58d085325ce37ed6ca37f76e8b8de9d90 (diff) | |
download | dexon-solidity-bb10be789c269927e593b41d37aa0637db68bbe1.tar.gz dexon-solidity-bb10be789c269927e593b41d37aa0637db68bbe1.tar.zst dexon-solidity-bb10be789c269927e593b41d37aa0637db68bbe1.zip |
Inject SMTLIB2 queries and responses via standard-json-io.
Diffstat (limited to 'libsolidity/formal/SMTLib2Interface.cpp')
-rw-r--r-- | libsolidity/formal/SMTLib2Interface.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/libsolidity/formal/SMTLib2Interface.cpp b/libsolidity/formal/SMTLib2Interface.cpp index 55c72cfc..80ecc715 100644 --- a/libsolidity/formal/SMTLib2Interface.cpp +++ b/libsolidity/formal/SMTLib2Interface.cpp @@ -20,6 +20,8 @@ #include <liblangutil/Exceptions.h> #include <libsolidity/interface/ReadFile.h> +#include <libdevcore/Keccak256.h> + #include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/join.hpp> #include <boost/filesystem/operations.hpp> @@ -37,8 +39,8 @@ using namespace dev; using namespace dev::solidity; using namespace dev::solidity::smt; -SMTLib2Interface::SMTLib2Interface(ReadCallback::Callback const& _queryCallback): - m_queryCallback(_queryCallback) +SMTLib2Interface::SMTLib2Interface(map<h256, string> const& _smtlib2Responses): + m_smtlib2Responses(_smtlib2Responses) { reset(); } @@ -212,11 +214,12 @@ vector<string> SMTLib2Interface::parseValues(string::const_iterator _start, stri string SMTLib2Interface::querySolver(string const& _input) { - if (!m_queryCallback) - BOOST_THROW_EXCEPTION(SolverError() << errinfo_comment("No SMT solver available.")); - - ReadCallback::Result queryResult = m_queryCallback(_input); - if (!queryResult.success) - BOOST_THROW_EXCEPTION(SolverError() << errinfo_comment(queryResult.responseOrErrorMessage)); - return queryResult.responseOrErrorMessage; + h256 inputHash = dev::keccak256(_input); + if (m_smtlib2Responses.count(inputHash)) + return m_smtlib2Responses.at(inputHash); + else + { + m_unhandledQueries.push_back(_input); + return "unknown\n"; + } } |