3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-21 13:23:39 +00:00

saved params work

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2012-11-29 17:19:12 -08:00
parent c3055207ed
commit cf28cbab0a
130 changed files with 1469 additions and 948 deletions

View file

@ -28,6 +28,7 @@ Notes:
#include"simplify_cmd.h"
#include"eval_cmd.h"
#include"front_end_params.h"
#include"gparams.h"
class help_cmd : public cmd {
svector<symbol> m_cmds;
@ -219,25 +220,6 @@ UNARY_CMD(pp_cmd, "display", "<term>", "display the given term.", CPK_EXPR, expr
UNARY_CMD(echo_cmd, "echo", "<string>", "display the given string", CPK_STRING, char const *, ctx.regular_stream() << arg << std::endl;);
/**
\brief Convert a keyword into an internal Z3 option name
*/
std::string smt_keyword2opt_name(symbol const & opt) {
std::string r;
SASSERT(opt.bare_str()[0] == ':');
r = opt.bare_str() + 1;
unsigned sz = static_cast<unsigned>(r.size());
for (unsigned i = 0; i < sz; i++) {
char curr = r[i];
if ('a' <= curr && curr <= 'z')
r[i] = 'A' + (curr - 'a');
else if (curr == '-')
r[i] = '_';
}
TRACE("smt2_opt_name", tout << opt << " -> '" << r << "'\n";);
return r;
}
class set_get_option_cmd : public cmd {
protected:
symbol m_true;
@ -259,7 +241,6 @@ protected:
symbol m_numeral_as_real;
symbol m_error_behavior;
symbol m_int_real_coercions;
ini_params m_ini;
bool is_builtin_option(symbol const & s) const {
return
@ -289,10 +270,7 @@ public:
m_global_decls(":global-decls"),
m_numeral_as_real(":numeral-as-real"),
m_error_behavior(":error-behavior"),
m_int_real_coercions(":int-real-coercions"),
m_ini(false) {
params.register_params(m_ini);
register_pp_params(m_ini);
m_int_real_coercions(":int-real-coercions") {
}
virtual ~set_get_option_cmd() {}
@ -324,22 +302,11 @@ class set_option_cmd : public set_get_option_cmd {
}
void set_param(cmd_context & ctx, char const * value) {
m_ini.freeze(ctx.has_manager());
std::string internal_opt = smt_keyword2opt_name(m_option);
try {
std::string old_value;
if (!m_ini.get_param_value(internal_opt.c_str(), old_value)) {
m_unsupported = true;
return;
}
m_ini.set_param_value(internal_opt.c_str(), value);
gparams::set(m_option, value);
}
catch (set_get_param_exception ex) {
std::string msg = "error setting '";
msg += m_option.str();
msg += "', ";
msg += ex.get_msg();
throw cmd_exception(msg);
catch (gparams::exception ex) {
throw cmd_exception(ex.msg());
}
}
@ -545,12 +512,10 @@ public:
print_bool(ctx, ctx.m().int_real_coercions());
}
else {
std::string iopt = smt_keyword2opt_name(opt);
std::string r;
if (m_ini.get_param_value(iopt.c_str(), r)) {
ctx.regular_stream() << r << std::endl;
try {
std::string val = gparams::get_value(opt);
}
else {
catch (gparams::exception ex) {
ctx.print_unsupported(opt);
}
}