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

Side by Side Diff: src/scanner.h

Issue 15300018: Add initial parser support for harmony iteration (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase onto current master Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/rewriter.cc ('k') | src/typing.cc » ('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 // 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 ConvertToUtf16(); 172 ConvertToUtf16();
173 } 173 }
174 ASSERT(code_unit < 0x10000u); 174 ASSERT(code_unit < 0x10000u);
175 *reinterpret_cast<uc16*>(&backing_store_[position_]) = code_unit; 175 *reinterpret_cast<uc16*>(&backing_store_[position_]) = code_unit;
176 position_ += kUC16Size; 176 position_ += kUC16Size;
177 } 177 }
178 178
179 bool is_ascii() { return is_ascii_; } 179 bool is_ascii() { return is_ascii_; }
180 180
181 bool is_contextual_keyword(Vector<const char> keyword) {
182 return is_ascii() && keyword.length() == position_ &&
183 (memcmp(keyword.start(), backing_store_.start(), position_) == 0);
184 }
185
181 Vector<const uc16> utf16_literal() { 186 Vector<const uc16> utf16_literal() {
182 ASSERT(!is_ascii_); 187 ASSERT(!is_ascii_);
183 ASSERT((position_ & 0x1) == 0); 188 ASSERT((position_ & 0x1) == 0);
184 return Vector<const uc16>( 189 return Vector<const uc16>(
185 reinterpret_cast<const uc16*>(backing_store_.start()), 190 reinterpret_cast<const uc16*>(backing_store_.start()),
186 position_ >> 1); 191 position_ >> 1);
187 } 192 }
188 193
189 Vector<const char> ascii_literal() { 194 Vector<const char> ascii_literal() {
190 ASSERT(is_ascii_); 195 ASSERT(is_ascii_);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 return current_.literal_chars->ascii_literal(); 323 return current_.literal_chars->ascii_literal();
319 } 324 }
320 Vector<const uc16> literal_utf16_string() { 325 Vector<const uc16> literal_utf16_string() {
321 ASSERT_NOT_NULL(current_.literal_chars); 326 ASSERT_NOT_NULL(current_.literal_chars);
322 return current_.literal_chars->utf16_literal(); 327 return current_.literal_chars->utf16_literal();
323 } 328 }
324 bool is_literal_ascii() { 329 bool is_literal_ascii() {
325 ASSERT_NOT_NULL(current_.literal_chars); 330 ASSERT_NOT_NULL(current_.literal_chars);
326 return current_.literal_chars->is_ascii(); 331 return current_.literal_chars->is_ascii();
327 } 332 }
333 bool is_literal_contextual_keyword(Vector<const char> keyword) {
334 ASSERT_NOT_NULL(next_.literal_chars);
335 return current_.literal_chars->is_contextual_keyword(keyword);
336 }
328 int literal_length() const { 337 int literal_length() const {
329 ASSERT_NOT_NULL(current_.literal_chars); 338 ASSERT_NOT_NULL(current_.literal_chars);
330 return current_.literal_chars->length(); 339 return current_.literal_chars->length();
331 } 340 }
332 341
333 bool literal_contains_escapes() const { 342 bool literal_contains_escapes() const {
334 Location location = current_.location; 343 Location location = current_.location;
335 int source_length = (location.end_pos - location.beg_pos); 344 int source_length = (location.end_pos - location.beg_pos);
336 if (current_.token == Token::STRING) { 345 if (current_.token == Token::STRING) {
337 // Subtract delimiters. 346 // Subtract delimiters.
(...skipping 16 matching lines...) Expand all
354 return next_.literal_chars->ascii_literal(); 363 return next_.literal_chars->ascii_literal();
355 } 364 }
356 Vector<const uc16> next_literal_utf16_string() { 365 Vector<const uc16> next_literal_utf16_string() {
357 ASSERT_NOT_NULL(next_.literal_chars); 366 ASSERT_NOT_NULL(next_.literal_chars);
358 return next_.literal_chars->utf16_literal(); 367 return next_.literal_chars->utf16_literal();
359 } 368 }
360 bool is_next_literal_ascii() { 369 bool is_next_literal_ascii() {
361 ASSERT_NOT_NULL(next_.literal_chars); 370 ASSERT_NOT_NULL(next_.literal_chars);
362 return next_.literal_chars->is_ascii(); 371 return next_.literal_chars->is_ascii();
363 } 372 }
373 bool is_next_contextual_keyword(Vector<const char> keyword) {
374 ASSERT_NOT_NULL(next_.literal_chars);
375 return next_.literal_chars->is_contextual_keyword(keyword);
376 }
364 int next_literal_length() const { 377 int next_literal_length() const {
365 ASSERT_NOT_NULL(next_.literal_chars); 378 ASSERT_NOT_NULL(next_.literal_chars);
366 return next_.literal_chars->length(); 379 return next_.literal_chars->length();
367 } 380 }
368 381
369 UnicodeCache* unicode_cache() { return unicode_cache_; } 382 UnicodeCache* unicode_cache() { return unicode_cache_; }
370 383
371 static const int kCharacterLookaheadBufferSize = 1; 384 static const int kCharacterLookaheadBufferSize = 1;
372 385
373 // Scans octal escape sequence. Also accepts "\0" decimal escape sequence. 386 // Scans octal escape sequence. Also accepts "\0" decimal escape sequence.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 bool has_multiline_comment_before_next_; 555 bool has_multiline_comment_before_next_;
543 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. 556 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings.
544 bool harmony_scoping_; 557 bool harmony_scoping_;
545 // Whether we scan 'module', 'import', 'export' as keywords. 558 // Whether we scan 'module', 'import', 'export' as keywords.
546 bool harmony_modules_; 559 bool harmony_modules_;
547 }; 560 };
548 561
549 } } // namespace v8::internal 562 } } // namespace v8::internal
550 563
551 #endif // V8_SCANNER_H_ 564 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/rewriter.cc ('k') | src/typing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698