diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 40 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4debugging.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 79 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 17 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 13 | ||||
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlboundsignal.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 2 |
9 files changed, 90 insertions, 79 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index fdfa72cdb0..655df13e27 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -55,7 +55,7 @@ DEFINE_MANAGED_VTABLE(ExecutionContext); CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData *callData) { - Q_ASSERT(function->function); + Q_ASSERT(function->function()); CallContext *c = static_cast<CallContext *>(engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(function, callData->argc))); new (c) CallContext(engine, Type_CallContext); @@ -64,15 +64,15 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData c->realArgumentCount = callData->argc; c->strictMode = function->strictMode(); - c->outer = function->scope; + c->outer = function->scope(); c->activation = 0; - c->compilationUnit = function->function->compilationUnit; + c->compilationUnit = function->function()->compilationUnit; c->lookups = c->compilationUnit->runtimeLookups; c->locals = (Value *)((quintptr(c + 1) + 7) & ~7); - const CompiledData::Function *compiledFunction = function->function->compiledFunction; + const CompiledData::Function *compiledFunction = function->function()->compiledFunction; int nLocals = compiledFunction->nLocals; if (nLocals) std::fill(c->locals, c->locals + nLocals, Primitive::undefinedValue()); @@ -174,12 +174,12 @@ CallContext::CallContext(ExecutionEngine *engine, ObjectRef qml, FunctionObject callData->thisObject = Primitive::undefinedValue(); strictMode = true; - outer = function->scope; + outer = function->scope(); activation = qml.getPointer(); - if (function->function) { - compilationUnit = function->function->compilationUnit; + if (function->function()) { + compilationUnit = function->function()->compilationUnit; lookups = compilationUnit->runtimeLookups; } @@ -190,7 +190,7 @@ CallContext::CallContext(ExecutionEngine *engine, ObjectRef qml, FunctionObject String * const *CallContext::formals() const { - return (function && function->function) ? function->function->internalClass->nameMap.constData() : 0; + return (function && function->function()) ? function->function()->internalClass->nameMap.constData() : 0; } unsigned int CallContext::formalCount() const @@ -200,7 +200,7 @@ unsigned int CallContext::formalCount() const String * const *CallContext::variables() const { - return (function && function->function) ? function->function->internalClass->nameMap.constData() + function->function->compiledFunction->nFormals : 0; + return (function && function->function()) ? function->function()->internalClass->nameMap.constData() + function->function()->compiledFunction->nFormals : 0; } unsigned int CallContext::variableCount() const @@ -228,7 +228,7 @@ bool ExecutionContext::deleteProperty(const StringRef name) CallContext *c = static_cast<CallContext *>(ctx); FunctionObject *f = c->function; if (f->needsActivation() || hasWith) { - uint index = f->function->internalClass->find(name); + uint index = f->function()->internalClass->find(name); if (index < UINT_MAX) // ### throw in strict mode? return false; @@ -301,8 +301,8 @@ void ExecutionContext::setProperty(const StringRef name, const ValueRef value) ScopedObject activation(scope, (Object *)0); if (ctx->type >= Type_CallContext) { CallContext *c = static_cast<CallContext *>(ctx); - if (c->function->function) { - uint index = c->function->function->internalClass->find(name); + if (c->function->function()) { + uint index = c->function->function()->internalClass->find(name); if (index < UINT_MAX) { if (index < c->function->formalParameterCount()) { c->callData->args[c->function->formalParameterCount() - index - 1] = *value; @@ -373,8 +373,8 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name) else if (ctx->type >= Type_CallContext) { QV4::CallContext *c = static_cast<CallContext *>(ctx); ScopedFunctionObject f(scope, c->function); - if (f->function && (f->needsActivation() || hasWith || hasCatchScope)) { - uint index = f->function->internalClass->find(name); + if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) { + uint index = f->function()->internalClass->find(name); if (index < UINT_MAX) { if (index < c->function->formalParameterCount()) return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue(); @@ -387,8 +387,8 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name) if (hasProperty) return v.asReturnedValue(); } - if (f->function && f->function->isNamedExpression() - && name->equals(f->function->name())) + if (f->function() && f->function()->isNamedExpression() + && name->equals(f->function()->name())) return f.asReturnedValue(); } @@ -439,8 +439,8 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR else if (ctx->type >= Type_CallContext) { QV4::CallContext *c = static_cast<CallContext *>(ctx); FunctionObject *f = c->function; - if (f->function && (f->needsActivation() || hasWith || hasCatchScope)) { - uint index = f->function->internalClass->find(name); + if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) { + uint index = f->function()->internalClass->find(name); if (index < UINT_MAX) { if (index < c->function->formalParameterCount()) return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue(); @@ -456,8 +456,8 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR return v.asReturnedValue(); } } - if (f->function && f->function->isNamedExpression() - && name->equals(f->function->name())) + if (f->function() && f->function()->isNamedExpression() + && name->equals(f->function()->name())) return c->function->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp index 06c6dbb4d9..9917426284 100644 --- a/src/qml/jsruntime/qv4debugging.cpp +++ b/src/qml/jsruntime/qv4debugging.cpp @@ -517,7 +517,7 @@ Function *Debugger::getFunction() const { ExecutionContext *context = m_engine->currentContext(); if (CallContext *callCtx = context->asCallContext()) - return callCtx->function->function; + return callCtx->function->function(); else { Q_ASSERT(context->type == QV4::ExecutionContext::Type_GlobalContext); return context->engine->globalCode; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 1af5359985..360262e941 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -697,14 +697,14 @@ QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const CallContext *callCtx = c->asCallContext(); if (callCtx && callCtx->function) { StackFrame frame; - if (callCtx->function->function) - frame.source = callCtx->function->function->sourceFile(); + if (callCtx->function->function()) + frame.source = callCtx->function->function()->sourceFile(); name = callCtx->function->name(); frame.function = name->toQString(); frame.line = -1; frame.column = -1; - if (callCtx->function->function) + if (callCtx->function->function()) // line numbers can be negative for places where you can't set a real breakpoint frame.line = qAbs(callCtx->lineNumber); @@ -784,8 +784,8 @@ QUrl ExecutionEngine::resolvedUrl(const QString &file) while (c) { CallContext *callCtx = c->asCallContext(); if (callCtx && callCtx->function) { - if (callCtx->function->function) - base.setUrl(callCtx->function->function->sourceFile()); + if (callCtx->function->function()) + base.setUrl(callCtx->function->function()->sourceFile()); break; } c = c->parent; diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 1edf6c7d0b..4133bf923f 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -76,17 +76,18 @@ DEFINE_OBJECT_VTABLE(FunctionObject); FunctionObject::FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto) : Object(scope->engine->functionClass) - , scope(scope) - , function(0) { - init(name, createProto); + data.scope = scope; + data.function = 0; + init(name, createProto); } FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto) : Object(scope->engine->functionClass) - , scope(scope) - , function(0) { + data.scope = scope; + data.function = 0; + Scope s(scope); ScopedValue protectThis(s, this); ScopedString n(s, s.engine->newString(name)); @@ -95,9 +96,10 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, boo FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name) : Object(scope->engine->functionClass) - , scope(scope) - , function(0) { + data.scope = scope; + data.function = 0; + Scope s(scope); ScopedValue protectThis(s, this); ScopedString n(s, name); @@ -106,9 +108,10 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name FunctionObject::FunctionObject(InternalClass *ic) : Object(ic) - , scope(ic->engine->rootContext) - , function(0) { + data.scope = ic->engine->rootContext; + data.function = 0; + managedData()->needsActivation = false; managedData()->strictMode = false; memberData()[Index_Prototype] = Encode::undefined(); @@ -116,8 +119,8 @@ FunctionObject::FunctionObject(InternalClass *ic) FunctionObject::~FunctionObject() { - if (function) - function->compilationUnit->deref(); + if (function()) + function()->compilationUnit->deref(); } void FunctionObject::init(const StringRef n, bool createProto) @@ -129,7 +132,7 @@ void FunctionObject::init(const StringRef n, bool createProto) managedData()->strictMode = false; if (createProto) { - Scoped<Object> proto(s, scope->engine->newObject(scope->engine->protoClass)); + Scoped<Object> proto(s, scope()->engine->newObject(scope()->engine->protoClass)); proto->memberData()[Index_ProtoConstructor] = this->asReturnedValue(); memberData()[Index_Prototype] = proto.asReturnedValue(); } else { @@ -137,12 +140,12 @@ void FunctionObject::init(const StringRef n, bool createProto) } ScopedValue v(s, n.asReturnedValue()); - defineReadonlyProperty(scope->engine->id_name, v); + defineReadonlyProperty(scope()->engine->id_name, v); } ReturnedValue FunctionObject::name() { - return get(scope->engine->id_name); + return get(scope()->engine->id_name); } @@ -167,8 +170,8 @@ ReturnedValue FunctionObject::call(Managed *, CallData *) void FunctionObject::markObjects(Managed *that, ExecutionEngine *e) { FunctionObject *o = static_cast<FunctionObject *>(that); - if (o->scope) - o->scope->mark(e); + if (o->scope()) + o->scope()->mark(e); Object::markObjects(that, e); } @@ -394,10 +397,10 @@ ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData) ExecutionContext *ctx = context->newCallContext(f.getPointer(), callData); ExecutionContextSaver ctxSaver(context); - ScopedValue result(scope, Q_V4_PROFILE(v4, ctx, f->function)); + ScopedValue result(scope, Q_V4_PROFILE(v4, ctx, f->function())); - if (f->function->compiledFunction->hasQmlDependencies()) - QmlContextWrapper::registerQmlDependencies(v4, f->function->compiledFunction); + if (f->function()->compiledFunction->hasQmlDependencies()) + QmlContextWrapper::registerQmlDependencies(v4, f->function()->compiledFunction); if (result->isObject()) return result.asReturnedValue(); @@ -418,10 +421,10 @@ ReturnedValue ScriptFunction::call(Managed *that, CallData *callData) CallContext *ctx = context->newCallContext(f, callData); ExecutionContextSaver ctxSaver(context); - ScopedValue result(scope, Q_V4_PROFILE(v4, ctx, f->function)); + ScopedValue result(scope, Q_V4_PROFILE(v4, ctx, f->function())); - if (f->function->compiledFunction->hasQmlDependencies()) - QmlContextWrapper::registerQmlDependencies(ctx->engine, f->function->compiledFunction); + if (f->function()->compiledFunction->hasQmlDependencies()) + QmlContextWrapper::registerQmlDependencies(ctx->engine, f->function()->compiledFunction); return result.asReturnedValue(); } @@ -436,8 +439,8 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu Scope s(scope); ScopedValue protectThis(s, this); - this->function = function; - this->function->compilationUnit->ref(); + data.function = function; + data.function->compilationUnit->ref(); Q_ASSERT(function); Q_ASSERT(function->code); @@ -479,9 +482,9 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) ctx.strictMode = f->strictMode(); ctx.callData = callData; ctx.function = f.getPointer(); - ctx.compilationUnit = f->function->compilationUnit; + ctx.compilationUnit = f->function()->compilationUnit; ctx.lookups = ctx.compilationUnit->runtimeLookups; - ctx.outer = f->scope; + ctx.outer = f->scope(); ctx.locals = v4->stackPush(f->varCount()); while (callData->argc < (int)f->formalParameterCount()) { callData->args[callData->argc] = Encode::undefined(); @@ -489,10 +492,10 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) } Q_ASSERT(v4->currentContext() == &ctx); - Scoped<Object> result(scope, Q_V4_PROFILE(v4, &ctx, f->function)); + Scoped<Object> result(scope, Q_V4_PROFILE(v4, &ctx, f->function())); - if (f->function->compiledFunction->hasQmlDependencies()) - QmlContextWrapper::registerQmlDependencies(v4, f->function->compiledFunction); + if (f->function()->compiledFunction->hasQmlDependencies()) + QmlContextWrapper::registerQmlDependencies(v4, f->function()->compiledFunction); if (!result) return callData->thisObject.asReturnedValue(); @@ -516,9 +519,9 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData) ctx.strictMode = f->strictMode(); ctx.callData = callData; ctx.function = f; - ctx.compilationUnit = f->function->compilationUnit; + ctx.compilationUnit = f->function()->compilationUnit; ctx.lookups = ctx.compilationUnit->runtimeLookups; - ctx.outer = f->scope; + ctx.outer = f->scope(); ctx.locals = v4->stackPush(f->varCount()); while (callData->argc < (int)f->formalParameterCount()) { callData->args[callData->argc] = Encode::undefined(); @@ -526,10 +529,10 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData) } Q_ASSERT(v4->currentContext() == &ctx); - ScopedValue result(scope, Q_V4_PROFILE(v4, &ctx, f->function)); + ScopedValue result(scope, Q_V4_PROFILE(v4, &ctx, f->function())); - if (f->function->compiledFunction->hasQmlDependencies()) - QmlContextWrapper::registerQmlDependencies(v4, f->function->compiledFunction); + if (f->function()->compiledFunction->hasQmlDependencies()) + QmlContextWrapper::registerQmlDependencies(v4, f->function()->compiledFunction); return result.asReturnedValue(); } @@ -576,7 +579,7 @@ ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData) ExecutionContextSaver ctxSaver(context); CallContext ctx(v4); - ctx.strictMode = f->scope->strictMode; // ### needed? scope or parent context? + ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? ctx.callData = callData; Q_ASSERT(v4->currentContext() == &ctx); @@ -595,7 +598,7 @@ ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData) ExecutionContextSaver ctxSaver(context); CallContext ctx(v4); - ctx.strictMode = f->scope->strictMode; // ### needed? scope or parent context? + ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? ctx.callData = callData; Q_ASSERT(v4->currentContext() == &ctx); @@ -640,7 +643,7 @@ void BoundFunction::destroy(Managed *that) ReturnedValue BoundFunction::call(Managed *that, CallData *dd) { BoundFunction *f = static_cast<BoundFunction *>(that); - Scope scope(f->scope->engine); + Scope scope(f->scope()->engine); if (scope.hasException()) return Encode::undefined(); @@ -654,7 +657,7 @@ ReturnedValue BoundFunction::call(Managed *that, CallData *dd) ReturnedValue BoundFunction::construct(Managed *that, CallData *dd) { BoundFunction *f = static_cast<BoundFunction *>(that); - Scope scope(f->scope->engine); + Scope scope(f->scope()->engine); if (scope.hasException()) return Encode::undefined(); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 53f2481ba1..5058b7aa5c 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -111,11 +111,20 @@ struct Q_QML_EXPORT FunctionObject: Object { Index_ProtoConstructor = 0 }; - ExecutionContext *scope; + struct Data { + ExecutionContext *scope; + Function *function; + + }; + Data data; + + + ExecutionContext *scope() { return data.scope; } + Function *function() { return data.function; } + ReturnedValue name(); - unsigned int formalParameterCount() { return function ? function->compiledFunction->nFormals : 0; } - unsigned int varCount() { return function ? function->compiledFunction->nLocals : 0; } - Function *function; + unsigned int formalParameterCount() { return function() ? function()->compiledFunction->nFormals : 0; } + unsigned int varCount() { return function() ? function()->compiledFunction->nLocals : 0; } FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto = false); FunctionObject(ExecutionContext *scope, const QString &name = QString(), bool createProto = false); diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index dd7c35a0d4..8a28f834fa 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -69,10 +69,10 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Objec Q_ASSERT(scope->inUse()); setVTable(staticVTable()); - function = f; - if (function) - function->compilationUnit->ref(); - managedData()->needsActivation = function ? function->needsActivation() : false; + data.function = f; + if (function()) + function()->compilationUnit->ref(); + managedData()->needsActivation = function() ? function()->needsActivation() : false; Scope s(scope); ScopedValue protectThis(s, this); @@ -91,7 +91,6 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml) Q_ASSERT(scope->inUse()); setVTable(staticVTable()); - function = 0; managedData()->needsActivation = false; Scope s(scope); @@ -110,13 +109,13 @@ ReturnedValue QmlBindingWrapper::call(Managed *that, CallData *) Scope scope(engine); QmlBindingWrapper *This = static_cast<QmlBindingWrapper *>(that); - if (!This->function) + if (!This->function()) return QV4::Encode::undefined(); CallContext *ctx = This->qmlContext; std::fill(ctx->locals, ctx->locals + ctx->function->varCount(), Primitive::undefinedValue()); engine->pushContext(ctx); - ScopedValue result(scope, This->function->code(ctx, This->function->codeData)); + ScopedValue result(scope, This->function()->code(ctx, This->function()->codeData)); engine->popContext(); return result.asReturnedValue(); diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index b580225d81..96caeab073 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -191,7 +191,7 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) lineNumber = loc.line; columnNumber = loc.column; } else { - QV4::Function *function = f->asFunctionObject()->function; + QV4::Function *function = f->asFunctionObject()->function(); Q_ASSERT(function); url = function->sourceFile(); @@ -284,7 +284,7 @@ QString QQmlBinding::expressionIdentifier(QQmlJavaScriptExpression *e) QQmlEnginePrivate *ep = QQmlEnginePrivate::get(This->context()->engine); QV4::Scope scope(ep->v4engine()); QV4::ScopedValue f(scope, This->v4function.value()); - QV4::Function *function = f->asFunctionObject()->function; + QV4::Function *function = f->asFunctionObject()->function(); QString url = function->sourceFile(); quint16 lineNumber = function->compiledFunction->location.line; diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 876f367097..cec5c31898 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -190,7 +190,7 @@ QV4::Function *QQmlBoundSignalExpression::function() const Q_ASSERT (context() && engine()); QV4::Scope scope(QQmlEnginePrivate::get(engine())->v4engine()); QV4::Scoped<QV4::FunctionObject> v(scope, m_v8function.value()); - return v ? v->function : 0; + return v ? v->function() : 0; } return 0; } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 322e81c681..949fc9ec8b 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1177,7 +1177,7 @@ ReturnedValue QtObject::method_locale(CallContext *ctx) } QQmlBindingFunction::QQmlBindingFunction(FunctionObject *originalFunction) - : QV4::FunctionObject(originalFunction->scope, originalFunction->name()) + : QV4::FunctionObject(originalFunction->scope(), originalFunction->name()) , originalFunction(originalFunction) { setVTable(staticVTable()); |