summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@cs.nyu.edu>2014-03-01 13:27:20 -0500
committerMorgan Deters <mdeters@cs.nyu.edu>2014-03-04 07:56:20 -0500
commit08294c3914e4e87f3c5c1eda60e6ea259b789f55 (patch)
treeb2779f49f6cedeb2fae53c421a5394ac3a178714
parent213075fa8e845b2236340ea76c1595a93a2ac44d (diff)
More useful error message when someone tries mkExpr(VARIABLE).
-rw-r--r--src/expr/expr_manager_template.cpp71
1 files changed, 56 insertions, 15 deletions
diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp
index c733e37ea..147ad3723 100644
--- a/src/expr/expr_manager_template.cpp
+++ b/src/expr/expr_manager_template.cpp
@@ -153,7 +153,13 @@ IntegerType ExprManager::integerType() const {
}
Expr ExprManager::mkExpr(Kind kind, Expr child1) {
- const unsigned n = 1 - (kind::metaKindOf(kind) == kind::metakind::PARAMETERIZED ? 1 : 0);
+ const kind::MetaKind mk = kind::metaKindOf(kind);
+ const unsigned n = 1 - (mk == kind::metakind::PARAMETERIZED ? 1 : 0);
+ CheckArgument(mk == kind::metakind::PARAMETERIZED ||
+ mk == kind::metakind::OPERATOR, kind,
+ "Only operator-style expressions are made with mkExpr(); "
+ "to make variables and constants, see mkVar(), mkBoundVar(), "
+ "and mkConst().");
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)",
@@ -169,7 +175,13 @@ Expr ExprManager::mkExpr(Kind kind, Expr child1) {
}
Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2) {
- const unsigned n = 2 - (kind::metaKindOf(kind) == kind::metakind::PARAMETERIZED ? 1 : 0);
+ const kind::MetaKind mk = kind::metaKindOf(kind);
+ const unsigned n = 2 - (mk == kind::metakind::PARAMETERIZED ? 1 : 0);
+ CheckArgument(mk == kind::metakind::PARAMETERIZED ||
+ mk == kind::metakind::OPERATOR, kind,
+ "Only operator-style expressions are made with mkExpr(); "
+ "to make variables and constants, see mkVar(), mkBoundVar(), "
+ "and mkConst().");
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)",
@@ -186,9 +198,14 @@ Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2) {
}
}
-Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2,
- Expr child3) {
- const unsigned n = 3 - (kind::metaKindOf(kind) == kind::metakind::PARAMETERIZED ? 1 : 0);
+Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2, Expr child3) {
+ const kind::MetaKind mk = kind::metaKindOf(kind);
+ const unsigned n = 3 - (mk == kind::metakind::PARAMETERIZED ? 1 : 0);
+ CheckArgument(mk == kind::metakind::PARAMETERIZED ||
+ mk == kind::metakind::OPERATOR, kind,
+ "Only operator-style expressions are made with mkExpr(); "
+ "to make variables and constants, see mkVar(), mkBoundVar(), "
+ "and mkConst().");
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)",
@@ -206,9 +223,15 @@ Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2,
}
}
-Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2,
- Expr child3, Expr child4) {
- const unsigned n = 4 - (kind::metaKindOf(kind) == kind::metakind::PARAMETERIZED ? 1 : 0);
+Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2, Expr child3,
+ Expr child4) {
+ const kind::MetaKind mk = kind::metaKindOf(kind);
+ const unsigned n = 4 - (mk == kind::metakind::PARAMETERIZED ? 1 : 0);
+ CheckArgument(mk == kind::metakind::PARAMETERIZED ||
+ mk == kind::metakind::OPERATOR, kind,
+ "Only operator-style expressions are made with mkExpr(); "
+ "to make variables and constants, see mkVar(), mkBoundVar(), "
+ "and mkConst().");
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)",
@@ -227,10 +250,15 @@ Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2,
}
}
-Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2,
- Expr child3, Expr child4,
- Expr child5) {
- const unsigned n = 5 - (kind::metaKindOf(kind) == kind::metakind::PARAMETERIZED ? 1 : 0);
+Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2, Expr child3,
+ Expr child4, Expr child5) {
+ const kind::MetaKind mk = kind::metaKindOf(kind);
+ const unsigned n = 5 - (mk == kind::metakind::PARAMETERIZED ? 1 : 0);
+ CheckArgument(mk == kind::metakind::PARAMETERIZED ||
+ mk == kind::metakind::OPERATOR, kind,
+ "Only operator-style expressions are made with mkExpr(); "
+ "to make variables and constants, see mkVar(), mkBoundVar(), "
+ "and mkConst().");
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)",
@@ -251,7 +279,13 @@ Expr ExprManager::mkExpr(Kind kind, Expr child1, Expr child2,
}
Expr ExprManager::mkExpr(Kind kind, const std::vector<Expr>& children) {
- const unsigned n = children.size() - (kind::metaKindOf(kind) == kind::metakind::PARAMETERIZED ? 1 : 0);
+ const kind::MetaKind mk = kind::metaKindOf(kind);
+ const unsigned n = children.size() - (mk == kind::metakind::PARAMETERIZED ? 1 : 0);
+ CheckArgument(mk == kind::metakind::PARAMETERIZED ||
+ mk == kind::metakind::OPERATOR, kind,
+ "Only operator-style expressions are made with mkExpr(); "
+ "to make variables and constants, see mkVar(), mkBoundVar(), "
+ "and mkConst().");
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)",
@@ -275,8 +309,15 @@ Expr ExprManager::mkExpr(Kind kind, const std::vector<Expr>& children) {
}
}
-Expr ExprManager::mkExpr(Kind kind, Expr child1, const std::vector<Expr>& otherChildren) {
- const unsigned n = otherChildren.size() - (kind::metaKindOf(kind) == kind::metakind::PARAMETERIZED ? 1 : 0) + 1;
+Expr ExprManager::mkExpr(Kind kind, Expr child1,
+ const std::vector<Expr>& otherChildren) {
+ const kind::MetaKind mk = kind::metaKindOf(kind);
+ const unsigned n = otherChildren.size() - (mk == kind::metakind::PARAMETERIZED ? 1 : 0) + 1;
+ CheckArgument(mk == kind::metakind::PARAMETERIZED ||
+ mk == kind::metakind::OPERATOR, kind,
+ "Only operator-style expressions are made with mkExpr(); "
+ "to make variables and constants, see mkVar(), mkBoundVar(), "
+ "and mkConst().");
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)",
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback