Commit graph

2373 commits

Author SHA1 Message Date
Linus Groh
6da6da73cc LibJS: Allow 'T' prefix in time-only strings
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/f5e8edf
2021-12-18 22:32:39 +00:00
Linus Groh
acce65b52c LibJS: Fix fractionalSecondDigits behavior in Duration.proto.toString()
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/3ee771e
2021-12-18 22:32:39 +00:00
Linus Groh
6d5e95d621 LibJS: Add optional calendar to Plain{Time,YearMonth,MonthDay} prod
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/7e58ba3
2021-12-18 22:32:39 +00:00
Linus Groh
b70a55bd5a LibJS: Update spec comment in get_iso_parts_from_epoch()
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/bdf60f5
2021-12-18 22:32:39 +00:00
Linus Groh
4b7f716f21 LibJS: Fix ambiguity in FractionalPart grammar
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/0f11bd6
2021-12-18 22:32:39 +00:00
Linus Groh
bbfbd02c1b LibJS: Make PlainDate difference methods units handling consistent
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/8b7ba00
2021-12-18 22:32:39 +00:00
Linus Groh
006bea5d31 LibJS: Remove outdated comment in prepare_partial_temporal_fields()
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/bf066ea
2021-12-18 22:32:39 +00:00
Linus Groh
69b8079b11 LibJS: Fix "smallestUnit" property name typo in a couple of places
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/900e4bc
2021-12-18 22:32:39 +00:00
Linus Groh
70e6eae27b LibJS: Fix off-by-one in balance_iso_date() for leap year inputs
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/5ab1822
2021-12-18 22:32:39 +00:00
Linus Groh
7270bbb255 LibJS: Remove outdated comment from parse_temporal_duration_string()
This is a normative change in the Temporal spec.

See:

- https://github.com/tc39/proposal-temporal/commit/e7182d3
- https://github.com/tc39/proposal-temporal/commit/6dae066
2021-12-18 22:32:39 +00:00
Linus Groh
247d2f7cc4 LibJS: Only allow Calendar this value in Temporal.Calendar.prototype.id
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/2644fc6
2021-12-18 22:32:39 +00:00
Andreas Kling
c175cea32d LibJS: Fix typo in MarkedVector::end() 2021-12-18 11:30:10 +01:00
Linus Groh
3214e35535 LibJS/Tests: Remove outdated FIXME 2021-12-17 23:22:30 +00:00
Andreas Kling
8bb9fe63b7 LibJS: Add MarkedVector<T>
This abstracts a vector of Cell* with a strongly typed span() accessor
that gives you Span<T*> instead of Span<Cell*>.

It is intended to replace MarkedValueList in situations where you only
need to store pointers to Cell (or an even more specific type of Cell).

The API can definitely be improved, it's just the bare basics for now.
2021-12-16 22:48:17 +01:00
Andreas Kling
c26b58bc53 LibJS: Add JS::make_handle(T&)
I'm not sure why we only had a T* variant of this.
2021-12-16 22:48:17 +01:00
Linus Groh
841bd680fa LibJS: Add ArrayBuffer::create() for ByteBuffer passed by value 2021-12-14 09:01:06 +01:00
Daniel Bertalan
4a81b33c07 Everywhere: Fix -Winconsistent-missing-override warnings from Clang
This option is already enabled when building Lagom, so let's enable it
for the main build too. We will no longer be surprised by Lagom Clang
CI builds failing while everything compiles locally.

Furthermore, the stronger `-Wsuggest-override` warning is enabled in
this commit, which enforces the use of the `override` keyword in all
classes, not just those which already have some methods marked as
`override`. This works with both GCC and Clang.
2021-12-11 13:14:15 -08:00
Timothy Flynn
2a7f36b392 LibJS+LibUnicode: Generate unique numeric symbol lists
There are 443 number system objects generated, each of which held an
array of number system symbols. Of those 443 arrays, only 39 are unique.

