зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1098412 - Remove the legacy Iterator constructor. r=luke
MozReview-Commit-ID: 4GmodzFsZsY --HG-- extra : rebase_source : e0043be00b457633be633836c0a9a8d27d2e9fc0
This commit is contained in:
Родитель
4c482a9f46
Коммит
b8a9cbf335
|
@ -341,13 +341,9 @@ CallJSNativeConstructor(JSContext* cx, Native native, const CallArgs& args)
|
|||
* - CallOrConstructBoundFunction is an exception as well because we might
|
||||
* have used bind on a proxy function.
|
||||
*
|
||||
* - new Iterator(x) is user-hookable; it returns x.__iterator__() which
|
||||
* could be any object.
|
||||
*
|
||||
* - (new Object(Object)) returns the callee.
|
||||
*/
|
||||
MOZ_ASSERT_IF(native != js::proxy_Construct &&
|
||||
native != js::IteratorConstructor &&
|
||||
(!callee->is<JSFunction>() || callee->as<JSFunction>().native() != obj_construct),
|
||||
args.rval().isObject() && callee != &args.rval().toObject());
|
||||
|
||||
|
|
|
@ -1022,27 +1022,6 @@ js::ThrowStopIteration(JSContext* cx)
|
|||
|
||||
/*** Iterator objects ****************************************************************************/
|
||||
|
||||
bool
|
||||
js::IteratorConstructor(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() == 0) {
|
||||
ReportMissingArg(cx, args.calleev(), 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool keyonly = false;
|
||||
if (args.length() >= 2)
|
||||
keyonly = ToBoolean(args[1]);
|
||||
unsigned flags = JSITER_OWNONLY | (keyonly ? 0 : (JSITER_FOREACH | JSITER_KEYVALUE));
|
||||
|
||||
RootedObject iterobj(cx, ValueToIterator(cx, flags, args[0]));
|
||||
if (!iterobj)
|
||||
return false;
|
||||
args.rval().setObject(*iterobj);
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
NativeIteratorNext(JSContext* cx, NativeIterator* ni, MutableHandleValue rval, bool* done)
|
||||
{
|
||||
|
@ -1111,12 +1090,6 @@ legacy_iterator_next(JSContext* cx, unsigned argc, Value* vp)
|
|||
return CallNonGenericMethod<IsLegacyIterator, legacy_iterator_next_impl>(cx, args);
|
||||
}
|
||||
|
||||
static const JSFunctionSpec legacy_iterator_methods[] = {
|
||||
JS_SELF_HOSTED_SYM_FN(iterator, "LegacyIteratorShim", 0, 0),
|
||||
JS_FN("next", legacy_iterator_next, 0, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
size_t
|
||||
PropertyIteratorObject::sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const
|
||||
{
|
||||
|
@ -1153,7 +1126,6 @@ const ClassOps PropertyIteratorObject::classOps_ = {
|
|||
|
||||
const Class PropertyIteratorObject::class_ = {
|
||||
"Iterator",
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Iterator) |
|
||||
JSCLASS_HAS_PRIVATE |
|
||||
JSCLASS_BACKGROUND_FINALIZE,
|
||||
&PropertyIteratorObject::classOps_
|
||||
|
@ -1633,44 +1605,6 @@ GlobalObject::initStringIteratorProto(JSContext* cx, Handle<GlobalObject*> globa
|
|||
return true;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
js::InitLegacyIteratorClass(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
Handle<GlobalObject*> global = obj.as<GlobalObject>();
|
||||
|
||||
if (global->getPrototype(JSProto_Iterator).isObject())
|
||||
return &global->getPrototype(JSProto_Iterator).toObject();
|
||||
|
||||
RootedObject iteratorProto(cx);
|
||||
iteratorProto = GlobalObject::createBlankPrototype(cx, global,
|
||||
&PropertyIteratorObject::class_);
|
||||
if (!iteratorProto)
|
||||
return nullptr;
|
||||
|
||||
NativeIterator* ni = NativeIterator::allocateIterator(cx, 0, 0);
|
||||
if (!ni)
|
||||
return nullptr;
|
||||
|
||||
iteratorProto->as<PropertyIteratorObject>().setNativeIterator(ni);
|
||||
ni->init(nullptr, nullptr, 0 /* flags */, 0, 0);
|
||||
|
||||
Rooted<JSFunction*> ctor(cx);
|
||||
ctor = GlobalObject::createConstructor(cx, IteratorConstructor, cx->names().Iterator, 2);
|
||||
if (!ctor)
|
||||
return nullptr;
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, iteratorProto))
|
||||
return nullptr;
|
||||
if (!DefinePropertiesAndFunctions(cx, iteratorProto, nullptr, legacy_iterator_methods))
|
||||
return nullptr;
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_Iterator,
|
||||
ctor, iteratorProto))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &global->getPrototype(JSProto_Iterator).toObject();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
js::InitStopIterationClass(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
|
|
|
@ -194,9 +194,6 @@ IteratorCloseForException(JSContext* cx, HandleObject obj);
|
|||
void
|
||||
UnwindIteratorForUncatchableException(JSContext* cx, JSObject* obj);
|
||||
|
||||
bool
|
||||
IteratorConstructor(JSContext* cx, unsigned argc, Value* vp);
|
||||
|
||||
extern bool
|
||||
SuppressDeletedProperty(JSContext* cx, HandleObject obj, jsid id);
|
||||
|
||||
|
@ -220,9 +217,6 @@ ThrowStopIteration(JSContext* cx);
|
|||
extern JSObject*
|
||||
CreateIterResultObject(JSContext* cx, HandleValue value, bool done);
|
||||
|
||||
extern JSObject*
|
||||
InitLegacyIteratorClass(JSContext* cx, HandleObject obj);
|
||||
|
||||
bool
|
||||
IsLegacyIterator(HandleValue v);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
real(CompileError, InitViaClassSpec, ERROR_CLASP(JSEXN_WASMCOMPILEERROR)) \
|
||||
real(LinkError, InitViaClassSpec, ERROR_CLASP(JSEXN_WASMLINKERROR)) \
|
||||
real(RuntimeError, InitViaClassSpec, ERROR_CLASP(JSEXN_WASMRUNTIMEERROR)) \
|
||||
real(Iterator, InitLegacyIteratorClass,OCLASP(PropertyIterator)) \
|
||||
imaginary(Iterator, dummy, dummy) \
|
||||
real(StopIteration, InitStopIterationClass, OCLASP(StopIteration)) \
|
||||
real(ArrayBuffer, InitViaClassSpec, OCLASP(ArrayBuffer)) \
|
||||
real(Int8Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Int8)) \
|
||||
|
|
|
@ -439,10 +439,6 @@ class GlobalObject : public NativeObject
|
|||
|
||||
TypedObjectModuleObject& getTypedObjectModule() const;
|
||||
|
||||
JSObject* getLegacyIteratorPrototype() {
|
||||
return &getPrototype(JSProto_Iterator).toObject();
|
||||
}
|
||||
|
||||
static JSObject*
|
||||
getOrCreateCollatorPrototype(JSContext* cx, Handle<GlobalObject*> global) {
|
||||
return getOrCreateObject(cx, global, COLLATOR_PROTO, initIntlObject);
|
||||
|
|
|
@ -687,9 +687,6 @@ EnsureParserCreatedClasses(JSContext* cx, ParseTaskKind kind)
|
|||
if (!EnsureConstructor(cx, global, JSProto_RegExp))
|
||||
return false; // needed by regular expression literals
|
||||
|
||||
if (!EnsureConstructor(cx, global, JSProto_Iterator))
|
||||
return false; // needed by ???
|
||||
|
||||
if (!GlobalObject::initStarGenerators(cx, global))
|
||||
return false; // needed by function*() {} and generator comprehensions
|
||||
|
||||
|
@ -1797,8 +1794,7 @@ GlobalHelperThreadState::mergeParseTaskCompartment(JSContext* cx, ParseTask* par
|
|||
JSProtoKey key = JS::IdentifyStandardPrototype(protoObj);
|
||||
if (key != JSProto_Null) {
|
||||
MOZ_ASSERT(key == JSProto_Object || key == JSProto_Array ||
|
||||
key == JSProto_Function || key == JSProto_RegExp ||
|
||||
key == JSProto_Iterator);
|
||||
key == JSProto_Function || key == JSProto_RegExp);
|
||||
newProto = GetBuiltinPrototypePure(global, key);
|
||||
} else if (protoObj == parseTaskStarGenFunctionProto) {
|
||||
newProto = global->getStarGeneratorFunctionPrototype();
|
||||
|
|
Загрузка…
Ссылка в новой задаче