From: Morgan Deters Date: Thu, 2 Aug 2012 21:40:02 +0000 (+0000) Subject: array-store-all class X-Git-Tag: cvc5-1.0.0~7897 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4cb370f81f0dcc1db56f981f46a7fb16f705d844;p=cvc5.git array-store-all class --- diff --git a/src/util/Makefile.am b/src/util/Makefile.am index c3b3d8438..8b0b2164f 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -74,6 +74,8 @@ libutil_la_SOURCES = \ index.h \ uninterpreted_constant.h \ uninterpreted_constant.cpp \ + array_store_all.h \ + array_store_all.cpp \ model.h \ model.cpp diff --git a/src/util/array_store_all.cpp b/src/util/array_store_all.cpp new file mode 100644 index 000000000..f12112b4c --- /dev/null +++ b/src/util/array_store_all.cpp @@ -0,0 +1,32 @@ +/********************* */ +/*! \file array_store_all.cpp + ** \verbatim + ** Original author: mdeters + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009-2012 The Analysis of Computer Systems Group (ACSys) + ** Courant Institute of Mathematical Sciences + ** New York University + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Representation of a constant array (an array in which the + ** element is the same for all indices) + ** + ** Representation of a constant array (an array in which the element is + ** the same for all indices). + **/ + +#include "util/array_store_all.h" +#include + +using namespace std; + +namespace CVC4 { + +std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) { + return out << "__array_store_all__(" << asa.getType() << ", " << asa.getExpr() << ')'; +} + +}/* CVC4 namespace */ diff --git a/src/util/array_store_all.h b/src/util/array_store_all.h new file mode 100644 index 000000000..5647ed53d --- /dev/null +++ b/src/util/array_store_all.h @@ -0,0 +1,95 @@ +/********************* */ +/*! \file array_store_all.h + ** \verbatim + ** Original author: mdeters + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009-2012 The Analysis of Computer Systems Group (ACSys) + ** Courant Institute of Mathematical Sciences + ** New York University + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Representation of a constant array (an array in which the + ** element is the same for all indices) + ** + ** Representation of a constant array (an array in which the element is + ** the same for all indices). + **/ + +#include "cvc4_public.h" + +#pragma once + +namespace CVC4 { + // messy; Expr needs ArrayStoreAll (because it's the payload of a + // CONSTANT-kinded expression), and ArrayStoreAll needs Expr. + class CVC4_PUBLIC ArrayStoreAll; +}/* CVC4 namespace */ + +#include "expr/expr.h" +#include "expr/type.h" +#include + +namespace CVC4 { + +class CVC4_PUBLIC ArrayStoreAll { + const Type d_type; + const Expr d_expr; + +public: + + ArrayStoreAll(Type type, Expr expr) throw(IllegalArgumentException) : + d_type(type), + d_expr(expr) { + CheckArgument(type.isArray(), type, "array store-all constants can only be created for array types, not `%s'", type.toString().c_str()); + CheckArgument(expr.getType() == ArrayType(type).getConstituentType(), expr, "expr type `%s' does not match constituent type of array type `%s'", expr.getType().toString().c_str(), type.toString().c_str()); + } + + ~ArrayStoreAll() throw() { + } + + Type getType() const throw() { + return d_type; + } + Expr getExpr() const throw() { + return d_expr; + } + + bool operator==(const ArrayStoreAll& asa) const throw() { + return d_type == asa.d_type && d_expr == asa.d_expr; + } + bool operator!=(const ArrayStoreAll& asa) const throw() { + return !(*this == asa); + } + + bool operator<(const ArrayStoreAll& asa) const throw() { + return d_type < asa.d_type || + (d_type == asa.d_type && d_expr < asa.d_expr); + } + bool operator<=(const ArrayStoreAll& asa) const throw() { + return d_type < asa.d_type || + (d_type == asa.d_type && d_expr <= asa.d_expr); + } + bool operator>(const ArrayStoreAll& asa) const throw() { + return !(*this <= asa); + } + bool operator>=(const ArrayStoreAll& asa) const throw() { + return !(*this < asa); + } + +};/* class ArrayStoreAll */ + +std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) CVC4_PUBLIC; + +/** + * Hash function for the BitVector constants. + */ +struct CVC4_PUBLIC ArrayStoreAllHashStrategy { + static inline size_t hash(const ArrayStoreAll& asa) { + return TypeHashFunction()(asa.getType()) * ExprHashFunction()(asa.getExpr()); + } +};/* struct ArrayStoreAllHashStrategy */ + +}/* CVC4 namespace */ diff --git a/src/util/uninterpreted_constant.h b/src/util/uninterpreted_constant.h index a6e7a7256..418b8d333 100644 --- a/src/util/uninterpreted_constant.h +++ b/src/util/uninterpreted_constant.h @@ -31,7 +31,7 @@ class CVC4_PUBLIC UninterpretedConstant { public: - UninterpretedConstant(Type type, Integer index) throw() : + UninterpretedConstant(Type type, Integer index) throw(IllegalArgumentException) : d_type(type), d_index(index) { CheckArgument(type.isSort(), type, "uninterpreted constants can only be created for uninterpreted sorts, not `%s'", type.toString().c_str());