// Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_OBJECTS_JS_TEMPORAL_OBJECTS_H_ #define V8_OBJECTS_JS_TEMPORAL_OBJECTS_H_ #include "src/execution/isolate.h" #include "src/heap/factory.h" #include "src/objects/objects.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" namespace v8 { namespace internal { #include "torque-generated/src/objects/js-temporal-objects-tq.inc" #define DECLARE_TEMPORAL_INLINE_GETTER_SETTER(field) \ inline void set_##field(int32_t field); \ inline int32_t field() const; #define DECLARE_TEMPORAL_TIME_INLINE_GETTER_SETTER() \ DECLARE_TEMPORAL_INLINE_GETTER_SETTER(iso_hour) \ DECLARE_TEMPORAL_INLINE_GETTER_SETTER(iso_minute) \ DECLARE_TEMPORAL_INLINE_GETTER_SETTER(iso_second) \ DECLARE_TEMPORAL_INLINE_GETTER_SETTER(iso_millisecond) \ DECLARE_TEMPORAL_INLINE_GETTER_SETTER(iso_microsecond) \ DECLARE_TEMPORAL_INLINE_GETTER_SETTER(iso_nanosecond) #define DECLARE_TEMPORAL_DATE_INLINE_GETTER_SETTER() \ DECLARE_TEMPORAL_INLINE_GETTER_SETTER(iso_year) \ DECLARE_TEMPORAL_INLINE_GETTER_SETTER(iso_month) \ DECLARE_TEMPORAL_INLINE_GETTER_SETTER(iso_day) #define TEMPORAL_UNIMPLEMENTED(T) \ { \ printf("TBW %s\n", __PRETTY_FUNCTION__); \ UNIMPLEMENTED(); \ } class JSTemporalPlainDate; class JSTemporalPlainMonthDay; class JSTemporalPlainYearMonth; class JSTemporalCalendar : public TorqueGeneratedJSTemporalCalendar { public: // #sec-temporal.calendar V8_WARN_UNUSED_RESULT static MaybeHandle Constructor( Isolate* isolate, Handle target, Handle new_target, Handle identifier); // #sec-temporal.calendar.prototype.year V8_WARN_UNUSED_RESULT static MaybeHandle Year( Isolate* isolate, Handle calendar, Handle temporal_date_like); // #sec-temporal.calendar.prototype.daysinyear V8_WARN_UNUSED_RESULT static MaybeHandle DaysInYear( Isolate* isolate, Handle calendar, Handle temporal_date_like); // #sec-temporal.calendar.prototype.dayofweek V8_WARN_UNUSED_RESULT static MaybeHandle DayOfWeek( Isolate* isolate, Handle calendar, Handle temporal_date_like); // #sec-temporal.calendar.prototype.dayofyear V8_WARN_UNUSED_RESULT static MaybeHandle DayOfYear( Isolate* isolate, Handle calendar, Handle temporal_date_like); // #sec-temporal.calendar.prototype.monthsinyear V8_WARN_UNUSED_RESULT static MaybeHandle MonthsInYear( Isolate* isolate, Handle calendar, Handle temporal_date_like); // #sec-temporal.calendar.prototype.inleapyear V8_WARN_UNUSED_RESULT static MaybeHandle InLeapYear( Isolate* isolate, Handle calendar, Handle temporal_date_like); // #sec-temporal.calendar.prototype.daysinmonth V8_WARN_UNUSED_RESULT static MaybeHandle DaysInMonth( Isolate* isolate, Handle calendar, Handle temporal_date_like); // #sec-temporal.calendar.prototype.daysinweek V8_WARN_UNUSED_RESULT static MaybeHandle DaysInWeek( Isolate* isolate, Handle calendar, Handle temporal_date_like); // #sec-temporal.calendar.prototype.datefromfields V8_WARN_UNUSED_RESULT static MaybeHandle DateFromFields( Isolate* isolate, Handle calendar, Handle fields, Handle options); // #sec-temporal.calendar.prototype.mergefields V8_WARN_UNUSED_RESULT static MaybeHandle MergeFields( Isolate* isolate, Handle calendar, Handle fields, Handle additional_fields); // #sec-temporal.calendar.prototype.tostring static MaybeHandle ToString(Isolate* isolate, Handle calendar, const char* method); DECL_PRINTER(JSTemporalCalendar) DEFINE_TORQUE_GENERATED_JS_TEMPORAL_CALENDAR_FLAGS() DECL_INT_ACCESSORS(calendar_index) TQ_OBJECT_CONSTRUCTORS(JSTemporalCalendar) }; class JSTemporalDuration : public TorqueGeneratedJSTemporalDuration { public: // #sec-temporal.duration V8_WARN_UNUSED_RESULT static MaybeHandle Constructor( Isolate* isolate, Handle target, Handle new_target, Handle years, Handle months, Handle weeks, Handle days, Handle hours, Handle minutes, Handle seconds, Handle milliseconds, Handle microseconds, Handle nanoseconds); // #sec-get-temporal.duration.prototype.sign V8_WARN_UNUSED_RESULT static MaybeHandle Sign( Isolate* isolate, Handle duration); // #sec-get-temporal.duration.prototype.blank V8_WARN_UNUSED_RESULT static MaybeHandle Blank( Isolate* isolate, Handle duration); // #sec-temporal.duration.prototype.negated V8_WARN_UNUSED_RESULT static MaybeHandle Negated( Isolate* isolate, Handle duration); // #sec-temporal.duration.prototype.abs V8_WARN_UNUSED_RESULT static MaybeHandle Abs( Isolate* isolate, Handle duration); DECL_PRINTER(JSTemporalDuration) TQ_OBJECT_CONSTRUCTORS(JSTemporalDuration) }; class JSTemporalInstant : public TorqueGeneratedJSTemporalInstant { public: // #sec-temporal-instant-constructor V8_WARN_UNUSED_RESULT static MaybeHandle Constructor( Isolate* isolate, Handle target, Handle new_target, Handle epoch_nanoseconds); // #sec-temporal.now.instant V8_WARN_UNUSED_RESULT static MaybeHandle Now( Isolate* isolate); // #sec-temporal.instant.fromepochseconds V8_WARN_UNUSED_RESULT static MaybeHandle FromEpochSeconds( Isolate* isolate, Handle epoch_seconds); // #sec-temporal.instant.fromepochmilliseconds V8_WARN_UNUSED_RESULT static MaybeHandle FromEpochMilliseconds(Isolate* isolate, Handle epoch_milliseconds); // #sec-temporal.instant.fromepochmicroseconds V8_WARN_UNUSED_RESULT static MaybeHandle FromEpochMicroseconds(Isolate* isolate, Handle epoch_microseconds); // #sec-temporal.instant.fromepochnanoeconds V8_WARN_UNUSED_RESULT static MaybeHandle FromEpochNanoseconds(Isolate* isolate, Handle epoch_nanoseconds); // #sec-temporal.instant.from V8_WARN_UNUSED_RESULT static MaybeHandle From( Isolate* isolate, Handle item); DECL_PRINTER(JSTemporalInstant) TQ_OBJECT_CONSTRUCTORS(JSTemporalInstant) }; class JSTemporalPlainDate : public TorqueGeneratedJSTemporalPlainDate { public: // #sec-temporal-createtemporaldate V8_WARN_UNUSED_RESULT static MaybeHandle Constructor( Isolate* isolate, Handle target, Handle new_target, Handle iso_year, Handle iso_month, Handle iso_day, Handle calendar_like); // #sec-temporal.plaindate.prototype.withcalendar V8_WARN_UNUSED_RESULT static MaybeHandle WithCalendar( Isolate* isolate, Handle plain_date, Handle calendar_like); // #sec-temporal.plaindate.from V8_WARN_UNUSED_RESULT static MaybeHandle From( Isolate* isolate, Handle item, Handle options); // #sec-temporal.plaindate.prototype.getisofields V8_WARN_UNUSED_RESULT static MaybeHandle GetISOFields( Isolate* isolate, Handle plain_date); // #sec-temporal.now.plaindate V8_WARN_UNUSED_RESULT static MaybeHandle Now( Isolate* isolate, Handle calendar_like, Handle temporal_time_zone_like); // #sec-temporal.now.plaindateiso V8_WARN_UNUSED_RESULT static MaybeHandle NowISO( Isolate* isolate, Handle temporal_time_zone_like); DECL_PRINTER(JSTemporalPlainDate) DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY() DECLARE_TEMPORAL_DATE_INLINE_GETTER_SETTER() TQ_OBJECT_CONSTRUCTORS(JSTemporalPlainDate) }; class JSTemporalPlainDateTime : public TorqueGeneratedJSTemporalPlainDateTime { public: // #sec-temporal-createtemporaldatetime V8_WARN_UNUSED_RESULT static MaybeHandle Constructor( Isolate* isolate, Handle target, Handle new_target, Handle iso_year, Handle iso_month, Handle iso_day, Handle hour, Handle minute, Handle second, Handle millisecond, Handle microsecond, Handle nanosecond, Handle calendar_like); // #sec-temporal.plaindatetime.prototype.withcalendar V8_WARN_UNUSED_RESULT static MaybeHandle WithCalendar(Isolate* isolate, Handle date_time, Handle calendar_like); // #sec-temporal.plaindatetime.prototype.getisofields V8_WARN_UNUSED_RESULT static MaybeHandle GetISOFields( Isolate* isolate, Handle date_time); // #sec-temporal.now.plaindatetime V8_WARN_UNUSED_RESULT static MaybeHandle Now( Isolate* isolate, Handle calendar_like, Handle temporal_time_zone_like); // #sec-temporal.now.plaindatetimeiso V8_WARN_UNUSED_RESULT static MaybeHandle NowISO( Isolate* isolate, Handle temporal_time_zone_like); DECL_PRINTER(JSTemporalPlainDateTime) DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY() DEFINE_TORQUE_GENERATED_JS_TEMPORAL_HOUR_MINUTE_SECOND() DEFINE_TORQUE_GENERATED_JS_TEMPORAL_SECOND_PARTS() DECLARE_TEMPORAL_DATE_INLINE_GETTER_SETTER() DECLARE_TEMPORAL_TIME_INLINE_GETTER_SETTER() TQ_OBJECT_CONSTRUCTORS(JSTemporalPlainDateTime) }; class JSTemporalPlainMonthDay : public TorqueGeneratedJSTemporalPlainMonthDay { public: // ##sec-temporal.plainmonthday V8_WARN_UNUSED_RESULT static MaybeHandle Constructor( Isolate* isolate, Handle target, Handle new_target, Handle iso_month, Handle iso_day, Handle calendar_like, Handle reference_iso_year); // #sec-temporal.plainmonthday.prototype.getisofields V8_WARN_UNUSED_RESULT static MaybeHandle GetISOFields( Isolate* isolate, Handle month_day); DECL_PRINTER(JSTemporalPlainMonthDay) DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY() DECLARE_TEMPORAL_DATE_INLINE_GETTER_SETTER() TQ_OBJECT_CONSTRUCTORS(JSTemporalPlainMonthDay) }; class JSTemporalPlainTime : public TorqueGeneratedJSTemporalPlainTime { public: // #sec-temporal-plaintime-constructor V8_WARN_UNUSED_RESULT static MaybeHandle Constructor( Isolate* isolate, Handle target, Handle new_target, Handle hour, Handle minute, Handle second, Handle millisecond, Handle microsecond, Handle nanosecond); // #sec-temporal.plaintime.from V8_WARN_UNUSED_RESULT static MaybeHandle From( Isolate* isolate, Handle item, Handle options); // #sec-temporal.plaintime.prototype.getisofields V8_WARN_UNUSED_RESULT static MaybeHandle GetISOFields( Isolate* isolate, Handle plain_time); // #sec-temporal.now.plaintimeiso V8_WARN_UNUSED_RESULT static MaybeHandle NowISO( Isolate* isolate, Handle temporal_time_zone_like); DECL_PRINTER(JSTemporalPlainTime) DEFINE_TORQUE_GENERATED_JS_TEMPORAL_HOUR_MINUTE_SECOND() DEFINE_TORQUE_GENERATED_JS_TEMPORAL_SECOND_PARTS() DECLARE_TEMPORAL_TIME_INLINE_GETTER_SETTER() TQ_OBJECT_CONSTRUCTORS(JSTemporalPlainTime) }; class JSTemporalPlainYearMonth : public TorqueGeneratedJSTemporalPlainYearMonth { public: // ##sec-temporal.plainyearmonth V8_WARN_UNUSED_RESULT static MaybeHandle Constructor(Isolate* isolate, Handle target, Handle new_target, Handle iso_year, Handle iso_month, Handle calendar_like, Handle reference_iso_day); // #sec-temporal.plainyearmonth.prototype.getisofields V8_WARN_UNUSED_RESULT static MaybeHandle GetISOFields( Isolate* isolate, Handle year_month); // Abstract Operations DECL_PRINTER(JSTemporalPlainYearMonth) DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY() DECLARE_TEMPORAL_DATE_INLINE_GETTER_SETTER() TQ_OBJECT_CONSTRUCTORS(JSTemporalPlainYearMonth) }; class JSTemporalTimeZone : public TorqueGeneratedJSTemporalTimeZone { public: // #sec-temporal.now.timezone V8_WARN_UNUSED_RESULT static MaybeHandle Now( Isolate* isolate); // #sec-temporal.timezone V8_WARN_UNUSED_RESULT static MaybeHandle Constructor( Isolate* isolate, Handle target, Handle new_target, Handle identifier); // #sec-temporal.timezone.prototype.tostring static MaybeHandle ToString(Isolate* isolate, Handle time_zone, const char* method); DECL_PRINTER(JSTemporalTimeZone) DEFINE_TORQUE_GENERATED_JS_TEMPORAL_TIME_ZONE_FLAGS() DEFINE_TORQUE_GENERATED_JS_TEMPORAL_TIME_ZONE_SUB_MILLISECONDS() DECL_BOOLEAN_ACCESSORS(is_offset) DECL_INT_ACCESSORS(offset_milliseconds_or_time_zone_index) DECLARE_TEMPORAL_INLINE_GETTER_SETTER(offset_milliseconds) DECLARE_TEMPORAL_INLINE_GETTER_SETTER(offset_sub_milliseconds) int32_t time_zone_index() const; int64_t offset_nanoseconds() const; void set_offset_nanoseconds(int64_t offset_nanoseconds); MaybeHandle id(Isolate* isolate) const; TQ_OBJECT_CONSTRUCTORS(JSTemporalTimeZone) }; class JSTemporalZonedDateTime : public TorqueGeneratedJSTemporalZonedDateTime { public: // #sec-temporal.zoneddatetime V8_WARN_UNUSED_RESULT static MaybeHandle Constructor( Isolate* isolate, Handle target, Handle new_target, Handle epoch_nanoseconds, Handle time_zone_like, Handle calendar_like); // #sec-temporal.zoneddatetime.prototype.withcalendar V8_WARN_UNUSED_RESULT static MaybeHandle WithCalendar(Isolate* isolate, Handle zoned_date_time, Handle calendar_like); // #sec-temporal.zoneddatetime.prototype.withtimezone V8_WARN_UNUSED_RESULT static MaybeHandle WithTimeZone(Isolate* isolate, Handle zoned_date_time, Handle time_zone_like); // #sec-temporal.zoneddatetime.prototype.getisofields V8_WARN_UNUSED_RESULT static MaybeHandle GetISOFields( Isolate* isolate, Handle zoned_date_time); // #sec-temporal.zoneddatetime.prototype.toplainyearmonth V8_WARN_UNUSED_RESULT static MaybeHandle ToPlainYearMonth(Isolate* isolate, Handle zoned_date_time); // #sec-temporal.zoneddatetime.prototype.toplainmonthday V8_WARN_UNUSED_RESULT static MaybeHandle ToPlainMonthDay(Isolate* isolate, Handle zoned_date_time); // #sec-temporal.now.zoneddatetime V8_WARN_UNUSED_RESULT static MaybeHandle Now( Isolate* isolate, Handle calendar_like, Handle temporal_time_zone_like); // #sec-temporal.now.zoneddatetimeiso V8_WARN_UNUSED_RESULT static MaybeHandle NowISO( Isolate* isolate, Handle temporal_time_zone_like); DECL_PRINTER(JSTemporalZonedDateTime) TQ_OBJECT_CONSTRUCTORS(JSTemporalZonedDateTime) }; namespace temporal { // #sec-temporal-createtemporalinstant V8_WARN_UNUSED_RESULT MaybeHandle CreateTemporalInstant( Isolate* isolate, Handle target, Handle new_target, Handle epoch_nanoseconds); V8_WARN_UNUSED_RESULT MaybeHandle CreateTemporalInstant( Isolate* isolate, Handle epoch_nanoseconds); // #sec-temporal-calendaryear #define DECLARE_CALENDAR_ABSTRACT_OPERATION(Name) \ V8_WARN_UNUSED_RESULT MaybeHandle Calendar##Name( \ Isolate* isolate, Handle calendar, \ Handle date_like); DECLARE_CALENDAR_ABSTRACT_OPERATION(Year) DECLARE_CALENDAR_ABSTRACT_OPERATION(Month) DECLARE_CALENDAR_ABSTRACT_OPERATION(MonthCode) DECLARE_CALENDAR_ABSTRACT_OPERATION(Day) #ifdef V8_INTL_SUPPORT DECLARE_CALENDAR_ABSTRACT_OPERATION(Era) DECLARE_CALENDAR_ABSTRACT_OPERATION(EraYear) #endif // V8_INTL_SUPPORT #undef DECLARE_CALENDAR_ABSTRACT_OPERATION // #sec-temporal-getiso8601calendar V8_WARN_UNUSED_RESULT MaybeHandle GetISO8601Calendar( Isolate* isolate); // #sec-temporal-builtintimezonegetplaindatetimefor V8_WARN_UNUSED_RESULT MaybeHandle BuiltinTimeZoneGetPlainDateTimeFor(Isolate* isolate, Handle time_zone, Handle instant, Handle calendar, const char* method); V8_WARN_UNUSED_RESULT MaybeHandle InvokeCalendarMethod( Isolate* isolate, Handle calendar, Handle name, Handle temporal_like); V8_WARN_UNUSED_RESULT MaybeHandle ToTemporalCalendar( Isolate* isolate, Handle temporal_calendar_like, const char* method); V8_WARN_UNUSED_RESULT MaybeHandle ToTemporalTimeZone( Isolate* isolate, Handle temporal_time_zone_like, const char* method); } // namespace temporal } // namespace internal } // namespace v8 #include "src/objects/object-macros-undef.h" #endif // V8_OBJECTS_JS_TEMPORAL_OBJECTS_H_