Refactor Z3 read callback.

This commit is contained in:
chriseth
2017-08-23 17:37:35 +02:00
parent 9ac2ac14c1
commit 1e05ebe50e
6 changed files with 46 additions and 133 deletions
+13 -1
View File
@@ -95,10 +95,11 @@ void SMTLib2Interface::addAssertion(Expression const& _expr)
pair<CheckResult, vector<string>> SMTLib2Interface::check(vector<Expression> const& _expressionsToEvaluate)
{
string response = m_communicator.communicate(
string response = querySolver(
boost::algorithm::join(m_accumulatedOutput, "\n") +
checkSatAndGetValuesCommand(_expressionsToEvaluate)
);
CheckResult result;
// TODO proper parsing
if (boost::starts_with(response, "sat\n"))
@@ -173,3 +174,14 @@ vector<string> SMTLib2Interface::parseValues(string::const_iterator _start, stri
return values;
}
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;
}