Commit graph

181 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
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
c3567faa8c LibJS: Remove unnecessary checks for undefined before ToPositiveInteger
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/9f3bf53
2022-07-05 23:15:52 +02:00
Linus Groh
7a8e6cf6c6 LibJS: Move MergeLists into non-Temporal ECMA-262 amendments
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/4ce3db1
2022-06-18 13:54:46 +01:00
Linus Groh
0c3d2b656e LibJS: Rename CalendarMergeFieldNames to MergeLists
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/bebf467
2022-06-18 13:54:46 +01:00
Linus Groh
569c2dc1d0 LibJS: Adjust order of operations in ISO{Date,MonthDay}FromFields
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/7dd90dc
2022-06-15 17:49:20 +01:00
Linus Groh
c0986be2c1 LibJS: Use consistent alias names for object-copy steps
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6669bad
2022-06-15 17:49:20 +01:00
Linus Groh
e68173b656 LibJS: Update AvailableCalendars AO to reflect spec changes
These are editorial and normative changes in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/2c977fc
- https://github.com/tc39/proposal-temporal/commit/3af75ec
- https://github.com/tc39/proposal-temporal/commit/75ea812
- https://github.com/tc39/proposal-temporal/commit/e7be49b
- https://github.com/tc39/proposal-temporal/commit/883e00a
- https://github.com/tc39/proposal-temporal/commit/5b9d76a
2022-06-15 17:49:20 +01:00
Linus Groh
3025f77991 LibJS: Add an explicit operation for merging calendar field names
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/2bd7977
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
3e6561c75f LibJS: Fold PreparePartialTemporalFields into PrepareTemporalFields
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6ed1835
2022-06-15 17:49:20 +01:00
Linus Groh
631f270ac1 LibJS: Add missing conversion to integer values in Calendar AOs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/bfeb523
2022-06-15 17:49:20 +01:00
Linus Groh
86e22abd76 LibJS: Rename DefaultMergeFields to DefaultMergeCalendarFields
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/0ee80b2
2022-06-10 12:39:11 +02:00
Linus Groh
a5c41aa905 LibJS: Use required fields argument in ISOYearMonthFromFields
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/ff02f87
2022-05-17 21:16:56 +01:00
Linus Groh
d2c1dd5454 LibJS: Introduce ISO Date Records
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d264341
2022-05-16 20:46:46 +01:00
Linus Groh
fc6cf3cb9d LibJS: Remove ToISODayOfWeek
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/3eab7e4
2022-05-08 00:07:58 +02:00
Linus Groh
cabcdd838b LibJS: Remove ToISODayOfYear
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6117d90
2022-05-08 00:07:58 +02:00
Linus Groh
a216c0b6df LibJS: Remove IsISOLeapYear
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/a36bdd4
2022-05-08 00:07:58 +02:00
Linus Groh
6d0d7c8fd0 LibJS: Remove ISODaysInYear
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/f62e737
2022-05-08 00:07:58 +02:00
Linus Groh
aac457755d LibJS: Define IsBuiltinCalendar in terms of AvailableCalendars
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/896b72d
2022-04-29 22:40:46 +02:00
Linus Groh
2499911898 LibJS: Rename DateFromFields to CalendarDateFromFields, etc
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/fd27b54
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
151eb8606d LibJS: Consistently call observable Temporal AOs with undefined options
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6fa5b9d
2022-04-07 12:58:39 +01:00
Linus Groh
cfb04765fa LibJS: Correct PlainYearMonth arithmetic for non-ISO calendars
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/61e8dd0
2022-03-31 17:09:10 +01:00
Linus Groh
0c22a7f822 LibJS: Assume Get() on the result of PrepareTemporalFields can't fail
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/980e168
2022-03-16 21:49:38 +00:00
Linus Groh
251f5e8885 LibJS: Use CreateTemporalCalendar in GetBuiltinCalendar
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/f6b3a10
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
bc183dbbcb LibJS: Replace uses of MarkedValueList with MarkedVector<Value>
This is effectively a drop-in replacement.
2022-02-09 12:25:27 +00:00
Linus Groh
6f20f49b21 Everywhere: Rename JS::PropertyKey variables from property_{name => key}
PropertyKey used to be called PropertyName, but got renamed. Let's
update all the variables of this type as well.
2022-02-06 22:02:45 +00:00
Linus Groh
e087cd574e LibJS: Rename variables to 'calendarLike' in a couple of places
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/9af2d35
2022-02-04 20:00:34 +00:00
Timothy Flynn
59ca435172 LibJS: Use new construct AO overload where easily applicable 2022-01-25 22:09:13 +00:00
mjz19910
1ef633472b Everywhere: Convert VM::call() to JS::call() 2022-01-23 15:24:45 +00:00
Linus Groh
29e96eceeb LibJS: Convert PropertyKey::from_value() to ThrowCompletionOr
Lots of MUST() - perhaps we'll eventually come up with a better API for
the common case where it can't fail.
2022-01-04 23:37:26 +00:00
Luke Wilde
4f3c283f24 LibJS: Move calendar validation out of parse_temporal_calendar_string
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/7207a1c
2021-12-08 19:11:50 +00:00
Linus Groh
a20b189eab LibJS: Fix incorrectly formatted section comments
A couple of missing URLs, spaces, and a stray comma.
2021-11-24 17:37:27 +00:00
Nico Weber
a164e6ecbb LibJS: Unbreak to_iso_day_of_week
481f7d6afa tried to use `modulo()` here, but missed that the
code used `<=` instead of `<`.

Keep using `modulo()` and add an explicit conditional, which is
arguably clearer.
2021-11-16 00:41:45 +00:00
Nico Weber
481f7d6afa LibJS: Use modulo() function in to_iso_day_of_week
No behavior change.
2021-11-15 23:54:41 +00:00
Linus Groh
a757f3f421 LibJS: Fix leap year check in to_iso_week_of_year() for week < 1
When the resulting week is in the previous year, we need to check if the
previous year is a leap year and can potentially have 53 weeks, instead
of the given year.
Also added a comment to briefly explain what's going on, as it took me a
while to figure out.
2021-11-15 21:33:26 +00:00
Luke Wilde
29072f4b09 LibJS: Implement the required AOs for Temporal.Duration.compare 2021-11-11 21:06:54 +00:00
Linus Groh
36b51276d5 LibJS: Change calendar_date_add() date parameter from PlainDate to Value
Turns out use of this AO is a bit more flexible than I anticipated.
2021-11-07 15:31:28 +01:00
Linus Groh
d49bbb1da3 LibJS: Implement TODO()'d parts of balance_duration()
Massive :yakstack:, so I understand why it was skipped in the first
place :^)
2021-11-02 09:24:35 +01:00
Linus Groh
97f6c6029f LibJS: Implement Temporal.TimeZone.prototype.getInstantFor() 2021-11-01 21:39:45 +01:00
Linus Groh
09d1db5afd LibJS: Clarify mathematical types in Temporal AOs and functions
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/e480d40
2021-10-26 23:10:11 +02:00
Andreas Kling
398c181c79 LibJS: Rename PropertyName to PropertyKey
Let's use the same name as the spec. :^)
2021-10-24 17:18:07 +02:00
Idan Horowitz
e26d9f419b LibJS: Remove vm.construct and it's usages 2021-10-23 02:49:41 +03:00
Linus Groh
be28a6142b LibJS: Convert to_integer_or_infinity() to ThrowCompletionOr 2021-10-18 21:24:30 +01:00
Linus Groh
52976bfac6 LibJS: Convert to_object() to ThrowCompletionOr 2021-10-13 09:55:10 +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
2c222ba40b LibJS: Implement Temporal.PlainYearMonth.prototype.toPlainDate() 2021-10-11 08:31:39 +01:00