diff options
author | Linus Groh <mail@linusgroh.de> | 2020-06-04 22:00:17 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-07 19:29:40 +0200 |
commit | 5b88aa8e96237f45a3adfd555086f3a72f283ae6 (patch) | |
tree | 64d601504614caa0d95da73b5bffb61f7c662e30 /Libraries | |
parent | 5a983c238bdf3008d58bd7ee75d40b22e1b9b402 (diff) | |
download | serenity-5b88aa8e96237f45a3adfd555086f3a72f283ae6.zip |
LibJS: Move Value::as_accessor() to Value.h
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibJS/Runtime/Value.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/Value.h | 9 |
2 files changed, 7 insertions, 8 deletions
diff --git a/Libraries/LibJS/Runtime/Value.cpp b/Libraries/LibJS/Runtime/Value.cpp index 0df5149a6f..a1d3b0ece0 100644 --- a/Libraries/LibJS/Runtime/Value.cpp +++ b/Libraries/LibJS/Runtime/Value.cpp @@ -62,12 +62,6 @@ Function& Value::as_function() return static_cast<Function&>(as_object()); } -Accessor& Value::as_accessor() -{ - ASSERT(is_accessor()); - return static_cast<Accessor&>(*m_value.as_accessor); -} - String Value::to_string_without_side_effects() const { switch (m_type) { diff --git a/Libraries/LibJS/Runtime/Value.h b/Libraries/LibJS/Runtime/Value.h index cb3e1c5835..0b252e2c6f 100644 --- a/Libraries/LibJS/Runtime/Value.h +++ b/Libraries/LibJS/Runtime/Value.h @@ -201,10 +201,13 @@ public: return m_value.as_cell; } - String to_string_without_side_effects() const; + Accessor& as_accessor() + { + ASSERT(is_accessor()); + return *m_value.as_accessor; + } Function& as_function(); - Accessor& as_accessor(); i32 as_i32() const; size_t as_size_t() const; @@ -219,6 +222,8 @@ public: size_t to_size_t(Interpreter&) const; bool to_boolean() const; + String to_string_without_side_effects() const; + Value value_or(Value fallback) const { if (is_empty()) |