Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1070)

Side by Side Diff: src/conversions-inl.h

Issue 798413003: Remove obsolete V8_INFINITY macro. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address Svens smiley. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/typer.cc ('k') | src/globals.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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()
9 #include <limits.h> // Required for INT_MAX etc.
10 #include <stdarg.h>
11 #include <cmath> 8 #include <cmath>
12 #include "src/globals.h" // Required for V8_INFINITY 9 #include <cstdarg>
10 #include <limits>
13 11
14 // ---------------------------------------------------------------------------- 12 // ----------------------------------------------------------------------------
15 // Extra POSIX/ANSI functions for Win32/MSVC. 13 // Extra POSIX/ANSI functions for Win32/MSVC.
16 14
17 #include "src/base/bits.h" 15 #include "src/base/bits.h"
18 #include "src/base/platform/platform.h" 16 #include "src/base/platform/platform.h"
19 #include "src/conversions.h" 17 #include "src/conversions.h"
20 #include "src/double.h" 18 #include "src/double.h"
21 #include "src/scanner.h" 19 #include "src/scanner.h"
22 #include "src/strtod.h" 20 #include "src/strtod.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 if (!SubStringEquals(&current, end, kInfinityString)) { 474 if (!SubStringEquals(&current, end, kInfinityString)) {
477 return JunkStringValue(); 475 return JunkStringValue();
478 } 476 }
479 477
480 if (!allow_trailing_junk && 478 if (!allow_trailing_junk &&
481 AdvanceToNonspace(unicode_cache, &current, end)) { 479 AdvanceToNonspace(unicode_cache, &current, end)) {
482 return JunkStringValue(); 480 return JunkStringValue();
483 } 481 }
484 482
485 DCHECK(buffer_pos == 0); 483 DCHECK(buffer_pos == 0);
486 return (sign == NEGATIVE) ? -V8_INFINITY : V8_INFINITY; 484 return (sign == NEGATIVE) ? -std::numeric_limits<double>::infinity()
485 : std::numeric_limits<double>::infinity();
487 } 486 }
488 487
489 bool leading_zero = false; 488 bool leading_zero = false;
490 if (*current == '0') { 489 if (*current == '0') {
491 ++current; 490 ++current;
492 if (current == end) return SignedZero(sign == NEGATIVE); 491 if (current == end) return SignedZero(sign == NEGATIVE);
493 492
494 leading_zero = true; 493 leading_zero = true;
495 494
496 // It could be hexadecimal value. 495 // It could be hexadecimal value.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 635 }
637 636
638 if (current == end || *current < '0' || *current > '9') { 637 if (current == end || *current < '0' || *current > '9') {
639 if (allow_trailing_junk) { 638 if (allow_trailing_junk) {
640 goto parsing_done; 639 goto parsing_done;
641 } else { 640 } else {
642 return JunkStringValue(); 641 return JunkStringValue();
643 } 642 }
644 } 643 }
645 644
646 const int max_exponent = INT_MAX / 2; 645 const int max_exponent = std::numeric_limits<int>::max() / 2;
647 DCHECK(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2); 646 DCHECK(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2);
648 int num = 0; 647 int num = 0;
649 do { 648 do {
650 // Check overflow. 649 // Check overflow.
651 int digit = *current - '0'; 650 int digit = *current - '0';
652 if (num >= max_exponent / 10 651 if (num >= max_exponent / 10
653 && !(num == max_exponent / 10 && digit <= max_exponent % 10)) { 652 && !(num == max_exponent / 10 && digit <= max_exponent % 10)) {
654 num = max_exponent; 653 num = max_exponent;
655 } else { 654 } else {
656 num = num * 10 + digit; 655 num = num * 10 + digit;
(...skipping 28 matching lines...) Expand all
685 SLOW_DCHECK(buffer_pos < kBufferSize); 684 SLOW_DCHECK(buffer_pos < kBufferSize);
686 buffer[buffer_pos] = '\0'; 685 buffer[buffer_pos] = '\0';
687 686
688 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); 687 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent);
689 return (sign == NEGATIVE) ? -converted : converted; 688 return (sign == NEGATIVE) ? -converted : converted;
690 } 689 }
691 690
692 } } // namespace v8::internal 691 } } // namespace v8::internal
693 692
694 #endif // V8_CONVERSIONS_INL_H_ 693 #endif // V8_CONVERSIONS_INL_H_
OLDNEW
« no previous file with comments | « src/compiler/typer.cc ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698