Linus Groh
d8e835d22f
LibJS: Implement Temporal.PlainYearMonth.prototype[@@toStringTag]
2021-08-08 17:45:06 +01:00
Linus Groh
4d3af45efb
LibJS: Handle PlainYearMonth in the Calendar.prototype getters
2021-08-08 17:45:06 +01:00
Linus Groh
e2f016dc81
LibJS: Handle PlainYearMonth in ISO{Year,Month,MonthCode,Day}
2021-08-08 17:45:06 +01:00
Linus Groh
4ba5df7145
LibJS: Handle PlainYearMonth in GetTemporalCalendarWithISODefault
2021-08-08 17:45:06 +01:00
Linus Groh
2aec6653c4
LibJS: Handle PlainYearMonth in ToTemporalCalendar
2021-08-08 17:45:06 +01:00
Linus Groh
0a8edd5ce7
LibJS: Start implementing Temporal.PlainYearMonth
...
This commit adds the PlainYearMonth object itself, its constructor and
prototype (currently empty), and the CreateTemporalYearMonth and
ISOYearMonthWithinLimits abstract operations.
2021-08-08 17:45:06 +01:00
Linus Groh
5b12542d39
LibJS: Fix Vector<Value> => MarkedValueList in calendar_fields()
...
We need to ensure the temporary PrimitiveString cells don't get GC'd.
2021-08-08 17:45:06 +01:00
Linus Groh
53c44bea00
LibJS: Mark getters of more Temporal objects [[nodiscard]]
...
PlainDate, PlainTime, and PlainDateTime already do this. All the others
should as well.
2021-08-08 17:45:06 +01:00
Linus Groh
16c38788c3
LibJS: Add missing spec links
2021-08-08 11:04:30 +01:00
Daniel Bertalan
0e21bf0f23
LibJS: Don't overflow size_t in Value::to_length()
...
Although this is not spec-compliant, we don't have a way to represent
objects larger than `NumericLimits<size_t>::max()`. Since this abstract
operation is only used when dealing with object size, we don't lose any
functionality by taking that limit into account too.
This fixes a UBSAN error when compiling with Clang.
2021-08-08 10:55:36 +02:00
Daniel Bertalan
12dc2c2079
LibJS: Fix wraparound UB in Value::to_u{8,16}
...
If we call these two functions on a negative value, undefined behavior
occurs due to casting a negative double to an unsigned integer. These
functions are defined to perform modular arithmetic, so negative values
can be fixed up by adding 2^8/2^16.
The reason why this step is not mentioned in ECMA-262 is that it defines
modular arithmetic so that `x mod m` had the same sign as `m`, while
LibM's `fmod(x, m)` copies `x`'s sign.
This issue was found by UBSAN with the Clang toolchain.
2021-08-08 10:55:36 +02:00
Daniel Bertalan
0a05f04d1b
LibJS: Fix UB in Number.IsSafeInteger
...
Casting a floating point number to an integer and comparing that against
the original value is not a good way to test if it is a whole number. It
may cause unnecessary narrowing conversion issues and UB. This was the
case, which was caught be Clang's `-fsanitize=float-cast-overflow`.
This commit changes the code to use `is_integral_number`, as suggested
in ECMA-262.
2021-08-08 10:55:36 +02:00
Daniel Bertalan
fd76e71934
LibJS: Fix UB in Math.clz32
...
If the argument to this function is greater then or equal to 2^32, the
`double` => `u32` cast produces undefined behavior, which Clang catches.
To fix this, we now use `ToUint32` for getting the integer argument, as
specified by ECMA-262.
2021-08-08 10:55:36 +02:00
Linus Groh
6852ba4d34
LibJS: Implement Temporal.Instant.prototype.subtract()
2021-08-07 13:10:35 +01:00
Linus Groh
b38f1fb071
LibJS: Implement Temporal.Instant.prototype.add()
2021-08-07 13:10:35 +01:00
Linus Groh
8ffad70504
LibJS: Add missing spec link to Temporal.Instant.prototype.round()
2021-08-07 13:10:35 +01:00
Linus Groh
6762378f89
LibJS/Tests: Add length test for Temporal.Instant.prototype.round()
2021-08-07 12:10:34 +01:00
Linus Groh
cdb0c879d3
LibJS/Tests: Add length test for Temporal.Instant.prototype.equals()
2021-08-07 12:10:34 +01:00
Linus Groh
a8ba2f4b21
LibJS/Tests: Fix bad copy and paste that crept into a lot of tests
...
The top-level function should have been `describe()``, but instead it's
been nested `test()`s.
2021-08-07 12:10:34 +01:00
sin-ack
ab39a94fdf
LibJS: Cast length to signed integer before subtraction
...
length is size_t as returned, and so subtracting from it may cause
underflow. We handle this case by just casting it to a signed value, and
the for loop predicate takes care of the rest.
2021-08-07 11:32:16 +02:00
Linus Groh
f12152f77e
LibJS: Reflect an editorial change in the Temporal spec
...
See: fb9b550
2021-08-07 01:21:39 +01:00
Linus Groh
5d536c7fbc
LibJS: Reflect infallibility editorial changes in the Temporal spec
...
See: de918c9
2021-08-07 01:15:45 +01:00
davidot
5cd2e0f3a2
LibJS: Improve the TypedArray.prototype.find{,Index} tests
...
Before this we did not check that it actually gave the first result.
2021-08-06 16:17:25 +01:00
davidot
871a29884d
LibJS: Implement proposed TypedArray.prototype.findLast{,Index}
...
Proposal: https://tc39.es/proposal-array-find-from-last/
2021-08-06 16:17:25 +01:00
davidot
b6523906b3
LibJS: Implement proposed Array.prototype.findLast{,Index}
...
Proposal: https://tc39.es/proposal-array-find-from-last/
2021-08-06 16:17:25 +01:00
Linus Groh
b7b23d05d5
LibJS: Implement Temporal.ZonedDateTime.prototype.getISOFields()
2021-08-05 23:15:27 +01:00
Linus Groh
82ab5da4db
LibJS: Implement Temporal.ZonedDateTime.prototype.toPlainDateTime()
2021-08-05 23:15:27 +01:00
Linus Groh
6ce631b023
LibJS: Implement Temporal.ZonedDateTime.prototype.toPlainTime()
2021-08-05 23:15:27 +01:00
Linus Groh
b4ea4e86a7
LibJS: Implement Temporal.ZonedDateTime.prototype.toPlainDate()
2021-08-05 23:15:27 +01:00
Linus Groh
96a0c201d5
LibJS: Implement Temporal.ZonedDateTime.prototype.toInstant()
2021-08-05 23:15:27 +01:00
Linus Groh
20300bd7c4
LibJS: Implement Temporal.ZonedDateTime.prototype.valueOf()
2021-08-05 23:15:27 +01:00
Linus Groh
6c345c8107
LibJS: Implement Temporal.ZonedDateTime.prototype.offset
2021-08-05 19:19:40 +02:00
Linus Groh
f937e9b966
LibJS: Implement Temporal.ZonedDateTime.prototype.offsetNanoseconds
2021-08-05 19:19:40 +02:00
Linus Groh
dd36593c72
LibJS: Implement Temporal.ZonedDateTime.prototype.inLeapYear
2021-08-05 19:19:40 +02:00
Linus Groh
5a7db1b5f4
LibJS: Implement Temporal.ZonedDateTime.prototype.monthsInYear
2021-08-05 19:19:40 +02:00
Linus Groh
204ba01416
LibJS: Implement Temporal.ZonedDateTime.prototype.daysInYear
2021-08-05 19:19:40 +02:00
Linus Groh
6007fc4804
LibJS: Implement Temporal.ZonedDateTime.prototype.daysInMonth
2021-08-05 19:19:40 +02:00
Linus Groh
d89d55a7a3
LibJS: Implement Temporal.ZonedDateTime.prototype.daysInWeek
2021-08-05 19:19:40 +02:00
Linus Groh
540fdbcf5b
LibJS: Implement Temporal.ZonedDateTime.prototype.weekOfYear
2021-08-05 19:19:40 +02:00
Linus Groh
d20a4fe43e
LibJS: Implement Temporal.ZonedDateTime.prototype.dayOfYear
2021-08-05 19:19:40 +02:00
Linus Groh
39e67a5823
LibJS: Implement Temporal.ZonedDateTime.prototype.dayOfWeek
2021-08-05 19:19:40 +02:00
Linus Groh
f86bbb7a71
LibJS: Implement Temporal.ZonedDateTime.prototype.epochNanoseconds
2021-08-05 19:19:40 +02:00
Linus Groh
62294d62c5
LibJS: Implement Temporal.ZonedDateTime.prototype.epochMicroseconds
2021-08-05 19:19:40 +02:00
Linus Groh
a9162b7e98
LibJS: Implement Temporal.ZonedDateTime.prototype.epochMilliseconds
2021-08-05 19:19:40 +02:00
Linus Groh
47135af987
LibJS: Implement Temporal.ZonedDateTime.prototype.epochSeconds
2021-08-05 19:19:40 +02:00
Linus Groh
a1082412ef
LibJS: Implement Temporal.ZonedDateTime.prototype.nanosecond
2021-08-05 19:19:40 +02:00
Linus Groh
4b22d0f2ce
LibJS: Implement Temporal.ZonedDateTime.prototype.microsecond
2021-08-05 19:19:40 +02:00
Linus Groh
752b3eb0c0
LibJS: Implement Temporal.ZonedDateTime.prototype.millisecond
2021-08-05 19:19:40 +02:00
Linus Groh
9d9ab492df
LibJS: Implement Temporal.ZonedDateTime.prototype.second
2021-08-05 19:19:40 +02:00
Linus Groh
a6775517ad
LibJS: Implement Temporal.ZonedDateTime.prototype.minute
2021-08-05 19:19:40 +02:00