3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 13:28:47 +00:00
z3/src/api/api_config_params.cpp
Leonardo de Moura 711abc75fb Fix issue reported at http://z3.codeplex.com/workitem/14
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-01-24 13:22:28 -08:00

116 lines
3.4 KiB
C++

/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
api_config_params.cpp
Abstract:
Configuration parameters
Author:
Leonardo de Moura (leonardo) 2012-02-29.
Revision History:
--*/
#include"z3.h"
#include"api_context.h"
#include"pp.h"
#include"api_log_macros.h"
#include"api_util.h"
#include"cmd_context.h"
#include"symbol.h"
#include"gparams.h"
#include"env_params.h"
#include"context_params.h"
extern "C" {
void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value) {
memory::initialize(UINT_MAX);
LOG_Z3_global_param_set(param_id, param_value);
try {
gparams::set(param_id, param_value);
env_params::updt_params();
}
catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
std::ostringstream buffer;
buffer << "Error setting " << param_id << ", " << ex.msg();
warning_msg(buffer.str().c_str());
}
}
void Z3_API Z3_global_param_reset_all(void) {
memory::initialize(UINT_MAX);
LOG_Z3_global_param_reset_all();
gparams::reset();
env_params::updt_params();
}
std::string g_Z3_global_param_get_buffer;
Z3_bool_opt Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value) {
memory::initialize(UINT_MAX);
LOG_Z3_global_param_get(param_id, param_value);
*param_value = 0;
try {
g_Z3_global_param_get_buffer = gparams::get_value(param_id);
*param_value = g_Z3_global_param_get_buffer.c_str();
return Z3_TRUE;
}
catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
std::ostringstream buffer;
buffer << "Error setting " << param_id << ": " << ex.msg();
warning_msg(buffer.str().c_str());
return Z3_FALSE;
}
}
Z3_config Z3_API Z3_mk_config(void) {
memory::initialize(UINT_MAX);
LOG_Z3_mk_config();
Z3_config r = reinterpret_cast<Z3_config>(alloc(context_params));
RETURN_Z3(r);
}
void Z3_API Z3_del_config(Z3_config c) {
LOG_Z3_del_config(c);
dealloc((reinterpret_cast<context_params*>(c)));
}
void Z3_API Z3_set_param_value(Z3_config c, char const * param_id, char const * param_value) {
LOG_Z3_set_param_value(c, param_id, param_value);
try {
context_params * p = reinterpret_cast<context_params*>(c);
p->set(param_id, param_value);
}
catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
std::ostringstream buffer;
buffer << "Error setting " << param_id << ": " << ex.msg();
warning_msg(buffer.str().c_str());
}
}
void Z3_API Z3_update_param_value(Z3_context c, Z3_string param_id, Z3_string param_value) {
Z3_TRY;
LOG_Z3_update_param_value(c, param_id, param_value);
RESET_ERROR_CODE();
mk_c(c)->params().set(param_id, param_value);
Z3_CATCH;
}
Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) {
LOG_Z3_get_param_value(c, param_id, param_value);
// TODO
return Z3_FALSE;
}
};