| Index: src/conversions.cc
|
| ===================================================================
|
| --- src/conversions.cc (revision 7006)
|
| +++ src/conversions.cc (working copy)
|
| @@ -127,25 +127,24 @@
|
| }
|
|
|
|
|
| -static double SignedZero(bool sign) {
|
| - return sign ? -0.0 : 0.0;
|
| +static double SignedZero(bool negative) {
|
| + return negative ? -0.0 : 0.0;
|
| }
|
|
|
|
|
| // Parsing integers with radix 2, 4, 8, 16, 32. Assumes current != end.
|
| template <int radix_log_2, class Iterator, class EndMark>
|
| -static double InternalStringToIntDouble(
|
| - ScannerConstants* scanner_constants,
|
| - Iterator current,
|
| - EndMark end,
|
| - bool sign,
|
| - bool allow_trailing_junk) {
|
| +static double InternalStringToIntDouble(ScannerConstants* scanner_constants,
|
| + Iterator current,
|
| + EndMark end,
|
| + bool negative,
|
| + bool allow_trailing_junk) {
|
| ASSERT(current != end);
|
|
|
| // Skip leading 0s.
|
| while (*current == '0') {
|
| ++current;
|
| - if (current == end) return SignedZero(sign);
|
| + if (current == end) return SignedZero(negative);
|
| }
|
|
|
| int64_t number = 0;
|
| @@ -223,7 +222,7 @@
|
| ASSERT(static_cast<int64_t>(static_cast<double>(number)) == number);
|
|
|
| if (exponent == 0) {
|
| - if (sign) {
|
| + if (negative) {
|
| if (number == 0) return -0.0;
|
| number = -number;
|
| }
|
| @@ -233,7 +232,7 @@
|
| ASSERT(number != 0);
|
| // The double could be constructed faster from number (mantissa), exponent
|
| // and sign. Assuming it's a rare case more simple code is used.
|
| - return static_cast<double>(sign ? -number : number) * pow(2.0, exponent);
|
| + return static_cast<double>(negative ? -number : number) * pow(2.0, exponent);
|
| }
|
|
|
|
|
| @@ -249,7 +248,7 @@
|
| return empty_string_val;
|
| }
|
|
|
| - bool sign = false;
|
| + bool negative = false;
|
| bool leading_zero = false;
|
|
|
| if (*current == '+') {
|
| @@ -263,14 +262,14 @@
|
| if (!AdvanceToNonspace(scanner_constants, ¤t, end)) {
|
| return JUNK_STRING_VALUE;
|
| }
|
| - sign = true;
|
| + negative = true;
|
| }
|
|
|
| if (radix == 0) {
|
| // Radix detection.
|
| if (*current == '0') {
|
| ++current;
|
| - if (current == end) return SignedZero(sign);
|
| + if (current == end) return SignedZero(negative);
|
| if (*current == 'x' || *current == 'X') {
|
| radix = 16;
|
| ++current;
|
| @@ -286,7 +285,7 @@
|
| if (*current == '0') {
|
| // Allow "0x" prefix.
|
| ++current;
|
| - if (current == end) return SignedZero(sign);
|
| + if (current == end) return SignedZero(negative);
|
| if (*current == 'x' || *current == 'X') {
|
| ++current;
|
| if (current == end) return JUNK_STRING_VALUE;
|
| @@ -302,7 +301,7 @@
|
| while (*current == '0') {
|
| leading_zero = true;
|
| ++current;
|
| - if (current == end) return SignedZero(sign);
|
| + if (current == end) return SignedZero(negative);
|
| }
|
|
|
| if (!leading_zero && !isDigit(*current, radix)) {
|
| @@ -313,21 +312,21 @@
|
| switch (radix) {
|
| case 2:
|
| return InternalStringToIntDouble<1>(
|
| - scanner_constants, current, end, sign, allow_trailing_junk);
|
| + scanner_constants, current, end, negative, allow_trailing_junk);
|
| case 4:
|
| return InternalStringToIntDouble<2>(
|
| - scanner_constants, current, end, sign, allow_trailing_junk);
|
| + scanner_constants, current, end, negative, allow_trailing_junk);
|
| case 8:
|
| return InternalStringToIntDouble<3>(
|
| - scanner_constants, current, end, sign, allow_trailing_junk);
|
| + scanner_constants, current, end, negative, allow_trailing_junk);
|
|
|
| case 16:
|
| return InternalStringToIntDouble<4>(
|
| - scanner_constants, current, end, sign, allow_trailing_junk);
|
| + scanner_constants, current, end, negative, allow_trailing_junk);
|
|
|
| case 32:
|
| return InternalStringToIntDouble<5>(
|
| - scanner_constants, current, end, sign, allow_trailing_junk);
|
| + scanner_constants, current, end, negative, allow_trailing_junk);
|
| default:
|
| UNREACHABLE();
|
| }
|
| @@ -360,7 +359,7 @@
|
| ASSERT(buffer_pos < kBufferSize);
|
| buffer[buffer_pos] = '\0';
|
| Vector<const char> buffer_vector(buffer, buffer_pos);
|
| - return sign ? -Strtod(buffer_vector, 0) : Strtod(buffer_vector, 0);
|
| + return negative ? -Strtod(buffer_vector, 0) : Strtod(buffer_vector, 0);
|
| }
|
|
|
| // The following code causes accumulating rounding error for numbers greater
|
| @@ -423,7 +422,7 @@
|
| return JUNK_STRING_VALUE;
|
| }
|
|
|
| - return sign ? -v : v;
|
| + return negative ? -v : v;
|
| }
|
|
|
|
|
| @@ -465,7 +464,7 @@
|
| bool nonzero_digit_dropped = false;
|
| bool fractional_part = false;
|
|
|
| - bool sign = false;
|
| + bool negative = false;
|
|
|
| if (*current == '+') {
|
| // Ignore leading sign.
|
| @@ -474,7 +473,7 @@
|
| } else if (*current == '-') {
|
| ++current;
|
| if (current == end) return JUNK_STRING_VALUE;
|
| - sign = true;
|
| + negative = true;
|
| }
|
|
|
| static const char kInfinitySymbol[] = "Infinity";
|
| @@ -489,13 +488,13 @@
|
| }
|
|
|
| ASSERT(buffer_pos == 0);
|
| - return sign ? -V8_INFINITY : V8_INFINITY;
|
| + return negative ? -V8_INFINITY : V8_INFINITY;
|
| }
|
|
|
| bool leading_zero = false;
|
| if (*current == '0') {
|
| ++current;
|
| - if (current == end) return SignedZero(sign);
|
| + if (current == end) return SignedZero(negative);
|
|
|
| leading_zero = true;
|
|
|
| @@ -509,14 +508,14 @@
|
| return InternalStringToIntDouble<4>(scanner_constants,
|
| current,
|
| end,
|
| - sign,
|
| + negative,
|
| allow_trailing_junk);
|
| }
|
|
|
| // Ignore leading zeros in the integer part.
|
| while (*current == '0') {
|
| ++current;
|
| - if (current == end) return SignedZero(sign);
|
| + if (current == end) return SignedZero(negative);
|
| }
|
| }
|
|
|
| @@ -561,7 +560,7 @@
|
| // leading zeros (if any).
|
| while (*current == '0') {
|
| ++current;
|
| - if (current == end) return SignedZero(sign);
|
| + if (current == end) return SignedZero(negative);
|
| exponent--; // Move this 0 into the exponent.
|
| }
|
| }
|
| @@ -655,7 +654,7 @@
|
| return InternalStringToIntDouble<3>(scanner_constants,
|
| buffer,
|
| buffer + buffer_pos,
|
| - sign,
|
| + negative,
|
| allow_trailing_junk);
|
| }
|
|
|
| @@ -668,7 +667,7 @@
|
| buffer[buffer_pos] = '\0';
|
|
|
| double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent);
|
| - return sign ? -converted : converted;
|
| + return negative ? -converted : converted;
|
| }
|
|
|
|
|
| @@ -740,26 +739,12 @@
|
|
|
|
|
| const char* DoubleToCString(double v, Vector<char> buffer) {
|
| - StringBuilder builder(buffer.start(), buffer.length());
|
| -
|
| switch (fpclassify(v)) {
|
| - case FP_NAN:
|
| - builder.AddString("NaN");
|
| - break;
|
| -
|
| - case FP_INFINITE:
|
| - if (v < 0.0) {
|
| - builder.AddString("-Infinity");
|
| - } else {
|
| - builder.AddString("Infinity");
|
| - }
|
| - break;
|
| -
|
| - case FP_ZERO:
|
| - builder.AddCharacter('0');
|
| - break;
|
| -
|
| + case FP_NAN: return "NaN";
|
| + case FP_INFINITE: return (v < 0.0 ? "-Infinity" : "Infinity");
|
| + case FP_ZERO: return "0";
|
| default: {
|
| + StringBuilder builder(buffer.start(), buffer.length());
|
| int decimal_point;
|
| int sign;
|
| const int kV8DtoaBufferCapacity = kBase10MaximalLength + 1;
|
| @@ -802,9 +787,9 @@
|
| if (exponent < 0) exponent = -exponent;
|
| builder.AddFormatted("%d", exponent);
|
| }
|
| + return builder.Finalize();
|
| }
|
| }
|
| - return builder.Finalize();
|
| }
|
|
|
|
|
|
|