mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +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:
committed by
Andreas Kling
parent
e07a39c816
commit
39a1c9d827
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user