mirror of
				https://github.com/Z3Prover/z3
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	harness internalization and API for #1776
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
		
							parent
							
								
									fed977b492
								
							
						
					
					
						commit
						f306f75e36
					
				
					 5 changed files with 16 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -379,11 +379,13 @@ extern "C" {
 | 
			
		|||
        Z3_TRY;
 | 
			
		||||
        LOG_Z3_dec_ref(c, a);
 | 
			
		||||
        RESET_ERROR_CODE();
 | 
			
		||||
        if (to_ast(a)->get_ref_count() == 0) {
 | 
			
		||||
        if (a && to_ast(a)->get_ref_count() == 0) {
 | 
			
		||||
            SET_ERROR_CODE(Z3_DEC_REF_ERROR, nullptr);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        mk_c(c)->m().dec_ref(to_ast(a));
 | 
			
		||||
        if (a) {
 | 
			
		||||
            mk_c(c)->m().dec_ref(to_ast(a));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Z3_CATCH;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -206,9 +206,8 @@ extern "C" {
 | 
			
		|||
        ptr_vector<expr> const & universe = to_model_ref(m)->get_universe(to_sort(s));
 | 
			
		||||
        Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
 | 
			
		||||
        mk_c(c)->save_object(v);
 | 
			
		||||
        unsigned sz = universe.size();
 | 
			
		||||
        for (unsigned i = 0; i < sz; i++) {
 | 
			
		||||
            v->m_ast_vector.push_back(universe[i]);
 | 
			
		||||
        for (expr * e : universe) {
 | 
			
		||||
            v->m_ast_vector.push_back(e);
 | 
			
		||||
        }
 | 
			
		||||
        RETURN_Z3(of_ast_vector(v));
 | 
			
		||||
        Z3_CATCH_RETURN(nullptr);
 | 
			
		||||
| 
						 | 
				
			
			@ -230,7 +229,7 @@ extern "C" {
 | 
			
		|||
        Z3_TRY;
 | 
			
		||||
        LOG_Z3_is_as_array(c, a);
 | 
			
		||||
        RESET_ERROR_CODE();
 | 
			
		||||
        return is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY);
 | 
			
		||||
        return a && is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY);
 | 
			
		||||
        Z3_CATCH_RETURN(Z3_FALSE);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			@ -238,7 +237,7 @@ extern "C" {
 | 
			
		|||
        Z3_TRY;
 | 
			
		||||
        LOG_Z3_get_as_array_func_decl(c, a);
 | 
			
		||||
        RESET_ERROR_CODE();
 | 
			
		||||
        if (is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY)) {
 | 
			
		||||
        if (a && is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY)) {
 | 
			
		||||
            RETURN_Z3(of_func_decl(to_func_decl(to_app(a)->get_decl()->get_parameter(0).get_ast())));
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
| 
						 | 
				
			
			@ -252,6 +251,7 @@ extern "C" {
 | 
			
		|||
        Z3_TRY;
 | 
			
		||||
        LOG_Z3_add_func_interp(c, m, f, else_val);
 | 
			
		||||
        RESET_ERROR_CODE();
 | 
			
		||||
		CHECK_NON_NULL(f, nullptr);
 | 
			
		||||
        func_decl* d = to_func_decl(f);
 | 
			
		||||
        model* mdl = to_model_ref(m);
 | 
			
		||||
        Z3_func_interp_ref * f_ref = alloc(Z3_func_interp_ref, *mk_c(c), mdl); 
 | 
			
		||||
| 
						 | 
				
			
			@ -268,7 +268,7 @@ extern "C" {
 | 
			
		|||
        LOG_Z3_add_const_interp(c, m, f, a);
 | 
			
		||||
        RESET_ERROR_CODE();
 | 
			
		||||
        func_decl* d = to_func_decl(f);
 | 
			
		||||
        if (d->get_arity() != 0) {
 | 
			
		||||
        if (!d || d->get_arity() != 0) {
 | 
			
		||||
            SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -438,8 +438,7 @@ namespace smt {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    extra_fresh_value * model_generator::mk_extra_fresh_value(sort * s) {
 | 
			
		||||
        SASSERT(s->is_infinite());
 | 
			
		||||
    extra_fresh_value * model_generator::mk_extra_fresh_value(sort * s) {        
 | 
			
		||||
        extra_fresh_value * r = alloc(extra_fresh_value, s, m_fresh_idx);
 | 
			
		||||
        m_fresh_idx++;
 | 
			
		||||
        m_extra_fresh_values.push_back(r);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -850,6 +850,7 @@ namespace smt {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    bool theory_bv::internalize_term(app * term) {
 | 
			
		||||
        scoped_suspend_rlimit _suspend_cancel(get_manager().limit());
 | 
			
		||||
        try {
 | 
			
		||||
        SASSERT(term->get_family_id() == get_family_id());
 | 
			
		||||
        TRACE("bv", tout << "internalizing term: " << mk_bounded_pp(term, get_manager()) << "\n";);
 | 
			
		||||
| 
						 | 
				
			
			@ -910,7 +911,7 @@ namespace smt {
 | 
			
		|||
        }
 | 
			
		||||
        }
 | 
			
		||||
        catch (z3_exception& ex) {
 | 
			
		||||
            IF_VERBOSE(1, verbose_stream() << ex.msg() << "\n";);
 | 
			
		||||
            IF_VERBOSE(1, verbose_stream() << "internalize_term: " << ex.msg() << "\n";);
 | 
			
		||||
            throw;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,12 +65,14 @@ public:
 | 
			
		|||
 | 
			
		||||
class scoped_suspend_rlimit {
 | 
			
		||||
    reslimit & m_limit;
 | 
			
		||||
    bool       m_suspend;
 | 
			
		||||
public:
 | 
			
		||||
    scoped_suspend_rlimit(reslimit& r): m_limit(r) {
 | 
			
		||||
        m_suspend = r.m_suspend;
 | 
			
		||||
        r.m_suspend = true;
 | 
			
		||||
    }
 | 
			
		||||
    ~scoped_suspend_rlimit() {
 | 
			
		||||
        m_limit.m_suspend = false;
 | 
			
		||||
        m_limit.m_suspend = m_suspend;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue