diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-30 19:19:18 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-07-03 08:09:05 +0000 |
commit | 6d8dbba4624c8a453ba13ff009f011f2946422bb (patch) | |
tree | ec1aec45c122a31d7e5c1c19daa9ba5d4f824355 /src/qml/jsruntime/qv4runtime.cpp | |
parent | deaa99f66ddedc2ea79e6902c665925b04665e68 (diff) |
Add support for super calls
Implement super call support for class constructor
functions.
Change-Id: I3c64276234689cf4f644b095e0fc8ca1c634ac53
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 0fd3787730..eeb66509e3 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1306,7 +1306,6 @@ ReturnedValue Runtime::method_construct(ExecutionEngine *engine, const Value &fu { if (!function.isFunctionObject()) return engine->throwTypeError(); - Q_ASSERT(function.sameValue(newTarget)); return static_cast<const FunctionObject &>(function).callAsConstructor(argv, argc, &newTarget); } @@ -1316,7 +1315,6 @@ ReturnedValue Runtime::method_constructWithSpread(ExecutionEngine *engine, const Q_UNIMPLEMENTED(); if (!function.isFunctionObject()) return engine->throwTypeError(); - Q_ASSERT(function.sameValue(newTarget)); Scope scope(engine); CallArgs arguments = createSpreadArguments(scope, argv, argc); @@ -1508,13 +1506,8 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde ExecutionContext *current = static_cast<ExecutionContext *>(&engine->currentStackFrame->jsFrame->context); ScopedFunctionObject constructor(scope); - if (cls->constructorFunction != UINT_MAX) { - QV4::Function *f = unit->runtimeFunctions[cls->constructorFunction]; - Q_ASSERT(f); - constructor = FunctionObject::createConstructorFunction(current, f)->asReturnedValue(); - } else { - constructor = engine->memoryManager->allocate<DefaultClassConstructorFunction>(); - } + QV4::Function *f = cls->constructorFunction != UINT_MAX ? unit->runtimeFunctions[cls->constructorFunction] : nullptr; + constructor = FunctionObject::createConstructorFunction(current, f, !superClass.isEmpty())->asReturnedValue(); constructor->setPrototypeUnchecked(constructorParent); constructor->defineDefaultProperty(engine->id_prototype(), proto); proto->defineDefaultProperty(engine->id_constructor(), constructor); |