Commit 20bf2b7b authored by Joshua Litt's avatar Joshua Litt Committed by Commit Bot

[scanner] Allow escaped keywords to be property names

Bug: v8:9647
Change-Id: Ib6449fadc42130a019788ba3a22e93bfd0de789b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1803514
Commit-Queue: Joshua Litt <joshualitt@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63796}
parent 7c9c1039
......@@ -444,7 +444,8 @@ class V8_EXPORT_PRIVATE Scanner {
#ifdef DEBUG
bool CanAccessLiteral() const {
return token == Token::PRIVATE_NAME || token == Token::ILLEGAL ||
token == Token::UNINITIALIZED || token == Token::REGEXP_LITERAL ||
token == Token::ESCAPED_KEYWORD || token == Token::UNINITIALIZED ||
token == Token::REGEXP_LITERAL ||
IsInRange(token, Token::NUMBER, Token::STRING) ||
Token::IsAnyIdentifier(token) || Token::IsKeyword(token) ||
IsInRange(token, Token::TEMPLATE_SPAN, Token::TEMPLATE_TAIL);
......@@ -586,15 +587,18 @@ class V8_EXPORT_PRIVATE Scanner {
// token as a one-byte literal. E.g. Token::FUNCTION pretends to have a
// literal "function".
Vector<const uint8_t> literal_one_byte_string() const {
DCHECK(current().CanAccessLiteral() || Token::IsKeyword(current().token));
DCHECK(current().CanAccessLiteral() || Token::IsKeyword(current().token) ||
current().token == Token::ESCAPED_KEYWORD);
return current().literal_chars.one_byte_literal();
}
Vector<const uint16_t> literal_two_byte_string() const {
DCHECK(current().CanAccessLiteral() || Token::IsKeyword(current().token));
DCHECK(current().CanAccessLiteral() || Token::IsKeyword(current().token) ||
current().token == Token::ESCAPED_KEYWORD);
return current().literal_chars.two_byte_literal();
}
bool is_literal_one_byte() const {
DCHECK(current().CanAccessLiteral() || Token::IsKeyword(current().token));
DCHECK(current().CanAccessLiteral() || Token::IsKeyword(current().token) ||
current().token == Token::ESCAPED_KEYWORD);
return current().literal_chars.is_one_byte();
}
// Returns the literal string for the next token (the token that
......
......@@ -34,7 +34,8 @@ const int8_t Token::precedence_[2][NUM_TOKENS] = {{TOKEN_LIST(T1, T1)},
#undef T2
#undef T1
#define KT(a, b, c) IsPropertyNameBits::encode(Token::IsAnyIdentifier(a)),
#define KT(a, b, c) \
IsPropertyNameBits::encode(Token::IsAnyIdentifier(a) || a == ESCAPED_KEYWORD),
#define KK(a, b, c) \
IsKeywordBits::encode(true) | IsPropertyNameBits::encode(true),
const uint8_t Token::token_flags[] = {TOKEN_LIST(KT, KK)};
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment