| 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 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 bool Utf16CharacterStream::SetBookmark() { return false; } | 33 bool Utf16CharacterStream::SetBookmark() { return false; } |
| 34 void Utf16CharacterStream::ResetToBookmark() { UNREACHABLE(); } | 34 void Utf16CharacterStream::ResetToBookmark() { UNREACHABLE(); } |
| 35 | 35 |
| 36 | 36 |
| 37 // ---------------------------------------------------------------------------- | 37 // ---------------------------------------------------------------------------- |
| 38 // Scanner | 38 // Scanner |
| 39 | 39 |
| 40 Scanner::Scanner(UnicodeCache* unicode_cache) | 40 Scanner::Scanner(UnicodeCache* unicode_cache) |
| 41 : unicode_cache_(unicode_cache), | 41 : unicode_cache_(unicode_cache), |
| 42 bookmark_c0_(kNoBookmark), | 42 bookmark_c0_(kNoBookmark), |
| 43 octal_pos_(Location::invalid()), | 43 octal_pos_(Location::invalid()) { |
| 44 harmony_unicode_(false) { | |
| 45 bookmark_current_.literal_chars = &bookmark_current_literal_; | 44 bookmark_current_.literal_chars = &bookmark_current_literal_; |
| 46 bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_; | 45 bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_; |
| 47 bookmark_next_.literal_chars = &bookmark_next_literal_; | 46 bookmark_next_.literal_chars = &bookmark_next_literal_; |
| 48 bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_; | 47 bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_; |
| 49 } | 48 } |
| 50 | 49 |
| 51 | 50 |
| 52 void Scanner::Initialize(Utf16CharacterStream* source) { | 51 void Scanner::Initialize(Utf16CharacterStream* source) { |
| 53 source_ = source; | 52 source_ = source; |
| 54 // Need to capture identifiers in order to recognize "get" and "set" | 53 // Need to capture identifiers in order to recognize "get" and "set" |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 uc32 Scanner::ScanIdentifierUnicodeEscape() { | 1067 uc32 Scanner::ScanIdentifierUnicodeEscape() { |
| 1069 Advance(); | 1068 Advance(); |
| 1070 if (c0_ != 'u') return -1; | 1069 if (c0_ != 'u') return -1; |
| 1071 Advance(); | 1070 Advance(); |
| 1072 return ScanUnicodeEscape<false>(); | 1071 return ScanUnicodeEscape<false>(); |
| 1073 } | 1072 } |
| 1074 | 1073 |
| 1075 | 1074 |
| 1076 template <bool capture_raw> | 1075 template <bool capture_raw> |
| 1077 uc32 Scanner::ScanUnicodeEscape() { | 1076 uc32 Scanner::ScanUnicodeEscape() { |
| 1078 // Accept both \uxxxx and \u{xxxxxx} (if harmony unicode escapes are | 1077 // Accept both \uxxxx and \u{xxxxxx}. In the latter case, the number of |
| 1079 // allowed). In the latter case, the number of hex digits between { } is | 1078 // hex digits between { } is arbitrary. \ and u have already been read. |
| 1080 // arbitrary. \ and u have already been read. | 1079 if (c0_ == '{') { |
| 1081 if (c0_ == '{' && HarmonyUnicode()) { | |
| 1082 Advance<capture_raw>(); | 1080 Advance<capture_raw>(); |
| 1083 uc32 cp = ScanUnlimitedLengthHexNumber<capture_raw>(0x10ffff); | 1081 uc32 cp = ScanUnlimitedLengthHexNumber<capture_raw>(0x10ffff); |
| 1084 if (cp < 0) { | 1082 if (cp < 0) { |
| 1085 return -1; | 1083 return -1; |
| 1086 } | 1084 } |
| 1087 if (c0_ != '}') { | 1085 if (c0_ != '}') { |
| 1088 return -1; | 1086 return -1; |
| 1089 } | 1087 } |
| 1090 Advance<capture_raw>(); | 1088 Advance<capture_raw>(); |
| 1091 return cp; | 1089 return cp; |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1615 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
| 1618 } | 1616 } |
| 1619 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1617 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
| 1620 | 1618 |
| 1621 backing_store_.AddBlock(bytes); | 1619 backing_store_.AddBlock(bytes); |
| 1622 return backing_store_.EndSequence().start(); | 1620 return backing_store_.EndSequence().start(); |
| 1623 } | 1621 } |
| 1624 | 1622 |
| 1625 } // namespace internal | 1623 } // namespace internal |
| 1626 } // namespace v8 | 1624 } // namespace v8 |
| OLD | NEW |