mirror of
https://github.com/Z3Prover/z3
synced 2026-02-22 08:17:37 +00:00
Implement Z3_optimize_translate for context translation (#8072)
* Initial plan * Implement Z3_optimize_translate functionality Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Fix compilation errors and add tests for optimize translate Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Revert changes to opt_solver.cpp as requested Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
3a09b0d2b5
commit
1081916973
6 changed files with 155 additions and 0 deletions
|
|
@ -481,4 +481,22 @@ extern "C" {
|
|||
Z3_CATCH;
|
||||
}
|
||||
|
||||
Z3_optimize Z3_API Z3_optimize_translate(Z3_context c, Z3_optimize o, Z3_context target) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_translate(c, o, target);
|
||||
RESET_ERROR_CODE();
|
||||
|
||||
// Translate the opt::context to the target manager
|
||||
opt::context* translated_ctx = to_optimize_ptr(o)->translate(mk_c(target)->m());
|
||||
|
||||
// Create a new Z3_optimize_ref in the target context
|
||||
Z3_optimize_ref* result_ref = alloc(Z3_optimize_ref, *mk_c(target));
|
||||
result_ref->m_opt = translated_ctx;
|
||||
mk_c(target)->save_object(result_ref);
|
||||
|
||||
Z3_optimize result = of_optimize(result_ref);
|
||||
RETURN_Z3(result);
|
||||
Z3_CATCH_RETURN(nullptr);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue