OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 // Ignore leading sign. | 474 // Ignore leading sign. |
475 ++current; | 475 ++current; |
476 if (current == end) return JunkStringValue(); | 476 if (current == end) return JunkStringValue(); |
477 sign = POSITIVE; | 477 sign = POSITIVE; |
478 } else if (*current == '-') { | 478 } else if (*current == '-') { |
479 ++current; | 479 ++current; |
480 if (current == end) return JunkStringValue(); | 480 if (current == end) return JunkStringValue(); |
481 sign = NEGATIVE; | 481 sign = NEGATIVE; |
482 } | 482 } |
483 | 483 |
484 static const char kInfinitySymbol[] = "Infinity"; | 484 static const char kInfinityString[] = "Infinity"; |
485 if (*current == kInfinitySymbol[0]) { | 485 if (*current == kInfinityString[0]) { |
486 if (!SubStringEquals(¤t, end, kInfinitySymbol)) { | 486 if (!SubStringEquals(¤t, end, kInfinityString)) { |
487 return JunkStringValue(); | 487 return JunkStringValue(); |
488 } | 488 } |
489 | 489 |
490 if (!allow_trailing_junk && | 490 if (!allow_trailing_junk && |
491 AdvanceToNonspace(unicode_cache, ¤t, end)) { | 491 AdvanceToNonspace(unicode_cache, ¤t, end)) { |
492 return JunkStringValue(); | 492 return JunkStringValue(); |
493 } | 493 } |
494 | 494 |
495 ASSERT(buffer_pos == 0); | 495 ASSERT(buffer_pos == 0); |
496 return (sign == NEGATIVE) ? -V8_INFINITY : V8_INFINITY; | 496 return (sign == NEGATIVE) ? -V8_INFINITY : V8_INFINITY; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 ASSERT(buffer_pos < kBufferSize); | 669 ASSERT(buffer_pos < kBufferSize); |
670 buffer[buffer_pos] = '\0'; | 670 buffer[buffer_pos] = '\0'; |
671 | 671 |
672 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); | 672 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); |
673 return (sign == NEGATIVE) ? -converted : converted; | 673 return (sign == NEGATIVE) ? -converted : converted; |
674 } | 674 } |
675 | 675 |
676 } } // namespace v8::internal | 676 } } // namespace v8::internal |
677 | 677 |
678 #endif // V8_CONVERSIONS_INL_H_ | 678 #endif // V8_CONVERSIONS_INL_H_ |
OLD | NEW |