mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-17 07:41:54 +00:00
LibJS: Implement 'new.target'
This adds a new MetaProperty AST node which will be used for 'new.target' and 'import.meta' meta properties. The parser now distinguishes between "in function context" and "in arrow function context" (which is required for this). When encountering TokenType::New we will attempt to parse it as meta property and resort to regular new expression parsing if that fails, much like the parsing of labelled statements.
This commit is contained in:
parent
e07a39c816
commit
39a1c9d827
Notes:
sideshowbarker
2024-07-19 01:34:39 +09:00
Author: https://github.com/linusg
Commit: 39a1c9d827
Pull-request: https://github.com/SerenityOS/serenity/pull/3923
Reviewed-by: https://github.com/awesomekling
6 changed files with 109 additions and 10 deletions
|
@ -105,6 +105,8 @@ LexicalEnvironment* ScriptFunction::create_environment()
|
|||
auto* environment = heap().allocate<LexicalEnvironment>(global_object(), move(variables), m_parent_environment, LexicalEnvironment::EnvironmentRecordType::Function);
|
||||
environment->set_home_object(home_object());
|
||||
environment->set_current_function(*this);
|
||||
if (m_is_arrow_function)
|
||||
environment->set_new_target(m_parent_environment->new_target());
|
||||
return environment;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue