1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 13:25:07 +00:00
Commit graph

3776 commits

Author SHA1 Message Date
davidot
54b2d8c1b8 LibJS: Reuse as_i32 in as_double in JS::Value
Since this might be complicated with NaN boxing keeping it as one
implementation makes this easier to check and change.
2022-11-17 16:05:20 +00:00
Timothy Flynn
421ebc2e29 LibJS: Remove workaround for Clang misalignment in MathematicalValue
As noted in 269a931, this has been fixed in Clang 15.
2022-11-15 12:30:16 +00:00
Linus Groh
24c0a6e9a4 Revert "LibJS: Add explicit assertion for days"
This reverts commit 56abb01ee3.

Unfortunately, the assertion doesn't work out as expected and crashes
test-js.
2022-11-11 14:10:02 +00:00
Andreas Kling
d7e5a2058d LibJS: Cache access to bindings in the global environment
This patch adds a special EnvironmentCoordinate::global_marker value
that signifies that a binding lookup ended up searching the global
environment. It doesn't matter if we find it there or not, the global
marker is always returned. This allows us to bypass other environments
on subsequent access, going directly to the global environment.
2022-11-11 12:22:01 +00:00
Andreas Kling
7b30df0840 LibJS: Make ObjectEnvironment::set_mutable_binding() faster as well
We can combine HasProperty and Set into just Set in non-strict mode for
non-with object environments.
2022-11-11 12:22:01 +00:00
Andreas Kling
12ceaf3790 LibJS: Make ObjectEnvironment::get_binding_value() faster in sloppy mode
We can combine HasProperty and Get into just Get in non-strict mode for
non-with object environments.
2022-11-11 12:22:01 +00:00
Smrtnyk
56abb01ee3 LibJS: Add explicit assertion for days
This is an editorial change in Temporal spec.

See: 15b7293b38
2022-11-11 12:14:46 +00:00
Nico Weber
6911c5545c Everywhere: Fix a few comment typos 2022-11-09 16:00:32 +00:00
Andreas Kling
88b15b0819 LibJS: Move throw_completion(Value) out of line
This allows us to instrument this function locally without rebuilding
1000+ files.
2022-11-09 15:48:08 +01:00
Daniel Bertalan
4296425bd8 Everywhere: Remove redundant inequality comparison operators
C++20 can automatically synthesize `operator!=` from `operator==`, so
there is no point in writing such functions by hand if all they do is
call through to `operator==`.

This fixes a compile error with compilers that implement P2468 (Clang
16 currently). This paper restores the C++17 behavior that if both
`T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be
rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators
makes the rewriting possible again.
See https://reviews.llvm.org/D134529#3853062
2022-11-06 10:25:08 -07:00
Timothy Flynn
5e5cdb2d28 LibJS: Remove the now-unused LocalTZA AO 2022-11-06 01:47:37 +00:00
Timothy Flynn
f211028252 LibJS: Change ToLocalTime to use epoch nanoseconds
This is an editorial change to the ECMA-402 spec. See:
b3f9a1b
2022-11-06 01:47:37 +00:00
Timothy Flynn
9a9025dea0 LibJS: Remove infallibility marker from DefaultTimeZone invocation
This is an editorial change to the ECMA-402 spec. See:
46aa5cc

Also add an ECMA-402 spec link to the DefaultTimeZone implementation, as
that definition supersedes ECMA-262.
2022-11-06 01:47:37 +00:00
Smrtnyk
2ba2e6ca0a LibJS: Rename ToShowTimeZoneNameOption to ToTimeZoneNameOption
This is an editorial change in Temporal spec.

See: ab5b1ba910
2022-11-05 15:44:49 +00:00
Timothy Flynn
8eec25b7ae LibJS: Use more accurate number-to-string method in Number toExponential 2022-11-04 21:12:10 +00:00
Timothy Flynn
5898db8c0f LibJS: Use more accurate number-to-string method in Number toPrecision 2022-11-04 21:12:10 +00:00
Timothy Flynn
d56205f991 LibJS: Use more accurate number-to-string method in Intl.NumberFormat
Intl.NumberFormat only ever wants literal number-to-digits here, without
extra exponential formatting.
2022-11-04 21:12:10 +00:00
Timothy Flynn
9620a092de LibJS: Publicly expose double_to_string and rename it number_to_string
Rename it to match the name used by the spec.

Add an override mode to skip formatting numbers with an exponential sign
(e.g. 1e23). This mode is needed by Number and Intl.NumberFormat, who
don't call out a specific number-to-string method to use (they just say
to make "the String consisting of the digits of n").
2022-11-04 21:12:10 +00:00
Smrtnyk
efe82e5c91 LibJS: Rename ToShowCalendarOption to ToCalendarNameOption
This is an editorial change in the Temporal spec.

See: 2c9e2615f7
2022-11-04 21:00:25 +00:00
Dan Klishch
56aa21a7dc LibJS: Implement precise double_to_string 2022-11-03 20:17:09 -06:00
Luke Wilde
ac67077b57 LibJS: Fix length of PlainDateTime.withPlainTime
withPlainTime's argument is optional, so the length of the function is
actually 0.
2022-11-03 21:09:58 +00:00
Luke Wilde
b26b18a0bc LibJS: Add timeZoneName: "critical" option to ZonedDateTime.toString()
This is a normative change in the Temporal spec.

See: d84937f
2022-11-03 19:15:50 +00:00
Luke Wilde
4a167cfbec LibJS: Add calendarName: "critical" option to toString() methods
This is a normative change in the Temporal spec.

See: e715a50
2022-11-03 19:15:50 +00:00
Luke Wilde
192aa75279 LibJS: Align ISO 8601 grammar with annotations from IXDTF
This is a normative change in the Temporal spec.

See: c64b844
2022-11-03 19:15:50 +00:00
Timothy Flynn
99fc94e138 LibJS: Delegate to NumberFormat for DurationFormat unit formatting
This is a normative change in the Intl.DurationFormat proposal. See:
12ba9df
2022-11-03 18:37:48 +00:00
Timothy Flynn
a5bf32018f LibJS+LibUnicode: Add "microsecond" and "nanosecond" as sanctioned units
This is a normative change in the ECMA-402 spec. See:
f627573
2022-11-03 18:37:48 +00:00
Timothy Flynn
8ff0d35386 LibJS: Format sanctioned units such that there is one unit per line
Much easier to manage and view diffs this way, rather than one large
single line. This will soon be the only method in this file, so there's
no concern over taking up too much vertical space here.
2022-11-03 18:37:48 +00:00
Nico Weber
daeaefad17 Everywhere: Clean up "the the" comment typos 2022-11-03 17:38:32 +00:00
Timothy Flynn
92f4f40198 LibJS: Rename the Intl Enumeration Available* AOs to AvailableCanonical*
This is an editorial change to the Intl Enumeration API proposal. See:
807b444

Note that this was followed by a normative change to actually ensure the
returned values are canonical:
075a6dc

But the values we return are already canonical.
2022-11-03 16:36:11 +00:00
Moustafa Raafat
939374a037 LibJS: Use the UnsignedBigInteger compare_to_double algorithm
This also avoids an unnecessary copy
2022-11-02 22:04:34 -06:00
Moustafa Raafat
54b8a2b094 LibCrypto: Add a way to compare UnsignedBigInteger with double
This patch also make SignedBigInteger::compare_to_double make use
of the new function.
2022-11-02 22:04:34 -06:00
Timothy Flynn
4686989582 LibJS: Map DurationFormat's list style to "short" when it is "digital"
This is a normative change in the Intl.DurationFormat proposal. See:
7495e32
2022-11-01 14:33:07 +00:00
Timothy Flynn
84e6833203 LibJS: Alphabetically sort the collations returned by CollationsOfLocale
This is a normative change in the Intl Locale Info proposal. See:
171d3ad

Note this doesn't affect us because we don't have collation info from
the CLDR; we just return ["default"] here.
2022-11-01 14:33:07 +00:00
demostanis
3e8b5ac920 AK+Everywhere: Turn bool keep_empty to an enum in split* functions 2022-10-24 23:29:18 +01:00
Yedaya Katsman
dcad8494d6 LibJS: Accept calendar names case-insensitively
This is a normative change in the Temporal spec

See tc39/proposal-temporal@03101c6
2022-10-24 23:00:19 +01:00
davidot
62fc3e50f3 LibJS: Make parseFloat use the new double parser
This means it no longer is locale dependent and doesn't incorrectly
accept hex floats anymore.
2022-10-23 15:48:45 +02:00
davidot
783b1a479d LibJS: Make string_to_double use the new double parser 2022-10-23 15:48:45 +02:00
davidot
6805ded21d LibJS: Make canonical_numeric_index_string use the new double parser 2022-10-23 15:48:45 +02:00
davidot
3dc99af3dc LibJS: Make parse_temporal_duration use the new double parser 2022-10-23 15:48:45 +02:00
davidot
d66bfcc3f4 LibJS: Make PluralRules use the new double parser 2022-10-23 15:48:45 +02:00
davidot
9921f80817 LibJS: Fix that non-double numbers from JSON were truncated to i32 2022-10-23 15:48:45 +02:00
Moustafa Raafat
5edd4bd512 LibJS: Require NanosecondsToDays remainder less than dayLength
This is an normative change in the Temporal spec.
See: ac69b63
2022-10-22 19:14:14 +02:00
Moustafa Raafat
b1c8029c2b LibJS: Require that NanosecondsToDays doesn't flip sign
This is an normative change in the Temporal spec.
See: e13c52d
2022-10-22 19:14:14 +02:00
Andreas Kling
e23fe8cf87 LibJS: Make define_native_foo() take SafeFunctions
We were taking AK::Function and then passing them along to
NativeFunction, which takes a SafeFunction. This works, since
SafeFunction will transparently wrap AK::Function in a CallableWrapper
when assigned, but it was causing us to accumulate thousands of
pointless wrappers around direct function pointers.

By using SafeFunction at every step of the setup call chain, we no
longer create any CallableWrappers for the majority of native functions
in LibJS. Also, the number of heap-registered SafeFunctions in a new
realm goes down from ~5000 to 5. :^)
2022-10-20 15:16:23 +02:00
Moustafa Raafat
8f964604f0 LibJS: Refactor CalendarFields for better linearity
This is a normative change in the Temporal spec.
See: 9b139a1
2022-10-20 00:53:44 +02:00
Idan Horowitz
d38aeddd77 LibJS: Simplify ParseTemporalTimeZoneString
This is an editorial change in the Temporal spec.
See: eec8efab
2022-10-20 00:47:42 +02:00
Idan Horowitz
0c61552b81 LibJS: Refactor ToRelativeTemporalObject
This is an editorial change in the Temporal spec.
See: 895854d9
2022-10-20 00:47:42 +02:00
Moustafa Raafat
092b33c96e LibJS: Remove trivial operations ISO{Year,Month,Day}
This is an editorial change in the Temporal spec.
See: 606d8a2
2022-10-19 22:39:33 +02:00
Moustafa Raafat
69d5368b2a LibJS: Remove trivial operation IsValidISOMonth
This is an editorial change in the Temporal spec.
See: a08330a
2022-10-19 22:39:33 +02:00
Moustafa Raafat
48cc557dfa LibJS: Merge ISOMonthCode and BuildISOMonthCode
This is an editorial change in the Temporal spec.
See: a4d17b1
2022-10-19 22:39:33 +02:00