Commit graph

107 commits

Author SHA1 Message Date
Linus Groh
5db38d7ba1 LibJS: Replace standalone js_bigint() with BigInt::create()
Three standalone Cell creation functions remain in the JS namespace:

- js_bigint()
- js_string()
- js_symbol()

All of them are leftovers from early iterations when LibJS still took
inspiration from JSC, which itself has jsString(). Nowadays, we pretty
much exclusively use static create() functions to construct types
allocated on the JS heap, and there's no reason to not do the same for
these.
Also change the return type from BigInt* to NonnullGCPtr<BigInt> while
we're here.

This is patch 1/3, replacement of js_string() and js_symbol() follow.
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
Linus Groh
b0e7d59b8b LibJS: Throw on conversion from TimeZone to Calendar and vice versa
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/2084e77
2022-12-02 02:04:13 +01:00
Andreas Kling
71067cbc6c LibJS+LibWeb: Make Runtime/AbstractOperations.h not include AST.h
This led to considerable fallout and many files had to be patched with
now-missing include statements.
2022-11-23 16:05:59 +00: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
72997c6b77 LibJS: Define IsValidTimeZoneName in terms of AvailableTimeZones
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d83dcf0

Note that even though we already implement AvailableTimeZones for Intl,
I kept the existing implementation calling into LibTimeZone directly.
2022-10-17 12:56:05 +02:00
Linus Groh
484c66125d LibJS: Rename Get{IANA => Named}TimeZonePreviousTransition
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6b759d1
2022-10-16 14:45:09 +02:00
Linus Groh
8cc260107d LibJS: Rename Get{IANA => Named}TimeZoneNextTransition
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/4b0246a
2022-10-16 14:45:09 +02:00
Luke Wilde
f7bb79d6d1 LibJS: Fast-path ToTemporalTimeZone when the argument is a TimeZone
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/54cea53
2022-10-16 13:40:21 +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
d992cba014 LibJS: Remove Temporal::DefaultTimeZone
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/e232580
2022-10-15 18:05:02 +02:00
Timothy Flynn
735e1c4e20 LibJS: Replace GetIANATimeZoneOffset[Ns] with GetNamedTimeZoneOffset[Ns]
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/e44d36b
2022-10-15 18:05:02 +02:00
Timothy Flynn
053cc90dbe LibJS: Replace GetIANATimeZoneEpochValue with GetNamedTimeZoneEpoch[Ns]
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/e834014
2022-10-15 18:05:02 +02:00
Timothy Flynn
1a84dbcb07 LibJS: Replace GetEpochFromISOParts with GetUTCEpochNanoseconds
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/1b051cc

Note that since Date's implementation of this AO uses Crypto bigints
rather than allocating JS bigints, this change has the fallout of
removing some unused VM parameters and adding an overload of the
IsValidEpochNanoseconds AO for use without a JS::BigInt.
2022-10-15 18:05:02 +02:00
davidot
1b0ca52c54 LibJS: Disallow one day long time zone offsets
This is a normative change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/9cc8b29b
2022-10-14 11:23:50 +02:00
Linus Groh
50428ea8d2 LibJS: Move intrinsics to the realm
Intrinsics, i.e. mostly constructor and prototype objects, but also
things like empty and new object shape now live on a new heap-allocated
JS::Intrinsics object, thus completing the long journey of taking all
the magic away from the global object.
This represents the Realm's [[Intrinsics]] slot in the spec and matches
its existing [[GlobalObject]] / [[GlobalEnv]] slots in terms of
architecture.

In the majority of cases it should now be possibly to fully allocate a
regular object without the global object existing, and in fact that's
what we do now - the realm is allocated before the global object, and
the intrinsics between both :^)
2022-08-27 11:29:10 +01: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
b345a0acca LibJS+LibWeb: Reduce use of GlobalObject as an intermediary
- Prefer VM::current_realm() over GlobalObject::associated_realm()
- Prefer VM::heap() over GlobalObject::heap()
- Prefer Cell::vm() over Cell::global_object()
- Prefer Wrapper::vm() over Wrapper::global_object()
- Inline Realm::global_object() calls used to access intrinsics as they
  will later perform a direct lookup without going through the global
  object
2022-08-23 13:58:30 +01:00
Linus Groh
25849f8a6d LibJS: Replace GlobalObject with VM in common AOs [Part 18/19] 2022-08-23 13:58:30 +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
41791146fd LibJS: Disallow out-of-range return from previous / next transition
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/f3c771f
2022-07-30 10:50:50 +01:00
Linus Groh
071b92e920 LibJS: Fix typos in Temporal spec comments
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/b0411b4
2022-07-10 01:29:28 +02:00
Linus Groh
fb2012dfc7 LibJS: Add Add IsValidISODate assertions
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/46f97ea
2022-07-10 01:22:34 +02: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
7138f10c30 LibJS: Check for invalid epoch ns in DisambiguatePossibleInstants
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/c12d20d
2022-06-24 22:12:03 +01:00
Linus Groh
9c31fee4b5 LibJS: Remove unnecessary modulo operation in GetISOPartsFromEpoch
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/fc3f80d
2022-06-24 22:12:03 +01:00
Linus Groh
9d2377ff60 LibJS: Only call CanonicalizeTimeZoneName on valid time zone IDs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/30122e6
2022-06-15 17:49:20 +01:00
Linus Groh
cf61d01140 LibJS: Add a named alias for parseResult.[[Name]] in ToTemporalTimeZone
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/8ddcb07
2022-06-15 17:49:20 +01:00
Linus Groh
3bb94dd62e LibJS: Refactor Temporal parse AOs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/7fe29eb
2022-06-10 12:39:11 +02:00
Linus Groh
ae1fdf299d LibJS: Use the rounding abstract operations from Intl.NumberFormat V3
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/75279e5

Co-Authored-By: Idan Horowitz <idan.horowitz@gmail.com>
2022-05-25 00:25:23 +01:00
Linus Groh
de0ea331cd LibJS: Simplify BalanceISODate
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/9544573
2022-05-08 00:07:58 +02:00
Linus Groh
15fe6297bc LibJS: Use "Completion" to emphasize completion record
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/31d9fc5
2022-05-08 00:07:58 +02:00
Linus Groh
c6f7214a60 LibJS: Replace magic nanosecond numbers with constants
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/3fdbfda
2022-05-08 00:07:58 +02:00
Linus Groh
27793bf76c LibJS: Replace U+2212 MINUS SIGN with U+002D HYPHEN-MINUS
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/bbcd37b
2022-04-29 22:40:46 +02:00
Linus Groh
df1f81ba90 LibJS: Add notes about lifetime of surrounding agent
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/54e4abc
2022-04-29 22:40:46 +02:00
Linus Groh
76a6bd0e75 LibJS: Fix numeric type confusion in GetEpochFromISOParts return value
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/2a59eac
2022-04-29 22:40:46 +02:00
Linus Groh
70593b7448 LibJS: Update for structured headers added to various Temporal AOs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/e6a15a5
2022-04-29 22:40:46 +02:00
Linus Groh
5397278bfc LibJS: Update spec comments to use ToZeroPaddedDecimalString AO
This is an editorial change in the ECMA-262 and Temporal specs.

See:
- https://github.com/tc39/ecma262/commit/843d8b8
- https://github.com/tc39/proposal-temporal/commit/f9211d9

Note that we don't actually need to implement the AO as we already have
String::formatted() for this, and use unified format strings instead of
zero-padding in individual steps in many cases anyway.
2022-04-12 23:43:29 +01:00
Linus Groh
a5ea066693 LibJS: Fix number types in GetISOPartsFromEpoch
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/c5b645d

This means we now have to pass a global object and construct a BigInt
object just for the assertion, but oh well. We might want to have an
assertion macro that's optimized away in release builds at a later
point, however.
2022-03-25 18:33:55 +00:00
Linus Groh
9950f06623 LibJS: Update spec comment in BuiltinTimeZoneGetPlainDateTimeFor
This is an editorial change in the Temporal spec from a long time ago.

See: https://github.com/tc39/proposal-temporal/commit/e480d40
2022-03-25 18:30:33 +00:00
Linus Groh
619794dfa7 LibJS: Fix fraction substring in ParseTimeZoneOffsetString
This is a normative change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/97d553c
- https://github.com/tc39/proposal-temporal/commit/d53af7f

Note that we already implemented this correctly, so the only change is
updating the spec comment.
2022-03-16 21:49:38 +00:00
Linus Groh
7f5b4842f2 LibJS: Replace dead code in ParseTimeZoneOffsetString with an assertion
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/a29c40b
2022-03-10 23:20:39 +01:00
Linus Groh
68af8649fb LibJS: Follow rules for consuming completion records
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/1c19b96
2022-03-10 23:20:39 +01:00
Linus Groh
17da627b4c LibJS: Fix "set it to" language to be more explicit
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/de58241
2022-03-10 23:20:39 +01:00
Linus Groh
1d32ac7b8b LibJS: Convert get_iana_time_zone_epoch_value() to MarkedVector<BigInt*> 2022-02-09 12:25:27 +00:00
Linus Groh
af7003ebd2 LibJS: Convert 'possible instants' AOs to MarkedVector<Instant*>
Resolve TODOs suggesting the use of a strongly typed MarkedValueList
(a.k.a. MarkedVector<T>) in the following AOs:

- get_possible_instants_for()
- disambiguate_possible_instants()
2022-02-09 12:25:27 +00:00