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:
Andreas Kling 2025-04-07 21:08:55 +02:00 committed by Andreas Kling
parent ef4e7b7945
commit 4209b18b88
Notes: github-actions[bot] 2025-04-08 16:54:03 +00:00
7 changed files with 95 additions and 27 deletions

View file

@ -1305,8 +1305,12 @@ inline Value new_function(VM& vm, FunctionNode const& function_node, Optional<Id
name = vm.bytecode_interpreter().current_executable().get_identifier(lhs_name.value());
value = function_node.instantiate_ordinary_function_expression(vm, name);
} else {
value = ECMAScriptFunctionObject::create(*vm.current_realm(), function_node.name(), function_node.source_text(), function_node.body(), function_node.parameters(), function_node.function_length(), function_node.local_variables_names(), vm.lexical_environment(), vm.running_execution_context().private_environment, function_node.kind(), function_node.is_strict_mode(),
function_node.parsing_insights(), function_node.is_arrow_function());
value = ECMAScriptFunctionObject::create_from_function_node(
function_node,
function_node.name(),
*vm.current_realm(),
vm.lexical_environment(),
vm.running_execution_context().private_environment);
}
if (home_object.has_value()) {