mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-29 15:58:47 +00:00
LibJS: Add ECMAScriptFunctionObject::create_from_function_node() helper
This gives us a shared entry point for every situation where we instantiate a function based on a FunctionNode from the AST.
This commit is contained in:
parent
ef4e7b7945
commit
4209b18b88
Notes:
github-actions[bot]
2025-04-08 16:54:03 +00:00
Author: https://github.com/awesomekling
Commit: 4209b18b88
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4283
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/trflynn89
7 changed files with 95 additions and 27 deletions
|
@ -500,8 +500,12 @@ ThrowCompletionOr<void> SourceTextModule::initialize_environment(VM& vm)
|
|||
FlyString function_name = function_declaration.name();
|
||||
if (function_name == ExportStatement::local_name_for_default)
|
||||
function_name = "default"_fly_string;
|
||||
auto function = ECMAScriptFunctionObject::create(realm(), function_name, function_declaration.source_text(), function_declaration.body(), function_declaration.parameters(), function_declaration.function_length(), function_declaration.local_variables_names(), environment, private_environment, function_declaration.kind(), function_declaration.is_strict_mode(),
|
||||
function_declaration.parsing_insights());
|
||||
auto function = ECMAScriptFunctionObject::create_from_function_node(
|
||||
function_declaration,
|
||||
function_name,
|
||||
realm(),
|
||||
environment,
|
||||
private_environment);
|
||||
|
||||
// 2. Perform ! env.InitializeBinding(dn, fo, normal).
|
||||
MUST(environment->initialize_binding(vm, name, function, Environment::InitializeBindingHint::Normal));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue