[temporal] Sync parser change in PR1957

https://github.com/tc39/proposal-temporal/pull/1957
Resolve https://github.com/tc39/proposal-temporal/issues/1794

Bug: v8:11544
Change-Id: I50d406848e815b400d6e0cd14dee95589aac0647
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3318718
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78263}
This commit is contained in:
Frank Tang 2021-12-06 11:50:27 -08:00 committed by V8 LUCI CQ
parent eb8849a594
commit 40deaa1768

View File

@ -182,10 +182,20 @@ int32_t ScanFractionalPart(base::Vector<Char> str, int32_t s, int64_t* out) {
// TimeFraction: FractionalPart // TimeFraction: FractionalPart
SCAN_FORWARD(TimeFractionalPart, FractionalPart, int32_t) SCAN_FORWARD(TimeFractionalPart, FractionalPart, int32_t)
// Fraction: DecimalSeparator TimeFractionalPart // Fraction: DecimalSeparator FractionalPart
// DecimalSeparator: one of , . // DecimalSeparator: one of , .
template <typename Char> template <typename Char>
int32_t ScanFraction(base::Vector<Char> str, int32_t s, int32_t* out) { int32_t ScanFraction(base::Vector<Char> str, int32_t s, int32_t* out) {
if ((str.length() < (s + 2)) || (!IsDecimalSeparator(str[s]))) return 0;
int32_t len;
if ((len = ScanFractionalPart(str, s + 1, out)) == 0) return 0;
return len + 1;
}
// TimeFraction: DecimalSeparator TimeFractionalPart
// DecimalSeparator: one of , .
template <typename Char>
int32_t ScanTimeFraction(base::Vector<Char> str, int32_t s, int32_t* out) {
if ((str.length() < (s + 2)) || (!IsDecimalSeparator(str[s]))) return 0; if ((str.length() < (s + 2)) || (!IsDecimalSeparator(str[s]))) return 0;
int32_t len; int32_t len;
if ((len = ScanTimeFractionalPart(str, s + 1, out)) == 0) return 0; if ((len = ScanTimeFractionalPart(str, s + 1, out)) == 0) return 0;
@ -193,12 +203,10 @@ int32_t ScanFraction(base::Vector<Char> str, int32_t s, int32_t* out) {
} }
template <typename Char> template <typename Char>
int32_t ScanFraction(base::Vector<Char> str, int32_t s, int32_t ScanTimeFraction(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) { ParsedISO8601Result* r) {
return ScanFraction(str, s, &(r->time_nanosecond)); return ScanTimeFraction(str, s, &(r->time_nanosecond));
} }
// TimeFraction: Fraction
SCAN_FORWARD(TimeFraction, Fraction, ParsedISO8601Result)
// TimeSpec: // TimeSpec:
// TimeHour // TimeHour
@ -544,7 +552,6 @@ int32_t ScanTimeZoneUTCOffsetName(base::Vector<Char> str, int32_t s) {
if ((len = ScanMinuteSecond(str, cur, &second)) == 0) return 0; if ((len = ScanMinuteSecond(str, cur, &second)) == 0) return 0;
cur += len; cur += len;
len = ScanFraction(str, cur, &fraction); len = ScanFraction(str, cur, &fraction);
// TODO(ftang) Problem See Issue 1794
return cur + len - s; return cur + len - s;
} else { } else {
if ((len = ScanMinuteSecond(str, cur, &minute)) == 0) { if ((len = ScanMinuteSecond(str, cur, &minute)) == 0) {
@ -557,7 +564,6 @@ int32_t ScanTimeZoneUTCOffsetName(base::Vector<Char> str, int32_t s) {
return cur - s; return cur - s;
} }
cur += len; cur += len;
// TODO(ftang) Problem See Issue 1794
len = ScanFraction(str, cur, &fraction); len = ScanFraction(str, cur, &fraction);
// Sign Hour MinuteSecond MinuteSecond [Fraction] // Sign Hour MinuteSecond MinuteSecond [Fraction]
return cur + len - s; return cur + len - s;