To uniquely store these, this change moves the generated NumericSymbol
enumeration to the public LibUnicode/NumberFormat.h header with a pre-
defined set of symbols that we need. This is to ensure the generated,
unique arrays are created in a known order with known symbols. While it
is unfortunate to no longer discover these symbols at generation time,
it does allow us to ignore unwanted symbols and perform less string-to-
enumeration conversions at lookup time.
2021-12-11 14:17:47 +00:00
Linus Groh
aa2b85c697 LibJS: Use AK::NaN<double> in Date::date_value() to fix build error
This was not happening locally for me, neither when building Lagom on
Linux nor with the SerenityOS toolchain...

    error: implicit conversion from ‘float’ to ‘double’ to match other
    result of conditional [-Werror=double-promotion]
2021-12-10 23:32:54 +00:00
Linus Groh
de00a7594f LibJS: Implement the thisTimeValue() AO and use it where applicable 2021-12-10 23:02:35 +00:00
Linus Groh
038d354b5d LibJS: Remove Object::value_of()
Being really close to Object.prototype.valueOf() name wise makes this
unnecessarily confusing - while it sometimes serves as the
implementation of a valueOf() function, it's an abstraction which the
spec doesn't have.
Use the appropriate getters to retrieve specific internal slots instead,
most commonly [[FooData]] from the primitive wrapper objects.
For the Object class specifically, use the Value(Object*) ctor instead.
2021-12-10 22:52:36 +00:00
Timothy Flynn
07c5419a82 LibJS: Add test case for locales which do not define day periods
Some locales do not define morning, night, etc. day period ranges.
TR-35 states they should fall back to the fixed day periods AM and PM.
Add a test case for the "as" locale, which is one such locale, to ensure
its AM/PM symbols are used.
2021-12-10 21:27:24 +00:00
Timothy Flynn
5bdee9e38a LibJS: Use locale-aware day period time ranges to format period symbols
For the test cases changed here, we now recognize "morning2" and
"afternoon2" from the CLDR, so the expected results now match the specs
and other engines.
2021-12-10 21:27:24 +00:00
Timothy Flynn
76aab821f4 LibJS+LibUnicode: Rename some Unicode::DayPeriod values
In the CLDR, there aren't "night" values, there are "night1" & "night2"
values. This is for locales which use a different name for nighttime
depending on the hour. For example, the ja locale uses "夜" between the
hours of 19:00 and 23:00, and "夜中" between the hours of 23:00 and
04:00. Our CLDR parser is currently ignoring "night2", so this rename
is to prepare for that.

We could probably come up with better names, but in the end, the API in
LibUnicode will be such that outside callers won't even see Night1, etc.
2021-12-10 21:27:24 +00:00
Timothy Flynn
2e4e0195de LibJS: Implement ECMA-402 Date.prototype.toLocaleTimeString 2021-12-10 13:58:33 +00:00
Timothy Flynn
4d310fd7aa LibJS: Implement ECMA-402 Date.prototype.toLocaleDateString 2021-12-10 13:58:33 +00:00
Timothy Flynn
9a62c01ebc LibJS: Implement ECMA-402 Date.prototype.toLocaleString 2021-12-10 13:58:33 +00:00
Timothy Flynn
53df13fed7 LibJS: Implement Intl.DateTimeFormat.prototype.formatRangeToParts 2021-12-09 23:43:04 +00:00
Timothy Flynn
04f8fb07e1 LibJS: Implement Intl.DateTimeFormat.prototype.formatRange 2021-12-09 23:43:04 +00:00
Timothy Flynn
1f35eda37b LibJS: Store range format patterns in the Intl.DateTimeFormat object
Now that LibUnicode generates these patterns, the AO steps to retrieve
them may be implemented.
2021-12-09 23:43:04 +00:00
Timothy Flynn
7a0d5e3f7a LibJS: Do not return views into potentially freed memory
In a future commit, the "part" view returned from FormatDateTimePattern
may be a view into a string that goes out of scope. Ensure the AO only
returns valid views. A similar approach is used in Intl.NumberFormat.
2021-12-09 23:43:04 +00:00
Linus Groh
bdb8fc54f2 LibJS: Update spec comment in balance_duration_relative()
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/665871e
2021-12-09 23:18:01 +00:00
Linus Groh
82efbfcf3d LibJS: Update spec comment in Temporal.Duration.prototype.round()
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/513c05b
2021-12-09 23:14:36 +00:00
Andreas Kling
fed6a76990 LibJS: Add Handle::operator->() 2021-12-09 21:28:52 +01:00
Linus Groh
859b810db1 LibJS/Tests: Enable two more skipped tests which now pass
Only two skipped tests remaining overall :^)
2021-12-08 20:08:26 +00:00
Linus Groh
f1dafabbb9 LibJS: Simplify TemporalInstantString
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/271d71c
2021-12-08 19:57:19 +00:00
Luke Wilde
4f3c283f24 LibJS: Move calendar validation out of parse_temporal_calendar_string
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/7207a1c
2021-12-08 19:11:50 +00:00
Luke Wilde
80dcddacea LibJS: Simplify return in parse_temporal_date_time_string
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/1f7e486
2021-12-08 19:11:50 +00:00
Luke Wilde
6244969ae2 LibJS: Remove duplicated spec step in parse_iso_date_time
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/516bf24
2021-12-08 19:11:50 +00:00
Timothy Flynn
1e68e7f129 LibJS: Implement Intl.DateTimeFormat.prototype.formatToParts 2021-12-08 11:29:36 +00:00
Timothy Flynn
adaf5985a4 LibJS: Implement (most of) Intl.DateTimeFormat.prototype.format
There are a few FIXMEs that will need to be addressed, but this
implements most of the prototype method. The FIXMEs are mostly related
to range formatting, which has been entirely ignored so far. But other
than that, the following will need to be addressed:

