1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:47:35 +00:00

LibJS+LibWeb: Replace GlobalObject with Realm in object constructors

No functional changes - we can still very easily get to the global
object via `Realm::global_object()`. This is in preparation of moving
the intrinsics to the realm and no longer having to pass a global
object when allocating any object.
In a few (now, and many more in subsequent commits) places we get a
realm using `GlobalObject::associated_realm()`, this is intended to be
temporary. For example, create() functions will later receive the same
treatment and are passed a realm instead of a global object.
This commit is contained in:
Linus Groh 2022-08-16 00:20:49 +01:00
parent 4c300cc5e8
commit ecd163bdf1
315 changed files with 592 additions and 554 deletions

View file

@ -13,11 +13,12 @@ namespace JS::Intl {
CollatorCompareFunction* CollatorCompareFunction::create(GlobalObject& global_object, Collator& collator)
{
return global_object.heap().allocate<CollatorCompareFunction>(global_object, global_object, collator);
auto& realm = *global_object.associated_realm();
return global_object.heap().allocate<CollatorCompareFunction>(global_object, realm, collator);
}
CollatorCompareFunction::CollatorCompareFunction(GlobalObject& global_object, Collator& collator)
: NativeFunction(*global_object.function_prototype())
CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator)
: NativeFunction(*realm.global_object().function_prototype())
, m_collator(collator)
{
}

View file

@ -16,7 +16,7 @@ class CollatorCompareFunction : public NativeFunction {
public:
static CollatorCompareFunction* create(GlobalObject&, Collator&);
explicit CollatorCompareFunction(GlobalObject&, Collator&);
CollatorCompareFunction(Realm&, Collator&);
virtual void initialize(GlobalObject&) override;
virtual ~CollatorCompareFunction() override = default;

View file

@ -132,8 +132,8 @@ static ThrowCompletionOr<Collator*> initialize_collator(GlobalObject& global_obj
}
// 10.1 The Intl.Collator Constructor, https://tc39.es/ecma402/#sec-the-intl-collator-constructor
CollatorConstructor::CollatorConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.Collator.as_string(), *global_object.function_prototype())
CollatorConstructor::CollatorConstructor(Realm& realm)
: NativeFunction(vm().names.Collator.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -14,7 +14,7 @@ class CollatorConstructor final : public NativeFunction {
JS_OBJECT(CollatorConstructor, NativeFunction);
public:
explicit CollatorConstructor(GlobalObject&);
explicit CollatorConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~CollatorConstructor() override = default;

View file

@ -12,8 +12,8 @@
namespace JS::Intl {
// 10.3 Properties of the Intl.Collator Prototype Object, https://tc39.es/ecma402/#sec-properties-of-the-intl-collator-prototype-object
CollatorPrototype::CollatorPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
CollatorPrototype::CollatorPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class CollatorPrototype final : public PrototypeObject<CollatorPrototype, Collat
JS_PROTOTYPE_OBJECT(CollatorPrototype, Collator, Collator);
public:
explicit CollatorPrototype(GlobalObject&);
explicit CollatorPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~CollatorPrototype() override = default;

View file

@ -17,8 +17,8 @@
namespace JS::Intl {
// 11.1 The Intl.DateTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-datetimeformat-constructor
DateTimeFormatConstructor::DateTimeFormatConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.DateTimeFormat.as_string(), *global_object.function_prototype())
DateTimeFormatConstructor::DateTimeFormatConstructor(Realm& realm)
: NativeFunction(vm().names.DateTimeFormat.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -14,7 +14,7 @@ class DateTimeFormatConstructor final : public NativeFunction {
JS_OBJECT(DateTimeFormatConstructor, NativeFunction);
public:
explicit DateTimeFormatConstructor(GlobalObject&);
explicit DateTimeFormatConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~DateTimeFormatConstructor() override = default;

View file

@ -14,8 +14,8 @@
namespace JS::Intl {
// 11.3 Properties of the Intl.DateTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-datetimeformat-prototype-object
DateTimeFormatPrototype::DateTimeFormatPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
DateTimeFormatPrototype::DateTimeFormatPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class DateTimeFormatPrototype final : public PrototypeObject<DateTimeFormatProto
JS_PROTOTYPE_OBJECT(DateTimeFormatPrototype, DateTimeFormat, Intl.DateTimeFormat);
public:
explicit DateTimeFormatPrototype(GlobalObject&);
explicit DateTimeFormatPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~DateTimeFormatPrototype() override = default;

View file

@ -16,8 +16,8 @@
namespace JS::Intl {
// 12.1 The Intl.DisplayNames Constructor, https://tc39.es/ecma402/#sec-intl-displaynames-constructor
DisplayNamesConstructor::DisplayNamesConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.DisplayNames.as_string(), *global_object.function_prototype())
DisplayNamesConstructor::DisplayNamesConstructor(Realm& realm)
: NativeFunction(vm().names.DisplayNames.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -14,7 +14,7 @@ class DisplayNamesConstructor final : public NativeFunction {
JS_OBJECT(DisplayNamesConstructor, NativeFunction);
public:
explicit DisplayNamesConstructor(GlobalObject&);
explicit DisplayNamesConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~DisplayNamesConstructor() override = default;

View file

@ -14,8 +14,8 @@
namespace JS::Intl {
// 12.3 Properties of the Intl.DisplayNames Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-displaynames-prototype-object
DisplayNamesPrototype::DisplayNamesPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
DisplayNamesPrototype::DisplayNamesPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class DisplayNamesPrototype final : public PrototypeObject<DisplayNamesPrototype
JS_PROTOTYPE_OBJECT(DisplayNamesPrototype, DisplayNames, Intl.DisplayNames);
public:
explicit DisplayNamesPrototype(GlobalObject&);
explicit DisplayNamesPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~DisplayNamesPrototype() override = default;

View file

@ -14,8 +14,8 @@
namespace JS::Intl {
// 1.2 The Intl.DurationFormat Constructor, https://tc39.es/proposal-intl-duration-format/#sec-intl-durationformat-constructor
DurationFormatConstructor::DurationFormatConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.DurationFormat.as_string(), *global_object.function_prototype())
DurationFormatConstructor::DurationFormatConstructor(Realm& realm)
: NativeFunction(vm().names.DurationFormat.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -14,7 +14,7 @@ class DurationFormatConstructor final : public NativeFunction {
JS_OBJECT(DurationFormatConstructor, NativeFunction);
public:
explicit DurationFormatConstructor(GlobalObject&);
explicit DurationFormatConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~DurationFormatConstructor() override = default;

View file

@ -11,8 +11,8 @@
namespace JS::Intl {
// 1.4 Properties of the Intl.DurationFormat Prototype Object, https://tc39.es/proposal-intl-duration-format/#sec-properties-of-intl-durationformat-prototype-object
DurationFormatPrototype::DurationFormatPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
DurationFormatPrototype::DurationFormatPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class DurationFormatPrototype final : public PrototypeObject<DurationFormatProto
JS_PROTOTYPE_OBJECT(DurationFormatPrototype, DurationFormat, Intl.DurationFormat);
public:
explicit DurationFormatPrototype(GlobalObject&);
explicit DurationFormatPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~DurationFormatPrototype() override = default;

View file

@ -28,8 +28,8 @@
namespace JS::Intl {
// 8 The Intl Object, https://tc39.es/ecma402/#intl-object
Intl::Intl(GlobalObject& global_object)
: Object(*global_object.object_prototype())
Intl::Intl(Realm& realm)
: Object(*realm.global_object().object_prototype())
{
}

View file

@ -14,7 +14,7 @@ class Intl final : public Object {
JS_OBJECT(Intl, Object);
public:
explicit Intl(GlobalObject&);
explicit Intl(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~Intl() override = default;

View file

@ -15,8 +15,8 @@
namespace JS::Intl {
// 13.1 The Intl.ListFormat Constructor, https://tc39.es/ecma402/#sec-intl-listformat-constructor
ListFormatConstructor::ListFormatConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.ListFormat.as_string(), *global_object.function_prototype())
ListFormatConstructor::ListFormatConstructor(Realm& realm)
: NativeFunction(vm().names.ListFormat.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -14,7 +14,7 @@ class ListFormatConstructor final : public NativeFunction {
JS_OBJECT(ListFormatConstructor, NativeFunction);
public:
explicit ListFormatConstructor(GlobalObject&);
explicit ListFormatConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~ListFormatConstructor() override = default;

View file

@ -13,8 +13,8 @@
namespace JS::Intl {
// 13.3 Properties of the Intl.ListFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object
ListFormatPrototype::ListFormatPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
ListFormatPrototype::ListFormatPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class ListFormatPrototype final : public PrototypeObject<ListFormatPrototype, Li
JS_PROTOTYPE_OBJECT(ListFormatPrototype, ListFormat, Intl.ListFormat);
public:
explicit ListFormatPrototype(GlobalObject&);
explicit ListFormatPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~ListFormatPrototype() override = default;

View file

@ -220,8 +220,8 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
}
// 14.1 The Intl.Locale Constructor, https://tc39.es/ecma402/#sec-intl-locale-constructor
LocaleConstructor::LocaleConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.Locale.as_string(), *global_object.function_prototype())
LocaleConstructor::LocaleConstructor(Realm& realm)
: NativeFunction(vm().names.Locale.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -14,7 +14,7 @@ class LocaleConstructor final : public NativeFunction {
JS_OBJECT(LocaleConstructor, NativeFunction);
public:
explicit LocaleConstructor(GlobalObject&);
explicit LocaleConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~LocaleConstructor() override = default;

View file

@ -14,8 +14,8 @@
namespace JS::Intl {
// 14.3 Properties of the Intl.Locale Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-locale-prototype-object
LocalePrototype::LocalePrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
LocalePrototype::LocalePrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class LocalePrototype final : public PrototypeObject<LocalePrototype, Locale> {
JS_PROTOTYPE_OBJECT(LocalePrototype, Locale, Intl.Locale);
public:
explicit LocalePrototype(GlobalObject&);
explicit LocalePrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~LocalePrototype() override = default;

View file

@ -14,8 +14,8 @@
namespace JS::Intl {
// 15.1 The Intl.NumberFormat Constructor, https://tc39.es/ecma402/#sec-intl-numberformat-constructor
NumberFormatConstructor::NumberFormatConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.NumberFormat.as_string(), *global_object.function_prototype())
NumberFormatConstructor::NumberFormatConstructor(Realm& realm)
: NativeFunction(vm().names.NumberFormat.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -15,7 +15,7 @@ class NumberFormatConstructor final : public NativeFunction {
JS_OBJECT(NumberFormatConstructor, NativeFunction);
public:
explicit NumberFormatConstructor(GlobalObject&);
explicit NumberFormatConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~NumberFormatConstructor() override = default;

View file

@ -14,8 +14,8 @@
namespace JS::Intl {
// 15.3 Properties of the Intl.NumberFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-prototype-object
NumberFormatPrototype::NumberFormatPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
NumberFormatPrototype::NumberFormatPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class NumberFormatPrototype final : public PrototypeObject<NumberFormatPrototype
JS_PROTOTYPE_OBJECT(NumberFormatPrototype, NumberFormat, Intl.NumberFormat);
public:
explicit NumberFormatPrototype(GlobalObject&);
explicit NumberFormatPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~NumberFormatPrototype() override = default;

View file

@ -16,8 +16,8 @@
namespace JS::Intl {
// 16.1 The Intl.PluralRules Constructor, https://tc39.es/ecma402/#sec-intl-pluralrules-constructor
PluralRulesConstructor::PluralRulesConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.PluralRules.as_string(), *global_object.function_prototype())
PluralRulesConstructor::PluralRulesConstructor(Realm& realm)
: NativeFunction(vm().names.PluralRules.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -14,7 +14,7 @@ class PluralRulesConstructor final : public NativeFunction {
JS_OBJECT(PluralRulesConstructor, NativeFunction);
public:
explicit PluralRulesConstructor(GlobalObject&);
explicit PluralRulesConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~PluralRulesConstructor() override = default;

View file

@ -13,8 +13,8 @@
namespace JS::Intl {
// 16.3 Properties of the Intl.PluralRules Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-pluralrules-prototype-object
PluralRulesPrototype::PluralRulesPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
PluralRulesPrototype::PluralRulesPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class PluralRulesPrototype final : public PrototypeObject<PluralRulesPrototype,
JS_PROTOTYPE_OBJECT(PluralRulesPrototype, PluralRules, Intl.PluralRules);
public:
explicit PluralRulesPrototype(GlobalObject&);
explicit PluralRulesPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~PluralRulesPrototype() override = default;

View file

@ -19,8 +19,8 @@
namespace JS::Intl {
// 17.1 The Intl.RelativeTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor
RelativeTimeFormatConstructor::RelativeTimeFormatConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.RelativeTimeFormat.as_string(), *global_object.function_prototype())
RelativeTimeFormatConstructor::RelativeTimeFormatConstructor(Realm& realm)
: NativeFunction(vm().names.RelativeTimeFormat.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -14,7 +14,7 @@ class RelativeTimeFormatConstructor final : public NativeFunction {
JS_OBJECT(RelativeTimeFormatConstructor, NativeFunction);
public:
explicit RelativeTimeFormatConstructor(GlobalObject&);
explicit RelativeTimeFormatConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~RelativeTimeFormatConstructor() override = default;

View file

@ -11,8 +11,8 @@
namespace JS::Intl {
// 17.3 Properties of the Intl.RelativeTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-relativetimeformat-prototype-object
RelativeTimeFormatPrototype::RelativeTimeFormatPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
RelativeTimeFormatPrototype::RelativeTimeFormatPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class RelativeTimeFormatPrototype final : public PrototypeObject<RelativeTimeFor
JS_PROTOTYPE_OBJECT(RelativeTimeFormatPrototype, RelativeTimeFormat, Intl.RelativeTimeFormat);
public:
explicit RelativeTimeFormatPrototype(GlobalObject&);
explicit RelativeTimeFormatPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~RelativeTimeFormatPrototype() override = default;

View file

@ -13,18 +13,19 @@ namespace JS::Intl {
// 18.6.1 CreateSegmentIterator ( segmenter, string ), https://tc39.es/ecma402/#sec-createsegmentsobject
SegmentIterator* SegmentIterator::create(GlobalObject& global_object, Segmenter& segmenter, Utf16View const& string, Segments const& segments)
{
auto& realm = *global_object.associated_realm();
// 1. Let internalSlotsList be « [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] ».
// 2. Let iterator be OrdinaryObjectCreate(%SegmentIteratorPrototype%, internalSlotsList).
// 3. Set iterator.[[IteratingSegmenter]] to segmenter.
// 4. Set iterator.[[IteratedString]] to string.
// 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0.
// 6. Return iterator.
return global_object.heap().allocate<SegmentIterator>(global_object, global_object, segmenter, move(string), segments);
return global_object.heap().allocate<SegmentIterator>(global_object, realm, segmenter, move(string), segments);
}
// 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects
SegmentIterator::SegmentIterator(GlobalObject& global_object, Segmenter& segmenter, Utf16View const& string, Segments const& segments)
: Object(*global_object.intl_segment_iterator_prototype())
SegmentIterator::SegmentIterator(Realm& realm, Segmenter& segmenter, Utf16View const& string, Segments const& segments)
: Object(*realm.global_object().intl_segment_iterator_prototype())
, m_iterating_segmenter(segmenter)
, m_iterated_string(string)
, m_segments(segments)

View file

@ -18,7 +18,7 @@ class SegmentIterator final : public Object {
public:
static SegmentIterator* create(GlobalObject&, Segmenter&, Utf16View const&, Segments const&);
SegmentIterator(GlobalObject&, Segmenter&, Utf16View const&, Segments const&);
SegmentIterator(Realm&, Segmenter&, Utf16View const&, Segments const&);
virtual ~SegmentIterator() override = default;
Segmenter const& iterating_segmenter() const { return m_iterating_segmenter; }

View file

@ -13,8 +13,8 @@
namespace JS::Intl {
// 18.6.2 The %SegmentIteratorPrototype% Object, https://tc39.es/ecma402/#sec-%segmentiteratorprototype%-object
SegmentIteratorPrototype::SegmentIteratorPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.iterator_prototype())
SegmentIteratorPrototype::SegmentIteratorPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().iterator_prototype())
{
}

View file

@ -15,7 +15,7 @@ class SegmentIteratorPrototype final : public PrototypeObject<SegmentIteratorPro
JS_PROTOTYPE_OBJECT(SegmentIteratorPrototype, SegmentIterator, SegmentIterator);
public:
explicit SegmentIteratorPrototype(GlobalObject&);
explicit SegmentIteratorPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~SegmentIteratorPrototype() override = default;

View file

@ -15,8 +15,8 @@
namespace JS::Intl {
// 18.1 The Intl.Segmenter Constructor, https://tc39.es/ecma402/#sec-intl-segmenter-constructor
SegmenterConstructor::SegmenterConstructor(GlobalObject& global_object)
: NativeFunction(vm().names.Segmenter.as_string(), *global_object.function_prototype())
SegmenterConstructor::SegmenterConstructor(Realm& realm)
: NativeFunction(vm().names.Segmenter.as_string(), *realm.global_object().function_prototype())
{
}

View file

@ -14,7 +14,7 @@ class SegmenterConstructor final : public NativeFunction {
JS_OBJECT(SegmenterConstructor, NativeFunction);
public:
explicit SegmenterConstructor(GlobalObject&);
explicit SegmenterConstructor(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~SegmenterConstructor() override = default;

View file

@ -12,8 +12,8 @@
namespace JS::Intl {
// 18.3 Properties of the Intl.Segmenter Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-segmenter-prototype-object
SegmenterPrototype::SegmenterPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
SegmenterPrototype::SegmenterPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class SegmenterPrototype final : public PrototypeObject<SegmenterPrototype, Segm
JS_PROTOTYPE_OBJECT(SegmenterPrototype, Segmenter, Segmenter);
public:
explicit SegmenterPrototype(GlobalObject&);
explicit SegmenterPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~SegmenterPrototype() override = default;

View file

@ -13,17 +13,18 @@ namespace JS::Intl {
// 18.5.1 CreateSegmentsObject ( segmenter, string ), https://tc39.es/ecma402/#sec-createsegmentsobject
Segments* Segments::create(GlobalObject& global_object, Segmenter& segmenter, Utf16String string)
{
auto& realm = *global_object.associated_realm();
// 1. Let internalSlotsList be « [[SegmentsSegmenter]], [[SegmentsString]] ».
// 2. Let segments be OrdinaryObjectCreate(%SegmentsPrototype%, internalSlotsList).
// 3. Set segments.[[SegmentsSegmenter]] to segmenter.
// 4. Set segments.[[SegmentsString]] to string.
// 5. Return segments.
return global_object.heap().allocate<Segments>(global_object, global_object, segmenter, move(string));
return global_object.heap().allocate<Segments>(global_object, realm, segmenter, move(string));
}
// 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects
Segments::Segments(GlobalObject& global_object, Segmenter& segmenter, Utf16String string)
: Object(*global_object.intl_segments_prototype())
Segments::Segments(Realm& realm, Segmenter& segmenter, Utf16String string)
: Object(*realm.global_object().intl_segments_prototype())
, m_segments_segmenter(segmenter)
, m_segments_string(move(string))
{

View file

@ -18,7 +18,7 @@ class Segments final : public Object {
public:
static Segments* create(GlobalObject&, Segmenter&, Utf16String);
Segments(GlobalObject&, Segmenter&, Utf16String);
Segments(Realm&, Segmenter&, Utf16String);
virtual ~Segments() override = default;
Segmenter& segments_segmenter() const { return m_segments_segmenter; }

View file

@ -12,8 +12,8 @@
namespace JS::Intl {
// 18.5.2 The %SegmentsPrototype% Object, https://tc39.es/ecma402/#sec-%segmentsprototype%-object
SegmentsPrototype::SegmentsPrototype(GlobalObject& global_object)
: PrototypeObject(*global_object.object_prototype())
SegmentsPrototype::SegmentsPrototype(Realm& realm)
: PrototypeObject(*realm.global_object().object_prototype())
{
}

View file

@ -15,7 +15,7 @@ class SegmentsPrototype final : public PrototypeObject<SegmentsPrototype, Segmen
JS_PROTOTYPE_OBJECT(SegmentsPrototype, Segments, Segments);
public:
explicit SegmentsPrototype(GlobalObject&);
explicit SegmentsPrototype(Realm&);
virtual void initialize(GlobalObject&) override;
virtual ~SegmentsPrototype() override = default;