Linus Groh
1d24699ca8
LibJS: Make Temporal to_foo() AO normalized_options Object a const&
...
These only pass the normalized_options Object directly or indirectly to
get_option(), which now takes a const reference.
2021-09-09 23:46:45 +01:00
Linus Groh
a422ea8792
LibJS: Make get_string_or_number_option() options Object a const&
...
This only passes the options Object to get_option(), which now takes a
const reference.
2021-09-09 23:46:45 +01:00
Linus Groh
c099b1b8a5
LibJS: Make get_option() options Object a const&
...
This only calls Object::get() on the options Object, which is
const-qualified.
2021-09-09 23:46:45 +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
Andreas Kling
d823d7da54
LibJS: Implement the ParseScript AO (as JS::Script::parse())
2021-09-09 21:25:10 +02:00
Andreas Kling
612a23d6fc
LibJS: Start adding a JS::Script class (spec's "Script Record")
2021-09-09 21:25:10 +02:00
Linus Groh
92363a4ef8
LibJS: Mark TemporalTimeToString as infallible
...
This is an editorial change in the Temporal spec.
See: 899cc24
2021-09-09 18:24:18 +01:00
Luke Wilde
90ada407db
LibJS: Implement Temporal.PlainYearMonth.compare
2021-09-09 09:06:23 +01:00
Luke Wilde
092ec0cecf
LibJS: Implement Temporal.PlainYearMonth.from
2021-09-09 09:06:23 +01:00
Luke Wilde
58e2597dc2
LibJS: Implement Temporal.PlainYearMonth.prototype.equals
2021-09-09 09:06:23 +01:00
Luke Wilde
ff0b01a505
LibJS: Implement ToTemporalYearMonth AO
2021-09-09 09:06:23 +01:00
Linus Groh
d3fcf5a570
LibJS: Implement Temporal.Instant.prototype.toZonedDateTimeISO()
2021-09-09 08:52:48 +01:00
Linus Groh
6607d1dfb1
LibJS: Implement Temporal.Instant.prototype.toZonedDateTime()
2021-09-09 08:52:48 +01:00
Andreas Kling
b76456f0ed
LibJS: Add a way to attach custom data to a JS::VM instance
...
This will be used by LibWeb to attach web engine specific stuff that
LibJS doesn't need to know about.
2021-09-09 02:18:31 +02:00
Linus Groh
9661d15fe2
LibJS: Implement Temporal.PlainTime.prototype.toJSON()
2021-09-08 23:42:26 +01:00
Linus Groh
6987e326d8
LibJS: Implement Temporal.PlainTime.prototype.toLocaleString()
2021-09-08 23:42:26 +01:00
Linus Groh
9f78a957d5
LibJS: Implement Temporal.PlainTime.prototype.toString()
2021-09-08 23:42:26 +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
Timothy Flynn
4f2bcebe74
LibUnicode+LibJS: Store locale keyword values as a single string
...
Previously, LibUnicode would store the values of a keyword as a Vector.
For example, the locale "en-u-ca-abc-def" would have its keyword "ca"
stored as {"abc, "def"}. Then, canonicalization would occur on each of
the elements in that Vector.
This is incorrect because, for example, the keyword value "true" should
only be dropped if that is the entire value. That is, the canonical form
of "en-u-kb-true" is "en-u-kb", but "en-u-kb-abc-true" does not change
for canonicalization. However, we would canonicalize that locale as
"en-u-kb-abc".
2021-09-08 21:08:48 +01:00
Timothy Flynn
2ebafe000a
LibJS: Fix typos in Intl.ListFormat comments
2021-09-08 21:08:48 +01:00
davidot
db0a48d34c
LibJS: Restore the environment if an exception is thrown in 'with' block
2021-09-08 20:37:39 +01:00
Luke Wilde
d943b8f100
LibJS: Implement Temporal.PlainTime.prototype.with
...
Ticks off one box in #8982 and fixes one test262 case.
2021-09-08 19:57:29 +01:00
davidot
43b17f27a3
test-js: Add a mark_as_garbage method to force GC to collect that object
...
This should fix the flaky tests of test-js.
It also fixes the tests when running with the -g flag since the values
will not be garbage collected too soon.
2021-09-08 08:53:02 +01:00
Luke Wilde
7788a7e744
LibJS: Fix Temporal.PlainTime.prototype.equals test
...
The two plain times weren't being compared to each other.
2021-09-08 08:48:13 +01:00
Linus Groh
33f76f88bb
LibJS: Add and use the CreateNegatedTemporalDuration AO
...
This is a normative change in the Temporal spec.
See: 6178ed3
2021-09-08 00:07:18 +01:00
Linus Groh
f046a4a75d
LibJS: Make implementation-defined language more concise
...
This is a normative change in the Temporal spec. No behavioral change,
just a clarification.
See: 42c964e
2021-09-08 00:07:18 +01:00
Linus Groh
86a7c795f6
LibJS: Use the newly added remainder operation in GetISOPartsFromEpoch
...
This is a normative change in the Temporal spec. No behavioral change,
just a clarification.
See: b7bdc65
2021-09-08 00:07:18 +01:00
Linus Groh
97cc8f4613
LibJS: Validate Calendar.prototype.fields() values more strictly
...
This is a normative change in the Temporal spec.
See:
- 75b66d8
- 9c2262b
2021-09-08 00:07:18 +01:00
Andreas Kling
6ad427993a
Everywhere: Behaviour => Behavior
2021-09-07 13:53:14 +02:00
Timothy Flynn
ef94c73a01
LibJS: Implement Intl.ListFormat.prototype.resolvedOptions
2021-09-06 23:49:56 +01:00
Timothy Flynn
5c06a91dfa
LibJS: Implement Intl.ListFormat.prototype.formatToParts
2021-09-06 23:49:56 +01:00
Timothy Flynn
cdba40f7ea
LibJS: Implement Intl.ListFormat.prototype.format
2021-09-06 23:49:56 +01:00
Timothy Flynn
3b410742ab
LibJS: Implement Intl.ListFormat.supportedLocalesOf
2021-09-06 23:49:56 +01:00
Timothy Flynn
eacc8bef47
LibJS: Implement the Intl.ListFormat constructor
2021-09-06 23:49:56 +01:00
Timothy Flynn
8e75e5fabb
LibJS: Implement a nearly empty Intl.ListFormat object
...
This adds plumbing for the Intl.ListFormat object, constructor, and
prototype.
2021-09-06 23:49:56 +01:00
Idan Horowitz
456938add0
LibJS: Use StringViews in Round{NumberToIncrement, TemporalInstant}
2021-09-06 22:15:39 +01:00
Idan Horowitz
4b5aa2102c
LibJS: Implement Temporal.Instant.prototype.since
2021-09-06 22:15:39 +01:00
Idan Horowitz
470499b2a8
LibJS: Implement Temporal.Instant.prototype.until
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
Timothy Flynn
207319ecf1
LibJS: Implement ECMA-402 String.prototype.toLocale{Lower,Upper}Case
2021-09-06 15:24:27 +01:00
Timothy Flynn
14086c69e7
LibJS: Only remove Unicode locale extensions during the LookupMatcher AO
...
This was one of the first AOs used for Intl, and I misinterpreted the
spec. Rather than removing all extensions, we must only remove Unicode
locale extensions.
Also use LocaleID::to_string() here instead of the heavier canonical
string method, because the locale is already canonical.
2021-09-06 15:24:27 +01:00
davidot
bbddfeef4b
LibJS: Clean up token constructor and use method instead for identifiers
...
Having two large constructor with just one parameter difference in the
middle seems quite dangerous so just do it with a method.
2021-09-06 08:43:38 +01:00
davidot
3fee7b0d0b
LibJS: Fix that windows style line endings were not ignored or converted
...
These are tested by test262 but the current test262-runner reads the
files in python which automatically converts \r\n to \n.
This meant that we passed the tests while we should not have.
2021-09-06 08:43:38 +01:00
Ali Mohammad Pur
7589cc2494
LibJS: Handle possible allocation failure in ArrayBuffer(size_t)
...
...by replacing it with a ctor that takes the buffer instead, and
handling the allocation failure in ArrayBuffer::create(size_t) by
throwing a RangeError as specified by the spec.
2021-09-06 01:53:26 +02:00
Ali Mohammad Pur
97e97bccab
Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
2021-09-06 01:53:26 +02:00
Linus Groh
6ffc8f389e
LibJS: Use different stack space limit values for with and without ASAN
...
Instead of having a single limit here, which we had to increase once to
work with ASAN enabled, check whether HAS_ADDRESS_SANITIZER is defined
and use 32 KiB, and 16 KiB otherwise (which is what we used previously).
This idea is shamelessly stolen from V8:
b2b44af/src/execution/isolate.cc (L1381-L1387)
2021-09-05 22:17:09 +01:00
Linus Groh
941ff0cf60
LibJS: Prevent stack overflow if Proxy handler's __proto__ is the Proxy
...
Fixes #9322 .
2021-09-05 22:17:09 +01:00
Linus Groh
9998a2c91e
LibJS: Add ErrorType::CallStackSizeExceeded
...
I'm about to add another use of this, so let's add an ErrorType for it
instead of hardcoding the message for a third time.
2021-09-05 22:17:09 +01:00
Brian Gianforcaro
d8de352ead
LibJS: Declare type aliases with "using" instead of "typedef"
2021-09-05 09:48:43 +01:00