mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 08:25:07 +00:00
LibJS: Convert BoundFunction::create() to NonnullGCPtr
This commit is contained in:
parent
b48fa8756f
commit
efbd8ee072
3 changed files with 4 additions and 4 deletions
|
@ -12,7 +12,7 @@
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
// 10.4.1.3 BoundFunctionCreate ( targetFunction, boundThis, boundArgs ), https://tc39.es/ecma262/#sec-boundfunctioncreate
|
// 10.4.1.3 BoundFunctionCreate ( targetFunction, boundThis, boundArgs ), https://tc39.es/ecma262/#sec-boundfunctioncreate
|
||||||
ThrowCompletionOr<BoundFunction*> BoundFunction::create(Realm& realm, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments)
|
ThrowCompletionOr<NonnullGCPtr<BoundFunction>> BoundFunction::create(Realm& realm, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments)
|
||||||
{
|
{
|
||||||
// 1. Let proto be ? targetFunction.[[GetPrototypeOf]]().
|
// 1. Let proto be ? targetFunction.[[GetPrototypeOf]]().
|
||||||
auto* prototype = TRY(target_function.internal_get_prototype_of());
|
auto* prototype = TRY(target_function.internal_get_prototype_of());
|
||||||
|
@ -29,7 +29,7 @@ ThrowCompletionOr<BoundFunction*> BoundFunction::create(Realm& realm, FunctionOb
|
||||||
auto* object = realm.heap().allocate<BoundFunction>(realm, realm, target_function, bound_this, move(bound_arguments), prototype);
|
auto* object = realm.heap().allocate<BoundFunction>(realm, realm, target_function, bound_this, move(bound_arguments), prototype);
|
||||||
|
|
||||||
// 10. Return obj.
|
// 10. Return obj.
|
||||||
return object;
|
return NonnullGCPtr { *object };
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function, Value bound_this, Vector<Value> bound_arguments, Object* prototype)
|
BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function, Value bound_this, Vector<Value> bound_arguments, Object* prototype)
|
||||||
|
|
|
@ -15,7 +15,7 @@ class BoundFunction final : public FunctionObject {
|
||||||
JS_OBJECT(BoundFunction, FunctionObject);
|
JS_OBJECT(BoundFunction, FunctionObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ThrowCompletionOr<BoundFunction*> create(Realm&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments);
|
static ThrowCompletionOr<NonnullGCPtr<BoundFunction>> create(Realm&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments);
|
||||||
|
|
||||||
virtual ~BoundFunction() override = default;
|
virtual ~BoundFunction() override = default;
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::bind)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Let F be ? BoundFunctionCreate(Target, thisArg, args).
|
// 3. Let F be ? BoundFunctionCreate(Target, thisArg, args).
|
||||||
auto* function = TRY(BoundFunction::create(realm, target, this_argument, move(arguments)));
|
auto function = TRY(BoundFunction::create(realm, target, this_argument, move(arguments)));
|
||||||
|
|
||||||
// 4. Let argCount be the number of elements in args.
|
// 4. Let argCount be the number of elements in args.
|
||||||
auto arg_count = vm.argument_count() > 0 ? vm.argument_count() - 1 : 0;
|
auto arg_count = vm.argument_count() > 0 ? vm.argument_count() - 1 : 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue