Bug 668024 - Make Array.prototype.splice better conform to ES5, with a clearer stepwise algorithm. Patch also includes modifications from jwalden. r=jwalden, r=bhackett

This commit is contained in:
Paul Biggar
2011-09-23 12:13:11 -07:00
parent 62bf7d0e84
commit cc5a4d7653
15 changed files with 808 additions and 133 deletions

View File

@@ -938,18 +938,31 @@ js_SuppressDeletedElement(JSContext *cx, JSObject *obj, uint32 index)
}
class IndexRangePredicate {
jsint begin, end;
public:
IndexRangePredicate(jsint begin, jsint end) : begin(begin), end(end) {}
uint32 begin, end;
public:
IndexRangePredicate(uint32 begin, uint32 end) : begin(begin), end(end) {}
bool operator()(jsid id) {
return JSID_IS_INT(id) && begin <= JSID_TO_INT(id) && JSID_TO_INT(id) < end;
if (JSID_IS_INT(id)) {
jsint i = JSID_TO_INT(id);
return i > 0 && begin <= uint32(i) && uint32(i) < end;
}
if (JS_LIKELY(JSID_IS_ATOM(id))) {
JSAtom *atom = JSID_TO_ATOM(id);
uint32 index;
return atom->isIndex(&index) && begin <= index && index < end;
}
return false;
}
bool matchesAtMostOne() { return false; }
};
bool
js_SuppressDeletedIndexProperties(JSContext *cx, JSObject *obj, jsint begin, jsint end)
js_SuppressDeletedElements(JSContext *cx, JSObject *obj, uint32 begin, uint32 end)
{
return SuppressDeletedPropertyHelper(cx, obj, IndexRangePredicate(begin, end));
}