From 1611071ac73953a5ed68690d3e6d91ffc54cebb3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 7 Mar 2020 23:16:14 +0100 Subject: [PATCH] LibJS: Flesh out JS::Value a little bit more --- Libraries/LibJS/Value.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Libraries/LibJS/Value.h b/Libraries/LibJS/Value.h index 4a384e19dc..ed00df7d89 100644 --- a/Libraries/LibJS/Value.h +++ b/Libraries/LibJS/Value.h @@ -51,6 +51,12 @@ public: bool is_object() const { return m_type == Type::Object; } bool is_boolean() const { return m_type == Type::Boolean; } + explicit Value(bool value) + : m_type(Type::Boolean) + { + m_value.as_bool = value; + } + explicit Value(double value) : m_type(Type::Number) { @@ -100,6 +106,12 @@ public: return m_value.as_object; } + const StringImpl* as_string() const + { + ASSERT(is_string()); + return m_value.as_string; + } + String to_string() const; private: