GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/smt_engine_scope.cpp Lines: 21 21 100.0 %
Date: 2021-09-18 Branches: 14 64 21.9 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andres Noetzli, Andrew Reynolds, Morgan Deters
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
 * [[ Add one-line brief description here ]]
14
 *
15
 * [[ Add lengthier description here ]]
16
 * \todo document this file
17
 */
18
19
#include "smt/smt_engine_scope.h"
20
21
#include "base/check.h"
22
#include "base/configuration_private.h"
23
#include "base/output.h"
24
#include "smt/smt_engine.h"
25
26
namespace cvc5 {
27
namespace smt {
28
29
thread_local SmtEngine* s_smtEngine_current = NULL;
30
31
34443547
SmtEngine* currentSmtEngine() {
32
34443547
  Assert(s_smtEngine_current != NULL);
33
34443547
  return s_smtEngine_current;
34
}
35
36
9709435
bool smtEngineInScope() { return s_smtEngine_current != NULL; }
37
38
7418516
ResourceManager* currentResourceManager()
39
{
40
7418516
  return s_smtEngine_current->getResourceManager();
41
}
42
43
165999
SmtScope::SmtScope(const SmtEngine* smt)
44
    : d_oldSmtEngine(s_smtEngine_current),
45
165999
      d_optionsScope(smt ? &const_cast<SmtEngine*>(smt)->getOptions() : nullptr)
46
{
47
165999
  Assert(smt != NULL);
48
165999
  s_smtEngine_current = const_cast<SmtEngine*>(smt);
49
165999
  Debug("current") << "smt scope: " << s_smtEngine_current << std::endl;
50
165999
}
51
52
326704
SmtScope::~SmtScope() {
53
163352
  s_smtEngine_current = d_oldSmtEngine;
54
326704
  Debug("current") << "smt scope: returning to " << s_smtEngine_current
55
163352
                   << std::endl;
56
163352
}
57
58
2797468
StatisticsRegistry& SmtScope::currentStatisticsRegistry()
59
{
60
2797468
  Assert(smtEngineInScope());
61
2797468
  return s_smtEngine_current->getStatisticsRegistry();
62
}
63
64
}  // namespace smt
65
29574
}  // namespace cvc5