mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:17:44 +00:00
parent
b7b02693b9
commit
1a27c525d5
69 changed files with 185 additions and 198 deletions
|
@ -116,7 +116,7 @@ ThrowCompletionOr<Value> get_option(VM& vm, Object const& options, PropertyKey c
|
|||
[](Empty) -> ThrowCompletionOr<Value> { return js_undefined(); },
|
||||
[](bool b) -> ThrowCompletionOr<Value> { return Value(b); },
|
||||
[](double d) -> ThrowCompletionOr<Value> { return Value(d); },
|
||||
[&vm](StringView s) -> ThrowCompletionOr<Value> { return MUST_OR_THROW_OOM(PrimitiveString::create(vm, s)); });
|
||||
[&vm](StringView s) -> ThrowCompletionOr<Value> { return PrimitiveString::create(vm, s); });
|
||||
}
|
||||
|
||||
// 5. If type is "boolean", then
|
||||
|
@ -602,7 +602,7 @@ ThrowCompletionOr<Value> to_relative_temporal_object(VM& vm, Object const& optio
|
|||
auto date_options = Object::create(realm, nullptr);
|
||||
|
||||
// g. Perform ! CreateDataPropertyOrThrow(dateOptions, "overflow", "constrain").
|
||||
MUST(date_options->create_data_property_or_throw(vm.names.overflow, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "constrain"sv))));
|
||||
MUST(date_options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, "constrain"_string)));
|
||||
|
||||
// h. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, dateOptions).
|
||||
result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, date_options));
|
||||
|
|
|
@ -120,9 +120,9 @@ ThrowCompletionOr<Vector<String>> calendar_fields(VM& vm, Object& calendar, Vect
|
|||
}
|
||||
|
||||
// 3. Let fieldsArray be ? Call(fields, calendar, « CreateArrayFromList(fieldNames) »).
|
||||
auto field_names_array = MUST_OR_THROW_OOM(Array::try_create_from<StringView>(vm, realm, field_names, [&](auto value) {
|
||||
auto field_names_array = Array::create_from<StringView>(realm, field_names, [&](auto value) {
|
||||
return PrimitiveString::create(vm, value);
|
||||
}));
|
||||
});
|
||||
auto fields_array = TRY(call(vm, *fields, &calendar, field_names_array));
|
||||
|
||||
// 4. Return ? IterableToListOfType(fieldsArray, « String »).
|
||||
|
|
|
@ -36,7 +36,7 @@ void CalendarPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 12.4.2 Temporal.Calendar.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.Calendar"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Calendar"_string), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.id, id_getter, {}, Attribute::Configurable);
|
||||
|
||||
|
|
|
@ -692,7 +692,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double
|
|||
auto until_options = Object::create(realm, nullptr);
|
||||
|
||||
// iii. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month").
|
||||
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "month"sv))));
|
||||
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"_string)));
|
||||
|
||||
// iv. Let untilResult be ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil).
|
||||
auto* until_result = TRY(calendar_date_until(vm, *calendar, relative_to, new_relative_to, *until_options, date_until));
|
||||
|
@ -928,7 +928,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y
|
|||
auto until_options = Object::create(realm, nullptr);
|
||||
|
||||
// m. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month").
|
||||
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "month"sv))));
|
||||
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"_string)));
|
||||
|
||||
// n. Let untilResult be ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil).
|
||||
auto* until_result = TRY(calendar_date_until(vm, calendar, relative_to, new_relative_to, *until_options, date_until));
|
||||
|
@ -954,7 +954,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y
|
|||
until_options = Object::create(realm, nullptr);
|
||||
|
||||
// vi. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month").
|
||||
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "month"sv))));
|
||||
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"_string)));
|
||||
|
||||
// vii. Set untilResult to ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil).
|
||||
until_result = TRY(calendar_date_until(vm, calendar, relative_to, new_relative_to, *until_options, date_until));
|
||||
|
@ -1109,7 +1109,7 @@ ThrowCompletionOr<DurationRecord> add_duration(VM& vm, double years1, double mon
|
|||
auto difference_options = Object::create(realm, nullptr);
|
||||
|
||||
// i. Perform ! CreateDataPropertyOrThrow(differenceOptions, "largestUnit", dateLargestUnit).
|
||||
MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, date_largest_unit))));
|
||||
MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, date_largest_unit)));
|
||||
|
||||
// j. Let dateDifference be ? CalendarDateUntil(calendar, relativeTo, end, differenceOptions).
|
||||
auto* date_difference = TRY(calendar_date_until(vm, calendar, &relative_to, end, *difference_options));
|
||||
|
@ -1312,7 +1312,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
|
|||
auto until_options = Object::create(realm, nullptr);
|
||||
|
||||
// l. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "year").
|
||||
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "year"sv))));
|
||||
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "year"_string)));
|
||||
|
||||
// m. Let timePassed be ? CalendarDateUntil(calendar, relativeTo, wholeDaysLater, untilOptions).
|
||||
auto* time_passed = TRY(calendar_date_until(vm, *calendar, relative_to, whole_days_later, *until_options));
|
||||
|
|
|
@ -27,7 +27,7 @@ void DurationPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 7.3.2 Temporal.Duration.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.Duration"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Duration"_string), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.years, years_getter, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.months, months_getter, {}, Attribute::Configurable);
|
||||
|
|
|
@ -31,7 +31,7 @@ void InstantPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 8.3.2 Temporal.Instant.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.Instant"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Instant"_string), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.epochSeconds, epoch_seconds_getter, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.epochMilliseconds, epoch_milliseconds_getter, {}, Attribute::Configurable);
|
||||
|
|
|
@ -33,7 +33,7 @@ void Now::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 2.1.1 Temporal.Now [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-now-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.Now"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Now"_string), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.timeZone, time_zone, 0, attr);
|
||||
|
|
|
@ -32,7 +32,7 @@ void PlainDatePrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 3.3.2 Temporal.PlainDate.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainDate"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainDate"_string), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable);
|
||||
|
|
|
@ -33,7 +33,7 @@ void PlainDateTimePrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 5.3.2 Temporal.PlainDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainDateTime"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainDateTime"_string), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable);
|
||||
|
|
|
@ -27,7 +27,7 @@ void PlainMonthDayPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 10.3.2 Temporal.PlainMonthDay.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainMonthDay"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainMonthDay"_string), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.monthCode, month_code_getter, {}, Attribute::Configurable);
|
||||
|
|
|
@ -32,7 +32,7 @@ void PlainTimePrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 4.3.2 Temporal.PlainTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainTime"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainTime"_string), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.hour, hour_getter, {}, Attribute::Configurable);
|
||||
|
|
|
@ -29,7 +29,7 @@ void PlainYearMonthPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 9.3.2 Temporal.PlainYearMonth.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.PlainYearMonth"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainYearMonth"_string), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable);
|
||||
|
|
|
@ -33,7 +33,7 @@ void Temporal::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 1.1.1 Temporal [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"_string), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_direct_property(vm.names.Now, MUST(heap().allocate<Now>(realm, realm)), attr);
|
||||
|
|
|
@ -42,7 +42,7 @@ void TimeZonePrototype::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.toJSON, to_json, 0, attr);
|
||||
|
||||
// 11.4.2 Temporal.TimeZone.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.TimeZone"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.TimeZone"_string), Attribute::Configurable);
|
||||
}
|
||||
|
||||
// 11.4.3 get Temporal.TimeZone.prototype.id, https://tc39.es/proposal-temporal/#sec-get-temporal.timezone.prototype.id
|
||||
|
|
|
@ -33,7 +33,7 @@ void ZonedDateTimePrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 6.3.2 Temporal.ZonedDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), MUST(PrimitiveString::create(vm, "Temporal.ZonedDateTime"sv)), Attribute::Configurable);
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.ZonedDateTime"_string), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.timeZone, time_zone_getter, {}, Attribute::Configurable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue