summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
Diffstat (limited to 'third_party')
-rw-r--r--third_party/bigint/BigInteger.cc34
-rw-r--r--third_party/bigint/BigInteger.hh16
-rw-r--r--third_party/bigint/BigIntegerUtils.cc5
-rw-r--r--third_party/bigint/BigUnsigned.cc27
-rw-r--r--third_party/bigint/BigUnsigned.hh31
-rw-r--r--third_party/bigint/BigUnsignedInABase.cc28
6 files changed, 1 insertions, 140 deletions
diff --git a/third_party/bigint/BigInteger.cc b/third_party/bigint/BigInteger.cc
index bac578f974..93b57e4255 100644
--- a/third_party/bigint/BigInteger.cc
+++ b/third_party/bigint/BigInteger.cc
@@ -20,11 +20,7 @@ BigInteger::BigInteger(const Blk *b, Index blen, Sign s) : mag(b, blen) {
switch (s) {
case zero:
if (!mag.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::BigInteger(const Blk *, Index, Sign): Cannot use a sign of zero with a nonzero magnitude";
-#endif
sign = zero;
break;
case positive:
@@ -35,11 +31,7 @@ BigInteger::BigInteger(const Blk *b, Index blen, Sign s) : mag(b, blen) {
default:
/* g++ seems to be optimizing out this case on the assumption
* that the sign is a valid member of the enumeration. Oh well. */
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::BigInteger(const Blk *, Index, Sign): Invalid sign";
-#endif
}
}
@@ -47,11 +39,7 @@ BigInteger::BigInteger(const BigUnsigned &x, Sign s) : mag(x) {
switch (s) {
case zero:
if (!mag.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::BigInteger(const BigUnsigned &, Sign): Cannot use a sign of zero with a nonzero magnitude";
-#endif
sign = zero;
break;
case positive:
@@ -62,11 +50,7 @@ BigInteger::BigInteger(const BigUnsigned &x, Sign s) : mag(x) {
default:
/* g++ seems to be optimizing out this case on the assumption
* that the sign is a valid member of the enumeration. Oh well. */
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::BigInteger(const BigUnsigned &, Sign): Invalid sign";
-#endif
}
}
@@ -114,12 +98,7 @@ inline X convertBigUnsignedToPrimitiveAccess(const BigUnsigned &a) {
template <class X>
X BigInteger::convertToUnsignedPrimitive() const {
if (sign == negative)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::to<Primitive>: "
- "Cannot convert a negative integer to an unsigned type";
-#endif
else
return convertBigUnsignedToPrimitiveAccess<X>(mag);
}
@@ -146,12 +125,7 @@ X BigInteger::convertToSignedPrimitive() const {
}
// Otherwise fall through.
}
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::to<Primitive>: "
- "Value is too big to fit in the requested type";
-#endif
}
unsigned long BigInteger::toUnsignedLong () const { return convertToUnsignedPrimitive<unsigned long > (); }
@@ -179,11 +153,7 @@ BigInteger::CmpRes BigInteger::compareTo(const BigInteger &x) const {
// Compare the magnitudes, but return the opposite result
return CmpRes(-mag.compareTo(x.mag));
default:
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger internal error";
-#endif
}
}
@@ -315,11 +285,7 @@ void BigInteger::divideWithRemainder(const BigInteger &b, BigInteger &q) {
// Defend against aliased calls;
// same idea as in BigUnsigned::divideWithRemainder .
if (this == &q)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::divideWithRemainder: Cannot write quotient and remainder into the same variable";
-#endif
if (this == &b || &q == &b) {
BigInteger tmpB(b);
divideWithRemainder(tmpB, q);
diff --git a/third_party/bigint/BigInteger.hh b/third_party/bigint/BigInteger.hh
index a239d3c954..320a22f7b7 100644
--- a/third_party/bigint/BigInteger.hh
+++ b/third_party/bigint/BigInteger.hh
@@ -164,11 +164,7 @@ inline BigInteger BigInteger::operator *(const BigInteger &x) const {
}
inline BigInteger BigInteger::operator /(const BigInteger &x) const {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::operator /: division by zero";
-#endif
BigInteger q, r;
r = *this;
r.divideWithRemainder(x, q);
@@ -176,11 +172,7 @@ inline BigInteger BigInteger::operator /(const BigInteger &x) const {
}
inline BigInteger BigInteger::operator %(const BigInteger &x) const {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::operator %: division by zero";
-#endif
BigInteger q, r;
r = *this;
r.divideWithRemainder(x, q);
@@ -210,11 +202,7 @@ inline void BigInteger::operator *=(const BigInteger &x) {
}
inline void BigInteger::operator /=(const BigInteger &x) {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::operator /=: division by zero";
-#endif
/* The following technique is slightly faster than copying *this first
* when x is large. */
BigInteger q;
@@ -224,11 +212,7 @@ inline void BigInteger::operator /=(const BigInteger &x) {
}
inline void BigInteger::operator %=(const BigInteger &x) {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::operator %=: division by zero";
-#endif
BigInteger q;
// Mods *this by x. Don't care about quotient left in q.
divideWithRemainder(x, q);
diff --git a/third_party/bigint/BigIntegerUtils.cc b/third_party/bigint/BigIntegerUtils.cc
index fac8ac34b1..f48334d961 100644
--- a/third_party/bigint/BigIntegerUtils.cc
+++ b/third_party/bigint/BigIntegerUtils.cc
@@ -42,11 +42,8 @@ std::ostream &operator <<(std::ostream &os, const BigUnsigned &x) {
if (osFlags & os.showbase)
os << '0';
} else
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "std::ostream << BigUnsigned: Could not determine the desired base from output-stream flags";
-#endif
+
std::string s = std::string(BigUnsignedInABase(x, base));
os << s;
return os;
diff --git a/third_party/bigint/BigUnsigned.cc b/third_party/bigint/BigUnsigned.cc
index 863fadcb39..e38e4aa26d 100644
--- a/third_party/bigint/BigUnsigned.cc
+++ b/third_party/bigint/BigUnsigned.cc
@@ -195,12 +195,7 @@ void BigUnsigned::subtract(const BigUnsigned &a, const BigUnsigned &b) {
return;
} else if (a.len < b.len)
// If a is shorter than b, the result is negative.
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::subtract: "
- "Negative result in unsigned calculation";
-#endif
// Some variables...
bool borrowIn, borrowOut;
Blk temp;
@@ -233,11 +228,7 @@ void BigUnsigned::subtract(const BigUnsigned &a, const BigUnsigned &b) {
* predictable state. */
if (borrowIn) {
len = 0;
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::subtract: Negative result in unsigned calculation";
-#endif
} else
// Copy over the rest of the blocks
for (; i < a.len; i++)
@@ -400,11 +391,7 @@ void BigUnsigned::divideWithRemainder(const BigUnsigned &b, BigUnsigned &q) {
* It would be silly to try to write quotient and remainder to the
* same variable. Rule that out right away. */
if (this == &q)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::divideWithRemainder: Cannot write quotient and remainder into the same variable";
-#endif
/* Now *this and q are separate, so the only concern is that b might be
* aliased to one of them. If so, use a temporary copy of b. */
if (this == &b || &q == &b) {
@@ -614,12 +601,7 @@ void BigUnsigned::bitShiftLeft(const BigUnsigned &a, int b) {
DTRT_ALIASED(this == &a, bitShiftLeft(a, b));
if (b < 0) {
if (b << 1 == 0)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::bitShiftLeft: "
- "Pathological shift amount not implemented";
-#endif
else {
bitShiftRight(a, -b);
return;
@@ -644,12 +626,7 @@ void BigUnsigned::bitShiftRight(const BigUnsigned &a, int b) {
DTRT_ALIASED(this == &a, bitShiftRight(a, b));
if (b < 0) {
if (b << 1 == 0)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::bitShiftRight: "
- "Pathological shift amount not implemented";
-#endif
else {
bitShiftLeft(a, -b);
return;
@@ -705,11 +682,7 @@ void BigUnsigned::operator ++(int) {
// Prefix decrement
void BigUnsigned::operator --() {
if (len == 0)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator --(): Cannot decrement an unsigned zero";
-#endif
Index i;
bool borrow = true;
for (i = 0; borrow; i++) {
diff --git a/third_party/bigint/BigUnsigned.hh b/third_party/bigint/BigUnsigned.hh
index accd4d6782..de4c18e066 100644
--- a/third_party/bigint/BigUnsigned.hh
+++ b/third_party/bigint/BigUnsigned.hh
@@ -267,11 +267,7 @@ inline BigUnsigned BigUnsigned::operator *(const BigUnsigned &x) const {
}
inline BigUnsigned BigUnsigned::operator /(const BigUnsigned &x) const {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator /: division by zero";
-#endif
BigUnsigned q, r;
r = *this;
r.divideWithRemainder(x, q);
@@ -279,11 +275,7 @@ inline BigUnsigned BigUnsigned::operator /(const BigUnsigned &x) const {
}
inline BigUnsigned BigUnsigned::operator %(const BigUnsigned &x) const {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator %: division by zero";
-#endif
BigUnsigned q, r;
r = *this;
r.divideWithRemainder(x, q);
@@ -326,11 +318,7 @@ inline void BigUnsigned::operator *=(const BigUnsigned &x) {
}
inline void BigUnsigned::operator /=(const BigUnsigned &x) {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator /=: division by zero";
-#endif
/* The following technique is slightly faster than copying *this first
* when x is large. */
BigUnsigned q;
@@ -340,11 +328,7 @@ inline void BigUnsigned::operator /=(const BigUnsigned &x) {
}
inline void BigUnsigned::operator %=(const BigUnsigned &x) {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator %=: division by zero";
-#endif
BigUnsigned q;
// Mods *this by x. Don't care about quotient left in q.
divideWithRemainder(x, q);
@@ -398,12 +382,7 @@ void BigUnsigned::initFromPrimitive(X x) {
template <class X>
void BigUnsigned::initFromSignedPrimitive(X x) {
if (x < 0)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned constructor: "
- "Cannot construct a BigUnsigned from a negative number";
-#endif
else
initFromPrimitive(x);
}
@@ -427,12 +406,7 @@ X BigUnsigned::convertToPrimitive() const {
return x;
// Otherwise fall through.
}
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::to<Primitive>: "
- "Value is too big to fit in the requested type";
-#endif
}
/* Wrap the above in an x >= 0 test to make sure we got a nonnegative result,
@@ -445,12 +419,7 @@ X BigUnsigned::convertToSignedPrimitive() const {
if (x >= 0)
return x;
else
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::to(Primitive): "
- "Value is too big to fit in the requested type";
-#endif
}
#endif
diff --git a/third_party/bigint/BigUnsignedInABase.cc b/third_party/bigint/BigUnsignedInABase.cc
index a24042d538..72fe256a5f 100644
--- a/third_party/bigint/BigUnsignedInABase.cc
+++ b/third_party/bigint/BigUnsignedInABase.cc
@@ -10,20 +10,12 @@ BigUnsignedInABase::BigUnsignedInABase(const Digit *d, Index l, Base base)
: NumberlikeArray<Digit>(d, l), base(base) {
// Check the base
if (base < 2)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase::BigUnsignedInABase(const Digit *, Index, Base): The base must be at least 2";
-#endif
// Validate the digits.
for (Index i = 0; i < l; i++)
if (blk[i] >= base)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase::BigUnsignedInABase(const Digit *, Index, Base): A digit is too large for the specified base";
-#endif
// Eliminate any leading zeros we may have been passed.
zapLeadingZeros();
@@ -46,11 +38,7 @@ namespace {
BigUnsignedInABase::BigUnsignedInABase(const BigUnsigned &x, Base base) {
// Check the base
if (base < 2)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase(BigUnsigned, Base): The base must be at least 2";
-#endif
this->base = base;
// Get an upper bound on how much space we need
@@ -91,11 +79,7 @@ BigUnsignedInABase::operator BigUnsigned() const {
BigUnsignedInABase::BigUnsignedInABase(const std::string &s, Base base) {
// Check the base.
if (base > 36)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase(std::string, Base): The default string conversion routines use the symbol set 0-9, A-Z and therefore support only up to base 36. You tried a conversion with a base over 36; write your own string conversion routine.";
-#endif
// Save the base.
// This pattern is seldom seen in C++, but the analogous ``this.'' is common in Java.
this->base = base;
@@ -116,29 +100,17 @@ BigUnsignedInABase::BigUnsignedInABase(const std::string &s, Base base) {
else if (theSymbol >= 'a' && theSymbol <= 'z')
blk[digitNum] = theSymbol - 'a' + 10;
else
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase(std::string, Base): Bad symbol in input. Only 0-9, A-Z, a-z are accepted.";
-#endif
if (blk[digitNum] >= base)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase::BigUnsignedInABase(const Digit *, Index, Base): A digit is too large for the specified base";
-#endif
}
zapLeadingZeros();
}
BigUnsignedInABase::operator std::string() const {
if (base > 36)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase ==> std::string: The default string conversion routines use the symbol set 0-9, A-Z and therefore support only up to base 36. You tried a conversion with a base over 36; write your own string conversion routine.";
-#endif
if (len == 0)
return std::string("0");
// Some compilers don't have push_back, so use a char * buffer instead.