bool status = true;
if (opts.driver.interactive && inputFromStdin)
{
- if (opts.driver.tearDownIncremental > 0)
- {
- throw Exception(
- "--tear-down-incremental doesn't work in interactive mode");
- }
if (!opts.base.incrementalSolvingWasSetByUser)
{
cmd.reset(new SetOptionCommand("incremental", "true"));
}
}
}
- else if (opts.driver.tearDownIncremental > 0)
- {
- if (!opts.base.incrementalSolving
- && opts.driver.tearDownIncremental > 1)
- {
- // For tear-down-incremental values greater than 1, need incremental
- // on too.
- cmd.reset(new SetOptionCommand("incremental", "true"));
- cmd->setMuted(true);
- pExecutor->doCommand(cmd);
- // if(opts.base.incrementalWasSetByUser) {
- // throw OptionException(
- // "--tear-down-incremental incompatible with --incremental");
- // }
-
- // cmd.reset(new SetOptionCommand("incremental", "false"));
- // cmd->setMuted(true);
- // pExecutor->doCommand(cmd);
- }
-
- ParserBuilder parserBuilder(pExecutor->getSolver(),
- pExecutor->getSymbolManager(),
- opts);
- std::unique_ptr<Parser> parser(parserBuilder.build());
- if( inputFromStdin ) {
- parser->setInput(Input::newStreamInput(
- opts.base.inputLanguage, cin, filename));
- }
- else
- {
- parser->setInput(Input::newFileInput(opts.base.inputLanguage,
- filename,
- opts.parser.memoryMap));
- }
-
- vector< vector<Command*> > allCommands;
- allCommands.push_back(vector<Command*>());
- int needReset = 0;
- // true if one of the commands was interrupted
- bool interrupted = false;
- while (status)
- {
- if (interrupted) {
- *opts.base.out << CommandInterrupted();
- break;
- }
-
- try {
- cmd.reset(parser->nextCommand());
- if (cmd == nullptr) break;
- } catch (UnsafeInterruptException& e) {
- interrupted = true;
- continue;
- }
-
- if(dynamic_cast<PushCommand*>(cmd.get()) != nullptr) {
- if (needReset >= opts.driver.tearDownIncremental)
- {
- pExecutor->reset();
- for(size_t i = 0; i < allCommands.size() && !interrupted; ++i) {
- if (interrupted) break;
- for(size_t j = 0; j < allCommands[i].size() && !interrupted; ++j)
- {
- Command* ccmd = allCommands[i][j]->clone();
- ccmd->setMuted(true);
- pExecutor->doCommand(ccmd);
- if (ccmd->interrupted())
- {
- interrupted = true;
- }
- delete ccmd;
- }
- }
- needReset = 0;
- }
- allCommands.push_back(vector<Command*>());
- Command* copy = cmd->clone();
- allCommands.back().push_back(copy);
- status = pExecutor->doCommand(cmd);
- if(cmd->interrupted()) {
- interrupted = true;
- continue;
- }
- } else if(dynamic_cast<PopCommand*>(cmd.get()) != nullptr) {
- allCommands.pop_back(); // fixme leaks cmds here
- if (needReset >= opts.driver.tearDownIncremental)
- {
- pExecutor->reset();
- for(size_t i = 0; i < allCommands.size() && !interrupted; ++i) {
- for(size_t j = 0; j < allCommands[i].size() && !interrupted; ++j)
- {
- std::unique_ptr<Command> ccmd(allCommands[i][j]->clone());
- ccmd->setMuted(true);
- pExecutor->doCommand(ccmd);
- if (ccmd->interrupted())
- {
- interrupted = true;
- }
- }
- }
- if (interrupted) continue;
- *opts.base.out << CommandSuccess();
- needReset = 0;
- }
- else
- {
- status = pExecutor->doCommand(cmd);
- if(cmd->interrupted()) {
- interrupted = true;
- continue;
- }
- }
- } else if(dynamic_cast<CheckSatCommand*>(cmd.get()) != nullptr ||
- dynamic_cast<QueryCommand*>(cmd.get()) != nullptr) {
- if (needReset >= opts.driver.tearDownIncremental)
- {
- pExecutor->reset();
- for(size_t i = 0; i < allCommands.size() && !interrupted; ++i) {
- for(size_t j = 0; j < allCommands[i].size() && !interrupted; ++j)
- {
- Command* ccmd = allCommands[i][j]->clone();
- ccmd->setMuted(true);
- pExecutor->doCommand(ccmd);
- if (ccmd->interrupted())
- {
- interrupted = true;
- }
- delete ccmd;
- }
- }
- needReset = 0;
- }
- else
- {
- ++needReset;
- }
- if (interrupted) {
- continue;
- }
-
- status = pExecutor->doCommand(cmd);
- if(cmd->interrupted()) {
- interrupted = true;
- continue;
- }
- } else if(dynamic_cast<ResetCommand*>(cmd.get()) != nullptr) {
- pExecutor->doCommand(cmd);
- allCommands.clear();
- allCommands.push_back(vector<Command*>());
- } else {
- // We shouldn't copy certain commands, because they can cause
- // an error on replay since there's no associated sat/unsat check
- // preceding them.
- if(dynamic_cast<GetUnsatCoreCommand*>(cmd.get()) == nullptr &&
- dynamic_cast<GetProofCommand*>(cmd.get()) == nullptr &&
- dynamic_cast<GetValueCommand*>(cmd.get()) == nullptr &&
- dynamic_cast<GetModelCommand*>(cmd.get()) == nullptr &&
- dynamic_cast<GetAssignmentCommand*>(cmd.get()) == nullptr &&
- dynamic_cast<GetInstantiationsCommand*>(cmd.get()) == nullptr &&
- dynamic_cast<GetAssertionsCommand*>(cmd.get()) == nullptr &&
- dynamic_cast<GetInfoCommand*>(cmd.get()) == nullptr &&
- dynamic_cast<GetOptionCommand*>(cmd.get()) == nullptr &&
- dynamic_cast<EchoCommand*>(cmd.get()) == nullptr) {
- Command* copy = cmd->clone();
- allCommands.back().push_back(copy);
- }
- status = pExecutor->doCommand(cmd);
- if(cmd->interrupted()) {
- interrupted = true;
- continue;
- }
-
- if(dynamic_cast<QuitCommand*>(cmd.get()) != nullptr) {
- break;
- }
- }
- }
- }
else
{
if (!opts.base.incrementalSolvingWasSetByUser)