mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
Merge branch 'opt' of https://github.com/nikolajbjorner/z3 into opt
This commit is contained in:
commit
181911463e
9 changed files with 75 additions and 52 deletions
|
@ -10,13 +10,21 @@ Copyright (c) 2015 Microsoft Corporation
|
|||
#include "z3.h"
|
||||
#include <iostream>
|
||||
|
||||
void test_print(Z3_context ctx, Z3_ast a) {
|
||||
void test_print(Z3_context ctx, Z3_ast_vector av) {
|
||||
Z3_set_ast_print_mode(ctx, Z3_PRINT_SMTLIB2_COMPLIANT);
|
||||
Z3_ast* args = new Z3_ast[Z3_ast_vector_size(ctx, av)];
|
||||
for (unsigned i = 0; i < Z3_ast_vector_size(ctx, av); ++i) {
|
||||
args[i] = Z3_ast_vector_get(ctx, av, i);
|
||||
}
|
||||
Z3_ast a = Z3_mk_and(ctx, Z3_ast_vector_size(ctx, av), args);
|
||||
Z3_inc_ref(ctx, a);
|
||||
delete[] args;
|
||||
char const* spec1 = Z3_benchmark_to_smtlib_string(ctx, "test", 0, 0, 0, 0, 0, a);
|
||||
Z3_dec_ref(ctx, a);
|
||||
std::cout << "spec1: benchmark->string\n" << spec1 << "\n";
|
||||
|
||||
std::cout << "attempting to parse spec1...\n";
|
||||
Z3_ast b =
|
||||
Z3_ast_vector b =
|
||||
Z3_parse_smtlib2_string(ctx,
|
||||
spec1,
|
||||
0,
|
||||
|
@ -26,15 +34,17 @@ void test_print(Z3_context ctx, Z3_ast a) {
|
|||
0,
|
||||
0);
|
||||
std::cout << "parse successful, converting ast->string\n";
|
||||
char const* spec2 = Z3_ast_to_string(ctx, b);
|
||||
Z3_ast_vector_inc_ref(ctx, b);
|
||||
char const* spec2 = Z3_ast_vector_to_string(ctx, b);
|
||||
std::cout << "spec2: string->ast->string\n" << spec2 << "\n";
|
||||
Z3_ast_vector_dec_ref(ctx, b);
|
||||
}
|
||||
|
||||
void test_parseprint(char const* spec) {
|
||||
Z3_context ctx = Z3_mk_context(0);
|
||||
std::cout << "spec:\n" << spec << "\n";
|
||||
|
||||
Z3_ast a =
|
||||
Z3_ast_vector a =
|
||||
Z3_parse_smtlib2_string(ctx,
|
||||
spec,
|
||||
0,
|
||||
|
@ -45,11 +55,12 @@ void test_parseprint(char const* spec) {
|
|||
0);
|
||||
|
||||
std::cout << "done parsing\n";
|
||||
|
||||
Z3_ast_vector_inc_ref(ctx, a);
|
||||
test_print(ctx, a);
|
||||
|
||||
std::cout << "done printing\n";
|
||||
|
||||
Z3_ast_vector_dec_ref(ctx, a);
|
||||
Z3_del_context(ctx);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue