mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00:00
LibJS: Add a Completion(ThrowCompletionOr<Value> const&) constructor
This commit is contained in:
parent
01c2570678
commit
68ac13a192
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -15,6 +16,17 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
Completion::Completion(ThrowCompletionOr<Value> const& throw_completion_or_value)
|
||||
{
|
||||
if (throw_completion_or_value.is_throw_completion()) {
|
||||
m_type = Type::Throw;
|
||||
m_value = throw_completion_or_value.throw_completion().value();
|
||||
} else {
|
||||
m_type = Type::Normal;
|
||||
m_value = throw_completion_or_value.value();
|
||||
}
|
||||
}
|
||||
|
||||
// 6.2.3.1 Await, https://tc39.es/ecma262/#await
|
||||
ThrowCompletionOr<Value> await(GlobalObject& global_object, Value value)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
VERIFY(!m_value->is_empty());
|
||||
}
|
||||
|
||||
Completion(ThrowCompletionOr<Value> const&);
|
||||
|
||||
// 5.2.3.1 Implicit Completion Values, https://tc39.es/ecma262/#sec-implicit-completion-values
|
||||
// Not `explicit` on purpose.
|
||||
Completion(Value value)
|
||||
|
|
Loading…
Reference in a new issue