Idan Horowitz
6c0d5163a1
LibJS: Add most of the Map.prototype methods
...
Specifically all aside from "keys", "values" and "entries" which
require an implementation of the MapIterator object.
2021-06-13 00:33:18 +01:00
Idan Horowitz
a96ac8bd56
LibJS: Add the Map built-in object
2021-06-13 00:33:18 +01:00
Idan Horowitz
3c83298a26
LibJS: Use undefined as the fallback value for iterable entry key/value
...
As defined in OdinaryGet in the specification.
2021-06-12 22:34:28 +01:00
Idan Horowitz
bd9e20ef79
LibJS: Add the Object.getOwnPropertySymbols method
2021-06-12 18:39:23 +01:00
Idan Horowitz
a2da3f97ef
LibJS: Remove argument count checks in Object.* methods
...
These are inconsistent with the specification.
2021-06-12 18:39:23 +01:00
Idan Horowitz
b9d4dd6850
LibJS: Add the WeakRef.prototype.deref method
...
This is the only exposed method of the WeakRef built-in.
2021-06-12 18:39:23 +01:00
Idan Horowitz
7eba63a8a3
LibJS: Add the WeakRef built-in object
2021-06-12 18:39:23 +01:00
davidot
e044a3e428
LibJS: Add Array.prototype.keys()
2021-06-12 14:40:34 +01:00
Linus Groh
7e1bffdeb8
LibJS: Implement Object.assign()
2021-06-12 11:36:17 +01:00
Idan Horowitz
77c2db4183
LibJS: Add all of the WeakMap.prototype methods (delete, get, has, set)
2021-06-12 10:44:28 +01:00
Linus Groh
862ba64037
LibJS: Implement the Error Cause proposal
...
Currently stage 3. https://github.com/tc39/proposal-error-cause
2021-06-11 21:34:05 +01:00
Linus Groh
8d77a3297a
LibJS: Improve Error/NativeError tests
...
Some of this stuff is already tested properly in the name and message
prototype tests, so let's focus on covering all error types here as well
instead.
2021-06-11 21:34:05 +01:00
Linus Groh
cbd7437d40
LibJS: Implement AggregateError
2021-06-11 18:49:50 +01:00
Luke
bc540de0af
LibJS: Pass in actual_delete_count to removed array creation in splice
...
More specifically, Array.prototype.splice. Additionally adds a missing
exception check to the array creation and a link to the spec.
Fixes create-non-array-invalid-len.js in the splice tests in test262.
This test timed out instead of throwing an "Invalid array length"
exception.
2021-06-10 10:04:06 +01:00
Linus Groh
f932da095e
LibJS: Use create_list_from_array_like() in Reflect.{apply,construct}()
2021-06-09 23:46:37 +01:00
Andreas Kling
4bc98fd39f
LibJS: Only "var" declarations go in the global object at program level
...
"let" and "const" go in the lexical environment.
This fixes one part of #4001 (Lexically declared variables are mixed up
with global object properties)
2021-06-09 23:25:16 +02:00
Idan Horowitz
a00d154522
LibJS: Notify WeakSets when heap cells are sweeped
...
This is an implementation of the following optional optimization:
https://tc39.es/ecma262/#sec-weakref-execution
2021-06-09 21:52:25 +01:00
Idan Horowitz
fb63aeae4d
LibJS: Add all of the WeakSet.prototype methods (add, delete, has)
2021-06-09 21:52:25 +01:00
Idan Horowitz
8b6beac5ce
LibJS: Add the WeakSet built-in object
2021-06-09 21:52:25 +01:00
Idan Horowitz
2a3090d292
LibJS: Add the SetIterator built-in and Set.prototype.{values, entries}
...
While this implementation should be complete it is based on HashTable's
iterator, which currently follows bucket-order instead of the required
insertion order. This can be simply fixed by replacing the underlying
HashTable member in Set with an enhanced one that maintains a linked
list in insertion order.
2021-06-09 11:48:04 +01:00
Idan Horowitz
0b0f1eda05
LibJS: Add most of the Set.prototype methods
...
Specifically all aside from "values" and "entries" which require an
implementation of the SetIterator object.
2021-06-09 11:48:04 +01:00
Idan Horowitz
670be04c81
LibJS: Add the Set built-in object
2021-06-09 11:48:04 +01:00
Linus Groh
83be39c91a
LibJS: Handle Proxy with Array target in IsArray() abstract operation
...
This was missing from Value::is_array(), which is equivalent to the
spec's IsArray() abstract operation - it treats a Proxy value with an
Array target object as being an Array.
It can throw, so needs both the global object and an exception check
now.
2021-06-08 23:53:13 +02:00
Linus Groh
9b35231453
LibJS: Implement Proxy.revocable()
2021-06-08 23:53:13 +02:00
Linus Groh
e39dd65cf0
LibJS: Remove Proxy() argument count check
...
Let's just treat missing arguments as undefined and throw with
'target/handler must be object' - this is more JavaScript-y.
2021-06-08 23:53:13 +02:00
Linus Groh
6c256bb400
LibJS: Add @@toStringTag to Reflect
2021-06-08 19:13:14 +01:00
Linus Groh
b377777208
LibJS: Add @@toStringTag to Promise.prototype
2021-06-08 19:13:14 +01:00
Idan Horowitz
064ed8279e
LibJS: Support deleting local variables with operator delete
...
To make this cleaner i also moved the logic into Reference::delete_.
2021-06-08 15:31:46 +01:00
Linus Groh
4e555fae22
LibJS: Add missing cyclic prototype check to Object.setPrototypeOf()
2021-06-07 22:56:16 +01:00
Idan Horowitz
17afe015a5
LibJS: Add Date.prototype.setTime()
2021-06-06 19:14:11 +01:00
Idan Horowitz
a93b1c7ea0
LibJS: Add Date.prototype.setMonth()
2021-06-06 19:14:11 +01:00
Idan Horowitz
59034554a4
LibJS: Account for differences in month representations (0-11 vs 1-12)
...
Since DateTime stores months as 1 to 12, while JS accepts months as
0 to 11, we have to account for the difference (by subtracting or
adding 1) where appropriate.
2021-06-06 19:14:11 +01:00
Idan Horowitz
b893963651
LibJS: Add Date.prototype.setDate()
2021-06-06 19:14:11 +01:00
Linus Groh
b661363dfe
LibJS: Implement String.prototype[@@toPrimitive]()
2021-06-06 19:34:43 +02:00
Linus Groh
8d7ec28924
LibJS: Remove String.prototype.length
...
A string's length property is supposed to be a regular non-writable,
non-enumerable, non-configurable property on the StringObject instead.
2021-06-06 19:34:43 +02:00
Linus Groh
d255e6892b
LibJS: Update NumberPrototype's this_number_value() to take a Value
...
This is now about as close to the spec as it gets - instead of querying
the |this| value inside of the function, we now pass it in from the
outside.
Also get rid of the oddly specific error messages, they're nice but
pretty inconsistent with most others. Let's prefer consistency and
simplicity for now.
Other than that, no functionality change.
2021-06-06 19:34:43 +02:00
Linus Groh
3cfd9f51f7
LibJS: Replace some is_nullish() checks with require_object_coercible()
2021-06-06 19:34:43 +02:00
Linus Groh
adc3de4480
LibJS: Implement Number.prototype.valueOf()
2021-06-06 06:56:08 +01:00
Idan Horowitz
0bf597e99d
LibJS: Uncomment and add parseInt tests
...
Added another test that checks radices > 16, as well as uncommented
several "FIXME" tests that are now working.
2021-06-06 01:34:22 +01:00
Idan Horowitz
2a8f4f097c
LibJS: Throw TypeError on write to non-writable property in strict mode
2021-06-05 23:54:08 +01:00
Idan Horowitz
442ef63008
LibJS: Add the global escape() & unescape() methods
2021-06-05 18:55:08 +01:00
Ryan Chandler
c66b281856
LibJS: Fix functions binding this to global object in strict mode
...
This fixes an issue where this would be bound to the global object
by default when operating in strict mode.
According to the specification, the expected value for |this| when
no binding is provided is undefined.
2021-06-04 13:00:37 +01:00
Ali Mohammad Pur
09cf1040ef
LibJS/Tests: Catch exceptions in describe() itself
...
Otherwise exceptions thrown in that state would simply terminate the
test.
2021-06-04 16:07:42 +04:30
Idan Horowitz
67a5e9f018
LibJS: Add left shift & right shift operator support for BigIntegers
...
Based on https://tc39.es/ecma262/#sec-numeric-types-bigint-leftShift
(This commit also includes the matching tests)
2021-05-31 19:50:29 +01:00
Ali Mohammad Pur
827d94939b
LibJS: Add tests for destructuring assignments and function parameters
2021-05-29 23:02:23 +04:30
Luke
4d34802f74
LibJS: Expose TypedArray.prototype.byteOffset
2021-05-21 22:52:35 +01:00
Luke
58afd71ad2
LibJS: Expose TypedArray.prototype.byteLength
2021-05-21 22:52:35 +01:00
Luke
8004a2dc77
LibJS: Expose TypedArray.prototype.buffer
2021-05-21 22:52:35 +01:00
Luke
6f1688279a
LibJS: Expose BYTES_PER_ELEMENT on each TypedArray
2021-05-21 22:52:35 +01:00
Andreas Kling
3ee092cd0c
LibJS: Implement Object.hasOwn() :^)
...
This is currently a TC39 Stage 2 proposal, but let's go for it!
https://github.com/tc39/proposal-accessible-object-hasownproperty
I wrote the C++, @linusg found bugs and wrote the test.
2021-05-18 11:18:19 +02:00