mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
LibJS: Take SharedFunctionInstanceData in NativeJavaScriptBackedFunction
Change NativeJavaScriptBackedFunction::create() to accept an already-created GC::Ref<SharedFunctionInstanceData> instead of a FunctionNode const&, removing another point of AST-runtime coupling.
This commit is contained in:
parent
7e85bb251f
commit
ef992b2010
Notes:
github-actions[bot]
2026-02-11 22:58:51 +00:00
Author: https://github.com/awesomekling
Commit: ef992b2010
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7896
2 changed files with 2 additions and 14 deletions
|
|
@ -18,7 +18,7 @@ namespace JS {
|
|||
GC_DEFINE_ALLOCATOR(NativeJavaScriptBackedFunction);
|
||||
|
||||
// 10.3.3 CreateBuiltinFunction ( behaviour, length, name, additionalInternalSlotsList [ , realm [ , prototype [ , prefix ] ] ] ), https://tc39.es/ecma262/#sec-createbuiltinfunction
|
||||
GC::Ref<NativeJavaScriptBackedFunction> NativeJavaScriptBackedFunction::create(Realm& realm, FunctionNode const& function_node, PropertyKey const& name, i32 length)
|
||||
GC::Ref<NativeJavaScriptBackedFunction> NativeJavaScriptBackedFunction::create(Realm& realm, GC::Ref<SharedFunctionInstanceData> shared_data, PropertyKey const& name, i32 length)
|
||||
{
|
||||
// 1. If realm is not present, set realm to the current Realm Record.
|
||||
// 2. If prototype is not present, set prototype to realm.[[Intrinsics]].[[%Function.prototype%]].
|
||||
|
|
@ -32,18 +32,6 @@ GC::Ref<NativeJavaScriptBackedFunction> NativeJavaScriptBackedFunction::create(R
|
|||
// 7. Set func.[[Extensible]] to true.
|
||||
// 8. Set func.[[Realm]] to realm.
|
||||
// 9. Set func.[[InitialName]] to null.
|
||||
auto shared_data = realm.heap().allocate<SharedFunctionInstanceData>(realm.vm(),
|
||||
function_node.kind(),
|
||||
function_node.name(),
|
||||
function_node.function_length(),
|
||||
function_node.parameters(),
|
||||
*function_node.body_ptr(),
|
||||
function_node.source_text(),
|
||||
function_node.is_strict_mode(),
|
||||
function_node.is_arrow_function(),
|
||||
function_node.parsing_insights(),
|
||||
function_node.local_variables_names());
|
||||
|
||||
auto function = realm.create<NativeJavaScriptBackedFunction>(shared_data, *prototype);
|
||||
|
||||
function->unsafe_set_shape(realm.intrinsics().native_function_shape());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue