| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_CONVERSIONS_INL_H_ | 5 #ifndef V8_CONVERSIONS_INL_H_ |
| 6 #define V8_CONVERSIONS_INL_H_ | 6 #define V8_CONVERSIONS_INL_H_ |
| 7 | 7 |
| 8 #include <float.h> // Required for DBL_MAX and on Win32 for finite() | 8 #include <float.h> // Required for DBL_MAX and on Win32 for finite() |
| 9 #include <limits.h> // Required for INT_MAX etc. | 9 #include <limits.h> // Required for INT_MAX etc. |
| 10 #include <stdarg.h> | 10 #include <stdarg.h> |
| 11 #include <cmath> | 11 #include <cmath> |
| 12 #include "src/globals.h" // Required for V8_INFINITY | 12 #include "src/globals.h" // Required for V8_INFINITY |
| 13 | 13 |
| 14 // ---------------------------------------------------------------------------- | 14 // ---------------------------------------------------------------------------- |
| 15 // Extra POSIX/ANSI functions for Win32/MSVC. | 15 // Extra POSIX/ANSI functions for Win32/MSVC. |
| 16 | 16 |
| 17 #include "src/base/bits.h" |
| 17 #include "src/base/platform/platform.h" | 18 #include "src/base/platform/platform.h" |
| 18 #include "src/conversions.h" | 19 #include "src/conversions.h" |
| 19 #include "src/double.h" | 20 #include "src/double.h" |
| 20 #include "src/scanner.h" | 21 #include "src/scanner.h" |
| 21 #include "src/strtod.h" | 22 #include "src/strtod.h" |
| 22 | 23 |
| 23 namespace v8 { | 24 namespace v8 { |
| 24 namespace internal { | 25 namespace internal { |
| 25 | 26 |
| 26 inline double JunkStringValue() { | 27 inline double JunkStringValue() { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 while (*current == '0') { | 282 while (*current == '0') { |
| 282 leading_zero = true; | 283 leading_zero = true; |
| 283 ++current; | 284 ++current; |
| 284 if (current == end) return SignedZero(negative); | 285 if (current == end) return SignedZero(negative); |
| 285 } | 286 } |
| 286 | 287 |
| 287 if (!leading_zero && !isDigit(*current, radix)) { | 288 if (!leading_zero && !isDigit(*current, radix)) { |
| 288 return JunkStringValue(); | 289 return JunkStringValue(); |
| 289 } | 290 } |
| 290 | 291 |
| 291 if (IsPowerOf2(radix)) { | 292 if (base::bits::IsPowerOfTwo32(radix)) { |
| 292 switch (radix) { | 293 switch (radix) { |
| 293 case 2: | 294 case 2: |
| 294 return InternalStringToIntDouble<1>( | 295 return InternalStringToIntDouble<1>( |
| 295 unicode_cache, current, end, negative, allow_trailing_junk); | 296 unicode_cache, current, end, negative, allow_trailing_junk); |
| 296 case 4: | 297 case 4: |
| 297 return InternalStringToIntDouble<2>( | 298 return InternalStringToIntDouble<2>( |
| 298 unicode_cache, current, end, negative, allow_trailing_junk); | 299 unicode_cache, current, end, negative, allow_trailing_junk); |
| 299 case 8: | 300 case 8: |
| 300 return InternalStringToIntDouble<3>( | 301 return InternalStringToIntDouble<3>( |
| 301 unicode_cache, current, end, negative, allow_trailing_junk); | 302 unicode_cache, current, end, negative, allow_trailing_junk); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 SLOW_DCHECK(buffer_pos < kBufferSize); | 677 SLOW_DCHECK(buffer_pos < kBufferSize); |
| 677 buffer[buffer_pos] = '\0'; | 678 buffer[buffer_pos] = '\0'; |
| 678 | 679 |
| 679 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); | 680 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); |
| 680 return (sign == NEGATIVE) ? -converted : converted; | 681 return (sign == NEGATIVE) ? -converted : converted; |
| 681 } | 682 } |
| 682 | 683 |
| 683 } } // namespace v8::internal | 684 } } // namespace v8::internal |
| 684 | 685 |
| 685 #endif // V8_CONVERSIONS_INL_H_ | 686 #endif // V8_CONVERSIONS_INL_H_ |
| OLD | NEW |