mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-22 12:23:08 +09:00
Issue #2838 - Use ToIndex in TypedArray CTORs
Also adjusts index handling to be more accurate/spec compliant.
This commit is contained in:
parent
2026586ce1
commit
c07ea665ea
5 changed files with 33 additions and 24 deletions
|
|
@ -1725,8 +1725,9 @@ js::ToLengthClamped<JSContext>(JSContext*, HandleValue, uint32_t*, bool*);
|
|||
template bool
|
||||
js::ToLengthClamped<ExclusiveContext>(ExclusiveContext*, HandleValue, uint32_t*, bool*);
|
||||
|
||||
//Non-standard: Used by Atomics.
|
||||
bool
|
||||
js::ToIntegerIndex(JSContext* cx, JS::HandleValue v, uint64_t* index)
|
||||
js::NonStandardToIndex(JSContext* cx, HandleValue v, uint64_t* index)
|
||||
{
|
||||
// Fast common case.
|
||||
if (v.isInt32()) {
|
||||
|
|
@ -1776,7 +1777,7 @@ js::ToIntegerIndex(JSContext* cx, JS::HandleValue v, uint64_t* index)
|
|||
|
||||
// ES2017 draft 7.1.17 ToIndex
|
||||
bool
|
||||
js::ToIndex(JSContext* cx, JS::HandleValue v, uint64_t* index)
|
||||
js::ToIndex(JSContext* cx, JS::HandleValue v, const unsigned errorNumber, uint64_t* index)
|
||||
{
|
||||
// Step 1.
|
||||
if (v.isUndefined()) {
|
||||
|
|
@ -1794,7 +1795,7 @@ js::ToIndex(JSContext* cx, JS::HandleValue v, uint64_t* index)
|
|||
// 2. Step eliminates < 0, +0 == -0 with SameValueZero.
|
||||
// 3/4. Limit to <= 2^53-1, so everything above should fail.
|
||||
if (integerIndex < 0 || integerIndex >= DOUBLE_INTEGRAL_PRECISION_LIMIT) {
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_INDEX);
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, errorNumber);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1803,6 +1804,12 @@ js::ToIndex(JSContext* cx, JS::HandleValue v, uint64_t* index)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::ToIndex(JSContext* cx, JS::HandleValue v, uint64_t* index)
|
||||
{
|
||||
return ToIndex(cx, v, JSMSG_BAD_INDEX, index);
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool
|
||||
js_strtod(ExclusiveContext* cx, const CharT* begin, const CharT* end, const CharT** dEnd,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue