diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-22 12:32:13 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-26 10:04:18 +0000 |
commit | eae4756f74d70de46d9345ece54345f597bc1929 (patch) | |
tree | 3bd9de778a4a035a79595ed160c7b474a03695ec /src/qml/jsruntime/qv4functionobject_p.h | |
parent | e9b3bdb96e008060a0e78815a3995015e5e4598d (diff) |
Add a MemberFunction function object
Member functions in ES7 can not be called as constructors and
will throw a type error when trying.
Some more fixes are needed here, as they also do not have a
prototype property.
Change-Id: Ieb920163acaa68d4ff0ff73ae4c1015e883b406f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 7a7c86a6c3..3245137ac9 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -124,6 +124,10 @@ struct ConstructorFunction : ScriptFunction { }; +struct MemberFunction : ScriptFunction +{ +}; + struct DefaultClassConstructorFunction : FunctionObject { }; @@ -161,6 +165,8 @@ struct Q_QML_EXPORT FunctionObject: Object { void init(String *name, bool createProto); + void createDefaultPrototypeProperty(); + inline ReturnedValue callAsConstructor(const JSCallData &data) const; ReturnedValue callAsConstructor(const Value *argv, int argc) const { return d()->jsConstruct(this, argv, argc); @@ -174,6 +180,7 @@ struct Q_QML_EXPORT FunctionObject: Object { static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function); static Heap::FunctionObject *createConstructorFunction(ExecutionContext *scope, Function *function); + static Heap::FunctionObject *createMemberFunction(ExecutionContext *scope, Function *function); static Heap::FunctionObject *createBuiltinFunction(ExecutionEngine *engine, StringOrSymbol *nameOrSymbol, jsCallFunction code, int argumentCount); bool strictMode() const { return d()->function ? d()->function->isStrict() : false; } @@ -247,6 +254,13 @@ struct ConstructorFunction : ScriptFunction { static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); }; +struct MemberFunction : ScriptFunction { + V4_OBJECT2(MemberFunction, ScriptFunction) + V4_INTERNALCLASS(MemberFunction) + static ReturnedValue callAsConstructor(const FunctionObject *, const Value *argv, int argc); +}; + + struct DefaultClassConstructorFunction : FunctionObject { V4_OBJECT2(DefaultClassConstructorFunction, FunctionObject) static ReturnedValue callAsConstructor(const FunctionObject *, const Value *argv, int argc); |