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:
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:
1508825
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:
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:
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:
5a2b1d1
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:
82e2f92
ce6c33e
b982783
96010f4
9dd123f
0c2834f
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:
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
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
Timothy Flynn
1edb96376b
AK+Everywhere: Make UTF-8 and UTF-32 to UTF-16 converters fallible
...
These could fail to allocate the underlying storage needed to store the
UTF-16 data. Propagate these errors.
2023-01-08 12:13:15 +01:00
Timothy Flynn
d8044c5358
LibJS+LibWeb: Move the macro to convert ENOMEM to an exception to LibJS
...
Move the macro to LibJS and change it to return a throw completion
instead of a WebIDL exception. This will let us use this macro within
LibJS to handle OOM conditions.
2023-01-08 12:13:15 +01:00
Timothy Flynn
ba97f6a0d3
LibJS: Move the "other" optional completion in the move constructor
...
Otherwise, we invoke a non-trival copy. Caught by clangd.
2023-01-08 12:13:15 +01:00
Timothy Flynn
49b24b0968
LibJS: Let Utf16String be forward-declared in Value.h
...
It's only used as a template parameter, so let it be forward-declared.
Otherwise, we aren't able to include Completion.h in Utf16String.h, as
there would be a Utf16String -> Completion -> Value -> Utf16String
include cycle.
2023-01-08 12:13:15 +01:00
Timothy Flynn
425c168ded
AK+LibJS+LibRegex: Define an alias for UTF-16 string data storage
...
Instead of writing out "Vector<u16, 1>" everywhere, let's have a name
for it.
2023-01-08 12:13:15 +01:00
BodilessSleeper
90b43712e6
LibJS: Rename ToIntegerThrowOnInfinity to ToIntegerWithTruncation
...
This commit ticks away two of the boxes in #15525
Temporal commits: tc39/proposal-temporal@f274678 and
tc39/proposal-temporal@a63a0fb
2023-01-06 11:16:55 +01:00
BodilessSleeper
18122c0368
LibJS: Replace "is not zero" language in Temporal comments
...
This commit ticks away one of the boxes in #15525
Temporal commit: tc39/proposal-temporal@9cd448a
2023-01-06 11:16:55 +01:00
Timothy Flynn
76b9d06b19
LibJS: Add and begin using a completion-compatible string builder
...
ThrowableStringBuilder is a thin wrapper around StringBuilder to map
results from the try_* methods to a throw completion. This will let us
try to throw on OOM conditions rather than just blowing up.
2023-01-05 22:07:44 +01:00
BodilessSleeper
8e6920a18d
LibJS: Convert calendar operation results to floats
...
This commit ticks away one of the boxes in #15525
Temporal commit: tc39/proposal-temporal@11aad40
2023-01-05 19:49:09 +01:00
BodilessSleeper
1f1b2f4d26
LibJS: Rename ToPositiveInteger -> ToPositiveIntegerWithTruncation
...
This commit ticks away one of the boxes in #15525
Temporal commit: tc39/proposal-temporal@768b916
2023-01-03 17:53:51 +01:00
BodilessSleeper
4e6beaabcb
LibJS: Update comments in Temporal/Calendar.cpp
...
This commit ticks away one of the boxes in #15525
Temporal commit: tc39/proposal-temporal@08cc0fb
2023-01-03 17:53:51 +01:00