3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-05 17:14:07 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-04-29 10:04:42 -07:00
parent c64d044e60
commit b8193a0ae6
7 changed files with 35 additions and 47 deletions

View file

@ -135,7 +135,7 @@ void context_params::set(char const * param, char const * value) {
}
void context_params::updt_params() {
updt_params(gparams::get());
updt_params(gparams::get_ref());
}
void context_params::updt_params(params_ref const & p) {

View file

@ -271,7 +271,7 @@ UNARY_CMD(elim_unused_vars_cmd, "dbg-elim-unused-vars", "<expr>", "eliminate unu
return;
}
expr_ref r(ctx.m());
elim_unused_vars(ctx.m(), to_quantifier(arg), gparams::get(), r);
elim_unused_vars(ctx.m(), to_quantifier(arg), gparams::get_ref(), r);
SASSERT(!is_quantifier(r) || !to_quantifier(r)->may_have_unused_vars());
ctx.display(ctx.regular_stream(), r);
ctx.regular_stream() << std::endl;

View file

@ -55,8 +55,8 @@ struct front_end_resource_limit : public lp::lp_resource_limit {
void run_solver(lp_params & params, char const * mps_file_name) {
reslimit rlim;
unsigned timeout = gparams::get().get_uint("timeout", 0);
unsigned rlimit = gparams::get().get_uint("rlimit", 0);
unsigned timeout = gparams::get_ref().get_uint("timeout", 0);
unsigned rlimit = gparams::get_ref().get_uint("rlimit", 0);
front_end_resource_limit lp_limit(rlim);
scoped_rlimit _rlimit(rlim, rlimit);

View file

@ -23,7 +23,7 @@ Notes:
#include "util/memory_manager.h"
void env_params::updt_params() {
params_ref p = gparams::get();
params_ref const& p = gparams::get_ref();
set_verbosity_level(p.get_uint("verbose", get_verbosity_level()));
enable_warning_messages(p.get_bool("warning", true));
memory::set_max_size(megabytes_to_bytes(p.get_uint("memory_max_size", 0)));

View file

@ -104,10 +104,8 @@ public:
~imp() {
reset();
dictionary<param_descrs*>::iterator it = m_module_param_descrs.begin();
dictionary<param_descrs*>::iterator end = m_module_param_descrs.end();
for (; it != end; ++it) {
dealloc(it->m_value);
for (auto & kv : m_module_param_descrs) {
dealloc(kv.m_value);
}
}
@ -115,10 +113,8 @@ public:
#pragma omp critical (gparams)
{
m_params.reset();
dictionary<params_ref*>::iterator it = m_module_params.begin();
dictionary<params_ref*>::iterator end = m_module_params.end();
for (; it != end; ++it) {
dealloc(it->m_value);
for (auto & kv : m_module_params) {
dealloc(kv.m_value);
}
m_module_params.reset();
}
@ -437,14 +433,8 @@ public:
return result;
}
params_ref get() {
params_ref result;
TRACE("gparams", tout << "get() m_params: " << m_params << "\n";);
#pragma omp critical (gparams)
{
result = m_params;
}
return result;
params_ref const& get_ref() {
return m_params;
}
// -----------------------------------------------
@ -464,16 +454,14 @@ public:
out << "Example: pp.decimal=true\n";
out << "\n";
}
dictionary<param_descrs*>::iterator it = get_module_param_descrs().begin();
dictionary<param_descrs*>::iterator end = get_module_param_descrs().end();
for (; it != end; ++it) {
out << "[module] " << it->m_key;
for (auto & kv : get_module_param_descrs()) {
out << "[module] " << kv.m_key;
char const * descr = nullptr;
if (get_module_descrs().find(it->m_key, descr)) {
if (get_module_descrs().find(kv.m_key, descr)) {
out << ", description: " << descr;
}
out << "\n";
it->m_value->display(out, indent + 4, smt2_style, include_descr);
kv.m_value->display(out, indent + 4, smt2_style, include_descr);
}
}
}
@ -481,12 +469,10 @@ public:
void display_modules(std::ostream & out) {
#pragma omp critical (gparams)
{
dictionary<param_descrs*>::iterator it = get_module_param_descrs().begin();
dictionary<param_descrs*>::iterator end = get_module_param_descrs().end();
for (; it != end; ++it) {
out << "[module] " << it->m_key;
for (auto & kv : get_module_param_descrs()) {
out << "[module] " << kv.m_key;
char const * descr = nullptr;
if (get_module_descrs().find(it->m_key, descr)) {
if (get_module_descrs().find(kv.m_key, descr)) {
out << ", description: " << descr;
}
out << "\n";
@ -618,10 +604,10 @@ params_ref gparams::get_module(symbol const & module_name) {
return g_imp->get_module(module_name);
}
params_ref gparams::get() {
TRACE("gparams", tout << "gparams::get()\n";);
params_ref const& gparams::get_ref() {
TRACE("gparams", tout << "gparams::get_ref()\n";);
SASSERT(g_imp != 0);
return g_imp->get();
return g_imp->get_ref();
}
void gparams::display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) {

View file

@ -106,7 +106,8 @@ public:
/**
\brief Return the global parameter set (i.e., parameters that are not associated with any particular module).
*/
static params_ref get();
static params_ref const& get_ref();
/**
\brief Dump information about available parameters in the given output stream.

View file

@ -334,7 +334,10 @@ public:
}
void inc_ref() { m_ref_count++; }
void dec_ref() { SASSERT(m_ref_count > 0); m_ref_count--; if (m_ref_count == 0) dealloc(this); }
void dec_ref() {
SASSERT(m_ref_count > 0);
if (--m_ref_count == 0) dealloc(this);
}
bool empty() const { return m_entries.empty(); }
bool contains(symbol const & k) const;
@ -565,27 +568,25 @@ void params_ref::copy(params_ref const & src) {
void params_ref::copy_core(params const * src) {
if (src == nullptr)
return;
svector<params::entry>::const_iterator it = src->m_entries.begin();
svector<params::entry>::const_iterator end = src->m_entries.end();
for (; it != end; ++it) {
switch (it->second.m_kind) {
for (auto const& p : src->m_entries) {
switch (p.second.m_kind) {
case CPK_BOOL:
m_params->set_bool(it->first, it->second.m_bool_value);
m_params->set_bool(p.first, p.second.m_bool_value);
break;
case CPK_UINT:
m_params->set_uint(it->first, it->second.m_uint_value);
m_params->set_uint(p.first, p.second.m_uint_value);
break;
case CPK_DOUBLE:
m_params->set_double(it->first, it->second.m_double_value);
m_params->set_double(p.first, p.second.m_double_value);
break;
case CPK_NUMERAL:
m_params->set_rat(it->first, *(it->second.m_rat_value));
m_params->set_rat(p.first, *(p.second.m_rat_value));
break;
case CPK_SYMBOL:
m_params->set_sym(it->first, symbol::mk_symbol_from_c_ptr(it->second.m_sym_value));
m_params->set_sym(p.first, symbol::mk_symbol_from_c_ptr(p.second.m_sym_value));
break;
case CPK_STRING:
m_params->set_str(it->first, it->second.m_str_value);
m_params->set_str(p.first, p.second.m_str_value);
break;
default:
UNREACHABLE();