Timothy Flynn
fc413711ee
LibJS: Port trivial use cases in the Intl namespace to String
2023-01-16 10:12:37 +00:00
Timothy Flynn
b6b5ddeb3b
LibJS: Port StringIterator to String
2023-01-16 10:12:37 +00:00
Timothy Flynn
0d47c4e7a0
LibJS: Port the TrimString AO to String
...
This also adds spec comments to parseFloat to make it clear that we are
now deviating a bit from the spec (the TrimString invocation should be
infallible, but we want to propagate OOM errors).
2023-01-16 10:12:37 +00:00
Timothy Flynn
4235c59397
LibJS: Add a convenience StringView accessor to PrimitiveString
2023-01-16 10:12:37 +00:00
Brian Gianforcaro
bffc29ae34
LibJS: Fix uninitialized member variable in DurationFormat
...
Reported-by: PVS Studio
2023-01-16 09:45:46 +01:00
BodilessSleeper
c5daa6d997
LibJS: Remove redundant ToString from ToTemporalZonedDateTime
...
Assert that the type of offsetString is either undefined or
string in order to avoid unnecessary ToString
Temporal commit: tc39/proposal-temporal@24ebcbd
2023-01-15 21:35:25 +00:00
BodilessSleeper
219db02b2f
LibJS: Assert TemporalDateTimeToString if showCalendar is "never"
...
The only part of TemporalDateTimeToString that can fail is
MaybeFormatAnnotateCalendar which cannot fail if showCalendar is
"never" as it simply makes an empty string.
Temporal commit: tc39/proposal-temporal@a1faee6
2023-01-15 21:35:25 +00:00
Timothy Flynn
bb4c7b6a35
LibJS: Remove now-unused ThrowableFormat header
...
The one place this was used now uses the fallible String::formatted.
2023-01-15 01:00:20 +00:00
Timothy Flynn
9f78e8728a
LibJS: Port (most of) String.prototype to String
...
The locations that haven't been ported have a much wider footprint than
just the String.prototype files, so they've been left alone for now.
2023-01-15 01:00:20 +00:00
Timothy Flynn
ceaec41726
LibJS: Port Value to-string methods to String
2023-01-15 01:00:20 +00:00
Timothy Flynn
46dd8c1c0b
LibJS: Resolve all UTF-8 rope strings as a String
2023-01-15 01:00:20 +00:00
Timothy Flynn
c9056b824e
LibJS: Define Value::to_string to convert a Value to a String
2023-01-15 01:00:20 +00:00
Timothy Flynn
afeb7273cc
LibJS+Everywhere: Rename Value::to_string to to_deprecated_string
2023-01-15 01:00:20 +00:00
Timothy Flynn
8f5bdce8e7
LibJS: Add initial support for creating PrimitiveStrings with AK::String
...
This will temporarily bloat the size of PrimitiveString as LibJS is
transitioned to use String throughout, but will make doing so piecemeal
much easier.
2023-01-15 01:00:20 +00:00
Timothy Flynn
0b58748156
LibJS: Define number_to_string to convert a double to a String
2023-01-15 01:00:20 +00:00
Timothy Flynn
8a88d4434f
LibJS+LibWeb: Rename number_to_string to number_to_deprecated_string
2023-01-15 01:00:20 +00:00
Timothy Flynn
c79d20be58
LibJS: Define Utf16String::to_utf8 to convert Utf16String to String
2023-01-15 01:00:20 +00:00
Timothy Flynn
4eb5eb2080
LibJS: Rename Utf16String::to_utf8 to to_deprecated_string
2023-01-15 01:00:20 +00:00
Timothy Flynn
ca655f5e7d
LibJS: Rename VM::string_cache to deprecated_string_cache
...
And rename the member variable from m_string_cache to
m_deprecated_string_cache to match.
2023-01-15 01:00:20 +00:00
Timothy Flynn
3a004e8f1a
LibJS: Rename PrimitiveString::has_utf8_string to has_deprecated_string
...
And rename the member variable from m_utf8_string to m_deprecated_string
to match.
2023-01-15 01:00:20 +00:00
Timothy Flynn
79e81e8a15
LibJS: Add ThrowableStringBuilder::to_string to create a new String
...
This wraps around the base class method to throw an OOM completion.
2023-01-15 01:00:20 +00:00
Timothy Flynn
0ddc2e1f50
LibCrypto+Everywhere: Rename *BigInteger::to_base to to_base_deprecated
2023-01-15 01:00:20 +00:00
Andrew Kaster
f5d253dcfa
Everywhere: Fully qualify IsLvalueReference in TRY() macros
...
If USING_AK_GLOBALLY is not defined, the name IsLvalueReference might
not be available in the global namespace. Follow the pattern established
in LibTest to fully qualify AK types in macros to avoid this problem.
2023-01-15 00:56:31 +00:00
Timothy Flynn
822e32eb11
LibJS: Reword and reorder some steps of the Intl ResolveLocale AO
...
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/4c55823
2023-01-14 19:12:48 +00:00
Timothy Flynn
0ff4d8100f
LibJS: Consistently use spaces / parentheses in NumberFormat operations
...
These are editorial changes in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/1508825
https://github.com/tc39/ecma402/commit/760f23a
2023-01-14 19:12:48 +00:00
Timothy Flynn
0ffad2a2d1
LibJS: Refer to String elements as code units rather than characters
...
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/d6b3435
2023-01-14 19:12:48 +00:00
Timothy Flynn
95cef87a9c
LibJS: Update syntax for invoking the GetOption AO from Intl objects
...
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/0ac2e10
2023-01-14 19:12:48 +00:00
Timothy Flynn
2cca5d6676
LibJS: Fix assignment of "isNegative" in FormatNumericToString
...
These are normative changes in the Intl.NumberFormat v3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/5a2b1d1
https://github.com/tc39/proposal-intl-numberformat-v3/commit/cd48a3d
2023-01-14 19:12:48 +00:00
Timothy Flynn
d30e96a209
LibJS: Renumber Intl.NumberFormat v3 prototypes and AOs
...
These are editorial changes in the Intl.NumberFormat v3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/82e2f92
https://github.com/tc39/proposal-intl-numberformat-v3/commit/ce6c33e
https://github.com/tc39/proposal-intl-numberformat-v3/commit/b982783
https://github.com/tc39/proposal-intl-numberformat-v3/commit/96010f4
https://github.com/tc39/proposal-intl-numberformat-v3/commit/9dd123f
https://github.com/tc39/proposal-intl-numberformat-v3/commit/0c2834f
https://github.com/tc39/proposal-intl-numberformat-v3/commit/31c72f3
2023-01-14 19:12:48 +00:00
Timothy Flynn
d1881da2be
LibJS: Set approximate number range format result's "source" to "shared"
...
This is a normative change in the Intl.NumberFormat v3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/7510e7f
2023-01-14 19:12:48 +00:00
Timothy Flynn
afc0e461e1
AK+Everywhere: Disallow returning a reference from a fallible expression
...
This will silently make a copy. Rather than masking this behavior, let's
explicitly disallow it.
2023-01-13 18:50:47 -05:00
Timothy Flynn
3de75f6436
LibJS: Explicitly disallow references in ThrowCompletionOr
...
This will be disallowed by TRY soon, but the compile error produced by
this requirement will pinpoint the errant line more accurately.
2023-01-13 18:50:47 -05:00
Timothy Flynn
a59ebdac2d
LibJS+Everywhere: Return strings by value from PrimitiveString
...
It turns out return a ThrowCompletionOr<T const&> is flawed, as the GCC
expansion trick used with TRY will always make a copy. PrimitiveString
is luckily the only such use case.
2023-01-13 18:50:47 -05:00
MacDue
9a120d7243
AK: Add support for "debug only" formatters
...
These are formatters that can only be used with debug print
functions, such as dbgln(). Currently this is limited to
Formatter<ErrorOr<T>>. With this you can still debug log ErrorOr
values (good for debugging), but trying to use them in any
String::formatted() call will fail (which prevents .to_string()
errors with the new failable strings being ignored).
You make a formatter debug only by adding a constexpr method like:
static constexpr bool is_debug_only() { return true; }
2023-01-13 21:09:26 +00:00
BodilessSleeper
0bc591a69b
LibJS: Use integer days in RoundDuration
...
Before we used the value of days which may also contain a fraction.
The algorithm expects it to be an integer.
This was addressed upstream in: tc39/proposal-temporal@02379da
2023-01-13 10:21:54 +00:00
Andreas Kling
7826cb2556
LibJS: Use a work queue instead of the C++ stack for the GC mark phase
...
This fixes an issue where we'd run out of C++ stack while traversing
large GC heap graphs.
2023-01-10 15:30:07 -05:00
BodilessSleeper
9a60d3509d
LibJS: Update ISODaysInMonth in Calendar.cpp
...
This commit ticks away a box in #15525
Temporal commit: tc39/proposal-temporal@eee1e27
2023-01-10 10:22:21 +00:00
Linus Groh
7762c1ac61
LibJS: Verify that objects are only initialized once
...
We already do this in a couple of other places, we wouldn't ever want to
re-assign already initialized constructor and prototype objects.
2023-01-09 22:14:35 -05:00
Linus Groh
63136615d2
LibJS: Make namespace object initialization lazy as well
2023-01-09 22:14:35 -05:00
Linus Groh
76f89bf50d
LibJS: Use intrinsic namespace objects in set_default_global_bindings()
...
We were accidentally allocating a new instance for each of the namespace
objects. Use the existing ones from the realm's intrinsics instead.
2023-01-09 22:14:35 -05:00
Timothy Flynn
f3db548a3d
AK+Everywhere: Rename FlyString to DeprecatedFlyString
...
DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so
let's rename it to A) match the name of DeprecatedString, B) write a new
FlyString class that is tied to String.
2023-01-09 23:00:24 +00:00
Timothy Flynn
d0403ec14f
AK+Everywhere: Rename Utf16View::to_utf8 to to_deprecated_string
...
A subsequent commit will add to_utf8 back to create an AK::String.
2023-01-09 23:00:24 +00:00
Timothy Flynn
3d22efccca
LibUnicode+LibJS: Propagate OOM from Unicode normalization
2023-01-09 22:48:15 +00:00
Timothy Flynn
1ff29afc45
LibUnicode+LibJS+LibWeb: Propagate OOM from Unicode case transformations
2023-01-09 22:48:15 +00:00
Timothy Flynn
48474b0de6
LibJS: Handle OOM errors in String.prototype.replaceAll
2023-01-09 22:48:15 +00:00
Timothy Flynn
57b918807e
LibJS: Handle OOM errors in the GetSubstitution AO
2023-01-09 22:48:15 +00:00
Timothy Flynn
356e58332c
LibJS: Add and begin using a completion-compatible string formatter
...
The `deprecated_format` helper is a thin wrapper to map results from
AK::vformat to a throw completion. This will let us try to throw on OOM
conditions rather than just blowing up.
Note it's called `deprecated_format` as we will likely end up adding a
method named just `format` to return `ThrowCompletionOr<String>`, when
we begin the migration from DeprecatedString->String for LibJS.
2023-01-08 12:13:15 +01:00
Timothy Flynn
6e1a239a62
LibJS: Use fallible methods to handle OOM when resolving rope strings
2023-01-08 12:13:15 +01:00
Timothy Flynn
115baa7e32
LibJS+Everywhere: Make PrimitiveString and Utf16String fallible
...
This makes construction of Utf16String fallible in OOM conditions. The
immediate impact is that PrimitiveString must then be fallible as well,
as it may either transcode UTF-8 to UTF-16, or create a UTF-16 string
from ropes.
There are a couple of places where it is very non-trivial to propagate
the error further. A FIXME has been added to those locations.
2023-01-08 12:13:15 +01:00
Timothy Flynn
d793262beb
AK+Everywhere: Make UTF-16 to UTF-8 converter fallible
...
This could fail to allocate the underlying storage needed to store the
UTF-8 data. Propagate this error.
2023-01-08 12:13:15 +01:00