1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 21:25:07 +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:
Linus Groh 2020-11-02 21:27:42 +00:00 committed by Andreas Kling
parent e07a39c816
commit 39a1c9d827
6 changed files with 109 additions and 10 deletions

View file

@ -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;
}