diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/expr/expr_manager_template.cpp | 18 | ||||
-rw-r--r-- | src/expr/expr_manager_template.h | 8 | ||||
-rw-r--r-- | src/expr/node_manager.h | 4 | ||||
-rw-r--r-- | src/main/driver.cpp | 1 | ||||
-rw-r--r-- | src/main/driver_portfolio.cpp | 7 | ||||
-rw-r--r-- | src/smt/Makefile.am | 2 | ||||
-rw-r--r-- | src/smt/smt_engine.cpp | 68 | ||||
-rw-r--r-- | src/smt/smt_engine.h | 4 | ||||
-rw-r--r-- | src/smt/smt_engine_scope.cpp | 10 | ||||
-rw-r--r-- | src/smt/smt_engine_scope.h | 40 | ||||
-rw-r--r-- | src/util/stats.cpp | 24 | ||||
-rw-r--r-- | src/util/stats.h | 3 |
12 files changed, 132 insertions, 57 deletions
diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp index 1db534dc4..25578399f 100644 --- a/src/expr/expr_manager_template.cpp +++ b/src/expr/expr_manager_template.cpp @@ -40,7 +40,7 @@ ${includes} stringstream statName; \ statName << "expr::ExprManager::" << kind; \ d_exprStatistics[kind] = new IntStat(statName.str(), 0); \ - StatisticsRegistry::registerStat(d_exprStatistics[kind]); \ + d_nodeManager->getStatisticsRegistry()->registerStat_(d_exprStatistics[kind]); \ } \ ++ *(d_exprStatistics[kind]); \ } @@ -56,7 +56,7 @@ ${includes} statName << "expr::ExprManager::VARIABLE:" << type; \ } \ d_exprStatisticsVars[type] = new IntStat(statName.str(), 0); \ - StatisticsRegistry::registerStat(d_exprStatisticsVars[type]); \ + d_nodeManager->getStatisticsRegistry()->registerStat_(d_exprStatisticsVars[type]); \ } \ ++ *(d_exprStatisticsVars[type]); \ } @@ -78,7 +78,7 @@ ExprManager::ExprManager() : for (unsigned i = 0; i < kind::LAST_KIND; ++ i) { d_exprStatistics[i] = NULL; } - for (unsigned i = 0; i <= LAST_TYPE; ++ i) { + for (unsigned i = 0; i < LAST_TYPE; ++ i) { d_exprStatisticsVars[i] = NULL; } #endif @@ -88,7 +88,7 @@ ExprManager::ExprManager(const Options& options) : d_ctxt(new Context()), d_nodeManager(new NodeManager(d_ctxt, this, options)) { #ifdef CVC4_STATISTICS_ON - for (unsigned i = 0; i <= LAST_TYPE; ++ i) { + for (unsigned i = 0; i < LAST_TYPE; ++ i) { d_exprStatisticsVars[i] = NULL; } for (unsigned i = 0; i < kind::LAST_KIND; ++ i) { @@ -105,13 +105,13 @@ ExprManager::~ExprManager() throw() { #ifdef CVC4_STATISTICS_ON for (unsigned i = 0; i < kind::LAST_KIND; ++ i) { if (d_exprStatistics[i] != NULL) { - StatisticsRegistry::unregisterStat(d_exprStatistics[i]); + d_nodeManager->getStatisticsRegistry()->unregisterStat_(d_exprStatistics[i]); delete d_exprStatistics[i]; } } - for (unsigned i = 0; i <= LAST_TYPE; ++ i) { + for (unsigned i = 0; i < LAST_TYPE; ++ i) { if (d_exprStatisticsVars[i] != NULL) { - StatisticsRegistry::unregisterStat(d_exprStatisticsVars[i]); + d_nodeManager->getStatisticsRegistry()->unregisterStat_(d_exprStatisticsVars[i]); delete d_exprStatisticsVars[i]; } } @@ -886,6 +886,10 @@ Context* ExprManager::getContext() const { return d_ctxt; } +StatisticsRegistry* ExprManager::getStatisticsRegistry() const throw() { + return d_nodeManager->getStatisticsRegistry(); +} + namespace expr { Node exportInternal(TNode n, ExprManager* from, ExprManager* to, ExprManagerMapCollection& vmap); diff --git a/src/expr/expr_manager_template.h b/src/expr/expr_manager_template.h index 9d0b8d34a..fdc1e1159 100644 --- a/src/expr/expr_manager_template.h +++ b/src/expr/expr_manager_template.h @@ -27,6 +27,7 @@ #include "expr/type.h" #include "expr/expr.h" #include "util/subrange_bound.h" +#include "util/stats.h" ${includes} @@ -34,7 +35,7 @@ ${includes} // compiler directs the user to the template file instead of the // generated one. We don't want the user to modify the generated one, // since it'll get overwritten on a later build. -#line 38 "${template}" +#line 39 "${template}" namespace CVC4 { @@ -64,7 +65,7 @@ private: NodeManager* d_nodeManager; /** Counts of expressions and variables created of a given kind */ - IntStat* d_exprStatisticsVars[LAST_TYPE + 1]; + IntStat* d_exprStatisticsVars[LAST_TYPE]; IntStat* d_exprStatistics[kind::LAST_KIND]; /** @@ -450,6 +451,9 @@ public: Expr mkVar(const std::string& name, Type type); Expr mkVar(Type type); + /** Get a reference to the statistics registry for this ExprManager */ + StatisticsRegistry* getStatisticsRegistry() const throw(); + /** Export an expr to a different ExprManager */ //static Expr exportExpr(const Expr& e, ExprManager* em); /** Export a type to a different ExprManager */ diff --git a/src/expr/node_manager.h b/src/expr/node_manager.h index 6ce96e70a..6c34eb4a3 100644 --- a/src/expr/node_manager.h +++ b/src/expr/node_manager.h @@ -277,7 +277,7 @@ public: } /** Get this node manager's statistics registry */ - StatisticsRegistry* getStatisticsRegistry() const { + StatisticsRegistry* getStatisticsRegistry() const throw() { return d_statisticsRegistry; } @@ -802,7 +802,7 @@ public: Debug("current") << "node manager scope: " << "returning to " << NodeManager::s_current << "\n"; } -}; +};/* class NodeManagerScope */ template <class AttrKind> diff --git a/src/main/driver.cpp b/src/main/driver.cpp index eda5df2ca..f24526e6c 100644 --- a/src/main/driver.cpp +++ b/src/main/driver.cpp @@ -240,6 +240,7 @@ int runCvc4(int argc, char* argv[], Options& options) { // signal handlers need access pStatistics = smt.getStatisticsRegistry(); + pStatistics->registerStat_(exprMgr.getStatisticsRegistry()); // Timer statistic RegisterStatistic statTotalTime(exprMgr, &s_totalTime); diff --git a/src/main/driver_portfolio.cpp b/src/main/driver_portfolio.cpp index 0698d5157..d93e9f872 100644 --- a/src/main/driver_portfolio.cpp +++ b/src/main/driver_portfolio.cpp @@ -409,7 +409,7 @@ int runCvc4(int argc, char *argv[], Options& options) { theStatisticsRegistry.registerStat_((&driverStatisticsRegistry)); // Timer statistic - RegisterStatistic* statTotatTime = + RegisterStatistic* statTotalTime = new RegisterStatistic(&driverStatisticsRegistry, &s_totalTime); RegisterStatistic* statBeforePortfolioTime = new RegisterStatistic(&driverStatisticsRegistry, &s_beforePortfolioTime); @@ -521,7 +521,8 @@ int runCvc4(int argc, char *argv[], Options& options) { // Register the statistics registry of the thread string tag = "thread #" + boost::lexical_cast<string>(threadOptions[i].thread_id); smts[i]->getStatisticsRegistry()->setName(tag); - theStatisticsRegistry.registerStat_( (Stat*)smts[i]->getStatisticsRegistry() ); + theStatisticsRegistry.registerStat_( smts[i]->getStatisticsRegistry() ); + theStatisticsRegistry.registerStat_( exprMgrs[i]->getStatisticsRegistry() ); } /************************* Lemma sharing init ************************/ @@ -635,7 +636,7 @@ int runCvc4(int argc, char *argv[], Options& options) { //delete vmaps; - delete statTotatTime; + delete statTotalTime; delete statBeforePortfolioTime; delete statFilenameReg; diff --git a/src/smt/Makefile.am b/src/smt/Makefile.am index 3e777ec89..5cc0cedd1 100644 --- a/src/smt/Makefile.am +++ b/src/smt/Makefile.am @@ -8,6 +8,8 @@ noinst_LTLIBRARIES = libsmt.la libsmt_la_SOURCES = \ smt_engine.cpp \ smt_engine.h \ + smt_engine_scope.cpp \ + smt_engine_scope.h \ modal_exception.h \ bad_option_exception.h \ no_such_function_exception.h diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp index 4cccb8d10..01ce73be1 100644 --- a/src/smt/smt_engine.cpp +++ b/src/smt/smt_engine.cpp @@ -38,6 +38,7 @@ #include "smt/modal_exception.h" #include "smt/no_such_function_exception.h" #include "smt/smt_engine.h" +#include "smt/smt_engine_scope.h" #include "theory/theory_engine.h" #include "proof/proof_manager.h" #include "util/proof.h" @@ -48,16 +49,9 @@ #include "util/output.h" #include "util/hash.h" #include "theory/substitutions.h" -#include "theory/builtin/theory_builtin.h" -#include "theory/booleans/theory_bool.h" -#include "theory/booleans/circuit_propagator.h" -#include "theory/uf/theory_uf.h" -#include "theory/arith/theory_arith.h" -#include "theory/arrays/theory_arrays.h" -#include "theory/bv/theory_bv.h" -#include "theory/datatypes/theory_datatypes.h" #include "theory/theory_traits.h" #include "theory/logic_info.h" +#include "theory/booleans/circuit_propagator.h" #include "util/ite_removal.h" #include "theory/model.h" @@ -265,6 +259,7 @@ SmtEngine::SmtEngine(ExprManager* em) throw(AssertionException) : d_cumulativeResourceUsed(0), d_status(), d_private(new smt::SmtEnginePrivate(*this)), + d_statisticsRegistry(new StatisticsRegistry()), d_definitionExpansionTime("smt::SmtEngine::definitionExpansionTime"), d_nonclausalSimplificationTime("smt::SmtEngine::nonclausalSimplificationTime"), d_numConstantProps("smt::SmtEngine::numConstantProps", 0), @@ -277,7 +272,7 @@ SmtEngine::SmtEngine(ExprManager* em) throw(AssertionException) : d_numAssertionsPre("smt::SmtEngine::numAssertionsPreITERemoval", 0), d_numAssertionsPost("smt::SmtEngine::numAssertionsPostITERemoval", 0) { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); StatisticsRegistry::registerStat(&d_definitionExpansionTime); StatisticsRegistry::registerStat(&d_nonclausalSimplificationTime); @@ -382,7 +377,7 @@ void SmtEngine::shutdown() { } SmtEngine::~SmtEngine() throw() { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); try { while(Options::current()->incrementalSolving && d_userContext->getLevel() > 1) { @@ -424,6 +419,9 @@ SmtEngine::~SmtEngine() throw() { delete d_theoryEngine; delete d_propEngine; //delete d_decisionEngine; + + delete d_statisticsRegistry; + } catch(Exception& e) { Warning() << "CVC4 threw an exception during cleanup." << endl << e << endl; @@ -431,7 +429,7 @@ SmtEngine::~SmtEngine() throw() { } void SmtEngine::setLogic(const LogicInfo& logic) throw(ModalException) { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); if(Dump.isOn("benchmark")) { Dump("benchmark") << SetBenchmarkLogicCommand(logic.getLogicString()); @@ -442,7 +440,7 @@ void SmtEngine::setLogic(const LogicInfo& logic) throw(ModalException) { } void SmtEngine::setLogic(const std::string& s) throw(ModalException) { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); setLogic(LogicInfo(s)); } @@ -605,7 +603,7 @@ void SmtEngine::setLogicInternal() throw(AssertionException) { void SmtEngine::setInfo(const std::string& key, const SExpr& value) throw(BadOptionException, ModalException) { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); Trace("smt") << "SMT setInfo(" << key << ", " << value << ")" << endl; if(Dump.isOn("benchmark")) { @@ -629,7 +627,7 @@ void SmtEngine::setInfo(const std::string& key, const SExpr& value) if(! value.isAtom()) { throw BadOptionException("argument to (set-info :cvc4-logic ..) must be a string"); } - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); d_logic = value.getValue(); setLogicInternal(); return; @@ -664,7 +662,7 @@ void SmtEngine::setInfo(const std::string& key, const SExpr& value) SExpr SmtEngine::getInfo(const std::string& key) const throw(BadOptionException) { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); Trace("smt") << "SMT getInfo(" << key << ")" << endl; if(key == ":all-statistics") { @@ -705,7 +703,7 @@ SExpr SmtEngine::getInfo(const std::string& key) const void SmtEngine::setOption(const std::string& key, const SExpr& value) throw(BadOptionException, ModalException) { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); Trace("smt") << "SMT setOption(" << key << ", " << value << ")" << endl; if(Dump.isOn("benchmark")) { @@ -757,7 +755,7 @@ void SmtEngine::setOption(const std::string& key, const SExpr& value) SExpr SmtEngine::getOption(const std::string& key) const throw(BadOptionException) { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); Trace("smt") << "SMT getOption(" << key << ")" << endl; if(Dump.isOn("benchmark")) { @@ -804,7 +802,7 @@ void SmtEngine::defineFunction(Expr func, << func; Dump("declarations") << DefineFunctionCommand(ss.str(), func, formals, formula); } - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); // type check body Type formulaType = formula.getType(Options::current()->typeChecking); @@ -1606,7 +1604,7 @@ Result SmtEngine::checkSat(const BoolExpr& e) { Assert(e.isNull() || e.getExprManager() == d_exprManager); - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); finalOptionsAreSet(); @@ -1669,7 +1667,7 @@ Result SmtEngine::query(const BoolExpr& e) { Assert(!e.isNull()); Assert(e.getExprManager() == d_exprManager); - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); finalOptionsAreSet(); @@ -1725,7 +1723,7 @@ Result SmtEngine::query(const BoolExpr& e) { Result SmtEngine::assertFormula(const BoolExpr& e) { Assert(e.getExprManager() == d_exprManager); - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); finalOptionsAreSet(); Trace("smt") << "SmtEngine::assertFormula(" << e << ")" << endl; ensureBoolean(e); @@ -1738,7 +1736,7 @@ Result SmtEngine::assertFormula(const BoolExpr& e) { Expr SmtEngine::simplify(const Expr& e) { Assert(e.getExprManager() == d_exprManager); - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); finalOptionsAreSet(); if( Options::current()->typeChecking ) { e.getType(true);// ensure expr is type-checked at this point @@ -1753,7 +1751,7 @@ Expr SmtEngine::simplify(const Expr& e) { Expr SmtEngine::getValue(const Expr& e) throw(ModalException, AssertionException) { Assert(e.getExprManager() == d_exprManager); - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); // ensure expr is type-checked at this point Type type = e.getType(Options::current()->typeChecking); @@ -1799,7 +1797,7 @@ Expr SmtEngine::getValue(const Expr& e) } bool SmtEngine::addToAssignment(const Expr& e) throw(AssertionException) { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); finalOptionsAreSet(); Type type = e.getType(Options::current()->typeChecking); // must be Boolean @@ -1828,7 +1826,7 @@ bool SmtEngine::addToAssignment(const Expr& e) throw(AssertionException) { SExpr SmtEngine::getAssignment() throw(ModalException, AssertionException) { Trace("smt") << "SMT getAssignment()" << endl; - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); finalOptionsAreSet(); if(Dump.isOn("benchmark")) { Dump("benchmark") << GetAssignmentCommand(); @@ -1890,7 +1888,7 @@ SExpr SmtEngine::getAssignment() throw(ModalException, AssertionException) { void SmtEngine::addToModelType( Type& t ){ Trace("smt") << "SMT addToModelType(" << t << ")" << endl; - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); if( Options::current()->produceModels ) { d_theoryEngine->getModel()->addDefineType( TypeNode::fromType( t ) ); } @@ -1898,7 +1896,7 @@ void SmtEngine::addToModelType( Type& t ){ void SmtEngine::addToModelFunction( Expr& e ){ Trace("smt") << "SMT addToModelFunction(" << e << ")" << endl; - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); if( Options::current()->produceModels ) { d_theoryEngine->getModel()->addDefineFunction( e.getNode() ); } @@ -1907,7 +1905,7 @@ void SmtEngine::addToModelFunction( Expr& e ){ Model* SmtEngine::getModel() throw(ModalException, AssertionException){ Trace("smt") << "SMT getModel()" << endl; - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); if(!Options::current()->produceModels) { const char* msg = @@ -1928,7 +1926,7 @@ Model* SmtEngine::getModel() throw(ModalException, AssertionException){ Proof* SmtEngine::getProof() throw(ModalException, AssertionException) { Trace("smt") << "SMT getProof()" << endl; - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); finalOptionsAreSet(); if(Dump.isOn("benchmark")) { Dump("benchmark") << GetProofCommand(); @@ -1958,7 +1956,7 @@ vector<Expr> SmtEngine::getAssertions() if(Dump.isOn("benchmark")) { Dump("benchmark") << GetAssertionsCommand(); } - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); Trace("smt") << "SMT getAssertions()" << endl; if(!Options::current()->interactive) { const char* msg = @@ -1970,13 +1968,13 @@ vector<Expr> SmtEngine::getAssertions() } size_t SmtEngine::getStackLevel() const { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); Trace("smt") << "SMT getStackLevel()" << endl; return d_context->getLevel(); } void SmtEngine::push() { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); finalOptionsAreSet(); Trace("smt") << "SMT push()" << endl; d_private->processAssertions(); @@ -2000,7 +1998,7 @@ void SmtEngine::push() { } void SmtEngine::pop() { - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); finalOptionsAreSet(); Trace("smt") << "SMT pop()" << endl; if(Dump.isOn("benchmark")) { @@ -2108,11 +2106,11 @@ unsigned long SmtEngine::getTimeRemaining() const throw(ModalException) { } StatisticsRegistry* SmtEngine::getStatisticsRegistry() const { - return d_exprManager->d_nodeManager->getStatisticsRegistry(); + return d_statisticsRegistry; } void SmtEngine::printModel( std::ostream& out, Model* m ){ - NodeManagerScope nms(d_nodeManager); + SmtScope smts(this); m->toStream(out); } diff --git a/src/smt/smt_engine.h b/src/smt/smt_engine.h index aef98d75b..4df9054a7 100644 --- a/src/smt/smt_engine.h +++ b/src/smt/smt_engine.h @@ -76,6 +76,7 @@ namespace smt { class DefinedFunction; class SmtEnginePrivate; + class SmtScope; }/* CVC4::smt namespace */ // TODO: SAT layer (esp. CNF- versus non-clausal solvers under the @@ -248,6 +249,9 @@ class CVC4_PUBLIC SmtEngine { void setLogicInternal() throw(AssertionException); friend class ::CVC4::smt::SmtEnginePrivate; + friend class ::CVC4::smt::SmtScope; + + StatisticsRegistry* d_statisticsRegistry; // === STATISTICS === /** time spent in definition-expansion */ diff --git a/src/smt/smt_engine_scope.cpp b/src/smt/smt_engine_scope.cpp new file mode 100644 index 000000000..03298e99a --- /dev/null +++ b/src/smt/smt_engine_scope.cpp @@ -0,0 +1,10 @@ +#include "smt/smt_engine.h" +#include "smt/smt_engine_scope.h" + +namespace CVC4 { +namespace smt { + +CVC4_THREADLOCAL(SmtEngine*) s_smtEngine_current = NULL; + +} +} diff --git a/src/smt/smt_engine_scope.h b/src/smt/smt_engine_scope.h new file mode 100644 index 000000000..bcdaefd9f --- /dev/null +++ b/src/smt/smt_engine_scope.h @@ -0,0 +1,40 @@ +#include "smt/smt_engine.h" +#include "util/tls.h" +#include "util/Assert.h" +#include "expr/node_manager.h" +#include "util/output.h" + +#pragma once + +namespace CVC4 { +namespace smt { + +extern CVC4_THREADLOCAL(SmtEngine*) s_smtEngine_current; + +inline SmtEngine* currentSmtEngine() { + Assert(s_smtEngine_current != NULL); + return s_smtEngine_current; +} + +class SmtScope : public NodeManagerScope { + /** The old NodeManager, to be restored on destruction. */ + SmtEngine* d_oldSmtEngine; + +public: + + SmtScope(const SmtEngine* smt) : + NodeManagerScope(smt->d_nodeManager), + d_oldSmtEngine(s_smtEngine_current) { + Assert(smt != NULL); + s_smtEngine_current = const_cast<SmtEngine*>(smt); + Debug("current") << "smt scope: " << s_smtEngine_current << std::endl; + } + + ~SmtScope() { + s_smtEngine_current = d_oldSmtEngine; + Debug("current") << "smt scope: returning to " << s_smtEngine_current << std::endl; + } +};/* class SmtScope */ + +} +} diff --git a/src/util/stats.cpp b/src/util/stats.cpp index b030495c5..96e300197 100644 --- a/src/util/stats.cpp +++ b/src/util/stats.cpp @@ -20,7 +20,10 @@ #include "util/stats.h" #include "expr/node_manager.h" #include "expr/expr_manager_scope.h" +#include "expr/expr_manager.h" #include "lib/clock_gettime.h" +#include "smt/smt_engine_scope.h" +#include "smt/smt_engine.h" #ifdef CVC4_STATISTICS_ON # define __CVC4_USE_STATISTICS true @@ -34,12 +37,12 @@ std::string Stat::s_delim(","); std::string StatisticsRegistry::s_regDelim("::"); StatisticsRegistry* StatisticsRegistry::current() { - return NodeManager::currentNM()->getStatisticsRegistry(); + return smt::currentSmtEngine()->getStatisticsRegistry(); } void StatisticsRegistry::registerStat(Stat* s) throw(AssertionException) { #ifdef CVC4_STATISTICS_ON - StatSet& registeredStats = NodeManager::currentNM()->getStatisticsRegistry()->d_registeredStats; + StatSet& registeredStats = current()->d_registeredStats; AlwaysAssert(registeredStats.find(s) == registeredStats.end(), "Statistic `%s' was already registered with this registry.", s->getName().c_str()); registeredStats.insert(s); @@ -55,7 +58,7 @@ void StatisticsRegistry::registerStat_(Stat* s) throw(AssertionException) { void StatisticsRegistry::unregisterStat(Stat* s) throw(AssertionException) { #ifdef CVC4_STATISTICS_ON - StatSet& registeredStats = NodeManager::currentNM()->getStatisticsRegistry()->d_registeredStats; + StatSet& registeredStats = current()->d_registeredStats; AlwaysAssert(registeredStats.find(s) != registeredStats.end(), "Statistic `%s' was not registered with this registry.", s->getName().c_str()); registeredStats.erase(s); @@ -91,11 +94,11 @@ void StatisticsRegistry::flushStat(std::ostream &out) const {; } StatisticsRegistry::const_iterator StatisticsRegistry::begin() { - return NodeManager::currentNM()->getStatisticsRegistry()->d_registeredStats.begin(); + return current()->d_registeredStats.begin(); }/* StatisticsRegistry::begin() */ StatisticsRegistry::const_iterator StatisticsRegistry::end() { - return NodeManager::currentNM()->getStatisticsRegistry()->d_registeredStats.end(); + return current()->d_registeredStats.end(); }/* StatisticsRegistry::end() */ void TimerStat::start() { @@ -117,9 +120,14 @@ void TimerStat::stop() { }/* TimerStat::stop() */ RegisterStatistic::RegisterStatistic(ExprManager& em, Stat* stat) : - d_reg(NULL), + d_reg(em.getStatisticsRegistry()), d_stat(stat) { - ExprManagerScope ems(em); - d_reg = StatisticsRegistry::current(); d_reg->registerStat_(d_stat); } + +RegisterStatistic::RegisterStatistic(SmtEngine& smt, Stat* stat) : + d_reg(smt.getStatisticsRegistry()), + d_stat(stat) { + d_reg->registerStat_(d_stat); +} + diff --git a/src/util/stats.h b/src/util/stats.h index 63e732305..aabf04dc0 100644 --- a/src/util/stats.h +++ b/src/util/stats.h @@ -43,6 +43,7 @@ namespace CVC4 { #endif class ExprManager; +class SmtEngine; class CVC4_PUBLIC Stat; @@ -803,6 +804,8 @@ public: RegisterStatistic(ExprManager& em, Stat* stat); + RegisterStatistic(SmtEngine& smt, Stat* stat); + ~RegisterStatistic() { d_reg->unregisterStat_(d_stat); } |