Skip to content

Commit

Permalink
Bug 1840374 - Part 41: Sync spec references in Temporal parsing. r=sp…
Browse files Browse the repository at this point in the history
…idermonkey-reviewers,mgaudet

Implement the changes from
- tc39/proposal-temporal#2600
- tc39/proposal-temporal#2604
- tc39/proposal-temporal#2606

Also moves `annotationValueComponent()` into the class, because it's both
simpler and faster than the previous implementation.

Depends on D182060

Differential Revision: https://phabricator.services.mozilla.com/D182061

UltraBlame original commit: 2de7da340caaad8e668a54faa44ec24696453005
  • Loading branch information
marco-c committed Jul 21, 2023
1 parent 26274a7 commit d89c6b7
Showing 1 changed file with 13 additions and 61 deletions.
74 changes: 13 additions & 61 deletions js/src/builtin/temporal/TemporalParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,6 @@ class TemporalParser final {





bool tzCharLegacy() {
if (!reader_.hasMore(1)) {
return false;
Expand Down Expand Up @@ -770,17 +768,19 @@ class TemporalParser final {



bool aValChar() {
if (!reader_.hasMore(1)) {
return false;
bool annotationValueComponent() {
size_t index = reader_.index();
size_t i = 0;
for (; index + i < reader_.length(); i++) {
auto ch = reader_.at(index + i);
if (!mozilla::IsAsciiAlphanumeric(ch)) {
break;
}
}

CharT ch = reader_.current();
if (!mozilla::IsAsciiAlphanumeric(ch)) {
if (i == 0) {
return false;
}

reader_.advance(1);
reader_.advance(i);
return true;
}

Expand Down Expand Up @@ -843,7 +843,6 @@ class TemporalParser final {
bool timeZoneIANANameComponent();
mozilla::Result<TimeZoneName, ParserError> timeZoneIANAName();

bool annotationValueComponent();
mozilla::Result<AnnotationKey, ParserError> annotationKey();
mozilla::Result<AnnotationValue, ParserError> annotationValue();
mozilla::Result<Annotation, ParserError> annotation();
Expand Down Expand Up @@ -935,11 +934,6 @@ mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::date() {








if (auto year = digits(4)) {
result.year = year.value();
} else if (hasSign()) {
Expand Down Expand Up @@ -1014,6 +1008,7 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() {




if (auto hour = digits(2)) {
result.hour = hour.value();
if (!inBounds(result.hour, 0, 23)) {
Expand Down Expand Up @@ -1201,6 +1196,7 @@ TemporalParser<CharT>::timeZoneAnnotation() {





if (!character('[')) {
return mozilla::Err(JSMSG_TEMPORAL_PARSER_BRACKET_BEFORE_TIMEZONE);
Expand Down Expand Up @@ -1240,24 +1236,6 @@ TemporalParser<CharT>::timeZoneIANAName() {
























Expand Down Expand Up @@ -1442,6 +1420,7 @@ TemporalParser<CharT>::parseTemporalTimeZoneString() {





if (hasTzLeadingChar()) {
if (auto name = timeZoneIANAName(); name.isOk() && reader_.atEnd()) {
Expand Down Expand Up @@ -2024,29 +2003,12 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx,
return true;
}

template <typename CharT>
bool TemporalParser<CharT>::annotationValueComponent() {






bool hasOne = false;
while (aValChar()) {
hasOne = true;
}
return hasOne;
}

template <typename CharT>
mozilla::Result<AnnotationKey, ParserError>
TemporalParser<CharT>::annotationKey() {






size_t start = reader_.index();

Expand All @@ -2067,9 +2029,6 @@ TemporalParser<CharT>::annotationValue() {







size_t start = reader_.index();

Expand Down Expand Up @@ -2425,11 +2384,6 @@ TemporalParser<CharT>::dateSpecYearMonth() {








if (auto year = digits(4)) {
result.year = year.value();
} else if (hasSign()) {
Expand Down Expand Up @@ -2474,8 +2428,6 @@ TemporalParser<CharT>::dateSpecMonthDay() {





PlainDate result = {};

string("--");
Expand Down

0 comments on commit d89c6b7

Please sign in to comment.