mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-06 09:01:53 +00:00
LibJS: Make Completion.[[Value]] non-optional
Instead, just use js_undefined() whenever the [[Value]] field is unused. This avoids a whole bunch of presence checks.
This commit is contained in:
parent
c0600c4353
commit
de424d6879
Notes:
github-actions[bot]
2025-04-05 09:21:48 +00:00
Author: https://github.com/awesomekling
Commit: de424d6879
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4232
65 changed files with 225 additions and 250 deletions
|
@ -436,7 +436,7 @@ ThrowCompletionOr<Value> ECMAScriptFunctionObject::internal_call(Value this_argu
|
|||
|
||||
// 8. If result.[[Type]] is return, return result.[[Value]].
|
||||
if (result.type() == Completion::Type::Return)
|
||||
return *result.value();
|
||||
return result.value();
|
||||
|
||||
// 9. Assert: result is a throw completion.
|
||||
VERIFY(result.type() == Completion::Type::Throw);
|
||||
|
@ -520,15 +520,15 @@ ThrowCompletionOr<GC::Ref<Object>> ECMAScriptFunctionObject::internal_construct(
|
|||
VERIFY(result.type() == Completion::Type::Return);
|
||||
|
||||
// 12. If Type(result.[[Value]]) is Object, return result.[[Value]].
|
||||
if (result.value()->is_object())
|
||||
return result.value()->as_object();
|
||||
if (result.value().is_object())
|
||||
return result.value().as_object();
|
||||
|
||||
// 13. If kind is base, return thisArgument.
|
||||
if (kind == ConstructorKind::Base)
|
||||
return *this_argument;
|
||||
|
||||
// 14. If result.[[Value]] is not undefined, throw a TypeError exception.
|
||||
if (!result.value()->is_undefined())
|
||||
if (!result.value().is_undefined())
|
||||
return vm.throw_completion<TypeError>(ErrorType::DerivedConstructorReturningInvalidValue);
|
||||
|
||||
// 15. Let thisBinding be ? constructorEnv.GetThisBinding().
|
||||
|
@ -771,7 +771,7 @@ void async_block_start(VM& vm, T const& async_body, PromiseCapability const& pro
|
|||
// g. Else if result is a return completion, then
|
||||
else if (result.type() == Completion::Type::Return) {
|
||||
// i. Perform ! Call(promiseCapability.[[Resolve]], undefined, « result.[[Value]] »).
|
||||
MUST(call(vm, *promise_capability.resolve(), js_undefined(), *result.value()));
|
||||
MUST(call(vm, *promise_capability.resolve(), js_undefined(), result.value()));
|
||||
}
|
||||
// h. Else,
|
||||
else {
|
||||
|
@ -779,7 +779,7 @@ void async_block_start(VM& vm, T const& async_body, PromiseCapability const& pro
|
|||
VERIFY(result.type() == Completion::Type::Throw);
|
||||
|
||||
// ii. Perform ! Call(promiseCapability.[[Reject]], undefined, « result.[[Value]] »).
|
||||
MUST(call(vm, *promise_capability.reject(), js_undefined(), *result.value()));
|
||||
MUST(call(vm, *promise_capability.reject(), js_undefined(), result.value()));
|
||||
}
|
||||
// i. Return unused.
|
||||
// NOTE: We don't support returning an empty/optional/unused value here.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue