mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
LibJS: Remove unused prototype parameter for NativeFunction::create()
This commit is contained in:
parent
9599742fea
commit
80fe75352e
3 changed files with 6 additions and 7 deletions
|
@ -33,7 +33,7 @@ void NativeFunction::visit_edges(Cell::Visitor& visitor)
|
|||
|
||||
// 10.3.3 CreateBuiltinFunction ( behaviour, length, name, additionalInternalSlotsList [ , realm [ , prototype [ , prefix ] ] ] ), https://tc39.es/ecma262/#sec-createbuiltinfunction
|
||||
// NOTE: This doesn't consider additionalInternalSlotsList, which is rarely used, and can either be implemented using only the `function` lambda, or needs a NativeFunction subclass.
|
||||
GC::Ref<NativeFunction> NativeFunction::create(Realm& allocating_realm, Function<ThrowCompletionOr<Value>(VM&)> behaviour, i32 length, PropertyKey const& name, Optional<Realm*> realm, Optional<Object*> prototype, Optional<StringView> const& prefix)
|
||||
GC::Ref<NativeFunction> NativeFunction::create(Realm& allocating_realm, Function<ThrowCompletionOr<Value>(VM&)> behaviour, i32 length, PropertyKey const& name, Optional<Realm*> realm, Optional<StringView> const& prefix)
|
||||
{
|
||||
auto& vm = allocating_realm.vm();
|
||||
|
||||
|
@ -42,8 +42,7 @@ GC::Ref<NativeFunction> NativeFunction::create(Realm& allocating_realm, Function
|
|||
realm = vm.current_realm();
|
||||
|
||||
// 2. If prototype is not present, set prototype to realm.[[Intrinsics]].[[%Function.prototype%]].
|
||||
if (!prototype.has_value())
|
||||
prototype = realm.value()->intrinsics().function_prototype();
|
||||
auto prototype = realm.value()->intrinsics().function_prototype();
|
||||
|
||||
// 3. Let internalSlotsList be a List containing the names of all the internal slots that 10.3 requires for the built-in function object that is about to be created.
|
||||
// 4. Append to internalSlotsList the elements of additionalInternalSlotsList.
|
||||
|
@ -53,7 +52,7 @@ GC::Ref<NativeFunction> NativeFunction::create(Realm& allocating_realm, Function
|
|||
// 7. Set func.[[Extensible]] to true.
|
||||
// 8. Set func.[[Realm]] to realm.
|
||||
// 9. Set func.[[InitialName]] to null.
|
||||
auto function = allocating_realm.create<NativeFunction>(GC::create_function(vm.heap(), move(behaviour)), prototype.value(), *realm.value());
|
||||
auto function = allocating_realm.create<NativeFunction>(GC::create_function(vm.heap(), move(behaviour)), prototype, *realm.value());
|
||||
|
||||
// 10. Perform SetFunctionLength(func, length).
|
||||
function->set_function_length(length);
|
||||
|
|
|
@ -21,7 +21,7 @@ class NativeFunction : public FunctionObject {
|
|||
GC_DECLARE_ALLOCATOR(NativeFunction);
|
||||
|
||||
public:
|
||||
static GC::Ref<NativeFunction> create(Realm&, ESCAPING Function<ThrowCompletionOr<Value>(VM&)> behaviour, i32 length, PropertyKey const& name = FlyString {}, Optional<Realm*> = {}, Optional<Object*> prototype = {}, Optional<StringView> const& prefix = {});
|
||||
static GC::Ref<NativeFunction> create(Realm&, ESCAPING Function<ThrowCompletionOr<Value>(VM&)> behaviour, i32 length, PropertyKey const& name = FlyString {}, Optional<Realm*> = {}, Optional<StringView> const& prefix = {});
|
||||
static GC::Ref<NativeFunction> create(Realm&, FlyString const& name, ESCAPING Function<ThrowCompletionOr<Value>(VM&)>);
|
||||
|
||||
virtual ~NativeFunction() override = default;
|
||||
|
|
|
@ -1266,10 +1266,10 @@ void Object::define_native_accessor(Realm& realm, PropertyKey const& property_ke
|
|||
{
|
||||
FunctionObject* getter_function = nullptr;
|
||||
if (getter)
|
||||
getter_function = NativeFunction::create(realm, move(getter), 0, property_key, &realm, {}, "get"sv);
|
||||
getter_function = NativeFunction::create(realm, move(getter), 0, property_key, &realm, "get"sv);
|
||||
FunctionObject* setter_function = nullptr;
|
||||
if (setter)
|
||||
setter_function = NativeFunction::create(realm, move(setter), 1, property_key, &realm, {}, "set"sv);
|
||||
setter_function = NativeFunction::create(realm, move(setter), 1, property_key, &realm, "set"sv);
|
||||
return define_direct_accessor(property_key, getter_function, setter_function, attribute);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue