mirror of
https://github.com/Z3Prover/z3
synced 2025-04-13 20:38:43 +00:00
minor code simplification
This commit is contained in:
parent
68e4ed3c9c
commit
cb75326686
|
@ -326,11 +326,7 @@ public:
|
|||
}
|
||||
|
||||
void set(char const * name, char const * value) {
|
||||
bool error = false;
|
||||
std::string error_msg;
|
||||
{
|
||||
lock_guard lock(*gparams_mux);
|
||||
try {
|
||||
symbol m, p;
|
||||
normalize(name, m, p);
|
||||
if (m == symbol::null) {
|
||||
|
@ -350,15 +346,6 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
// Exception cannot cross critical section boundaries.
|
||||
error = true;
|
||||
error_msg = ex.msg();
|
||||
}
|
||||
}
|
||||
if (error)
|
||||
throw exception(std::move(error_msg));
|
||||
}
|
||||
|
||||
std::string get_value(params_ref const & ps, symbol const & p) {
|
||||
std::ostringstream buffer;
|
||||
|
@ -377,50 +364,33 @@ public:
|
|||
}
|
||||
|
||||
std::string get_value(char const * name) {
|
||||
std::string r;
|
||||
bool error = false;
|
||||
std::string error_msg;
|
||||
{
|
||||
lock_guard lock(*gparams_mux);
|
||||
try {
|
||||
symbol m, p;
|
||||
normalize(name, m, p);
|
||||
if (m == symbol::null) {
|
||||
if (m_params.contains(p)) {
|
||||
r = get_value(m_params, p);
|
||||
return get_value(m_params, p);
|
||||
}
|
||||
else {
|
||||
r = get_default(get_param_descrs(), p, m);
|
||||
return get_default(get_param_descrs(), p, m);
|
||||
}
|
||||
}
|
||||
else {
|
||||
params_ref * ps = nullptr;
|
||||
if (m_module_params.find(m, ps) && ps->contains(p)) {
|
||||
r = get_value(*ps, p);
|
||||
return get_value(*ps, p);
|
||||
}
|
||||
else {
|
||||
param_descrs * d;
|
||||
if (get_module_param_descrs().find(m, d)) {
|
||||
r = get_default(*d, p, m);
|
||||
return get_default(*d, p, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::stringstream strm;
|
||||
strm << "unknown module '" << m << "'";
|
||||
throw exception(strm.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
// Exception cannot cross critical section boundaries.
|
||||
error = true;
|
||||
error_msg = ex.msg();
|
||||
}
|
||||
}
|
||||
if (error)
|
||||
throw exception(std::move(error_msg));
|
||||
return r;
|
||||
}
|
||||
|
||||
// unfortunately, params_ref is not thread safe
|
||||
// so better create a local copy of the parameters.
|
||||
|
@ -480,10 +450,7 @@ public:
|
|||
}
|
||||
|
||||
void display_module(std::ostream & out, symbol const & module_name) {
|
||||
bool error = false;
|
||||
std::string error_msg;
|
||||
lock_guard lock(*gparams_mux);
|
||||
try {
|
||||
param_descrs * d = nullptr;
|
||||
if (!get_module_param_descrs().find(module_name, d)) {
|
||||
std::stringstream strm;
|
||||
|
@ -498,21 +465,9 @@ public:
|
|||
out << "\n";
|
||||
d->display(out, 4, false);
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
// Exception cannot cross critical section boundaries.
|
||||
error = true;
|
||||
error_msg = ex.msg();
|
||||
}
|
||||
if (error)
|
||||
throw exception(std::move(error_msg));
|
||||
}
|
||||
|
||||
void display_parameter(std::ostream & out, char const * name) {
|
||||
bool error = false;
|
||||
std::string error_msg;
|
||||
{
|
||||
lock_guard lock(*gparams_mux);
|
||||
try {
|
||||
symbol m, p;
|
||||
normalize(name, m, p);
|
||||
out << name << " " << m << " " << p << "\n";
|
||||
|
@ -538,15 +493,6 @@ public:
|
|||
out << " description: " << d->get_descr(p) << "\n";
|
||||
out << " default value: " << d->get_default(p) << "\n";
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
// Exception cannot cross critical section boundaries.
|
||||
error = true;
|
||||
error_msg = ex.msg();
|
||||
}
|
||||
}
|
||||
if (error)
|
||||
throw exception(std::move(error_msg));
|
||||
}
|
||||
};
|
||||
|
||||
gparams::imp * gparams::g_imp = nullptr;
|
||||
|
@ -637,5 +583,3 @@ void gparams::finalize() {
|
|||
dealloc(g_imp);
|
||||
delete gparams_mux;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue