Commit c6833625 authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

[Temporal] Add Plain(Date|MonthDay|YearMonth).*.to(Locale)?String

Spec Text:
https://tc39.es/proposal-temporal/#sup-temporal.plaindate.prototype.tostring
https://tc39.es/proposal-temporal/#sup-temporal.plaindate.prototype.tolocalestring
https://tc39.es/proposal-temporal/#sup-temporal.plainmonthday.prototype.tostring
https://tc39.es/proposal-temporal/#sup-temporal.plainmonthday.prototype.tolocalestring
https://tc39.es/proposal-temporal/#sup-temporal.plainyearmonth.prototype.tostring
https://tc39.es/proposal-temporal/#sup-temporal.plainyearmonth.prototype.tolocalestring

Implement toString/toLocaleString as non-intl version.

Because toString took options bag in Temporal, we cannot use the
same way how we handle Date.prototype.toLocaleString() for non-intl
build by just forwarding to it's toString implementation.
Change built-ins-defintions.h to always has built-ins for
*.toLocaleString , not just in intl build.
Change src/init/bootstrapper.cc away of the toLocaleString forward
to toString approach.

Implement the non-intl version of ToLocaleString in js-temporal-objects.cc for
Temporal.Plain(Date|YearMonth|MonthDay)


Bug: v8:11544
Change-Id: I202bcf28ef05ed03c337475300cfdfd18b52ffb3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3656137Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80675}
parent 44932c16
......@@ -1172,6 +1172,8 @@ namespace internal {
CPP(TemporalPlainDatePrototypeToString) \
/* Temporal #sec-temporal.plaindate.prototype.tojson */ \
CPP(TemporalPlainDatePrototypeToJSON) \
/* Temporal #sec-temporal.plaindate.prototype.tolocalestring */ \
CPP(TemporalPlainDatePrototypeToLocaleString) \
/* Temporal #sec-temporal.plaindate.prototype.valueof */ \
CPP(TemporalPlainDatePrototypeValueOf) \
\
......@@ -1220,6 +1222,8 @@ namespace internal {
CPP(TemporalPlainTimePrototypeToString) \
/* Temporal #sec-temporal.plaindtimeprototype.tojson */ \
CPP(TemporalPlainTimePrototypeToJSON) \
/* Temporal #sec-temporal.plaintime.prototype.tolocalestring */ \
CPP(TemporalPlainTimePrototypeToLocaleString) \
/* Temporal #sec-temporal.plaintime.prototype.valueof */ \
CPP(TemporalPlainTimePrototypeValueOf) \
\
......@@ -1292,6 +1296,8 @@ namespace internal {
CPP(TemporalPlainDateTimePrototypeToString) \
/* Temporal #sec-temporal.plainddatetimeprototype.tojson */ \
CPP(TemporalPlainDateTimePrototypeToJSON) \
/* Temporal #sec-temporal.plaindatetime.prototype.tolocalestring */ \
CPP(TemporalPlainDateTimePrototypeToLocaleString) \
/* Temporal #sec-temporal.plaindatetime.prototype.valueof */ \
CPP(TemporalPlainDateTimePrototypeValueOf) \
/* Temporal #sec-temporal.plaindatetime.prototype.tozoneddatetime */ \
......@@ -1394,6 +1400,8 @@ namespace internal {
CPP(TemporalZonedDateTimePrototypeToString) \
/* Temporal #sec-temporal.zonedddatetimeprototype.tojson */ \
CPP(TemporalZonedDateTimePrototypeToJSON) \
/* Temporal #sec-temporal.zoneddatetime.prototype.tolocalestring */ \
CPP(TemporalZonedDateTimePrototypeToLocaleString) \
/* Temporal #sec-temporal.zoneddatetime.prototype.valueof */ \
CPP(TemporalZonedDateTimePrototypeValueOf) \
/* Temporal #sec-temporal.zoneddatetime.prototype.startofday */ \
......@@ -1462,6 +1470,8 @@ namespace internal {
CPP(TemporalDurationPrototypeToString) \
/* Temporal #sec-temporal.duration.tojson */ \
CPP(TemporalDurationPrototypeToJSON) \
/* Temporal #sec-temporal.duration.prototype.tolocalestring */ \
CPP(TemporalDurationPrototypeToLocaleString) \
/* Temporal #sec-temporal.duration.prototype.valueof */ \
CPP(TemporalDurationPrototypeValueOf) \
\
......@@ -1504,6 +1514,8 @@ namespace internal {
CPP(TemporalInstantPrototypeToString) \
/* Temporal #sec-temporal.instant.tojson */ \
CPP(TemporalInstantPrototypeToJSON) \
/* Temporal #sec-temporal.instant.prototype.tolocalestring */ \
CPP(TemporalInstantPrototypeToLocaleString) \
/* Temporal #sec-temporal.instant.prototype.valueof */ \
CPP(TemporalInstantPrototypeValueOf) \
/* Temporal #sec-temporal.instant.prototype.tozoneddatetime */ \
......@@ -1550,6 +1562,8 @@ namespace internal {
CPP(TemporalPlainYearMonthPrototypeToString) \
/* Temporal #sec-temporal.plainyearmonth.tojson */ \
CPP(TemporalPlainYearMonthPrototypeToJSON) \
/* Temporal #sec-temporal.plainyearmonth.prototype.tolocalestring */ \
CPP(TemporalPlainYearMonthPrototypeToLocaleString) \
/* Temporal #sec-temporal.plainyearmonth.prototype.valueof */ \
CPP(TemporalPlainYearMonthPrototypeValueOf) \
/* Temporal #sec-temporal.plainyearmonth.prototype.toplaindate */ \
......@@ -1578,6 +1592,8 @@ namespace internal {
CPP(TemporalPlainMonthDayPrototypeToString) \
/* Temporal #sec-temporal.plainmonthday.tojson */ \
CPP(TemporalPlainMonthDayPrototypeToJSON) \
/* Temporal #sec-temporal.plainmonthday.prototype.tolocalestring */ \
CPP(TemporalPlainMonthDayPrototypeToLocaleString) \
/* Temporal #sec-temporal.plainmonthday.prototype.valueof */ \
CPP(TemporalPlainMonthDayPrototypeValueOf) \
/* Temporal #sec-temporal.plainmonthday.prototype.toplaindate */ \
......@@ -1834,38 +1850,22 @@ namespace internal {
CPP(TemporalCalendarPrototypeEra) \
/* Temporal #sec-temporal.calendar.prototype.erayear */ \
CPP(TemporalCalendarPrototypeEraYear) \
/* Temporal #sec-temporal.duration.prototype.tolocalestring */ \
CPP(TemporalDurationPrototypeToLocaleString) \
/* Temporal #sec-temporal.instant.prototype.tolocalestring */ \
CPP(TemporalInstantPrototypeToLocaleString) \
/* Temporal #sec-get-temporal.plaindate.prototype.era */ \
CPP(TemporalPlainDatePrototypeEra) \
/* Temporal #sec-get-temporal.plaindate.prototype.erayear */ \
CPP(TemporalPlainDatePrototypeEraYear) \
/* Temporal #sec-temporal.plaindate.prototype.tolocalestring */ \
CPP(TemporalPlainDatePrototypeToLocaleString) \
/* Temporal #sec-get-temporal.plaindatetime.prototype.era */ \
CPP(TemporalPlainDateTimePrototypeEra) \
/* Temporal #sec-get-temporal.plaindatetime.prototype.erayear */ \
CPP(TemporalPlainDateTimePrototypeEraYear) \
/* Temporal #sec-temporal.plaindatetime.prototype.tolocalestring */ \
CPP(TemporalPlainDateTimePrototypeToLocaleString) \
/* Temporal #sec-temporal.plainmonthday.prototype.tolocalestring */ \
CPP(TemporalPlainMonthDayPrototypeToLocaleString) \
/* Temporal #sec-temporal.plaintime.prototype.tolocalestring */ \
CPP(TemporalPlainTimePrototypeToLocaleString) \
/* Temporal #sec-get-temporal.plainyearmonth.prototype.era */ \
CPP(TemporalPlainYearMonthPrototypeEra) \
/* Temporal #sec-get-temporal.plainyearmonth.prototype.erayear */ \
CPP(TemporalPlainYearMonthPrototypeEraYear) \
/* Temporal #sec-temporal.plainyearmonth.prototype.tolocalestring */ \
CPP(TemporalPlainYearMonthPrototypeToLocaleString) \
/* Temporal #sec-get-temporal.zoneddatetime.prototype.era */ \
CPP(TemporalZonedDateTimePrototypeEra) \
/* Temporal #sec-get-temporal.zoneddatetime.prototype.erayear */ \
CPP(TemporalZonedDateTimePrototypeEraYear) \
/* Temporal #sec-temporal.zoneddatetime.prototype.tolocalestring */ \
CPP(TemporalZonedDateTimePrototypeToLocaleString) \
\
CPP(V8BreakIteratorConstructor) \
CPP(V8BreakIteratorInternalAdoptText) \
......
......@@ -60,8 +60,6 @@ TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeEquals)
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainDateTime)
/* Temporal #sec-temporal.plaindate.prototype.tozoneddatetime */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToZonedDateTime)
/* Temporal #sec-temporal.plaindate.prototype.tostring */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToString)
/* Temporal.PlaneTime */
/* Temporal #sec-temporal.plaintime.compare */
......@@ -84,6 +82,8 @@ TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeEquals)
TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToPlainDateTime)
/* Temporal #sec-temporal.plaintime.prototype.tozoneddatetime */
TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToZonedDateTime)
/* Temporal #sec-temporal.plaintime.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToLocaleString)
/* Temporal #sec-temporal.plaintime.prototype.tostring */
TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToString)
/* Temporal #sec-temporal.plaindtimeprototype.tojson */
......@@ -110,6 +110,8 @@ TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeSince)
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeRound)
/* Temporal #sec-temporal.plaindatetime.prototype.equals */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeEquals)
/* Temporal #sec-temporal.plaindatetime.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToLocaleString)
/* Temporal #sec-temporal.plaindatetime.prototype.tostring */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToString)
/* Temporal #sec-temporal.plainddatetimeprototype.tojson */
......@@ -202,6 +204,8 @@ TO_BE_IMPLEMENTED(TemporalDurationPrototypeSubtract)
TO_BE_IMPLEMENTED(TemporalDurationPrototypeRound)
/* Temporal #sec-temporal.duration.prototype.total */
TO_BE_IMPLEMENTED(TemporalDurationPrototypeTotal)
/* Temporal #sec-temporal.duration.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalDurationPrototypeToLocaleString)
/* Temporal #sec-temporal.duration.prototype.tostring */
TO_BE_IMPLEMENTED(TemporalDurationPrototypeToString)
/* Temporal #sec-temporal.duration.tojson */
......@@ -222,6 +226,8 @@ TO_BE_IMPLEMENTED(TemporalInstantPrototypeSince)
TO_BE_IMPLEMENTED(TemporalInstantPrototypeRound)
/* Temporal #sec-temporal.instant.prototype.equals */
TO_BE_IMPLEMENTED(TemporalInstantPrototypeEquals)
/* Temporal #sec-temporal.instant.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalInstantPrototypeToLocaleString)
/* Temporal #sec-temporal.instant.prototype.tostring */
TO_BE_IMPLEMENTED(TemporalInstantPrototypeToString)
/* Temporal #sec-temporal.instant.tojson */
......@@ -248,8 +254,6 @@ TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeUntil)
TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeSince)
/* Temporal #sec-temporal.plainyearmonth.prototype.equals */
TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeEquals)
/* Temporal #sec-temporal.plainyearmonth.tostring */
TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToString)
/* Temporal #sec-temporal.plainyearmonth.prototype.toplaindate */
TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToPlainDate)
......@@ -264,8 +268,6 @@ TO_BE_IMPLEMENTED(TemporalPlainMonthDayFrom)
TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeWith)
/* Temporal #sec-temporal.plainmonthday.prototype.equals */
TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeEquals)
/* Temporal #sec-temporal.plainmonthday.prototype.tostring */
TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToString)
/* Temporal #sec-temporal.plainmonthday.prototype.toplaindate */
TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToPlainDate)
......@@ -273,28 +275,14 @@ TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToPlainDate)
/* Temporal #sec-temporal.calendar.prototype.weekofyear */
TO_BE_IMPLEMENTED(TemporalCalendarPrototypeWeekOfYear)
/* Temporal.ZonedDateTime */
/* Temporal #sec-temporal.zoneddatetime.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToLocaleString)
#ifdef V8_INTL_SUPPORT
/* Temporal */
/* Temporal #sec-temporal.duration.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalDurationPrototypeToLocaleString)
/* Temporal #sec-temporal.instant.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalInstantPrototypeToLocaleString)
/* Temporal #sec-temporal.plaindate.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToLocaleString)
/* Temporal #sec-temporal.plaindatetime.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToLocaleString)
/* Temporal #sec-temporal.plainmonthday.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToLocaleString)
/* Temporal #sec-temporal.plaintime.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToLocaleString)
/* Temporal #sec-temporal.plainyearmonth.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToLocaleString)
/* Temporal #sec-get-temporal.zoneddatetime.prototype.era */
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeEra)
/* Temporal #sec-get-temporal.zoneddatetime.prototype.erayear */
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeEraYear)
/* Temporal #sec-temporal.zoneddatetime.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToLocaleString)
#endif // V8_INTL_SUPPORT
#define TEMPORAL_CONSTRUCTOR1(T) \
......@@ -491,6 +479,8 @@ TEMPORAL_PROTOTYPE_METHOD1(PlainDate, WithCalendar, withCalendar)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, GetISOFields, getISOFields)
TEMPORAL_VALUE_OF(PlainDate)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, ToJSON, toJSON)
TEMPORAL_PROTOTYPE_METHOD2(PlainDate, ToLocaleString, toLocaleString)
TEMPORAL_PROTOTYPE_METHOD1(PlainDate, ToString, toString)
// PlainTime
BUILTIN(TemporalPlainTimeConstructor) {
......@@ -580,7 +570,9 @@ TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, MonthsInYear,
TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, InLeapYear, inLeapYear)
TEMPORAL_PROTOTYPE_METHOD0(PlainYearMonth, GetISOFields, getISOFields)
TEMPORAL_VALUE_OF(PlainYearMonth)
TEMPORAL_PROTOTYPE_METHOD2(PlainYearMonth, ToLocaleString, toLocaleString)
TEMPORAL_PROTOTYPE_METHOD0(PlainYearMonth, ToJSON, toJSON)
TEMPORAL_PROTOTYPE_METHOD1(PlainYearMonth, ToString, toString)
// PlainMonthDay
BUILTIN(TemporalPlainMonthDayConstructor) {
......@@ -599,6 +591,8 @@ TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainMonthDay, Day, day)
TEMPORAL_PROTOTYPE_METHOD0(PlainMonthDay, GetISOFields, getISOFields)
TEMPORAL_VALUE_OF(PlainMonthDay)
TEMPORAL_PROTOTYPE_METHOD0(PlainMonthDay, ToJSON, toJSON)
TEMPORAL_PROTOTYPE_METHOD2(PlainMonthDay, ToLocaleString, toLocaleString)
TEMPORAL_PROTOTYPE_METHOD1(PlainMonthDay, ToString, toString)
// ZonedDateTime
......
......@@ -4829,6 +4829,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
V(since, Since, 1) \
V(equals, Equals, 1) \
V(getISOFields, GetISOFields, 0) \
V(toLocaleString, ToLocaleString, 0) \
V(toPlainDateTime, ToPlainDateTime, 0) \
V(toZonedDateTime, ToZonedDateTime, 1) \
V(toString, ToString, 0) \
......@@ -4841,20 +4842,6 @@ void Genesis::InitializeGlobal_harmony_temporal() {
PLAIN_DATE_FUNC_LIST(INSTALL_PLAIN_DATE_FUNC)
#undef PLAIN_DATE_FUNC_LIST
#undef INSTALL_PLAIN_DATE_FUNC
#ifdef V8_INTL_SUPPORT
#define INSTALL_TO_LOCALE_STRING_FUNC(R) \
SimpleInstallFunction(isolate(), prototype, "toLocaleString", \
Builtin::kTemporal##R##PrototypeToLocaleString, 0, \
false);
#else
#define INSTALL_TO_LOCALE_STRING_FUNC(R) \
/* Install Intl fallback functions. */ \
SimpleInstallFunction(isolate(), prototype, "toLocaleString", \
Builtin::kTemporal##R##PrototypeToString, 0, false);
#endif // V8_INTL_SUPPORT
INSTALL_TO_LOCALE_STRING_FUNC(PlainDate)
}
{ // -- P l a i n T i m e
// #sec-temporal-plaintime-objects
......@@ -4891,6 +4878,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
V(toPlainDateTime, ToPlainDateTime, 1) \
V(toZonedDateTime, ToZonedDateTime, 1) \
V(getISOFields, GetISOFields, 0) \
V(toLocaleString, ToLocaleString, 0) \
V(toString, ToString, 0) \
V(toJSON, ToJSON, 0) \
V(valueOf, ValueOf, 0)
......@@ -4901,8 +4889,6 @@ void Genesis::InitializeGlobal_harmony_temporal() {
PLAIN_TIME_FUNC_LIST(INSTALL_PLAIN_TIME_FUNC)
#undef PLAIN_TIME_FUNC_LIST
#undef INSTALL_PLAIN_TIME_FUNC
INSTALL_TO_LOCALE_STRING_FUNC(PlainTime)
}
{ // -- P l a i n D a t e T i m e
// #sec-temporal-plaindatetime-objects
......@@ -4961,6 +4947,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
V(since, Since, 1) \
V(round, Round, 1) \
V(equals, Equals, 1) \
V(toLocaleString, ToLocaleString, 0) \
V(toJSON, ToJSON, 0) \
V(toString, ToString, 0) \
V(valueOf, ValueOf, 0) \
......@@ -4978,8 +4965,6 @@ void Genesis::InitializeGlobal_harmony_temporal() {
PLAIN_DATE_TIME_FUNC_LIST(INSTALL_PLAIN_DATE_TIME_FUNC)
#undef PLAIN_DATE_TIME_FUNC_LIST
#undef INSTALL_PLAIN_DATE_TIME_FUNC
INSTALL_TO_LOCALE_STRING_FUNC(PlainDateTime)
}
{ // -- Z o n e d D a t e T i m e
// #sec-temporal-zoneddatetime-objects
......@@ -5047,6 +5032,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
V(since, Since, 1) \
V(round, Round, 1) \
V(equals, Equals, 1) \
V(toLocaleString, ToLocaleString, 0) \
V(toString, ToString, 0) \
V(toJSON, ToJSON, 0) \
V(valueOf, ValueOf, 0) \
......@@ -5066,8 +5052,6 @@ void Genesis::InitializeGlobal_harmony_temporal() {
ZONED_DATE_TIME_FUNC_LIST(INSTALL_ZONED_DATE_TIME_FUNC)
#undef ZONED_DATE_TIME_FUNC_LIST
#undef INSTALL_ZONED_DATE_TIME_FUNC
INSTALL_TO_LOCALE_STRING_FUNC(ZonedDateTime)
}
{ // -- D u r a t i o n
// #sec-temporal-duration-objects
......@@ -5106,6 +5090,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
V(subtract, Subtract, 1) \
V(round, Round, 1) \
V(total, Total, 1) \
V(toLocaleString, ToLocaleString, 0) \
V(toString, ToString, 0) \
V(toJSON, ToJSON, 0) \
V(valueOf, ValueOf, 0)
......@@ -5116,8 +5101,6 @@ void Genesis::InitializeGlobal_harmony_temporal() {
DURATION_FUNC_LIST(INSTALL_DURATION_FUNC)
#undef DURATION_FUNC_LIST
#undef INSTALL_DURATION_FUNC
INSTALL_TO_LOCALE_STRING_FUNC(Duration)
}
{ // -- I n s t a n t
// #sec-temporal-instant-objects
......@@ -5154,6 +5137,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
V(since, Since, 1) \
V(round, Round, 1) \
V(equals, Equals, 1) \
V(toLocaleString, ToLocaleString, 0) \
V(toString, ToString, 0) \
V(toJSON, ToJSON, 0) \
V(valueOf, ValueOf, 0) \
......@@ -5166,8 +5150,6 @@ void Genesis::InitializeGlobal_harmony_temporal() {
INSTANT_FUNC_LIST(INSTALL_INSTANT_FUNC)
#undef INSTANT_FUNC_LIST
#undef INSTALL_INSTANT_FUNC
INSTALL_TO_LOCALE_STRING_FUNC(Instant)
}
{ // -- P l a i n Y e a r M o n t h
// #sec-temporal-plainyearmonth-objects
......@@ -5211,6 +5193,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
V(until, Until, 1) \
V(since, Since, 1) \
V(equals, Equals, 1) \
V(toLocaleString, ToLocaleString, 0) \
V(toString, ToString, 0) \
V(toJSON, ToJSON, 0) \
V(valueOf, ValueOf, 0) \
......@@ -5224,8 +5207,6 @@ void Genesis::InitializeGlobal_harmony_temporal() {
PLAIN_YEAR_MONTH_FUNC_LIST(INSTALL_PLAIN_YEAR_MONTH_FUNC)
#undef PLAIN_YEAR_MONTH_FUNC_LIST
#undef INSTALL_PLAIN_YEAR_MONTH_FUNC
INSTALL_TO_LOCALE_STRING_FUNC(PlainYearMonth)
}
{ // -- P l a i n M o n t h D a y
// #sec-temporal-plainmonthday-objects
......@@ -5250,6 +5231,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
#define PLAIN_MONTH_DAY_FUNC_LIST(V) \
V(with, With, 1) \
V(equals, Equals, 1) \
V(toLocaleString, ToLocaleString, 0) \
V(toString, ToString, 0) \
V(toJSON, ToJSON, 0) \
V(valueOf, ValueOf, 0) \
......@@ -5263,10 +5245,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
PLAIN_MONTH_DAY_FUNC_LIST(INSTALL_PLAIN_MONTH_DAY_FUNC)
#undef PLAIN_MONTH_DAY_FUNC_LIST
#undef INSTALL_PLAIN_MONTH_DAY_FUNC
INSTALL_TO_LOCALE_STRING_FUNC(PlainMonthDay)
}
#undef INSTALL_TO_LOCALE_STRING_FUNC
{ // -- T i m e Z o n e
// #sec-temporal-timezone-objects
// #sec-temporal.timezone
......
......@@ -7504,7 +7504,63 @@ MaybeHandle<JSReceiver> JSTemporalPlainDate::GetISOFields(
// #sec-temporal.plaindate.prototype.tojson
MaybeHandle<String> JSTemporalPlainDate::ToJSON(
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date) {
// #sec-temporal.plaindate.prototype.tolocalestring
// 1. Let temporalDate be the this value.
// 2. Perform ? RequireInternalSlot(temporalDate,
// [[InitializedTemporalDate]]).
// 3. Return ? TemporalDateToString(temporalDate, "auto").
return TemporalDateToString(isolate, temporal_date, ShowCalendar::kAuto);
}
namespace {
// #sec-temporal-toshowcalendaroption
Maybe<ShowCalendar> ToShowCalendarOption(Isolate* isolate,
Handle<JSReceiver> options,
const char* method) {
// 1. Return ? GetOption(normalizedOptions, "calendarName", « String », «
// "auto", "always", "never" », "auto").
return GetStringOption<ShowCalendar>(
isolate, options, "calendarName", method, {"auto", "always", "never"},
{ShowCalendar::kAuto, ShowCalendar::kAlways, ShowCalendar::kNever},
ShowCalendar::kAuto);
}
template <typename T,
MaybeHandle<String> (*F)(Isolate*, Handle<T>, ShowCalendar)>
MaybeHandle<String> TemporalToString(Isolate* isolate, Handle<T> temporal,
Handle<Object> options_obj,
const char* method_name) {
// 1. Let temporalDate be the this value.
// 2. Perform ? RequireInternalSlot(temporalDate,
// [[InitializedTemporalDate]]).
// 3. Set options to ? GetOptionsObject(options).
Handle<JSReceiver> options;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, options, GetOptionsObject(isolate, options_obj, method_name),
String);
// 4. Let showCalendar be ? ToShowCalendarOption(options).
ShowCalendar show_calendar;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, show_calendar,
ToShowCalendarOption(isolate, options, method_name), Handle<String>());
// 5. Return ? TemporalDateToString(temporalDate, showCalendar).
return F(isolate, temporal, show_calendar);
}
} // namespace
// #sec-temporal.plaindate.prototype.tostring
MaybeHandle<String> JSTemporalPlainDate::ToString(
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date,
Handle<Object> options) {
return TemporalToString<JSTemporalPlainDate, TemporalDateToString>(
isolate, temporal_date, options, "Temporal.PlainDate.prototype.toString");
}
// #sup-temporal.plaindate.prototype.tolocalestring
MaybeHandle<String> JSTemporalPlainDate::ToLocaleString(
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date,
Handle<Object> locales, Handle<Object> options) {
// TODO(ftang) Implement #sup-temporal.plaindate.prototype.tolocalestring
return TemporalDateToString(isolate, temporal_date, ShowCalendar::kAuto);
}
......@@ -7978,6 +8034,22 @@ MaybeHandle<String> JSTemporalPlainMonthDay::ToJSON(
return TemporalMonthDayToString(isolate, month_day, ShowCalendar::kAuto);
}
// #sec-temporal.plainmonthday.prototype.tostring
MaybeHandle<String> JSTemporalPlainMonthDay::ToString(
Isolate* isolate, Handle<JSTemporalPlainMonthDay> month_day,
Handle<Object> options) {
return TemporalToString<JSTemporalPlainMonthDay, TemporalMonthDayToString>(
isolate, month_day, options, "Temporal.PlainMonthDay.prototype.toString");
}
// #sec-temporal.plainmonthday.prototype.tolocalestring
MaybeHandle<String> JSTemporalPlainMonthDay::ToLocaleString(
Isolate* isolate, Handle<JSTemporalPlainMonthDay> month_day,
Handle<Object> locales, Handle<Object> options) {
// TODO(ftang) Implement #sup-temporal.plainmonthday.prototype.tolocalestring
return TemporalMonthDayToString(isolate, month_day, ShowCalendar::kAuto);
}
MaybeHandle<JSTemporalPlainYearMonth> JSTemporalPlainYearMonth::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
Handle<Object> iso_year_obj, Handle<Object> iso_month_obj,
......@@ -8056,6 +8128,23 @@ MaybeHandle<String> JSTemporalPlainYearMonth::ToJSON(
return TemporalYearMonthToString(isolate, year_month, ShowCalendar::kAuto);
}
// #sec-temporal.plainyearmonth.prototype.tostring
MaybeHandle<String> JSTemporalPlainYearMonth::ToString(
Isolate* isolate, Handle<JSTemporalPlainYearMonth> year_month,
Handle<Object> options) {
return TemporalToString<JSTemporalPlainYearMonth, TemporalYearMonthToString>(
isolate, year_month, options,
"Temporal.PlainYearMonth.prototype.toString");
}
// #sec-temporal.plainyearmonth.prototype.tolocalestring
MaybeHandle<String> JSTemporalPlainYearMonth::ToLocaleString(
Isolate* isolate, Handle<JSTemporalPlainYearMonth> year_month,
Handle<Object> locales, Handle<Object> options) {
// TODO(ftang) Implement #sup-temporal.plainyearmonth.prototype.tolocalestring
return TemporalYearMonthToString(isolate, year_month, ShowCalendar::kAuto);
}
// #sec-temporal-plaintime-constructor
MaybeHandle<JSTemporalPlainTime> JSTemporalPlainTime::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
......
......@@ -138,14 +138,15 @@ class JSTemporalCalendar
Handle<Object> temporal_date_like);
// #sec-temporal.calendar.prototype.tostring
static MaybeHandle<String> ToString(Isolate* isolate,
Handle<JSTemporalCalendar> calendar,
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToString(
Isolate* isolate, Handle<JSTemporalCalendar> calendar,
const char* method_name);
#ifdef V8_INTL_SUPPORT
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> Era(
Isolate* isolate, Handle<JSTemporalCalendar> calendar,
Handle<Object> temporal_date_like);
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> EraYear(
Isolate* isolate, Handle<JSTemporalCalendar> calendar,
Handle<Object> temporal_date_like);
......@@ -263,10 +264,20 @@ class JSTemporalPlainDate
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like);
// #sec-temporal.plaindate.prototype.tostring
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToString(
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date,
Handle<Object> options);
// #sec-temporal.plaindate.prototype.tojson
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToJSON(
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date);
// #sec-temporal.plaindate.prototype.tolocalestring
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToLocaleString(
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date,
Handle<Object> locales, Handle<Object> options);
DECL_PRINTER(JSTemporalPlainDate)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY()
......@@ -338,10 +349,20 @@ class JSTemporalPlainMonthDay
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainMonthDay> month_day);
// #sec-temporal.plainmonthday.prototype.tostring
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToString(
Isolate* isolate, Handle<JSTemporalPlainMonthDay> month_day,
Handle<Object> options);
// #sec-temporal.plainmonthday.prototype.tojson
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToJSON(
Isolate* isolate, Handle<JSTemporalPlainMonthDay> month_day);
// #sec-temporal.plainmonthday.prototype.tolocalestring
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToLocaleString(
Isolate* isolate, Handle<JSTemporalPlainMonthDay> plain_date,
Handle<Object> locales, Handle<Object> options);
DECL_PRINTER(JSTemporalPlainMonthDay)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY()
......@@ -398,10 +419,20 @@ class JSTemporalPlainYearMonth
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainYearMonth> year_month);
// #sec-temporal.plainyearmonth.prototype.tostring
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToString(
Isolate* isolate, Handle<JSTemporalPlainYearMonth> year_month,
Handle<Object> options);
// #sec-temporal.plainyearmonth.prototype.tojson
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToJSON(
Isolate* isolate, Handle<JSTemporalPlainYearMonth> year_month);
// #sec-temporal.plainyearmonth.prototype.tolocalestring
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToLocaleString(
Isolate* isolate, Handle<JSTemporalPlainYearMonth> plain_date,
Handle<Object> locales, Handle<Object> options);
// Abstract Operations
DECL_PRINTER(JSTemporalPlainYearMonth)
......
......@@ -726,8 +726,6 @@
'built-ins/Temporal/PlainDate/prototype/add/overflow-undefined': [FAIL],
'built-ins/Temporal/PlainDate/prototype/add/overflow-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/add/subclassing-ignored': [FAIL],
'built-ins/Temporal/PlainDate/prototype/dayOfWeek/basic': [FAIL],
'built-ins/Temporal/PlainDate/prototype/dayOfYear/basic': [FAIL],
'built-ins/Temporal/PlainDate/prototype/equals/argument-object-invalid': [FAIL],
'built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid': [FAIL],
'built-ins/Temporal/PlainDate/prototype/equals/argument-plaindatetime': [FAIL],
......@@ -795,8 +793,6 @@
'built-ins/Temporal/PlainDate/prototype/subtract/overflow-undefined': [FAIL],
'built-ins/Temporal/PlainDate/prototype/subtract/overflow-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/subtract/subclassing-ignored': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toLocaleString/branding': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toLocaleString/return-string': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-negative-epochnanoseconds': [FAIL],
......@@ -818,16 +814,6 @@
'built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-arguments': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fields-iterable': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/basic': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/branding': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/calendarname-always': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/calendarname-invalid-string': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/calendarname-never': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/options-undefined': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/year-format': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-zoneddatetime-negative-epochnanoseconds': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/basic': [FAIL],
......@@ -1155,7 +1141,6 @@
'built-ins/Temporal/PlainMonthDay/prototype/equals/calendars': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-temporal-object': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/equals/infinity-throws-rangeerror': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toLocaleString/branding': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/argument-not-object': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/branding': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fields-iterable': [FAIL],
......@@ -1163,15 +1148,6 @@
'built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/copies-merge-fields-object': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/infinity-throws-rangeerror': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/limits': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/branding': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-invalid-string': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/options-undefined': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/year-format': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/valueOf/basic': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/with/basic': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/with/branding': [FAIL],
......@@ -1454,7 +1430,6 @@
'built-ins/Temporal/PlainYearMonth/prototype/subtract/overflow-undefined': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/subtract/overflow-wrong-type': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/subtract/subclassing-ignored': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toLocaleString/branding': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/argument-not-object': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/branding': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fields-iterable': [FAIL],
......@@ -1462,12 +1437,6 @@
'built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/copies-merge-fields-object': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/infinity-throws-rangeerror': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/limits': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/branding': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-invalid-string': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/options-undefined': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/year-format': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/until/branding': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateadd-called-with-plaindate-instance': [FAIL],
......@@ -2246,9 +2215,6 @@
'built-ins/Temporal/PlainYearMonth/prototype/subtract/month-length': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/subtract/options-invalid': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/basic': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/until/argument-casting': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/until/arguments-missing-throws': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/until/largestunit-auto': [FAIL],
......@@ -2401,7 +2367,6 @@
'built-ins/Temporal/PlainDate/prototype/add/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/since/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/subtract/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toString/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/until/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/with/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainDateTime/compare/calendar-ignored': [FAIL],
......@@ -2481,7 +2446,6 @@
'built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object': [FAIL],
'built-ins/Temporal/PlainMonthDay/from/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/toString/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/with/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainTime/prototype/round/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainTime/prototype/round/roundto-invalid-string': [FAIL],
......@@ -2493,7 +2457,6 @@
'built-ins/Temporal/PlainYearMonth/prototype/add/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/since/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/subtract/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/toString/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/until/options-wrong-type': [FAIL],
'built-ins/Temporal/ZonedDateTime/from/options-wrong-type': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/add/options-wrong-type': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment