mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Catch exception in Z3.
Note: This exception might not be the result of resource limitation, it might also hint towards usage error.
This commit is contained in:
parent
a71c6faf0f
commit
153ae98878
@ -73,28 +73,37 @@ void Z3Interface::addAssertion(Expression const& _expr)
|
||||
pair<CheckResult, vector<string>> Z3Interface::check(vector<Expression> const& _expressionsToEvaluate)
|
||||
{
|
||||
CheckResult result;
|
||||
switch (m_solver.check())
|
||||
vector<string> values;
|
||||
try
|
||||
{
|
||||
case z3::check_result::sat:
|
||||
result = CheckResult::SATISFIABLE;
|
||||
break;
|
||||
case z3::check_result::unsat:
|
||||
result = CheckResult::UNSATISFIABLE;
|
||||
break;
|
||||
case z3::check_result::unknown:
|
||||
result = CheckResult::UNKNOWN;
|
||||
break;
|
||||
default:
|
||||
solAssert(false, "");
|
||||
switch (m_solver.check())
|
||||
{
|
||||
case z3::check_result::sat:
|
||||
result = CheckResult::SATISFIABLE;
|
||||
break;
|
||||
case z3::check_result::unsat:
|
||||
result = CheckResult::UNSATISFIABLE;
|
||||
break;
|
||||
case z3::check_result::unknown:
|
||||
result = CheckResult::UNKNOWN;
|
||||
break;
|
||||
default:
|
||||
solAssert(false, "");
|
||||
}
|
||||
|
||||
if (result != CheckResult::UNSATISFIABLE)
|
||||
{
|
||||
z3::model m = m_solver.get_model();
|
||||
for (Expression const& e: _expressionsToEvaluate)
|
||||
values.push_back(toString(m.eval(toZ3Expr(e))));
|
||||
}
|
||||
}
|
||||
catch (z3::exception const& _e)
|
||||
{
|
||||
result = CheckResult::ERROR;
|
||||
values.clear();
|
||||
}
|
||||
|
||||
vector<string> values;
|
||||
if (result != CheckResult::UNSATISFIABLE)
|
||||
{
|
||||
z3::model m = m_solver.get_model();
|
||||
for (Expression const& e: _expressionsToEvaluate)
|
||||
values.push_back(toString(m.eval(toZ3Expr(e))));
|
||||
}
|
||||
return make_pair(result, values);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user