1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Abdalrhman Mohamed |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Implements listener classes for SMT engine. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "smt/listeners.h" |
17 |
|
|
18 |
|
#include "base/configuration.h" |
19 |
|
#include "expr/attribute.h" |
20 |
|
#include "expr/node_manager_attributes.h" |
21 |
|
#include "options/smt_options.h" |
22 |
|
#include "printer/printer.h" |
23 |
|
#include "smt/dump.h" |
24 |
|
#include "smt/dump_manager.h" |
25 |
|
#include "smt/node_command.h" |
26 |
|
#include "smt/smt_engine.h" |
27 |
|
#include "smt/smt_engine_scope.h" |
28 |
|
|
29 |
|
namespace cvc5 { |
30 |
|
namespace smt { |
31 |
|
|
32 |
13173 |
ResourceOutListener::ResourceOutListener(SmtEngine& smt) : d_smt(smt) {} |
33 |
|
|
34 |
|
void ResourceOutListener::notify() |
35 |
|
{ |
36 |
|
SmtScope scope(&d_smt); |
37 |
|
Assert(smt::smtEngineInScope()); |
38 |
|
d_smt.interrupt(); |
39 |
|
} |
40 |
|
|
41 |
13173 |
SmtNodeManagerListener::SmtNodeManagerListener(DumpManager& dm, |
42 |
13173 |
OutputManager& outMgr) |
43 |
13173 |
: d_dm(dm), d_outMgr(outMgr) |
44 |
|
{ |
45 |
13173 |
} |
46 |
|
|
47 |
8404 |
void SmtNodeManagerListener::nmNotifyNewSort(TypeNode tn, uint32_t flags) |
48 |
|
{ |
49 |
16808 |
DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()), 0, tn); |
50 |
8404 |
if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0) |
51 |
|
{ |
52 |
6400 |
d_dm.addToDump(c); |
53 |
|
} |
54 |
8404 |
} |
55 |
|
|
56 |
97 |
void SmtNodeManagerListener::nmNotifyNewSortConstructor(TypeNode tn, |
57 |
|
uint32_t flags) |
58 |
|
{ |
59 |
194 |
DeclareTypeNodeCommand c(tn.getAttribute(expr::VarNameAttr()), |
60 |
97 |
tn.getAttribute(expr::SortArityAttr()), |
61 |
388 |
tn); |
62 |
97 |
if ((flags & NodeManager::SORT_FLAG_PLACEHOLDER) == 0) |
63 |
|
{ |
64 |
97 |
d_dm.addToDump(c); |
65 |
|
} |
66 |
97 |
} |
67 |
|
|
68 |
4443 |
void SmtNodeManagerListener::nmNotifyNewDatatypes( |
69 |
|
const std::vector<TypeNode>& dtts, uint32_t flags) |
70 |
|
{ |
71 |
4443 |
if ((flags & NodeManager::DATATYPE_FLAG_PLACEHOLDER) == 0) |
72 |
|
{ |
73 |
3368 |
if (Configuration::isAssertionBuild()) |
74 |
|
{ |
75 |
7095 |
for (CVC5_UNUSED const TypeNode& dt : dtts) |
76 |
|
{ |
77 |
3727 |
Assert(dt.isDatatype()); |
78 |
|
} |
79 |
|
} |
80 |
6736 |
DeclareDatatypeNodeCommand c(dtts); |
81 |
3368 |
d_dm.addToDump(c); |
82 |
|
} |
83 |
4443 |
} |
84 |
|
|
85 |
177808 |
void SmtNodeManagerListener::nmNotifyNewVar(TNode n) |
86 |
|
{ |
87 |
|
DeclareFunctionNodeCommand c( |
88 |
355616 |
n.getAttribute(expr::VarNameAttr()), n, n.getType()); |
89 |
177808 |
d_dm.addToDump(c); |
90 |
177808 |
} |
91 |
|
|
92 |
95666 |
void SmtNodeManagerListener::nmNotifyNewSkolem(TNode n, |
93 |
|
const std::string& comment, |
94 |
|
uint32_t flags) |
95 |
|
{ |
96 |
191332 |
std::string id = n.getAttribute(expr::VarNameAttr()); |
97 |
191332 |
DeclareFunctionNodeCommand c(id, n, n.getType()); |
98 |
95666 |
if (Dump.isOn("skolems") && comment != "") |
99 |
|
{ |
100 |
|
d_outMgr.getPrinter().toStreamCmdComment(d_outMgr.getDumpOut(), |
101 |
|
id + " is " + comment); |
102 |
|
} |
103 |
95666 |
d_dm.addToDump(c, "skolems"); |
104 |
95666 |
} |
105 |
|
|
106 |
|
} // namespace smt |
107 |
29511 |
} // namespace cvc5 |