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

Side by Side Diff: src/parsing/scanner.cc

Issue 2329703002: Private fields
Patch Set: some comments Created 4 years, 3 months 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/parsing/preparser.cc ('k') | src/parsing/token.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 // Features shared by parsing and pre-parsing scanners. 5 // Features shared by parsing and pre-parsing scanners.
6 6
7 #include "src/parsing/scanner.h" 7 #include "src/parsing/scanner.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 return x; 102 return x;
103 } 103 }
104 104
105 105
106 // Ensure that tokens can be stored in a byte. 106 // Ensure that tokens can be stored in a byte.
107 STATIC_ASSERT(Token::NUM_TOKENS <= 0x100); 107 STATIC_ASSERT(Token::NUM_TOKENS <= 0x100);
108 108
109 // Table of one-character tokens, by character (0x00..0x7f only). 109 // Table of one-character tokens, by character (0x00..0x7f only).
110 // clang-format off
110 static const byte one_char_tokens[] = { 111 static const byte one_char_tokens[] = {
111 Token::ILLEGAL, 112 Token::ILLEGAL,
112 Token::ILLEGAL, 113 Token::ILLEGAL,
113 Token::ILLEGAL, 114 Token::ILLEGAL,
114 Token::ILLEGAL, 115 Token::ILLEGAL,
115 Token::ILLEGAL, 116 Token::ILLEGAL,
116 Token::ILLEGAL, 117 Token::ILLEGAL,
117 Token::ILLEGAL, 118 Token::ILLEGAL,
118 Token::ILLEGAL, 119 Token::ILLEGAL,
119 Token::ILLEGAL, 120 Token::ILLEGAL,
(...skipping 16 matching lines...) Expand all
136 Token::ILLEGAL, 137 Token::ILLEGAL,
137 Token::ILLEGAL, 138 Token::ILLEGAL,
138 Token::ILLEGAL, 139 Token::ILLEGAL,
139 Token::ILLEGAL, 140 Token::ILLEGAL,
140 Token::ILLEGAL, 141 Token::ILLEGAL,
141 Token::ILLEGAL, 142 Token::ILLEGAL,
142 Token::ILLEGAL, 143 Token::ILLEGAL,
143 Token::ILLEGAL, 144 Token::ILLEGAL,
144 Token::ILLEGAL, 145 Token::ILLEGAL,
145 Token::ILLEGAL, 146 Token::ILLEGAL,
147 Token::HASH, // 0x23
146 Token::ILLEGAL, 148 Token::ILLEGAL,
147 Token::ILLEGAL, 149 Token::ILLEGAL,
148 Token::ILLEGAL, 150 Token::ILLEGAL,
149 Token::ILLEGAL,
150 Token::ILLEGAL, 151 Token::ILLEGAL,
151 Token::LPAREN, // 0x28 152 Token::LPAREN, // 0x28
152 Token::RPAREN, // 0x29 153 Token::RPAREN, // 0x29
153 Token::ILLEGAL, 154 Token::ILLEGAL,
154 Token::ILLEGAL, 155 Token::ILLEGAL,
155 Token::COMMA, // 0x2c 156 Token::COMMA, // 0x2c
156 Token::ILLEGAL, 157 Token::ILLEGAL,
157 Token::ILLEGAL, 158 Token::ILLEGAL,
158 Token::ILLEGAL, 159 Token::ILLEGAL,
159 Token::ILLEGAL, 160 Token::ILLEGAL,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 Token::ILLEGAL, 231 Token::ILLEGAL,
231 Token::ILLEGAL, 232 Token::ILLEGAL,
232 Token::ILLEGAL, 233 Token::ILLEGAL,
233 Token::ILLEGAL, 234 Token::ILLEGAL,
234 Token::LBRACE, // 0x7b 235 Token::LBRACE, // 0x7b
235 Token::ILLEGAL, 236 Token::ILLEGAL,
236 Token::RBRACE, // 0x7d 237 Token::RBRACE, // 0x7d
237 Token::BIT_NOT, // 0x7e 238 Token::BIT_NOT, // 0x7e
238 Token::ILLEGAL 239 Token::ILLEGAL
239 }; 240 };
240 241 // clang-format on
241 242
242 Token::Value Scanner::Next() { 243 Token::Value Scanner::Next() {
243 if (next_.token == Token::EOS) { 244 if (next_.token == Token::EOS) {
244 next_.location.beg_pos = current_.location.beg_pos; 245 next_.location.beg_pos = current_.location.beg_pos;
245 next_.location.end_pos = current_.location.end_pos; 246 next_.location.end_pos = current_.location.end_pos;
246 } 247 }
247 current_ = next_; 248 current_ = next_;
248 if (V8_UNLIKELY(next_next_.token != Token::UNINITIALIZED)) { 249 if (V8_UNLIKELY(next_next_.token != Token::UNINITIALIZED)) {
249 next_ = next_next_; 250 next_ = next_next_;
250 next_next_.token = Token::UNINITIALIZED; 251 next_next_.token = Token::UNINITIALIZED;
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 break; 705 break;
705 706
706 case '?': 707 case '?':
707 token = Select(Token::CONDITIONAL); 708 token = Select(Token::CONDITIONAL);
708 break; 709 break;
709 710
710 case '~': 711 case '~':
711 token = Select(Token::BIT_NOT); 712 token = Select(Token::BIT_NOT);
712 break; 713 break;
713 714
715 case '#':
716 token = Select(Token::HASH);
717 break;
718
714 case '`': 719 case '`':
715 token = ScanTemplateStart(); 720 token = ScanTemplateStart();
716 break; 721 break;
717 722
718 default: 723 default:
719 if (c0_ < 0) { 724 if (c0_ < 0) {
720 token = Token::EOS; 725 token = Token::EOS;
721 } else if (unicode_cache_->IsIdentifierStart(c0_)) { 726 } else if (unicode_cache_->IsIdentifierStart(c0_)) {
722 token = ScanIdentifierOrKeyword(); 727 token = ScanIdentifierOrKeyword();
723 } else if (IsDecimalDigit(c0_)) { 728 } else if (IsDecimalDigit(c0_)) {
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 to->token = from->token; 1636 to->token = from->token;
1632 to->location = from->location; 1637 to->location = from->location;
1633 to->literal_chars->CopyFrom(from->literal_chars); 1638 to->literal_chars->CopyFrom(from->literal_chars);
1634 to->raw_literal_chars->CopyFrom(from->raw_literal_chars); 1639 to->raw_literal_chars->CopyFrom(from->raw_literal_chars);
1635 } 1640 }
1636 1641
1637 1642
1638 1643
1639 } // namespace internal 1644 } // namespace internal
1640 } // namespace v8 1645 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.cc ('k') | src/parsing/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698