diff --git a/scripts/update_api.py b/scripts/update_api.py index eeebfd076..09b325909 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -64,7 +64,7 @@ def is_obj(ty): Type2Str = { VOID : 'void', VOID_PTR : 'void*', INT : 'int', UINT : 'unsigned', INT64 : 'int64_t', UINT64 : 'uint64_t', DOUBLE : 'double', FLOAT : 'float', STRING : 'Z3_string', STRING_PTR : 'Z3_string_ptr', BOOL : 'bool', SYMBOL : 'Z3_symbol', - PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code', CHAR: 'char', CHAR_PTR: 'char*' + PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code', CHAR: 'char', CHAR_PTR: 'Z3_char_ptr' } Type2PyStr = { VOID_PTR : 'ctypes.c_void_p', INT : 'ctypes.c_int', UINT : 'ctypes.c_uint', INT64 : 'ctypes.c_longlong', @@ -90,7 +90,7 @@ Type2JavaW = { VOID : 'void', VOID_PTR : 'jlong', INT : 'jint', UINT : 'jint', I # Mapping to ML types Type2ML = { VOID : 'unit', VOID_PTR : 'VOIDP', INT : 'int', UINT : 'int', INT64 : 'int', UINT64 : 'int', DOUBLE : 'float', FLOAT : 'float', STRING : 'string', STRING_PTR : 'char**', - BOOL : 'bool', SYMBOL : 'z3_symbol', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char', CHAR_PTR : 'char*' } + BOOL : 'bool', SYMBOL : 'z3_symbol', PRINT_MODE : 'int', ERROR_CODE : 'int', CHAR : 'char', CHAR_PTR : 'char const*' } next_type_id = FIRST_OBJ_ID diff --git a/src/api/api_array.cpp b/src/api/api_array.cpp index bec0e7560..77a4ef1ef 100644 --- a/src/api/api_array.cpp +++ b/src/api/api_array.cpp @@ -168,7 +168,7 @@ extern "C" { } ast_manager & m = mk_c(c)->m(); func_decl* _f = to_func_decl(f); - expr* const* _args = to_exprs(args); + expr* const* _args = to_exprs(n, args); ptr_vector domain; for (unsigned i = 0; i < n; ++i) { diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index 5def91086..c84b69c3c 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -804,7 +804,7 @@ extern "C" { RESET_ERROR_CODE(); ast_manager& m = mk_c(c)->m(); expr* a = to_expr(_a); - expr* const* args = to_exprs(_args); + expr* const* args = to_exprs(num_args, _args); switch(a->get_kind()) { case AST_APP: { app* e = to_app(a); @@ -843,8 +843,8 @@ extern "C" { RESET_ERROR_CODE(); ast_manager & m = mk_c(c)->m(); expr * a = to_expr(_a); - expr * const * from = to_exprs(_from); - expr * const * to = to_exprs(_to); + expr * const * from = to_exprs(num_exprs, _from); + expr * const * to = to_exprs(num_exprs, _to); expr * r = nullptr; for (unsigned i = 0; i < num_exprs; i++) { if (m.get_sort(from[i]) != m.get_sort(to[i])) { @@ -875,7 +875,7 @@ extern "C" { RESET_ERROR_CODE(); ast_manager & m = mk_c(c)->m(); expr * a = to_expr(_a); - expr * const * to = to_exprs(_to); + expr * const * to = to_exprs(num_exprs, _to); var_subst subst(m, false); expr_ref new_a = subst(a, num_exprs, to); mk_c(c)->save_ast_trail(new_a); diff --git a/src/api/api_context.h b/src/api/api_context.h index 8d240f3de..e81c3ba02 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -20,9 +20,11 @@ Revision History: #ifndef API_CONTEXT_H_ #define API_CONTEXT_H_ -#include "api/z3.h" + +#include "util/hashtable.h" +#include "util/mutex.h" +#include "util/event_handler.h" #include "ast/ast.h" -#include "api/api_util.h" #include "ast/arith_decl_plugin.h" #include "ast/bv_decl_plugin.h" #include "ast/seq_decl_plugin.h" @@ -31,18 +33,17 @@ Revision History: #include "ast/fpa_decl_plugin.h" #include "ast/recfun_decl_plugin.h" #include "ast/special_relations_decl_plugin.h" -#include "smt/smt_kernel.h" +#include "ast/rewriter/seq_rewriter.h" #include "smt/params/smt_params.h" -#include "util/event_handler.h" +#include "smt/smt_kernel.h" +#include "smt/smt_solver.h" #include "cmd_context/tactic_manager.h" #include "cmd_context/context_params.h" #include "cmd_context/cmd_context.h" -#include "api/api_polynomial.h" -#include "util/hashtable.h" -#include "ast/rewriter/seq_rewriter.h" -#include "smt/smt_solver.h" #include "solver/solver.h" -#include "util/mutex.h" +#include "api/z3.h" +#include "api/api_util.h" +#include "api/api_polynomial.h" namespace smtlib { class parser; diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 77c59e2d6..09106c9ec 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -350,7 +350,7 @@ extern "C" { unsigned num_queries, Z3_ast _queries[]) { Z3_TRY; - expr*const* queries = to_exprs(_queries); + expr*const* queries = to_exprs(num_queries, _queries); LOG_Z3_fixedpoint_to_string(c, d, num_queries, _queries); RESET_ERROR_CODE(); return mk_c(c)->mk_external_string(to_fixedpoint_ref(d)->to_string(num_queries, queries)); diff --git a/src/api/api_opt.cpp b/src/api/api_opt.cpp index ad2c75764..8256fc0e2 100644 --- a/src/api/api_opt.cpp +++ b/src/api/api_opt.cpp @@ -157,7 +157,7 @@ extern "C" { scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit); try { expr_ref_vector asms(mk_c(c)->m()); - asms.append(num_assumptions, to_exprs(assumptions)); + asms.append(num_assumptions, to_exprs(num_assumptions, assumptions)); r = to_optimize_ptr(o)->optimize(asms); } catch (z3_exception& ex) { diff --git a/src/api/api_pb.cpp b/src/api/api_pb.cpp index 8116789f9..bc0fc1948 100644 --- a/src/api/api_pb.cpp +++ b/src/api/api_pb.cpp @@ -30,7 +30,7 @@ extern "C" { RESET_ERROR_CODE(); parameter param(k); pb_util util(mk_c(c)->m()); - ast* a = util.mk_at_most_k(num_args, to_exprs(args), k); + ast* a = util.mk_at_most_k(num_args, to_exprs(num_args, args), k); mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); @@ -44,7 +44,7 @@ extern "C" { RESET_ERROR_CODE(); parameter param(k); pb_util util(mk_c(c)->m()); - ast* a = util.mk_at_least_k(num_args, to_exprs(args), k); + ast* a = util.mk_at_least_k(num_args, to_exprs(num_args, args), k); mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); @@ -62,7 +62,7 @@ extern "C" { for (unsigned i = 0; i < num_args; ++i) { coeffs.push_back(rational(_coeffs[i])); } - ast* a = util.mk_le(num_args, coeffs.c_ptr(), to_exprs(args), rational(k)); + ast* a = util.mk_le(num_args, coeffs.c_ptr(), to_exprs(num_args, args), rational(k)); mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); @@ -80,7 +80,7 @@ extern "C" { for (unsigned i = 0; i < num_args; ++i) { coeffs.push_back(rational(_coeffs[i])); } - ast* a = util.mk_ge(num_args, coeffs.c_ptr(), to_exprs(args), rational(k)); + ast* a = util.mk_ge(num_args, coeffs.c_ptr(), to_exprs(num_args, args), rational(k)); mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); @@ -98,7 +98,7 @@ extern "C" { for (unsigned i = 0; i < num_args; ++i) { coeffs.push_back(rational(_coeffs[i])); } - ast* a = util.mk_eq(num_args, coeffs.c_ptr(), to_exprs(args), rational(k)); + ast* a = util.mk_eq(num_args, coeffs.c_ptr(), to_exprs(num_args, args), rational(k)); mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); diff --git a/src/api/api_quant.cpp b/src/api/api_quant.cpp index 546f4174a..ab9c165a1 100644 --- a/src/api/api_quant.cpp +++ b/src/api/api_quant.cpp @@ -327,7 +327,7 @@ extern "C" { RETURN_Z3(nullptr); } } - app* a = mk_c(c)->m().mk_pattern(num_patterns, reinterpret_cast(to_exprs(terms))); + app* a = mk_c(c)->m().mk_pattern(num_patterns, reinterpret_cast(to_exprs(num_patterns, terms))); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_pattern(a)); Z3_CATCH_RETURN(nullptr); diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index 184671a28..2e0441653 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -449,7 +449,7 @@ extern "C" { return Z3_L_UNDEF; } } - expr * const * _assumptions = to_exprs(assumptions); + expr * const * _assumptions = to_exprs(num_assumptions, assumptions); unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout()); unsigned rlimit = to_solver(s)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit()); bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", true); @@ -605,7 +605,7 @@ extern "C" { RESET_ERROR_CODE(); CHECK_SEARCHING(c); init_solver(c, s); - lbool result = smt::implied_equalities(m, *to_solver_ref(s), num_terms, to_exprs(terms), class_ids); + lbool result = smt::implied_equalities(m, *to_solver_ref(s), num_terms, to_exprs(num_terms, terms), class_ids); return static_cast(result); Z3_CATCH_RETURN(Z3_L_UNDEF); } diff --git a/src/api/api_util.h b/src/api/api_util.h index 848d935c5..37d9880bc 100644 --- a/src/api/api_util.h +++ b/src/api/api_util.h @@ -54,7 +54,7 @@ inline Z3_ast of_ast(ast* a) { return reinterpret_cast(a); } inline expr * to_expr(Z3_ast a) { return reinterpret_cast(a); } inline Z3_ast of_expr(expr* e) { return reinterpret_cast(e); } -inline expr * const * to_exprs(Z3_ast const* a) { return reinterpret_cast(a); } +inline expr * const * to_exprs(unsigned n, Z3_ast const* a) { return reinterpret_cast(a); } inline Z3_ast * const * of_exprs(expr* const* e) { return reinterpret_cast(e); } inline app * to_app(Z3_app a) { return reinterpret_cast(a); } @@ -165,7 +165,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned num_args, Z3_ast const* args) { \ LOG_ ## NAME(c, num_args, args); \ RESET_ERROR_CODE(); \ EXTRA_CODE; \ - ast* a = mk_c(c)->m().mk_app(FID, OP, 0, 0, num_args, to_exprs(args)); \ + ast* a = mk_c(c)->m().mk_app(FID, OP, 0, 0, num_args, to_exprs(num_args, args)); \ mk_c(c)->save_ast_trail(a); \ check_sorts(c, a); \ RETURN_Z3(of_ast(a)); \