From 245d486ba4f255a85c52579e8654bac7861d8365 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 4 Jan 2022 22:04:22 +0100 Subject: LibJS: Convert PromiseResolvingElementFunction to ThrowCompletionOr --- .../LibJS/Runtime/PromiseResolvingElementFunctions.cpp | 16 ++++++++-------- .../LibJS/Runtime/PromiseResolvingElementFunctions.h | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp index 0860b1802f..aeb205dac3 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp @@ -58,7 +58,7 @@ PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, { } -Value PromiseAllResolveElementFunction::resolve_element() +ThrowCompletionOr PromiseAllResolveElementFunction::resolve_element() { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -73,7 +73,7 @@ Value PromiseAllResolveElementFunction::resolve_element() auto* values_array = Array::create_from(global_object, m_values.values()); // b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »). - return TRY_OR_DISCARD(vm.call(*m_capability.resolve, js_undefined(), values_array)); + return vm.call(*m_capability.resolve, js_undefined(), values_array); } // 11. Return undefined. @@ -90,7 +90,7 @@ PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction { } -Value PromiseAllSettledResolveElementFunction::resolve_element() +ThrowCompletionOr PromiseAllSettledResolveElementFunction::resolve_element() { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -114,7 +114,7 @@ Value PromiseAllSettledResolveElementFunction::resolve_element() auto* values_array = Array::create_from(global_object, m_values.values()); // b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »). - return TRY_OR_DISCARD(vm.call(*m_capability.resolve, js_undefined(), values_array)); + return vm.call(*m_capability.resolve, js_undefined(), values_array); } // 15. Return undefined. @@ -131,7 +131,7 @@ PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(s { } -Value PromiseAllSettledRejectElementFunction::resolve_element() +ThrowCompletionOr PromiseAllSettledRejectElementFunction::resolve_element() { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -155,7 +155,7 @@ Value PromiseAllSettledRejectElementFunction::resolve_element() auto values_array = Array::create_from(global_object, m_values.values()); // b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »). - return TRY_OR_DISCARD(vm.call(*m_capability.resolve, js_undefined(), values_array)); + return vm.call(*m_capability.resolve, js_undefined(), values_array); } // 15. Return undefined. @@ -172,7 +172,7 @@ PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, P { } -Value PromiseAnyRejectElementFunction::resolve_element() +ThrowCompletionOr PromiseAnyRejectElementFunction::resolve_element() { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -191,7 +191,7 @@ Value PromiseAnyRejectElementFunction::resolve_element() MUST(error->define_property_or_throw(vm.names.errors, { .value = errors_array, .writable = true, .enumerable = false, .configurable = true })); // c. Return ? Call(promiseCapability.[[Reject]], undefined, « error »). - return TRY_OR_DISCARD(vm.call(*m_capability.reject, js_undefined(), error)); + return vm.call(*m_capability.reject, js_undefined(), error); } return js_undefined(); diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h index 0c56aeae0a..81197dfb07 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h @@ -51,7 +51,7 @@ public: protected: explicit PromiseResolvingElementFunction(size_t, PromiseValueList&, PromiseCapability, RemainingElements&, Object& prototype); - virtual Value resolve_element() = 0; + virtual ThrowCompletionOr resolve_element() = 0; size_t m_index { 0 }; PromiseValueList& m_values; @@ -75,7 +75,7 @@ public: virtual ~PromiseAllResolveElementFunction() override = default; private: - virtual Value resolve_element() override; + virtual ThrowCompletionOr resolve_element() override; }; // 27.2.4.2.2 Promise.allSettled Resolve Element Functions, https://tc39.es/ecma262/#sec-promise.allsettled-resolve-element-functions @@ -89,7 +89,7 @@ public: virtual ~PromiseAllSettledResolveElementFunction() override = default; private: - virtual Value resolve_element() override; + virtual ThrowCompletionOr resolve_element() override; }; // 27.2.4.2.3 Promise.allSettled Reject Element Functions, https://tc39.es/ecma262/#sec-promise.allsettled-reject-element-functions @@ -103,7 +103,7 @@ public: virtual ~PromiseAllSettledRejectElementFunction() override = default; private: - virtual Value resolve_element() override; + virtual ThrowCompletionOr resolve_element() override; }; // 27.2.4.3.2 Promise.any Reject Element Functions, https://tc39.es/ecma262/#sec-promise.any-reject-element-functions @@ -117,7 +117,7 @@ public: virtual ~PromiseAnyRejectElementFunction() override = default; private: - virtual Value resolve_element() override; + virtual ThrowCompletionOr resolve_element() override; }; } -- cgit v1.2.3