mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibJS: Allow reserved words as keys in object expressions.
This commit is contained in:
parent
0345fdcb77
commit
bf5b251684
Notes:
sideshowbarker
2024-07-19 07:29:33 +09:00
Author: https://github.com/sunverwerth
Commit: bf5b251684
Pull-request: https://github.com/SerenityOS/serenity/pull/1849
Issue: https://github.com/SerenityOS/serenity/issues/1768
5 changed files with 61 additions and 3 deletions
|
@ -129,4 +129,44 @@ bool Token::bool_value() const
|
|||
return m_value == "true";
|
||||
}
|
||||
|
||||
bool Token::is_identifier_name() const
|
||||
{
|
||||
// IdentifierNames are Identifiers + ReservedWords
|
||||
// The standard defines this reversed: Identifiers are IdentifierNames except reserved words
|
||||
// https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
|
||||
return m_type == TokenType::Identifier
|
||||
|| m_type == TokenType::Await
|
||||
|| m_type == TokenType::BoolLiteral
|
||||
|| m_type == TokenType::Break
|
||||
|| m_type == TokenType::Case
|
||||
|| m_type == TokenType::Catch
|
||||
|| m_type == TokenType::Class
|
||||
|| m_type == TokenType::Const
|
||||
|| m_type == TokenType::Continue
|
||||
|| m_type == TokenType::Default
|
||||
|| m_type == TokenType::Delete
|
||||
|| m_type == TokenType::Do
|
||||
|| m_type == TokenType::Else
|
||||
|| m_type == TokenType::Finally
|
||||
|| m_type == TokenType::For
|
||||
|| m_type == TokenType::Function
|
||||
|| m_type == TokenType::If
|
||||
|| m_type == TokenType::In
|
||||
|| m_type == TokenType::Instanceof
|
||||
|| m_type == TokenType::Interface
|
||||
|| m_type == TokenType::Let
|
||||
|| m_type == TokenType::New
|
||||
|| m_type == TokenType::NullLiteral
|
||||
|| m_type == TokenType::Return
|
||||
|| m_type == TokenType::Switch
|
||||
|| m_type == TokenType::This
|
||||
|| m_type == TokenType::Throw
|
||||
|| m_type == TokenType::Try
|
||||
|| m_type == TokenType::Typeof
|
||||
|| m_type == TokenType::Var
|
||||
|| m_type == TokenType::Void
|
||||
|| m_type == TokenType::While
|
||||
|| m_type == TokenType::Yield;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue