GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/solver_engine_scope.cpp Lines: 19 21 90.5 %
Date: 2021-11-07 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/solver_engine_scope.h"
20
21
#include "base/check.h"
22
#include "base/configuration_private.h"
23
#include "base/output.h"
24
#include "smt/solver_engine.h"
25
26
namespace cvc5 {
27
namespace smt {
28
29
thread_local SolverEngine* s_slvEngine_current = nullptr;
30
31
47096618
SolverEngine* currentSolverEngine()
32
{
33
47096618
  Assert(s_slvEngine_current != nullptr);
34
47096618
  return s_slvEngine_current;
35
}
36
37
4816652
bool solverEngineInScope() { return s_slvEngine_current != nullptr; }
38
39
ResourceManager* currentResourceManager()
40
{
41
  return s_slvEngine_current->getResourceManager();
42
}
43
44
211368
SolverEngineScope::SolverEngineScope(const SolverEngine* smt)
45
    : d_oldSlvEngine(s_slvEngine_current),
46
      d_optionsScope(smt ? &const_cast<SolverEngine*>(smt)->getOptions()
47
211368
                         : nullptr)
48
{
49
211368
  Assert(smt != nullptr);
50
211368
  s_slvEngine_current = const_cast<SolverEngine*>(smt);
51
211368
  Debug("current") << "smt scope: " << s_slvEngine_current << std::endl;
52
211368
}
53
54
417238
SolverEngineScope::~SolverEngineScope()
55
{
56
208619
  s_slvEngine_current = d_oldSlvEngine;
57
417238
  Debug("current") << "smt scope: returning to " << s_slvEngine_current
58
208619
                   << std::endl;
59
208619
}
60
61
4310517
StatisticsRegistry& SolverEngineScope::currentStatisticsRegistry()
62
{
63
4310517
  Assert(solverEngineInScope());
64
4310517
  return s_slvEngine_current->getStatisticsRegistry();
65
}
66
67
}  // namespace smt
68
31137
}  // namespace cvc5