From 6d8dbba4624c8a453ba13ff009f011f2946422bb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 30 Jun 2018 19:19:18 +0200 Subject: Add support for super calls Implement super call support for class constructor functions. Change-Id: I3c64276234689cf4f644b095e0fc8ca1c634ac53 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4stackframe_p.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/qml/jsruntime/qv4stackframe_p.h') diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h index 68301eb097..4966a5637d 100644 --- a/src/qml/jsruntime/qv4stackframe_p.h +++ b/src/qml/jsruntime/qv4stackframe_p.h @@ -129,6 +129,9 @@ struct Q_QML_EXPORT CppStackFrame { } #ifndef V4_BOOTSTRAP + static uint requiredJSStackFrameSize(uint nRegisters) { + return CallData::HeaderSize() + nRegisters; + } static uint requiredJSStackFrameSize(Function *v4Function) { return CallData::HeaderSize() + v4Function->compiledFunction->nRegisters; } @@ -136,7 +139,12 @@ struct Q_QML_EXPORT CppStackFrame { return requiredJSStackFrameSize(v4Function); } void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope, - const Value &thisObject, const Value &newTarget = Primitive::undefinedValue()) + const Value &thisObject, const Value &newTarget = Primitive::undefinedValue()) { + setupJSFrame(stackSpace, function, scope, thisObject, newTarget, + v4Function->nFormals, v4Function->compiledFunction->nRegisters); + } + void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope, + const Value &thisObject, const Value &newTarget, uint nFormals, uint nRegisters) { jsFrame = reinterpret_cast(stackSpace); jsFrame->function = function; @@ -146,12 +154,12 @@ struct Q_QML_EXPORT CppStackFrame { jsFrame->newTarget = newTarget; uint argc = uint(originalArgumentsCount); - if (argc > v4Function->nFormals) - argc = v4Function->nFormals; + if (argc > nFormals) + argc = nFormals; jsFrame->setArgc(argc); memcpy(jsFrame->args, originalArguments, argc*sizeof(Value)); - const Value *end = jsFrame->args + v4Function->compiledFunction->nRegisters; + const Value *end = jsFrame->args + nRegisters; for (Value *v = jsFrame->args + argc; v < end; ++v) *v = Encode::undefined(); } -- cgit v1.2.3