LibJS: Convert PromiseResolvingFunction::create() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-13 20:49:50 +00:00
parent d3cb7cd584
commit 6e386acb11
Notes: sideshowbarker 2024-07-18 04:38:32 +09:00
3 changed files with 5 additions and 5 deletions

View file

@ -71,7 +71,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
// 6. Set resolve.[[AlreadyResolved]] to alreadyResolved.
// 27.2.1.3.2 Promise Resolve Functions, https://tc39.es/ecma262/#sec-promise-resolve-functions
auto* resolve_function = PromiseResolvingFunction::create(realm, *this, *already_resolved, [](auto& vm, auto& promise, auto& already_resolved) {
auto resolve_function = PromiseResolvingFunction::create(realm, *this, *already_resolved, [](auto& vm, auto& promise, auto& already_resolved) {
dbgln_if(PROMISE_DEBUG, "[Promise @ {} / PromiseResolvingFunction]: Resolve function was called", &promise);
auto& realm = *vm.current_realm();
@ -166,7 +166,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
// 11. Set reject.[[AlreadyResolved]] to alreadyResolved.
// 27.2.1.3.1 Promise Reject Functions, https://tc39.es/ecma262/#sec-promise-reject-functions
auto* reject_function = PromiseResolvingFunction::create(realm, *this, *already_resolved, [](auto& vm, auto& promise, auto& already_resolved) {
auto reject_function = PromiseResolvingFunction::create(realm, *this, *already_resolved, [](auto& vm, auto& promise, auto& already_resolved) {
dbgln_if(PROMISE_DEBUG, "[Promise @ {} / PromiseResolvingFunction]: Reject function was called", &promise);
auto reason = vm.argument(0);

View file

@ -11,9 +11,9 @@
namespace JS {
PromiseResolvingFunction* PromiseResolvingFunction::create(Realm& realm, Promise& promise, AlreadyResolved& already_resolved, FunctionType function)
NonnullGCPtr<PromiseResolvingFunction> PromiseResolvingFunction::create(Realm& realm, Promise& promise, AlreadyResolved& already_resolved, FunctionType function)
{
return realm.heap().allocate<PromiseResolvingFunction>(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype());
return *realm.heap().allocate<PromiseResolvingFunction>(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype());
}
PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype)

View file

@ -28,7 +28,7 @@ class PromiseResolvingFunction final : public NativeFunction {
public:
using FunctionType = Function<ThrowCompletionOr<Value>(VM&, Promise&, AlreadyResolved&)>;
static PromiseResolvingFunction* create(Realm&, Promise&, AlreadyResolved&, FunctionType);
static NonnullGCPtr<PromiseResolvingFunction> create(Realm&, Promise&, AlreadyResolved&, FunctionType);
virtual void initialize(Realm&) override;
virtual ~PromiseResolvingFunction() override = default;