diff options
author | Yulong Bai <yulong.bai@qt.io> | 2018-06-15 14:44:19 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-26 10:03:56 +0000 |
commit | 74f4065caa7254b0e30afa955aa59092024decdb (patch) | |
tree | b9b5555807ebfb2e7b6a80a56aec8785b4066ae1 /src/qml/jsruntime/qv4functionobject_p.h | |
parent | c9fa5b8071f4a32afd05cc9fa5cd8ab28e60dc55 (diff) |
Add basic support for EcmaScript classes
Most of the class creation is done inside the runtime
in the CreateClass method. Added a corresponding
instruction to the interpreter and jit.
The compiled data now contains an array of classes
containing the compile time generated layout of the class.
Currently, classes without an explicit constructor and
classes with inheritance are not supported.
Done-with: Yulong Bai <yulong.bai@qt.io>
Change-Id: I0185dcc1e3b0b8f44deff74e44a8262fc646aa9e
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 | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index e8bd574161..1e7df2c27e 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -120,6 +120,10 @@ DECLARE_HEAP_OBJECT(ScriptFunction, FunctionObject) { void init(QV4::ExecutionContext *scope, Function *function); }; +struct ConstructorFunction : ScriptFunction +{ +}; + #define BoundFunctionMembers(class, Member) \ Member(class, Pointer, FunctionObject *, target) \ Member(class, HeapValue, HeapValue, boundThis) \ @@ -165,6 +169,7 @@ struct Q_QML_EXPORT FunctionObject: Object { static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function); + static Heap::FunctionObject *createConstructorFunction(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; } @@ -232,6 +237,11 @@ struct ScriptFunction : FunctionObject { Heap::InternalClass *classForConstructor() const; }; +struct ConstructorFunction : ScriptFunction { + V4_OBJECT2(ConstructorFunction, ScriptFunction) + V4_INTERNALCLASS(ConstructorFunction) + static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; struct BoundFunction: FunctionObject { V4_OBJECT2(BoundFunction, FunctionObject) |