mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-30 11:18:39 +09:00
Issue #1240 - Part 6b - Use ToIndex when constructing TypedArray with length argument. https://bugzilla.mozilla.org/show_bug.cgi?id=1317383 Part 2.
This commit is contained in:
parent
e8f0ea219f
commit
e004b99054
5 changed files with 51 additions and 43 deletions
|
|
@ -1768,6 +1768,35 @@ js::ToIntegerIndex(JSContext* cx, JS::HandleValue v, uint64_t* index)
|
|||
return true;
|
||||
}
|
||||
|
||||
// ES2017 draft 7.1.17 ToIndex
|
||||
bool
|
||||
js::ToIndex(JSContext* cx, JS::HandleValue v, uint64_t* index)
|
||||
{
|
||||
// Step 1.
|
||||
if (v.isUndefined()) {
|
||||
*index = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Step 2.a.
|
||||
double integerIndex;
|
||||
if (!ToInteger(cx, v, &integerIndex))
|
||||
return false;
|
||||
|
||||
// Inlined version of ToLength.
|
||||
// 1. Already an integer.
|
||||
// 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);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Step 3.
|
||||
*index = uint64_t(integerIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
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