From 35c9aa7c05c7d2b012e86cc72945ade3440ab0bf Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 28 Aug 2022 23:51:28 +0200 Subject: LibJS: Hide all the constructors! Now that the GC allocator is able to invoke Cell subclass constructors directly via friendship, we no longer need to keep them public. :^) --- .../Libraries/LibJS/Contrib/Test262/$262Object.h | 3 ++- .../Libraries/LibJS/Contrib/Test262/AgentObject.h | 3 ++- .../Libraries/LibJS/Contrib/Test262/GlobalObject.h | 9 +++++---- .../Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h | 3 ++- Userland/Libraries/LibJS/Runtime/Accessor.h | 12 +++++------ Userland/Libraries/LibJS/Runtime/AggregateError.h | 3 ++- .../LibJS/Runtime/AggregateErrorConstructor.h | 2 +- .../LibJS/Runtime/AggregateErrorPrototype.h | 4 +++- Userland/Libraries/LibJS/Runtime/ArgumentsObject.h | 4 ++-- Userland/Libraries/LibJS/Runtime/Array.h | 3 +++ Userland/Libraries/LibJS/Runtime/ArrayBuffer.h | 5 +++-- .../LibJS/Runtime/ArrayBufferConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/ArrayBufferPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/ArrayConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/ArrayIterator.h | 3 ++- .../LibJS/Runtime/ArrayIteratorPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/ArrayPrototype.h | 3 ++- .../LibJS/Runtime/AsyncFromSyncIterator.h | 3 ++- .../LibJS/Runtime/AsyncFromSyncIteratorPrototype.h | 3 ++- .../LibJS/Runtime/AsyncFunctionConstructor.h | 3 ++- .../LibJS/Runtime/AsyncFunctionDriverWrapper.h | 3 ++- .../LibJS/Runtime/AsyncFunctionPrototype.h | 4 +++- Userland/Libraries/LibJS/Runtime/AsyncGenerator.h | 3 ++- .../Runtime/AsyncGeneratorFunctionConstructor.h | 3 ++- .../Runtime/AsyncGeneratorFunctionPrototype.h | 4 +++- .../LibJS/Runtime/AsyncGeneratorPrototype.h | 4 +++- .../LibJS/Runtime/AsyncIteratorPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/AtomicsObject.h | 3 ++- Userland/Libraries/LibJS/Runtime/BigInt.h | 3 ++- .../Libraries/LibJS/Runtime/BigIntConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/BigIntObject.h | 3 ++- Userland/Libraries/LibJS/Runtime/BigIntPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/BooleanConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/BooleanObject.h | 4 +++- .../Libraries/LibJS/Runtime/BooleanPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/BoundFunction.h | 3 ++- Userland/Libraries/LibJS/Runtime/ConsoleObject.h | 3 ++- Userland/Libraries/LibJS/Runtime/DataView.h | 3 ++- .../Libraries/LibJS/Runtime/DataViewConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/DataViewPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/Date.h | 3 ++- Userland/Libraries/LibJS/Runtime/DateConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/DatePrototype.h | 3 ++- .../LibJS/Runtime/DeclarativeEnvironment.h | 7 ++++--- .../LibJS/Runtime/ECMAScriptFunctionObject.h | 3 ++- Userland/Libraries/LibJS/Runtime/Error.h | 4 +++- .../Libraries/LibJS/Runtime/ErrorConstructor.h | 11 ++++++++--- Userland/Libraries/LibJS/Runtime/ErrorPrototype.h | 7 +++++-- .../Libraries/LibJS/Runtime/FinalizationRegistry.h | 3 ++- .../Runtime/FinalizationRegistryConstructor.h | 3 ++- .../LibJS/Runtime/FinalizationRegistryPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/FunctionConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/FunctionEnvironment.h | 3 ++- .../Libraries/LibJS/Runtime/FunctionPrototype.h | 3 ++- .../LibJS/Runtime/GeneratorFunctionConstructor.h | 3 ++- .../LibJS/Runtime/GeneratorFunctionPrototype.h | 4 +++- Userland/Libraries/LibJS/Runtime/GeneratorObject.h | 3 ++- .../Libraries/LibJS/Runtime/GeneratorPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/GlobalEnvironment.h | 4 ++-- Userland/Libraries/LibJS/Runtime/GlobalObject.h | 4 +++- Userland/Libraries/LibJS/Runtime/Intl/Collator.h | 3 ++- .../LibJS/Runtime/Intl/CollatorCompareFunction.h | 3 ++- .../LibJS/Runtime/Intl/CollatorConstructor.h | 3 ++- .../LibJS/Runtime/Intl/CollatorPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Intl/DateTimeFormat.h | 3 ++- .../LibJS/Runtime/Intl/DateTimeFormatConstructor.h | 3 ++- .../LibJS/Runtime/Intl/DateTimeFormatFunction.h | 3 ++- .../LibJS/Runtime/Intl/DateTimeFormatPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Intl/DisplayNames.h | 3 ++- .../LibJS/Runtime/Intl/DisplayNamesConstructor.h | 3 ++- .../LibJS/Runtime/Intl/DisplayNamesPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Intl/DurationFormat.h | 3 ++- .../LibJS/Runtime/Intl/DurationFormatConstructor.h | 3 ++- .../LibJS/Runtime/Intl/DurationFormatPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/Intl/Intl.h | 3 ++- Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h | 3 ++- .../LibJS/Runtime/Intl/ListFormatConstructor.h | 3 ++- .../LibJS/Runtime/Intl/ListFormatPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/Intl/Locale.h | 5 +++-- .../LibJS/Runtime/Intl/LocaleConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/Intl/LocalePrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Intl/NumberFormat.h | 7 +++++-- .../LibJS/Runtime/Intl/NumberFormatConstructor.h | 3 ++- .../LibJS/Runtime/Intl/NumberFormatFunction.h | 3 ++- .../LibJS/Runtime/Intl/NumberFormatPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Intl/PluralRules.h | 3 ++- .../LibJS/Runtime/Intl/PluralRulesConstructor.h | 3 ++- .../LibJS/Runtime/Intl/PluralRulesPrototype.h | 3 ++- .../LibJS/Runtime/Intl/RelativeTimeFormat.h | 3 ++- .../Runtime/Intl/RelativeTimeFormatConstructor.h | 3 ++- .../Runtime/Intl/RelativeTimeFormatPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Intl/SegmentIterator.h | 3 ++- .../LibJS/Runtime/Intl/SegmentIteratorPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/Intl/Segmenter.h | 3 ++- .../LibJS/Runtime/Intl/SegmenterConstructor.h | 3 ++- .../LibJS/Runtime/Intl/SegmenterPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/Intl/Segments.h | 3 ++- .../LibJS/Runtime/Intl/SegmentsPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/Intrinsics.h | 4 ++-- .../Libraries/LibJS/Runtime/IteratorPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/JSONObject.h | 3 ++- Userland/Libraries/LibJS/Runtime/Map.h | 5 ++++- Userland/Libraries/LibJS/Runtime/MapConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/MapIterator.h | 3 ++- .../Libraries/LibJS/Runtime/MapIteratorPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/MapPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/MathObject.h | 3 ++- .../Libraries/LibJS/Runtime/ModuleEnvironment.h | 4 ++-- .../LibJS/Runtime/ModuleNamespaceObject.h | 4 ++-- Userland/Libraries/LibJS/Runtime/NativeFunction.h | 4 ++-- .../Libraries/LibJS/Runtime/NumberConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/NumberObject.h | 4 +++- Userland/Libraries/LibJS/Runtime/NumberPrototype.h | 4 +++- Userland/Libraries/LibJS/Runtime/Object.h | 7 ++++--- .../Libraries/LibJS/Runtime/ObjectConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/ObjectEnvironment.h | 3 ++- Userland/Libraries/LibJS/Runtime/ObjectPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/PrimitiveString.h | 7 ++++--- .../Libraries/LibJS/Runtime/PrivateEnvironment.h | 4 ++-- Userland/Libraries/LibJS/Runtime/Promise.h | 3 ++- .../Libraries/LibJS/Runtime/PromiseConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/PromisePrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/PromiseReaction.h | 3 ++- .../Runtime/PromiseResolvingElementFunctions.h | 23 ++++++++++++---------- .../LibJS/Runtime/PromiseResolvingFunction.h | 3 ++- .../Libraries/LibJS/Runtime/ProxyConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/ProxyObject.h | 3 ++- Userland/Libraries/LibJS/Runtime/Realm.h | 4 ++-- Userland/Libraries/LibJS/Runtime/ReflectObject.h | 3 ++- .../Libraries/LibJS/Runtime/RegExpConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/RegExpObject.h | 6 +++--- Userland/Libraries/LibJS/Runtime/RegExpPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/RegExpStringIterator.h | 3 ++- .../LibJS/Runtime/RegExpStringIteratorPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/Set.h | 3 ++- Userland/Libraries/LibJS/Runtime/SetConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/SetIterator.h | 3 ++- .../Libraries/LibJS/Runtime/SetIteratorPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/SetPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/ShadowRealm.h | 3 ++- .../LibJS/Runtime/ShadowRealmConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/ShadowRealmPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/Shape.h | 8 ++++---- .../Libraries/LibJS/Runtime/StringConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/StringIterator.h | 3 ++- .../LibJS/Runtime/StringIteratorPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/StringObject.h | 4 +++- Userland/Libraries/LibJS/Runtime/Symbol.h | 3 ++- .../Libraries/LibJS/Runtime/SymbolConstructor.h | 3 ++- Userland/Libraries/LibJS/Runtime/SymbolObject.h | 3 ++- Userland/Libraries/LibJS/Runtime/SymbolPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Temporal/Calendar.h | 3 ++- .../LibJS/Runtime/Temporal/CalendarConstructor.h | 3 ++- .../LibJS/Runtime/Temporal/CalendarPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Temporal/Duration.h | 3 ++- .../LibJS/Runtime/Temporal/DurationConstructor.h | 3 ++- .../LibJS/Runtime/Temporal/DurationPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Temporal/Instant.h | 3 ++- .../LibJS/Runtime/Temporal/InstantConstructor.h | 3 ++- .../LibJS/Runtime/Temporal/InstantPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/Temporal/Now.h | 3 ++- .../Libraries/LibJS/Runtime/Temporal/PlainDate.h | 3 ++- .../LibJS/Runtime/Temporal/PlainDateConstructor.h | 3 ++- .../LibJS/Runtime/Temporal/PlainDatePrototype.h | 3 ++- .../LibJS/Runtime/Temporal/PlainDateTime.h | 3 ++- .../Runtime/Temporal/PlainDateTimeConstructor.h | 3 ++- .../Runtime/Temporal/PlainDateTimePrototype.h | 3 ++- .../LibJS/Runtime/Temporal/PlainMonthDay.h | 3 ++- .../Runtime/Temporal/PlainMonthDayConstructor.h | 3 ++- .../Runtime/Temporal/PlainMonthDayPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Temporal/PlainTime.h | 3 ++- .../LibJS/Runtime/Temporal/PlainTimeConstructor.h | 3 ++- .../LibJS/Runtime/Temporal/PlainTimePrototype.h | 3 ++- .../LibJS/Runtime/Temporal/PlainYearMonth.h | 3 ++- .../Runtime/Temporal/PlainYearMonthConstructor.h | 3 ++- .../Runtime/Temporal/PlainYearMonthPrototype.h | 3 ++- .../Libraries/LibJS/Runtime/Temporal/Temporal.h | 4 +++- .../Libraries/LibJS/Runtime/Temporal/TimeZone.h | 3 ++- .../LibJS/Runtime/Temporal/TimeZoneConstructor.h | 3 ++- .../LibJS/Runtime/Temporal/TimeZonePrototype.h | 3 ++- .../LibJS/Runtime/Temporal/ZonedDateTime.h | 3 ++- .../Runtime/Temporal/ZonedDateTimeConstructor.h | 3 ++- .../Runtime/Temporal/ZonedDateTimePrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/TypedArray.h | 12 +++++++---- .../LibJS/Runtime/TypedArrayConstructor.h | 4 +++- .../Libraries/LibJS/Runtime/TypedArrayPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/WeakMap.h | 3 ++- .../Libraries/LibJS/Runtime/WeakMapConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/WeakMapPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/WeakRef.h | 5 +++-- .../Libraries/LibJS/Runtime/WeakRefConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/WeakRefPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/WeakSet.h | 3 ++- .../Libraries/LibJS/Runtime/WeakSetConstructor.h | 3 ++- .../Libraries/LibJS/Runtime/WeakSetPrototype.h | 3 ++- Userland/Libraries/LibJS/Runtime/WrappedFunction.h | 3 ++- 196 files changed, 455 insertions(+), 241 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h index aa586f58dc..ac4a21d947 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h @@ -17,11 +17,12 @@ class $262Object final : public Object { JS_OBJECT($262Object, Object); public: - explicit $262Object(Realm&); virtual void initialize(JS::Realm&) override; virtual ~$262Object() override = default; private: + explicit $262Object(Realm&); + virtual void visit_edges(Visitor&) override; AgentObject* m_agent { nullptr }; diff --git a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h index 262d939994..3daf6e166d 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h @@ -15,11 +15,12 @@ class AgentObject final : public Object { JS_OBJECT(AgentObject, Object); public: - explicit AgentObject(Realm&); virtual void initialize(JS::Realm&) override; virtual ~AgentObject() override = default; private: + explicit AgentObject(Realm&); + JS_DECLARE_NATIVE_FUNCTION(monotonic_now); JS_DECLARE_NATIVE_FUNCTION(sleep); }; diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h index f095233c1a..84cbdb5889 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h @@ -15,16 +15,17 @@ class GlobalObject final : public JS::GlobalObject { JS_OBJECT(GlobalObject, JS::GlobalObject); public: - GlobalObject(JS::Realm& realm) - : JS::GlobalObject(realm) - { - } virtual void initialize(Realm&) override; virtual ~GlobalObject() override = default; $262Object* $262() const { return m_$262; } private: + GlobalObject(JS::Realm& realm) + : JS::GlobalObject(realm) + { + } + virtual void visit_edges(Visitor&) override; $262Object* m_$262 { nullptr }; diff --git a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h index f34322e4ea..f8b1788b0a 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h @@ -14,12 +14,13 @@ class IsHTMLDDA final : public NativeFunction { JS_OBJECT(IsHTMLDDA, NativeFunction); public: - explicit IsHTMLDDA(Realm&); virtual ~IsHTMLDDA() override = default; virtual ThrowCompletionOr call() override; private: + explicit IsHTMLDDA(Realm&); + virtual bool is_htmldda() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/Accessor.h b/Userland/Libraries/LibJS/Runtime/Accessor.h index a665a64e10..1ed693df4f 100644 --- a/Userland/Libraries/LibJS/Runtime/Accessor.h +++ b/Userland/Libraries/LibJS/Runtime/Accessor.h @@ -22,12 +22,6 @@ public: return vm.heap().allocate_without_realm(getter, setter); } - Accessor(FunctionObject* getter, FunctionObject* setter) - : m_getter(getter) - , m_setter(setter) - { - } - FunctionObject* getter() const { return m_getter; } void set_getter(FunctionObject* getter) { m_getter = getter; } @@ -41,6 +35,12 @@ public: } private: + Accessor(FunctionObject* getter, FunctionObject* setter) + : m_getter(getter) + , m_setter(setter) + { + } + FunctionObject* m_getter { nullptr }; FunctionObject* m_setter { nullptr }; }; diff --git a/Userland/Libraries/LibJS/Runtime/AggregateError.h b/Userland/Libraries/LibJS/Runtime/AggregateError.h index 23e74be65f..d1ff1af061 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateError.h +++ b/Userland/Libraries/LibJS/Runtime/AggregateError.h @@ -16,9 +16,10 @@ class AggregateError : public Error { public: static AggregateError* create(Realm&); + virtual ~AggregateError() override = default; +private: explicit AggregateError(Object& prototype); - virtual ~AggregateError() override = default; }; } diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h index c2d6a7c2a4..7d3492d5b9 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h @@ -14,7 +14,6 @@ class AggregateErrorConstructor final : public NativeFunction { JS_OBJECT(AggregateErrorConstructor, NativeFunction); public: - explicit AggregateErrorConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~AggregateErrorConstructor() override = default; @@ -22,6 +21,7 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit AggregateErrorConstructor(Realm&); virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h index b1aae1b60d..420a0864f0 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h @@ -14,9 +14,11 @@ class AggregateErrorPrototype final : public Object { JS_OBJECT(AggregateErrorPrototype, Object); public: - explicit AggregateErrorPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~AggregateErrorPrototype() override = default; + +private: + explicit AggregateErrorPrototype(Realm&); }; } diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h index ce23d81e92..c3c9f30801 100644 --- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h +++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h @@ -16,8 +16,6 @@ class ArgumentsObject final : public Object { JS_OBJECT(ArgumentsObject, Object); public: - ArgumentsObject(Realm&, Environment&); - virtual void initialize(Realm&) override; virtual ~ArgumentsObject() override = default; @@ -33,6 +31,8 @@ public: Object& parameter_map() { return *m_parameter_map; } private: + ArgumentsObject(Realm&, Environment&); + virtual void visit_edges(Cell::Visitor&) override; Environment& m_environment; diff --git a/Userland/Libraries/LibJS/Runtime/Array.h b/Userland/Libraries/LibJS/Runtime/Array.h index 5ccb0e8d65..dd988309b7 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.h +++ b/Userland/Libraries/LibJS/Runtime/Array.h @@ -44,6 +44,9 @@ public: [[nodiscard]] bool length_is_writable() const { return m_length_writable; }; +protected: + explicit Array(Object& prototype); + private: ThrowCompletionOr set_length(PropertyDescriptor const&); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h index 830f899d5a..34f4655654 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h @@ -29,8 +29,6 @@ public: static ArrayBuffer* create(Realm&, ByteBuffer); static ArrayBuffer* create(Realm&, ByteBuffer*); - ArrayBuffer(ByteBuffer buffer, Object& prototype); - ArrayBuffer(ByteBuffer* buffer, Object& prototype); virtual ~ArrayBuffer() override = default; size_t byte_length() const { return buffer_impl().size(); } @@ -58,6 +56,9 @@ public: Value get_modify_set_value(size_t byte_index, Value value, ReadWriteModifyFunction operation, bool is_little_endian = true); private: + ArrayBuffer(ByteBuffer buffer, Object& prototype); + ArrayBuffer(ByteBuffer* buffer, Object& prototype); + virtual void visit_edges(Visitor&) override; ByteBuffer& buffer_impl() diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h index 3d5d2b5f1d..4befd09841 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h @@ -14,7 +14,6 @@ class ArrayBufferConstructor final : public NativeFunction { JS_OBJECT(ArrayBufferConstructor, NativeFunction); public: - explicit ArrayBufferConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~ArrayBufferConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit ArrayBufferConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(is_view); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h index 62b0e2b5b2..5cec046f5c 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h @@ -15,11 +15,12 @@ class ArrayBufferPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit ArrayConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIterator.h b/Userland/Libraries/LibJS/Runtime/ArrayIterator.h index fca149fb16..e296a85d0d 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIterator.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayIterator.h @@ -16,7 +16,6 @@ class ArrayIterator final : public Object { public: static ArrayIterator* create(Realm&, Value array, Object::PropertyKind iteration_kind); - explicit ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype); virtual ~ArrayIterator() override = default; Value array() const { return m_array; } @@ -26,6 +25,8 @@ public: private: friend class ArrayIteratorPrototype; + ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype); + virtual void visit_edges(Cell::Visitor&) override; Value m_array; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h index ad48f8e372..25c53bdcec 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h @@ -15,11 +15,12 @@ class ArrayIteratorPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit AsyncFunctionConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h index 40f92034a5..c1f34c8d65 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h @@ -19,7 +19,6 @@ class AsyncFunctionDriverWrapper final : public Promise { public: static ThrowCompletionOr create(Realm&, GeneratorObject*); - explicit AsyncFunctionDriverWrapper(Realm&, GeneratorObject*); virtual ~AsyncFunctionDriverWrapper() override = default; void visit_edges(Cell::Visitor&) override; @@ -27,6 +26,8 @@ public: ThrowCompletionOr react_to_async_task_completion(VM&, Value, bool is_successful); private: + AsyncFunctionDriverWrapper(Realm&, GeneratorObject*); + GeneratorObject* m_generator_object { nullptr }; NativeFunction* m_on_fulfillment { nullptr }; NativeFunction* m_on_rejection { nullptr }; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h index 04f731dbbc..44a532f8bc 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h @@ -14,9 +14,11 @@ class AsyncFunctionPrototype final : public Object { JS_OBJECT(AsyncFunctionPrototype, Object); public: - explicit AsyncFunctionPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~AsyncFunctionPrototype() override = default; + +private: + explicit AsyncFunctionPrototype(Realm&); }; } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h index 7154b851e1..d43df4f8e0 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h @@ -26,10 +26,11 @@ public: Completed, }; - explicit AsyncGenerator(Object& prototype); virtual ~AsyncGenerator() override = default; private: + explicit AsyncGenerator(Object& prototype); + virtual void visit_edges(Cell::Visitor&) override; // At the time of constructing an AsyncGenerator, we still need to point to an diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h index d59fcbb089..f3c474e36e 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h @@ -14,7 +14,6 @@ class AsyncGeneratorFunctionConstructor final : public NativeFunction { JS_OBJECT(AsyncGeneratorFunctionConstructor, NativeFunction); public: - explicit AsyncGeneratorFunctionConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~AsyncGeneratorFunctionConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit AsyncGeneratorFunctionConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h index 558f53cbbd..602a947d94 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h @@ -14,9 +14,11 @@ class AsyncGeneratorFunctionPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit BigIntConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(as_int_n); diff --git a/Userland/Libraries/LibJS/Runtime/BigIntObject.h b/Userland/Libraries/LibJS/Runtime/BigIntObject.h index 2eb03f5c90..e8fcf6268e 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntObject.h +++ b/Userland/Libraries/LibJS/Runtime/BigIntObject.h @@ -17,13 +17,14 @@ class BigIntObject final : public Object { public: static BigIntObject* create(Realm&, BigInt&); - BigIntObject(BigInt&, Object& prototype); virtual ~BigIntObject() override = default; BigInt const& bigint() const { return m_bigint; } BigInt& bigint() { return m_bigint; } private: + BigIntObject(BigInt&, Object& prototype); + virtual void visit_edges(Visitor&) override; BigInt& m_bigint; diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h index d1e3b59a5e..ca95f9684b 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h @@ -14,11 +14,12 @@ class BigIntPrototype final : public Object { JS_OBJECT(BigIntPrototype, Object); public: - explicit BigIntPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~BigIntPrototype() override = default; private: + explicit BigIntPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(to_string); JS_DECLARE_NATIVE_FUNCTION(to_locale_string); JS_DECLARE_NATIVE_FUNCTION(value_of); diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h index fa2c8a825f..71cd414339 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h @@ -14,7 +14,6 @@ class BooleanConstructor final : public NativeFunction { JS_OBJECT(BooleanConstructor, NativeFunction); public: - explicit BooleanConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~BooleanConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit BooleanConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/BooleanObject.h b/Userland/Libraries/LibJS/Runtime/BooleanObject.h index 4be928dcd7..308e3e8dac 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanObject.h +++ b/Userland/Libraries/LibJS/Runtime/BooleanObject.h @@ -16,11 +16,13 @@ class BooleanObject : public Object { public: static BooleanObject* create(Realm&, bool); - BooleanObject(bool, Object& prototype); virtual ~BooleanObject() override = default; bool boolean() const { return m_value; } +protected: + BooleanObject(bool, Object& prototype); + private: bool m_value { false }; }; diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h index 269b572319..83af2e841d 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h @@ -14,11 +14,12 @@ class BooleanPrototype final : public BooleanObject { JS_OBJECT(BooleanPrototype, BooleanObject); public: - explicit BooleanPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~BooleanPrototype() override = default; private: + explicit BooleanPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(to_string); JS_DECLARE_NATIVE_FUNCTION(value_of); }; diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.h b/Userland/Libraries/LibJS/Runtime/BoundFunction.h index 85425be94a..a5e11c6498 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.h +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.h @@ -17,7 +17,6 @@ class BoundFunction final : public FunctionObject { public: static ThrowCompletionOr create(Realm&, FunctionObject& target_function, Value bound_this, Vector bound_arguments); - BoundFunction(Realm&, FunctionObject& target_function, Value bound_this, Vector bound_arguments, Object* prototype); virtual ~BoundFunction() override = default; virtual ThrowCompletionOr internal_call(Value this_argument, MarkedVector arguments_list) override; @@ -32,6 +31,8 @@ public: Vector const& bound_arguments() const { return m_bound_arguments; } private: + BoundFunction(Realm&, FunctionObject& target_function, Value bound_this, Vector bound_arguments, Object* prototype); + virtual void visit_edges(Visitor&) override; FunctionObject* m_bound_target_function { nullptr }; // [[BoundTargetFunction]] diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.h b/Userland/Libraries/LibJS/Runtime/ConsoleObject.h index 405f02bf56..a4bb63f273 100644 --- a/Userland/Libraries/LibJS/Runtime/ConsoleObject.h +++ b/Userland/Libraries/LibJS/Runtime/ConsoleObject.h @@ -14,13 +14,14 @@ class ConsoleObject final : public Object { JS_OBJECT(ConsoleObject, Object); public: - explicit ConsoleObject(Realm&); virtual void initialize(Realm&) override; virtual ~ConsoleObject() override = default; Console& console() { return *m_console; } private: + explicit ConsoleObject(Realm&); + JS_DECLARE_NATIVE_FUNCTION(log); JS_DECLARE_NATIVE_FUNCTION(debug); JS_DECLARE_NATIVE_FUNCTION(info); diff --git a/Userland/Libraries/LibJS/Runtime/DataView.h b/Userland/Libraries/LibJS/Runtime/DataView.h index 4edb44cc88..a3c866023c 100644 --- a/Userland/Libraries/LibJS/Runtime/DataView.h +++ b/Userland/Libraries/LibJS/Runtime/DataView.h @@ -18,7 +18,6 @@ class DataView : public Object { public: static DataView* create(Realm&, ArrayBuffer*, size_t byte_length, size_t byte_offset); - explicit DataView(ArrayBuffer*, size_t byte_length, size_t byte_offset, Object& prototype); virtual ~DataView() override = default; ArrayBuffer* viewed_array_buffer() const { return m_viewed_array_buffer; } @@ -26,6 +25,8 @@ public: size_t byte_offset() const { return m_byte_offset; } private: + DataView(ArrayBuffer*, size_t byte_length, size_t byte_offset, Object& prototype); + virtual void visit_edges(Visitor& visitor) override; ArrayBuffer* m_viewed_array_buffer { nullptr }; diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h index 20d77f0dcf..e2b067a5b1 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h @@ -14,7 +14,6 @@ class DataViewConstructor final : public NativeFunction { JS_OBJECT(DataViewConstructor, NativeFunction); public: - explicit DataViewConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~DataViewConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject&) override; private: + explicit DataViewConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h index 979c7a3f32..7138918922 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h @@ -15,11 +15,12 @@ class DataViewPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit DateConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(now); diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.h b/Userland/Libraries/LibJS/Runtime/DatePrototype.h index 452fca295f..aaa63634bd 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.h @@ -15,11 +15,12 @@ class DatePrototype final : public PrototypeObject { JS_PROTOTYPE_OBJECT(DatePrototype, Date, Date); public: - explicit DatePrototype(Realm&); virtual void initialize(Realm&) override; virtual ~DatePrototype() override = default; private: + explicit DatePrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(get_date); JS_DECLARE_NATIVE_FUNCTION(get_day); JS_DECLARE_NATIVE_FUNCTION(get_full_year); diff --git a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.h b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.h index 8191663aba..0110f57d59 100644 --- a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.h +++ b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.h @@ -29,9 +29,6 @@ class DeclarativeEnvironment : public Environment { public: static DeclarativeEnvironment* create_for_per_iteration_bindings(Badge, DeclarativeEnvironment& other, size_t bindings_size); - DeclarativeEnvironment(); - explicit DeclarativeEnvironment(Environment* parent_environment); - explicit DeclarativeEnvironment(Environment* parent_environment, Span bindings); virtual ~DeclarativeEnvironment() override = default; virtual ThrowCompletionOr has_binding(FlyString const& name, Optional* = nullptr) const override; @@ -62,6 +59,10 @@ public: ThrowCompletionOr set_mutable_binding_direct(VM&, size_t index, Value, bool strict); protected: + DeclarativeEnvironment(); + explicit DeclarativeEnvironment(Environment* parent_environment); + DeclarativeEnvironment(Environment* parent_environment, Span bindings); + virtual void visit_edges(Visitor&) override; private: diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h index 29d7fcc5a7..038ab5f9c1 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h @@ -35,7 +35,6 @@ public: static ECMAScriptFunctionObject* create(Realm&, FlyString name, String source_text, Statement const& ecmascript_code, Vector parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant class_field_initializer_name = {}); static ECMAScriptFunctionObject* create(Realm&, FlyString name, Object& prototype, String source_text, Statement const& ecmascript_code, Vector parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant class_field_initializer_name = {}); - ECMAScriptFunctionObject(FlyString name, String source_text, Statement const& ecmascript_code, Vector parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant class_field_initializer_name); virtual void initialize(Realm&) override; virtual ~ECMAScriptFunctionObject() override = default; @@ -94,6 +93,8 @@ protected: virtual Completion ordinary_call_evaluate_body(); private: + ECMAScriptFunctionObject(FlyString name, String source_text, Statement const& ecmascript_code, Vector parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant class_field_initializer_name); + virtual bool is_ecmascript_function_object() const override { return true; } virtual void visit_edges(Visitor&) override; diff --git a/Userland/Libraries/LibJS/Runtime/Error.h b/Userland/Libraries/LibJS/Runtime/Error.h index 761dee42d4..74a16db8f5 100644 --- a/Userland/Libraries/LibJS/Runtime/Error.h +++ b/Userland/Libraries/LibJS/Runtime/Error.h @@ -26,7 +26,6 @@ public: static Error* create(Realm&); static Error* create(Realm&, String const& message); - explicit Error(Object& prototype); virtual ~Error() override = default; [[nodiscard]] String stack_string() const; @@ -35,6 +34,9 @@ public: Vector const& traceback() const { return m_traceback; } +protected: + explicit Error(Object& prototype); + private: void populate_stack(); Vector m_traceback; diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h index caaf3022e1..98d3bea32d 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h @@ -15,7 +15,6 @@ class ErrorConstructor final : public NativeFunction { JS_OBJECT(ErrorConstructor, NativeFunction); public: - explicit ErrorConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~ErrorConstructor() override = default; @@ -23,6 +22,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit ErrorConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; @@ -31,14 +32,18 @@ private: JS_OBJECT(ConstructorName, NativeFunction); \ \ public: \ - explicit ConstructorName(Realm&); \ virtual void initialize(Realm&) override; \ virtual ~ConstructorName() override; \ virtual ThrowCompletionOr call() override; \ virtual ThrowCompletionOr construct(FunctionObject& new_target) override; \ \ private: \ - virtual bool has_constructor() const override { return true; } \ + explicit ConstructorName(Realm&); \ + \ + virtual bool has_constructor() const override \ + { \ + return true; \ + } \ }; #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h index 285e786ec4..7be8d62fa4 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h @@ -16,11 +16,12 @@ class ErrorPrototype final : public PrototypeObject { JS_PROTOTYPE_OBJECT(ErrorPrototype, Error, Error); public: - explicit ErrorPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~ErrorPrototype() override = default; private: + explicit ErrorPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(to_string); JS_DECLARE_NATIVE_FUNCTION(stack_getter); JS_DECLARE_NATIVE_FUNCTION(stack_setter); @@ -31,9 +32,11 @@ private: JS_PROTOTYPE_OBJECT(PrototypeName, ClassName, ClassName); \ \ public: \ - explicit PrototypeName(Realm&); \ virtual void initialize(Realm&) override; \ virtual ~PrototypeName() override = default; \ + \ + private: \ + explicit PrototypeName(Realm&); \ }; #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h index 83903c4b1b..39a2573a3f 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h @@ -22,7 +22,6 @@ class FinalizationRegistry final JS_OBJECT(FinalizationRegistry, Object); public: - explicit FinalizationRegistry(Realm&, JobCallback, Object& prototype); virtual ~FinalizationRegistry() override = default; void add_finalization_record(Cell& target, Value held_value, Cell* unregister_token); @@ -38,6 +37,8 @@ public: JobCallback const& cleanup_callback() const { return m_cleanup_callback; } private: + FinalizationRegistry(Realm&, JobCallback, Object& prototype); + virtual void visit_edges(Visitor& visitor) override; Handle m_realm; diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h index 39c6c32649..d857c7bd4d 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h @@ -14,7 +14,6 @@ class FinalizationRegistryConstructor final : public NativeFunction { JS_OBJECT(FinalizationRegistryConstructor, NativeFunction); public: - explicit FinalizationRegistryConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~FinalizationRegistryConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject&) override; private: + explicit FinalizationRegistryConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h index 29f2aac192..a63e759ca7 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h @@ -15,11 +15,12 @@ class FinalizationRegistryPrototype final : public PrototypeObject create_dynamic_function(VM&, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector const& args); - explicit FunctionConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~FunctionConstructor() override = default; @@ -25,6 +24,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit FunctionConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.h b/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.h index 8501a75239..679b5908d0 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.h @@ -22,7 +22,6 @@ public: Uninitialized, }; - explicit FunctionEnvironment(Environment* parent_environment); virtual ~FunctionEnvironment() override = default; ThisBindingStatus this_binding_status() const { return m_this_binding_status; } @@ -47,6 +46,8 @@ public: ThrowCompletionOr bind_this_value(VM&, Value); private: + explicit FunctionEnvironment(Environment* parent_environment); + virtual bool is_function_environment() const override { return true; } virtual void visit_edges(Visitor&) override; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h index 91ce61e648..b9b1c92642 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h @@ -14,7 +14,6 @@ class FunctionPrototype final : public FunctionObject { JS_OBJECT(FunctionPrototype, FunctionObject); public: - explicit FunctionPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~FunctionPrototype() override = default; @@ -22,6 +21,8 @@ public: virtual FlyString const& name() const override { return m_name; } private: + explicit FunctionPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(apply); JS_DECLARE_NATIVE_FUNCTION(bind); JS_DECLARE_NATIVE_FUNCTION(call); diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h index 49a9af4649..d4bc8eca2a 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h @@ -15,7 +15,6 @@ class GeneratorFunctionConstructor final : public NativeFunction { JS_OBJECT(GeneratorFunctionConstructor, NativeFunction); public: - explicit GeneratorFunctionConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~GeneratorFunctionConstructor() override = default; @@ -23,6 +22,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit GeneratorFunctionConstructor(Realm&); + bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h index dedd61c4f1..84c3483458 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h @@ -16,9 +16,11 @@ class GeneratorFunctionPrototype final : public Object { JS_OBJECT(GeneratorFunctionPrototype, Object); public: - explicit GeneratorFunctionPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~GeneratorFunctionPrototype() override = default; + +private: + explicit GeneratorFunctionPrototype(Realm&); }; } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h index 9432f87805..3beb777ce1 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h @@ -17,7 +17,6 @@ class GeneratorObject final : public Object { public: static ThrowCompletionOr create(Realm&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::RegisterWindow); - GeneratorObject(Realm&, Object& prototype, ExecutionContext); virtual void initialize(Realm&) override; virtual ~GeneratorObject() override = default; void visit_edges(Cell::Visitor&) override; @@ -26,6 +25,8 @@ public: void set_done() { m_done = true; } private: + GeneratorObject(Realm&, Object& prototype, ExecutionContext); + ExecutionContext m_execution_context; ECMAScriptFunctionObject* m_generating_function { nullptr }; Value m_previous_value; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h index 1272c202f4..079e76c5ca 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h @@ -16,11 +16,12 @@ class GeneratorPrototype final : public PrototypeObject get_this_binding(VM&) const final; @@ -40,6 +38,8 @@ public: ThrowCompletionOr create_global_function_binding(FlyString const& name, Value, bool can_be_deleted); private: + GlobalEnvironment(Object&, Object& this_value); + virtual bool is_global_environment() const override { return true; } virtual void visit_edges(Visitor&) override; diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.h b/Userland/Libraries/LibJS/Runtime/GlobalObject.h index 7fc1a24ab9..c40a1f8296 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h @@ -19,10 +19,12 @@ class GlobalObject : public Object { friend class Intrinsics; public: - explicit GlobalObject(Realm&); virtual void initialize(Realm&) override; virtual ~GlobalObject() override; +protected: + explicit GlobalObject(Realm&); + private: virtual bool is_global_object() const final { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Collator.h b/Userland/Libraries/LibJS/Runtime/Intl/Collator.h index 40f61f45d1..bd319bc801 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Collator.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/Collator.h @@ -43,7 +43,6 @@ public: return AK::Array { "co"sv, "kf"sv, "kn"sv }; } - explicit Collator(Object& prototype); virtual ~Collator() override = default; String const& locale() const { return m_locale; } @@ -74,6 +73,8 @@ public: void set_bound_compare(CollatorCompareFunction* bound_compare) { m_bound_compare = bound_compare; } private: + explicit Collator(Object& prototype); + virtual void visit_edges(Visitor&) override; String m_locale; // [[Locale]] diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h index 0bab632a37..3bdbc5dd6b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h @@ -16,13 +16,14 @@ class CollatorCompareFunction : public NativeFunction { public: static CollatorCompareFunction* create(Realm&, Collator&); - CollatorCompareFunction(Realm&, Collator&); virtual void initialize(Realm&) override; virtual ~CollatorCompareFunction() override = default; virtual ThrowCompletionOr call() override; private: + CollatorCompareFunction(Realm&, Collator&); + virtual void visit_edges(Visitor&) override; Collator& m_collator; // [[Collator]] diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h index 778c817ce1..240122823e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h @@ -14,7 +14,6 @@ class CollatorConstructor final : public NativeFunction { JS_OBJECT(CollatorConstructor, NativeFunction); public: - explicit CollatorConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~CollatorConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit CollatorConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(supported_locales_of); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h index 42daa2e02d..f65e6d2f77 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h @@ -15,11 +15,12 @@ class CollatorPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit DateTimeFormatConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(supported_locales_of); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.h index ece66beeec..d11669b8c7 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.h @@ -18,13 +18,14 @@ class DateTimeFormatFunction final : public NativeFunction { public: static DateTimeFormatFunction* create(Realm&, DateTimeFormat&); - explicit DateTimeFormatFunction(DateTimeFormat&, Object& prototype); virtual ~DateTimeFormatFunction() override = default; virtual void initialize(Realm&) override; virtual ThrowCompletionOr call() override; private: + explicit DateTimeFormatFunction(DateTimeFormat&, Object& prototype); + virtual void visit_edges(Visitor&) override; DateTimeFormat& m_date_time_format; // [[DateTimeFormat]] diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h index bb925b7f98..c72a7bcae3 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h @@ -15,11 +15,12 @@ class DateTimeFormatPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit DisplayNamesConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(supported_locales_of); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h index 77f82674ae..57bb97f0c3 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h @@ -15,11 +15,12 @@ class DisplayNamesPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit DurationFormatConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(supported_locales_of); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h index a12677db6b..d10942cddf 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h @@ -15,11 +15,12 @@ class DurationFormatPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit ListFormatConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(supported_locales_of); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h index bb9cde718f..74d5fe3714 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h @@ -15,11 +15,12 @@ class ListFormatPrototype final : public PrototypeObject m_calendar; // [[Calendar]] Optional m_case_first; // [[CaseFirst]] diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h index e10856c295..d4524696cc 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h @@ -14,7 +14,6 @@ class LocaleConstructor final : public NativeFunction { JS_OBJECT(LocaleConstructor, NativeFunction); public: - explicit LocaleConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~LocaleConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit LocaleConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h index e84025fafd..03078adbfb 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h @@ -15,11 +15,12 @@ class LocalePrototype final : public PrototypeObject { JS_PROTOTYPE_OBJECT(LocalePrototype, Locale, Intl.Locale); public: - explicit LocalePrototype(Realm&); virtual void initialize(Realm&) override; virtual ~LocalePrototype() override = default; private: + explicit LocalePrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(maximize); JS_DECLARE_NATIVE_FUNCTION(minimize); JS_DECLARE_NATIVE_FUNCTION(to_string); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.h index bedfd31cba..921f6db79c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.h @@ -56,7 +56,6 @@ public: StripIfInteger, }; - NumberFormatBase(Object& prototype); virtual ~NumberFormatBase() override = default; String const& locale() const { return m_locale; } @@ -99,6 +98,9 @@ public: StringView trailing_zero_display_string() const; void set_trailing_zero_display(StringView trailing_zero_display); +protected: + explicit NumberFormatBase(Object& prototype); + private: String m_locale; // [[Locale]] String m_data_locale; // [[DataLocale]] @@ -174,7 +176,6 @@ public: return AK::Array { "nu"sv }; } - NumberFormat(Object& prototype); virtual ~NumberFormat() override = default; String const& numbering_system() const { return m_numbering_system; } @@ -233,6 +234,8 @@ public: Unicode::NumberFormat compact_format() const { return *m_compact_format; } private: + explicit NumberFormat(Object& prototype); + virtual void visit_edges(Visitor&) override; String m_locale; // [[Locale]] diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h index 4d88eec5ff..ebe3bd603f 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h @@ -15,7 +15,6 @@ class NumberFormatConstructor final : public NativeFunction { JS_OBJECT(NumberFormatConstructor, NativeFunction); public: - explicit NumberFormatConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~NumberFormatConstructor() override = default; @@ -23,6 +22,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit NumberFormatConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(supported_locales_of); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.h index d562ca5c07..7ea30be9fc 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.h @@ -18,13 +18,14 @@ class NumberFormatFunction final : public NativeFunction { public: static NumberFormatFunction* create(Realm&, NumberFormat&); - explicit NumberFormatFunction(NumberFormat&, Object& prototype); virtual ~NumberFormatFunction() override = default; virtual void initialize(Realm&) override; virtual ThrowCompletionOr call() override; private: + explicit NumberFormatFunction(NumberFormat&, Object& prototype); + virtual void visit_edges(Visitor&) override; NumberFormat& m_number_format; // [[NumberFormat]] diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h index 85e33daec9..4f5740662a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h @@ -15,11 +15,12 @@ class NumberFormatPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit PluralRulesConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(supported_locales_of); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h index 35d794f401..5c48fa106e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h @@ -15,11 +15,12 @@ class PluralRulesPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit RelativeTimeFormatConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(supported_locales_of); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h index e7d40f780e..4012ed2184 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h @@ -15,11 +15,12 @@ class RelativeTimeFormatPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit SegmenterConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(supported_locales_of); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h index 4f1942a055..672318f1cf 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h @@ -15,11 +15,12 @@ class SegmenterPrototype final : public PrototypeObject>& boundaries_cache() const { return m_boundaries_cache; } private: + Segments(Realm&, Segmenter&, Utf16String); + virtual void visit_edges(Cell::Visitor&) override; Segmenter& m_segments_segmenter; // [[SegmentsSegmenter]] diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h index 142c294c10..24ca244130 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h @@ -15,11 +15,12 @@ class SegmentsPrototype final : public PrototypeObject seen_objects; diff --git a/Userland/Libraries/LibJS/Runtime/Map.h b/Userland/Libraries/LibJS/Runtime/Map.h index 6cdef237b1..eed8cc4490 100644 --- a/Userland/Libraries/LibJS/Runtime/Map.h +++ b/Userland/Libraries/LibJS/Runtime/Map.h @@ -19,10 +19,12 @@ namespace JS { class Map : public Object { JS_OBJECT(Map, Object); + // NOTE: This awkwardness is due to Set using a Map internally. + friend class Set; + public: static Map* create(Realm&); - explicit Map(Object& prototype); virtual ~Map() override = default; void map_clear(); @@ -106,6 +108,7 @@ public: EndIterator end() const { return {}; } private: + explicit Map(Object& prototype); virtual void visit_edges(Visitor& visitor) override; size_t m_next_insertion_id { 0 }; diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.h b/Userland/Libraries/LibJS/Runtime/MapConstructor.h index ecf044339c..ed4d6c8ffc 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.h @@ -14,7 +14,6 @@ class MapConstructor final : public NativeFunction { JS_OBJECT(MapConstructor, NativeFunction); public: - explicit MapConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~MapConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject&) override; private: + explicit MapConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(symbol_species_getter); diff --git a/Userland/Libraries/LibJS/Runtime/MapIterator.h b/Userland/Libraries/LibJS/Runtime/MapIterator.h index 676f46c7d3..54641fa2ca 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIterator.h +++ b/Userland/Libraries/LibJS/Runtime/MapIterator.h @@ -18,7 +18,6 @@ class MapIterator final : public Object { public: static MapIterator* create(Realm&, Map& map, Object::PropertyKind iteration_kind); - explicit MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype); virtual ~MapIterator() override = default; Map& map() const { return m_map; } @@ -28,6 +27,8 @@ public: private: friend class MapIteratorPrototype; + explicit MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype); + virtual void visit_edges(Cell::Visitor&) override; Map& m_map; diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h index 4aaf071e01..5f1e1db3c7 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h @@ -15,11 +15,12 @@ class MapIteratorPrototype final : public PrototypeObject { JS_PROTOTYPE_OBJECT(MapPrototype, Map, Map); public: - MapPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~MapPrototype() override = default; private: + explicit MapPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(clear); JS_DECLARE_NATIVE_FUNCTION(delete_); JS_DECLARE_NATIVE_FUNCTION(entries); diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.h b/Userland/Libraries/LibJS/Runtime/MathObject.h index 5208e96d1f..a7253a5ba9 100644 --- a/Userland/Libraries/LibJS/Runtime/MathObject.h +++ b/Userland/Libraries/LibJS/Runtime/MathObject.h @@ -14,11 +14,12 @@ class MathObject final : public Object { JS_OBJECT(MathObject, Object); public: - explicit MathObject(Realm&); virtual void initialize(Realm&) override; virtual ~MathObject() override = default; private: + explicit MathObject(Realm&); + JS_DECLARE_NATIVE_FUNCTION(abs); JS_DECLARE_NATIVE_FUNCTION(random); JS_DECLARE_NATIVE_FUNCTION(sqrt); diff --git a/Userland/Libraries/LibJS/Runtime/ModuleEnvironment.h b/Userland/Libraries/LibJS/Runtime/ModuleEnvironment.h index 8670a915df..6b1b13e3f3 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleEnvironment.h +++ b/Userland/Libraries/LibJS/Runtime/ModuleEnvironment.h @@ -17,8 +17,6 @@ class ModuleEnvironment final : public DeclarativeEnvironment { JS_ENVIRONMENT(ModuleEnvironment, DeclarativeEnvironment); public: - ModuleEnvironment(Environment* outer_environment); - // Note: Module Environment Records support all of the declarative Environment Record methods listed // in Table 18 and share the same specifications for all of those methods except for // GetBindingValue, DeleteBinding, HasThisBinding and GetThisBinding. @@ -36,6 +34,8 @@ public: virtual ThrowCompletionOr has_binding(FlyString const& name, Optional* = nullptr) const override; private: + explicit ModuleEnvironment(Environment* outer_environment); + struct IndirectBinding { FlyString name; Module* module; diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h index 676e67a8c8..8c72cfd436 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h +++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h @@ -16,8 +16,6 @@ class ModuleNamespaceObject final : public Object { JS_OBJECT(ModuleNamespaceObject, Object); public: - ModuleNamespaceObject(Realm&, Module* module, Vector exports); - // 10.4.6 Module Namespace Exotic Objects, https://tc39.es/ecma262/#sec-module-namespace-exotic-objects virtual ThrowCompletionOr internal_get_prototype_of() const override; @@ -34,6 +32,8 @@ public: virtual void initialize(Realm&) override; private: + ModuleNamespaceObject(Realm&, Module* module, Vector exports); + // FIXME: UHHH how do we want to store this to avoid cycles but be safe?? Module* m_module; // [[Module]] Vector m_exports; // [[Exports]] diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.h b/Userland/Libraries/LibJS/Runtime/NativeFunction.h index a96517f7ed..510a255d42 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.h @@ -23,8 +23,6 @@ public: static NativeFunction* create(Realm&, Function(VM&)> behaviour, i32 length, PropertyKey const& name, Optional = {}, Optional prototype = {}, Optional const& prefix = {}); static NativeFunction* create(Realm&, FlyString const& name, Function(VM&)>); - NativeFunction(Function(VM&)>, Object* prototype, Realm& realm); - NativeFunction(FlyString name, Function(VM&)>, Object& prototype); virtual void initialize(Realm&) override { } virtual ~NativeFunction() override = default; @@ -46,6 +44,8 @@ public: protected: NativeFunction(FlyString name, Object& prototype); + NativeFunction(Function(VM&)>, Object* prototype, Realm& realm); + NativeFunction(FlyString name, Function(VM&)>, Object& prototype); explicit NativeFunction(Object& prototype); private: diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h index 1d2f765f38..e523bafcbe 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h @@ -14,7 +14,6 @@ class NumberConstructor final : public NativeFunction { JS_OBJECT(NumberConstructor, NativeFunction); public: - explicit NumberConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~NumberConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit NumberConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(is_finite); diff --git a/Userland/Libraries/LibJS/Runtime/NumberObject.h b/Userland/Libraries/LibJS/Runtime/NumberObject.h index 16fd7fd2d9..ceaeb29e62 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberObject.h +++ b/Userland/Libraries/LibJS/Runtime/NumberObject.h @@ -16,11 +16,13 @@ class NumberObject : public Object { public: static NumberObject* create(Realm&, double); - NumberObject(double, Object& prototype); virtual ~NumberObject() override = default; double number() const { return m_value; } +protected: + NumberObject(double, Object& prototype); + private: double m_value { 0 }; }; diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.h b/Userland/Libraries/LibJS/Runtime/NumberPrototype.h index e4819f5073..22139df606 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.h @@ -14,7 +14,6 @@ class NumberPrototype final : public NumberObject { JS_OBJECT(NumberPrototype, NumberObject); public: - explicit NumberPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~NumberPrototype() override = default; @@ -24,6 +23,9 @@ public: JS_DECLARE_NATIVE_FUNCTION(to_precision); JS_DECLARE_NATIVE_FUNCTION(to_string); JS_DECLARE_NATIVE_FUNCTION(value_of); + +private: + explicit NumberPrototype(Realm&); }; } diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index a2a1ebec7a..6498ca841a 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -45,9 +45,6 @@ class Object : public Cell { public: static Object* create(Realm&, Object* prototype); - Object(Realm&, Object* prototype); - explicit Object(Object& prototype); - explicit Object(Shape&); virtual void initialize(Realm&) override; virtual ~Object() = default; @@ -189,8 +186,12 @@ public: protected: enum class GlobalObjectTag { Tag }; enum class ConstructWithoutPrototypeTag { Tag }; + Object(GlobalObjectTag, Realm&); Object(ConstructWithoutPrototypeTag, Realm&); + Object(Realm&, Object* prototype); + explicit Object(Object& prototype); + explicit Object(Shape&); void set_prototype(Object*); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h index 41ece30cea..58b731fc7f 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h @@ -15,7 +15,6 @@ class ObjectConstructor final : public NativeFunction { JS_OBJECT(ObjectConstructor, NativeFunction); public: - explicit ObjectConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~ObjectConstructor() override = default; @@ -23,6 +22,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit ObjectConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(define_property); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.h b/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.h index ec5fa7dae5..813a711ccd 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.h @@ -18,7 +18,6 @@ public: No, Yes, }; - ObjectEnvironment(Object& binding_object, IsWithEnvironment, Environment* outer_environment); virtual ThrowCompletionOr has_binding(FlyString const& name, Optional* = nullptr) const override; virtual ThrowCompletionOr create_mutable_binding(VM&, FlyString const& name, bool can_be_deleted) override; @@ -43,6 +42,8 @@ public: bool is_with_environment() const { return m_with_environment; } private: + ObjectEnvironment(Object& binding_object, IsWithEnvironment, Environment* outer_environment); + virtual void visit_edges(Visitor&) override; Object& m_binding_object; diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h index b4f31184b6..abb3a4976c 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h @@ -15,7 +15,6 @@ class ObjectPrototype final : public Object { JS_OBJECT(ObjectPrototype, Object); public: - explicit ObjectPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~ObjectPrototype() override = default; @@ -27,6 +26,8 @@ public: JS_DECLARE_NATIVE_FUNCTION(to_string); private: + explicit ObjectPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(has_own_property); JS_DECLARE_NATIVE_FUNCTION(to_locale_string); JS_DECLARE_NATIVE_FUNCTION(value_of); diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h index 755946479d..768034fe62 100644 --- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h +++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h @@ -19,9 +19,6 @@ class PrimitiveString final : public Cell { JS_CELL(PrimitiveString, Cell); public: - explicit PrimitiveString(PrimitiveString&, PrimitiveString&); - explicit PrimitiveString(String); - explicit PrimitiveString(Utf16String); virtual ~PrimitiveString(); PrimitiveString(PrimitiveString const&) = delete; @@ -39,6 +36,10 @@ public: Optional get(VM&, PropertyKey const&) const; private: + explicit PrimitiveString(PrimitiveString&, PrimitiveString&); + explicit PrimitiveString(String); + explicit PrimitiveString(Utf16String); + virtual void visit_edges(Cell::Visitor&) override; void resolve_rope_if_needed() const; diff --git a/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h b/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h index 5bdedd41e5..f9c6d07b05 100644 --- a/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h +++ b/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h @@ -31,13 +31,13 @@ class PrivateEnvironment : public Cell { JS_CELL(PrivateEnvironment, Cell); public: - explicit PrivateEnvironment(PrivateEnvironment* parent); - PrivateName resolve_private_identifier(FlyString const& identifier) const; void add_private_name(Badge, FlyString description); private: + explicit PrivateEnvironment(PrivateEnvironment* parent); + virtual void visit_edges(Visitor&) override; auto find_private_name(FlyString const& description) const diff --git a/Userland/Libraries/LibJS/Runtime/Promise.h b/Userland/Libraries/LibJS/Runtime/Promise.h index 2a3bf7e917..a4ef47c143 100644 --- a/Userland/Libraries/LibJS/Runtime/Promise.h +++ b/Userland/Libraries/LibJS/Runtime/Promise.h @@ -29,7 +29,6 @@ public: static Promise* create(Realm&); - explicit Promise(Object& prototype); virtual ~Promise() = default; State state() const { return m_state; } @@ -48,6 +47,8 @@ public: bool is_handled() const { return m_is_handled; } protected: + explicit Promise(Object& prototype); + virtual void visit_edges(Visitor&) override; private: diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h index 73ba53eff0..3780ed9b1e 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h @@ -14,7 +14,6 @@ class PromiseConstructor final : public NativeFunction { JS_OBJECT(PromiseConstructor, NativeFunction); public: - explicit PromiseConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~PromiseConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit PromiseConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(all); diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.h b/Userland/Libraries/LibJS/Runtime/PromisePrototype.h index e8e6c8cd15..9fc359d8cf 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.h @@ -14,11 +14,12 @@ class PromisePrototype final : public PrototypeObject JS_PROTOTYPE_OBJECT(PromisePrototype, Promise, Promise); public: - PromisePrototype(Realm&); virtual void initialize(Realm&) override; virtual ~PromisePrototype() override = default; private: + PromisePrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(then); JS_DECLARE_NATIVE_FUNCTION(catch_); JS_DECLARE_NATIVE_FUNCTION(finally); diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h index 2797766640..966d22094f 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h @@ -78,7 +78,6 @@ public: return vm.heap().allocate_without_realm(type, capability, move(handler)); } - PromiseReaction(Type type, Optional capability, Optional handler); virtual ~PromiseReaction() = default; Type type() const { return m_type; } @@ -88,6 +87,8 @@ public: Optional const& handler() const { return m_handler; } private: + PromiseReaction(Type type, Optional capability, Optional handler); + virtual void visit_edges(Visitor&) override; Type m_type; diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h index 56c2154601..d878d7612f 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h @@ -15,28 +15,27 @@ namespace JS { struct RemainingElements final : public Cell { JS_CELL(RemainingElements, Cell); + u64 value { 0 }; + +private: RemainingElements() = default; explicit RemainingElements(u64 initial_value) : value(initial_value) { } - - u64 value { 0 }; }; class PromiseValueList final : public Cell { JS_CELL(PromiseValueList, Cell); public: - PromiseValueList() - { - } - Vector& values() { return m_values; } Vector const& values() const { return m_values; } private: + PromiseValueList() = default; + virtual void visit_edges(Visitor&) override; Vector m_values; @@ -74,10 +73,11 @@ class PromiseAllResolveElementFunction final : public PromiseResolvingElementFun public: static PromiseAllResolveElementFunction* create(Realm&, size_t, PromiseValueList&, PromiseCapability, RemainingElements&); - explicit PromiseAllResolveElementFunction(size_t, PromiseValueList&, PromiseCapability, RemainingElements&, Object& prototype); virtual ~PromiseAllResolveElementFunction() override = default; private: + explicit PromiseAllResolveElementFunction(size_t, PromiseValueList&, PromiseCapability, RemainingElements&, Object& prototype); + virtual ThrowCompletionOr resolve_element() override; }; @@ -88,10 +88,11 @@ class PromiseAllSettledResolveElementFunction final : public PromiseResolvingEle public: static PromiseAllSettledResolveElementFunction* create(Realm&, size_t, PromiseValueList&, PromiseCapability, RemainingElements&); - explicit PromiseAllSettledResolveElementFunction(size_t, PromiseValueList&, PromiseCapability, RemainingElements&, Object& prototype); virtual ~PromiseAllSettledResolveElementFunction() override = default; private: + explicit PromiseAllSettledResolveElementFunction(size_t, PromiseValueList&, PromiseCapability, RemainingElements&, Object& prototype); + virtual ThrowCompletionOr resolve_element() override; }; @@ -102,10 +103,11 @@ class PromiseAllSettledRejectElementFunction final : public PromiseResolvingElem public: static PromiseAllSettledRejectElementFunction* create(Realm&, size_t, PromiseValueList&, PromiseCapability, RemainingElements&); - explicit PromiseAllSettledRejectElementFunction(size_t, PromiseValueList&, PromiseCapability, RemainingElements&, Object& prototype); virtual ~PromiseAllSettledRejectElementFunction() override = default; private: + explicit PromiseAllSettledRejectElementFunction(size_t, PromiseValueList&, PromiseCapability, RemainingElements&, Object& prototype); + virtual ThrowCompletionOr resolve_element() override; }; @@ -116,10 +118,11 @@ class PromiseAnyRejectElementFunction final : public PromiseResolvingElementFunc public: static PromiseAnyRejectElementFunction* create(Realm&, size_t, PromiseValueList&, PromiseCapability, RemainingElements&); - explicit PromiseAnyRejectElementFunction(size_t, PromiseValueList&, PromiseCapability, RemainingElements&, Object& prototype); virtual ~PromiseAnyRejectElementFunction() override = default; private: + explicit PromiseAnyRejectElementFunction(size_t, PromiseValueList&, PromiseCapability, RemainingElements&, Object& prototype); + virtual ThrowCompletionOr resolve_element() override; }; diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h index 759b9be6b8..46ad433f36 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h @@ -30,13 +30,14 @@ public: static PromiseResolvingFunction* create(Realm&, Promise&, AlreadyResolved&, FunctionType); - explicit PromiseResolvingFunction(Promise&, AlreadyResolved&, FunctionType, Object& prototype); virtual void initialize(Realm&) override; virtual ~PromiseResolvingFunction() override = default; virtual ThrowCompletionOr call() override; private: + explicit PromiseResolvingFunction(Promise&, AlreadyResolved&, FunctionType, Object& prototype); + virtual void visit_edges(Visitor&) override; Promise& m_promise; diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h index 81bdbdd9ae..8cdb0cd677 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h @@ -15,7 +15,6 @@ class ProxyConstructor final : public NativeFunction { JS_OBJECT(ProxyConstructor, NativeFunction); public: - explicit ProxyConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~ProxyConstructor() override = default; @@ -23,6 +22,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit ProxyConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(revocable); diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.h b/Userland/Libraries/LibJS/Runtime/ProxyObject.h index b6c228641a..c7ac85170b 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.h @@ -18,7 +18,6 @@ class ProxyObject final : public FunctionObject { public: static ProxyObject* create(Realm&, Object& target, Object& handler); - ProxyObject(Object& target, Object& handler, Object& prototype); virtual ~ProxyObject() override = default; virtual FlyString const& name() const override; @@ -47,6 +46,8 @@ public: virtual ThrowCompletionOr internal_construct(MarkedVector arguments_list, FunctionObject& new_target) override; private: + ProxyObject(Object& target, Object& handler, Object& prototype); + virtual void visit_edges(Visitor&) override; virtual bool is_function() const override { return m_target.is_function(); } diff --git a/Userland/Libraries/LibJS/Runtime/Realm.h b/Userland/Libraries/LibJS/Runtime/Realm.h index d1f4fecd73..5d699af5ff 100644 --- a/Userland/Libraries/LibJS/Runtime/Realm.h +++ b/Userland/Libraries/LibJS/Runtime/Realm.h @@ -27,8 +27,6 @@ public: virtual ~HostDefined() = default; }; - Realm() = default; - static Realm* create(VM&); static ThrowCompletionOr> initialize_host_defined_realm(VM&, Function create_global_object, Function create_global_this_value); @@ -49,6 +47,8 @@ public: void set_host_defined(OwnPtr host_defined) { m_host_defined = move(host_defined); } private: + Realm() = default; + virtual void visit_edges(Visitor&) override; Intrinsics* m_intrinsics { nullptr }; // [[Intrinsics]] diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.h b/Userland/Libraries/LibJS/Runtime/ReflectObject.h index 53e40c319d..4f0058e930 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.h +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.h @@ -14,11 +14,12 @@ class ReflectObject final : public Object { JS_OBJECT(ReflectObject, Object); public: - explicit ReflectObject(Realm&); virtual void initialize(Realm&) override; virtual ~ReflectObject() override = default; private: + explicit ReflectObject(Realm&); + JS_DECLARE_NATIVE_FUNCTION(apply); JS_DECLARE_NATIVE_FUNCTION(construct); JS_DECLARE_NATIVE_FUNCTION(define_property); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h index 543fea86f1..2d182ac041 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h @@ -14,7 +14,6 @@ class RegExpConstructor final : public NativeFunction { JS_OBJECT(RegExpConstructor, NativeFunction); public: - explicit RegExpConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~RegExpConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit RegExpConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(symbol_species_getter); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.h b/Userland/Libraries/LibJS/Runtime/RegExpObject.h index e90d26da00..3865a0b775 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.h @@ -39,9 +39,6 @@ public: static RegExpObject* create(Realm&); static RegExpObject* create(Realm&, Regex regex, String pattern, String flags); - RegExpObject(Object& prototype); - RegExpObject(Regex regex, String pattern, String flags, Object& prototype); - ThrowCompletionOr regexp_initialize(VM&, Value pattern, Value flags); String escape_regexp_pattern() const; @@ -54,6 +51,9 @@ public: Regex const& regex() const { return *m_regex; } private: + RegExpObject(Object& prototype); + RegExpObject(Regex regex, String pattern, String flags, Object& prototype); + String m_pattern; String m_flags; Optional> m_regex; diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h index 4eea613c89..69bbb6b14e 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h @@ -19,11 +19,12 @@ class RegExpPrototype final : public PrototypeObject construct(FunctionObject&) override; private: + explicit SetConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(symbol_species_getter); diff --git a/Userland/Libraries/LibJS/Runtime/SetIterator.h b/Userland/Libraries/LibJS/Runtime/SetIterator.h index 8b077c7f51..9caef615b3 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIterator.h +++ b/Userland/Libraries/LibJS/Runtime/SetIterator.h @@ -18,7 +18,6 @@ class SetIterator final : public Object { public: static SetIterator* create(Realm&, Set& set, Object::PropertyKind iteration_kind); - explicit SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype); virtual ~SetIterator() override = default; Set& set() const { return m_set; } @@ -28,6 +27,8 @@ public: private: friend class SetIteratorPrototype; + explicit SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype); + virtual void visit_edges(Cell::Visitor&) override; Set& m_set; diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h index e50c00484a..4bf9e6b85b 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h @@ -15,11 +15,12 @@ class SetIteratorPrototype final : public PrototypeObject { JS_PROTOTYPE_OBJECT(SetPrototype, Set, Set); public: - SetPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~SetPrototype() override = default; private: + explicit SetPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(add); JS_DECLARE_NATIVE_FUNCTION(clear); JS_DECLARE_NATIVE_FUNCTION(delete_); diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealm.h b/Userland/Libraries/LibJS/Runtime/ShadowRealm.h index d0ad14d8e2..f355d3f700 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealm.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealm.h @@ -17,7 +17,6 @@ class ShadowRealm final : public Object { JS_OBJECT(ShadowRealm, Object); public: - ShadowRealm(Realm&, ExecutionContext, Object& prototype); virtual ~ShadowRealm() override = default; [[nodiscard]] Realm const& shadow_realm() const { return m_shadow_realm; } @@ -26,6 +25,8 @@ public: [[nodiscard]] ExecutionContext& execution_context() { return m_execution_context; } private: + ShadowRealm(Realm&, ExecutionContext, Object& prototype); + virtual void visit_edges(Visitor&) override; // 3.5 Properties of ShadowRealm Instances, https://tc39.es/proposal-shadowrealm/#sec-properties-of-shadowrealm-instances diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h index f489dbaac7..a5c8dd5a1f 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h @@ -14,7 +14,6 @@ class ShadowRealmConstructor final : public NativeFunction { JS_OBJECT(ShadowRealmConstructor, NativeFunction); public: - explicit ShadowRealmConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~ShadowRealmConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit ShadowRealmConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h index e0b9f99250..6e85ad4089 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h @@ -15,11 +15,12 @@ class ShadowRealmPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit StringConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(raw); diff --git a/Userland/Libraries/LibJS/Runtime/StringIterator.h b/Userland/Libraries/LibJS/Runtime/StringIterator.h index fead3dd09b..4760cd73b2 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIterator.h +++ b/Userland/Libraries/LibJS/Runtime/StringIterator.h @@ -17,13 +17,14 @@ class StringIterator final : public Object { public: static StringIterator* create(Realm&, String string); - explicit StringIterator(String string, Object& prototype); virtual ~StringIterator() override = default; Utf8CodePointIterator& iterator() { return m_iterator; } bool done() const { return m_done; } private: + explicit StringIterator(String string, Object& prototype); + friend class StringIteratorPrototype; String m_string; diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h index 75089f3365..3c7720786b 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h @@ -16,11 +16,12 @@ class StringIteratorPrototype final : public PrototypeObject> internal_get_own_property(PropertyKey const&) const override; virtual ThrowCompletionOr internal_define_own_property(PropertyKey const&, PropertyDescriptor const&) override; diff --git a/Userland/Libraries/LibJS/Runtime/Symbol.h b/Userland/Libraries/LibJS/Runtime/Symbol.h index 4fd640370e..3cde01bd1b 100644 --- a/Userland/Libraries/LibJS/Runtime/Symbol.h +++ b/Userland/Libraries/LibJS/Runtime/Symbol.h @@ -18,7 +18,6 @@ class Symbol final : public Cell { AK_MAKE_NONMOVABLE(Symbol); public: - Symbol(Optional, bool); virtual ~Symbol() = default; String description() const { return m_description.value_or(""); } @@ -27,6 +26,8 @@ public: String to_string() const { return String::formatted("Symbol({})", description()); } private: + Symbol(Optional, bool); + Optional m_description; bool m_is_global; }; diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h index 2d27b474ab..93b6bbf625 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h @@ -14,7 +14,6 @@ class SymbolConstructor final : public NativeFunction { JS_OBJECT(SymbolConstructor, NativeFunction); public: - explicit SymbolConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~SymbolConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit SymbolConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(for_); diff --git a/Userland/Libraries/LibJS/Runtime/SymbolObject.h b/Userland/Libraries/LibJS/Runtime/SymbolObject.h index bf04e5a09b..7bbe829034 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolObject.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolObject.h @@ -17,7 +17,6 @@ class SymbolObject : public Object { public: static SymbolObject* create(Realm&, Symbol&); - SymbolObject(Symbol&, Object& prototype); virtual ~SymbolObject() override = default; Symbol& primitive_symbol() { return m_symbol; } @@ -27,6 +26,8 @@ public: bool is_global() const { return m_symbol.is_global(); } private: + SymbolObject(Symbol&, Object& prototype); + virtual void visit_edges(Visitor&) override; Symbol& m_symbol; diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h index d445ddaa85..9f0bd4e8eb 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h @@ -14,11 +14,12 @@ class SymbolPrototype final : public Object { JS_OBJECT(SymbolPrototype, Object); public: - explicit SymbolPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~SymbolPrototype() override = default; private: + explicit SymbolPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(description_getter); JS_DECLARE_NATIVE_FUNCTION(to_string); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h index 50b98e5936..69f158e8e4 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h @@ -20,12 +20,13 @@ class Calendar final : public Object { JS_OBJECT(Calendar, Object); public: - Calendar(String identifier, Object& prototype); virtual ~Calendar() override = default; [[nodiscard]] String const& identifier() const { return m_identifier; } private: + Calendar(String identifier, Object& prototype); + // 12.5 Properties of Temporal.Calendar Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-calendar-instances String m_identifier; // [[Identifier]] }; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h index 9bf8ed4125..dfe868740f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h @@ -14,7 +14,6 @@ class CalendarConstructor final : public NativeFunction { JS_OBJECT(CalendarConstructor, NativeFunction); public: - explicit CalendarConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~CalendarConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit CalendarConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h index 79b4ef726d..317c7ee426 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h @@ -15,11 +15,12 @@ class CalendarPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit DurationConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h index 69acdc3c48..07996aa841 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h @@ -15,11 +15,12 @@ class DurationPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit InstantConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h index 14b448c269..80899bd45d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h @@ -15,11 +15,12 @@ class InstantPrototype final : public PrototypeObject JS_PROTOTYPE_OBJECT(InstantPrototype, Instant, Temporal.Instant); public: - explicit InstantPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~InstantPrototype() override = default; private: + explicit InstantPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(epoch_seconds_getter); JS_DECLARE_NATIVE_FUNCTION(epoch_milliseconds_getter); JS_DECLARE_NATIVE_FUNCTION(epoch_microseconds_getter); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.h b/Userland/Libraries/LibJS/Runtime/Temporal/Now.h index fe4e358218..c6821b5c43 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.h @@ -15,11 +15,12 @@ class Now final : public Object { JS_OBJECT(Now, Object); public: - explicit Now(Realm&); virtual void initialize(Realm&) override; virtual ~Now() override = default; private: + explicit Now(Realm&); + JS_DECLARE_NATIVE_FUNCTION(time_zone); JS_DECLARE_NATIVE_FUNCTION(instant); JS_DECLARE_NATIVE_FUNCTION(plain_date_time); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h index 9cc63ca7f5..b26b104808 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h @@ -18,7 +18,6 @@ class PlainDate final : public Object { JS_OBJECT(PlainDate, Object); public: - PlainDate(i32 iso_year, u8 iso_month, u8 iso_day, Object& calendar, Object& prototype); virtual ~PlainDate() override = default; [[nodiscard]] i32 iso_year() const { return m_iso_year; } @@ -28,6 +27,8 @@ public: [[nodiscard]] Object& calendar() { return m_calendar; } private: + PlainDate(i32 iso_year, u8 iso_month, u8 iso_day, Object& calendar, Object& prototype); + virtual void visit_edges(Visitor&) override; // 3.4 Properties of Temporal.PlainDate Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-plaindate-instances diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h index 05df5e88ce..57c9b09bd0 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h @@ -14,7 +14,6 @@ class PlainDateConstructor final : public NativeFunction { JS_OBJECT(PlainDateConstructor, NativeFunction); public: - explicit PlainDateConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~PlainDateConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit PlainDateConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h index 058d8339f1..6ffb2dcda2 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h @@ -15,11 +15,12 @@ class PlainDatePrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit PlainDateTimeConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h index 23f4a1caa2..f290e18f39 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h @@ -15,11 +15,12 @@ class PlainDateTimePrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit PlainMonthDayConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h index 80629771bf..c20cf81468 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h @@ -15,11 +15,12 @@ class PlainMonthDayPrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit PlainTimeConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h index 1445243864..00bdbf5423 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h @@ -15,11 +15,12 @@ class PlainTimePrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit PlainYearMonthConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h index 4fbeb5c01c..3e987a077d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h @@ -15,11 +15,12 @@ class PlainYearMonthPrototype final : public PrototypeObject m_offset_nanoseconds; // [[OffsetNanoseconds]] diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h index ba1481048e..65923cd488 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h @@ -14,7 +14,6 @@ class TimeZoneConstructor final : public NativeFunction { JS_OBJECT(TimeZoneConstructor, NativeFunction); public: - explicit TimeZoneConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~TimeZoneConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject& new_target) override; private: + explicit TimeZoneConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h index 08976b9396..a1fb7f9103 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h @@ -15,11 +15,12 @@ class TimeZonePrototype final : public PrototypeObject construct(FunctionObject& new_target) override; private: + explicit ZonedDateTimeConstructor(Realm&); + virtual bool has_constructor() const override { return true; } JS_DECLARE_NATIVE_FUNCTION(from); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h index 8e3addd255..86bb929a52 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h @@ -15,11 +15,12 @@ class ZonedDateTimePrototype final : public PrototypeObject data() const + Span data() const { return { reinterpret_cast(m_viewed_array_buffer->buffer().data() + m_byte_offset), m_array_length }; } @@ -471,22 +471,25 @@ ThrowCompletionOr compare_typed_array_elements(VM&, Value x, Value y, Fu Realm&, u32 length, FunctionObject& new_target); \ static ThrowCompletionOr create(Realm&, u32 length); \ static ClassName* create(Realm&, u32 length, ArrayBuffer& buffer); \ - ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer); \ virtual FlyString const& element_name() const override; \ + \ + protected: \ + ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer); \ }; \ class PrototypeName final : public Object { \ JS_OBJECT(PrototypeName, Object); \ \ public: \ - PrototypeName(Realm&); \ virtual void initialize(Realm&) override; \ virtual ~PrototypeName() override; \ + \ + private: \ + PrototypeName(Realm&); \ }; \ class ConstructorName final : public TypedArrayConstructor { \ JS_OBJECT(ConstructorName, TypedArrayConstructor); \ \ public: \ - explicit ConstructorName(Realm&); \ virtual void initialize(Realm&) override; \ virtual ~ConstructorName() override; \ \ @@ -494,6 +497,7 @@ ThrowCompletionOr compare_typed_array_elements(VM&, Value x, Value y, Fu virtual ThrowCompletionOr construct(FunctionObject& new_target) override; \ \ private: \ + explicit ConstructorName(Realm&); \ virtual bool has_constructor() const override \ { \ return true; \ diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h index a75c819f1c..e98eeb4155 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h @@ -14,7 +14,6 @@ class TypedArrayConstructor : public NativeFunction { JS_OBJECT(TypedArrayConstructor, NativeFunction); public: - TypedArrayConstructor(FlyString const& name, Object& prototype); explicit TypedArrayConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~TypedArrayConstructor() override = default; @@ -22,6 +21,9 @@ public: virtual ThrowCompletionOr call() override; virtual ThrowCompletionOr construct(FunctionObject& new_target) override; +protected: + TypedArrayConstructor(FlyString const& name, Object& prototype); + private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h index f7ba75970e..cb73efd9eb 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h @@ -15,11 +15,12 @@ class TypedArrayPrototype final : public Object { JS_OBJECT(TypedArrayPrototype, Object); public: - explicit TypedArrayPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~TypedArrayPrototype() override = default; private: + explicit TypedArrayPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(buffer_getter); JS_DECLARE_NATIVE_FUNCTION(byte_length_getter); JS_DECLARE_NATIVE_FUNCTION(byte_offset_getter); diff --git a/Userland/Libraries/LibJS/Runtime/WeakMap.h b/Userland/Libraries/LibJS/Runtime/WeakMap.h index 9ea83683df..832de588cb 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMap.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMap.h @@ -21,7 +21,6 @@ class WeakMap final public: static WeakMap* create(Realm&); - explicit WeakMap(Object& prototype); virtual ~WeakMap() override = default; HashMap const& values() const { return m_values; }; @@ -30,6 +29,8 @@ public: virtual void remove_dead_cells(Badge) override; private: + explicit WeakMap(Object& prototype); + void visit_edges(Visitor&) override; HashMap m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h index 05489291f1..ff1ccaa11e 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h @@ -14,7 +14,6 @@ class WeakMapConstructor final : public NativeFunction { JS_OBJECT(WeakMapConstructor, NativeFunction); public: - explicit WeakMapConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~WeakMapConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject&) override; private: + explicit WeakMapConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h index be4a3ac739..32aec28120 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h @@ -15,11 +15,12 @@ class WeakMapPrototype final : public PrototypeObject JS_PROTOTYPE_OBJECT(WeakMapPrototype, WeakMap, WeakMap); public: - WeakMapPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~WeakMapPrototype() override = default; private: + explicit WeakMapPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(delete_); JS_DECLARE_NATIVE_FUNCTION(get); JS_DECLARE_NATIVE_FUNCTION(has); diff --git a/Userland/Libraries/LibJS/Runtime/WeakRef.h b/Userland/Libraries/LibJS/Runtime/WeakRef.h index c49c4fbef2..02d4371baf 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRef.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRef.h @@ -21,8 +21,6 @@ public: static WeakRef* create(Realm&, Object&); static WeakRef* create(Realm&, Symbol&); - explicit WeakRef(Object&, Object& prototype); - explicit WeakRef(Symbol&, Object& prototype); virtual ~WeakRef() override = default; auto const& value() const { return m_value; }; @@ -32,6 +30,9 @@ public: virtual void remove_dead_cells(Badge) override; private: + explicit WeakRef(Object&, Object& prototype); + explicit WeakRef(Symbol&, Object& prototype); + virtual void visit_edges(Visitor&) override; Variant m_value; diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h index efdc7dc1e5..e25a5fb9ce 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h @@ -14,7 +14,6 @@ class WeakRefConstructor final : public NativeFunction { JS_OBJECT(WeakRefConstructor, NativeFunction); public: - explicit WeakRefConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~WeakRefConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject&) override; private: + explicit WeakRefConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h index a39967e6d6..3dbe323a7d 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h @@ -15,11 +15,12 @@ class WeakRefPrototype final : public PrototypeObject JS_PROTOTYPE_OBJECT(WeakRefPrototype, WeakRef, WeakRef); public: - WeakRefPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~WeakRefPrototype() override = default; private: + explicit WeakRefPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(deref); }; diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.h b/Userland/Libraries/LibJS/Runtime/WeakSet.h index 7a21bcca03..9894ce10ac 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSet.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSet.h @@ -21,7 +21,6 @@ class WeakSet final public: static WeakSet* create(Realm&); - explicit WeakSet(Object& prototype); virtual ~WeakSet() override = default; HashTable const& values() const { return m_values; }; @@ -30,6 +29,8 @@ public: virtual void remove_dead_cells(Badge) override; private: + explicit WeakSet(Object& prototype); + HashTable m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping }; diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h index 6187a0e298..de9e1a3944 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h @@ -14,7 +14,6 @@ class WeakSetConstructor final : public NativeFunction { JS_OBJECT(WeakSetConstructor, NativeFunction); public: - explicit WeakSetConstructor(Realm&); virtual void initialize(Realm&) override; virtual ~WeakSetConstructor() override = default; @@ -22,6 +21,8 @@ public: virtual ThrowCompletionOr construct(FunctionObject&) override; private: + explicit WeakSetConstructor(Realm&); + virtual bool has_constructor() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h index 0ad81f9619..2a01447bef 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h @@ -15,11 +15,12 @@ class WeakSetPrototype final : public PrototypeObject JS_PROTOTYPE_OBJECT(WeakSetPrototype, WeakSet, WeakSet); public: - WeakSetPrototype(Realm&); virtual void initialize(Realm&) override; virtual ~WeakSetPrototype() override = default; private: + explicit WeakSetPrototype(Realm&); + JS_DECLARE_NATIVE_FUNCTION(add); JS_DECLARE_NATIVE_FUNCTION(delete_); JS_DECLARE_NATIVE_FUNCTION(has); diff --git a/Userland/Libraries/LibJS/Runtime/WrappedFunction.h b/Userland/Libraries/LibJS/Runtime/WrappedFunction.h index 5008dc32cc..4cc6c98d86 100644 --- a/Userland/Libraries/LibJS/Runtime/WrappedFunction.h +++ b/Userland/Libraries/LibJS/Runtime/WrappedFunction.h @@ -17,7 +17,6 @@ class WrappedFunction final : public FunctionObject { public: static ThrowCompletionOr create(Realm&, Realm& caller_realm, FunctionObject& target_function); - WrappedFunction(Realm&, FunctionObject&, Object& prototype); virtual ~WrappedFunction() = default; virtual ThrowCompletionOr internal_call(Value this_argument, MarkedVector arguments_list) override; @@ -31,6 +30,8 @@ public: FunctionObject& wrapped_target_function() { return m_wrapped_target_function; } private: + WrappedFunction(Realm&, FunctionObject&, Object& prototype); + virtual void visit_edges(Visitor&) override; // Internal Slots of Wrapped Function Exotic Objects, https://tc39.es/proposal-shadowrealm/#table-internal-slots-of-wrapped-function-exotic-objects -- cgit v1.2.3