summaryrefslogtreecommitdiff
path: root/src/expr/array_store_all.cpp
diff options
context:
space:
mode:
authorTim King <taking@google.com>2015-12-24 05:38:43 -0500
committerTim King <taking@google.com>2015-12-24 05:38:43 -0500
commita39ad6584c1d61e22e72b53c3838f4f675ed2e19 (patch)
treeed40cb371c41ac285ca2bf41a82254a36134e132 /src/expr/array_store_all.cpp
parent87b0fe9ce10d1e5e9ed5a3e7db77f46bf3f68922 (diff)
Miscellaneous fixes
- Splitting the two instances of CheckArgument. The template version is now always defined in base/exception.h and is available in a cvc4_public header. This version has lost its variadic version (due to swig not supporting va_list's). The CPP macro version has been renamed PrettyCheckArgument. (Taking suggestions for a better name.) This is now only defined in base/cvc4_assert.h. Only use this in cvc4_private headers and in .cpp files that can use cvc4_private headers. To use a variadic version of CheckArguments, outside of this scope, you need to duplicate this macro locally. See cvc3_compat.cpp for an example. - Making fitsSignedInt() and fitsUnsignedInt() work more robustly for CLN on 32 bit systems. - Refactoring ArrayStoreAll to avoid potential problems with circular header inclusions. - Changing some headers to use iosfwd when possible.
Diffstat (limited to 'src/expr/array_store_all.cpp')
-rw-r--r--src/expr/array_store_all.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/expr/array_store_all.cpp b/src/expr/array_store_all.cpp
index 62c8ec978..d9d0a5f8d 100644
--- a/src/expr/array_store_all.cpp
+++ b/src/expr/array_store_all.cpp
@@ -20,12 +20,85 @@
#include <iostream>
+#include "base/cvc4_assert.h"
+#include "expr/expr.h"
+#include "expr/type.h"
+
using namespace std;
namespace CVC4 {
+ArrayStoreAll::ArrayStoreAll(const ArrayStoreAll& other)
+ : d_type(new ArrayType(other.getType()))
+ , d_expr(new Expr(other.getExpr())) {}
+
+ArrayStoreAll::~ArrayStoreAll() throw() {
+ delete d_expr;
+ delete d_type;
+}
+
+ArrayStoreAll& ArrayStoreAll::operator=(const ArrayStoreAll& other){
+ (*d_type) = other.getType();
+ (*d_expr) = other.getExpr();
+}
+
+ArrayStoreAll::ArrayStoreAll(const ArrayType& type, const Expr& expr)
+ throw(IllegalArgumentException)
+ : d_type(new ArrayType(type))
+ , d_expr(new Expr(expr))
+{
+ // this check is stronger than the assertion check in the expr manager that ArrayTypes are actually array types
+ // because this check is done in production builds too
+ PrettyCheckArgument(
+ type.isArray(),
+ type,
+ "array store-all constants can only be created for array types, not `%s'",
+ type.toString().c_str());
+
+ PrettyCheckArgument(
+ expr.getType().isComparableTo(type.getConstituentType()),
+ expr,
+ "expr type `%s' does not match constituent type of array type `%s'",
+ expr.getType().toString().c_str(),
+ type.toString().c_str());
+
+ PrettyCheckArgument(
+ expr.isConst(),
+ expr,
+ "ArrayStoreAll requires a constant expression");
+}
+
+
+const ArrayType& ArrayStoreAll::getType() const throw() {
+ return *d_type;
+}
+
+const Expr& ArrayStoreAll::getExpr() const throw() {
+ return *d_expr;
+}
+
+bool ArrayStoreAll::operator==(const ArrayStoreAll& asa) const throw() {
+ return getType() == asa.getType() && getExpr() == asa.getExpr();
+}
+
+
+bool ArrayStoreAll::operator<(const ArrayStoreAll& asa) const throw() {
+ return (getType() < asa.getType()) ||
+ (getType() == asa.getType() && getExpr() < asa.getExpr());
+}
+
+bool ArrayStoreAll::operator<=(const ArrayStoreAll& asa) const throw() {
+ return (getType() < asa.getType()) ||
+ (getType() == asa.getType() && getExpr() <= asa.getExpr());
+}
+
std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) {
return out << "__array_store_all__(" << asa.getType() << ", " << asa.getExpr() << ')';
}
+size_t ArrayStoreAllHashFunction::operator()(const ArrayStoreAll& asa) const {
+ return TypeHashFunction()(asa.getType()) * ExprHashFunction()(asa.getExpr());
+}
+
+
}/* CVC4 namespace */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback