Timothy Flynn
4d0315099f
LibJS: Allow TypeArray to become detached in TypedArray.prototype.set
...
This is a normative change in the ECMA-262 spec. See:
4d570c4
2022-04-13 16:02:01 +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:
- 843d8b8
- 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
00b8ce4a6d
LibJS: Pass this value to fallback func in Array.prototype.toString()
...
The existing code looks innocently correct, implementing the following
step:
3. If IsCallable(func) is false, set func to the intrinsic function
%Object.prototype.toString%.
as
return ObjectPrototype::to_string(vm, global_object);
However, this misses the fact that the next step calls the function with
the previously ToObject()'d this value (`array`):
4. Return ? Call(func, array).
This doesn't happen in the current implementation, which will use the
unaltered this value from the Array.prototype.toString() call, and make
another, unequal object in %Object.prototype.toString%. Since both that
and Array.prototype.toString() do a Get() call on said object, this
behavior is observable (see newly added test).
Fix this by actually doing what the spec says and calling the fallback
function the regular way.
2022-04-12 00:23:27 +01:00
Luke Wilde
c32dcf7f75
LibJS: Update ZonedDateTime AO spec comments for structured headers
...
This is an editorial change in the Temporal spec.
See: 01714a5
2022-04-11 23:47:02 +01:00
Linus Groh
7e18d1c078
LibJS: Remove unused include from AbstractOperations.cpp
2022-04-11 21:34:57 +01:00
Linus Groh
24d772af7c
LibJS: Move additional notes to spec comments onto their own line
...
Having all spec comments verbatim on their own line with no additions
made by us will make it easier to automate comparing said comments to
their current spec counterparts.
2022-04-11 21:32:37 +01:00
Luke Wilde
90f14de1e9
LibJS: Call HostEnsureCanCompileStrings in CreateDynamicFunction
...
I noticed we were missing this when I added to PerformEval :^)
2022-04-11 21:23:36 +01:00
Luke Wilde
7798821f5b
LibJS: Add tests for the new steps added to PerformEval
2022-04-11 21:23:36 +01:00
Luke Wilde
34f902fb52
LibJS: Add missing steps and spec comments to PerformEval
...
While adding spec comments to PerformEval, I noticed we were missing
multiple steps.
Namely, these were:
- Checking if the host will allow us to compile the string
(allowing LibWeb to perform CSP for eval)
- The parser's initial state depending on the environment around us
on direct eval:
- Allowing new.target via eval in functions
- Allowing super calls and super properties via eval in classes
- Disallowing the use of the arguments object in class field
initializers at eval's parse time
- Setting ScriptOrModule of eval's execution context
The spec allows us to apply the additional parsing steps in any order.
The method I have gone with is passing in a struct to the parser's
constructor, which overrides the parser's initial state to (dis)allow
the things stated above from the get-go.
2022-04-11 21:23:36 +01:00
Linus Groh
b4c6fd51be
LibJS: Use single page spec link for BoundFunctionCreate
2022-04-11 19:44:56 +01:00
Linus Groh
231acda7f8
LibJS: Fix two bogus spec links
2022-04-11 19:44:33 +01:00
Timothy Flynn
84a81dd466
LibJS: Do not throw a TypeError when sorting a detached TypedArray
...
This is a normative change in the ECMA-262 spec. See:
e0c74e1
2022-04-08 11:15:16 +01:00
Timothy Flynn
13d05403ff
LibJS: Move DetachArrayBuffer implementation to the ArrayBuffer object
...
The spec notes that this AO is unused by ECMA-262, but is provided for
ECMAScript hosts. Move the definition to a common location to allow
test-js to also use it.
2022-04-08 11:15:16 +01:00
Linus Groh
e109b967a1
LibJS: Make options object const in more Temporal AOs
2022-04-08 00:43:17 +01:00
Linus Groh
2844a2c448
LibJS: Handle undefined options in MergeLargestUnitOption
...
This is an editorial change in the Temporal spec.
See: 5e161a2
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: 6fa5b9d
2022-04-07 12:58:39 +01:00
Timothy Flynn
29b6c22384
LibJS: Reorder and reduce steps of InitializeDateTimeFormat
...
These are editorial changes in the Intl spec. See:
7d0326c
05a299b
8c24ea7
fd8dea9
2022-04-06 20:58:12 -04:00
Timothy Flynn
f3f3e3cdc3
LibJS: Remove outdated FIXME from String.prototype.localeCompare
...
This FIXME was addressed in 0975eba724
.
2022-04-06 20:58:12 -04:00
Ali Mohammad Pur
4b5a9bab34
LibJS: Actually generate a lexical env for SwitchStatement in BC
...
We had code for this in ScopeNode, but that function was never called
for a SwitchStatement.
This fixes a bunch of scoping tests for switch.
2022-04-05 11:46:48 +02:00
Ali Mohammad Pur
0e1943937c
LibJS: Use InitializeOrSet to initialize function declarations in BC
...
A function may be redefined, in which case the existing binding is
expected to be reused.
2022-04-05 11:46:48 +02:00
Ali Mohammad Pur
5407fe8fcf
LibJS: Make Handle<Value>::is_null() also consider the contained value
...
Previously this would've said `make_handle(Value(1234))` is null, as it
did not contain a cell (but rather a plain Value), which made throwing
primitives spin forever in BC mode.
2022-04-05 11:46:48 +02:00
Linus Groh
421d9a6361
LibJS: Fix typo in a variable name in get_substitution()
2022-04-04 20:35:57 +01:00
Linus Groh
0057d489bd
LibJS: Fix some clang-tidy warnings in Temporal
...
- Remove unused declarations of removed functions
- Remove unused includes
- Declare pointer values as `auto*`
2022-04-04 19:22:58 +01: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
5b48912d35
LibJS: Remove a bunch of gratuitous JS namespace qualifiers
2022-04-03 15:19:33 +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
Idan Horowitz
59080f441e
LibJS: Normalize NaN values in Sets and Maps
...
This ensures that different NaN types (e.g. 0/0, 0 * Infinity, etc) are
mapped to the same Set/Map entry.
2022-04-02 14:15:43 +01:00
Idan Horowitz
086969277e
Everywhere: Run clang-format
2022-04-01 21:24:45 +01:00
Andreas Kling
7047a5ca59
LibJS: Allow JS::make_handle(T*) to be called with nullptr
...
Instead of asserting, just return an empty Handle.
2022-03-31 18:25:06 +02:00
Ali Mohammad Pur
7ea095feb0
LibJS: Don't assume that for-in/of target is a variable on LHS::Assign
...
e.g. `for ([foo.bar] in ...)` is actually a binding pattern.
2022-03-31 18:11:08 +02:00
Ali Mohammad Pur
56c0fdc1c4
LibJS: Implement codegen for MemberExpression binding patterns
2022-03-31 18:11:08 +02:00
Ali Mohammad Pur
007ffcd763
LibJS: Implement bytecode generation for all ObjectExpression properties
2022-03-31 18:11:08 +02:00
Linus Groh
8e175b4959
LibJS: Adjust ISO8601 representation for years between 1 BCE and 999 CE
...
This is a normative change in the Temporal spec.
See: 39eeecd
2022-03-31 17:09:10 +01:00
Linus Groh
cfb04765fa
LibJS: Correct PlainYearMonth arithmetic for non-ISO calendars
...
This is a normative change in the Temporal spec.
See: 61e8dd0
2022-03-31 17:09:10 +01:00
Linus Groh
b020b8eea2
LibJS: Handle Etc/GMT timezones properly in TimeZone{IANA,Bracketed}Name
...
This is a normative change in the Temporal spec.
See: 8c73780
2022-03-31 17:09:10 +01:00
Linus Groh
b5392f9e39
LibJS: Emit reference information for { calendarName: "always" } option
...
This is a normative change in the Temporal spec.
See: 4f7519a
2022-03-31 17:09:10 +01:00
Linus Groh
29aa938fa5
LibJS: Fix Duration.compare() for dates with unusual number of hours
...
This is a normative change in the Temporal spec.
See:
- 08bcd53
- e962797
2022-03-31 17:09:10 +01:00
Hendiadyoin1
c79e4961f6
LibJS: Add explicit default copy+move constructors to ThrowCompletionOr
...
This stops clangd from complaining about not being able to determine the
copy-constructibility of ThrowCompletionOr and Completion.
2022-03-31 09:25:17 -04:00
Timothy Flynn
4fd463dae0
LibJS: Normalize mathematical references to negative zero
...
This is an editorial change in the Intl spec. See:
d4be24e
2022-03-30 14:24:32 +01:00
Timothy Flynn
41df4c6353
LibJS: Modernize InitializeDateTimeFormat and simplify error handling
...
This is an editorial change in the Intl spec. See:
4cf1d2c
2022-03-30 14:24:32 +01:00
Timothy Flynn
066352c9aa
LibJS+LibUnicode: Align ECMA-402 "sanctioned" terminology with UTS 35
...
This is an editorial change in the Intl spec. See:
087995c
233d29c
This also adds a missing spec link for the sanctioned units and fixes a
broken spec link for IsSanctionedSingleUnitIdentifier. In LibUnicode,
the NumberFormat generator is updated to use the constexpr helper to
retrieve sanctioned units.
2022-03-30 14:24:32 +01:00
Timothy Flynn
1a76839e8d
LibJS: Use consistent ASCII case-transformation and string language
...
Also update the incorrect spec link for IsWellFormedCurrencyCode.
These are editorial changes in the Intl spec. See:
6939b44
3a775eb
97a7940
129c790
42ec908
ea25c36
2022-03-30 14:24:32 +01:00
Timothy Flynn
72674d7905
LibJS: Set DateTimeFormat's [[HourCycle]] internal slot only once
...
This is an editorial change in the Intl spec. See:
8081868
2022-03-30 14:24:32 +01:00
Timothy Flynn
0975eba724
LibJS: Mark an invocation to RequireObjectCoercible as fallible
...
This is an editorial change in the Intl spec. See:
6939b44
2022-03-30 14:24:32 +01:00
Timothy Flynn
36bff95f15
LibJS: Use the new TransformCase AO for locale-aware case conversions
...
This is an editorial change in the Intl spec. See:
6939b44
2022-03-30 14:24:32 +01:00
Timothy Flynn
f8e7701cf3
LibJS: Disallow calendar display names which contain an underscore
...
This is a normative change in the Intl spec. See:
2703d06
2022-03-30 14:24:32 +01:00
Timothy Flynn
7c41e6058a
LibJS: Explicitly indicate infallible incovations
...
These are editorial changes in the Intl spec.
See:
6804096
6361167
8718171
fd37cb4
00fcfb0
913f832
2022-03-30 14:24:32 +01:00
Linus Groh
68ee193464
LibJS: Check type of ShadowRealm.prototype.importValue() 2nd argument
...
This is a normative change in the ShadowRealm spec.
See: 2b45a15
2022-03-29 23:48:25 +01:00
Linus Groh
f1d744e11a
LibJS: Fix sign in PlainYearMonth.prototype.subtract()
...
This is a normative change in the Temporal spec.
See: 6cf421b
2022-03-29 23:21:17 +01:00
Linus Groh
e4fe60b972
LibJS: Update incorrect spec comment in ToRelativeTemporalObject
...
This is a normative change in the Temporal spec.
See: 4cb192d
2022-03-29 22:56:03 +01:00