Bug 784300 - Make self-hosted non-constructor functions not have a prototype. r=tschneidereit

This commit is contained in:
Norbert Lindenberg 2012-09-13 11:33:00 +02:00
Родитель 4dfed85b87
Коммит 4c10fe56ce
2 изменённых файлов: 7 добавлений и 6 удалений

Просмотреть файл

@ -287,18 +287,18 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
if (JSID_IS_ATOM(id, cx->runtime->atomState.classPrototypeAtom)) {
/*
* Native or "built-in" functions do not have a .prototype property per
* ECMA-262, or (Object.prototype, Function.prototype, etc.) have that
* property created eagerly.
* Built-in functions do not have a .prototype property per ECMA-262,
* or (Object.prototype, Function.prototype, etc.) have that property
* created eagerly.
*
* ES5 15.3.4: the non-native function object named Function.prototype
* does not have a .prototype property.
*
* ES5 15.3.4.5: bound functions don't have a prototype property. The
* isNative() test covers this case because bound functions are native
* functions by definition/construction.
* isBuiltin() test covers this case because bound functions are native
* (and thus built-in) functions by definition/construction.
*/
if (fun->isNative() || fun->isFunctionPrototype())
if (fun->isBuiltin() || fun->isFunctionPrototype())
return true;
if (!ResolveInterpretedFunctionPrototype(cx, fun))

Просмотреть файл

@ -81,6 +81,7 @@ struct JSFunction : public JSObject
bool isInterpreted() const { return flags & JSFUN_INTERPRETED; }
bool isNative() const { return !isInterpreted(); }
bool isSelfHostedBuiltin() const { return flags & JSFUN_SELF_HOSTED; }
bool isBuiltin() const { return isNative() || isSelfHostedBuiltin(); }
bool isSelfHostedConstructor() const { return flags & JSFUN_SELF_HOSTED_CTOR; }
bool isNativeConstructor() const { return flags & JSFUN_CONSTRUCTOR; }
bool isHeavyweight() const { return JSFUN_HEAVYWEIGHT_TEST(flags); }