summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
AgeCommit message (Collapse)Author
2021-12-11LibJS+LibUnicode: Generate unique numeric symbol listsTimothy Flynn
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-10LibJS: Use AK::NaN<double> in Date::date_value() to fix build errorLinus Groh
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-10LibJS: Implement the thisTimeValue() AO and use it where applicableLinus Groh
2021-12-10LibJS: Remove Object::value_of()Linus Groh
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-10LibJS: Add test case for locales which do not define day periodsTimothy Flynn
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-10LibJS: Use locale-aware day period time ranges to format period symbolsTimothy Flynn
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-10LibJS+LibUnicode: Rename some Unicode::DayPeriod valuesTimothy Flynn
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-10LibJS: Implement ECMA-402 Date.prototype.toLocaleTimeStringTimothy Flynn
2021-12-10LibJS: Implement ECMA-402 Date.prototype.toLocaleDateStringTimothy Flynn
2021-12-10LibJS: Implement ECMA-402 Date.prototype.toLocaleStringTimothy Flynn
2021-12-09LibJS: Implement Intl.DateTimeFormat.prototype.formatRangeToPartsTimothy Flynn
2021-12-09LibJS: Implement Intl.DateTimeFormat.prototype.formatRangeTimothy Flynn
2021-12-09LibJS: Store range format patterns in the Intl.DateTimeFormat objectTimothy Flynn
Now that LibUnicode generates these patterns, the AO steps to retrieve them may be implemented.
2021-12-09LibJS: Do not return views into potentially freed memoryTimothy Flynn
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-09LibJS: Update spec comment in balance_duration_relative()Linus Groh
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/665871e
2021-12-09LibJS: Update spec comment in Temporal.Duration.prototype.round()Linus Groh
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/513c05b
2021-12-09LibJS: Add Handle::operator->()Andreas Kling
2021-12-08LibJS/Tests: Enable two more skipped tests which now passLinus Groh
Only two skipped tests remaining overall :^)
2021-12-08LibJS: Simplify TemporalInstantStringLinus Groh
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/271d71c
2021-12-08LibJS: Move calendar validation out of parse_temporal_calendar_stringLuke Wilde
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/7207a1c
2021-12-08LibJS: Simplify return in parse_temporal_date_time_stringLuke Wilde
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/1f7e486
2021-12-08LibJS: Remove duplicated spec step in parse_iso_date_timeLuke Wilde
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/516bf24
2021-12-08LibJS: Implement Intl.DateTimeFormat.prototype.formatToPartsTimothy Flynn
2021-12-08LibJS: Implement (most of) Intl.DateTimeFormat.prototype.formatTimothy Flynn
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-08LibJS: Cache the data locale used by Intl.DateTimeFormatTimothy Flynn
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-08LibJS: Add an accessor for the %Date.now% instrinsic propertyTimothy Flynn
2021-12-08LibJS: Implement Date's Week Day AOTimothy Flynn
2021-12-08LibJS: Implement Date's TimeClip AOTimothy Flynn
2021-12-08LibJS: Do not override hour, minute, and second format field lengthsTimothy Flynn
This was an oversight in e42d954743056e476bbb1623cfc60e7797a8a6ca. 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-08LibJS+LibUnicode: Generate missing patterns with fractionalSecondDigitsTimothy Flynn
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-08LibJS+LibUnicode: Supply field type in CalendarPattern's for-each methodTimothy Flynn
Some callers will want different behavior depending on what field is being provided to the callback.
2021-12-08 LibJS: Mark Function object's private environment during GCAndreas Kling
2021-12-08LibJS: Mark entire private environment chains during GCAndreas Kling
2021-12-08LibJS: Make sure private environments are marked during GCAndreas Kling
2021-12-08LibJS: Only allocate space for Object private elements if neededAndreas Kling
Most JavaScript objects don't have private elements, so this reduces the size of typical JS::Object instances by two pointers.
2021-12-06LibJS: Add tests for calendar fields of DateTimeFormat's resolvedOptionsTimothy Flynn
These are (mostly) testable now that LibUnicode parses format patterns.
2021-12-06LibJS: Always respect user-provided format field lengthsTimothy Flynn
ECMA-402 doesn't explicitly handle a note in the TR-35 spec related to expanding field lengths based on user-provided options. Instead, it assumes the "implementation defined" locale data includes the possible values. LibUnicode does not generate every possible combination of field lengths in its implementation of TR-35's "Missing Skeleton Fields", because the number of generated patterns would grow out of control. Instead, it's much simpler to handle this difference at runtime.
2021-12-06LibJS: Fallback to [[pattern]] when [[pattern12]] is unavailableTimothy Flynn
Other implementations unconditionally initialize [[pattern12]] from [[pattern]] regardless of whether [[pattern]] has an hour pattern of h11 or h12. LibUnicode does not do this. So when InitializeDateTimeFormat defaults the hour cycle to the locale's preferred hour cycle, if the best format didn't have an equivalent hour pattern, [[pattern12]] will be empty.
2021-12-01LibUnicode: Do not generate data for "generic" calendarsTimothy Flynn
This is not a calendar supported by ECMA-402, so let's not waste space with its data. Further, don't generate "gregorian" as a valid Unicode locale extension keyword. It's an invalid type identifier, thus cannot be used in locales such as "en-u-ca-gregorian".
2021-12-01LibJS: Change all [[RelevantExtensionKeys]] to return constexpr arraysTimothy Flynn
There's no need to allocate a vector for this internal slot. Similar to commit: bb1143779275f3dfa652c88c11ac2ad6e69ac9cd
2021-11-30LibJS/Tests: Fix typo in a test descriptionLinus Groh
2021-11-30LibJS: Don't match async \n function as an async function declarationdavidot
2021-11-30LibJS: Replace the verify in private identifier with a syntax errordavidot
Since sometimes expressions are parsed without checking we can hit this expression without it being followed by an 'in'.
2021-11-30LibJS: Split parsing program to script and module separatelydavidot
This allows us to only perform checks like export bindings existing only for modules. Also this makes it easier to set strict and other state variables with TemporaryChanges.
2021-11-30LibJS: Rename in_async_function_context to await_expression_is_validdavidot
Since await can be valid in module code which is not an async function the old name is not really representative for the usage.
2021-11-30LibJS: Parse dynamic import calls 'import()' and 'import.meta'davidot
For now both just throw when executing but this can be implemented when modules are implemented :^).
2021-11-30LibJS: Lookahead for a period when parsing new.targetdavidot
This allows us to skip saving and loading the state whenever we parse 'new'.
2021-11-30LibJS: Stop parsing an expression on comma after a yielddavidot
2021-11-30LibJS: Disallow member expression in binding pattern as parametersdavidot
2021-11-30LibJS: Disallow shorthand properties with reserved namesdavidot