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 23 matching lines...) Expand all Loading... | |
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_modules_(false), | 44 harmony_modules_(false) { |
45 harmony_unicode_(false) { | |
46 bookmark_current_.literal_chars = &bookmark_current_literal_; | 45 bookmark_current_.literal_chars = &bookmark_current_literal_; |
47 bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_; | 46 bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_; |
48 bookmark_next_.literal_chars = &bookmark_next_literal_; | 47 bookmark_next_.literal_chars = &bookmark_next_literal_; |
49 bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_; | 48 bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_; |
50 } | 49 } |
51 | 50 |
52 | 51 |
53 void Scanner::Initialize(Utf16CharacterStream* source) { | 52 void Scanner::Initialize(Utf16CharacterStream* source) { |
54 source_ = source; | 53 source_ = source; |
55 // Need to capture identifiers in order to recognize "get" and "set" | 54 // Need to capture identifiers in order to recognize "get" and "set" |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1069 uc32 Scanner::ScanIdentifierUnicodeEscape() { | 1068 uc32 Scanner::ScanIdentifierUnicodeEscape() { |
1070 Advance(); | 1069 Advance(); |
1071 if (c0_ != 'u') return -1; | 1070 if (c0_ != 'u') return -1; |
1072 Advance(); | 1071 Advance(); |
1073 return ScanUnicodeEscape<false>(); | 1072 return ScanUnicodeEscape<false>(); |
1074 } | 1073 } |
1075 | 1074 |
1076 | 1075 |
1077 template <bool capture_raw> | 1076 template <bool capture_raw> |
1078 uc32 Scanner::ScanUnicodeEscape() { | 1077 uc32 Scanner::ScanUnicodeEscape() { |
1079 // Accept both \uxxxx and \u{xxxxxx} (if harmony unicode escapes are | 1078 // Accept both \uxxxx and \u{xxxxxx}. |
rossberg
2015/08/05 07:58:07
Nit: reformat.
adamk
2015/08/05 18:16:17
Done.
| |
1080 // allowed). In the latter case, the number of hex digits between { } is | 1079 // In the latter case, the number of hex digits between { } is |
1081 // arbitrary. \ and u have already been read. | 1080 // arbitrary. \ and u have already been read. |
1082 if (c0_ == '{' && HarmonyUnicode()) { | 1081 if (c0_ == '{') { |
1083 Advance<capture_raw>(); | 1082 Advance<capture_raw>(); |
1084 uc32 cp = ScanUnlimitedLengthHexNumber<capture_raw>(0x10ffff); | 1083 uc32 cp = ScanUnlimitedLengthHexNumber<capture_raw>(0x10ffff); |
1085 if (cp < 0) { | 1084 if (cp < 0) { |
1086 return -1; | 1085 return -1; |
1087 } | 1086 } |
1088 if (c0_ != '}') { | 1087 if (c0_ != '}') { |
1089 return -1; | 1088 return -1; |
1090 } | 1089 } |
1091 Advance<capture_raw>(); | 1090 Advance<capture_raw>(); |
1092 return cp; | 1091 return cp; |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1624 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1623 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1625 } | 1624 } |
1626 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1625 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1627 | 1626 |
1628 backing_store_.AddBlock(bytes); | 1627 backing_store_.AddBlock(bytes); |
1629 return backing_store_.EndSequence().start(); | 1628 return backing_store_.EndSequence().start(); |
1630 } | 1629 } |
1631 | 1630 |
1632 } // namespace internal | 1631 } // namespace internal |
1633 } // namespace v8 | 1632 } // namespace v8 |
OLD | NEW |