mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1398768 part 12 - Remove/inline CanonicalizeArrayLengthValue. r=anba
--HG-- extra : rebase_source : 05168647a7f049c91cdaa26daeeb137610d2ee31
This commit is contained in:
parent
c54af726e3
commit
f539dbedf1
@ -685,24 +685,6 @@ MaybeInIteration(HandleObject obj, JSContext* cx)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
js::CanonicalizeArrayLengthValue(JSContext* cx, HandleValue v, uint32_t* newLen)
|
||||
{
|
||||
double d;
|
||||
|
||||
if (!ToUint32(cx, v, newLen))
|
||||
return false;
|
||||
|
||||
if (!ToNumber(cx, v, &d))
|
||||
return false;
|
||||
|
||||
if (d == *newLen)
|
||||
return true;
|
||||
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ES6 draft rev 34 (2015 Feb 20) 9.4.2.4 ArraySetLength */
|
||||
bool
|
||||
js::ArraySetLength(JSContext* cx, Handle<ArrayObject*> arr, HandleId id,
|
||||
@ -726,11 +708,22 @@ js::ArraySetLength(JSContext* cx, Handle<ArrayObject*> arr, HandleId id,
|
||||
} else {
|
||||
// Step 2 is irrelevant in our implementation.
|
||||
|
||||
// Steps 3-7.
|
||||
if (!CanonicalizeArrayLengthValue(cx, value, &newLen))
|
||||
// Step 3.
|
||||
if (!ToUint32(cx, value, &newLen))
|
||||
return false;
|
||||
|
||||
// Step 8 is irrelevant in our implementation.
|
||||
// Step 4.
|
||||
double d;
|
||||
if (!ToNumber(cx, value, &d))
|
||||
return false;
|
||||
|
||||
// Step 5.
|
||||
if (d != newLen) {
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Steps 6-8 are irrelevant in our implementation.
|
||||
}
|
||||
|
||||
// Steps 9-11.
|
||||
|
@ -121,13 +121,6 @@ NewValuePair(JSContext* cx, const Value& val1, const Value& val2, MutableHandleV
|
||||
extern bool
|
||||
WouldDefinePastNonwritableLength(HandleNativeObject obj, uint32_t index);
|
||||
|
||||
/*
|
||||
* Canonicalize |vp| to a uint32_t value potentially suitable for use as an
|
||||
* array length.
|
||||
*/
|
||||
extern bool
|
||||
CanonicalizeArrayLengthValue(JSContext* cx, HandleValue v, uint32_t* canonicalized);
|
||||
|
||||
extern bool
|
||||
GetLengthProperty(JSContext* cx, HandleObject obj, uint32_t* lengthp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user