Bug 1166950 - Introduce a new FunctionKind for class-constructors. r=efaust

This commit is contained in:
Tom Schuster 2015-05-25 19:31:46 +02:00
Родитель cf9976434d
Коммит d42ec1b025
2 изменённых файлов: 12 добавлений и 14 удалений

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

@ -2442,7 +2442,7 @@ FunctionObjectToShadowFunction(JSObject* fun)
}
/* Statically asserted in jsfun.h. */
static const unsigned JS_FUNCTION_INTERPRETED_BITS = 0x401;
static const unsigned JS_FUNCTION_INTERPRETED_BITS = 0x0201;
// Return whether the given function object is native.
static MOZ_ALWAYS_INLINE bool

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

@ -32,6 +32,7 @@ class JSFunction : public js::NativeObject
NormalFunction = 0,
Arrow, /* ES6 '(args) => body' syntax */
Method, /* ES6 MethodDefinition */
ClassConstructor,
Getter,
Setter,
AsmJS, /* function is an asm.js module or exported function */
@ -52,18 +53,18 @@ class JSFunction : public js::NativeObject
function-statement) */
SELF_HOSTED = 0x0080, /* function is self-hosted builtin and must not be
decompilable nor constructible. */
// Free bit
HAS_REST = 0x0200, /* function has a rest (...) parameter */
INTERPRETED_LAZY = 0x0400, /* function is interpreted but doesn't have a script yet */
RESOLVED_LENGTH = 0x0800, /* f.length has been resolved (see fun_resolve). */
RESOLVED_NAME = 0x1000, /* f.name has been resolved (see fun_resolve). */
HAS_REST = 0x0100, /* function has a rest (...) parameter */
INTERPRETED_LAZY = 0x0200, /* function is interpreted but doesn't have a script yet */
RESOLVED_LENGTH = 0x0400, /* f.length has been resolved (see fun_resolve). */
RESOLVED_NAME = 0x0800, /* f.name has been resolved (see fun_resolve). */
FUNCTION_KIND_SHIFT = 13,
FUNCTION_KIND_MASK = 0x7 << FUNCTION_KIND_SHIFT,
FUNCTION_KIND_SHIFT = 12,
FUNCTION_KIND_MASK = 0xf << FUNCTION_KIND_SHIFT,
ASMJS_KIND = AsmJS << FUNCTION_KIND_SHIFT,
ARROW_KIND = Arrow << FUNCTION_KIND_SHIFT,
METHOD_KIND = Method << FUNCTION_KIND_SHIFT,
CLASSCONSTRUCTOR_KIND = ClassConstructor << FUNCTION_KIND_SHIFT,
GETTER_KIND = Getter << FUNCTION_KIND_SHIFT,
SETTER_KIND = Setter << FUNCTION_KIND_SHIFT,
@ -73,7 +74,7 @@ class JSFunction : public js::NativeObject
ASMJS_CTOR = ASMJS_KIND | NATIVE_CTOR,
ASMJS_LAMBDA_CTOR = ASMJS_KIND | NATIVE_CTOR | LAMBDA,
INTERPRETED_METHOD = INTERPRETED | METHOD_KIND,
INTERPRETED_CLASS_CONSTRUCTOR = INTERPRETED | METHOD_KIND | CONSTRUCTOR,
INTERPRETED_CLASS_CONSTRUCTOR = INTERPRETED | CLASSCONSTRUCTOR_KIND | CONSTRUCTOR,
INTERPRETED_GETTER = INTERPRETED | GETTER_KIND,
INTERPRETED_SETTER = INTERPRETED | SETTER_KIND,
INTERPRETED_LAMBDA = INTERPRETED | LAMBDA | CONSTRUCTOR,
@ -165,15 +166,12 @@ class JSFunction : public js::NativeObject
// Arrow functions store their lexical |this| in the first extended slot.
bool isArrow() const { return kind() == Arrow; }
// Every class-constructor is also a method.
bool isMethod() const { return kind() == Method; }
bool isMethod() const { return kind() == Method || kind() == ClassConstructor; }
bool isClassConstructor() const { return kind() == ClassConstructor; }
bool isGetter() const { return kind() == Getter; }
bool isSetter() const { return kind() == Setter; }
bool isClassConstructor() const {
return kind() == Method && isConstructor();
}
bool allowSuperProperty() const {
return isMethod() || isGetter() || isSetter();
}