mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 21:05:36 +00:00
Bug 1036507
- Introduce and use StandardProtoKeyOrNull. r=luke
This commit is contained in:
parent
8b8c93b583
commit
f0ba9615ce
@ -3424,7 +3424,7 @@ JS::IdentifyStandardInstance(JSObject *obj)
|
||||
{
|
||||
// Note: The prototype shares its JSClass with instances.
|
||||
JS_ASSERT(!obj->is<CrossCompartmentWrapperObject>());
|
||||
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(obj->getClass());
|
||||
JSProtoKey key = StandardProtoKeyOrNull(obj);
|
||||
if (key != JSProto_Null && !IsStandardPrototype(obj, key))
|
||||
return key;
|
||||
return JSProto_Null;
|
||||
@ -3435,7 +3435,7 @@ JS::IdentifyStandardPrototype(JSObject *obj)
|
||||
{
|
||||
// Note: The prototype shares its JSClass with instances.
|
||||
JS_ASSERT(!obj->is<CrossCompartmentWrapperObject>());
|
||||
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(obj->getClass());
|
||||
JSProtoKey key = StandardProtoKeyOrNull(obj);
|
||||
if (key != JSProto_Null && IsStandardPrototype(obj, key))
|
||||
return key;
|
||||
return JSProto_Null;
|
||||
@ -3444,7 +3444,7 @@ JS::IdentifyStandardPrototype(JSObject *obj)
|
||||
JSProtoKey
|
||||
JS::IdentifyStandardInstanceOrPrototype(JSObject *obj)
|
||||
{
|
||||
return JSCLASS_CACHED_PROTO_KEY(obj->getClass());
|
||||
return StandardProtoKeyOrNull(obj);
|
||||
}
|
||||
|
||||
JSProtoKey
|
||||
|
@ -807,6 +807,15 @@ GenericCreatePrototype(JSContext *cx, JSProtoKey key)
|
||||
return cx->global()->createBlankPrototypeInheriting(cx, clasp, *parentProto);
|
||||
}
|
||||
|
||||
inline JSProtoKey
|
||||
StandardProtoKeyOrNull(const JSObject *obj)
|
||||
{
|
||||
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(obj->getClass());
|
||||
if (key == JSProto_Error)
|
||||
return GetExceptionProtoKey(obj->as<ErrorObject>().type());
|
||||
return key;
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
||||
template<>
|
||||
|
Loading…
Reference in New Issue
Block a user