mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:47:35 +00:00
LibJS: Move the TRY_OR_REJECT macro to PromiseReaction
Also fixes that we ignored the result of the Call which we shouldn't according to the spec.
This commit is contained in:
parent
7fd38eac98
commit
0535c1abbd
2 changed files with 20 additions and 20 deletions
|
@ -38,26 +38,6 @@ static ThrowCompletionOr<Value> get_promise_resolve(GlobalObject& global_object,
|
||||||
return promise_resolve;
|
return promise_resolve;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 27.2.1.1.1 IfAbruptRejectPromise ( value, capability ), https://tc39.es/ecma262/#sec-ifabruptrejectpromise
|
|
||||||
#define TRY_OR_REJECT(vm, capability, expression) \
|
|
||||||
({ \
|
|
||||||
auto _temporary_result = (expression); \
|
|
||||||
/* 1. If value is an abrupt completion, then */ \
|
|
||||||
if (_temporary_result.is_error()) { \
|
|
||||||
vm.clear_exception(); \
|
|
||||||
vm.stop_unwind(); \
|
|
||||||
\
|
|
||||||
/* a. Perform ? Call(capability.[[Reject]], undefined, « value.[[Value]] »). */ \
|
|
||||||
(void)vm.call(*capability.reject, js_undefined(), _temporary_result.release_error().value()); \
|
|
||||||
\
|
|
||||||
/* b. Return capability.[[Promise]]. */ \
|
|
||||||
return capability.promise; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
/* 2. Else if value is a Completion Record, set value to value.[[Value]]. */ \
|
|
||||||
_temporary_result.release_value(); \
|
|
||||||
})
|
|
||||||
|
|
||||||
static bool iterator_record_is_complete(GlobalObject& global_object, Object& iterator_record)
|
static bool iterator_record_is_complete(GlobalObject& global_object, Object& iterator_record)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
|
@ -19,6 +19,26 @@ struct PromiseCapability {
|
||||||
FunctionObject* reject { nullptr };
|
FunctionObject* reject { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 27.2.1.1.1 IfAbruptRejectPromise ( value, capability ), https://tc39.es/ecma262/#sec-ifabruptrejectpromise
|
||||||
|
#define TRY_OR_REJECT(vm, capability, expression) \
|
||||||
|
({ \
|
||||||
|
auto _temporary_try_or_reject_result = (expression); \
|
||||||
|
/* 1. If value is an abrupt completion, then */ \
|
||||||
|
if (_temporary_try_or_reject_result.is_error()) { \
|
||||||
|
vm.clear_exception(); \
|
||||||
|
vm.stop_unwind(); \
|
||||||
|
\
|
||||||
|
/* a. Perform ? Call(capability.[[Reject]], undefined, « value.[[Value]] »). */ \
|
||||||
|
TRY(vm.call(*capability.reject, js_undefined(), _temporary_try_or_reject_result.release_error().value())); \
|
||||||
|
\
|
||||||
|
/* b. Return capability.[[Promise]]. */ \
|
||||||
|
return capability.promise; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
/* 2. Else if value is a Completion Record, set value to value.[[Value]]. */ \
|
||||||
|
_temporary_try_or_reject_result.release_value(); \
|
||||||
|
})
|
||||||
|
|
||||||
// 27.2.1.5 NewPromiseCapability ( C ), https://tc39.es/ecma262/#sec-newpromisecapability
|
// 27.2.1.5 NewPromiseCapability ( C ), https://tc39.es/ecma262/#sec-newpromisecapability
|
||||||
ThrowCompletionOr<PromiseCapability> new_promise_capability(GlobalObject& global_object, Value constructor);
|
ThrowCompletionOr<PromiseCapability> new_promise_capability(GlobalObject& global_object, Value constructor);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue