GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/env.cpp Lines: 41 43 95.3 %
Date: 2021-08-01 Branches: 23 70 32.9 %

Line Exec Source
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 "options/base_options.h"
22
#include "printer/printer.h"
23
#include "proof/conv_proof_generator.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
10481
Env::Env(NodeManager* nm, Options* opts)
36
10481
    : d_context(new context::Context()),
37
10481
      d_userContext(new context::UserContext()),
38
      d_nodeManager(nm),
39
      d_proofNodeManager(nullptr),
40
10481
      d_rewriter(new theory::Rewriter()),
41
20962
      d_topLevelSubs(new theory::TrustSubstitutionMap(d_userContext.get())),
42
10481
      d_dumpManager(new DumpManager(d_userContext.get())),
43
      d_logic(),
44
      d_statisticsRegistry(std::make_unique<StatisticsRegistry>()),
45
      d_options(),
46
      d_originalOptions(opts),
47
73367
      d_resourceManager()
48
{
49
10481
  if (opts != nullptr)
50
  {
51
9607
    d_options.copyValues(*opts);
52
  }
53
10481
  d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options);
54
10481
}
55
56
10481
Env::~Env() {}
57
58
3756
void Env::setProofNodeManager(ProofNodeManager* pnm)
59
{
60
3756
  Assert(pnm != nullptr);
61
3756
  Assert(d_proofNodeManager == nullptr);
62
3756
  d_proofNodeManager = pnm;
63
3756
  d_rewriter->setProofNodeManager(pnm);
64
3756
  d_topLevelSubs->setProofNodeManager(pnm);
65
3756
}
66
67
10480
void Env::shutdown()
68
{
69
10480
  d_rewriter.reset(nullptr);
70
10480
  d_dumpManager.reset(nullptr);
71
  // d_resourceManager must be destroyed before d_statisticsRegistry
72
10480
  d_resourceManager.reset(nullptr);
73
10480
}
74
75
431306
context::UserContext* Env::getUserContext() { return d_userContext.get(); }
76
77
12894826
context::Context* Env::getContext() { return d_context.get(); }
78
79
1398905
NodeManager* Env::getNodeManager() const { return d_nodeManager; }
80
81
19676
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; }
82
83
32198946
theory::Rewriter* Env::getRewriter() { return d_rewriter.get(); }
84
85
349956
theory::TrustSubstitutionMap& Env::getTopLevelSubstitutions()
86
{
87
349956
  return *d_topLevelSubs.get();
88
}
89
90
22679
DumpManager* Env::getDumpManager() { return d_dumpManager.get(); }
91
92
82624
const LogicInfo& Env::getLogicInfo() const { return d_logic; }
93
94
4654455
StatisticsRegistry& Env::getStatisticsRegistry()
95
{
96
4654455
  return *d_statisticsRegistry;
97
}
98
99
138118
const Options& Env::getOptions() const { return d_options; }
100
101
const Options& Env::getOriginalOptions() const { return *d_originalOptions; }
102
103
15880009
ResourceManager* Env::getResourceManager() const
104
{
105
15880009
  return d_resourceManager.get();
106
}
107
108
10
const Printer& Env::getPrinter()
109
{
110
10
  return *Printer::getPrinter(d_options.base.outputLanguage);
111
}
112
113
std::ostream& Env::getDumpOut() { return *d_options.base.out; }
114
115
29280
}  // namespace cvc5