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

Unified Diff: src/scanner.cc

Issue 1297253002: [es6] Handle unicode escapes before checking for keywords (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Skip mozilla test Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scanner.h ('k') | test/mozilla/mozilla.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.cc
diff --git a/src/scanner.cc b/src/scanner.cc
index c6c0a8d6a23448b7be244224ec48bc5b37b16cee..0a3d69dea97ea28c3903b9e4f7aec2241fb5dc41 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -1266,7 +1266,7 @@ Token::Value Scanner::ScanIdentifierOrKeyword() {
return Token::ILLEGAL;
}
AddLiteralChar(c);
- return ScanIdentifierSuffix(&literal);
+ return ScanIdentifierOrKeywordSuffix(&literal);
} else {
uc32 first_char = c0_;
Advance();
@@ -1281,8 +1281,8 @@ Token::Value Scanner::ScanIdentifierOrKeyword() {
AddLiteralChar(next_char);
continue;
}
- // Fallthrough if no longer able to complete keyword.
- return ScanIdentifierSuffix(&literal);
+ // Fallthrough if a unicode escape is found.
+ return ScanIdentifierOrKeywordSuffix(&literal);
}
literal.Complete();
@@ -1295,7 +1295,7 @@ Token::Value Scanner::ScanIdentifierOrKeyword() {
}
-Token::Value Scanner::ScanIdentifierSuffix(LiteralScope* literal) {
+Token::Value Scanner::ScanIdentifierOrKeywordSuffix(LiteralScope* literal) {
// Scan the rest of the identifier characters.
while (c0_ >= 0 && unicode_cache_->IsIdentifierPart(c0_)) {
if (c0_ == '\\') {
@@ -1314,6 +1314,11 @@ Token::Value Scanner::ScanIdentifierSuffix(LiteralScope* literal) {
}
literal->Complete();
+ if (next_.literal_chars->is_one_byte()) {
+ Vector<const uint8_t> chars = next_.literal_chars->one_byte_literal();
+ return KeywordOrIdentifierToken(chars.start(), chars.length());
+ }
+
return Token::IDENTIFIER;
}
« no previous file with comments | « src/scanner.h ('k') | test/mozilla/mozilla.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698