diff options
author | Tim King <taking@google.com> | 2015-12-24 05:38:43 -0500 |
---|---|---|
committer | Tim King <taking@google.com> | 2015-12-24 05:38:43 -0500 |
commit | a39ad6584c1d61e22e72b53c3838f4f675ed2e19 (patch) | |
tree | ed40cb371c41ac285ca2bf41a82254a36134e132 /src/util/integer_cln_imp.h | |
parent | 87b0fe9ce10d1e5e9ed5a3e7db77f46bf3f68922 (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/util/integer_cln_imp.h')
-rw-r--r-- | src/util/integer_cln_imp.h | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/util/integer_cln_imp.h b/src/util/integer_cln_imp.h index 6df8d3b8e..9e5e6c2ae 100644 --- a/src/util/integer_cln_imp.h +++ b/src/util/integer_cln_imp.h @@ -20,14 +20,13 @@ #ifndef __CVC4__INTEGER_H #define __CVC4__INTEGER_H -#include <string> -#include <sstream> -#include <iostream> - -#include <cln/integer.h> #include <cln/input.h> +#include <cln/integer.h> #include <cln/integer_io.h> +#include <iostream> #include <limits> +#include <sstream> +#include <string> #include "base/exception.h" @@ -57,6 +56,17 @@ private: void parseInt(const std::string& s, unsigned base) throw(std::invalid_argument); + + // These constants are to help with CLN conversion in 32 bit. + // See http://www.ginac.de/CLN/cln.html#Conversions + static signed int s_fastSignedIntMax; /* 2^29 - 1 */ + static signed int s_fastSignedIntMin; /* -2^29 */ + static unsigned int s_fastUnsignedIntMax; /* 2^29 - 1 */ + + static signed long s_slowSignedIntMax; /* std::numeric_limits<signed int>::max() */ + static signed long s_slowSignedIntMin; /* std::numeric_limits<signed int>::min() */ + static unsigned long s_slowUnsignedIntMax; /* std::numeric_limits<unsigned int>::max() */ + public: /** Constructs a rational with the value 0. */ @@ -186,14 +196,7 @@ public: return Integer(cln::logior(d_value, mask)); } - Integer oneExtend(uint32_t size, uint32_t amount) const { - DebugCheckArgument((*this) < Integer(1).multiplyByPow2(size), size); - cln::cl_byte range(amount, size); - cln::cl_I allones = (cln::cl_I(1) << (size + amount))- 1; // 2^size - 1 - Integer temp(allones); - - return Integer(cln::deposit_field(allones, d_value, range)); - } + Integer oneExtend(uint32_t size, uint32_t amount) const; uint32_t toUnsignedInt() const { return cln::cl_I_to_uint(d_value); @@ -300,10 +303,7 @@ public: /** * If y divides *this, then exactQuotient returns (this/y) */ - Integer exactQuotient(const Integer& y) const { - DebugCheckArgument(y.divides(*this), y); - return Integer( cln::exquo(d_value, y.d_value) ); - } + Integer exactQuotient(const Integer& y) const; Integer modByPow2(uint32_t exp) const { cln::cl_byte range(exp, 0); |