Commit a2f22f43 authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ
parent 1f35a33d
......@@ -40,10 +40,6 @@ namespace internal {
/* Temporal #sec-temporal.plaindate.compare */
TO_BE_IMPLEMENTED(TemporalPlainDateCompare)
/* Temporal #sec-temporal.plaindate.prototype.toplainyearmonth */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainYearMonth)
/* Temporal #sec-temporal.plaindate.prototype.toplainmonthday */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainMonthDay)
/* Temporal #sec-temporal.plaindate.prototype.add */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeAdd)
/* Temporal #sec-temporal.plaindate.prototype.substract */
......@@ -120,10 +116,6 @@ TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToJSON)
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToZonedDateTime)
/* Temporal #sec-temporal.plaindatetime.prototype.toplaindate */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainDate)
/* Temporal #sec-temporal.plaindatetime.prototype.toplainyearmonth */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainYearMonth)
/* Temporal #sec-temporal.plaindatetime.prototype.toplainmonthday */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainMonthDay)
/* Temporal #sec-temporal.plaindatetime.prototype.toplaintime */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainTime)
......@@ -439,6 +431,8 @@ TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInMonth, daysInMonth)
TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInYear, daysInYear)
TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, MonthsInYear, monthsInYear)
TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, InLeapYear, inLeapYear)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, ToPlainYearMonth, toPlainYearMonth)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, ToPlainMonthDay, toPlainMonthDay)
TEMPORAL_PROTOTYPE_METHOD1(PlainDate, WithCalendar, withCalendar)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, GetISOFields, getISOFields)
TEMPORAL_VALUE_OF(PlainDate)
......@@ -509,6 +503,8 @@ TEMPORAL_GET_SMI(PlainDateTime, Millisecond, iso_millisecond)
TEMPORAL_GET_SMI(PlainDateTime, Microsecond, iso_microsecond)
TEMPORAL_GET_SMI(PlainDateTime, Nanosecond, iso_nanosecond)
TEMPORAL_METHOD2(PlainDateTime, From)
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, ToPlainYearMonth, toPlainYearMonth)
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, ToPlainMonthDay, toPlainMonthDay)
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, GetISOFields, getISOFields)
TEMPORAL_VALUE_OF(PlainDateTime)
......
......@@ -7602,6 +7602,56 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::WithCalendar(
calendar);
}
// Template for common code shared by
// Temporal.PlainDate(Timne)?.prototype.toPlain(YearMonth|MonthDay)
// #sec-temporal.plaindate.prototype.toplainmonthday
// #sec-temporal.plaindate.prototype.toplainyearmonth
// #sec-temporal.plaindatetime.prototype.toplainmonthday
// #sec-temporal.plaindatetime.prototype.toplainyearmonth
template <typename T, typename R,
MaybeHandle<R> (*from_fields)(Isolate*, Handle<JSReceiver>,
Handle<JSReceiver>, Handle<Object>)>
MaybeHandle<R> ToPlain(Isolate* isolate, Handle<T> t, Handle<String> f1,
Handle<String> f2) {
Factory* factory = isolate->factory();
// 1. Let temporalDate be the this value.
// 2. Perform ? RequireInternalSlot(t, [[InitializedTemporalDate]]).
// 3. Let calendar be t.[[Calendar]].
Handle<JSReceiver> calendar(t->calendar(), isolate);
// 4. Let fieldNames be ? CalendarFields(calendar, « f1 , f2 »).
Handle<FixedArray> field_names = factory->NewFixedArray(2);
field_names->set(0, *f1);
field_names->set(1, *f2);
ASSIGN_RETURN_ON_EXCEPTION(isolate, field_names,
CalendarFields(isolate, calendar, field_names), R);
// 5. Let fields be ? PrepareTemporalFields(t, fieldNames, «»).
Handle<JSReceiver> fields;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, fields,
PrepareTemporalFields(isolate, t, field_names, RequiredFields::kNone), R);
// 6. Return ? FromFields(calendar, fields).
return from_fields(isolate, calendar, fields,
isolate->factory()->undefined_value());
}
// #sec-temporal.plaindate.prototype.toplainyearmonth
MaybeHandle<JSTemporalPlainYearMonth> JSTemporalPlainDate::ToPlainYearMonth(
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date) {
return ToPlain<JSTemporalPlainDate, JSTemporalPlainYearMonth,
YearMonthFromFields>(isolate, temporal_date,
isolate->factory()->monthCode_string(),
isolate->factory()->year_string());
}
// #sec-temporal.plaindate.prototype.toplainmonthday
MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainDate::ToPlainMonthDay(
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date) {
return ToPlain<JSTemporalPlainDate, JSTemporalPlainMonthDay,
MonthDayFromFields>(isolate, temporal_date,
isolate->factory()->day_string(),
isolate->factory()->monthCode_string());
}
// #sec-temporal.now.plaindate
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Now(
Isolate* isolate, Handle<Object> calendar_like,
......@@ -8094,6 +8144,24 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::WithCalendar(
calendar);
}
// #sec-temporal.plaindatetime.prototype.toplainyearmonth
MaybeHandle<JSTemporalPlainYearMonth> JSTemporalPlainDateTime::ToPlainYearMonth(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time) {
return ToPlain<JSTemporalPlainDateTime, JSTemporalPlainYearMonth,
YearMonthFromFields>(isolate, date_time,
isolate->factory()->monthCode_string(),
isolate->factory()->year_string());
}
// #sec-temporal.plaindatetime.prototype.toplainmonthday
MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainDateTime::ToPlainMonthDay(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time) {
return ToPlain<JSTemporalPlainDateTime, JSTemporalPlainMonthDay,
MonthDayFromFields>(isolate, date_time,
isolate->factory()->day_string(),
isolate->factory()->monthCode_string());
}
// #sec-temporal.now.plaindatetime
MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Now(
Isolate* isolate, Handle<Object> calendar_like,
......
......@@ -259,6 +259,14 @@ class JSTemporalPlainDate
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date);
// #sec-temporal.plaindate.prototype.toplainyearmonth
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainYearMonth>
ToPlainYearMonth(Isolate* isolate, Handle<JSTemporalPlainDate> plain_date);
// #sec-temporal.plaindate.prototype.toplainmonthday
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainMonthDay>
ToPlainMonthDay(Isolate* isolate, Handle<JSTemporalPlainDate> plain_date);
// #sec-temporal.now.plaindate
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> Now(
Isolate* isolate, Handle<Object> calendar_like,
......@@ -313,6 +321,14 @@ class JSTemporalPlainDateTime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDateTime> From(
Isolate* isolate, Handle<Object> item, Handle<Object> options);
// #sec-temporal.plaindatetime.prototype.toplainyearmonth
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainYearMonth>
ToPlainYearMonth(Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time);
// #sec-temporal.plaindatetime.prototype.toplainmonthday
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainMonthDay>
ToPlainMonthDay(Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time);
// #sec-temporal.plaindatetime.prototype.getisofields
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time);
......
......@@ -69,15 +69,11 @@
'temporal/plain-date-time-subtract': [FAIL],
'temporal/plain-date-time-to-json': [FAIL],
'temporal/plain-date-time-to-plain-date': [FAIL],
'temporal/plain-date-time-to-plain-month-day': [FAIL],
'temporal/plain-date-time-to-plain-time': [FAIL],
'temporal/plain-date-time-to-plain-year-month': [FAIL],
'temporal/plain-date-time-with': [FAIL],
'temporal/plain-date-time-with-plain-date': [FAIL],
'temporal/plain-date-time-with-plain-time': [FAIL],
'temporal/plain-date-to-plain-date-time': [FAIL],
'temporal/plain-date-to-plain-month-day': [FAIL],
'temporal/plain-date-to-plain-year-month': [FAIL],
'temporal/plain-date-with': [FAIL],
##############################################################################
......
......@@ -804,14 +804,6 @@
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/plaintime-propertybag-no-time-units': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/time-invalid': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/time-undefined': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/branding': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-arguments': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fields-iterable': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/branding': [FAIL],
'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/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],
......@@ -996,15 +988,7 @@
'built-ins/Temporal/PlainDateTime/prototype/toLocaleString/return-string': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainDate/branding': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainDate/limits': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/branding': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-arguments': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fields-iterable': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainTime/branding': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/branding': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-arguments': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fields-iterable': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/branding': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined': [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