summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2019-12-06 11:00:33 -0600
committerGitHub <noreply@github.com>2019-12-06 11:00:33 -0600
commitc7c2d593674e3776ab0c720be1c0c759db8f9453 (patch)
treefc129a2f0453eb2944009249c4a83ba3bdbaf5a0
parent499aa5641e2b830f60159c2ce1c791bf4d45aac1 (diff)
Add ExprManager as argument to Datatype (#3535)
-rw-r--r--examples/api/datatypes-new.cpp8
-rw-r--r--examples/api/datatypes.cpp4
-rw-r--r--examples/api/java/Datatypes.java2
-rw-r--r--src/api/cvc4cpp.cpp44
-rw-r--r--src/api/cvc4cpp.h103
-rw-r--r--src/expr/datatype.cpp9
-rw-r--r--src/expr/datatype.h7
-rw-r--r--src/expr/node_manager.cpp4
-rw-r--r--src/expr/sygus_datatype.cpp5
-rw-r--r--src/parser/cvc/Cvc.g2
-rw-r--r--src/parser/smt2/Smt2.g8
-rw-r--r--src/parser/smt2/smt2.cpp2
-rw-r--r--src/parser/smt2/smt2.h35
-rw-r--r--test/unit/api/datatype_api_black.h2
-rw-r--r--test/unit/api/solver_black.h10
-rw-r--r--test/unit/api/sort_black.h12
-rw-r--r--test/unit/expr/expr_public.h2
-rw-r--r--test/unit/theory/type_enumerator_white.h6
-rw-r--r--test/unit/util/datatype_black.h24
19 files changed, 187 insertions, 102 deletions
diff --git a/examples/api/datatypes-new.cpp b/examples/api/datatypes-new.cpp
index 9ff05ac0d..43f97796e 100644
--- a/examples/api/datatypes-new.cpp
+++ b/examples/api/datatypes-new.cpp
@@ -85,8 +85,9 @@ void test(Solver& slv, Sort& consListSort)
// This example builds a simple parameterized list of sort T, with one
// constructor "cons".
Sort sort = slv.mkParamSort("T");
- DatatypeDecl paramConsListSpec("paramlist",
- sort); // give the datatype a name
+ DatatypeDecl paramConsListSpec =
+ slv.mkDatatypeDecl("paramlist",
+ sort); // give the datatype a name
DatatypeConstructorDecl paramCons("cons");
DatatypeConstructorDecl paramNil("nil");
DatatypeSelectorDecl paramHead("head", sort);
@@ -139,7 +140,8 @@ int main()
// Second, it is "resolved" to an actual sort, at which point function
// symbols are assigned to its constructors, selectors, and testers.
- DatatypeDecl consListSpec("list"); // give the datatype a name
+ DatatypeDecl consListSpec =
+ slv.mkDatatypeDecl("list"); // give the datatype a name
DatatypeConstructorDecl cons("cons");
DatatypeSelectorDecl head("head", slv.getIntegerSort());
DatatypeSelectorDecl tail("tail", DatatypeDeclSelfSort());
diff --git a/examples/api/datatypes.cpp b/examples/api/datatypes.cpp
index 34d440e3e..a749f0a0f 100644
--- a/examples/api/datatypes.cpp
+++ b/examples/api/datatypes.cpp
@@ -31,7 +31,7 @@ int main() {
// is specified. Second, it is "resolved"---at which point function
// symbols are assigned to its constructors, selectors, and testers.
- Datatype consListSpec("list"); // give the datatype a name
+ Datatype consListSpec(&em, "list"); // give the datatype a name
DatatypeConstructor cons("cons");
cons.addArg("head", em.integerType());
cons.addArg("tail", DatatypeSelfType()); // a list
@@ -103,7 +103,7 @@ int main() {
// This example builds a simple parameterized list of sort T, with one
// constructor "cons".
Type sort = em.mkSort("T", ExprManager::SORT_FLAG_PLACEHOLDER);
- Datatype paramConsListSpec("list", std::vector<Type>{sort});
+ Datatype paramConsListSpec(&em, "list", std::vector<Type>{sort});
DatatypeConstructor paramCons("cons");
DatatypeConstructor paramNil("nil");
paramCons.addArg("head", sort);
diff --git a/examples/api/java/Datatypes.java b/examples/api/java/Datatypes.java
index 2c79bb75f..c5efe3d06 100644
--- a/examples/api/java/Datatypes.java
+++ b/examples/api/java/Datatypes.java
@@ -31,7 +31,7 @@ public class Datatypes {
// is specified. Second, it is "resolved"---at which point function
// symbols are assigned to its constructors, selectors, and testers.
- Datatype consListSpec = new Datatype("list"); // give the datatype a name
+ Datatype consListSpec = new Datatype(em, "list"); // give a name
DatatypeConstructor cons = new DatatypeConstructor("cons");
cons.addArg("head", em.integerType());
cons.addArg("tail", new DatatypeSelfType()); // a list
diff --git a/src/api/cvc4cpp.cpp b/src/api/cvc4cpp.cpp
index 7a3577e0d..f7ffe850a 100644
--- a/src/api/cvc4cpp.cpp
+++ b/src/api/cvc4cpp.cpp
@@ -1680,20 +1680,26 @@ std::ostream& operator<<(std::ostream& out,
/* DatatypeDecl ------------------------------------------------------------- */
-DatatypeDecl::DatatypeDecl(const std::string& name, bool isCoDatatype)
- : d_dtype(new CVC4::Datatype(name, isCoDatatype))
+DatatypeDecl::DatatypeDecl(const Solver* s,
+ const std::string& name,
+ bool isCoDatatype)
+ : d_dtype(new CVC4::Datatype(s->getExprManager(), name, isCoDatatype))
{
}
-DatatypeDecl::DatatypeDecl(const std::string& name,
+DatatypeDecl::DatatypeDecl(const Solver* s,
+ const std::string& name,
Sort param,
bool isCoDatatype)
- : d_dtype(new CVC4::Datatype(
- name, std::vector<Type>{*param.d_type}, isCoDatatype))
+ : d_dtype(new CVC4::Datatype(s->getExprManager(),
+ name,
+ std::vector<Type>{*param.d_type},
+ isCoDatatype))
{
}
-DatatypeDecl::DatatypeDecl(const std::string& name,
+DatatypeDecl::DatatypeDecl(const Solver* s,
+ const std::string& name,
const std::vector<Sort>& params,
bool isCoDatatype)
{
@@ -1703,7 +1709,7 @@ DatatypeDecl::DatatypeDecl(const std::string& name,
tparams.push_back(*s.d_type);
}
d_dtype = std::shared_ptr<CVC4::Datatype>(
- new CVC4::Datatype(name, tparams, isCoDatatype));
+ new CVC4::Datatype(s->getExprManager(), name, tparams, isCoDatatype));
}
DatatypeDecl::~DatatypeDecl() {}
@@ -2867,6 +2873,28 @@ Term Solver::mkVar(Sort sort, const std::string& symbol) const
CVC4_API_SOLVER_TRY_CATCH_END;
}
+/* Create datatype declarations */
+/* -------------------------------------------------------------------------- */
+
+DatatypeDecl Solver::mkDatatypeDecl(const std::string& name, bool isCoDatatype)
+{
+ return DatatypeDecl(this, name, isCoDatatype);
+}
+
+DatatypeDecl Solver::mkDatatypeDecl(const std::string& name,
+ Sort param,
+ bool isCoDatatype)
+{
+ return DatatypeDecl(this, name, param, isCoDatatype);
+}
+
+DatatypeDecl Solver::mkDatatypeDecl(const std::string& name,
+ const std::vector<Sort>& params,
+ bool isCoDatatype)
+{
+ return DatatypeDecl(this, name, params, isCoDatatype);
+}
+
/* Create terms */
/* -------------------------------------------------------------------------- */
@@ -3409,7 +3437,7 @@ Sort Solver::declareDatatype(
{
CVC4_API_ARG_CHECK_EXPECTED(ctors.size() > 0, ctors)
<< "a datatype declaration with at least one constructor";
- DatatypeDecl dtdecl(symbol);
+ DatatypeDecl dtdecl(this, symbol);
for (const DatatypeConstructorDecl& ctor : ctors)
{
dtdecl.addConstructor(ctor);
diff --git a/src/api/cvc4cpp.h b/src/api/cvc4cpp.h
index 8c9bdc10c..e05c228bc 100644
--- a/src/api/cvc4cpp.h
+++ b/src/api/cvc4cpp.h
@@ -1093,6 +1093,7 @@ class CVC4_PUBLIC DatatypeConstructorDecl
std::shared_ptr<CVC4::DatatypeConstructor> d_ctor;
};
+class Solver;
/**
* A CVC4 datatype declaration.
*/
@@ -1100,37 +1101,8 @@ class CVC4_PUBLIC DatatypeDecl
{
friend class DatatypeConstructorArg;
friend class Solver;
-
public:
/**
- * Constructor.
- * @param name the name of the datatype
- * @param isCoDatatype true if a codatatype is to be constructed
- * @return the DatatypeDecl
- */
- DatatypeDecl(const std::string& name, bool isCoDatatype = false);
-
- /**
- * Constructor for parameterized datatype declaration.
- * Create sorts parameter with Solver::mkParamSort().
- * @param name the name of the datatype
- * @param param the sort parameter
- * @param isCoDatatype true if a codatatype is to be constructed
- */
- DatatypeDecl(const std::string& name, Sort param, bool isCoDatatype = false);
-
- /**
- * Constructor for parameterized datatype declaration.
- * Create sorts parameter with Solver::mkParamSort().
- * @param name the name of the datatype
- * @param params a list of sort parameters
- * @param isCoDatatype true if a codatatype is to be constructed
- */
- DatatypeDecl(const std::string& name,
- const std::vector<Sort>& params,
- bool isCoDatatype = false);
-
- /**
* Destructor.
*/
~DatatypeDecl();
@@ -1157,6 +1129,42 @@ class CVC4_PUBLIC DatatypeDecl
const CVC4::Datatype& getDatatype(void) const;
private:
+ /**
+ * Constructor.
+ * @param s the solver that created this datatype declaration
+ * @param name the name of the datatype
+ * @param isCoDatatype true if a codatatype is to be constructed
+ * @return the DatatypeDecl
+ */
+ DatatypeDecl(const Solver* s,
+ const std::string& name,
+ bool isCoDatatype = false);
+
+ /**
+ * Constructor for parameterized datatype declaration.
+ * Create sorts parameter with Solver::mkParamSort().
+ * @param s the solver that created this datatype declaration
+ * @param name the name of the datatype
+ * @param param the sort parameter
+ * @param isCoDatatype true if a codatatype is to be constructed
+ */
+ DatatypeDecl(const Solver* s,
+ const std::string& name,
+ Sort param,
+ bool isCoDatatype = false);
+
+ /**
+ * Constructor for parameterized datatype declaration.
+ * Create sorts parameter with Solver::mkParamSort().
+ * @param s the solver that created this datatype declaration
+ * @param name the name of the datatype
+ * @param params a list of sort parameters
+ * @param isCoDatatype true if a codatatype is to be constructed
+ */
+ DatatypeDecl(const Solver* s,
+ const std::string& name,
+ const std::vector<Sort>& params,
+ bool isCoDatatype = false);
/* The internal (intermediate) datatype wrapped by this datatype
* declaration
* This is a shared_ptr rather than a unique_ptr since CVC4::Datatype is
@@ -2293,6 +2301,43 @@ class CVC4_PUBLIC Solver
Term mkVar(Sort sort, const std::string& symbol = std::string()) const;
/* .................................................................... */
+ /* Create datatype declarations */
+ /* .................................................................... */
+
+ /**
+ * Create a datatype declaration.
+ * @param name the name of the datatype
+ * @param isCoDatatype true if a codatatype is to be constructed
+ * @return the DatatypeDecl
+ */
+ DatatypeDecl mkDatatypeDecl(const std::string& name,
+ bool isCoDatatype = false);
+
+ /**
+ * Create a datatype declaration.
+ * Create sorts parameter with Solver::mkParamSort().
+ * @param name the name of the datatype
+ * @param param the sort parameter
+ * @param isCoDatatype true if a codatatype is to be constructed
+ * @return the DatatypeDecl
+ */
+ DatatypeDecl mkDatatypeDecl(const std::string& name,
+ Sort param,
+ bool isCoDatatype = false);
+
+ /**
+ * Create a datatype declaration.
+ * Create sorts parameter with Solver::mkParamSort().
+ * @param name the name of the datatype
+ * @param params a list of sort parameters
+ * @param isCoDatatype true if a codatatype is to be constructed
+ * @return the DatatypeDecl
+ */
+ DatatypeDecl mkDatatypeDecl(const std::string& name,
+ const std::vector<Sort>& params,
+ bool isCoDatatype = false);
+
+ /* .................................................................... */
/* Formula Handling */
/* .................................................................... */
diff --git a/src/expr/datatype.cpp b/src/expr/datatype.cpp
index f3f4c10d3..07af9617d 100644
--- a/src/expr/datatype.cpp
+++ b/src/expr/datatype.cpp
@@ -55,8 +55,8 @@ typedef expr::Attribute<expr::attr::DatatypeFiniteComputedTag, bool> DatatypeFin
typedef expr::Attribute<expr::attr::DatatypeUFiniteTag, bool> DatatypeUFiniteAttr;
typedef expr::Attribute<expr::attr::DatatypeUFiniteComputedTag, bool> DatatypeUFiniteComputedAttr;
-Datatype::Datatype(std::string name, bool isCo)
- : d_internal(nullptr), // until the Node-level datatype API is activated
+Datatype::Datatype(ExprManager* em, std::string name, bool isCo)
+ : d_em(em),
d_name(name),
d_params(),
d_isCo(isCo),
@@ -75,10 +75,11 @@ Datatype::Datatype(std::string name, bool isCo)
{
}
-Datatype::Datatype(std::string name,
+Datatype::Datatype(ExprManager* em,
+ std::string name,
const std::vector<Type>& params,
bool isCo)
- : d_internal(nullptr), // until the Node-level datatype API is activated
+ : d_em(em),
d_name(name),
d_params(params),
d_isCo(isCo),
diff --git a/src/expr/datatype.h b/src/expr/datatype.h
index c78fbc436..c9191aadf 100644
--- a/src/expr/datatype.h
+++ b/src/expr/datatype.h
@@ -656,13 +656,14 @@ class CVC4_PUBLIC Datatype {
typedef DatatypeConstructorIterator const_iterator;
/** Create a new Datatype of the given name. */
- explicit Datatype(std::string name, bool isCo = false);
+ explicit Datatype(ExprManager* em, std::string name, bool isCo = false);
/**
* Create a new Datatype of the given name, with the given
* parameterization.
*/
- Datatype(std::string name,
+ Datatype(ExprManager* em,
+ std::string name,
const std::vector<Type>& params,
bool isCo = false);
@@ -976,6 +977,8 @@ class CVC4_PUBLIC Datatype {
void toStream(std::ostream& out) const;
private:
+ /** The expression manager that created this datatype */
+ ExprManager* d_em;
/** The internal representation */
std::shared_ptr<DType> d_internal;
/** name of this datatype */
diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp
index 201e428de..1142da429 100644
--- a/src/expr/node_manager.cpp
+++ b/src/expr/node_manager.cpp
@@ -545,7 +545,7 @@ TypeNode NodeManager::TupleTypeCache::getTupleType( NodeManager * nm, std::vecto
for (unsigned i = 0; i < types.size(); ++ i) {
sst << "_" << types[i];
}
- Datatype dt(sst.str());
+ Datatype dt(nm->toExprManager(), sst.str());
dt.setTuple();
std::stringstream ssc;
ssc << sst.str() << "_ctor";
@@ -574,7 +574,7 @@ TypeNode NodeManager::RecTypeCache::getRecordType( NodeManager * nm, const Recor
for(Record::FieldVector::const_iterator i = fields.begin(); i != fields.end(); ++i) {
sst << "_" << (*i).first << "_" << (*i).second;
}
- Datatype dt(sst.str());
+ Datatype dt(nm->toExprManager(), sst.str());
dt.setRecord();
std::stringstream ssc;
ssc << sst.str() << "_ctor";
diff --git a/src/expr/sygus_datatype.cpp b/src/expr/sygus_datatype.cpp
index 73f7c5769..bea8a41b8 100644
--- a/src/expr/sygus_datatype.cpp
+++ b/src/expr/sygus_datatype.cpp
@@ -20,7 +20,10 @@ using namespace CVC4::kind;
namespace CVC4 {
-SygusDatatype::SygusDatatype(const std::string& name) : d_dt(Datatype(name)) {}
+SygusDatatype::SygusDatatype(const std::string& name)
+ : d_dt(Datatype(NodeManager::currentNM()->toExprManager(), name))
+{
+}
std::string SygusDatatype::getName() const { return d_dt.getName(); }
diff --git a/src/parser/cvc/Cvc.g b/src/parser/cvc/Cvc.g
index 94bb87fdb..e4849aae6 100644
--- a/src/parser/cvc/Cvc.g
+++ b/src/parser/cvc/Cvc.g
@@ -2294,7 +2294,7 @@ datatypeDef[std::vector<CVC4::Datatype>& datatypes]
params.push_back( t ); }
)* RBRACKET
)?
- { datatypes.push_back(Datatype(id, params, false));
+ { datatypes.push_back(Datatype(EXPR_MANAGER, id, params, false));
if(!PARSER_STATE->isUnresolvedType(id)) {
// if not unresolved, must be undeclared
PARSER_STATE->checkDeclaration(id, CHECK_UNDECLARED, SYM_SORT);
diff --git a/src/parser/smt2/Smt2.g b/src/parser/smt2/Smt2.g
index c1a9df887..96ac7d48e 100644
--- a/src/parser/smt2/Smt2.g
+++ b/src/parser/smt2/Smt2.g
@@ -959,7 +959,7 @@ sygusGrammar[CVC4::Type & ret,
std::stringstream ss;
ss << "dt_" << fun << "_" << i.first;
std::string dname = ss.str();
- datatypes.push_back(Datatype(dname));
+ datatypes.push_back(Datatype(EXPR_MANAGER, dname));
// make its unresolved type, used for referencing the final version of
// the datatype
PARSER_STATE->checkDeclaration(dname, CHECK_UNDECLARED, SYM_SORT);
@@ -1523,7 +1523,7 @@ datatypesDef[bool isCo,
PARSER_STATE->parseError("Wrong number of parameters for datatype.");
}
Debug("parser-dt") << params.size() << " parameters for " << dnames[dts.size()] << std::endl;
- dts.push_back(Datatype(dnames[dts.size()],params,isCo));
+ dts.push_back(Datatype(EXPR_MANAGER, dnames[dts.size()],params,isCo));
}
LPAREN_TOK
( LPAREN_TOK constructorDef[dts.back()] RPAREN_TOK )+
@@ -1533,7 +1533,7 @@ datatypesDef[bool isCo,
PARSER_STATE->parseError("No parameters given for datatype.");
}
Debug("parser-dt") << params.size() << " parameters for " << dnames[dts.size()] << std::endl;
- dts.push_back(Datatype(dnames[dts.size()],params,isCo));
+ dts.push_back(Datatype(EXPR_MANAGER, dnames[dts.size()],params,isCo));
}
( LPAREN_TOK constructorDef[dts.back()] RPAREN_TOK )+
)
@@ -2596,7 +2596,7 @@ datatypeDef[bool isCo, std::vector<CVC4::Datatype>& datatypes,
params.push_back( t ); }
)* ']'
)?*/ //AJR: this isn't necessary if we use z3's style
- { datatypes.push_back(Datatype(id,params,isCo));
+ { datatypes.push_back(Datatype(EXPR_MANAGER, id, params, isCo));
if(!PARSER_STATE->isUnresolvedType(id)) {
// if not unresolved, must be undeclared
PARSER_STATE->checkDeclaration(id, CHECK_UNDECLARED, SYM_SORT);
diff --git a/src/parser/smt2/smt2.cpp b/src/parser/smt2/smt2.cpp
index c7e70495e..73dea766a 100644
--- a/src/parser/smt2/smt2.cpp
+++ b/src/parser/smt2/smt2.cpp
@@ -1099,7 +1099,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(Datatype(dname));
+ datatypes.push_back(Datatype(getExprManager(), dname));
ops.push_back(std::vector<Expr>());
cnames.push_back(std::vector<std::string>());
cargs.push_back(std::vector<std::vector<CVC4::Type> >());
diff --git a/src/parser/smt2/smt2.h b/src/parser/smt2/smt2.h
index 215f565cd..efdb0c70f 100644
--- a/src/parser/smt2/smt2.h
+++ b/src/parser/smt2/smt2.h
@@ -383,22 +383,25 @@ class Smt2 : public Parser
CVC4::Type& ret,
bool isNested = false);
- static bool pushSygusDatatypeDef( Type t, std::string& 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,
- std::vector< std::vector< std::vector< CVC4::Type > > >& cargs,
- std::vector< bool >& allow_const,
- std::vector< std::vector< std::string > >& unresolved_gterm_sym );
-
- 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,
- std::vector< std::vector< std::vector< CVC4::Type > > >& cargs,
- std::vector< bool >& allow_const,
- std::vector< std::vector< std::string > >& unresolved_gterm_sym );
+ bool pushSygusDatatypeDef(
+ Type t,
+ std::string& 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,
+ std::vector<std::vector<std::vector<CVC4::Type>>>& cargs,
+ std::vector<bool>& allow_const,
+ std::vector<std::vector<std::string>>& unresolved_gterm_sym);
+
+ 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,
+ std::vector<std::vector<std::vector<CVC4::Type>>>& cargs,
+ std::vector<bool>& allow_const,
+ std::vector<std::vector<std::string>>& unresolved_gterm_sym);
void setSygusStartIndex(const std::string& fun,
int startIndex,
diff --git a/test/unit/api/datatype_api_black.h b/test/unit/api/datatype_api_black.h
index 6a5f3eb7b..b9c671a30 100644
--- a/test/unit/api/datatype_api_black.h
+++ b/test/unit/api/datatype_api_black.h
@@ -38,7 +38,7 @@ void DatatypeBlack::tearDown() {}
void DatatypeBlack::testMkDatatypeSort()
{
- DatatypeDecl dtypeSpec("list");
+ DatatypeDecl dtypeSpec = d_solver.mkDatatypeDecl("list");
DatatypeConstructorDecl cons("cons");
DatatypeSelectorDecl head("head", d_solver.getIntegerSort());
cons.addSelector(head);
diff --git a/test/unit/api/solver_black.h b/test/unit/api/solver_black.h
index 92313ac3c..2831b840d 100644
--- a/test/unit/api/solver_black.h
+++ b/test/unit/api/solver_black.h
@@ -179,7 +179,7 @@ void SolverBlack::testMkFloatingPointSort()
void SolverBlack::testMkDatatypeSort()
{
- DatatypeDecl dtypeSpec("list");
+ DatatypeDecl dtypeSpec = d_solver->mkDatatypeDecl("list");
DatatypeConstructorDecl cons("cons");
DatatypeSelectorDecl head("head", d_solver->getIntegerSort());
cons.addSelector(head);
@@ -187,7 +187,7 @@ void SolverBlack::testMkDatatypeSort()
DatatypeConstructorDecl nil("nil");
dtypeSpec.addConstructor(nil);
TS_ASSERT_THROWS_NOTHING(d_solver->mkDatatypeSort(dtypeSpec));
- DatatypeDecl throwsDtypeSpec("list");
+ DatatypeDecl throwsDtypeSpec = d_solver->mkDatatypeDecl("list");
TS_ASSERT_THROWS(d_solver->mkDatatypeSort(throwsDtypeSpec),
CVC4ApiException&);
}
@@ -627,7 +627,7 @@ void SolverBlack::testMkTermFromOp()
// list datatype
Sort sort = d_solver->mkParamSort("T");
- DatatypeDecl listDecl("paramlist", sort);
+ DatatypeDecl listDecl = d_solver->mkDatatypeDecl("paramlist", sort);
DatatypeConstructorDecl cons("cons");
DatatypeConstructorDecl nil("nil");
DatatypeSelectorDecl head("head", sort);
@@ -930,7 +930,7 @@ void SolverBlack::testGetOp()
TS_ASSERT_EQUALS(exta.getOp(), ext);
// Test Datatypes -- more complicated
- DatatypeDecl consListSpec("list");
+ DatatypeDecl consListSpec = d_solver->mkDatatypeDecl("list");
DatatypeConstructorDecl cons("cons");
DatatypeSelectorDecl head("head", d_solver->getIntegerSort());
DatatypeSelectorDecl tail("tail", DatatypeDeclSelfSort());
@@ -1036,7 +1036,7 @@ void SolverBlack::testSimplify()
Sort uSort = d_solver->mkUninterpretedSort("u");
Sort funSort1 = d_solver->mkFunctionSort({bvSort, bvSort}, bvSort);
Sort funSort2 = d_solver->mkFunctionSort(uSort, d_solver->getIntegerSort());
- DatatypeDecl consListSpec("list");
+ DatatypeDecl consListSpec = d_solver->mkDatatypeDecl("list");
DatatypeConstructorDecl cons("cons");
DatatypeSelectorDecl head("head", d_solver->getIntegerSort());
DatatypeSelectorDecl tail("tail", DatatypeDeclSelfSort());
diff --git a/test/unit/api/sort_black.h b/test/unit/api/sort_black.h
index 73eb3df88..4ea29b8d7 100644
--- a/test/unit/api/sort_black.h
+++ b/test/unit/api/sort_black.h
@@ -58,7 +58,7 @@ void SortBlack::tearDown() {}
void SortBlack::testGetDatatype()
{
// create datatype sort, check should not fail
- DatatypeDecl dtypeSpec("list");
+ DatatypeDecl dtypeSpec = d_solver.mkDatatypeDecl("list");
DatatypeConstructorDecl cons("cons");
DatatypeSelectorDecl head("head", d_solver.getIntegerSort());
cons.addSelector(head);
@@ -76,7 +76,7 @@ void SortBlack::testInstantiate()
{
// instantiate parametric datatype, check should not fail
Sort sort = d_solver.mkParamSort("T");
- DatatypeDecl paramDtypeSpec("paramlist", sort);
+ DatatypeDecl paramDtypeSpec = d_solver.mkDatatypeDecl("paramlist", sort);
DatatypeConstructorDecl paramCons("cons");
DatatypeConstructorDecl paramNil("nil");
DatatypeSelectorDecl paramHead("head", sort);
@@ -87,7 +87,7 @@ void SortBlack::testInstantiate()
TS_ASSERT_THROWS_NOTHING(
paramDtypeSort.instantiate(std::vector<Sort>{d_solver.getIntegerSort()}));
// instantiate non-parametric datatype sort, check should fail
- DatatypeDecl dtypeSpec("list");
+ DatatypeDecl dtypeSpec = d_solver.mkDatatypeDecl("list");
DatatypeConstructorDecl cons("cons");
DatatypeSelectorDecl head("head", d_solver.getIntegerSort());
cons.addSelector(head);
@@ -222,7 +222,7 @@ void SortBlack::testGetDatatypeParamSorts()
{
// create parametric datatype, check should not fail
Sort sort = d_solver.mkParamSort("T");
- DatatypeDecl paramDtypeSpec("paramlist", sort);
+ DatatypeDecl paramDtypeSpec = d_solver.mkDatatypeDecl("paramlist", sort);
DatatypeConstructorDecl paramCons("cons");
DatatypeConstructorDecl paramNil("nil");
DatatypeSelectorDecl paramHead("head", sort);
@@ -232,7 +232,7 @@ void SortBlack::testGetDatatypeParamSorts()
Sort paramDtypeSort = d_solver.mkDatatypeSort(paramDtypeSpec);
TS_ASSERT_THROWS_NOTHING(paramDtypeSort.getDatatypeParamSorts());
// create non-parametric datatype sort, check should fail
- DatatypeDecl dtypeSpec("list");
+ DatatypeDecl dtypeSpec = d_solver.mkDatatypeDecl("list");
DatatypeConstructorDecl cons("cons");
DatatypeSelectorDecl head("head", d_solver.getIntegerSort());
cons.addSelector(head);
@@ -246,7 +246,7 @@ void SortBlack::testGetDatatypeParamSorts()
void SortBlack::testGetDatatypeArity()
{
// create datatype sort, check should not fail
- DatatypeDecl dtypeSpec("list");
+ DatatypeDecl dtypeSpec = d_solver.mkDatatypeDecl("list");
DatatypeConstructorDecl cons("cons");
DatatypeSelectorDecl head("head", d_solver.getIntegerSort());
cons.addSelector(head);
diff --git a/test/unit/expr/expr_public.h b/test/unit/expr/expr_public.h
index 82cf10a9b..da9434d79 100644
--- a/test/unit/expr/expr_public.h
+++ b/test/unit/expr/expr_public.h
@@ -370,7 +370,7 @@ private:
TS_ASSERT(!null->isConst());
// more complicated "constants" exist in datatypes and arrays theories
- Datatype list("list");
+ Datatype list(d_em, "list");
DatatypeConstructor consC("cons");
consC.addArg("car", d_em->integerType());
consC.addArg("cdr", DatatypeSelfType());
diff --git a/test/unit/theory/type_enumerator_white.h b/test/unit/theory/type_enumerator_white.h
index 2c3f09ce0..da915b7ee 100644
--- a/test/unit/theory/type_enumerator_white.h
+++ b/test/unit/theory/type_enumerator_white.h
@@ -146,7 +146,7 @@ class TypeEnumeratorWhite : public CxxTest::TestSuite {
}
void testDatatypesFinite() {
- Datatype dt("Colors");
+ Datatype dt(d_em, "Colors");
dt.addConstructor(DatatypeConstructor("red"));
dt.addConstructor(DatatypeConstructor("orange"));
dt.addConstructor(DatatypeConstructor("yellow"));
@@ -167,7 +167,7 @@ class TypeEnumeratorWhite : public CxxTest::TestSuite {
}
void testDatatypesInfinite1() {
- Datatype colors("Colors");
+ Datatype colors(d_em, "Colors");
colors.addConstructor(DatatypeConstructor("red"));
colors.addConstructor(DatatypeConstructor("orange"));
colors.addConstructor(DatatypeConstructor("yellow"));
@@ -175,7 +175,7 @@ class TypeEnumeratorWhite : public CxxTest::TestSuite {
colors.addConstructor(DatatypeConstructor("blue"));
colors.addConstructor(DatatypeConstructor("violet"));
TypeNode colorsType = TypeNode::fromType(d_em->mkDatatypeType(colors));
- Datatype listColors("ListColors");
+ Datatype listColors(d_em, "ListColors");
DatatypeConstructor consC("cons");
consC.addArg("car", colorsType.toType());
consC.addArg("cdr", DatatypeSelfType());
diff --git a/test/unit/util/datatype_black.h b/test/unit/util/datatype_black.h
index 6df18fd44..e81caf36f 100644
--- a/test/unit/util/datatype_black.h
+++ b/test/unit/util/datatype_black.h
@@ -47,7 +47,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
}
void testEnumeration() {
- Datatype colors("colors");
+ Datatype colors(d_em, "colors");
DatatypeConstructor yellow("yellow", "is_yellow");
DatatypeConstructor blue("blue", "is_blue");
@@ -85,7 +85,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
}
void testNat() {
- Datatype nat("nat");
+ Datatype nat(d_em, "nat");
DatatypeConstructor succ("succ", "is_succ");
succ.addArg("pred", DatatypeSelfType());
@@ -112,7 +112,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
}
void testTree() {
- Datatype tree("tree");
+ Datatype tree(d_em, "tree");
Type integerType = d_em->integerType();
DatatypeConstructor node("node", "is_node");
@@ -144,7 +144,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
}
void testListInt() {
- Datatype list("list");
+ Datatype list(d_em, "list");
Type integerType = d_em->integerType();
DatatypeConstructor cons("cons", "is_cons");
@@ -169,7 +169,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
}
void testListReal() {
- Datatype list("list");
+ Datatype list(d_em, "list");
Type realType = d_em->realType();
DatatypeConstructor cons("cons", "is_cons");
@@ -194,7 +194,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
}
void testListBoolean() {
- Datatype list("list");
+ Datatype list(d_em, "list");
Type booleanType = d_em->booleanType();
DatatypeConstructor cons("cons", "is_cons");
@@ -226,7 +226,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
* list = cons(car: tree, cdr: list) | nil
* END;
*/
- Datatype tree("tree");
+ Datatype tree(d_em, "tree");
DatatypeConstructor node("node", "is_node");
node.addArg("left", DatatypeSelfType());
node.addArg("right", DatatypeSelfType());
@@ -238,7 +238,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
Debug("datatypes") << tree << std::endl;
- Datatype list("list");
+ Datatype list(d_em, "list");
DatatypeConstructor cons("cons", "is_cons");
cons.addArg("car", DatatypeUnresolvedType("tree"));
cons.addArg("cdr", DatatypeSelfType());
@@ -280,7 +280,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
}
void testMutualListTrees2()
{
- Datatype tree("tree");
+ Datatype tree(d_em, "tree");
DatatypeConstructor node("node", "is_node");
node.addArg("left", DatatypeSelfType());
node.addArg("right", DatatypeSelfType());
@@ -290,7 +290,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
leaf.addArg("leaf", DatatypeUnresolvedType("list"));
tree.addConstructor(leaf);
- Datatype list("list");
+ Datatype list(d_em, "list");
DatatypeConstructor cons("cons", "is_cons");
cons.addArg("car", DatatypeUnresolvedType("tree"));
cons.addArg("cdr", DatatypeSelfType());
@@ -327,7 +327,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
}
void testNotSoWellFounded() {
- Datatype tree("tree");
+ Datatype tree(d_em, "tree");
DatatypeConstructor node("node", "is_node");
node.addArg("left", DatatypeSelfType());
@@ -351,7 +351,7 @@ class DatatypeBlack : public CxxTest::TestSuite {
Type t1, t2;
v.push_back(t1 = d_em->mkSort("T1"));
v.push_back(t2 = d_em->mkSort("T2"));
- Datatype pair("pair", v);
+ Datatype pair(d_em, "pair", v);
DatatypeConstructor mkpair("mk-pair");
mkpair.addArg("first", t1);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback