mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8006 from ethereum/boost-workaround
Remove Boost <1.55 workaround for multiprecision::msb()
This commit is contained in:
commit
eba30c13a4
@ -52,23 +52,6 @@ using namespace dev::solidity;
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned int mostSignificantBit(bigint const& _number)
|
|
||||||
{
|
|
||||||
#if BOOST_VERSION < 105500
|
|
||||||
solAssert(_number > 0, "");
|
|
||||||
bigint number = _number;
|
|
||||||
unsigned int result = 0;
|
|
||||||
while (number != 0)
|
|
||||||
{
|
|
||||||
number >>= 1;
|
|
||||||
++result;
|
|
||||||
}
|
|
||||||
return --result;
|
|
||||||
#else
|
|
||||||
return boost::multiprecision::msb(_number);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check whether (_base ** _exp) fits into 4096 bits.
|
/// Check whether (_base ** _exp) fits into 4096 bits.
|
||||||
bool fitsPrecisionExp(bigint const& _base, bigint const& _exp)
|
bool fitsPrecisionExp(bigint const& _base, bigint const& _exp)
|
||||||
{
|
{
|
||||||
@ -79,7 +62,7 @@ bool fitsPrecisionExp(bigint const& _base, bigint const& _exp)
|
|||||||
|
|
||||||
size_t const bitsMax = 4096;
|
size_t const bitsMax = 4096;
|
||||||
|
|
||||||
unsigned mostSignificantBaseBit = mostSignificantBit(_base);
|
unsigned mostSignificantBaseBit = boost::multiprecision::msb(_base);
|
||||||
if (mostSignificantBaseBit == 0) // _base == 1
|
if (mostSignificantBaseBit == 0) // _base == 1
|
||||||
return true;
|
return true;
|
||||||
if (mostSignificantBaseBit > bitsMax) // _base >= 2 ^ 4096
|
if (mostSignificantBaseBit > bitsMax) // _base >= 2 ^ 4096
|
||||||
@ -105,7 +88,7 @@ bool fitsPrecisionBaseX(
|
|||||||
|
|
||||||
size_t const bitsMax = 4096;
|
size_t const bitsMax = 4096;
|
||||||
|
|
||||||
unsigned mostSignificantMantissaBit = mostSignificantBit(_mantissa);
|
unsigned mostSignificantMantissaBit = boost::multiprecision::msb(_mantissa);
|
||||||
if (mostSignificantMantissaBit > bitsMax) // _mantissa >= 2 ^ 4096
|
if (mostSignificantMantissaBit > bitsMax) // _mantissa >= 2 ^ 4096
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1100,7 +1083,7 @@ TypeResult RationalNumberType::binaryOperatorResult(Token _operator, Type const*
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32_t exponent = other.m_value.numerator().convert_to<uint32_t>();
|
uint32_t exponent = other.m_value.numerator().convert_to<uint32_t>();
|
||||||
if (exponent > mostSignificantBit(boost::multiprecision::abs(m_value.numerator())))
|
if (exponent > boost::multiprecision::msb(boost::multiprecision::abs(m_value.numerator())))
|
||||||
value = m_value.numerator() < 0 ? -1 : 0;
|
value = m_value.numerator() < 0 ? -1 : 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1124,7 +1107,7 @@ TypeResult RationalNumberType::binaryOperatorResult(Token _operator, Type const*
|
|||||||
}
|
}
|
||||||
|
|
||||||
// verify that numerator and denominator fit into 4096 bit after every operation
|
// verify that numerator and denominator fit into 4096 bit after every operation
|
||||||
if (value.numerator() != 0 && max(mostSignificantBit(abs(value.numerator())), mostSignificantBit(abs(value.denominator()))) > 4096)
|
if (value.numerator() != 0 && max(boost::multiprecision::msb(abs(value.numerator())), boost::multiprecision::msb(abs(value.denominator()))) > 4096)
|
||||||
return TypeResult::err("Precision of rational constants is limited to 4096 bits.");
|
return TypeResult::err("Precision of rational constants is limited to 4096 bits.");
|
||||||
|
|
||||||
return TypeResult{TypeProvider::rationalNumber(value)};
|
return TypeResult{TypeProvider::rationalNumber(value)};
|
||||||
|
@ -49,18 +49,6 @@ using namespace dev::solidity::test;
|
|||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#if BOOST_VERSION < 105900
|
|
||||||
test_case *make_test_case(
|
|
||||||
function<void()> const& _fn,
|
|
||||||
string const& _name,
|
|
||||||
string const& /* _filename */,
|
|
||||||
size_t /* _line */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return make_test_case(_fn, _name);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void removeTestSuite(std::string const& _name)
|
void removeTestSuite(std::string const& _name)
|
||||||
|
Loading…
Reference in New Issue
Block a user