summaryrefslogtreecommitdiff
path: root/src/expr/expr_manager_template.cpp
diff options
context:
space:
mode:
authorDejan Jovanović <dejan.jovanovic@gmail.com>2010-04-29 23:42:41 +0000
committerDejan Jovanović <dejan.jovanovic@gmail.com>2010-04-29 23:42:41 +0000
commit349131957e91150c24a9c69f5e1f04e34494b0c6 (patch)
tree8012c2475dde1f1177f693643fb1a07e89c29538 /src/expr/expr_manager_template.cpp
parentac8b46fe3b5256e387da724b7c3abfb59d25531e (diff)
Added the capability to construct expressions by passing the operator instead of the kind, i.e.
Expr op = ..."f"... em.mkExpr(op, children); Operator kinds are automatically associated with the enclosing expression kind in the DSL and generated.
Diffstat (limited to 'src/expr/expr_manager_template.cpp')
-rw-r--r--src/expr/expr_manager_template.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp
index 3480cc0e6..b957019fb 100644
--- a/src/expr/expr_manager_template.cpp
+++ b/src/expr/expr_manager_template.cpp
@@ -66,6 +66,11 @@ IntegerType ExprManager::integerType() const {
return Type(d_nodeManager, new TypeNode(d_nodeManager->integerType()));
}
+BitVectorType ExprManager::bitVectorType(unsigned size) const {
+ NodeManagerScope nms(d_nodeManager);
+ return Type(d_nodeManager, new TypeNode(d_nodeManager->bitVectorType(size)));
+}
+
Expr ExprManager::mkExpr(Kind kind) {
const unsigned n = 0;
CheckArgument(n >= minArity(kind) && n <= maxArity(kind), kind,
@@ -161,6 +166,27 @@ Expr ExprManager::mkExpr(Kind kind, const std::vector<Expr>& children) {
return Expr(this, d_nodeManager->mkNodePtr(kind, nodes));
}
+Expr ExprManager::mkExpr(Expr opExpr, const std::vector<Expr>& children) {
+ const unsigned n = children.size();
+ Kind kind = kind::operatorKindToKind(opExpr.getKind());
+ 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;
+ vector<Expr>::const_iterator it = children.begin();
+ vector<Expr>::const_iterator it_end = children.end();
+ while(it != it_end) {
+ nodes.push_back(it->getNode());
+ ++it;
+ }
+ return Expr(this, d_nodeManager->mkNodePtr(opExpr.getNode(), nodes));
+}
+
/** Make a function type from domain to range. */
FunctionType ExprManager::mkFunctionType(const Type& domain, const Type& range) {
NodeManagerScope nms(d_nodeManager);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback