Commit graph

45 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
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
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
e3895e6c80 LibJS: Pass Realm to define_native_{accessor,function}()
This is needed so that the allocated NativeFunction receives the correct
realm, usually forwarded from the Object's initialize() function, rather
than using the current realm.
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
5dd5896588 LibJS+LibWeb: Replace GlobalObject with Realm in initialize() functions
This is a continuation of the previous commit.

Calling initialize() is the first thing that's done after allocating a
cell on the JS heap - and in the common case of allocating an object,
that's where properties are assigned and intrinsics occasionally
accessed.
Since those are supposed to live on the realm eventually, this is
another step into that direction.
2022-08-23 13:58:30 +01:00
Linus Groh
ecd163bdf1 LibJS+LibWeb: Replace GlobalObject with Realm in object constructors
No functional changes - we can still very easily get to the global
object via `Realm::global_object()`. This is in preparation of moving
the intrinsics to the realm and no longer having to pass a global
object when allocating any object.
In a few (now, and many more in subsequent commits) places we get a
realm using `GlobalObject::associated_realm()`, this is intended to be
temporary. For example, create() functions will later receive the same
treatment and are passed a realm instead of a global object.
2022-08-23 13:58:30 +01: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
f0523aa098 LibJS: Use MUST() instead of TRY() for two infallible Temporal AOs
These were incorrectly used during the conversion from exception checks
to completions.
2022-04-04 19:04:07 +01:00
Linus Groh
83e8dfae38 LibJS: Use AK::Time in system_utc_epoch_nanoseconds()
This also uses <time.h> APIs internally, but wraps them in a much nicer
interface.
2022-04-03 01:10:31 +01: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
Linus Groh
df67f4978e LibJS: Convert Temporal.Now functions to ThrowCompletionOr 2021-10-21 22:31:09 +01:00
Idan Horowitz
40eb3a39d4 LibJS: Rename define_native_function => define_old_native_function
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Idan Horowitz
20163c0584 LibJS: Add ThrowCompletionOr versions of the JS native function macros
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and
JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all
native functions were converted to the new format.
2021-10-20 12:27:19 +01:00
Linus Groh
4d5bd092ea LibJS: Use MUST() where applicable 2021-10-03 20:14:03 +01:00
Linus Groh
6bdd62b51b LibJS: Convert Now AOs to ThrowCompletionOr 2021-09-17 23:43:01 +02:00
Linus Groh
35bba1c98d LibJS: Convert PlainDate 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
f8d92232c8 LibJS: Convert Calendar AOs to ThrowCompletionOr 2021-09-17 08:25:12 +01:00
Idan Horowitz
229a5ce149 LibJS: Convert PlainTime AOs to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Idan Horowitz
cc00a726a8 LibJS: Convert TimeZone AOs to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Idan Horowitz
1822b2938e LibJS: Convert ZonedDateTime AOs to ThrowCompletionOr 2021-09-16 13:53:37 +01:00
Linus Groh
312946059b LibJS+Spreadsheet: Use js_string(VM&, ...) overload more 2021-08-08 21:32:58 +01:00
Linus Groh
16c38788c3 LibJS: Add missing spec links 2021-08-08 11:04:30 +01:00
Linus Groh
a06bd451d4 LibJS: Implement Temporal.Now.zonedDateTimeISO() 2021-08-01 20:31:31 +01:00
Linus Groh
36c79c2989 LibJS: Implement Temporal.Now.zonedDateTime() 2021-08-01 20:31:31 +01:00
Linus Groh
e511390423 LibJS: Implement Temporal.TimeZone.prototype.getPlainDateTimeFor() 2021-08-01 10:24:38 +01:00
Linus Groh
4e4d8d6905 LibJS: Reflect infallibility editorial changes in the Temporal spec
See:

- https://github.com/tc39/proposal-temporal/commit/3c0671f
- https://github.com/tc39/proposal-temporal/commit/fe28b86
2021-07-28 23:48:56 +01:00
Linus Groh
5e64156fce LibJS: Implement Temporal.Now.plainTimeISO() 2021-07-28 21:57:30 +01:00
Linus Groh
2aa2c56891 LibJS: Update Temporal.Now spec section numbers
The addition of @@toStringTag shifted them all by 1.
2021-07-28 21:57:30 +01:00
Linus Groh
af3a26f4cc LibJS: Implement Temporal.Now.plainDateTimeISO() 2021-07-27 19:51:44 +01:00
Linus Groh
0bb19fc51c LibJS: Implement Temporal.Now.plainDateTime() 2021-07-27 19:51:44 +01:00
Linus Groh
f2a2e8e13c LibJS: Implement Temporal.Now.plainDateISO() 2021-07-27 19:51:44 +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
Linus Groh
ff307194f3 LibJS: Implement Temporal.Now[@@toStringTag] 2021-07-27 18:48:22 +01:00
Linus Groh
8f26f51580 LibJS: Add missing spec links to System{Instant,UTCEpochNanoseconds} 2021-07-22 21:19:40 +01:00
Linus Groh
5516ad7158 LibJS: Rename Temporal.now => Temporal.Now
See:

- https://github.com/tc39/proposal-temporal/commit/d0acb66
- https://github.com/tc39/proposal-temporal/commit/0097fdd
2021-07-19 00:59:26 +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
Linus Groh
6c8f0fbb35 LibJS: Use more specific return types for some Temporal AOs
Instead of returning Object* we should be specific and return Instant*,
TimeZone* etc.
2021-07-14 23:50:03 +01:00
Linus Groh
b180e154aa LibJS: Add thousands separators to nanoseconds multiplier value
Increases readability. Thanks to @nico for noticing this!
2021-07-07 20:01:08 +01:00
Linus Groh
3a39ff8f40 LibJS: Implement Temporal.now.instant() 2021-07-07 19:00:42 +01:00
Linus Groh
6cd16eceb3 LibJS: Implement Temporal.now.timeZone() 2021-07-07 00:42:01 +01:00
Linus Groh
7da1fcb2ef LibJS: Add the Temporal.now namespace object
This will be home to various functions:

- Temporal.now.timeZone()
- Temporal.now.instant()
- Temporal.now.plainDateTime()
- Temporal.now.plainDateTimeISO()
- Temporal.now.zonedDateTime()
- Temporal.now.zonedDateTimeISO()
- Temporal.now.plainDate()
- Temporal.now.plainDateISO()
- Temporal.now.plainTimeISO()
2021-07-07 00:42:01 +01:00