This PR consolidates the two different reset implementations into a single function.
CommandExecutor::CommandExecutor(const Options& options)
: d_solver(new api::Solver(&options)),
d_symman(new SymbolManager(d_solver.get())),
- d_driverOptions(&options),
d_result()
{
}
void CommandExecutor::reset()
{
printStatistics(*d_solver->getOptions().base.err);
- /* We have to keep options passed via CL on reset. These options are stored
- * in CommandExecutor::d_driverOptions (populated and created in the driver),
- * and CommandExecutor::d_driverOptions only contains *these* options since
- * the SmtEngine copies them into its own options object before configuring
- * additional options based on the given CL options.
- * We can thus safely reuse CommandExecutor::d_driverOptions here.
- */
- d_solver.reset(new api::Solver(d_driverOptions));
+
+ Command::resetSolver(d_solver.get());
}
bool CommandExecutor::doCommandSingleton(Command* cmd)
* symbol manager.
*/
std::unique_ptr<SymbolManager> d_symman;
- /**
- * A pointer to the original options from the driver. Contain options as
- * parsed from the command line. Used when the solver is reset.
- */
- const Options* d_driverOptions;
api::Result d_result;
}
}
+void Command::resetSolver(api::Solver* solver)
+{
+ std::unique_ptr<Options> opts = std::make_unique<Options>();
+ opts->copyValues(*solver->d_originalOptions);
+ // This reconstructs a new solver object at the same memory location as the
+ // current one. Note that this command does not own the solver object!
+ // It may be safer to instead make the ResetCommand a special case in the
+ // CommandExecutor such that this reconstruction can be done within the
+ // CommandExecutor, who actually owns the solver.
+ solver->~Solver();
+ new (solver) api::Solver(opts.get());
+}
+
Node Command::termToNode(const api::Term& term) { return term.getNode(); }
std::vector<Node> Command::termVectorToNodes(
try
{
sm->reset();
- Options opts;
- opts.copyValues(getOriginalOptionsFrom(solver));
- // This reconstructs a new solver object at the same memory location as the
- // current one. Note that this command does not own the solver object!
- // It may be safer to instead make the ResetCommand a special case in the
- // CommandExecutor such that this reconstruction can be done within the
- // CommandExecutor, who actually owns the solver.
- solver->~Solver();
- new (solver) api::Solver(&opts);
+ resetSolver(solver);
d_commandStatus = CommandSuccess::instance();
}
catch (exception& e)
*/
bool d_muted;
+ /**
+ * Reset the given solver in-place (keep the object at the same memory
+ * location).
+ */
+ static void resetSolver(api::Solver* solver);
+
protected:
// These methods rely on Command being a friend of classes in the API.
// Subclasses of command should use these methods for conversions,