3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

working on parallel solver

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-10-10 16:35:05 -07:00
commit 1a6f8c2fad
25 changed files with 320 additions and 126 deletions

View file

@ -65,6 +65,15 @@ void throw_z3_error(Z3_context c, Z3_error_code e)
longjmp(g_catch_buffer, e);
}
/**
\brief Error handling that depends on checking an error code on the context.
*/
void nothrow_z3_error(Z3_context c, Z3_error_code e) {
// no-op
}
/**
\brief Create a logical context.
@ -1592,18 +1601,16 @@ void error_code_example1()
void error_code_example2() {
Z3_config cfg;
Z3_context ctx = NULL;
int r;
Z3_error_code e;
printf("\nerror_code_example2\n");
LOG_MSG("error_code_example2");
/* low tech try&catch */
r = setjmp(g_catch_buffer);
if (r == 0) {
if (1) {
Z3_ast x, y, app;
cfg = Z3_mk_config();
ctx = mk_context_custom(cfg, throw_z3_error);
ctx = mk_context_custom(cfg, nothrow_z3_error);
Z3_del_config(cfg);
x = mk_int_var(ctx, "x");
@ -1611,11 +1618,14 @@ void error_code_example2() {
printf("before Z3_mk_iff\n");
/* the next call will produce an error */
app = Z3_mk_iff(ctx, x, y);
e = Z3_get_error_code(ctx);
if (e != Z3_OK) goto err;
unreachable();
Z3_del_context(ctx);
}
else {
printf("Z3 error: %s.\n", Z3_get_error_msg(ctx, (Z3_error_code)r));
err:
printf("Z3 error: %s.\n", Z3_get_error_msg(ctx, e));
if (ctx != NULL) {
Z3_del_context(ctx);
}
@ -1781,15 +1791,14 @@ void parser_example5() {
Z3_config cfg;
Z3_context ctx = NULL;
Z3_solver s = NULL;
int r;
Z3_error_code e;
printf("\nparser_example5\n");
LOG_MSG("parser_example5");
r = setjmp(g_catch_buffer);
if (r == 0) {
if (1) {
cfg = Z3_mk_config();
ctx = mk_context_custom(cfg, throw_z3_error);
ctx = mk_context_custom(cfg, nothrow_z3_error);
s = mk_solver(ctx);
Z3_del_config(cfg);
@ -1798,12 +1807,15 @@ void parser_example5() {
"(benchmark tst :extrafuns ((x Int (y Int)) :formula (> x y) :formula (> x 0))",
0, 0, 0,
0, 0, 0);
e = Z3_get_error_code(ctx);
if (e != Z3_OK) goto err;
unreachable();
del_solver(ctx, s);
Z3_del_context(ctx);
}
else {
printf("Z3 error: %s.\n", Z3_get_error_msg(ctx, (Z3_error_code)r));
err:
printf("Z3 error: %s.\n", Z3_get_error_msg(ctx, e));
if (ctx != NULL) {
printf("Error message: '%s'.\n",Z3_get_smtlib_error(ctx));
del_solver(ctx, s);