#include "expr/attribute.h"
#include "expr/node_value.h"
#include "util/output.h"
+#include "smt/smt_engine.h"
#include <utility>
namespace expr {
namespace attr {
-AttributeManager::AttributeManager(context::Context* ctxt) :
+SmtAttributes::SmtAttributes(context::Context* ctxt) :
d_cdbools(ctxt),
d_cdints(ctxt),
d_cdtnodes(ctxt),
d_cdnodes(ctxt),
d_cdstrings(ctxt),
- d_cdptrs(ctxt),
+ d_cdptrs(ctxt) {
+}
+
+AttributeManager::AttributeManager() :
d_inGarbageCollection(false)
{}
return d_inGarbageCollection;
}
+SmtAttributes& AttributeManager::getSmtAttributes(SmtEngine* smt) {
+ Assert(smt != NULL);
+ return *smt->d_smtAttributes;
+}
+
+const SmtAttributes& AttributeManager::getSmtAttributes(SmtEngine* smt) const {
+ return *smt->d_smtAttributes;
+}
+
void AttributeManager::debugHook(int debugFlag) {
/* DO NOT CHECK IN ANY CODE INTO THE DEBUG HOOKS!
* debugHook() is an empty function for the purpose of debugging
deleteFromTable(d_types, nv);
deleteFromTable(d_strings, nv);
deleteFromTable(d_ptrs, nv);
+}
+
+void SmtAttributes::deleteAllAttributes(TNode n) {
+ NodeValue* nv = n.d_nv;
d_cdbools.erase(nv);
deleteFromTable(d_cdints, nv);
deleteAllFromTable(d_types);
deleteAllFromTable(d_strings);
deleteAllFromTable(d_ptrs);
-
- d_cdbools.clear();
- d_cdints.clear();
- d_cdtnodes.clear();
- d_cdnodes.clear();
- d_cdstrings.clear();
- d_cdptrs.clear();
}
-void AttributeManager::deleteAttributes(const AttrIdVec& atids){
+void AttributeManager::deleteAttributes(const AttrIdVec& atids) {
typedef std::map<uint64_t, std::vector< uint64_t> > AttrToVecMap;
AttrToVecMap perTableIds;
- for(AttrIdVec::const_iterator it = atids.begin(), it_end = atids.end(); it != it_end; ++it){
+ for(AttrIdVec::const_iterator it = atids.begin(), it_end = atids.end(); it != it_end; ++it) {
const AttributeUniqueId& pair = *(*it);
std::vector< uint64_t>& inTable = perTableIds[pair.getTableId()];
inTable.push_back(pair.getWithinTypeId());
}
AttrToVecMap::iterator it = perTableIds.begin(), it_end = perTableIds.end();
- for(; it != it_end; ++it){
+ for(; it != it_end; ++it) {
Assert(((*it).first) <= LastAttrTable);
AttrTableId tableId = (AttrTableId) ((*it).first);
std::vector< uint64_t>& ids = (*it).second;
std::sort(ids.begin(), ids.end());
- switch(tableId){
+ switch(tableId) {
case AttrTableBool:
Unimplemented("delete attributes is unimplemented for bools");
break;
case AttrTableCDPointer:
Unimplemented("CDAttributes cannot be deleted. Contact Tim/Morgan if this behavior is desired.");
break;
+
case LastAttrTable:
default:
Unreachable();
* attributes and nodes due to template use */
#include "expr/node.h"
#include "expr/type_node.h"
+#include "context/context.h"
#ifndef __CVC4__EXPR__ATTRIBUTE_H
#define __CVC4__EXPR__ATTRIBUTE_H
#undef CVC4_ATTRIBUTE_H__INCLUDING__ATTRIBUTE_INTERNALS_H
namespace CVC4 {
+
+class SmtEngine;
+
+namespace smt {
+ extern CVC4_THREADLOCAL(SmtEngine*) s_smtEngine_current;
+}/* CVC4::smt namespace */
+
namespace expr {
namespace attr {
// ATTRIBUTE MANAGER ===========================================================
-/**
- * A container for the main attribute tables of the system. There's a
- * one-to-one NodeManager : AttributeManager correspondence.
- */
-class AttributeManager {
-
- // IF YOU ADD ANY TABLES, don't forget to add them also to the
- // implementation of deleteAllAttributes().
-
- /** Underlying hash table for boolean-valued attributes */
- AttrHash<bool> d_bools;
- /** Underlying hash table for integral-valued attributes */
- AttrHash<uint64_t> d_ints;
- /** Underlying hash table for node-valued attributes */
- AttrHash<TNode> d_tnodes;
- /** Underlying hash table for node-valued attributes */
- AttrHash<Node> d_nodes;
- /** Underlying hash table for types attributes */
- AttrHash<TypeNode> d_types;
- /** Underlying hash table for string-valued attributes */
- AttrHash<std::string> d_strings;
- /** Underlying hash table for pointer-valued attributes */
- AttrHash<void*> d_ptrs;
+struct SmtAttributes {
+ SmtAttributes(context::Context*);
// IF YOU ADD ANY TABLES, don't forget to add them also to the
// implementation of deleteAllAttributes().
/** Underlying hash table for context-dependent pointer-valued attributes */
CDAttrHash<void*> d_cdptrs;
- template <class T>
- void deleteFromTable(AttrHash<T>& table, NodeValue* nv);
+ /** Delete all attributes of given node */
+ void deleteAllAttributes(TNode n);
template <class T>
void deleteFromTable(CDAttrHash<T>& table, NodeValue* nv);
+};/* struct SmtAttributes */
+
+/**
+ * A container for the main attribute tables of the system. There's a
+ * one-to-one NodeManager : AttributeManager correspondence.
+ */
+class AttributeManager {
+
+ template <class T>
+ void deleteFromTable(AttrHash<T>& table, NodeValue* nv);
+
template <class T>
void deleteAllFromTable(AttrHash<T>& table);
void clearDeleteAllAttributesBuffer();
+ SmtAttributes& getSmtAttributes(SmtEngine*);
+ const SmtAttributes& getSmtAttributes(SmtEngine*) const;
+
public:
/** Construct an attribute manager. */
- AttributeManager(context::Context* ctxt);
+ AttributeManager();
+
+ // IF YOU ADD ANY TABLES, don't forget to add them also to the
+ // implementation of deleteAllAttributes().
+
+ /** Underlying hash table for boolean-valued attributes */
+ AttrHash<bool> d_bools;
+ /** Underlying hash table for integral-valued attributes */
+ AttrHash<uint64_t> d_ints;
+ /** Underlying hash table for node-valued attributes */
+ AttrHash<TNode> d_tnodes;
+ /** Underlying hash table for node-valued attributes */
+ AttrHash<Node> d_nodes;
+ /** Underlying hash table for types attributes */
+ AttrHash<TypeNode> d_types;
+ /** Underlying hash table for string-valued attributes */
+ AttrHash<std::string> d_strings;
+ /** Underlying hash table for pointer-valued attributes */
+ AttrHash<void*> d_ptrs;
/**
* Get a particular attribute on a particular node.
struct getTable<bool, false> {
static const AttrTableId id = AttrTableBool;
typedef AttrHash<bool> table_type;
- static inline table_type& get(AttributeManager& am) {
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
return am.d_bools;
}
- static inline const table_type& get(const AttributeManager& am) {
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
return am.d_bools;
}
};
struct getTable<uint64_t, false> {
static const AttrTableId id = AttrTableUInt64;
typedef AttrHash<uint64_t> table_type;
- static inline table_type& get(AttributeManager& am) {
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
return am.d_ints;
}
- static inline const table_type& get(const AttributeManager& am) {
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
return am.d_ints;
}
};
struct getTable<TNode, false> {
static const AttrTableId id = AttrTableTNode;
typedef AttrHash<TNode> table_type;
- static inline table_type& get(AttributeManager& am) {
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
return am.d_tnodes;
}
- static inline const table_type& get(const AttributeManager& am) {
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
return am.d_tnodes;
}
};
struct getTable<Node, false> {
static const AttrTableId id = AttrTableNode;
typedef AttrHash<Node> table_type;
- static inline table_type& get(AttributeManager& am) {
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
return am.d_nodes;
}
- static inline const table_type& get(const AttributeManager& am) {
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
return am.d_nodes;
}
};
struct getTable<TypeNode, false> {
static const AttrTableId id = AttrTableTypeNode;
typedef AttrHash<TypeNode> table_type;
- static inline table_type& get(AttributeManager& am) {
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
return am.d_types;
}
- static inline const table_type& get(const AttributeManager& am) {
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
return am.d_types;
}
};
struct getTable<std::string, false> {
static const AttrTableId id = AttrTableString;
typedef AttrHash<std::string> table_type;
- static inline table_type& get(AttributeManager& am) {
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
return am.d_strings;
}
- static inline const table_type& get(const AttributeManager& am) {
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
return am.d_strings;
}
};
struct getTable<T*, false> {
static const AttrTableId id = AttrTablePointer;
typedef AttrHash<void*> table_type;
- static inline table_type& get(AttributeManager& am) {
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
return am.d_ptrs;
}
- static inline const table_type& get(const AttributeManager& am) {
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
return am.d_ptrs;
}
};
struct getTable<const T*, false> {
static const AttrTableId id = AttrTablePointer;
typedef AttrHash<void*> table_type;
- static inline table_type& get(AttributeManager& am) {
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
return am.d_ptrs;
}
- static inline const table_type& get(const AttributeManager& am) {
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
return am.d_ptrs;
}
};
struct getTable<bool, true> {
static const AttrTableId id = AttrTableCDBool;
typedef CDAttrHash<bool> table_type;
- static inline table_type& get(AttributeManager& am) {
- return am.d_cdbools;
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdbools;
}
- static inline const table_type& get(const AttributeManager& am) {
- return am.d_cdbools;
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdbools;
}
};
struct getTable<uint64_t, true> {
static const AttrTableId id = AttrTableCDUInt64;
typedef CDAttrHash<uint64_t> table_type;
- static inline table_type& get(AttributeManager& am) {
- return am.d_cdints;
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdints;
}
- static inline const table_type& get(const AttributeManager& am) {
- return am.d_cdints;
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdints;
}
};
struct getTable<TNode, true> {
static const AttrTableId id = AttrTableCDTNode;
typedef CDAttrHash<TNode> table_type;
- static inline table_type& get(AttributeManager& am) {
- return am.d_cdtnodes;
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdtnodes;
}
- static inline const table_type& get(const AttributeManager& am) {
- return am.d_cdtnodes;
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdtnodes;
}
};
struct getTable<Node, true> {
static const AttrTableId id = AttrTableCDNode;
typedef CDAttrHash<Node> table_type;
- static inline table_type& get(AttributeManager& am) {
- return am.d_cdnodes;
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdnodes;
}
- static inline const table_type& get(const AttributeManager& am) {
- return am.d_cdnodes;
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdnodes;
}
};
struct getTable<std::string, true> {
static const AttrTableId id = AttrTableCDString;
typedef CDAttrHash<std::string> table_type;
- static inline table_type& get(AttributeManager& am) {
- return am.d_cdstrings;
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdstrings;
}
- static inline const table_type& get(const AttributeManager& am) {
- return am.d_cdstrings;
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdstrings;
}
};
struct getTable<T*, true> {
static const AttrTableId id = AttrTableCDPointer;
typedef CDAttrHash<void*> table_type;
- static inline table_type& get(AttributeManager& am) {
- return am.d_cdptrs;
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdptrs;
}
- static inline const table_type& get(const AttributeManager& am) {
- return am.d_cdptrs;
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdptrs;
}
};
struct getTable<const T*, true> {
static const AttrTableId id = AttrTableCDPointer;
typedef CDAttrHash<void*> table_type;
- static inline table_type& get(AttributeManager& am) {
- return am.d_cdptrs;
+ static inline table_type& get(AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdptrs;
}
- static inline const table_type& get(const AttributeManager& am) {
- return am.d_cdptrs;
+ static inline const table_type& get(const AttributeManager& am, SmtEngine* smt) {
+ return am.getSmtAttributes(smt).d_cdptrs;
}
};
table_type table_type;
const table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*this);
+ getTable<value_type, AttrKind::context_dependent>::get(*this, smt::s_smtEngine_current);
typename table_type::const_iterator i =
ah.find(std::make_pair(AttrKind::getId(), nv));
table_type;
const table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*am);
+ getTable<value_type, AttrKind::context_dependent>::get(*am, smt::s_smtEngine_current);
typename table_type::const_iterator i =
ah.find(std::make_pair(AttrKind::getId(), nv));
table_type table_type;
const table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*am);
+ getTable<value_type, AttrKind::context_dependent>::get(*am, smt::s_smtEngine_current);
typename table_type::const_iterator i =
ah.find(std::make_pair(AttrKind::getId(), nv));
table_type table_type;
const table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*am);
+ getTable<value_type, AttrKind::context_dependent>::get(*am, smt::s_smtEngine_current);
typename table_type::const_iterator i =
ah.find(std::make_pair(AttrKind::getId(), nv));
table_type table_type;
table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*this);
+ getTable<value_type, AttrKind::context_dependent>::get(*this, smt::s_smtEngine_current);
ah[std::make_pair(AttrKind::getId(), nv)] = mapping::convert(value);
}
* Obliterate a NodeValue from a (context-dependent) attribute table.
*/
template <class T>
-inline void AttributeManager::deleteFromTable(CDAttrHash<T>& table,
- NodeValue* nv) {
+inline void SmtAttributes::deleteFromTable(CDAttrHash<T>& table,
+ NodeValue* nv) {
for(unsigned id = 0; id < attr::LastAttributeId<T, true>::getId(); ++id) {
table.obliterate(std::make_pair(id, nv));
}
#include "expr/node_manager.h"
#include "expr/expr_manager.h"
#include "expr/variable_type_map.h"
-#include "context/context.h"
#include "options/options.h"
#include "util/statistics_registry.h"
// 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 33 "${template}"
+#line 32 "${template}"
#ifdef CVC4_STATISTICS_ON
#define INC_STAT(kind) \
#endif
using namespace std;
-using namespace CVC4::context;
using namespace CVC4::kind;
namespace CVC4 {
ExprManager::ExprManager() :
- d_ctxt(new Context()),
- d_nodeManager(new NodeManager(d_ctxt, this)) {
+ d_nodeManager(new NodeManager(this)) {
#ifdef CVC4_STATISTICS_ON
for (unsigned i = 0; i < kind::LAST_KIND; ++ i) {
d_exprStatistics[i] = NULL;
}
ExprManager::ExprManager(const Options& options) :
- d_ctxt(new Context()),
- d_nodeManager(new NodeManager(d_ctxt, this, options)) {
+ d_nodeManager(new NodeManager(this, options)) {
#ifdef CVC4_STATISTICS_ON
for (unsigned i = 0; i < LAST_TYPE; ++ i) {
d_exprStatisticsVars[i] = NULL;
delete d_nodeManager;
d_nodeManager = NULL;
- delete d_ctxt;
- d_ctxt = NULL;
} catch(Exception& e) {
Warning() << "CVC4 threw an exception during cleanup." << std::endl
return d_nodeManager;
}
-Context* ExprManager::getContext() const {
- return d_ctxt;
-}
-
Statistics ExprManager::getStatistics() const throw() {
return Statistics(*d_nodeManager->getStatisticsRegistry());
}
}/* CVC4::expr::pickle namespace */
}/* CVC4::expr namespace */
-namespace context {
- class Context;
-}/* CVC4::context namespace */
-
namespace stats {
StatisticsRegistry* getStatisticsRegistry(ExprManager*);
}/* CVC4::stats namespace */
class CVC4_PUBLIC ExprManager {
private:
- /** The context */
- context::Context* d_ctxt;
-
/** The internal node manager */
NodeManager* d_nodeManager;
*/
NodeManager* getNodeManager() const;
- /**
- * Returns the internal Context. Used by internal users, i.e. the
- * friend classes.
- */
- context::Context* getContext() const;
-
/**
* Check some things about a newly-created DatatypeType.
*/
namespace attr {
class AttributeManager;
+ class SmtAttributes;
}/* CVC4::expr::attr namespace */
class ExprSetDepth;
friend class NodeBuilder;
friend class ::CVC4::expr::attr::AttributeManager;
+ friend class ::CVC4::expr::attr::SmtAttributes;
friend struct ::CVC4::kind::metakind::NodeValueConstPrinter;
}
};
-NodeManager::NodeManager(context::Context* ctxt,
- ExprManager* exprManager) :
+NodeManager::NodeManager(ExprManager* exprManager) :
d_options(new Options()),
d_statisticsRegistry(new StatisticsRegistry()),
next_id(0),
- d_attrManager(new expr::attr::AttributeManager(ctxt)),
+ d_attrManager(new expr::attr::AttributeManager()),
d_exprManager(exprManager),
d_nodeUnderDeletion(NULL),
d_inReclaimZombies(false),
init();
}
-NodeManager::NodeManager(context::Context* ctxt,
- ExprManager* exprManager,
+NodeManager::NodeManager(ExprManager* exprManager,
const Options& options) :
d_options(new Options(options)),
d_statisticsRegistry(new StatisticsRegistry()),
next_id(0),
- d_attrManager(new expr::attr::AttributeManager(ctxt)),
+ d_attrManager(new expr::attr::AttributeManager()),
d_exprManager(exprManager),
d_nodeUnderDeletion(NULL),
d_inReclaimZombies(false),
{
ScopedBool dontGC(d_inReclaimZombies);
+ // hopefully by this point all SmtEngines have been deleted
+ // already, along with all their attributes
d_attrManager->deleteAllAttributes();
}
d_nodeUnderDeletion = nv;
// remove attributes
+ { // notify listeners of deleted node
+ TNode n;
+ n.d_nv = nv;
+ nv->d_rc = 1; // so that TNode doesn't assert-fail
+ for(vector<NodeManagerListener*>::iterator i = d_listeners.begin(); i != d_listeners.end(); ++i) {
+ (*i)->nmNotifyDeleteNode(n);
+ }
+ // this would mean that one of the listeners stowed away
+ // a reference to this node!
+ Assert(nv->d_rc == 1);
+ }
+ nv->d_rc = 0;
d_attrManager->deleteAllAttributes(nv);
// decr ref counts of children
#include "expr/kind.h"
#include "expr/metakind.h"
#include "expr/node_value.h"
-#include "context/context.h"
#include "util/subrange_bound.h"
#include "util/tls.h"
#include "options/options.h"
virtual void nmNotifyNewDatatypes(const std::vector<DatatypeType>& datatypes) { }
virtual void nmNotifyNewVar(TNode n, uint32_t flags) { }
virtual void nmNotifyNewSkolem(TNode n, const std::string& comment, uint32_t flags) { }
+ /**
+ * Notify a listener of a Node that's being GCed. If this function stores a reference
+ * to the Node somewhere, very bad things will happen.
+ */
+ virtual void nmNotifyDeleteNode(TNode n) { }
};/* class NodeManagerListener */
class NodeManager {
public:
- explicit NodeManager(context::Context* ctxt, ExprManager* exprManager);
- explicit NodeManager(context::Context* ctxt, ExprManager* exprManager, const Options& options);
+ explicit NodeManager(ExprManager* exprManager);
+ explicit NodeManager(ExprManager* exprManager, const Options& options);
~NodeManager();
/** The node manager in the current public-facing CVC4 library context */
#include "expr/node_builder.h"
#include "expr/node.h"
#include "expr/node_self_iterator.h"
+#include "expr/attribute.h"
#include "prop/prop_engine.h"
#include "proof/theory_proof.h"
#include "smt/modal_exception.h"
}
}
+ void nmNotifyDeleteNode(TNode n) {
+ d_smt.d_smtAttributes->deleteAllAttributes(n);
+ }
+
Node applySubstitutions(TNode node) const {
return Rewriter::rewrite(d_topLevelSubstitutions.apply(node));
}
}/* namespace CVC4::smt */
SmtEngine::SmtEngine(ExprManager* em) throw() :
- d_context(em->getContext()),
+ d_context(new Context()),
d_userLevels(),
d_userContext(new UserContext()),
d_exprManager(em),
d_cumulativeResourceUsed(0),
d_status(),
d_private(NULL),
+ d_smtAttributes(NULL),
d_statisticsRegistry(NULL),
d_stats(NULL) {
SmtScope smts(this);
+ d_smtAttributes = new expr::attr::SmtAttributes(d_context);
d_private = new smt::SmtEnginePrivate(*this);
d_statisticsRegistry = new StatisticsRegistry();
d_stats = new SmtEngineStatistics();
delete d_private;
d_private = NULL;
+ delete d_smtAttributes;
+ d_smtAttributes = NULL;
+
delete d_userContext;
d_userContext = NULL;
+ delete d_context;
+ d_context = NULL;
} catch(Exception& e) {
Warning() << "CVC4 threw an exception during cleanup." << endl
class PropEngine;
}/* CVC4::prop namespace */
+namespace expr {
+ namespace attr {
+ class AttributeManager;
+ struct SmtAttributes;
+ }/* CVC4::expr::attr namespace */
+}/* CVC4::expr namespace */
+
namespace smt {
/**
* Representation of a defined function. We keep these around in
// to access d_modelCommands
friend class ::CVC4::Model;
friend class ::CVC4::theory::TheoryModel;
+ // to access SmtAttributes
+ friend class expr::attr::AttributeManager;
// to access getModel(), which is private (for now)
friend class GetModelCommand;
+ /**
+ * There's something of a handshake between the expr package's
+ * AttributeManager and the SmtEngine because the expr package
+ * doesn't have a Context on its own (that's owned by the
+ * SmtEngine). Thus all context-dependent attributes are stored
+ * here.
+ */
+ expr::attr::SmtAttributes* d_smtAttributes;
+
StatisticsRegistry* d_statisticsRegistry;
smt::SmtEngineStatistics* d_stats;
using namespace CVC4::theory;
using namespace CVC4::theory::quantifiers;
using namespace CVC4::kind;
-using namespace CVC4::context;
void FirstOrderPropagation::collectLits( Node n, std::vector<Node> & lits ){
using namespace CVC4::theory;
using namespace CVC4::theory::quantifiers;
using namespace CVC4::kind;
-using namespace CVC4::context;
bool QuantifierMacros::simplify( std::vector< Node >& assertions, bool doRewrite ){
public:
void setUp() {
- d_ctxt = new Context;
- d_nm = new NodeManager(d_ctxt, NULL);
+ d_ctxt = new Context();
+ d_nm = new NodeManager(NULL);
d_scope = new NodeManagerScope(d_nm);
d_mapPtr = new StackingMap<TNode, TNode, TNodeHashFunction>(d_ctxt);
public:
void setUp() {
- d_ctxt = new Context;
- d_nm = new NodeManager(d_ctxt, NULL);
+ d_ctxt = new Context();
+ d_nm = new NodeManager(NULL);
d_scope = new NodeManagerScope(d_nm);
d_vectorPtr = new StackingVector<TNode>(d_ctxt);
#include "expr/node_manager.h"
#include "expr/node.h"
#include "expr/attribute.h"
+#include "smt/smt_engine.h"
+#include "smt/smt_engine_scope.h"
using namespace CVC4;
using namespace CVC4::kind;
-using namespace CVC4::context;
+using namespace CVC4::smt;
using namespace std;
class AttributeBlack : public CxxTest::TestSuite {
private:
- Context* d_ctxt;
+ ExprManager* d_exprManager;
NodeManager* d_nodeManager;
- NodeManagerScope* d_scope;
+ SmtEngine* d_smtEngine;
+ SmtScope* d_scope;
public:
void setUp() {
- d_ctxt = new Context;
- d_nodeManager = new NodeManager(d_ctxt, NULL);
- d_scope = new NodeManagerScope(d_nodeManager);
+ d_exprManager = new ExprManager();
+ d_nodeManager = NodeManager::fromExprManager(d_exprManager);
+ d_smtEngine = new SmtEngine(d_exprManager);
+ d_scope = new SmtScope(d_smtEngine);
}
void tearDown() {
delete d_scope;
- delete d_nodeManager;
- delete d_ctxt;
+ delete d_smtEngine;
+ delete d_exprManager;
}
class MyData {
#include <string>
-#include "context/context.h"
#include "expr/node_value.h"
#include "expr/node_builder.h"
#include "expr/node_manager.h"
#include "theory/theory_engine.h"
#include "theory/uf/theory_uf.h"
#include "util/cvc4_assert.h"
+#include "smt/smt_engine.h"
+#include "smt/smt_engine_scope.h"
using namespace CVC4;
using namespace CVC4::kind;
-using namespace CVC4::context;
+using namespace CVC4::smt;
using namespace CVC4::expr;
using namespace CVC4::expr::attr;
using namespace std;
class AttributeWhite : public CxxTest::TestSuite {
- Context* d_ctxt;
+ ExprManager* d_em;
NodeManager* d_nm;
- NodeManagerScope* d_scope;
+ SmtScope* d_scope;
TypeNode* d_booleanType;
+ SmtEngine* d_smtEngine;
public:
void setUp() {
- d_ctxt = new Context;
- d_nm = new NodeManager(d_ctxt, NULL);
- d_scope = new NodeManagerScope(d_nm);
-
+ d_em = new ExprManager();
+ d_nm = NodeManager::fromExprManager(d_em);
+ d_smtEngine = new SmtEngine(d_em);
+ d_scope = new SmtScope(d_smtEngine);
d_booleanType = new TypeNode(d_nm->booleanType());
}
void tearDown() {
delete d_booleanType;
delete d_scope;
- delete d_nm;
- delete d_ctxt;
+ delete d_smtEngine;
+ delete d_em;
}
void testAttributeIds() {
lastId = attr::LastAttributeId<TypeNode, false>::getId();
TS_ASSERT_LESS_THAN(TypeAttr::s_id, lastId);
-
}
void testCDAttributes() {
Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
TS_ASSERT(! c.getAttribute(TestFlag1cd()));
- d_ctxt->push(); // level 1
+ d_smtEngine->push(); // level 1
// test that all boolean flags are FALSE to start
Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
TS_ASSERT(! c.getAttribute(TestFlag1cd()));
- d_ctxt->push(); // level 2
+ d_smtEngine->push(); // level 2
Debug("cdboolattr") << "get flag 1 on a (should be T)\n";
TS_ASSERT(a.getAttribute(TestFlag1cd()));
Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
TS_ASSERT(! c.getAttribute(TestFlag1cd()));
- d_ctxt->push(); // level 3
+ d_smtEngine->push(); // level 3
Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
TS_ASSERT(! a.getAttribute(TestFlag1cd()));
Debug("cdboolattr") << "get flag 1 on c (should be T)\n";
TS_ASSERT(c.getAttribute(TestFlag1cd()));
- d_ctxt->pop(); // level 2
+ d_smtEngine->pop(); // level 2
Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
TS_ASSERT(! a.getAttribute(TestFlag1cd()));
Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
TS_ASSERT(! c.getAttribute(TestFlag1cd()));
- d_ctxt->pop(); // level 1
+ d_smtEngine->pop(); // level 1
Debug("cdboolattr") << "get flag 1 on a (should be T)\n";
TS_ASSERT(a.getAttribute(TestFlag1cd()));
Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
TS_ASSERT(! c.getAttribute(TestFlag1cd()));
- d_ctxt->pop(); // level 0
+ d_smtEngine->pop(); // level 0
Debug("cdboolattr") << "get flag 1 on a (should be F)\n";
TS_ASSERT(! a.getAttribute(TestFlag1cd()));
Debug("cdboolattr") << "get flag 1 on c (should be F)\n";
TS_ASSERT(! c.getAttribute(TestFlag1cd()));
-#ifdef CVC4_ASSERTIONS
- TS_ASSERT_THROWS( d_ctxt->pop(), AssertionException );
-#endif /* CVC4_ASSERTIONS */
+ TS_ASSERT_THROWS( d_smtEngine->pop(), ModalException );
}
void testAttributes() {
- //Debug.on("bootattr");
+ //Debug.on("boolattr");
Node a = d_nm->mkVar(*d_booleanType);
Node b = d_nm->mkVar(*d_booleanType);
using namespace CVC4;
using namespace CVC4::kind;
-using namespace CVC4::context;
using namespace std;
class NodeBlack : public CxxTest::TestSuite {
private:
Options opts;
- Context* d_ctxt;
NodeManager* d_nodeManager;
NodeManagerScope* d_scope;
TypeNode* d_booleanType;
free(argv[0]);
free(argv[1]);
- d_ctxt = new Context();
- d_nodeManager = new NodeManager(d_ctxt, NULL, opts);
+ d_nodeManager = new NodeManager(NULL, opts);
d_scope = new NodeManagerScope(d_nodeManager);
d_booleanType = new TypeNode(d_nodeManager->booleanType());
d_realType = new TypeNode(d_nodeManager->realType());
delete d_booleanType;
delete d_scope;
delete d_nodeManager;
- delete d_ctxt;
}
bool imp(bool a, bool b) const {
#include "expr/node_manager.h"
#include "expr/node.h"
#include "expr/kind.h"
-#include "context/context.h"
#include "util/cvc4_assert.h"
#include "util/rational.h"
using namespace CVC4;
using namespace CVC4::kind;
-using namespace CVC4::context;
using namespace std;
class NodeBuilderBlack : public CxxTest::TestSuite {
private:
- Context* d_ctxt;
NodeManager* d_nm;
NodeManagerScope* d_scope;
TypeNode* d_booleanType;
public:
void setUp() {
- d_ctxt = new Context;
- d_nm = new NodeManager(d_ctxt, NULL);
+ d_nm = new NodeManager(NULL);
d_scope = new NodeManagerScope(d_nm);
specKind = AND;
delete d_realType;
delete d_scope;
delete d_nm;
- delete d_ctxt;
}
#include "expr/node_manager.h"
#include "expr/node_manager_attributes.h"
-#include "context/context.h"
#include "util/rational.h"
#include "util/integer.h"
using namespace CVC4;
using namespace CVC4::expr;
using namespace CVC4::kind;
-using namespace CVC4::context;
class NodeManagerBlack : public CxxTest::TestSuite {
- Context* d_context;
NodeManager* d_nodeManager;
NodeManagerScope* d_scope;
public:
void setUp() {
- d_context = new Context;
- d_nodeManager = new NodeManager(d_context, NULL);
+ d_nodeManager = new NodeManager(NULL);
d_scope = new NodeManagerScope(d_nodeManager);
}
void tearDown() {
delete d_scope;
delete d_nodeManager;
- delete d_context;
}
void testMkNodeNot() {
#include <string>
#include "expr/node_manager.h"
-#include "context/context.h"
#include "util/rational.h"
#include "util/integer.h"
using namespace CVC4;
using namespace CVC4::expr;
-using namespace CVC4::context;
class NodeManagerWhite : public CxxTest::TestSuite {
- Context* d_ctxt;
NodeManager* d_nm;
NodeManagerScope* d_scope;
public:
void setUp() {
- d_ctxt = new Context();
- d_nm = new NodeManager(d_ctxt, NULL);
+ d_nm = new NodeManager(NULL);
d_scope = new NodeManagerScope(d_nm);
}
void tearDown() {
delete d_scope;
delete d_nm;
- delete d_ctxt;
}
void testMkConstRational() {
#include <cxxtest/TestSuite.h>
-#include "context/context.h"
#include "expr/node.h"
#include "expr/node_self_iterator.h"
#include "expr/node_builder.h"
#include "expr/convenience_node_builders.h"
using namespace CVC4;
-using namespace CVC4::context;
using namespace CVC4::kind;
using namespace CVC4::expr;
using namespace std;
class NodeSelfIteratorBlack : public CxxTest::TestSuite {
private:
- Context* d_ctxt;
NodeManager* d_nodeManager;
NodeManagerScope* d_scope;
TypeNode* d_booleanType;
public:
void setUp() {
- d_ctxt = new Context;
- d_nodeManager = new NodeManager(d_ctxt, NULL);
+ d_nodeManager = new NodeManager(NULL);
d_scope = new NodeManagerScope(d_nodeManager);
d_booleanType = new TypeNode(d_nodeManager->booleanType());
d_realType = new TypeNode(d_nodeManager->realType());
delete d_booleanType;
delete d_scope;
delete d_nodeManager;
- delete d_ctxt;
}
void testSelfIteration() {
#include "expr/node_builder.h"
#include "expr/node_manager.h"
#include "expr/node.h"
-#include "context/context.h"
#include "util/cvc4_assert.h"
using namespace CVC4;
using namespace CVC4::kind;
-using namespace CVC4::context;
using namespace CVC4::expr;
using namespace std;
class NodeWhite : public CxxTest::TestSuite {
- Context* d_ctxt;
NodeManager* d_nm;
NodeManagerScope* d_scope;
public:
void setUp() {
- d_ctxt = new Context();
- d_nm = new NodeManager(d_ctxt, NULL);
+ d_nm = new NodeManager(NULL);
d_scope = new NodeManagerScope(d_nm);
}
void tearDown() {
delete d_scope;
delete d_nm;
- delete d_ctxt;
}
void testNull() {
** Black box testing of CVC4::BooleanSimplification.
**/
-#include "context/context.h"
#include "util/language.h"
#include "expr/node.h"
#include "expr/kind.h"
#include <set>
using namespace CVC4;
-using namespace CVC4::context;
using namespace std;
class BooleanSimplificationBlack : public CxxTest::TestSuite {
- Context* d_context;
NodeManager* d_nm;
NodeManagerScope* d_scope;
public:
void setUp() {
- d_context = new Context();
- d_nm = new NodeManager(d_context, NULL);
+ d_nm = new NodeManager(NULL);
d_scope = new NodeManagerScope(d_nm);
a = d_nm->mkSkolem("a", d_nm->booleanType());
delete d_scope;
delete d_nm;
- delete d_context;
}
void testNegate() {