GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/env.cpp Lines: 42 43 97.7 %
Date: 2021-08-16 Branches: 23 68 33.8 %

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
10497
Env::Env(NodeManager* nm, Options* opts)
36
10497
    : d_context(new context::Context()),
37
10497
      d_userContext(new context::UserContext()),
38
      d_nodeManager(nm),
39
      d_proofNodeManager(nullptr),
40
10497
      d_rewriter(new theory::Rewriter()),
41
20994
      d_topLevelSubs(new theory::TrustSubstitutionMap(d_userContext.get())),
42
10497
      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
73479
      d_resourceManager()
48
{
49
10497
  if (opts != nullptr)
50
  {
51
9623
    d_options.copyValues(*opts);
52
  }
53
10497
  d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options);
54
10497
}
55
56
10497
Env::~Env() {}
57
58
3768
void Env::setProofNodeManager(ProofNodeManager* pnm)
59
{
60
3768
  Assert(pnm != nullptr);
61
3768
  Assert(d_proofNodeManager == nullptr);
62
3768
  d_proofNodeManager = pnm;
63
3768
  d_rewriter->setProofNodeManager(pnm);
64
3768
  d_topLevelSubs->setProofNodeManager(pnm);
65
3768
}
66
67
10497
void Env::shutdown()
68
{
69
10497
  d_rewriter.reset(nullptr);
70
10497
  d_dumpManager.reset(nullptr);
71
  // d_resourceManager must be destroyed before d_statisticsRegistry
72
10497
  d_resourceManager.reset(nullptr);
73
10497
}
74
75
431996
context::UserContext* Env::getUserContext() { return d_userContext.get(); }
76
77
14663710
context::Context* Env::getContext() { return d_context.get(); }
78
79
1388263
NodeManager* Env::getNodeManager() const { return d_nodeManager; }
80
81
19706
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; }
82
83
32470498
theory::Rewriter* Env::getRewriter() { return d_rewriter.get(); }
84
85
352373
theory::TrustSubstitutionMap& Env::getTopLevelSubstitutions()
86
{
87
352373
  return *d_topLevelSubs.get();
88
}
89
90
22710
DumpManager* Env::getDumpManager() { return d_dumpManager.get(); }
91
92
82719
const LogicInfo& Env::getLogicInfo() const { return d_logic; }
93
94
4691598
StatisticsRegistry& Env::getStatisticsRegistry()
95
{
96
4691598
  return *d_statisticsRegistry;
97
}
98
99
138272
const Options& Env::getOptions() const { return d_options; }
100
101
const Options& Env::getOriginalOptions() const { return *d_originalOptions; }
102
103
16097082
ResourceManager* Env::getResourceManager() const
104
{
105
16097082
  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
9
std::ostream& Env::getDumpOut() { return *d_options.base.out; }
114
115
29340
}  // namespace cvc5