Backed out changeset 3eba249fac11 (bug 1845441) for causing build bustages in Decimal.h
This commit is contained in:
@@ -187,16 +187,16 @@ static const nsAttrValue::EnumTable kCaptureTable[] = {
|
||||
|
||||
static const nsAttrValue::EnumTable* kCaptureDefault = &kCaptureTable[2];
|
||||
|
||||
constexpr Decimal HTMLInputElement::kStepScaleFactorDate(86400000);
|
||||
constexpr Decimal HTMLInputElement::kStepScaleFactorNumberRange(1);
|
||||
constexpr Decimal HTMLInputElement::kStepScaleFactorTime(1000);
|
||||
constexpr Decimal HTMLInputElement::kStepScaleFactorMonth(1);
|
||||
constexpr Decimal HTMLInputElement::kStepScaleFactorWeek(7 * 86400000);
|
||||
constexpr Decimal HTMLInputElement::kDefaultStepBase(0);
|
||||
constexpr Decimal HTMLInputElement::kDefaultStepBaseWeek(-259200000);
|
||||
constexpr Decimal HTMLInputElement::kDefaultStep(1);
|
||||
constexpr Decimal HTMLInputElement::kDefaultStepTime(60);
|
||||
constexpr Decimal HTMLInputElement::kStepAny(0);
|
||||
const Decimal HTMLInputElement::kStepScaleFactorDate = Decimal(86400000);
|
||||
const Decimal HTMLInputElement::kStepScaleFactorNumberRange = Decimal(1);
|
||||
const Decimal HTMLInputElement::kStepScaleFactorTime = Decimal(1000);
|
||||
const Decimal HTMLInputElement::kStepScaleFactorMonth = Decimal(1);
|
||||
const Decimal HTMLInputElement::kStepScaleFactorWeek = Decimal(7 * 86400000);
|
||||
const Decimal HTMLInputElement::kDefaultStepBase = Decimal(0);
|
||||
const Decimal HTMLInputElement::kDefaultStepBaseWeek = Decimal(-259200000);
|
||||
const Decimal HTMLInputElement::kDefaultStep = Decimal(1);
|
||||
const Decimal HTMLInputElement::kDefaultStepTime = Decimal(60);
|
||||
const Decimal HTMLInputElement::kStepAny = Decimal(0);
|
||||
|
||||
const double HTMLInputElement::kMinimumYear = 1;
|
||||
const double HTMLInputElement::kMaximumYear = 275760;
|
||||
|
||||
@@ -41,6 +41,12 @@ namespace blink {
|
||||
|
||||
namespace DecimalPrivate {
|
||||
|
||||
static int const ExponentMax = 1023;
|
||||
static int const ExponentMin = -1023;
|
||||
static int const Precision = 18;
|
||||
|
||||
static const uint64_t MaxCoefficient = UINT64_C(0xDE0B6B3A763FFFF); // 999999999999999999 == 18 9's
|
||||
|
||||
// This class handles Decimal special values.
|
||||
class SpecialValueHandler {
|
||||
STACK_ALLOCATED();
|
||||
@@ -224,6 +230,43 @@ static uint64_t scaleUp(uint64_t x, int n)
|
||||
|
||||
using namespace DecimalPrivate;
|
||||
|
||||
Decimal::EncodedData::EncodedData(Sign sign, FormatClass formatClass)
|
||||
: m_coefficient(0)
|
||||
, m_exponent(0)
|
||||
, m_formatClass(formatClass)
|
||||
, m_sign(sign)
|
||||
{
|
||||
}
|
||||
|
||||
Decimal::EncodedData::EncodedData(Sign sign, int exponent, uint64_t coefficient)
|
||||
: m_formatClass(coefficient ? ClassNormal : ClassZero)
|
||||
, m_sign(sign)
|
||||
{
|
||||
if (exponent >= ExponentMin && exponent <= ExponentMax) {
|
||||
while (coefficient > MaxCoefficient) {
|
||||
coefficient /= 10;
|
||||
++exponent;
|
||||
}
|
||||
}
|
||||
|
||||
if (exponent > ExponentMax) {
|
||||
m_coefficient = 0;
|
||||
m_exponent = 0;
|
||||
m_formatClass = ClassInfinity;
|
||||
return;
|
||||
}
|
||||
|
||||
if (exponent < ExponentMin) {
|
||||
m_coefficient = 0;
|
||||
m_exponent = 0;
|
||||
m_formatClass = ClassZero;
|
||||
return;
|
||||
}
|
||||
|
||||
m_coefficient = coefficient;
|
||||
m_exponent = static_cast<int16_t>(exponent);
|
||||
}
|
||||
|
||||
bool Decimal::EncodedData::operator==(const EncodedData& another) const
|
||||
{
|
||||
return m_sign == another.m_sign
|
||||
@@ -232,6 +275,16 @@ bool Decimal::EncodedData::operator==(const EncodedData& another) const
|
||||
&& m_coefficient == another.m_coefficient;
|
||||
}
|
||||
|
||||
Decimal::Decimal(int32_t i32)
|
||||
: m_data(i32 < 0 ? Negative : Positive, 0, i32 < 0 ? static_cast<uint64_t>(-static_cast<int64_t>(i32)) : static_cast<uint64_t>(i32))
|
||||
{
|
||||
}
|
||||
|
||||
Decimal::Decimal(Sign sign, int exponent, uint64_t coefficient)
|
||||
: m_data(sign, coefficient ? exponent : 0, coefficient)
|
||||
{
|
||||
}
|
||||
|
||||
Decimal::Decimal(const EncodedData& data)
|
||||
: m_data(data)
|
||||
{
|
||||
|
||||
@@ -65,11 +65,6 @@
|
||||
namespace blink {
|
||||
|
||||
namespace DecimalPrivate {
|
||||
constexpr int ExponentMax = 1023;
|
||||
constexpr int ExponentMin = -1023;
|
||||
constexpr int Precision = 18;
|
||||
|
||||
static const uint64_t MaxCoefficient = UINT64_C(0xDE0B6B3A763FFFF); // 999999999999999999 == 18 9's
|
||||
class SpecialValueHandler;
|
||||
}
|
||||
|
||||
@@ -93,32 +88,7 @@ public:
|
||||
friend class Decimal;
|
||||
friend class DecimalPrivate::SpecialValueHandler;
|
||||
public:
|
||||
constexpr EncodedData(Sign sign, int exponent, uint64_t coefficient)
|
||||
: m_coefficient(0),
|
||||
m_exponent(0),
|
||||
m_formatClass(coefficient ? ClassNormal : ClassZero),
|
||||
m_sign(sign) {
|
||||
if (exponent >= DecimalPrivate::ExponentMin &&
|
||||
exponent <= DecimalPrivate::ExponentMax) {
|
||||
while (coefficient > DecimalPrivate::MaxCoefficient) {
|
||||
coefficient /= 10;
|
||||
++exponent;
|
||||
}
|
||||
}
|
||||
|
||||
if (exponent > DecimalPrivate::ExponentMax) {
|
||||
m_formatClass = ClassInfinity;
|
||||
return;
|
||||
}
|
||||
|
||||
if (exponent < DecimalPrivate::ExponentMin) {
|
||||
m_formatClass = ClassZero;
|
||||
return;
|
||||
}
|
||||
|
||||
m_coefficient = coefficient;
|
||||
m_exponent = static_cast<int16_t>(exponent);
|
||||
}
|
||||
EncodedData(Sign, int exponent, uint64_t coefficient);
|
||||
|
||||
bool operator==(const EncodedData&) const;
|
||||
bool operator!=(const EncodedData& another) const { return !operator==(another); }
|
||||
@@ -142,12 +112,7 @@ public:
|
||||
ClassZero,
|
||||
};
|
||||
|
||||
constexpr EncodedData(Sign sign, FormatClass formatClass)
|
||||
: m_coefficient(0),
|
||||
m_exponent(0),
|
||||
m_formatClass(formatClass),
|
||||
m_sign(sign) {}
|
||||
|
||||
EncodedData(Sign, FormatClass);
|
||||
FormatClass formatClass() const { return m_formatClass; }
|
||||
|
||||
uint64_t m_coefficient;
|
||||
@@ -156,12 +121,8 @@ public:
|
||||
Sign m_sign;
|
||||
};
|
||||
|
||||
MFBT_API constexpr explicit Decimal(int32_t i32 = 0)
|
||||
: m_data(i32 < 0 ? Negative : Positive, 0,
|
||||
i32 < 0 ? static_cast<uint64_t>(-static_cast<int64_t>(i32))
|
||||
: static_cast<uint64_t>(i32)) {}
|
||||
MFBT_API constexpr Decimal(Sign sign, int exponent, uint64_t coefficient)
|
||||
: m_data(sign, coefficient ? exponent : 0, coefficient) {}
|
||||
MFBT_API explicit Decimal(int32_t = 0);
|
||||
MFBT_API Decimal(Sign, int exponent, uint64_t coefficient);
|
||||
MFBT_API Decimal(const Decimal&);
|
||||
|
||||
MFBT_API Decimal& operator=(const Decimal&);
|
||||
|
||||
Reference in New Issue
Block a user