diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp index 4cb42f215f..8c8a47fa1b 100644 --- a/Userland/Libraries/LibJS/Runtime/Set.cpp +++ b/Userland/Libraries/LibJS/Runtime/Set.cpp @@ -22,18 +22,6 @@ Set::~Set() { } -Set* Set::typed_this(VM& vm, GlobalObject& global_object) -{ - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return {}; - if (!is(this_object)) { - vm.throw_exception(global_object, ErrorType::NotA, "Set"); - return nullptr; - } - return static_cast(this_object); -} - void Set::visit_edges(Cell::Visitor& visitor) { Object::visit_edges(visitor); diff --git a/Userland/Libraries/LibJS/Runtime/Set.h b/Userland/Libraries/LibJS/Runtime/Set.h index 59ac8ace4c..0e17fa7196 100644 --- a/Userland/Libraries/LibJS/Runtime/Set.h +++ b/Userland/Libraries/LibJS/Runtime/Set.h @@ -41,8 +41,6 @@ public: explicit Set(Object& prototype); virtual ~Set() override; - static Set* typed_this(VM&, GlobalObject&); - HashTable const& values() const { return m_values; }; HashTable& values() { return m_values; }; diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp index d6f6a14af8..ac6c731260 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp @@ -11,14 +11,14 @@ namespace JS { SetPrototype::SetPrototype(GlobalObject& global_object) - : Set(*global_object.object_prototype()) + : Object(*global_object.object_prototype()) { } void SetPrototype::initialize(GlobalObject& global_object) { auto& vm = this->vm(); - Set::initialize(global_object); + Object::initialize(global_object); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(vm.names.add, add, 1, attr); @@ -40,6 +40,18 @@ SetPrototype::~SetPrototype() { } +Set* SetPrototype::typed_this(VM& vm, GlobalObject& global_object) +{ + auto* this_object = vm.this_value(global_object).to_object(global_object); + if (!this_object) + return {}; + if (!is(this_object)) { + vm.throw_exception(global_object, ErrorType::NotA, "Set"); + return nullptr; + } + return static_cast(this_object); +} + JS_DEFINE_NATIVE_FUNCTION(SetPrototype::add) { auto* set = typed_this(vm, global_object); diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.h b/Userland/Libraries/LibJS/Runtime/SetPrototype.h index e0b7056140..9044172c5c 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.h @@ -10,8 +10,8 @@ namespace JS { -class SetPrototype final : public Set { - JS_OBJECT(SetPrototype, Set); +class SetPrototype final : public Object { + JS_OBJECT(SetPrototype, Object); public: SetPrototype(GlobalObject&); @@ -19,6 +19,8 @@ public: virtual ~SetPrototype() override; private: + static Set* typed_this(VM&, GlobalObject&); + JS_DECLARE_NATIVE_FUNCTION(add); JS_DECLARE_NATIVE_FUNCTION(clear); JS_DECLARE_NATIVE_FUNCTION(delete_);