v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
temporal-parser.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_TEMPORAL_TEMPORAL_PARSER_H_
6#define V8_TEMPORAL_TEMPORAL_PARSER_H_
7
8#include <optional>
9
11
12namespace v8::internal {
13
25 int32_t date_year; // DateYear production
26 int32_t date_month; // DateMonth production
27 int32_t date_day; // DateDay production
28 int32_t time_hour; // TimeHour production
29 int32_t time_minute; // TimeMinute production
30 int32_t time_second; // TimeSecond production
31 int32_t
32 time_nanosecond; // TimeFractionalPart production stored in nanosecond
33 int32_t tzuo_sign; // TimeZoneUTCOffsetSign production
34 int32_t tzuo_hour; // TimeZoneUTCOffsetHour production
35 int32_t tzuo_minute; // TimeZoneUTCOffsetMinute production
36 int32_t tzuo_second; // TimeZoneUTCOffsetSecond production
37 int32_t
38 tzuo_nanosecond; // TimeZoneUTCOffsetFractionalPart stored in nanosecond
39 bool utc_designator; // UTCDesignator is presented
40 int32_t tzi_name_start; // Starting offset of TimeZoneIANAName in the input
41 // string.
42 int32_t tzi_name_length; // Length of TimeZoneIANAName production
43 int32_t calendar_name_start; // Starting offset of CalendarName production in
44 // the input string.
45 int32_t calendar_name_length; // Length of CalendarName production.
46 int32_t offset_string_start; // Starting offset of TimeZoneNumericUTCOffset
47 // in the input string.
48 int32_t
49 offset_string_length; // Length of TimeZoneNumericUTCOffset production
50
71
72 bool date_year_is_undefined() const { return date_year == kMinInt31; }
73 bool date_month_is_undefined() const { return date_month == kMinInt31; }
74 bool date_day_is_undefined() const { return date_day == kMinInt31; }
75 bool time_hour_is_undefined() const { return time_hour == kMinInt31; }
79 return time_nanosecond == kMinInt31;
80 }
81 bool tzuo_hour_is_undefined() const { return tzuo_hour == kMinInt31; }
84 bool tzuo_sign_is_undefined() const { return tzuo_sign == kMinInt31; }
86 return tzuo_nanosecond == kMinInt31;
87 }
88};
89
98 double sign; // Sign production
99 double years; // DurationYears production
100 double months; // DurationMonths production
101 double weeks; // DurationWeeks production
102 double days; // DurationDays production
103 double whole_hours; // DurationWholeHours production
104 double whole_minutes; // DurationWholeMinutes production
105 double whole_seconds; // DurationWholeSeconds production
106 int32_t hours_fraction; // DurationHoursFraction, in unit of 1e-9 hours
107 int32_t minutes_fraction; // DurationMinuteFraction, in unit of 1e-9 minutes
108 int32_t seconds_fraction; // DurationSecondFraction, in unit of nanosecond (
109 // 1e-9 seconds).
110
111 static constexpr int32_t kEmpty = -1;
124};
125
135 public:
136#define DEFINE_PARSE_METHOD(R, NAME) \
137 V8_WARN_UNUSED_RESULT static std::optional<R> Parse##NAME( \
138 Isolate* isolate, DirectHandle<String> iso_string)
140 DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalDateTimeString);
142 DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalYearMonthString);
143 DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalMonthDayString);
145 DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalZonedDateTimeString);
147 DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalRelativeToString);
150 DEFINE_PARSE_METHOD(ParsedISO8601Result, TimeZoneNumericUTCOffset);
151};
152#undef DEFINE_PARSE_METHOD
153
154} // namespace v8::internal
155
156#endif // V8_TEMPORAL_TEMPORAL_PARSER_H_
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalYearMonthString)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalMonthDayString)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TimeZoneIdentifier)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalTimeString)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalDateTimeString)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalInstantString)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalRelativeToString)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TimeZoneNumericUTCOffset)
DEFINE_PARSE_METHOD(ParsedISO8601Duration, TemporalDurationString)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalZonedDateTimeString)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalDateString)
DEFINE_PARSE_METHOD(ParsedISO8601Result, CalendarName)
constexpr int kMinInt31
Definition globals.h:385
#define V8_EXPORT_PRIVATE
Definition macros.h:460