From 7fc28079295ebcd3b834bd96230aee22997b5411 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 8 Oct 2021 19:25:45 +0100 Subject: [PATCH] LibJS: Add Completion::is_abrupt() This is commonly used in the spec. --- Userland/Libraries/LibJS/Runtime/Completion.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/Completion.h b/Userland/Libraries/LibJS/Runtime/Completion.h index 3a9b62b4b7..252d5a3be5 100644 --- a/Userland/Libraries/LibJS/Runtime/Completion.h +++ b/Userland/Libraries/LibJS/Runtime/Completion.h @@ -78,6 +78,9 @@ public: [[nodiscard]] bool has_target() const { return m_target.has_value(); } [[nodiscard]] FlyString const& target() const { return *m_target; } + // "abrupt completion refers to any completion with a [[Type]] value other than normal" + [[nodiscard]] bool is_abrupt() const { return m_type != Type::Normal; } + // These are for compatibility with the TRY() macro in AK. [[nodiscard]] bool is_error() const { return m_type == Type::Throw; } [[nodiscard]] Value release_value() { return m_value.release_value(); }