1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Gereon Kremer, Aina Niemetz |
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 |
|
* Smt Environment, main access to global utilities available to |
14 |
|
* internal code. |
15 |
|
*/ |
16 |
|
|
17 |
|
#include "smt/env.h" |
18 |
|
|
19 |
|
#include "context/context.h" |
20 |
|
#include "expr/node.h" |
21 |
|
#include "expr/term_conversion_proof_generator.h" |
22 |
|
#include "options/base_options.h" |
23 |
|
#include "printer/printer.h" |
24 |
|
#include "smt/dump_manager.h" |
25 |
|
#include "smt/smt_engine_stats.h" |
26 |
|
#include "theory/rewriter.h" |
27 |
|
#include "theory/trust_substitutions.h" |
28 |
|
#include "util/resource_manager.h" |
29 |
|
#include "util/statistics_registry.h" |
30 |
|
|
31 |
|
using namespace cvc5::smt; |
32 |
|
|
33 |
|
namespace cvc5 { |
34 |
|
|
35 |
10093 |
Env::Env(NodeManager* nm, Options* opts) |
36 |
10093 |
: d_context(new context::Context()), |
37 |
10093 |
d_userContext(new context::UserContext()), |
38 |
|
d_nodeManager(nm), |
39 |
|
d_proofNodeManager(nullptr), |
40 |
10093 |
d_rewriter(new theory::Rewriter()), |
41 |
20186 |
d_topLevelSubs(new theory::TrustSubstitutionMap(d_userContext.get())), |
42 |
10093 |
d_dumpManager(new DumpManager(d_userContext.get())), |
43 |
|
d_logic(), |
44 |
|
d_statisticsRegistry(std::make_unique<StatisticsRegistry>()), |
45 |
|
d_options(), |
46 |
70651 |
d_resourceManager() |
47 |
|
{ |
48 |
10093 |
if (opts != nullptr) |
49 |
|
{ |
50 |
9253 |
d_options.copyValues(*opts); |
51 |
|
} |
52 |
10093 |
d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options); |
53 |
10093 |
} |
54 |
|
|
55 |
10093 |
Env::~Env() {} |
56 |
|
|
57 |
3600 |
void Env::setProofNodeManager(ProofNodeManager* pnm) |
58 |
|
{ |
59 |
3600 |
Assert(pnm != nullptr); |
60 |
3600 |
Assert(d_proofNodeManager == nullptr); |
61 |
3600 |
d_proofNodeManager = pnm; |
62 |
3600 |
d_rewriter->setProofNodeManager(pnm); |
63 |
3600 |
d_topLevelSubs->setProofNodeManager(pnm); |
64 |
3600 |
} |
65 |
|
|
66 |
10092 |
void Env::shutdown() |
67 |
|
{ |
68 |
10092 |
d_rewriter.reset(nullptr); |
69 |
10092 |
d_dumpManager.reset(nullptr); |
70 |
|
// d_resourceManager must be destroyed before d_statisticsRegistry |
71 |
10092 |
d_resourceManager.reset(nullptr); |
72 |
10092 |
} |
73 |
|
|
74 |
404412 |
context::UserContext* Env::getUserContext() { return d_userContext.get(); } |
75 |
|
|
76 |
12656261 |
context::Context* Env::getContext() { return d_context.get(); } |
77 |
|
|
78 |
1391634 |
NodeManager* Env::getNodeManager() const { return d_nodeManager; } |
79 |
|
|
80 |
9459 |
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; } |
81 |
|
|
82 |
27840804 |
theory::Rewriter* Env::getRewriter() { return d_rewriter.get(); } |
83 |
|
|
84 |
282717 |
theory::TrustSubstitutionMap& Env::getTopLevelSubstitutions() |
85 |
|
{ |
86 |
282717 |
return *d_topLevelSubs.get(); |
87 |
|
} |
88 |
|
|
89 |
21863 |
DumpManager* Env::getDumpManager() { return d_dumpManager.get(); } |
90 |
|
|
91 |
78504 |
const LogicInfo& Env::getLogicInfo() const { return d_logic; } |
92 |
|
|
93 |
4633676 |
StatisticsRegistry& Env::getStatisticsRegistry() |
94 |
|
{ |
95 |
4633676 |
return *d_statisticsRegistry; |
96 |
|
} |
97 |
|
|
98 |
29 |
const Options& Env::getOptions() const { return d_options; } |
99 |
|
|
100 |
36159153 |
ResourceManager* Env::getResourceManager() const |
101 |
|
{ |
102 |
36159153 |
return d_resourceManager.get(); |
103 |
|
} |
104 |
|
|
105 |
10 |
const Printer& Env::getPrinter() |
106 |
|
{ |
107 |
10 |
return *Printer::getPrinter(d_options[options::outputLanguage]); |
108 |
|
} |
109 |
|
|
110 |
|
std::ostream& Env::getDumpOut() { return *d_options.getOut(); } |
111 |
|
|
112 |
28191 |
} // namespace cvc5 |