summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-08 19:25:45 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-09 14:29:20 +0100
commit7fc28079295ebcd3b834bd96230aee22997b5411 (patch)
tree175091d0f5652c5e93c8e2a6f3a9357489d3407d
parentc58d51ce4087c657c664219857918a338437e786 (diff)
downloadserenity-7fc28079295ebcd3b834bd96230aee22997b5411.zip
LibJS: Add Completion::is_abrupt()
This is commonly used in the spec.
-rw-r--r--Userland/Libraries/LibJS/Runtime/Completion.h3
1 files changed, 3 insertions, 0 deletions
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(); }