mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 08:27:35 +00:00
LibJS: Make intrinsics getters return NonnullGCPtr
Some of these are allocated upon initialization of the intrinsics, and some lazily, but in neither case the getters actually return a nullptr. This saves us a whole bunch of pointer dereferences (as NonnullGCPtr has an `operator T&()`), and also has the interesting side effect of forcing us to explicitly use the FunctionObject& overload of call(), as passing a NonnullGCPtr is ambigous - it could implicitly be turned into a Value _or_ a FunctionObject& (so we have to dereference manually).
This commit is contained in:
parent
ed9e2366da
commit
b84f8fb55b
182 changed files with 564 additions and 567 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@ JS::NonnullGCPtr<Promise> create_promise(JS::Realm& realm)
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// 1. Let constructor be realm.[[Intrinsics]].[[%Promise%]].
|
||||
auto* constructor = realm.intrinsics().promise_constructor();
|
||||
auto constructor = realm.intrinsics().promise_constructor();
|
||||
|
||||
// Return ? NewPromiseCapability(constructor).
|
||||
// NOTE: When called with %Promise%, NewPromiseCapability can't throw.
|
||||
|
@ -37,7 +37,7 @@ JS::NonnullGCPtr<Promise> create_resolved_promise(JS::Realm& realm, JS::Value va
|
|||
// 1. Let value be the result of converting x to an ECMAScript value.
|
||||
|
||||
// 2. Let constructor be realm.[[Intrinsics]].[[%Promise%]].
|
||||
auto* constructor = realm.intrinsics().promise_constructor();
|
||||
auto constructor = realm.intrinsics().promise_constructor();
|
||||
|
||||
// 3. Let promiseCapability be ? NewPromiseCapability(constructor).
|
||||
// NOTE: When called with %Promise%, NewPromiseCapability can't throw.
|
||||
|
@ -56,7 +56,7 @@ JS::NonnullGCPtr<Promise> create_rejected_promise(JS::Realm& realm, JS::Value re
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// 1. Let constructor be realm.[[Intrinsics]].[[%Promise%]].
|
||||
auto* constructor = realm.intrinsics().promise_constructor();
|
||||
auto constructor = realm.intrinsics().promise_constructor();
|
||||
|
||||
// 2. Let promiseCapability be ? NewPromiseCapability(constructor).
|
||||
// NOTE: When called with %Promise%, NewPromiseCapability can't throw.
|
||||
|
@ -132,7 +132,7 @@ JS::NonnullGCPtr<JS::Promise> react_to_promise(Promise const& promise, Optional<
|
|||
auto on_rejected = JS::NativeFunction::create(realm, move(on_rejected_steps), 1, "");
|
||||
|
||||
// 5. Let constructor be promise.[[Promise]].[[Realm]].[[Intrinsics]].[[%Promise%]].
|
||||
auto* constructor = realm.intrinsics().promise_constructor();
|
||||
auto constructor = realm.intrinsics().promise_constructor();
|
||||
|
||||
// 6. Let newCapability be ? NewPromiseCapability(constructor).
|
||||
// NOTE: When called with %Promise%, NewPromiseCapability can't throw.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue