Don't wrap StopIteration singleton, just translate it to the current global's StopIteration object and freeze StopIteration at birth (606573, r=mrbkap).
This commit is contained in:
@@ -624,6 +624,16 @@ GetIterator(JSContext *cx, JSObject *obj, uintN flags, Value *vp)
|
||||
bool keysOnly = (flags == JSITER_ENUMERATE);
|
||||
|
||||
if (obj) {
|
||||
/* Enumerate Iterator.prototype directly. */
|
||||
JSIteratorOp op = obj->getClass()->ext.iteratorObject;
|
||||
if (op && (obj->getClass() != &js_IteratorClass || obj->getNativeIterator())) {
|
||||
JSObject *iterobj = op(cx, obj, !(flags & JSITER_FOREACH));
|
||||
if (!iterobj)
|
||||
return false;
|
||||
vp->setObject(*iterobj);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (keysOnly) {
|
||||
/*
|
||||
* Check to see if this is the same as the most recent object which
|
||||
@@ -813,8 +823,7 @@ js_ValueToIterator(JSContext *cx, uintN flags, Value *vp)
|
||||
if ((flags & JSITER_ENUMERATE)) {
|
||||
if (!js_ValueToObjectOrNull(cx, *vp, &obj))
|
||||
return false;
|
||||
if (!obj)
|
||||
return GetIterator(cx, NULL, flags, vp);
|
||||
/* fall through */
|
||||
} else {
|
||||
obj = js_ValueToNonNullObject(cx, *vp);
|
||||
if (!obj)
|
||||
@@ -822,18 +831,6 @@ js_ValueToIterator(JSContext *cx, uintN flags, Value *vp)
|
||||
}
|
||||
}
|
||||
|
||||
AutoObjectRooter tvr(cx, obj);
|
||||
|
||||
/* Enumerate Iterator.prototype directly. */
|
||||
JSIteratorOp op = obj->getClass()->ext.iteratorObject;
|
||||
if (op && (obj->getClass() != &js_IteratorClass || obj->getNativeIterator())) {
|
||||
JSObject *iterobj = op(cx, obj, !(flags & JSITER_FOREACH));
|
||||
if (!iterobj)
|
||||
return false;
|
||||
vp->setObject(*iterobj);
|
||||
return true;
|
||||
}
|
||||
|
||||
return GetIterator(cx, obj, flags, vp);
|
||||
}
|
||||
|
||||
@@ -1084,7 +1081,9 @@ stopiter_hasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
|
||||
|
||||
Class js_StopIterationClass = {
|
||||
js_StopIteration_str,
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_StopIteration),
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_StopIteration) |
|
||||
JSCLASS_FREEZE_PROTO |
|
||||
JSCLASS_FREEZE_CTOR,
|
||||
PropertyStub, /* addProperty */
|
||||
PropertyStub, /* delProperty */
|
||||
PropertyStub, /* getProperty */
|
||||
|
||||
Reference in New Issue
Block a user