mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 19:05:08 +00:00
LibJS/Bytecode: Move NewFunction impl into CommonImplementations
This commit is contained in:
parent
a913ac5799
commit
9f61cda27e
3 changed files with 23 additions and 14 deletions
|
@ -264,4 +264,25 @@ ThrowCompletionOr<void> set_variable(
|
|||
return {};
|
||||
}
|
||||
|
||||
Value new_function(VM& vm, FunctionExpression const& function_node, Optional<IdentifierTableIndex> const& lhs_name, Optional<Register> const& home_object)
|
||||
{
|
||||
Value value;
|
||||
|
||||
if (!function_node.has_name()) {
|
||||
DeprecatedFlyString name = {};
|
||||
if (lhs_name.has_value())
|
||||
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.might_need_arguments_object(), function_node.contains_direct_call_to_eval(), function_node.is_arrow_function());
|
||||
}
|
||||
|
||||
if (home_object.has_value()) {
|
||||
auto home_object_value = vm.bytecode_interpreter().reg(home_object.value());
|
||||
static_cast<ECMAScriptFunctionObject&>(value.as_function()).set_home_object(&home_object_value.as_object());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue