1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:17:45 +00:00

LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors

Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
This commit is contained in:
Timothy Flynn 2023-01-28 12:33:35 -05:00 committed by Linus Groh
parent 1c1b902a6a
commit 2692db8699
694 changed files with 1774 additions and 1065 deletions

View file

@ -22,11 +22,13 @@ CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collato
{
}
void CollatorCompareFunction::initialize(Realm&)
ThrowCompletionOr<void> CollatorCompareFunction::initialize(Realm&)
{
auto& vm = this->vm();
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
return {};
}
// 10.3.3.2 CompareStrings ( collator, x, y ), https://tc39.es/ecma402/#sec-collator-comparestrings

View file

@ -16,7 +16,7 @@ class CollatorCompareFunction : public NativeFunction {
public:
static NonnullGCPtr<CollatorCompareFunction> create(Realm&, Collator&);
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~CollatorCompareFunction() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -135,9 +135,9 @@ CollatorConstructor::CollatorConstructor(Realm& realm)
{
}
void CollatorConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> CollatorConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
@ -147,6 +147,8 @@ void CollatorConstructor::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
return {};
}
// 10.1.1 Intl.Collator ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.collator

View file

@ -14,7 +14,7 @@ class CollatorConstructor final : public NativeFunction {
JS_OBJECT(CollatorConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~CollatorConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -17,9 +17,9 @@ CollatorPrototype::CollatorPrototype(Realm& realm)
{
}
void CollatorPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> CollatorPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Object::initialize(realm));
auto& vm = this->vm();
@ -29,6 +29,8 @@ void CollatorPrototype::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_accessor(realm, vm.names.compare, compare_getter, {}, attr);
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
return {};
}
// 10.3.3 get Intl.Collator.prototype.compare, https://tc39.es/ecma402/#sec-intl.collator.prototype.compare

View file

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

View file

@ -23,9 +23,9 @@ DateTimeFormatConstructor::DateTimeFormatConstructor(Realm& realm)
{
}
void DateTimeFormatConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> DateTimeFormatConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
@ -36,6 +36,8 @@ void DateTimeFormatConstructor::initialize(Realm& realm)
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
return {};
}
// 11.1.1 Intl.DateTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.datetimeformat

View file

@ -14,7 +14,7 @@ class DateTimeFormatConstructor final : public NativeFunction {
JS_OBJECT(DateTimeFormatConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~DateTimeFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -25,13 +25,15 @@ DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format,
{
}
void DateTimeFormatFunction::initialize(Realm& realm)
ThrowCompletionOr<void> DateTimeFormatFunction::initialize(Realm& realm)
{
auto& vm = this->vm();
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
return {};
}
ThrowCompletionOr<Value> DateTimeFormatFunction::call()

View file

@ -19,7 +19,7 @@ public:
static NonnullGCPtr<DateTimeFormatFunction> create(Realm&, DateTimeFormat&);
virtual ~DateTimeFormatFunction() override = default;
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -19,9 +19,9 @@ DateTimeFormatPrototype::DateTimeFormatPrototype(Realm& realm)
{
}
void DateTimeFormatPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> DateTimeFormatPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
auto& vm = this->vm();
@ -35,6 +35,8 @@ void DateTimeFormatPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.formatRange, format_range, 2, attr);
define_native_function(realm, vm.names.formatRangeToParts, format_range_to_parts, 2, attr);
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
return {};
}
// 11.3.3 get Intl.DateTimeFormat.prototype.format, https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype.format

View file

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

View file

@ -21,9 +21,9 @@ DisplayNamesConstructor::DisplayNamesConstructor(Realm& realm)
{
}
void DisplayNamesConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> DisplayNamesConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
@ -34,6 +34,8 @@ void DisplayNamesConstructor::initialize(Realm& realm)
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
return {};
}
// 12.1.1 Intl.DisplayNames ( locales, options ), https://tc39.es/ecma402/#sec-Intl.DisplayNames

View file

@ -14,7 +14,7 @@ class DisplayNamesConstructor final : public NativeFunction {
JS_OBJECT(DisplayNamesConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~DisplayNamesConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -19,9 +19,9 @@ DisplayNamesPrototype::DisplayNamesPrototype(Realm& realm)
{
}
void DisplayNamesPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> DisplayNamesPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
auto& vm = this->vm();
@ -31,6 +31,8 @@ void DisplayNamesPrototype::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.of, of, 1, attr);
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
return {};
}
// 12.3.3 Intl.DisplayNames.prototype.of ( code ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype.of

View file

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

View file

@ -20,9 +20,9 @@ DurationFormatConstructor::DurationFormatConstructor(Realm& realm)
{
}
void DurationFormatConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> DurationFormatConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
@ -32,6 +32,8 @@ void DurationFormatConstructor::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
return {};
}
// 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat

View file

@ -14,7 +14,7 @@ class DurationFormatConstructor final : public NativeFunction {
JS_OBJECT(DurationFormatConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~DurationFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -18,9 +18,9 @@ DurationFormatPrototype::DurationFormatPrototype(Realm& realm)
{
}
void DurationFormatPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> DurationFormatPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
auto& vm = this->vm();
@ -31,6 +31,8 @@ void DurationFormatPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.format, format, 1, attr);
define_native_function(realm, vm.names.formatToParts, format_to_parts, 1, attr);
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
return {};
}
// 1.4.3 Intl.DurationFormat.prototype.format ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.format

View file

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

View file

@ -32,9 +32,9 @@ Intl::Intl(Realm& realm)
{
}
void Intl::initialize(Realm& realm)
ThrowCompletionOr<void> Intl::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Object::initialize(realm));
auto& vm = this->vm();
@ -55,6 +55,8 @@ void Intl::initialize(Realm& realm)
define_native_function(realm, vm.names.getCanonicalLocales, get_canonical_locales, 1, attr);
define_native_function(realm, vm.names.supportedValuesOf, supported_values_of, 1, attr);
return {};
}
// 8.3.1 Intl.getCanonicalLocales ( locales ), https://tc39.es/ecma402/#sec-intl.getcanonicallocales

View file

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

View file

@ -20,9 +20,9 @@ ListFormatConstructor::ListFormatConstructor(Realm& realm)
{
}
void ListFormatConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> ListFormatConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
@ -33,6 +33,8 @@ void ListFormatConstructor::initialize(Realm& realm)
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
return {};
}
// 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat

View file

@ -14,7 +14,7 @@ class ListFormatConstructor final : public NativeFunction {
JS_OBJECT(ListFormatConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~ListFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -18,9 +18,9 @@ ListFormatPrototype::ListFormatPrototype(Realm& realm)
{
}
void ListFormatPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> ListFormatPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
auto& vm = this->vm();
@ -31,6 +31,8 @@ void ListFormatPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.format, format, 1, attr);
define_native_function(realm, vm.names.formatToParts, format_to_parts, 1, attr);
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
return {};
}
// 13.3.3 Intl.ListFormat.prototype.format ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.format

View file

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

View file

@ -222,15 +222,17 @@ LocaleConstructor::LocaleConstructor(Realm& realm)
{
}
void LocaleConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> LocaleConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
// 14.2.1 Intl.Locale.prototype, https://tc39.es/ecma402/#sec-Intl.Locale.prototype
define_direct_property(vm.names.prototype, realm.intrinsics().intl_locale_prototype(), 0);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
return {};
}
// 14.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale

View file

@ -14,7 +14,7 @@ class LocaleConstructor final : public NativeFunction {
JS_OBJECT(LocaleConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~LocaleConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -19,9 +19,9 @@ LocalePrototype::LocalePrototype(Realm& realm)
{
}
void LocalePrototype::initialize(Realm& realm)
ThrowCompletionOr<void> LocalePrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
auto& vm = this->vm();
@ -50,6 +50,8 @@ void LocalePrototype::initialize(Realm& realm)
define_native_accessor(realm, vm.names.timeZones, time_zones, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.textInfo, text_info, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.weekInfo, week_info, {}, Attribute::Configurable);
return {};
}
// 14.3.3 Intl.Locale.prototype.maximize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.maximize

View file

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

View file

@ -19,9 +19,9 @@ NumberFormatConstructor::NumberFormatConstructor(Realm& realm)
{
}
void NumberFormatConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> NumberFormatConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
@ -32,6 +32,8 @@ void NumberFormatConstructor::initialize(Realm& realm)
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
return {};
}
// 15.1.1 Intl.NumberFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.numberformat

View file

@ -15,7 +15,7 @@ class NumberFormatConstructor final : public NativeFunction {
JS_OBJECT(NumberFormatConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~NumberFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -23,13 +23,15 @@ NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object&
{
}
void NumberFormatFunction::initialize(Realm& realm)
ThrowCompletionOr<void> NumberFormatFunction::initialize(Realm& realm)
{
auto& vm = this->vm();
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
return {};
}
ThrowCompletionOr<Value> NumberFormatFunction::call()

View file

@ -19,7 +19,7 @@ public:
static NonnullGCPtr<NumberFormatFunction> create(Realm&, NumberFormat&);
virtual ~NumberFormatFunction() override = default;
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -19,9 +19,9 @@ NumberFormatPrototype::NumberFormatPrototype(Realm& realm)
{
}
void NumberFormatPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> NumberFormatPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
auto& vm = this->vm();
@ -35,6 +35,8 @@ void NumberFormatPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.formatRange, format_range, 2, attr);
define_native_function(realm, vm.names.formatRangeToParts, format_range_to_parts, 2, attr);
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
return {};
}
// 15.3.3 get Intl.NumberFormat.prototype.format, https://tc39.es/ecma402/#sec-intl.numberformat.prototype.format

