summaryrefslogtreecommitdiff
path: root/src/expr/expr_manager_template.cpp
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2010-04-04 19:36:56 +0000
committerMorgan Deters <mdeters@gmail.com>2010-04-04 19:36:56 +0000
commit73be7b6b5a9c98cc5a32dcfb3050b9656bf10243 (patch)
tree5421477844240ad71493ee01a85a4a8a5369d92d /src/expr/expr_manager_template.cpp
parent3e27983545a25f3acc3bf7c7dbdf0ec1fe3219ca (diff)
Recommit revision 365 (undoing revision 375, which reverted revision 365).
Fix the case in NodeBuilderBlack that triggered bug #82. (Fixes bug #82.) This also fixes regression failures from this morning (2010 Apr 4), in the optimized builds, for which a fix was included in 365 and reverted in 375. They looked like this: In ExprBlack::testGetConst: /usr/local/share/cvc4/src/cvc4-2010-04-04/builds/x86_64-unknown-linux-gnu/production/../../../test/unit/expr/expr_black.h:377: Error: Expected (a->getConst<Kind>()) to throw (IllegalArgumentException) but it didn't throw /usr/local/share/cvc4/src/cvc4-2010-04-04/builds/x86_64-unknown-linux-gnu/production/../../../test/unit/expr/expr_black.h:378: Error: Expected (b->getConst<Kind>()) to throw (IllegalArgumentException) but it didn't throw [etc..]
Diffstat (limited to 'src/expr/expr_manager_template.cpp')
-rw-r--r--src/expr/expr_manager_template.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp
index fa1a1a6af..6a2640080 100644
--- a/src/expr/expr_manager_template.cpp
+++ b/src/expr/expr_manager_template.cpp
@@ -57,16 +57,34 @@ KindType* ExprManager::kindType() const {
}
Expr ExprManager::mkExpr(Kind kind) {
+ const unsigned n = 0;
+ CheckArgument(n >= minArity(kind) && n <= maxArity(kind), kind,
+ "Exprs with kind %s must have at least %u children and "
+ "at most %u children (the one under construction has %u)",
+ kind::kindToString(kind).c_str(),
+ minArity(kind), maxArity(kind), n);
NodeManagerScope nms(d_nodeManager);
return Expr(this, new Node(d_nodeManager->mkNode(kind)));
}
Expr ExprManager::mkExpr(Kind kind, const Expr& child1) {
+ const unsigned n = 1;
+ CheckArgument(n >= minArity(kind) && n <= maxArity(kind), kind,
+ "Exprs with kind %s must have at least %u children and "
+ "at most %u children (the one under construction has %u)",
+ kind::kindToString(kind).c_str(),
+ minArity(kind), maxArity(kind), n);
NodeManagerScope nms(d_nodeManager);
return Expr(this, new Node(d_nodeManager->mkNode(kind, child1.getNode())));
}
Expr ExprManager::mkExpr(Kind kind, const Expr& child1, const Expr& child2) {
+ const unsigned n = 2;
+ CheckArgument(n >= minArity(kind) && n <= maxArity(kind), kind,
+ "Exprs with kind %s must have at least %u children and "
+ "at most %u children (the one under construction has %u)",
+ kind::kindToString(kind).c_str(),
+ minArity(kind), maxArity(kind), n);
NodeManagerScope nms(d_nodeManager);
return Expr(this, new Node(d_nodeManager->mkNode(kind, child1.getNode(),
child2.getNode())));
@@ -74,6 +92,12 @@ Expr ExprManager::mkExpr(Kind kind, const Expr& child1, const Expr& child2) {
Expr ExprManager::mkExpr(Kind kind, const Expr& child1, const Expr& child2,
const Expr& child3) {
+ const unsigned n = 3;
+ CheckArgument(n >= minArity(kind) && n <= maxArity(kind), kind,
+ "Exprs with kind %s must have at least %u children and "
+ "at most %u children (the one under construction has %u)",
+ kind::kindToString(kind).c_str(),
+ minArity(kind), maxArity(kind), n);
NodeManagerScope nms(d_nodeManager);
return Expr(this, new Node(d_nodeManager->mkNode(kind, child1.getNode(),
child2.getNode(), child3.getNode())));
@@ -81,6 +105,12 @@ Expr ExprManager::mkExpr(Kind kind, const Expr& child1, const Expr& child2,
Expr ExprManager::mkExpr(Kind kind, const Expr& child1, const Expr& child2,
const Expr& child3, const Expr& child4) {
+ const unsigned n = 4;
+ CheckArgument(n >= minArity(kind) && n <= maxArity(kind), kind,
+ "Exprs with kind %s must have at least %u children and "
+ "at most %u children (the one under construction has %u)",
+ kind::kindToString(kind).c_str(),
+ minArity(kind), maxArity(kind), n);
NodeManagerScope nms(d_nodeManager);
return Expr(this, new Node(d_nodeManager->mkNode(kind, child1.getNode(),
child2.getNode(), child3.getNode(),
@@ -90,6 +120,12 @@ Expr ExprManager::mkExpr(Kind kind, const Expr& child1, const Expr& child2,
Expr ExprManager::mkExpr(Kind kind, const Expr& child1, const Expr& child2,
const Expr& child3, const Expr& child4,
const Expr& child5) {
+ const unsigned n = 5;
+ CheckArgument(n >= minArity(kind) && n <= maxArity(kind), kind,
+ "Exprs with kind %s must have at least %u children and "
+ "at most %u children (the one under construction has %u)",
+ kind::kindToString(kind).c_str(),
+ minArity(kind), maxArity(kind), n);
NodeManagerScope nms(d_nodeManager);
return Expr(this, new Node(d_nodeManager->mkNode(kind, child1.getNode(),
child2.getNode(), child3.getNode(),
@@ -97,6 +133,13 @@ Expr ExprManager::mkExpr(Kind kind, const Expr& child1, const Expr& child2,
}
Expr ExprManager::mkExpr(Kind kind, const vector<Expr>& children) {
+ const unsigned n = children.size();
+ CheckArgument(n >= minArity(kind) && n <= maxArity(kind), kind,
+ "Exprs with kind %s must have at least %u children and "
+ "at most %u children (the one under construction has %u)",
+ kind::kindToString(kind).c_str(),
+ minArity(kind), maxArity(kind), n);
+
NodeManagerScope nms(d_nodeManager);
vector<Node> nodes;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback