Commit graph

44 commits

Author SHA1 Message Date
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
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
34f02bed17 LibJS: Remove check for Instant range before subtracting UTC offset
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/5e2fecb
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
287dd03e2e LibJS: Use nsMinInstant / nsMaxInstant constants in ParseTemporalInstant
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/a045682
2022-06-15 17:49:20 +01:00
Linus Groh
4c77575ec5 LibJS: Simplify Temporal unit AOs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/1b3d018
2022-06-10 12:39:11 +02:00
Linus Groh
b9beb2b120 LibJS: Remove unnecessary ToLimitedTemporalDuration AO
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/c6571f4
2022-06-10 12:39:11 +02:00
Linus Groh
237f537b5c LibJS: Align DifferenceTemporalInstant with similar AOs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/cf9118b
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
80048c694a LibJS: Use '2 × nsMaxInstant' in a couple of assertion comments
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/a225863
2022-05-09 20:27:20 +02:00
Linus Groh
cc8f5151d7 LibJS: Refactor Temporal since/until to common AOs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/85a9f57
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
3729a910f6 LibJS: Refactor Temporal add/subtract to common AOs
This is an editorial change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/2f96efc
- https://github.com/tc39/proposal-temporal/commit/fbff635
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
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
55f9733316 LibJS: Add missing check in ParseTemporalInstant
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/baead4d
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
64e43c89bc LibJS: Remove assertions that are now part of structured headers
This is an editorial change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/7fbdd28
- https://github.com/tc39/proposal-temporal/commit/f666243
- https://github.com/tc39/proposal-temporal/commit/8c7d066
- https://github.com/tc39/proposal-temporal/commit/307d108
- https://github.com/tc39/proposal-temporal/commit/d9ca402

In practical terms this means we can now get rid of a couple of awkward
assertion steps that were no-ops anyway, since the types are enforced
by the compiler.
2022-03-10 23:20:39 +01:00
Linus Groh
64f125fe34 LibJS: Mark CreateTemporalTimeZone("UTC") as infallible
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/ea25cfa
2022-01-13 19:25:56 +01:00
Linus Groh
38809f90d9 LibJS: Introduce & use FormatISOTimeZoneOffsetString
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6b7a993
2021-11-04 16:45:54 +01:00
Linus Groh
60ee542612 LibJS: Mark GetEpochFromISOParts as infallible
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/66ea81b
2021-10-23 01:05:50 +01:00
Linus Groh
4d8912a92b LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
2021-10-13 09:55:10 +01:00
Linus Groh
d764f1c699 LibJS: Convert PlainDateTime AOs to ThrowCompletionOr 2021-09-17 23:43:01 +02:00
Linus Groh
20337a34a2 LibJS: Convert Instant AOs to ThrowCompletionOr 2021-09-17 08:25:12 +01:00
Linus Groh
4f487266b4 LibJS: Convert parse_temporal_instant_string() to ThrowCompletionOr 2021-09-16 22:34:24 +01:00
Idan Horowitz
cc00a726a8 LibJS: Convert TimeZone AOs to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Idan Horowitz
5a4c90fcb1 LibJS: Convert ordinary_create_from_constructor<T> to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Linus Groh
5ae6ad8557 LibJS: Store Instant's and ZonedDateTime's m_nanoseconds as a const&
There's no need for these to be non-const. Suggested by @IdanHo in
https://github.com/SerenityOS/serenity/pull/9904#discussion_r704960184.

Perhaps we can make more internal slots of these and other objects const
references as well, but that's a bit more involved as they are used by
various functions expecting non-const references.
2021-09-09 23:46:45 +01:00
Linus Groh
e4c07c5b8f LibJS: Make new_target parameter of all Temporal AOs a const*
These are passed to ordinary_create_from_constructor() in each case,
which takes the parameter as a const&, so these can also be const.
2021-09-09 23:46:45 +01:00
Linus Groh
81aaa9ccd5 LibJS: Replace String const& with StringView in various Temporal AOs
This is especially helpful where we already pass StringView literals
and only compare them with others, e.g. overflow and largest/smallest
unit, in which case there's no need to actually allocate a string.
2021-09-08 23:42:26 +01:00
Idan Horowitz
456938add0 LibJS: Use StringViews in Round{NumberToIncrement, TemporalInstant} 2021-09-06 22:15:39 +01:00
Idan Horowitz
24b78fff7d LibJS: Add a bunch of Temporal Abstract Operations
These will allow us to (partially) implement
Temporal.Instant.prototype.{until, since}
2021-09-06 22:15:39 +01:00
Linus Groh
576be0f8e7 LibJS: Implement Temporal.Instant.prototype.toString() 2021-08-31 16:35:51 +02:00
Linus Groh
16c38788c3 LibJS: Add missing spec links 2021-08-08 11:04:30 +01:00
Linus Groh
b38f1fb071 LibJS: Implement Temporal.Instant.prototype.add() 2021-08-07 13:10:35 +01:00
Linus Groh
f58891ed42 LibJS: Add a js_bigint(VM&, ...) overload and use it
We already have js_string(VM&, ...) and js_symbol(VM&, ...) overloads,
so feels very familiar.
2021-08-03 00:14:48 +01:00
Linus Groh
6f75dcc7b8 LibJS: Handle ZonedDateTime in ToTemporalInstant 2021-08-01 20:31:31 +01:00
Linus Groh
d159938acc LibJS: Reflect recent editorial changes in the Temporal proposal
See:

- https://github.com/tc39/proposal-temporal/commit/2148441
- https://github.com/tc39/proposal-temporal/commit/08c04cc
- https://github.com/tc39/proposal-temporal/commit/b77da58
2021-07-19 00:59:26 +01:00
Idan Horowitz
84b028bd71 LibJS: Add Temporal.Instant.prototype.round()
As well as the required Abstract Operations.
2021-07-12 19:05:17 +01:00
Idan Horowitz
33cf6274e8 LibJS: Add Temporal.Instant.compare() 2021-07-12 19:05:17 +01:00
Idan Horowitz
b816037739 LibJS: Add the ToTemporalInstant Abstract Operation & its requirements
This is Abstract Operation is required for the majority of
InstantConstructor's and InstantPrototype's methods.

The implementation is not entirely complete, (specifically 2 of the
underlying required abstract operations, ParseTemporalTimeZoneString
and ParseISODateTime are missing the required lexing, and as such are
TODO()-ed) but the majority of it is done.
2021-07-12 19:05:17 +01:00
Linus Groh
47fb4286c7 LibJS: Start implementing Temporal.Instant
Just like the initial Temporal.TimeZone commit, this patch adds the
Instant object itself, its constructor and prototype (currently empty),
and two required abstract operations.
2021-07-07 19:00:42 +01:00