View file

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

View file

@ -21,9 +21,9 @@ PluralRulesConstructor::PluralRulesConstructor(Realm& realm)
{
}
void PluralRulesConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> PluralRulesConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
@ -33,6 +33,8 @@ void PluralRulesConstructor::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
return {};
}
// 16.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules

View file

@ -14,7 +14,7 @@ class PluralRulesConstructor final : public NativeFunction {
JS_OBJECT(PluralRulesConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~PluralRulesConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -18,9 +18,9 @@ PluralRulesPrototype::PluralRulesPrototype(Realm& realm)
{
}
void PluralRulesPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> PluralRulesPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Object::initialize(realm));
auto& vm = this->vm();
@ -31,6 +31,8 @@ void PluralRulesPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.select, select, 1, attr);
define_native_function(realm, vm.names.selectRange, select_range, 2, attr);
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
return {};
}
// 16.3.3 Intl.PluralRules.prototype.select ( value ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.select

View file

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

View file

@ -24,9 +24,9 @@ RelativeTimeFormatConstructor::RelativeTimeFormatConstructor(Realm& realm)
{
}
void RelativeTimeFormatConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> RelativeTimeFormatConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
@ -36,6 +36,8 @@ void RelativeTimeFormatConstructor::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
return {};
}
// 17.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat

View file

@ -14,7 +14,7 @@ class RelativeTimeFormatConstructor final : public NativeFunction {
JS_OBJECT(RelativeTimeFormatConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~RelativeTimeFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -16,9 +16,9 @@ RelativeTimeFormatPrototype::RelativeTimeFormatPrototype(Realm& realm)
{
}
void RelativeTimeFormatPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> RelativeTimeFormatPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Object::initialize(realm));
auto& vm = this->vm();
@ -29,6 +29,8 @@ void RelativeTimeFormatPrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.format, format, 2, attr);
define_native_function(realm, vm.names.formatToParts, format_to_parts, 2, attr);
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
return {};
}
// 17.3.3 Intl.RelativeTimeFormat.prototype.format ( value, unit ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.format

View file

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

View file

@ -18,9 +18,9 @@ SegmentIteratorPrototype::SegmentIteratorPrototype(Realm& realm)
{
}
void SegmentIteratorPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> SegmentIteratorPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Object::initialize(realm));
auto& vm = this->vm();
@ -29,6 +29,8 @@ void SegmentIteratorPrototype::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.next, next, 0, attr);
return {};
}
// 18.6.2.1 %SegmentIteratorPrototype%.next ( ), https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.next

View file

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

View file

@ -21,9 +21,9 @@ SegmenterConstructor::SegmenterConstructor(Realm& realm)
{
}
void SegmenterConstructor::initialize(Realm& realm)
ThrowCompletionOr<void> SegmenterConstructor::initialize(Realm& realm)
{
NativeFunction::initialize(realm);
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
auto& vm = this->vm();
@ -33,6 +33,8 @@ void SegmenterConstructor::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
return {};
}
// 18.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter

View file

@ -14,7 +14,7 @@ class SegmenterConstructor final : public NativeFunction {
JS_OBJECT(SegmenterConstructor, NativeFunction);
public:
virtual void initialize(Realm&) override;
virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~SegmenterConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;

View file

@ -17,9 +17,9 @@ SegmenterPrototype::SegmenterPrototype(Realm& realm)
{
}
void SegmenterPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> SegmenterPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
auto& vm = this->vm();
@ -29,6 +29,8 @@ void SegmenterPrototype::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
define_native_function(realm, vm.names.segment, segment, 1, attr);
return {};
}
// 18.3.4 Intl.Segmenter.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.segmenter.prototype.resolvedoptions

View file

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

View file

@ -17,15 +17,17 @@ SegmentsPrototype::SegmentsPrototype(Realm& realm)
{
}
void SegmentsPrototype::initialize(Realm& realm)
ThrowCompletionOr<void> SegmentsPrototype::initialize(Realm& realm)
{
Object::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
auto& vm = this->vm();
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, *vm.well_known_symbol_iterator(), symbol_iterator, 0, attr);
define_native_function(realm, vm.names.containing, containing, 1, attr);
return {};
}
// 18.5.2.1 %SegmentsPrototype%.containing ( index ), https://tc39.es/ecma402/#sec-%segmentsprototype%.containing

View file

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