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

Unified Diff: src/scanner.h

Issue 1429983002: [es6] early error when Identifier is an escaped reserved word (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser.h ('k') | src/scanner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.h
diff --git a/src/scanner.h b/src/scanner.h
index 6d0d4dc8eddb52022f67cb1cdb01273695666373..ab5693ee5a5c3fc889ec2cec80561fa61c29ae9e 100644
--- a/src/scanner.h
+++ b/src/scanner.h
@@ -373,13 +373,10 @@ class Scanner {
Location peek_location() const { return next_.location; }
bool literal_contains_escapes() const {
- Location location = current_.location;
- int source_length = (location.end_pos - location.beg_pos);
- if (current_.token == Token::STRING) {
- // Subtract delimiters.
- source_length -= 2;
- }
- return current_.literal_chars->length() != source_length;
+ return LiteralContainsEscapes(current_);
+ }
+ bool next_literal_contains_escapes() const {
+ return LiteralContainsEscapes(next_);
}
bool is_literal_contextual_keyword(Vector<const char> keyword) {
DCHECK_NOT_NULL(current_.literal_chars);
@@ -665,7 +662,7 @@ class Scanner {
void ScanDecimalDigits();
Token::Value ScanNumber(bool seen_period);
Token::Value ScanIdentifierOrKeyword();
- Token::Value ScanIdentifierSuffix(LiteralScope* literal);
+ Token::Value ScanIdentifierSuffix(LiteralScope* literal, bool escaped);
Token::Value ScanString();
@@ -689,6 +686,16 @@ class Scanner {
return static_cast<int>(source_->pos()) - kCharacterLookaheadBufferSize;
}
+ static bool LiteralContainsEscapes(const TokenDesc& token) {
+ Location location = token.location;
+ int source_length = (location.end_pos - location.beg_pos);
+ if (token.token == Token::STRING) {
+ // Subtract delimiters.
+ source_length -= 2;
+ }
+ return token.literal_chars->length() != source_length;
+ }
+
UnicodeCache* unicode_cache_;
// Buffers collecting literal strings, numbers, etc.
« no previous file with comments | « src/preparser.h ('k') | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698