summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorajreynol <andrew.j.reynolds@gmail.com>2016-11-01 13:33:38 -0500
committerajreynol <andrew.j.reynolds@gmail.com>2016-11-01 13:33:38 -0500
commitf4c783f97201753bf63c70c5c16b7861a236d57c (patch)
tree8e4a9e85d7485200bdfb52b5afc5032993938488
parent8e0fce94790249ff7aff84ff4500bb96e2ebb9e9 (diff)
Revert change to datatypes API for passing pointers, instead make deep copy during call to mkMutualDatatypes.
-rw-r--r--src/compat/cvc3_compat.cpp6
-rw-r--r--src/expr/expr_manager_template.cpp22
-rw-r--r--src/expr/expr_manager_template.h6
-rw-r--r--src/expr/node_manager.cpp12
-rw-r--r--src/expr/node_manager.h2
-rw-r--r--src/parser/cvc/Cvc.g10
-rw-r--r--src/parser/parser.cpp2
-rw-r--r--src/parser/parser.h2
-rw-r--r--src/parser/smt2/Smt2.g22
-rw-r--r--src/parser/smt2/smt2.cpp60
-rw-r--r--src/parser/smt2/smt2.h18
-rw-r--r--src/smt/boolean_terms.cpp16
12 files changed, 89 insertions, 89 deletions
diff --git a/src/compat/cvc3_compat.cpp b/src/compat/cvc3_compat.cpp
index 0482c99ee..5de62a458 100644
--- a/src/compat/cvc3_compat.cpp
+++ b/src/compat/cvc3_compat.cpp
@@ -1384,11 +1384,11 @@ void ValidityChecker::dataType(const std::vector<std::string>& names,
CompatCheckArgument(names.size() == types.size(), types,
"Expected names and types vectors to be of equal "
"length.");
- vector<CVC4::Datatype*> dv;
+ vector<CVC4::Datatype> dv;
// Set up the datatype specifications.
for(unsigned i = 0; i < names.size(); ++i) {
- CVC4::Datatype* dt = new CVC4::Datatype(names[i], false);
+ CVC4::Datatype dt(names[i], false);
CompatCheckArgument(constructors[i].size() == selectors[i].size(),
"Expected sub-vectors in constructors and selectors "
"vectors to match in size.");
@@ -1409,7 +1409,7 @@ void ValidityChecker::dataType(const std::vector<std::string>& names,
ctor.addArg(selectors[i][j][k], exprToType(types[i][j][k]));
}
}
- dt->addConstructor(ctor);
+ dt.addConstructor(ctor);
}
dv.push_back(dt);
}
diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp
index 525f8ead3..d36ff5a3d 100644
--- a/src/expr/expr_manager_template.cpp
+++ b/src/expr/expr_manager_template.cpp
@@ -645,10 +645,10 @@ SetType ExprManager::mkSetType(Type elementType) const {
return SetType(Type(d_nodeManager, new TypeNode(d_nodeManager->mkSetType(*elementType.d_typeNode))));
}
-DatatypeType ExprManager::mkDatatypeType(Datatype*& datatype) {
+DatatypeType ExprManager::mkDatatypeType(Datatype& datatype) {
// Not worth a special implementation; this doesn't need to be fast
// code anyway.
- vector<Datatype*> datatypes;
+ vector<Datatype> datatypes;
datatypes.push_back(datatype);
std::vector<DatatypeType> result;
mkMutualDatatypeTypes(datatypes, result);
@@ -656,28 +656,28 @@ DatatypeType ExprManager::mkDatatypeType(Datatype*& datatype) {
return result.front();
}
-void ExprManager::mkMutualDatatypeTypes(std::vector<Datatype*>& datatypes, std::vector<DatatypeType>& dtts) {
+void ExprManager::mkMutualDatatypeTypes(std::vector<Datatype>& datatypes, std::vector<DatatypeType>& dtts) {
std::set<Type> unresolvedTypes;
return mkMutualDatatypeTypes(datatypes, unresolvedTypes, dtts);
}
-void ExprManager::mkMutualDatatypeTypes(std::vector<Datatype*>& datatypes, std::set<Type>& unresolvedTypes, std::vector<DatatypeType>& dtts) {
+void ExprManager::mkMutualDatatypeTypes(std::vector<Datatype>& datatypes, std::set<Type>& unresolvedTypes, std::vector<DatatypeType>& dtts) {
NodeManagerScope nms(d_nodeManager);
std::map<std::string, DatatypeType> nameResolutions;
Trace("ajr-temp") << "Build datatypes..." << std::endl;
- //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 ) );
- //}
-
+ //have to build deep copy so that datatypes will live in NodeManager
+ 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 ) );
+ }
// First do some sanity checks, set up the final Type to be used for
// each datatype, and set up the "named resolutions" used to handle
// simple self- and mutual-recursion, for example in the definition
// "nat = succ(pred:nat) | zero", a named resolution can handle the
// pred selector.
- for(std::vector<Datatype*>::iterator i = datatypes.begin(), i_end = datatypes.end(); i != i_end; ++i) {
+ for(std::vector<Datatype*>::iterator i = dt_copies.begin(), i_end = dt_copies.end(); i != i_end; ++i) {
TypeNode* typeNode;
if( (*i)->getNumParameters() == 0 ) {
unsigned index = d_nodeManager->registerDatatype( *i );
@@ -699,7 +699,7 @@ void ExprManager::mkMutualDatatypeTypes(std::vector<Datatype*>& datatypes, std::
DatatypeType dtt(type);
PrettyCheckArgument(
nameResolutions.find((*i)->getName()) == nameResolutions.end(),
- datatypes,
+ dt_copies,
"cannot construct two datatypes at the same time "
"with the same name `%s'",
(*i)->getName().c_str());
diff --git a/src/expr/expr_manager_template.h b/src/expr/expr_manager_template.h
index 3f29396a3..d08c53e3d 100644
--- a/src/expr/expr_manager_template.h
+++ b/src/expr/expr_manager_template.h
@@ -374,13 +374,13 @@ public:
SetType mkSetType(Type elementType) const;
/** Make a type representing the given datatype. */
- DatatypeType mkDatatypeType(Datatype*& datatype);
+ DatatypeType mkDatatypeType(Datatype& datatype);
/**
* Make a set of types representing the given datatypes, which may be
* mutually recursive.
*/
- void mkMutualDatatypeTypes(std::vector<Datatype*>& datatypes, std::vector<DatatypeType>& dtts);
+ void mkMutualDatatypeTypes(std::vector<Datatype>& datatypes, std::vector<DatatypeType>& dtts);
/**
* Make a set of types representing the given datatypes, which may
@@ -411,7 +411,7 @@ public:
* then no complicated Type needs to be created, and the above,
* simpler form of mkMutualDatatypeTypes() is enough.
*/
- void mkMutualDatatypeTypes(std::vector<Datatype*>& datatypes, std::set<Type>& unresolvedTypes, std::vector<DatatypeType>& dtts);
+ void mkMutualDatatypeTypes(std::vector<Datatype>& datatypes, std::set<Type>& unresolvedTypes, std::vector<DatatypeType>& dtts);
/**
* Make a type representing a constructor with the given parameterization.
diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp
index af0b1a2d0..2e6792bdd 100644
--- a/src/expr/node_manager.cpp
+++ b/src/expr/node_manager.cpp
@@ -489,15 +489,15 @@ TypeNode NodeManager::mkSubrangeType(const SubrangeBounds& bounds)
TypeNode NodeManager::TupleTypeCache::getTupleType( NodeManager * nm, std::vector< TypeNode >& types, unsigned index ) {
if( index==types.size() ){
if( d_data.isNull() ){
- Datatype* dt = new Datatype("__cvc4_tuple");
- dt->setTuple();
+ Datatype dt("__cvc4_tuple");
+ dt.setTuple();
DatatypeConstructor c("__cvc4_tuple_ctor");
for (unsigned i = 0; i < types.size(); ++ i) {
std::stringstream ss;
ss << "__cvc4_tuple_stor_" << i;
c.addArg(ss.str().c_str(), types[i].toType());
}
- dt->addConstructor(c);
+ dt.addConstructor(c);
d_data = TypeNode::fromType(nm->toExprManager()->mkDatatypeType(dt));
Debug("tuprec-debug") << "Return type : " << d_data << std::endl;
}
@@ -511,13 +511,13 @@ TypeNode NodeManager::RecTypeCache::getRecordType( NodeManager * nm, const Recor
if( index==rec.getNumFields() ){
if( d_data.isNull() ){
const Record::FieldVector& fields = rec.getFields();
- Datatype* dt = new Datatype("__cvc4_record");
- dt->setRecord();
+ Datatype dt("__cvc4_record");
+ dt.setRecord();
DatatypeConstructor c("__cvc4_record_ctor");
for(Record::FieldVector::const_iterator i = fields.begin(); i != fields.end(); ++i) {
c.addArg((*i).first, (*i).second);
}
- dt->addConstructor(c);
+ dt.addConstructor(c);
d_data = TypeNode::fromType(nm->toExprManager()->mkDatatypeType(dt));
Debug("tuprec-debug") << "Return type : " << d_data << std::endl;
}
diff --git a/src/expr/node_manager.h b/src/expr/node_manager.h
index 9342a02c4..5e6fcf3d3 100644
--- a/src/expr/node_manager.h
+++ b/src/expr/node_manager.h
@@ -84,7 +84,7 @@ class NodeManager {
friend Expr ExprManager::mkVar(Type, uint32_t flags);
// friend so it can access NodeManager's d_listeners and notify clients
- friend void ExprManager::mkMutualDatatypeTypes(std::vector<Datatype*>&, std::set<Type>&, std::vector<DatatypeType>&);
+ friend void ExprManager::mkMutualDatatypeTypes(std::vector<Datatype>&, std::set<Type>&, std::vector<DatatypeType>&);
/** Predicate for use with STL algorithms */
struct NodeValueReferenceCountNonZero {
diff --git a/src/parser/cvc/Cvc.g b/src/parser/cvc/Cvc.g
index 7ca6beb60..8c5d97254 100644
--- a/src/parser/cvc/Cvc.g
+++ b/src/parser/cvc/Cvc.g
@@ -708,7 +708,7 @@ mainCommand[CVC4::Command*& cmd]
SExpr sexpr;
std::string id;
Type t;
- std::vector<CVC4::Datatype*> dts;
+ std::vector<CVC4::Datatype> dts;
Debug("parser-extra") << "command: " << AntlrInput::tokenText(LT(1)) << std::endl;
std::string s;
}
@@ -2175,7 +2175,7 @@ iteElseTerm[CVC4::Expr& f]
/**
* Parses a datatype definition
*/
-datatypeDef[std::vector<CVC4::Datatype*>& datatypes]
+datatypeDef[std::vector<CVC4::Datatype>& datatypes]
@init {
std::string id, id2;
Type t;
@@ -2195,7 +2195,7 @@ datatypeDef[std::vector<CVC4::Datatype*>& datatypes]
params.push_back( t ); }
)* RBRACKET
)?
- { datatypes.push_back(new Datatype(id, params, false));
+ { datatypes.push_back(Datatype(id, params, false));
if(!PARSER_STATE->isUnresolvedType(id)) {
// if not unresolved, must be undeclared
PARSER_STATE->checkDeclaration(id, CHECK_UNDECLARED, SYM_SORT);
@@ -2209,7 +2209,7 @@ datatypeDef[std::vector<CVC4::Datatype*>& datatypes]
/**
* Parses a constructor defintion for type
*/
-constructorDef[CVC4::Datatype*& type]
+constructorDef[CVC4::Datatype& type]
@init {
std::string id;
CVC4::DatatypeConstructor* ctor = NULL;
@@ -2227,7 +2227,7 @@ constructorDef[CVC4::Datatype*& type]
RPAREN
)?
{ // make the constructor
- type->addConstructor(*ctor);
+ type.addConstructor(*ctor);
Debug("parser-idt") << "constructor: " << id.c_str() << std::endl;
delete ctor;
}
diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp
index e46c13140..cef8c4be4 100644
--- a/src/parser/parser.cpp
+++ b/src/parser/parser.cpp
@@ -303,7 +303,7 @@ bool Parser::isUnresolvedType(const std::string& name) {
return d_unresolved.find(getSort(name)) != d_unresolved.end();
}
-void Parser::mkMutualDatatypeTypes(std::vector<Datatype*>& datatypes, std::vector<DatatypeType>& types) {
+void Parser::mkMutualDatatypeTypes(std::vector<Datatype>& datatypes, std::vector<DatatypeType>& types) {
try {
d_exprManager->mkMutualDatatypeTypes(datatypes, d_unresolved, types);
diff --git a/src/parser/parser.h b/src/parser/parser.h
index 52f8dcb86..7c9870edb 100644
--- a/src/parser/parser.h
+++ b/src/parser/parser.h
@@ -501,7 +501,7 @@ public:
/**
* Create sorts of mutually-recursive datatypes.
*/
- void mkMutualDatatypeTypes(std::vector<Datatype*>& datatypes, std::vector<DatatypeType>& dtts);
+ void mkMutualDatatypeTypes(std::vector<Datatype>& datatypes, std::vector<DatatypeType>& dtts);
/**
* Add an operator to the current legal set.
diff --git a/src/parser/smt2/Smt2.g b/src/parser/smt2/Smt2.g
index 0fbd454b4..3bd308559 100644
--- a/src/parser/smt2/Smt2.g
+++ b/src/parser/smt2/Smt2.g
@@ -512,7 +512,7 @@ sygusCommand returns [CVC4::Command* cmd = NULL]
SExpr sexpr;
CommandSequence* seq;
std::vector< std::vector< CVC4::SygusGTerm > > sgts;
- std::vector< CVC4::Datatype* > datatypes;
+ std::vector< CVC4::Datatype > datatypes;
std::vector< std::vector<Expr> > ops;
std::vector< std::vector< std::string > > cnames;
std::vector< std::vector< std::vector< CVC4::Type > > > cargs;
@@ -621,14 +621,14 @@ sygusCommand returns [CVC4::Command* cmd = NULL]
//swap index if necessary
Debug("parser-sygus") << "--- Making sygus datatypes..." << std::endl;
for( unsigned i=0; i<datatypes.size(); i++ ){
- Debug("parser-sygus") << "..." << datatypes[i]->getName() << " has builtin sort " << sorts[i] << std::endl;
+ Debug("parser-sygus") << "..." << datatypes[i].getName() << " has builtin sort " << sorts[i] << std::endl;
}
for( unsigned i=0; i<datatypes.size(); i++ ){
- Debug("parser-sygus") << "...make " << datatypes[i]->getName() << " with builtin sort " << sorts[i] << std::endl;
+ Debug("parser-sygus") << "...make " << datatypes[i].getName() << " with builtin sort " << sorts[i] << std::endl;
if( sorts[i].isNull() ){
PARSER_STATE->parseError(std::string("Internal error : could not infer builtin sort for nested gterm."));
}
- datatypes[i]->setSygus( sorts[i], terms[0], allow_const[i], false );
+ datatypes[i].setSygus( sorts[i], terms[0], allow_const[i], false );
PARSER_STATE->mkSygusDatatype( datatypes[i], ops[i], cnames[i], cargs[i], unresolved_gterm_sym[i], sygus_to_builtin );
}
PARSER_STATE->setSygusStartIndex( fun, startIndex, datatypes, sorts, ops );
@@ -637,7 +637,7 @@ sygusCommand returns [CVC4::Command* cmd = NULL]
PARSER_STATE->popScope();
Debug("parser-sygus") << "--- Make " << datatypes.size() << " mutual datatypes..." << std::endl;
for( unsigned i=0; i<datatypes.size(); i++ ){
- Debug("parser-sygus") << " " << i << " : " << datatypes[i]->getName() << std::endl;
+ Debug("parser-sygus") << " " << i << " : " << datatypes[i].getName() << std::endl;
}
seq = new CommandSequence();
std::vector<DatatypeType> datatypeTypes;
@@ -1169,7 +1169,7 @@ smt25Command[CVC4::Command*& cmd]
extendedCommand[CVC4::Command*& cmd]
@declarations {
- std::vector<CVC4::Datatype*> dts;
+ std::vector<CVC4::Datatype> dts;
Expr e, e2;
Type t;
std::string name;
@@ -1325,7 +1325,7 @@ extendedCommand[CVC4::Command*& cmd]
datatypesDefCommand[bool isCo, CVC4::Command*& cmd]
@declarations {
- std::vector<CVC4::Datatype*> dts;
+ std::vector<CVC4::Datatype> dts;
std::vector<CVC4::DatatypeType> dtts;
std::string name;
std::vector<Type> sorts;
@@ -2475,7 +2475,7 @@ nonemptyNumeralList[std::vector<uint64_t>& numerals]
/**
* Parses a datatype definition
*/
-datatypeDef[bool isCo, std::vector<CVC4::Datatype*>& datatypes, std::vector< CVC4::Type >& params]
+datatypeDef[bool isCo, std::vector<CVC4::Datatype>& datatypes, std::vector< CVC4::Type >& params]
@init {
std::string id;
}
@@ -2493,7 +2493,7 @@ datatypeDef[bool isCo, std::vector<CVC4::Datatype*>& datatypes, std::vector< CVC
params.push_back( t ); }
)* ']'
)?*/ //AJR: this isn't necessary if we use z3's style
- { datatypes.push_back(new Datatype(id,params,isCo));
+ { datatypes.push_back(Datatype(id,params,isCo));
if(!PARSER_STATE->isUnresolvedType(id)) {
// if not unresolved, must be undeclared
PARSER_STATE->checkDeclaration(id, CHECK_UNDECLARED, SYM_SORT);
@@ -2506,7 +2506,7 @@ datatypeDef[bool isCo, std::vector<CVC4::Datatype*>& datatypes, std::vector< CVC
/**
* Parses a constructor defintion for type
*/
-constructorDef[CVC4::Datatype*& type]
+constructorDef[CVC4::Datatype& type]
@init {
std::string id;
CVC4::DatatypeConstructor* ctor = NULL;
@@ -2520,7 +2520,7 @@ constructorDef[CVC4::Datatype*& type]
}
( LPAREN_TOK selector[*ctor] RPAREN_TOK )*
{ // make the constructor
- type->addConstructor(*ctor);
+ type.addConstructor(*ctor);
Debug("parser-idt") << "constructor: " << id.c_str() << std::endl;
delete ctor;
}
diff --git a/src/parser/smt2/smt2.cpp b/src/parser/smt2/smt2.cpp
index dd48ceca7..8db344f92 100644
--- a/src/parser/smt2/smt2.cpp
+++ b/src/parser/smt2/smt2.cpp
@@ -563,7 +563,7 @@ void collectSygusGrammarTypesFor( Type range, std::vector< Type >& types, std::m
}
}
-void Smt2::mkSygusDefaultGrammar( const Type& range, Expr& bvl, const std::string& fun, std::vector< CVC4::Datatype* >& datatypes,
+void Smt2::mkSygusDefaultGrammar( const Type& range, Expr& bvl, const std::string& fun, std::vector<CVC4::Datatype>& datatypes,
std::vector<Type>& sorts, std::vector< std::vector<Expr> >& ops, std::vector<Expr> sygus_vars, int& startIndex ) {
//if( !range.isBoolean() && !range.isInteger() && !range.isBitVector() && !range.isDatatype() ){
@@ -594,7 +594,7 @@ void Smt2::mkSygusDefaultGrammar( const Type& range, Expr& bvl, const std::strin
std::stringstream ss;
ss << fun << "_" << types[i];
std::string dname = ss.str();
- datatypes.push_back(new Datatype(dname));
+ datatypes.push_back(Datatype(dname));
ops.push_back(std::vector<Expr>());
//make unresolved type
Type unres_t = mkUnresolvedType(dname);
@@ -683,7 +683,7 @@ void Smt2::mkSygusDefaultGrammar( const Type& range, Expr& bvl, const std::strin
}
}
Debug("parser-sygus") << "...make datatype " << datatypes.back() << std::endl;
- datatypes[i]->setSygus( types[i], bvl, true, true );
+ datatypes[i].setSygus( types[i], bvl, true, true );
mkSygusDatatype( datatypes[i], ops[i], cnames, cargs, unresolved_gterm_sym, sygus_to_builtin );
sorts.push_back( types[i] );
//set start index if applicable
@@ -694,12 +694,12 @@ void Smt2::mkSygusDefaultGrammar( const Type& range, Expr& bvl, const std::strin
//make Boolean type
Type btype = getExprManager()->booleanType();
- datatypes.push_back(new Datatype(dbname));
+ datatypes.push_back(Datatype(dbname));
ops.push_back(std::vector<Expr>());
std::vector<std::string> cnames;
std::vector<std::vector<CVC4::Type> > cargs;
std::vector<std::string> unresolved_gterm_sym;
- Debug("parser-sygus") << "Make grammar for " << btype << " " << *(datatypes.back()) << std::endl;
+ Debug("parser-sygus") << "Make grammar for " << btype << " " << datatypes.back() << std::endl;
//add variables
for( unsigned i=0; i<sygus_vars.size(); i++ ){
if( sygus_vars[i].getType().isBoolean() ){
@@ -776,8 +776,8 @@ void Smt2::mkSygusDefaultGrammar( const Type& range, Expr& bvl, const std::strin
if( range==btype ){
startIndex = sorts.size();
}
- Debug("parser-sygus") << "...make datatype " << *(datatypes.back()) << std::endl;
- datatypes.back()->setSygus( btype, bvl, true, true );
+ Debug("parser-sygus") << "...make datatype " << datatypes.back() << std::endl;
+ datatypes.back().setSygus( btype, bvl, true, true );
mkSygusDatatype( datatypes.back(), ops.back(), cnames, cargs, unresolved_gterm_sym, sygus_to_builtin );
sorts.push_back( btype );
@@ -804,7 +804,7 @@ void Smt2::mkSygusConstantsForType( const Type& type, std::vector<CVC4::Expr>& o
// This method adds N operators to ops[index], N names to cnames[index] and N type argument vectors to cargs[index] (where typically N=1)
// This method may also add new elements pairwise into datatypes/sorts/ops/cnames/cargs in the case of non-flat gterms.
void Smt2::processSygusGTerm( CVC4::SygusGTerm& sgt, int index,
- std::vector< CVC4::Datatype* >& datatypes,
+ std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
@@ -848,7 +848,7 @@ void Smt2::processSygusGTerm( CVC4::SygusGTerm& sgt, int index,
cargs[index].push_back( std::vector< CVC4::Type >() );
for( unsigned i=0; i<sgt.d_children.size(); i++ ){
std::stringstream ss;
- ss << datatypes[index]->getName() << "_" << ops[index].size() << "_arg_" << i;
+ ss << datatypes[index].getName() << "_" << ops[index].size() << "_arg_" << i;
std::string sub_dname = ss.str();
//add datatype for child
Type null_type;
@@ -921,7 +921,7 @@ void Smt2::processSygusGTerm( CVC4::SygusGTerm& sgt, int index,
}
bool Smt2::pushSygusDatatypeDef( Type t, std::string& dname,
- std::vector< CVC4::Datatype* >& datatypes,
+ std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
@@ -929,7 +929,7 @@ bool Smt2::pushSygusDatatypeDef( Type t, std::string& dname,
std::vector< bool >& allow_const,
std::vector< std::vector< std::string > >& unresolved_gterm_sym ){
sorts.push_back(t);
- datatypes.push_back(new Datatype(dname));
+ datatypes.push_back(Datatype(dname));
ops.push_back(std::vector<Expr>());
cnames.push_back(std::vector<std::string>());
cargs.push_back(std::vector<std::vector<CVC4::Type> >());
@@ -938,7 +938,7 @@ bool Smt2::pushSygusDatatypeDef( Type t, std::string& dname,
return true;
}
-bool Smt2::popSygusDatatypeDef( std::vector< CVC4::Datatype* >& datatypes,
+bool Smt2::popSygusDatatypeDef( std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
@@ -955,7 +955,7 @@ bool Smt2::popSygusDatatypeDef( std::vector< CVC4::Datatype* >& datatypes,
return true;
}
-Type Smt2::processSygusNestedGTerm( int sub_dt_index, std::string& sub_dname, std::vector< CVC4::Datatype* >& datatypes,
+Type Smt2::processSygusNestedGTerm( int sub_dt_index, std::string& sub_dname, std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
@@ -1024,7 +1024,7 @@ Type Smt2::processSygusNestedGTerm( int sub_dt_index, std::string& sub_dname, st
sygus_to_builtin[t] = curr_t;
}else{
Debug("parser-sygus") << "simple argument " << t << std::endl;
- Debug("parser-sygus") << "...removing " << datatypes.back()->getName() << std::endl;
+ Debug("parser-sygus") << "...removing " << datatypes.back().getName() << std::endl;
//otherwise, datatype was unecessary
//pop argument datatype definition
popSygusDatatypeDef( datatypes, sorts, ops, cnames, cargs, allow_const, unresolved_gterm_sym );
@@ -1034,7 +1034,7 @@ Type Smt2::processSygusNestedGTerm( int sub_dt_index, std::string& sub_dname, st
void Smt2::processSygusLetConstructor( std::vector< CVC4::Expr >& let_vars,
int index,
- std::vector< CVC4::Datatype* >& datatypes,
+ std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
@@ -1045,7 +1045,7 @@ void Smt2::processSygusLetConstructor( std::vector< CVC4::Expr >& let_vars,
std::vector< CVC4::Expr > let_define_args;
Expr let_body;
int dindex = cargs[index].size()-1;
- Debug("parser-sygus") << "Process let constructor for datatype " << datatypes[index]->getName() << ", #subtypes = " << cargs[index][dindex].size() << std::endl;
+ Debug("parser-sygus") << "Process let constructor for datatype " << datatypes[index].getName() << ", #subtypes = " << cargs[index][dindex].size() << std::endl;
for( unsigned i=0; i<cargs[index][dindex].size(); i++ ){
Debug("parser-sygus") << " " << i << " : " << cargs[index][dindex][i] << std::endl;
if( i+1==cargs[index][dindex].size() ){
@@ -1054,7 +1054,7 @@ void Smt2::processSygusLetConstructor( std::vector< CVC4::Expr >& let_vars,
let_body = it->second;
}else{
std::stringstream ss;
- ss << datatypes[index]->getName() << "_body";
+ ss << datatypes[index].getName() << "_body";
let_body = mkBoundVar(ss.str(), sygus_to_builtin[cargs[index][dindex][i]]);
d_sygus_bound_var_type[let_body] = cargs[index][dindex][i];
}
@@ -1094,7 +1094,7 @@ void Smt2::processSygusLetConstructor( std::vector< CVC4::Expr >& let_vars,
Type ft = getExprManager()->mkFunctionType(fsorts, let_body.getType());
std::stringstream ss;
- ss << datatypes[index]->getName() << "_let";
+ ss << datatypes[index].getName() << "_let";
Expr let_func = mkFunction(ss.str(), ft, ExprManager::VAR_FLAG_DEFINED);
d_sygus_defined_funs.push_back( let_func );
preemptCommand( new DefineFunctionCommand(ss.str(), let_func, let_define_args, let_body) );
@@ -1130,11 +1130,11 @@ void Smt2::collectSygusLetArgs( CVC4::Expr e, std::vector< CVC4::Type >& sygusAr
}
void Smt2::setSygusStartIndex( std::string& fun, int startIndex,
- std::vector< CVC4::Datatype* >& datatypes,
+ std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops ) {
if( startIndex>0 ){
- CVC4::Datatype* tmp_dt = datatypes[0];
+ CVC4::Datatype tmp_dt = datatypes[0];
Type tmp_sort = sorts[0];
std::vector< Expr > tmp_ops;
tmp_ops.insert( tmp_ops.end(), ops[0].begin(), ops[0].end() );
@@ -1218,11 +1218,11 @@ void Smt2::defineSygusFuns() {
}
}
-void Smt2::mkSygusDatatype( CVC4::Datatype* dt, std::vector<CVC4::Expr>& ops,
+void Smt2::mkSygusDatatype( CVC4::Datatype& dt, std::vector<CVC4::Expr>& ops,
std::vector<std::string>& cnames, std::vector< std::vector< CVC4::Type > >& cargs,
std::vector<std::string>& unresolved_gterm_sym,
std::map< CVC4::Type, CVC4::Type >& sygus_to_builtin ) {
- Debug("parser-sygus") << "Making sygus datatype " << dt->getName() << std::endl;
+ Debug("parser-sygus") << "Making sygus datatype " << dt.getName() << std::endl;
Debug("parser-sygus") << " add constructors..." << std::endl;
for( int i=0; i<(int)cnames.size(); i++ ){
bool is_dup = false;
@@ -1260,7 +1260,7 @@ void Smt2::mkSygusDatatype( CVC4::Datatype* dt, std::vector<CVC4::Expr>& ops,
for( unsigned j=0; j<cargs[i].size(); j++ ){
Type bt = sygus_to_builtin[cargs[i][j]];
std::stringstream ss;
- ss << dt->getName() << "_x_" << i << "_" << j;
+ ss << dt.getName() << "_x_" << i << "_" << j;
Expr v = mkBoundVar(ss.str(), bt);
let_args.push_back( v );
fsorts.push_back( bt );
@@ -1280,7 +1280,7 @@ void Smt2::mkSygusDatatype( CVC4::Datatype* dt, std::vector<CVC4::Expr>& ops,
Type ft = getExprManager()->mkFunctionType(fsorts, let_body.getType());
Debug("parser-sygus") << ": function type is " << ft << std::endl;
std::stringstream ss;
- ss << dt->getName() << "_df_" << i;
+ ss << dt.getName() << "_df_" << i;
//replace operator and name
ops[i] = mkFunction(ss.str(), ft, ExprManager::VAR_FLAG_DEFINED);
cnames[i] = ss.str();
@@ -1309,7 +1309,7 @@ void Smt2::mkSygusDatatype( CVC4::Datatype* dt, std::vector<CVC4::Expr>& ops,
if( std::find( types.begin(), types.end(), t )==types.end() ){
types.push_back( t );
//identity element
- Type bt = dt->getSygusType();
+ Type bt = dt.getSygusType();
Debug("parser-sygus") << ": make identity function for " << bt << ", argument type " << t << std::endl;
std::stringstream ss;
ss << t << "_x_id";
@@ -1338,19 +1338,19 @@ void Smt2::mkSygusDatatype( CVC4::Datatype* dt, std::vector<CVC4::Expr>& ops,
}
-void Smt2::addSygusDatatypeConstructor( CVC4::Datatype* dt, CVC4::Expr op, std::string& cname, std::vector< CVC4::Type >& cargs,
+void Smt2::addSygusDatatypeConstructor( CVC4::Datatype& dt, CVC4::Expr op, std::string& cname, std::vector< CVC4::Type >& cargs,
CVC4::Expr& let_body, std::vector< CVC4::Expr >& let_args, unsigned let_num_input_args ) {
- Debug("parser-sygus") << "--> Add constructor " << cname << " to " << dt->getName() << std::endl;
+ Debug("parser-sygus") << "--> Add constructor " << cname << " to " << dt.getName() << std::endl;
if( !let_body.isNull() ){
Debug("parser-sygus") << " let body = " << let_body << ", args = " << let_args.size() << "," << let_num_input_args << std::endl;
//TODO : remove arguments not occurring in body
//if this is a self identity function, ignore
if( let_args.size()==0 && let_args[0]==let_body ){
- Debug("parser-sygus") << " identity function " << cargs[0] << " to " << dt->getName() << std::endl;
+ Debug("parser-sygus") << " identity function " << cargs[0] << " to " << dt.getName() << std::endl;
//TODO
}
}
- std::string name = dt->getName() + "_" + cname;
+ std::string name = dt.getName() + "_" + cname;
std::string testerId("is-");
testerId.append(name);
checkDeclaration(name, CHECK_UNDECLARED, SYM_VARIABLE);
@@ -1363,7 +1363,7 @@ void Smt2::addSygusDatatypeConstructor( CVC4::Datatype* dt, CVC4::Expr op, std::
sname << name << "_" << j;
c.addArg(sname.str(), cargs[j]);
}
- dt->addConstructor(c);
+ dt.addConstructor(c);
}
diff --git a/src/parser/smt2/smt2.h b/src/parser/smt2/smt2.h
index ac4be9bee..b99e142ba 100644
--- a/src/parser/smt2/smt2.h
+++ b/src/parser/smt2/smt2.h
@@ -173,13 +173,13 @@ public:
Expr mkSygusVar(const std::string& name, const Type& type, bool isPrimed = false);
- void mkSygusDefaultGrammar( const Type& range, Expr& bvl, const std::string& fun, std::vector< CVC4::Datatype* >& datatypes,
+ void mkSygusDefaultGrammar( const Type& range, Expr& bvl, const std::string& fun, std::vector<CVC4::Datatype>& datatypes,
std::vector<Type>& sorts, std::vector< std::vector<Expr> >& ops, std::vector<Expr> sygus_vars, int& startIndex );
void mkSygusConstantsForType( const Type& type, std::vector<CVC4::Expr>& ops );
void processSygusGTerm( CVC4::SygusGTerm& sgt, int index,
- std::vector< CVC4::Datatype* >& datatypes,
+ std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
@@ -191,7 +191,7 @@ public:
CVC4::Type& ret, bool isNested = false );
static bool pushSygusDatatypeDef( Type t, std::string& dname,
- std::vector< CVC4::Datatype* >& datatypes,
+ std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
@@ -199,7 +199,7 @@ public:
std::vector< bool >& allow_const,
std::vector< std::vector< std::string > >& unresolved_gterm_sym );
- static bool popSygusDatatypeDef( std::vector< CVC4::Datatype* >& datatypes,
+ static bool popSygusDatatypeDef( std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
@@ -208,7 +208,7 @@ public:
std::vector< std::vector< std::string > >& unresolved_gterm_sym );
void setSygusStartIndex( std::string& fun, int startIndex,
- std::vector< CVC4::Datatype* >& datatypes,
+ std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops );
@@ -218,7 +218,7 @@ public:
void defineSygusFuns();
- void mkSygusDatatype( CVC4::Datatype* dt, std::vector<CVC4::Expr>& ops,
+ void mkSygusDatatype( CVC4::Datatype& dt, std::vector<CVC4::Expr>& ops,
std::vector<std::string>& cnames, std::vector< std::vector< CVC4::Type > >& cargs,
std::vector<std::string>& unresolved_gterm_sym,
std::map< CVC4::Type, CVC4::Type >& sygus_to_builtin );
@@ -314,10 +314,10 @@ private:
void collectSygusLetArgs( CVC4::Expr e, std::vector< CVC4::Type >& sygusArgs, std::vector< CVC4::Expr >& builtinArgs );
- void addSygusDatatypeConstructor( CVC4::Datatype* dt, CVC4::Expr op, std::string& cname, std::vector< CVC4::Type >& cargs,
+ void addSygusDatatypeConstructor( CVC4::Datatype& dt, CVC4::Expr op, std::string& cname, std::vector< CVC4::Type >& cargs,
CVC4::Expr& let_body, std::vector< CVC4::Expr >& let_args, unsigned let_num_input_args );
- Type processSygusNestedGTerm( int sub_dt_index, std::string& sub_dname, std::vector< CVC4::Datatype* >& datatypes,
+ Type processSygusNestedGTerm( int sub_dt_index, std::string& sub_dname, std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
@@ -328,7 +328,7 @@ private:
std::map< CVC4::Type, CVC4::Expr >& sygus_to_builtin_expr, Type sub_ret );
void processSygusLetConstructor( std::vector< CVC4::Expr >& let_vars, int index,
- std::vector< CVC4::Datatype* >& datatypes,
+ std::vector< CVC4::Datatype >& datatypes,
std::vector< CVC4::Type>& sorts,
std::vector< std::vector<CVC4::Expr> >& ops,
std::vector< std::vector<std::string> >& cnames,
diff --git a/src/smt/boolean_terms.cpp b/src/smt/boolean_terms.cpp
index e9b51c47b..0771cfc06 100644
--- a/src/smt/boolean_terms.cpp
+++ b/src/smt/boolean_terms.cpp
@@ -60,10 +60,10 @@ BooleanTermConverter::BooleanTermConverter(SmtEngine& smt) :
d_ffDt = d_ff;
d_ttDt = d_tt;
} else {
- Datatype* spec = new Datatype("BooleanTerm");
+ Datatype spec("BooleanTerm");
// don't change the order; false is assumed to come first by the model postprocessor
- spec->addConstructor(DatatypeConstructor("BT_False"));
- spec->addConstructor(DatatypeConstructor("BT_True"));
+ spec.addConstructor(DatatypeConstructor("BT_False"));
+ spec.addConstructor(DatatypeConstructor("BT_True"));
const Datatype& dt = NodeManager::currentNM()->toExprManager()->mkDatatypeType(spec).getDatatype();
d_ffDt = NodeManager::currentNM()->mkNode(kind::APPLY_CONSTRUCTOR, Node::fromExpr(dt["BT_False"].getConstructor()));
d_ttDt = NodeManager::currentNM()->mkNode(kind::APPLY_CONSTRUCTOR, Node::fromExpr(dt["BT_True"].getConstructor()));
@@ -255,13 +255,13 @@ const Datatype& BooleanTermConverter::convertDatatype(const Datatype& dt) throw(
mySelfType = NodeManager::currentNM()->toExprManager()->mkSortConstructor(dt.getName() + "'", dt.getNumParameters());
unresolvedTypes.insert(mySelfType);
}
- vector<Datatype*> newDtVector;
+ vector<Datatype> newDtVector;
if(dt.isParametric()) {
- newDtVector.push_back(new Datatype(dt.getName() + "'", dt.getParameters(), false));
+ newDtVector.push_back(Datatype(dt.getName() + "'", dt.getParameters(), false));
} else {
- newDtVector.push_back(new Datatype(dt.getName() + "'", false));
+ newDtVector.push_back(Datatype(dt.getName() + "'", false));
}
- Datatype * newDt = newDtVector.front();
+ Datatype& newDt = newDtVector.front();
Debug("boolean-terms") << "found a Boolean arg in constructor " << (*c).getName() << endl;
for(c = dt.begin(); c != dt.end(); ++c) {
DatatypeConstructor ctor((*c).getName() + "'", (*c).getTesterName() + "'");
@@ -286,7 +286,7 @@ const Datatype& BooleanTermConverter::convertDatatype(const Datatype& dt) throw(
}
}
}
- newDt->addConstructor(ctor);
+ newDt.addConstructor(ctor);
}
vector<DatatypeType> newDttVector;
NodeManager::currentNM()->toExprManager()->mkMutualDatatypeTypes(newDtVector, unresolvedTypes, newDttVector);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback