Commit graph

213 commits

Author SHA1 Message Date
Linus Groh
3aa3ab65b1 LibJS: Port to_temporal_rounding_mode() to String
Also make negate_temporal_rounding_mode() take a StringView as part of
this, it only does equality checks.
2023-01-26 20:20:54 +00:00
Linus Groh
ec9f2013c9 LibJS: Port to_temporal_disambiguation() to String 2023-01-26 20:20:54 +00:00
Linus Groh
b8759e86ee LibJS: Port to_temporal_overflow() to String 2023-01-26 20:20:54 +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
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
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
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
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
Ben Wiederhake
6b7ce19161 Everywhere: Remove unused includes of LibC/stdlib.h
These instances were detected by searching for files that include
stdlib.h, but don't match the regex:

\\b(_abort|abort|abs|aligned_alloc|arc4random|arc4random_buf|arc4random_
uniform|atexit|atof|atoi|atol|atoll|bsearch|calloc|clearenv|div|div_t|ex
it|_Exit|EXIT_FAILURE|EXIT_SUCCESS|free|getenv|getprogname|grantpt|labs|
ldiv|ldiv_t|llabs|lldiv|lldiv_t|malloc|malloc_good_size|malloc_size|mble
n|mbstowcs|mbtowc|mkdtemp|mkstemp|mkstemps|mktemp|posix_memalign|posix_o
penpt|ptsname|ptsname_r|putenv|qsort|qsort_r|rand|RAND_MAX|random|reallo
c|realpath|secure_getenv|serenity_dump_malloc_stats|serenity_setenv|sete
nv|setprogname|srand|srandom|strtod|strtof|strtol|strtold|strtoll|strtou
l|strtoull|system|unlockpt|unsetenv|wcstombs|wctomb)\\b

(Without the linebreaks.)

This regex is pessimistic, so there might be more files that don't
actually use anything from the stdlib.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:27:20 -05:00
Linus Groh
ddc6e139a6 LibJS: Convert Object::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00
Linus Groh
525f22d018 LibJS: Replace standalone js_string() with PrimitiveString::create()
Note that js_rope_string() has been folded into this, the old name was
misleading - it would not always create a rope string, only if both
sides are not empty strings. Use a three-argument create() overload
instead.
2022-12-07 16:43:06 +00:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Smrtnyk
2ba2e6ca0a LibJS: Rename ToShowTimeZoneNameOption to ToTimeZoneNameOption
This is an editorial change in Temporal spec.

See: ab5b1ba910
2022-11-05 15:44:49 +00:00
Smrtnyk
efe82e5c91 LibJS: Rename ToShowCalendarOption to ToCalendarNameOption
This is an editorial change in the Temporal spec.

See: 2c9e2615f7
2022-11-04 21:00:25 +00:00
Luke Wilde
b26b18a0bc LibJS: Add timeZoneName: "critical" option to ZonedDateTime.toString()
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d84937f
2022-11-03 19:15:50 +00:00
Luke Wilde
4a167cfbec LibJS: Add calendarName: "critical" option to toString() methods
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/e715a50
2022-11-03 19:15:50 +00:00
Luke Wilde
192aa75279 LibJS: Align ISO 8601 grammar with annotations from IXDTF
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/c64b844
2022-11-03 19:15:50 +00:00
davidot
3dc99af3dc LibJS: Make parse_temporal_duration use the new double parser 2022-10-23 15:48:45 +02:00
Idan Horowitz
d38aeddd77 LibJS: Simplify ParseTemporalTimeZoneString
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/eec8efab
2022-10-20 00:47:42 +02:00
Idan Horowitz
0c61552b81 LibJS: Refactor ToRelativeTemporalObject
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/895854d9
2022-10-20 00:47:42 +02:00
Linus Groh
b79b78a5cc LibJS: Sync the set of rounding modes
This is a normative change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/9613358
- https://github.com/tc39/proposal-temporal/commit/4c45464
2022-10-17 13:31:22 +02:00
Linus Groh
4567ded8e4 LibJS: Reject relativeTo string such as "2022-08-18T17:01Z"
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/2dc20bf
2022-10-17 12:56:05 +02:00
Linus Groh
57162ad510 LibJS: Rename IsValidTimeZoneName to IsAvailableTimeZoneName
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/873313b
2022-10-17 12:56:05 +02:00
Linus Groh
b6f101f1c0 LibJS: Fix TemporalCalendarString ambiguity
This is a normative change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/278d238
- https://github.com/tc39/proposal-temporal/commit/b73aea7
2022-10-16 15:20:23 +02:00
Timothy Flynn
443ffab9dc LibJS: Use infallible ParseTimeZoneOffsetString
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/654e300
2022-10-15 18:05:02 +02:00
Timothy Flynn
4fbec2e8b3 LibJS: Replace RoundTowardsZero with truncate
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/409ab66
2022-10-15 18:05:02 +02:00
snooze6214
1fde3737f4 LibJS: Move time zone annotation parsing into ParseISODateTime
This is an editorial change in the Temporal spec.

See: tc39/proposal-temporal@c410e25e47
2022-10-15 05:09:09 +00:00
davidot
791855deab LibCrypto+LibJS: Remove the create_from methods from BigInteger
Instead we just use a specific constructor. With this set of
constructors using curly braces for constructing is highly recommended.
As then it will not do too many implicit conversions which could lead to
unexpected loss of data or calling the much slower double constructor.

Also to ensure we don't feed (Un)SignedBigInteger infinities we throw
RangeError earlier for Durations.
2022-08-26 19:18:26 +01:00
Linus Groh
2cf5f5c278 LibJS: Remove unused nonterminals from the ISO8601 parser
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/fe9ef00
2022-08-25 23:41:09 +01:00
Linus Groh
ccdfa2320c LibJS: Replace GlobalObject with VM in Iterator AOs [Part 7/19] 2022-08-23 13:58:30 +01:00
Linus Groh
a022e548b8 LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]
This is where the fun begins. :^)
2022-08-23 13:58:30 +01:00
Linus Groh
694f66b5ca LibJS: Replace GlobalObject with VM in Temporal AOs [Part 2/19] 2022-08-23 13:58:30 +01:00
Linus Groh
f3117d46dc LibJS: Remove GlobalObject from VM::throw_completion()
This is a continuation of the previous five commits.

A first big step into the direction of no longer having to pass a realm
(or currently, a global object) trough layers upon layers of AOs!
Unlike the create() APIs we can safely assume that this is only ever
called when a running execution context and therefore current realm
exists. If not, you can always manually allocate the Error and put it in
a Completion :^)

In the spec, throw exceptions implicitly use the current realm's
intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
2022-08-23 13:58:30 +01:00
Linus Groh
b99cc7d050 LibJS+LibWeb: Replace GlobalObject with Realm in create() functions
This is a continuation of the previous two commits.

As allocating a JS cell already primarily involves a realm instead of a
global object, and we'll need to pass one to the allocate() function
itself eventually (it's bridged via the global object right now), the
create() functions need to receive a realm as well.
The plan is for this to be the highest-level function that actually
receives a realm and passes it around, AOs on an even higher level will
use the "current realm" concept via VM::current_realm() as that's what
the spec assumes; passing around realms (or global objects, for that
matter) on higher AO levels is pointless and unlike for allocating
individual objects, which may happen outside of regular JS execution, we
don't need control over the specific realm that is being used there.
2022-08-23 13:58:30 +01:00
Linus Groh
0355c72d6a LibJS: Validate fractionalSecondDigits after truncation
This is a normative change in the Temporal spec.
Also correct some bogus spec numbers.

See:
- https://github.com/tc39/proposal-temporal/commit/39e1784
- https://github.com/tc39/proposal-temporal/commit/c3c0ee1
- https://github.com/tc39/proposal-temporal/commit/273cb2e
2022-07-30 10:50:50 +01:00
Linus Groh
ca85e157e8 LibJS: Use null-prototype objects in a few more places in Temporal
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/334479f
2022-06-29 07:35:42 +01:00
Linus Groh
3720f4bd8f LibJS: Fix production for time zone name in time zone strings
This is a normative change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/caf013a
- https://github.com/tc39/proposal-temporal/commit/fb7cfa6
2022-06-29 07:35:42 +01:00
Linus Groh
ee0d5d6649 LibJS: Refactor common option reading into the GetDifferenceSettings AO
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/78abbb8
2022-06-24 22:12:03 +01:00
Linus Groh
80663d9d3b LibJS: Mark CreateTemporalDate in ToRelativeTemporalObject as fallible
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/09e9f9c
2022-06-24 22:12:03 +01:00
Linus Groh
416f94eb3b LibJS: Add Number conversion in PrepareTemporalFields
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/687d06c
2022-06-24 22:12:03 +01:00
Linus Groh
b2965cf204 LibJS: Fix Instant rounding modes
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/0993b75
2022-06-15 17:49:20 +01:00
Linus Groh
52a4ee563d LibJS: Assume options is an object in the MergeLargestUnitOption AO
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/20a04ac
2022-06-15 17:49:20 +01:00
Linus Groh
9b3602d000 LibJS: Update missing/superfluous commas in various spec comments
These are editorial changes in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/9586746
- https://github.com/tc39/proposal-temporal/commit/3c76ecc
- https://github.com/tc39/proposal-temporal/commit/96eab07
2022-06-15 17:49:20 +01:00
Linus Groh
30328d74d0 LibJS: Use MaximumTemporalDurationRoundingIncrement in two more places
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/de582e2
2022-06-15 17:49:20 +01:00
Linus Groh
71a519831d LibJS: Update to the latest ECMA-402 GetOption and move it into ECMA-262
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/4e79b69
2022-06-15 17:49:20 +01:00
Linus Groh
46d2ac6da4 LibJS: Align Temporal GetOption AO with ECMA-402
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/7b6a264
2022-06-15 17:49:20 +01:00
Linus Groh
c8d84f33b0 LibJS: Remove unused GetStringOrNumberOption operation
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d8b3423
2022-06-15 17:49:20 +01:00
Linus Groh
d1b71cba25 LibJS: Explicitly handle "auto" vs. number fractionalSecondDigits
This is an editorial change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/4dd6713
- https://github.com/tc39/proposal-temporal/commit/4c2476b
- https://github.com/tc39/proposal-temporal/commit/f1a839b
- https://github.com/tc39/proposal-temporal/commit/c775ebe
- https://github.com/tc39/proposal-temporal/commit/0409774

(Changes across multiple commits, that ended up being reverted.)
2022-06-15 17:49:20 +01:00