diff --git a/Libraries/LibJS/Runtime/BigIntObject.h b/Libraries/LibJS/Runtime/BigIntObject.h index 0696c31cd85..49f5d6021a8 100644 --- a/Libraries/LibJS/Runtime/BigIntObject.h +++ b/Libraries/LibJS/Runtime/BigIntObject.h @@ -26,9 +26,14 @@ public: private: BigIntObject(BigInt&, Object& prototype); + virtual bool is_bigint_object() const final { return true; } + virtual void visit_edges(Visitor&) override; GC::Ref m_bigint; }; +template<> +inline bool Object::fast_is() const { return is_bigint_object(); } + } diff --git a/Libraries/LibJS/Runtime/BooleanObject.h b/Libraries/LibJS/Runtime/BooleanObject.h index ae97c51b68c..21fb5f5e146 100644 --- a/Libraries/LibJS/Runtime/BooleanObject.h +++ b/Libraries/LibJS/Runtime/BooleanObject.h @@ -25,7 +25,12 @@ protected: BooleanObject(bool, Object& prototype); private: + virtual bool is_boolean_object() const final { return true; } + bool m_value { false }; }; +template<> +inline bool Object::fast_is() const { return is_boolean_object(); } + } diff --git a/Libraries/LibJS/Runtime/Date.h b/Libraries/LibJS/Runtime/Date.h index bcf0fc0f71f..f96ae10e658 100644 --- a/Libraries/LibJS/Runtime/Date.h +++ b/Libraries/LibJS/Runtime/Date.h @@ -31,9 +31,14 @@ public: private: Date(double date_value, Object& prototype); + virtual bool is_date() const final { return true; } + double m_date_value { 0 }; // [[DateValue]] }; +template<> +inline bool Object::fast_is() const { return is_date(); } + // 21.4.1.22 Time Zone Identifier Record, https://tc39.es/ecma262/#sec-time-zone-identifier-record struct TimeZoneIdentifier { String identifier; // [[Identifier]] diff --git a/Libraries/LibJS/Runtime/Error.h b/Libraries/LibJS/Runtime/Error.h index b63befc3570..3632a83c936 100644 --- a/Libraries/LibJS/Runtime/Error.h +++ b/Libraries/LibJS/Runtime/Error.h @@ -47,10 +47,15 @@ protected: explicit Error(Object& prototype); private: + virtual bool is_error() const final { return true; } + void populate_stack(); Vector m_traceback; }; +template<> +inline bool Object::fast_is() const { return is_error(); } + // NOTE: Making these inherit from Error is not required by the spec but // our way of implementing the [[ErrorData]] internal slot, which is // used in Object.prototype.toString(). diff --git a/Libraries/LibJS/Runtime/NumberObject.h b/Libraries/LibJS/Runtime/NumberObject.h index 13fb041c2d0..dd4444d4742 100644 --- a/Libraries/LibJS/Runtime/NumberObject.h +++ b/Libraries/LibJS/Runtime/NumberObject.h @@ -25,7 +25,12 @@ protected: NumberObject(double, Object& prototype); private: + virtual bool is_number_object() const final { return true; } + double m_value { 0 }; }; +template<> +inline bool Object::fast_is() const { return is_number_object(); } + } diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h index 5e1687c8a99..6fdce3c335b 100644 --- a/Libraries/LibJS/Runtime/Object.h +++ b/Libraries/LibJS/Runtime/Object.h @@ -190,6 +190,12 @@ public: virtual bool is_dom_node() const { return false; } virtual bool is_function() const { return false; } + virtual bool is_error() const { return false; } + virtual bool is_date() const { return false; } + virtual bool is_number_object() const { return false; } + virtual bool is_boolean_object() const { return false; } + virtual bool is_regexp_object() const { return false; } + virtual bool is_bigint_object() const { return false; } virtual bool is_string_object() const { return false; } virtual bool is_global_object() const { return false; } virtual bool is_proxy_object() const { return false; } diff --git a/Libraries/LibJS/Runtime/RegExpObject.h b/Libraries/LibJS/Runtime/RegExpObject.h index 32c1926dffa..b7ebe63facc 100644 --- a/Libraries/LibJS/Runtime/RegExpObject.h +++ b/Libraries/LibJS/Runtime/RegExpObject.h @@ -74,6 +74,7 @@ private: RegExpObject(Object& prototype); RegExpObject(Regex regex, String pattern, String flags, Object& prototype); + virtual bool is_regexp_object() const final { return true; } virtual void visit_edges(Visitor&) override; String m_pattern; @@ -85,6 +86,9 @@ private: Optional> m_regex; }; +template<> +inline bool Object::fast_is() const { return is_regexp_object(); } + AK_ENUM_BITWISE_OPERATORS(RegExpObject::Flags); }