GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/env.cpp Lines: 47 48 97.9 %
Date: 2021-08-17 Branches: 28 74 37.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 "options/smt_options.h"
23
#include "printer/printer.h"
24
#include "proof/conv_proof_generator.h"
25
#include "smt/dump_manager.h"
26
#include "smt/smt_engine_stats.h"
27
#include "theory/rewriter.h"
28
#include "theory/trust_substitutions.h"
29
#include "util/resource_manager.h"
30
#include "util/statistics_registry.h"
31
32
using namespace cvc5::smt;
33
34
namespace cvc5 {
35
36
10494
Env::Env(NodeManager* nm, Options* opts)
37
10494
    : d_context(new context::Context()),
38
10494
      d_userContext(new context::UserContext()),
39
      d_nodeManager(nm),
40
      d_proofNodeManager(nullptr),
41
10494
      d_rewriter(new theory::Rewriter()),
42
20988
      d_topLevelSubs(new theory::TrustSubstitutionMap(d_userContext.get())),
43
10494
      d_dumpManager(new DumpManager(d_userContext.get())),
44
      d_logic(),
45
      d_statisticsRegistry(std::make_unique<StatisticsRegistry>()),
46
      d_options(),
47
      d_originalOptions(opts),
48
73458
      d_resourceManager()
49
{
50
10494
  if (opts != nullptr)
51
  {
52
9620
    d_options.copyValues(*opts);
53
  }
54
10494
  d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options);
55
10494
}
56
57
10494
Env::~Env() {}
58
59
3766
void Env::setProofNodeManager(ProofNodeManager* pnm)
60
{
61
3766
  Assert(pnm != nullptr);
62
3766
  Assert(d_proofNodeManager == nullptr);
63
3766
  d_proofNodeManager = pnm;
64
3766
  d_rewriter->setProofNodeManager(pnm);
65
3766
  d_topLevelSubs->setProofNodeManager(pnm);
66
3766
}
67
68
10494
void Env::shutdown()
69
{
70
10494
  d_rewriter.reset(nullptr);
71
10494
  d_dumpManager.reset(nullptr);
72
  // d_resourceManager must be destroyed before d_statisticsRegistry
73
10494
  d_resourceManager.reset(nullptr);
74
10494
}
75
76
927916
context::UserContext* Env::getUserContext() { return d_userContext.get(); }
77
78
33463027
context::Context* Env::getContext() { return d_context.get(); }
79
80
1388184
NodeManager* Env::getNodeManager() const { return d_nodeManager; }
81
82
37130
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; }
83
84
137942
bool Env::isTheoryProofProducing() const
85
{
86
137942
  return d_proofNodeManager != nullptr
87
155372
         && (!d_options.smt.unsatCores
88
52724
             || d_options.smt.unsatCoresMode
89
137942
                    == options::UnsatCoresMode::FULL_PROOF);
90
}
91
92
31995286
theory::Rewriter* Env::getRewriter() { return d_rewriter.get(); }
93
94
352460
theory::TrustSubstitutionMap& Env::getTopLevelSubstitutions()
95
{
96
352460
  return *d_topLevelSubs.get();
97
}
98
99
22704
DumpManager* Env::getDumpManager() { return d_dumpManager.get(); }
100
101
304776
const LogicInfo& Env::getLogicInfo() const { return d_logic; }
102
103
4690189
StatisticsRegistry& Env::getStatisticsRegistry()
104
{
105
4690189
  return *d_statisticsRegistry;
106
}
107
108
138390
const Options& Env::getOptions() const { return d_options; }
109
110
const Options& Env::getOriginalOptions() const { return *d_originalOptions; }
111
112
15687227
ResourceManager* Env::getResourceManager() const
113
{
114
15687227
  return d_resourceManager.get();
115
}
116
117
10
const Printer& Env::getPrinter()
118
{
119
10
  return *Printer::getPrinter(d_options.base.outputLanguage);
120
}
121
122
9
std::ostream& Env::getDumpOut() { return *d_options.base.out; }
123
124
29337
}  // namespace cvc5