From d3a1a9e4fea5f6b623ebd13f43957ebbe5bfabea Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 4 Jul 2017 22:23:17 +0200 Subject: Unify SimpleCallContext and CallContext Plan is to completely remove the need for the simple call context. Change-Id: Ie5e4673a6746dc110adbf526e45188f218fd7bfc Reviewed-by: Erik Verbruggen --- src/qml/jsruntime/qv4context.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/qml/jsruntime/qv4context.cpp') diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index dd05539864..5f552b5515 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -54,7 +54,6 @@ using namespace QV4; DEFINE_MANAGED_VTABLE(ExecutionContext); -DEFINE_MANAGED_VTABLE(SimpleCallContext); DEFINE_MANAGED_VTABLE(CallContext); DEFINE_MANAGED_VTABLE(CatchContext); @@ -127,15 +126,14 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) while (ctx) { switch (ctx->d()->type) { case Heap::ExecutionContext::Type_CallContext: - case Heap::ExecutionContext::Type_SimpleCallContext: { - Heap::SimpleCallContext *c = static_cast(ctx->d()); + case Heap::ExecutionContext::Type_SimpleCallContext: if (!activation) { + Heap::CallContext *c = static_cast(ctx->d()); if (!c->activation) c->activation.set(scope.engine, scope.engine->newObject()); activation = c->activation; } break; - } case Heap::ExecutionContext::Type_QmlContext: { // this is ugly, as it overrides the inner callcontext, but has to stay as long // as bindings still get their own callcontext @@ -143,8 +141,9 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) break; } case Heap::ExecutionContext::Type_GlobalContext: { + Q_ASSERT(scope.engine->globalObject->d() == ctx->d()->activation); if (!activation) - activation = scope.engine->globalObject; + activation = ctx->d()->activation; break; } default: @@ -176,22 +175,22 @@ void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionV this->exceptionValue.set(internalClass->engine, exceptionValue); } -Identifier * const *SimpleCallContext::formals() const +Identifier * const *CallContext::formals() const { return d()->v4Function ? d()->v4Function->internalClass->nameMap.constData() : 0; } -unsigned int SimpleCallContext::formalCount() const +unsigned int CallContext::formalCount() const { return d()->v4Function ? d()->v4Function->nFormals : 0; } -Identifier * const *SimpleCallContext::variables() const +Identifier * const *CallContext::variables() const { return d()->v4Function ? d()->v4Function->internalClass->nameMap.constData() + d()->v4Function->nFormals : 0; } -unsigned int SimpleCallContext::variableCount() const +unsigned int CallContext::variableCount() const { return d()->v4Function ? d()->v4Function->compiledFunction->nLocals : 0; } @@ -263,7 +262,7 @@ void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Functio ExecutionContextSaver ctxSaver(scope); - SimpleCallContext::Data *ctx = scope.engine->memoryManager->allocSimpleCallContext(); + CallContext::Data *ctx = scope.engine->memoryManager->allocSimpleCallContext(); ctx->strictMode = function->isStrict(); ctx->callData = callData; @@ -316,7 +315,7 @@ void ExecutionContext::setProperty(String *name, const Value &value) } case Heap::ExecutionContext::Type_CallContext: case Heap::ExecutionContext::Type_SimpleCallContext: { - Heap::SimpleCallContext *c = static_cast(ctx->d()); + Heap::CallContext *c = static_cast(ctx->d()); if (c->v4Function) { uint index = c->v4Function->internalClass->find(id); if (index < UINT_MAX) { @@ -483,7 +482,7 @@ Function *ExecutionContext::getFunction() const Scope scope(engine()); ScopedContext it(scope, this->d()); for (; it; it = it->d()->outer) { - if (const SimpleCallContext *callCtx = it->asSimpleCallContext()) + if (const CallContext *callCtx = it->asCallContext()) return callCtx->d()->v4Function; else if (it->d()->type == Heap::ExecutionContext::Type_CatchContext || it->d()->type == Heap::ExecutionContext::Type_WithContext) -- cgit v1.2.3