1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:37:34 +00:00

LibJS: Add spec comments to Completion

This commit is contained in:
Linus Groh 2023-01-27 21:33:28 +00:00
parent e32265c896
commit 0f3899b24a
2 changed files with 8 additions and 5 deletions

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org> * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -28,6 +28,7 @@ Completion::Completion(ThrowCompletionOr<Value> const& throw_completion_or_value
} }
// 6.2.3.1 Await, https://tc39.es/ecma262/#await // 6.2.3.1 Await, https://tc39.es/ecma262/#await
// FIXME: This no longer matches the spec!
ThrowCompletionOr<Value> await(VM& vm, Value value) ThrowCompletionOr<Value> await(VM& vm, Value value)
{ {
auto& realm = *vm.current_realm(); auto& realm = *vm.current_realm();
@ -120,9 +121,10 @@ ThrowCompletionOr<Value> await(VM& vm, Value value)
return throw_completion(result); return throw_completion(result);
} }
// 6.2.3.3 ThrowCompletion ( value ), https://tc39.es/ecma262/#sec-throwcompletion // 6.2.4.2 ThrowCompletion ( value ), https://tc39.es/ecma262/#sec-throwcompletion
Completion throw_completion(Value value) Completion throw_completion(Value value)
{ {
// 1. Return Completion Record { [[Type]]: throw, [[Value]]: value, [[Target]]: empty }.
return { Completion::Type::Throw, value, {} }; return { Completion::Type::Throw, value, {} };
} }

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org> * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -345,13 +345,14 @@ public:
ThrowCompletionOr<Value> await(VM&, Value); ThrowCompletionOr<Value> await(VM&, Value);
// 6.2.3.2 NormalCompletion ( value ), https://tc39.es/ecma262/#sec-normalcompletion // 6.2.4.1 NormalCompletion ( value ), https://tc39.es/ecma262/#sec-normalcompletion
inline Completion normal_completion(Optional<Value> value) inline Completion normal_completion(Optional<Value> value)
{ {
// 1. Return Completion Record { [[Type]]: normal, [[Value]]: value, [[Target]]: empty }.
return { Completion::Type::Normal, move(value), {} }; return { Completion::Type::Normal, move(value), {} };
} }
// 6.2.3.3 ThrowCompletion ( value ), https://tc39.es/ecma262/#sec-throwcompletion // 6.2.4.2 ThrowCompletion ( value ), https://tc39.es/ecma262/#sec-throwcompletion
Completion throw_completion(Value); Completion throw_completion(Value);
} }