blob: 6a4e18b5b12e698e9bd0278d3a5477b72ae8e52c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/********************* */
/*! \file command_executor.cpp
** \verbatim
** Original author: kshitij
** Major contributors: mdeters
** Minor contributors (to current version): none
** This file is part of the CVC4 prototype.
** Copyright (c) 2009-2012 New York University and The University of Iowa
** See the file COPYING in the top-level source directory for licensing
** information.\endverbatim
**
** \brief An additional layer between commands and invoking them.
**/
#include <iostream>
#include "main/command_executor.h"
#include "expr/command.h"
#include "main/main.h"
namespace CVC4 {
namespace main {
CommandExecutor::CommandExecutor(ExprManager &exprMgr, Options &options):
d_exprMgr(exprMgr),
d_smtEngine(SmtEngine(&exprMgr)),
d_options(options),
d_stats("driver") {
}
bool CommandExecutor::doCommand(Command* cmd)
{
if( d_options[options::parseOnly] ) {
return true;
}
CommandSequence *seq = dynamic_cast<CommandSequence*>(cmd);
if(seq != NULL) {
// assume no error
bool status = true;
for(CommandSequence::iterator subcmd = seq->begin();
status && subcmd != seq->end();
++subcmd) {
status = doCommand(*subcmd);
}
return status;
} else {
if(d_options[options::verbosity] > 2) {
*d_options[options::out] << "Invoking: " << *cmd << std::endl;
}
return doCommandSingleton(cmd);
}
}
bool CommandExecutor::doCommandSingleton(Command *cmd)
{
bool status = true;
if(d_options[options::verbosity] >= -1) {
status = smtEngineInvoke(&d_smtEngine, cmd, d_options[options::out]);
} else {
status = smtEngineInvoke(&d_smtEngine, cmd, NULL);
}
return status;
}
std::string CommandExecutor::getSmtEngineStatus()
{
return d_smtEngine.getInfo("status").getValue();
}
bool smtEngineInvoke(SmtEngine* smt, Command* cmd, std::ostream *out)
{
if(out == NULL) {
cmd->invoke(smt);
} else {
cmd->invoke(smt, *out);
}
return !cmd->fail();
}
}/* CVC4::main namespace */
}/* CVC4 namespace */
|