summaryrefslogtreecommitdiff
path: root/src/expr/expr_manager_template.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/expr/expr_manager_template.cpp')
-rw-r--r--src/expr/expr_manager_template.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp
index 1981d0a7d..8bf8d9e54 100644
--- a/src/expr/expr_manager_template.cpp
+++ b/src/expr/expr_manager_template.cpp
@@ -115,10 +115,11 @@ ExprManager::~ExprManager()
}
}
#endif
+ // clear the datatypes
+ d_ownedDatatypes.clear();
delete d_nodeManager;
d_nodeManager = NULL;
-
} catch(Exception& e) {
Warning() << "CVC4 threw an exception during cleanup." << std::endl
<< e << std::endl;
@@ -676,10 +677,11 @@ std::vector<DatatypeType> ExprManager::mkMutualDatatypeTypes(
std::map<std::string, DatatypeType> nameResolutions;
std::vector<DatatypeType> dtts;
- //have to build deep copy so that datatypes will live in NodeManager
+ // have to build deep copy so that datatypes will live in this class
std::vector< Datatype* > dt_copies;
for(std::vector<Datatype>::iterator i = datatypes.begin(), i_end = datatypes.end(); i != i_end; ++i) {
- dt_copies.push_back( new Datatype( *i ) );
+ d_ownedDatatypes.push_back(std::unique_ptr<Datatype>(new Datatype(*i)));
+ dt_copies.push_back(d_ownedDatatypes.back().get());
}
// First do some sanity checks, set up the final Type to be used for
@@ -689,12 +691,12 @@ std::vector<DatatypeType> ExprManager::mkMutualDatatypeTypes(
// pred selector.
for(std::vector<Datatype*>::iterator i = dt_copies.begin(), i_end = dt_copies.end(); i != i_end; ++i) {
TypeNode* typeNode;
+ // register datatype with the node manager
+ unsigned index = d_nodeManager->registerDatatype((*i)->d_internal);
if( (*i)->getNumParameters() == 0 ) {
- unsigned index = d_nodeManager->registerDatatype( *i );
typeNode = new TypeNode(d_nodeManager->mkTypeConst(DatatypeIndexConstant(index)));
//typeNode = new TypeNode(d_nodeManager->mkTypeConst(*i));
} else {
- unsigned index = d_nodeManager->registerDatatype( *i );
TypeNode cons = d_nodeManager->mkTypeConst(DatatypeIndexConstant(index));
//TypeNode cons = d_nodeManager->mkTypeConst(*i);
std::vector< TypeNode > params;
@@ -1098,6 +1100,13 @@ Type ExprManager::exportType(const Type& t, ExprManager* em, ExprManagerMapColle
new TypeNode(expr::exportTypeInternal(*t.d_typeNode, t.d_nodeManager, em->d_nodeManager, vmap)));
}
+const Datatype& ExprManager::getDatatypeForIndex(unsigned index) const
+{
+ // when the Node-level API is in place, this function will be deleted.
+ Assert(index < d_ownedDatatypes.size());
+ return *d_ownedDatatypes[index];
+}
+
${mkConst_implementations}
}/* CVC4 namespace */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback