Commit graph

50 commits

Author SHA1 Message Date
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
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
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
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
ea023ac62c LibJS: Add Number conversion in AddDu/ToOrSubtractDu/FromPlainYearMonth
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/823300c
2022-06-24 22:12:03 +01:00
Linus Groh
0ff6260afb LibJS: Use ToTemporalDuration in AddDu/ToOrSubtractDu/FromPlainYearMonth
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/a454134
2022-06-24 22:12:03 +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
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
07041498f8 LibJS: Inline ConstrainISOYearMonth into RegulateISOYearMonth
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/c97932b
2022-06-15 17:49:20 +01:00
Linus Groh
aaa9524a52 LibJS: Add parentheses around modulo operation
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/90e4b34
2022-06-15 17:49:20 +01:00
Linus Groh
690585323d LibJS: Prefer Else + Assertion over If for constrained values
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/2088eaa
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
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
93a20b3bfb LibJS: Use default argument of CalendarDateFromFields
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/7a4a518
2022-05-25 00:25:23 +01: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
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
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
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
e109b967a1 LibJS: Make options object const in more Temporal AOs 2022-04-08 00:43:17 +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
b5392f9e39 LibJS: Emit reference information for { calendarName: "always" } option
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/4f7519a
2022-03-31 17:09:10 +01:00
Linus Groh
2ad69d789b LibJS: Remove the ConstrainToRange AO
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/537b3e6
2022-03-16 21:49:38 +00: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
9c209b8079 LibJS: Support modulo(x, y) with different types
It's a bit annoying having to add '.0' to y given that it's an integral
number in most cases.
This turns the single template parameter T into T and U to permit that.
2021-12-22 11:27:31 +01:00
Linus Groh
a3de9dcf95 LibJS: Fix incorrect use of "modulo" in balance_iso_year_month() 2021-11-14 23:08:40 +00: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
f8d92232c8 LibJS: Convert Calendar AOs to ThrowCompletionOr 2021-09-17 08:25:12 +01:00
Linus Groh
6b4777c558 LibJS: Convert prepare_temporal_fields() to ThrowCompletionOr 2021-09-16 22:34:24 +01:00
Linus Groh
2f56fd48ca LibJS: Convert parse_temporal_year_month_string() to ThrowCompletionOr 2021-09-16 22:34:24 +01:00
Linus Groh
9f03647f1f LibJS: Convert to_temporal_overflow() to ThrowCompletionOr 2021-09-16 22:34:24 +01:00
Idan Horowitz
c57a78423d LibJS: Convert PlainYearMonth 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
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
Luke Wilde
ff0b01a505 LibJS: Implement ToTemporalYearMonth AO 2021-09-09 09:06:23 +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
Andreas Kling
6ad427993a Everywhere: Behaviour => Behavior 2021-09-07 13:53:14 +02:00
Linus Groh
421ad73b4f LibJS: Implement Temporal.PlainYearMonth.prototype.toString() 2021-08-20 18:12:15 +01:00
Linus Groh
0cdad283c0 LibJS: Reflect Record wording editorial change in the Temporal spec
See: https://github.com/tc39/proposal-temporal/commit/c8f14d0
2021-08-17 21:59:35 +01:00
Linus Groh
ed9d37bd40 LibJS: Implement Temporal.Calendar.prototype.yearMonthFromFields() 2021-08-16 14:10:41 +01:00
Andreas Kling
286a7ecd92 LibJS: Call base class visit_edges() in various Temporal objects
When overriding visit_edges() in a JS::Object subclass, we must make
sure to call the base class visit_edges(), or the object's Shape (and
any properties) will not get marked.
2021-08-14 20:12:22 +02:00
Linus Groh
0a8edd5ce7 LibJS: Start implementing Temporal.PlainYearMonth
This commit adds the PlainYearMonth object itself, its constructor and
prototype (currently empty), and the CreateTemporalYearMonth and
ISOYearMonthWithinLimits abstract operations.
2021-08-08 17:45:06 +01:00
Linus Groh
c303bbde54 LibJS: Implement Temporal.Now.plainDate()
...and ten required AOs we didn't have yet:

- BalanceISODate
- BalanceISODateTime
- BalanceISOYearMonth
- BalanceTime
- BuiltinTimeZoneGetPlainDateTimeFor
- GetISOPartsFromEpoch
- GetOffsetNanosecondsFor
- ParseTemporalTimeZone
- SystemDateTime
- ToTemporalTimeZone
2021-07-27 19:51:44 +01:00