This PR refactors the driver to no longer directly access the Options object, but instead use Solver::getOption() or Solver::getOptionInfo().
*/
SmtEngine* Solver::getSmtEngine(void) const { return d_smtEngine.get(); }
-/*
- * !!! This is only temporarily available until the parser is fully migrated to
- * the new API. !!!
- */
-Options& Solver::getOptions(void) { return d_smtEngine->getOptions(); }
-
Statistics Solver::getStatistics() const
{
return Statistics(d_smtEngine->getStatisticsRegistry());
// to the new API. !!!
SmtEngine* getSmtEngine(void) const;
- // !!! This is only temporarily available until options are refactored at
- // the driver level. !!!
- Options& getOptions(void);
-
/**
* Returns a snapshot of the current state of the statistic values of this
* solver. The returned object is completely decoupled from the solver and
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <ostream>
#include <sstream>
#include <string>
return ss.str();
}
+void Exception::toStream(std::ostream& os) const { os << d_msg; }
+
thread_local LastExceptionBuffer* LastExceptionBuffer::s_currentBuffer = nullptr;
LastExceptionBuffer::LastExceptionBuffer() : d_contents(nullptr) {}
* a derived class, it's recommended that this method print the
* type of exception before the actual message.
*/
- virtual void toStream(std::ostream& os) const { os << d_msg; }
+ virtual void toStream(std::ostream& os) const;
}; /* class Exception */
#include <vector>
#include "main/main.h"
-#include "options/base_options.h"
-#include "options/main_options.h"
#include "smt/command.h"
#include "smt/smt_engine.h"
{
}
-Options& CommandExecutor::getOptions()
-{
- return d_solver->d_smtEngine->getOptions();
-}
void CommandExecutor::storeOptionsAsOriginal()
{
- d_solver->d_originalOptions->copyValues(getOptions());
+ d_solver->d_originalOptions->copyValues(d_solver->d_smtEngine->getOptions());
}
void CommandExecutor::printStatistics(std::ostream& out) const
{
- const auto& baseopts = d_solver->getOptions().base;
- if (baseopts.statistics)
+ if (d_solver->getOptionInfo("stats").boolValue())
{
const auto& stats = d_solver->getStatistics();
- auto it = stats.begin(baseopts.statisticsExpert, baseopts.statisticsAll);
+ auto it = stats.begin(d_solver->getOptionInfo("stats-expert").boolValue(),
+ d_solver->getOptionInfo("stats-all").boolValue());
for (; it != stats.end(); ++it)
{
out << it->first << " = " << it->second << std::endl;
void CommandExecutor::printStatisticsSafe(int fd) const
{
- if (d_solver->getOptions().base.statistics)
+ if (d_solver->getOptionInfo("stats").boolValue())
{
d_solver->printStatisticsSafe(fd);
}
bool CommandExecutor::doCommand(Command* cmd)
{
- if (d_solver->getOptions().base.parseOnly)
+ if (d_solver->getOptionInfo("parse-only").boolValue())
{
return true;
}
return status;
} else {
- if (d_solver->getOptions().base.verbosity > 2)
+ if (d_solver->getOptionInfo("verbosity").intValue() > 2)
{
d_solver->getDriverOptions().out() << "Invoking: " << *cmd << std::endl;
}
// dump the model/proof/unsat core if option is set
if (status) {
std::vector<std::unique_ptr<Command> > getterCommands;
- if (d_solver->getOptions().driver.dumpModels
+ if (d_solver->getOptionInfo("dump-models").boolValue()
&& (isResultSat
|| (res.isSatUnknown()
&& res.getUnknownExplanation() == api::Result::INCOMPLETE)))
{
getterCommands.emplace_back(new GetModelCommand());
}
- if (d_solver->getOptions().driver.dumpProofs && isResultUnsat)
+ if (d_solver->getOptionInfo("dump-proofs").boolValue() && isResultUnsat)
{
getterCommands.emplace_back(new GetProofCommand());
}
- if ((d_solver->getOptions().driver.dumpInstantiations
- || d_solver->getOptions().driver.dumpInstantiationsDebug)
+ if ((d_solver->getOptionInfo("dump-instantiations").boolValue()
+ || d_solver->getOptionInfo("dump-instantiations-debug").boolValue())
&& GetInstantiationsCommand::isEnabled(d_solver.get(), res))
{
getterCommands.emplace_back(new GetInstantiationsCommand());
}
- if ((d_solver->getOptions().driver.dumpUnsatCores
- || d_solver->getOptions().driver.dumpUnsatCoresFull)
+ if ((d_solver->getOptionInfo("dump-unsat-cores").boolValue()
+ || d_solver->getOptionInfo("dump-unsat-cores-full").boolValue())
&& isResultUnsat)
{
getterCommands.emplace_back(new GetUnsatCoreCommand());
if (!getterCommands.empty()) {
// set no time limit during dumping if applicable
- if (d_solver->getOptions().driver.forceNoLimitCpuWhileDump)
+ if (d_solver->getOptionInfo("force-no-limit-cpu-while-dump").boolValue())
{
setNoLimitCPU();
}
SmtEngine* getSmtEngine() const { return d_solver->getSmtEngine(); }
- /** Get the current options from the solver */
- Options& getOptions();
/** Store the current options as the original options */
void storeOptionsAsOriginal();
#include "main/options.h"
#include "main/signal_handlers.h"
#include "main/time_limit.h"
-#include "options/base_options.h"
-#include "options/main_options.h"
-#include "options/option_exception.h"
-#include "options/options.h"
-#include "options/options_public.h"
-#include "options/parser_options.h"
-#include "options/set_language.h"
#include "parser/parser.h"
#include "parser/parser_builder.h"
#include "smt/command.h"
// Create the command executor to execute the parsed commands
pExecutor = std::make_unique<CommandExecutor>(solver);
api::DriverOptions dopts = solver->getDriverOptions();
- Options* opts = &pExecutor->getOptions();
// Parse the options
std::vector<string> filenames = main::parse(*solver, argc, argv, progName);
- auto limit = install_time_limit(*opts);
+ auto limit = install_time_limit(solver->getOptionInfo("tlimit").uintValue());
- if (opts->driver.help)
+ if (solver->getOptionInfo("help").boolValue())
{
printUsage(dopts, true);
exit(1);
}
- else if (opts->base.languageHelp)
+ else if (solver->getOptionInfo("language-help").boolValue())
{
main::printLanguageHelp(dopts.out());
exit(1);
}
- else if (opts->driver.version)
+ else if (solver->getOptionInfo("version").boolValue())
{
dopts.out() << Configuration::about().c_str() << flush;
exit(0);
}
- segvSpin = opts->driver.segvSpin;
+ segvSpin = solver->getOptionInfo("segv-spin").boolValue();
// If in competition mode, set output stream option to flush immediately
#ifdef CVC5_COMPETITION_MODE
const bool inputFromStdin = filenames.empty() || filenames[0] == "-";
// if we're reading from stdin on a TTY, default to interactive mode
- if (!opts->driver.interactiveWasSetByUser)
+ if (!solver->getOptionInfo("interactive").setByUser)
{
- opts->driver.interactive = inputFromStdin && isatty(fileno(stdin));
+ solver->setOption("interactive", (inputFromStdin && isatty(fileno(stdin))) ? "true" : "false");
}
// Auto-detect input language by filename extension
// Parse and execute commands until we are done
std::unique_ptr<Command> cmd;
bool status = true;
- if (opts->driver.interactive && inputFromStdin)
+ if (solver->getOptionInfo("interactive").boolValue() && inputFromStdin)
{
- if (!opts->base.incrementalSolvingWasSetByUser)
+ if (!solver->getOptionInfo("incremental").setByUser)
{
cmd.reset(new SetOptionCommand("incremental", "true"));
cmd->setMuted(true);
if (cmd == nullptr)
break;
status = pExecutor->doCommand(cmd) && status;
- opts = &pExecutor->getOptions();
if (cmd->interrupted()) {
break;
}
}
else
{
- if (!opts->base.incrementalSolvingWasSetByUser)
+ if (!solver->getOptionInfo("incremental").setByUser)
{
cmd.reset(new SetOptionCommand("incremental", "false"));
cmd->setMuted(true);
parser->setInput(
Input::newFileInput(solver->getOption("input-language"),
filename,
- solver->getOption("mmap") == "true"));
+ solver->getOptionInfo("mmap").boolValue()));
}
bool interrupted = false;
if (interrupted) {
dopts.out() << CommandInterrupted();
pExecutor->reset();
- opts = &pExecutor->getOptions();
break;
}
try {
}
status = pExecutor->doCommand(cmd);
- opts = &pExecutor->getOptions();
if (cmd->interrupted() && status == 0) {
interrupted = true;
break;
pExecutor->flushOutputStreams();
#ifdef CVC5_DEBUG
- if (opts->driver.earlyExit && opts->driver.earlyExitWasSetByUser)
{
- _exit(returnValue);
+ auto info = solver->getOptionInfo("early-exit");
+ if (info.boolValue() && info.setByUser)
+ {
+ _exit(returnValue);
+ }
}
#else /* CVC5_DEBUG */
- if (opts->driver.earlyExit)
+ if (solver->getOptionInfo("early-exit").boolValue())
{
_exit(returnValue);
}
#include "base/check.h"
#include "base/output.h"
#include "expr/symbol_manager.h"
-#include "options/base_options.h"
-#include "options/language.h"
-#include "options/main_options.h"
-#include "options/options.h"
-#include "options/parser_options.h"
#include "parser/input.h"
#include "parser/parser.h"
#include "parser/parser_builder.h"
ParserBuilder parserBuilder(solver, sm, true);
/* Create parser with bogus input. */
d_parser = parserBuilder.build();
- if (d_solver->getOptions().parser.forceLogicStringWasSetByUser)
+ if (d_solver->getOptionInfo("force-logic").setByUser)
{
LogicInfo tmp(d_solver->getOption("force-logic"));
d_parser->forceLogic(tmp.getLogicString());
#ifdef CVC5_COMPETITION_MODE
solver->getDriverOptions().out() << "unknown" << std::endl;
#endif
- if (language::isLangSmt2(solver->getOptions().base.outputLanguage))
+ if (solver->getOption("output-language") == "LANG_SMTLIB_V2_6")
{
solver->getDriverOptions().out()
<< "(error \"" << e << "\")" << std::endl;
solver->getDriverOptions().err()
<< "(error \"" << e << "\")" << std::endl;
}
- if (solver->getOptions().base.statistics && pExecutor != nullptr)
+ if (solver->getOptionInfo("stats").boolValue()
+ && main::pExecutor != nullptr)
{
totalTime.reset();
pExecutor->printStatistics(solver->getDriverOptions().err());
#include <cstring>
#include "base/exception.h"
-#include "options/base_options.h"
#include "signal_handlers.h"
namespace cvc5 {
}
#endif
-TimeLimit install_time_limit(const Options& opts)
+TimeLimit install_time_limit(uint64_t ms)
{
- uint64_t ms = opts.base.cumulativeMillisecondLimit;
// Skip if no time limit shall be set.
if (ms == 0) {
return TimeLimit();
* thread needs to communicate back to the timer thread when it wants to
* terminate, which is done via the TimeLimit object.
*/
-TimeLimit install_time_limit(const Options& opts);
+TimeLimit install_time_limit(uint64_t ms);
} // namespace main
} // namespace cvc5
[[option]]
name = "languageHelp"
+ long = "language-help"
category = "undocumented"
type = "bool"
#include "base/check.h"
#include "base/output.h"
#include "expr/kind.h"
-#include "options/base_options.h"
-#include "options/options.h"
#include "parser/input.h"
#include "parser/parser_exception.h"
#include "smt/command.h"
api::Term Parser::mkStringConstant(const std::string& s)
{
- if (language::isLangSmt2(d_solver->getOptions().base.inputLanguage))
+ if (d_solver->getOption("input-language") == "LANG_SMTLIB_V2_6")
{
return d_solver->mkString(s, true);
}
#include "api/cpp/cvc5.h"
#include "base/check.h"
#include "cvc/cvc.h"
-#include "options/base_options.h"
-#include "options/options.h"
-#include "options/parser_options.h"
#include "parser/antlr_input.h"
#include "parser/input.h"
#include "parser/parser.h"
init(solver, sm);
if (useOptions)
{
- withOptions(solver->getOptions());
+ withOptions();
}
}
return *this;
}
-ParserBuilder& ParserBuilder::withOptions(const Options& opts)
+ParserBuilder& ParserBuilder::withOptions()
{
ParserBuilder& retval = *this;
retval = retval.withInputLanguage(d_solver->getOption("input-language"))
- .withChecks(opts.parser.semanticChecks)
- .withStrictMode(opts.parser.strictParsing)
- .withParseOnly(opts.base.parseOnly)
- .withIncludeFile(opts.parser.filesystemAccess);
- if (opts.parser.forceLogicStringWasSetByUser)
+ .withChecks(d_solver->getOptionInfo("semantic-checks").boolValue())
+ .withStrictMode(d_solver->getOptionInfo("strict-parsing").boolValue())
+ .withParseOnly(d_solver->getOptionInfo("parse-only").boolValue())
+ .withIncludeFile(d_solver->getOptionInfo("filesystem-access").boolValue());
+ auto info = d_solver->getOptionInfo("force-logic");
+ if (info.setByUser)
{
- LogicInfo tmp(opts.parser.forceLogicString);
+ LogicInfo tmp(info.stringValue());
retval = retval.withForcedLogic(tmp.getLogicString());
}
return retval;
*/
ParserBuilder& withParseOnly(bool flag = true);
- /** Derive settings from the given options. */
- ParserBuilder& withOptions(const Options& opts);
+ /** Derive settings from the solver's options. */
+ ParserBuilder& withOptions();
/**
* Should the parser use strict mode?
#include <algorithm>
#include "base/check.h"
-#include "options/base_options.h"
-#include "options/options.h"
-#include "options/options_public.h"
#include "parser/antlr_input.h"
#include "parser/parser.h"
#include "parser/smt2/smt2_input.h"
return d_solver->mkAbstractValue(name.substr(1));
}
-Language Smt2::getLanguage() const
-{
- return d_solver->getOptions().base.inputLanguage;
-}
-
void Smt2::parseOpApplyTypeAscription(ParseOp& p, api::Sort type)
{
Debug("parser") << "parseOpApplyTypeAscription : " << p << " " << type
void addSepOperators();
- Language getLanguage() const;
-
/**
* Utility function to create a conjunction of expressions.
*