* Determining flexible day periods must be made locale-aware.
* DST will need to be determined and acted upon.
* Time zones other than UTC and calendars other than Gregorian are
  ignored.
* Some of our results differ from other engines as they have some
  format patterns we do not. For example, they seem to have a lonely
  {dayPeriod} pattern, whereas our closest pattern is
  "{hour} {dayPeriod}".
2021-12-08 11:29:36 +00:00
Timothy Flynn
d010ba10c3 LibJS: Cache the data locale used by Intl.DateTimeFormat
Unlike the locale, the data locale has Unicode locale extensions removed
(e.g. the data locale for "en-US-u-ca-gregory" is just "en-US"). Cache
the data locale for LibUnicode lookups during formatting.
2021-12-08 11:29:36 +00:00
Timothy Flynn
4cc8cf9233 LibJS: Add an accessor for the %Date.now% instrinsic property 2021-12-08 11:29:36 +00:00
Timothy Flynn
baf3f3bd6e LibJS: Implement Date's Week Day AO 2021-12-08 11:29:36 +00:00
Timothy Flynn
e56be34148 LibJS: Implement Date's TimeClip AO 2021-12-08 11:29:36 +00:00
Timothy Flynn
26f9666191 LibJS: Do not override hour, minute, and second format field lengths
This was an oversight in e42d954743.

These fields should always follow the locale preference in the CLDR.
Overriding these fields would permit formats like "h:mm:ss" to result in
strings like "1:2:3" instead of "1:02:03".
2021-12-08 11:29:36 +00:00
Timothy Flynn
9f7c727720 LibJS+LibUnicode: Generate missing patterns with fractionalSecondDigits
TR-35's Matching Skeleton algorithm dictates how user requests including
fractional second digits should be handled when the CLDR format pattern
does not include that field. When the format pattern contains {second},
but does not contain {fractionalSecondDigits}, generate a second pattern
which appends "{decimal}{fractionalSecondDigits}" to the {second} field.
2021-12-08 11:29:36 +00:00
Timothy Flynn
6ace4000bf LibJS+LibUnicode: Supply field type in CalendarPattern's for-each method
Some callers will want different behavior depending on what field is
being provided to the callback.
2021-12-08 11:29:36 +00:00
Andreas Kling
fa879168f5 LibJS: Mark Function object's private environment during GC 2021-12-08 10:29:54 +01:00
Andreas Kling
f25899ca34 LibJS: Mark entire private environment chains during GC 2021-12-08 10:29:54 +01:00