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 |
34902736 |
SmtEngine* currentSmtEngine() { |
32 |
34902736 |
Assert(s_smtEngine_current != NULL); |
33 |
34902736 |
return s_smtEngine_current; |
34 |
|
} |
35 |
|
|
36 |
9696464 |
bool smtEngineInScope() { return s_smtEngine_current != NULL; } |
37 |
|
|
38 |
7414957 |
ResourceManager* currentResourceManager() |
39 |
|
{ |
40 |
7414957 |
return s_smtEngine_current->getResourceManager(); |
41 |
|
} |
42 |
|
|
43 |
165760 |
SmtScope::SmtScope(const SmtEngine* smt) |
44 |
|
: NodeManagerScope(smt->getNodeManager()), |
45 |
|
d_oldSmtEngine(s_smtEngine_current), |
46 |
165760 |
d_optionsScope(smt ? &const_cast<SmtEngine*>(smt)->getOptions() : nullptr) |
47 |
|
{ |
48 |
165760 |
Assert(smt != NULL); |
49 |
165760 |
s_smtEngine_current = const_cast<SmtEngine*>(smt); |
50 |
165760 |
Debug("current") << "smt scope: " << s_smtEngine_current << std::endl; |
51 |
165760 |
} |
52 |
|
|
53 |
326236 |
SmtScope::~SmtScope() { |
54 |
163118 |
s_smtEngine_current = d_oldSmtEngine; |
55 |
326236 |
Debug("current") << "smt scope: returning to " << s_smtEngine_current |
56 |
163118 |
<< std::endl; |
57 |
163118 |
} |
58 |
|
|
59 |
2790971 |
StatisticsRegistry& SmtScope::currentStatisticsRegistry() |
60 |
|
{ |
61 |
2790971 |
Assert(smtEngineInScope()); |
62 |
2790971 |
return s_smtEngine_current->getStatisticsRegistry(); |
63 |
|
} |
64 |
|
|
65 |
|
} // namespace smt |
66 |
29514 |
} // namespace cvc5 |