Encapsulate the current context and fix it's usage
authorLars Knoll <lars.knoll@digia.com>
Thu, 21 Nov 2013 15:41:32 +0000 (16:41 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 4 Dec 2013 08:45:50 +0000 (09:45 +0100)
Encapsulate accesses to the current context, and rework
the way we push and pop this context from the context
stack.

Largely a cleanup, but simplifies the code in the long term

Change-Id: I409e378490d0ab027be6a4c01a4031b2ea35c51d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
47 files changed:
src/imports/localstorage/plugin.cpp
src/qml/jsapi/qjsengine.cpp
src/qml/jsapi/qjsvalue.cpp
src/qml/jsapi/qjsvalueiterator.cpp
src/qml/jsruntime/qv4argumentsobject.cpp
src/qml/jsruntime/qv4arrayobject.cpp
src/qml/jsruntime/qv4context.cpp
src/qml/jsruntime/qv4context_p.h
src/qml/jsruntime/qv4debugging.cpp
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4engine_p.h
src/qml/jsruntime/qv4errorobject.cpp
src/qml/jsruntime/qv4functionobject.cpp
src/qml/jsruntime/qv4functionobject_p.h
src/qml/jsruntime/qv4globalobject.cpp
src/qml/jsruntime/qv4include.cpp
src/qml/jsruntime/qv4internalclass.cpp
src/qml/jsruntime/qv4jsonobject.cpp
src/qml/jsruntime/qv4lookup.cpp
src/qml/jsruntime/qv4managed.cpp
src/qml/jsruntime/qv4managed_p.h
src/qml/jsruntime/qv4object.cpp
src/qml/jsruntime/qv4objectproto.cpp
src/qml/jsruntime/qv4qobjectwrapper.cpp
src/qml/jsruntime/qv4regexpobject.cpp
src/qml/jsruntime/qv4runtime.cpp
src/qml/jsruntime/qv4scopedvalue_p.h
src/qml/jsruntime/qv4script.cpp
src/qml/jsruntime/qv4sequenceobject.cpp
src/qml/jsruntime/qv4serialize.cpp
src/qml/jsruntime/qv4stringobject.cpp
src/qml/jsruntime/qv4value.cpp
src/qml/qml/qqmlcomponent.cpp
src/qml/qml/qqmlcontextwrapper.cpp
src/qml/qml/qqmljavascriptexpression.cpp
src/qml/qml/qqmllistwrapper.cpp
src/qml/qml/qqmltypeloader.cpp
src/qml/qml/qqmltypewrapper.cpp
src/qml/qml/qqmlvaluetypewrapper.cpp
src/qml/qml/qqmlvmemetaobject.cpp
src/qml/qml/qqmlxmlhttprequest.cpp
src/qml/qml/v8/qv8engine.cpp
src/qml/types/qqmldelegatemodel.cpp
src/qml/types/qquickworkerscript.cpp
src/quick/items/context2d/qquickcontext2d.cpp
tests/auto/qml/qqmlecmascript/testtypes.cpp
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

index 1dbf0d5..48693db 100644 (file)
@@ -659,7 +659,7 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args)
 {
 #ifndef QT_NO_SETTINGS
     QV8Engine *engine = args->engine();
-    QV4::ExecutionContext *ctx = args->v4engine()->current;
+    QV4::ExecutionContext *ctx = args->v4engine()->currentContext();
     QV4::Scope scope(ctx);
     if (engine->engine()->offlineStoragePath().isEmpty())
         V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled."));
index cb050c2..a19c358 100644 (file)
@@ -261,7 +261,7 @@ void QJSEngine::collectGarbage()
 QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, int lineNumber)
 {
     QV4::Scope scope(d->m_v4Engine);
-    QV4::ExecutionContext *ctx = d->m_v4Engine->current;
+    QV4::ExecutionContext *ctx = d->m_v4Engine->currentContext();
     QV4::ScopedValue result(scope);
 
     QV4::Script script(ctx, program, fileName, lineNumber);
index f0e92eb..d7a1cef 100644 (file)
@@ -383,7 +383,7 @@ double QJSValue::toNumber() const
     if (d->value.isEmpty())
         return __qmljs_string_to_number(d->string);
 
-    QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0;
+    QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
     double dbl = d->value.toNumber();
     if (ctx && ctx->engine->hasException) {
         ctx->catchException();
@@ -409,7 +409,7 @@ bool QJSValue::toBool() const
     if (d->value.isEmpty())
         return d->string.length() > 0;
 
-    QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0;
+    QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
     bool b = d->value.toBoolean();
     if (ctx && ctx->engine->hasException) {
         ctx->catchException();
@@ -435,7 +435,7 @@ qint32 QJSValue::toInt() const
     if (d->value.isEmpty())
         return QV4::Primitive::toInt32(__qmljs_string_to_number(d->string));
 
-    QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0;
+    QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
     qint32 i = d->value.toInt32();
     if (ctx && ctx->engine->hasException) {
         ctx->catchException();
@@ -461,7 +461,7 @@ quint32 QJSValue::toUInt() const
     if (d->value.isEmpty())
         return QV4::Primitive::toUInt32(__qmljs_string_to_number(d->string));
 
-    QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0;
+    QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
     quint32 u = d->value.toUInt32();
     if (ctx && ctx->engine->hasException) {
         ctx->catchException();
@@ -536,7 +536,7 @@ QJSValue QJSValue::call(const QJSValueList &args)
     }
 
     ScopedValue result(scope);
-    QV4::ExecutionContext *ctx = engine->current;
+    QV4::ExecutionContext *ctx = engine->currentContext();
     result = f->call(callData);
     if (scope.hasException())
         result = ctx->catchException();
@@ -590,7 +590,7 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList
     }
 
     ScopedValue result(scope);
-    QV4::ExecutionContext *ctx = engine->current;
+    QV4::ExecutionContext *ctx = engine->currentContext();
     result = f->call(callData);
     if (scope.hasException())
         result = ctx->catchException();
@@ -636,7 +636,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args)
     }
 
     ScopedValue result(scope);
-    QV4::ExecutionContext *ctx = engine->current;
+    QV4::ExecutionContext *ctx = engine->currentContext();
     result = f->construct(callData);
     if (scope.hasException())
         result = ctx->catchException();
@@ -859,7 +859,7 @@ QJSValue QJSValue::property(const QString& name) const
         return property(idx);
 
     s->makeIdentifier();
-    QV4::ExecutionContext *ctx = engine->current;
+    QV4::ExecutionContext *ctx = engine->currentContext();
     QV4::ScopedValue result(scope);
     result = o->get(s);
     if (scope.hasException())
@@ -891,7 +891,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const
     if (!o)
         return QJSValue();
 
-    QV4::ExecutionContext *ctx = engine->current;
+    QV4::ExecutionContext *ctx = engine->currentContext();
     QV4::ScopedValue result(scope);
     result = arrayIndex == UINT_MAX ? o->get(engine->id_uintMax) : o->getIndexed(arrayIndex);
     if (scope.hasException())
@@ -933,7 +933,7 @@ void QJSValue::setProperty(const QString& name, const QJSValue& value)
         return;
     }
 
-    QV4::ExecutionContext *ctx = engine->current;
+    QV4::ExecutionContext *ctx = engine->currentContext();
     s->makeIdentifier();
     QV4::ScopedValue v(scope, value.d->getValue(engine));
     o->put(s, v);
@@ -964,7 +964,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
     if (!o)
         return;
 
-    QV4::ExecutionContext *ctx = engine->current;
+    QV4::ExecutionContext *ctx = engine->currentContext();
     QV4::ScopedValue v(scope, value.d->getValue(engine));
     if (arrayIndex != UINT_MAX)
         o->putIndexed(arrayIndex, v);
@@ -997,7 +997,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
 bool QJSValue::deleteProperty(const QString &name)
 {
     ExecutionEngine *engine = d->engine;
-    ExecutionContext *ctx = engine->current;
+    ExecutionContext *ctx = engine->currentContext();
     Scope scope(engine);
     ScopedObject o(scope, d->value.asObject());
     if (!o)
index 245b75b..ed011ef 100644 (file)
@@ -59,7 +59,7 @@ QJSValueIteratorPrivate::QJSValueIteratorPrivate(const QJSValue &v)
 
     QV4::Scope scope(e);
     QV4::ScopedObject o(scope, jsp->value);
-    iterator = e->newForEachIteratorObject(e->current, o)->asReturnedValue();
+    iterator = e->newForEachIteratorObject(e->currentContext(), o)->asReturnedValue();
 
     currentName = (QV4::String *)0;
     nextName = (QV4::String *)0;
@@ -198,7 +198,7 @@ QJSValue QJSValueIterator::value() const
     QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
     QV4::ScopedObject o(scope, it->it.object);
 
-    QV4::ExecutionContext *ctx = engine->current;
+    QV4::ExecutionContext *ctx = engine->currentContext();
     QV4::ScopedValue v(scope);
     if (!!d_ptr->currentName) {
         QV4::ScopedString n(scope, d_ptr->currentName);
@@ -237,7 +237,7 @@ QJSValueIterator& QJSValueIterator::operator=(QJSValue& object)
     QJSValuePrivate *jsp = QJSValuePrivate::get(object);
     QV4::Scope scope(v4);
     QV4::ScopedObject o(scope, jsp->value);
-    d_ptr->iterator = v4->newForEachIteratorObject(v4->current, o)->asReturnedValue();
+    d_ptr->iterator = v4->newForEachIteratorObject(v4->currentContext(), o)->asReturnedValue();
     QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
     it->it.flags =  QV4::ObjectIterator::NoFlags;
     it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextAttributes);
index 3ec11cc..629c255 100644 (file)
@@ -215,7 +215,7 @@ ReturnedValue ArgumentsGetterFunction::call(Managed *getter, CallData *callData)
     Scoped<ArgumentsGetterFunction> g(scope, static_cast<ArgumentsGetterFunction *>(getter));
     Scoped<ArgumentsObject> o(scope, callData->thisObject.as<ArgumentsObject>());
     if (!o)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
     Q_ASSERT(g->index < static_cast<unsigned>(o->context->callData->argc));
     return o->context->argument(g->index);
@@ -230,7 +230,7 @@ ReturnedValue ArgumentsSetterFunction::call(Managed *setter, CallData *callData)
     Scoped<ArgumentsSetterFunction> s(scope, static_cast<ArgumentsSetterFunction *>(setter));
     Scoped<ArgumentsObject> o(scope, callData->thisObject.as<ArgumentsObject>());
     if (!o)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
     Q_ASSERT(s->index < static_cast<unsigned>(o->context->callData->argc));
     o->context->callData->args[s->index] = callData->argc ? callData->args[0].asReturnedValue() : Encode::undefined();
index 39b9b9e..a8bc774 100644 (file)
@@ -65,7 +65,7 @@ ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData)
         len = callData->args[0].asArrayLength(&ok);
 
         if (!ok)
-            return v4->current->throwRangeError(callData->args[0]);
+            return v4->currentContext()->throwRangeError(callData->args[0]);
 
         if (len < 0x1000)
             a->arrayReserve(len);
index f9b63ac..05a0e66 100644 (file)
@@ -76,9 +76,7 @@ const ManagedVTable ExecutionContext::static_vtbl =
 CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData *callData)
 {
     CallContext *c = static_cast<CallContext *>(engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(function, callData->argc)));
-    new (c) CallContext(engine, this, Type_CallContext);
-
-    engine->current = c;
+    new (c) CallContext(engine, Type_CallContext);
 
     c->function = function;
     c->realArgumentCount = callData->argc;
@@ -112,22 +110,20 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData
 
 WithContext *ExecutionContext::newWithContext(ObjectRef with)
 {
-    WithContext *w = new (engine->memoryManager) WithContext(this, with);
-    engine->current = w;
+    WithContext *w = new (engine->memoryManager) WithContext(engine, with);
     return w;
 }
 
 CatchContext *ExecutionContext::newCatchContext(const StringRef exceptionVarName, const ValueRef exceptionValue)
 {
-    CatchContext *c = new (engine->memoryManager) CatchContext(this, exceptionVarName, exceptionValue);
-    engine->current = c;
+    CatchContext *c = new (engine->memoryManager) CatchContext(engine, exceptionVarName, exceptionValue);
     return c;
 }
 
 CallContext *ExecutionContext::newQmlContext(FunctionObject *f, ObjectRef qml)
 {
     CallContext *c = static_cast<CallContext *>(engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(f, 0)));
-    new (c) CallContext(this, qml, f);
+    new (c) CallContext(engine, qml, f);
     return c;
 }
 
@@ -192,45 +188,38 @@ unsigned int ExecutionContext::variableCount() const
 }
 
 
-GlobalContext::GlobalContext(ExecutionEngine *eng, ExecutionContext *parent)
-    : ExecutionContext(eng, Type_GlobalContext, parent)
+GlobalContext::GlobalContext(ExecutionEngine *eng)
+    : ExecutionContext(eng, Type_GlobalContext)
 {
-    if (!parent) {
-        callData = reinterpret_cast<CallData *>(this + 1);
-        callData->tag = QV4::Value::_Integer_Type;
-        callData->argc = 0;
-        callData->thisObject = eng->globalObject;
-        callData->args[0] = Encode::undefined();
-    }
-    global = 0;
+    global = eng->globalObject;
 }
 
-WithContext::WithContext(ExecutionContext *p, ObjectRef with)
-    : ExecutionContext(p->engine, Type_WithContext, p)
+WithContext::WithContext(ExecutionEngine *engine, ObjectRef with)
+    : ExecutionContext(engine, Type_WithContext)
 {
-    callData = p->callData;
-    outer = p;
-    lookups = p->lookups;
-    compilationUnit = p->compilationUnit;
+    callData = parent->callData;
+    outer = parent;
+    lookups = parent->lookups;
+    compilationUnit = parent->compilationUnit;
 
     withObject = with.getPointer();
 }
 
-CatchContext::CatchContext(ExecutionContext *p, const StringRef exceptionVarName, const ValueRef exceptionValue)
-    : ExecutionContext(p->engine, Type_CatchContext, p)
+CatchContext::CatchContext(ExecutionEngine *engine, const StringRef exceptionVarName, const ValueRef exceptionValue)
+    : ExecutionContext(engine, Type_CatchContext)
 {
-    strictMode = p->strictMode;
-    callData = p->callData;
-    outer = p;
-    lookups = p->lookups;
-    compilationUnit = p->compilationUnit;
+    strictMode = parent->strictMode;
+    callData = parent->callData;
+    outer = parent;
+    lookups = parent->lookups;
+    compilationUnit = parent->compilationUnit;
 
     this->exceptionVarName = exceptionVarName;
     this->exceptionValue = exceptionValue;
 }
 
-CallContext::CallContext(ExecutionContext *parentContext, ObjectRef qml, FunctionObject *function)
-    : ExecutionContext(parentContext->engine, Type_QmlContext, parentContext)
+CallContext::CallContext(ExecutionEngine *engine, ObjectRef qml, FunctionObject *function)
+    : ExecutionContext(engine, Type_QmlContext)
 {
     this->function = function;
     callData = reinterpret_cast<CallData *>(this + 1);
index f2650b2..4eb89ad 100644 (file)
@@ -80,19 +80,20 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
         Type_QmlContext = 0x6
     };
 
-    ExecutionContext(ExecutionEngine *engine, ContextType t, ExecutionContext *parent)
+    ExecutionContext(ExecutionEngine *engine, ContextType t)
         : Managed(engine->executionContextClass)
     {
         this->type = t;
         strictMode = false;
         this->engine = engine;
-        this->parent = parent;
+        this->parent = engine->currentContext();
         outer = 0;
         lookups = 0;
         compilationUnit = 0;
         currentEvalCode = 0;
         interpreterInstructionPointer = 0;
         lineNumber = -1;
+        engine->current = this;
     }
 
     ContextType type;
@@ -159,36 +160,34 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
 
 struct CallContext : public ExecutionContext
 {
-    CallContext(ExecutionEngine *engine, ExecutionContext *parent, ContextType t = Type_SimpleCallContext)
-        : ExecutionContext(engine, t, parent)
+    CallContext(ExecutionEngine *engine, ContextType t = Type_SimpleCallContext)
+        : ExecutionContext(engine, t)
     {
         function = 0;
         locals = 0;
         activation = 0;
     }
-    CallContext(ExecutionContext *parentContext, ObjectRef qml, QV4::FunctionObject *function);
+    CallContext(ExecutionEngine *engine, ObjectRef qml, QV4::FunctionObject *function);
 
     FunctionObject *function;
     int realArgumentCount;
     SafeValue *locals;
     Object *activation;
 
-    void initQmlContext(ExecutionContext *parentContext, ObjectRef qml, QV4::FunctionObject *function);
-
     inline ReturnedValue argument(int i);
     bool needsOwnArguments() const;
 };
 
 struct GlobalContext : public ExecutionContext
 {
-    GlobalContext(ExecutionEngine *engine, ExecutionContext *parent = 0);
+    GlobalContext(ExecutionEngine *engine);
 
     Object *global;
 };
 
 struct CatchContext : public ExecutionContext
 {
-    CatchContext(ExecutionContext *p, const StringRef exceptionVarName, const ValueRef exceptionValue);
+    CatchContext(ExecutionEngine *engine, const StringRef exceptionVarName, const ValueRef exceptionValue);
 
     SafeString exceptionVarName;
     SafeValue exceptionValue;
@@ -196,7 +195,7 @@ struct CatchContext : public ExecutionContext
 
 struct WithContext : public ExecutionContext
 {
-    WithContext(ExecutionContext *p, ObjectRef with);
+    WithContext(ExecutionEngine *engine, ObjectRef with);
     Object *withObject;
 };
 
@@ -220,6 +219,7 @@ inline void ExecutionEngine::pushContext(CallContext *context)
 
 inline ExecutionContext *ExecutionEngine::popContext()
 {
+    Q_ASSERT(current->parent);
     current = current->parent;
     return current;
 }
index e14ea25..4170b68 100644 (file)
@@ -185,7 +185,7 @@ void Debugger::resume(Speed speed)
     if (speed == StepOver)
         setTemporaryBreakPointOnNextLine();
     if (speed == StepOut)
-        m_temporaryBreakPoints = TemporaryBreakPoint(getFunction(), m_engine->current);
+        m_temporaryBreakPoints = TemporaryBreakPoint(getFunction(), m_engine->currentContext());
 
     m_stepping = speed;
     m_runningCondition.wakeAll();
@@ -293,7 +293,7 @@ void Debugger::collectArgumentsInContext(Collector *collector, int frameNr, int
             if (frameNr < 0)
                 return;
 
-            CallContext *ctxt = findScope(findContext(engine->current, frameNr), scopeNr);
+            CallContext *ctxt = findScope(findContext(engine->currentContext(), frameNr), scopeNr);
             if (!ctxt)
                 return;
 
@@ -340,7 +340,7 @@ void Debugger::collectLocalsInContext(Collector *collector, int frameNr, int sco
             if (frameNr < 0)
                 return;
 
-            CallContext *ctxt = findScope(findContext(engine->current, frameNr), scopeNr);
+            CallContext *ctxt = findScope(findContext(engine->currentContext(), frameNr), scopeNr);
             if (!ctxt)
                 return;
 
@@ -387,7 +387,7 @@ bool Debugger::collectThisInContext(Debugger::Collector *collector, int frame)
 
         bool myRun()
         {
-            ExecutionContext *ctxt = findContext(engine->current, frameNr);
+            ExecutionContext *ctxt = findContext(engine->currentContext(), frameNr);
             while (ctxt) {
                 if (CallContext *cCtxt = ctxt->asCallContext())
                     if (cCtxt->activation)
@@ -456,7 +456,7 @@ QVector<ExecutionContext::ContextType> Debugger::getScopeTypes(int frame) const
     if (state() != Paused)
         return types;
 
-    CallContext *sctxt = findContext(m_engine->current, frame);
+    CallContext *sctxt = findContext(m_engine->currentContext(), frame);
     if (!sctxt || sctxt->type < ExecutionContext::Type_SimpleCallContext)
         return types;
     CallContext *ctxt = static_cast<CallContext *>(sctxt);
@@ -500,7 +500,7 @@ void Debugger::maybeBreakAtInstruction(const uchar *code, bool breakPointHit)
         m_pauseRequested = false;
         pauseAndWait(PauseRequest);
     } else if (breakPointHit) {
-        if (m_stepping == StepOver && m_temporaryBreakPoints.context == m_engine->current)
+        if (m_stepping == StepOver && m_temporaryBreakPoints.context == m_engine->currentContext())
             pauseAndWait(Step);
         else if (reallyHitTheBreakPoint(state.fileName, state.lineNumber))
             pauseAndWait(BreakPoint);
@@ -528,7 +528,7 @@ void Debugger::leavingFunction(const ReturnedValue &retVal)
     QMutexLocker locker(&m_lock);
 
     if ((m_stepping == StepOut || m_stepping == StepOver)
-            && temporaryBreakPointInFunction(m_engine->current)) {
+            && temporaryBreakPointInFunction(m_engine->currentContext())) {
         clearTemporaryBreakPoints();
         m_stepping = NotStepping;
         m_stopForStepping = true;
@@ -552,7 +552,7 @@ void Debugger::aboutToThrow()
 
 Function *Debugger::getFunction() const
 {
-    ExecutionContext *context = m_engine->current;
+    ExecutionContext *context = m_engine->currentContext();
     if (CallContext *callCtx = context->asCallContext())
         return callCtx->function->function;
     else {
@@ -595,7 +595,7 @@ void Debugger::setTemporaryBreakPointOnNextLine()
     if (pcs.isEmpty())
         return;
 
-    m_temporaryBreakPoints = TemporaryBreakPoint(function, m_engine->current);
+    m_temporaryBreakPoints = TemporaryBreakPoint(function, m_engine->currentContext());
     m_temporaryBreakPoints.codeOffsets.reserve(pcs.size());
     for (QList<qptrdiff>::const_iterator i = pcs.begin(), ei = pcs.end(); i != ei; ++i) {
         // note: we do set a breakpoint on the current line, because there could be a loop where
index b3d3214..dc8c0da 100644 (file)
@@ -136,6 +136,7 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
     : memoryManager(new QV4::MemoryManager)
     , executableAllocator(new QV4::ExecutableAllocator)
     , regExpAllocator(new QV4::ExecutableAllocator)
+    , current(0)
     , bumperPointerAllocator(new WTF::BumpPointerAllocator)
     , jsStack(new WTF::PageAllocation)
     , debugger(0)
@@ -405,8 +406,11 @@ void ExecutionEngine::initRootContext()
 {
     rootContext = static_cast<GlobalContext *>(memoryManager->allocManaged(sizeof(GlobalContext) + sizeof(CallData)));
     new (rootContext) GlobalContext(this);
-    current = rootContext;
-    current->parent = 0;
+    rootContext->callData = reinterpret_cast<CallData *>(rootContext + 1);
+    rootContext->callData->tag = QV4::Value::_Integer_Type;
+    rootContext->callData->argc = 0;
+    rootContext->callData->thisObject = globalObject;
+    rootContext->callData->args[0] = Encode::undefined();
 }
 
 InternalClass *ExecutionEngine::newClass(const InternalClass &other)
@@ -416,13 +420,11 @@ InternalClass *ExecutionEngine::newClass(const InternalClass &other)
 
 ExecutionContext *ExecutionEngine::pushGlobalContext()
 {
-    GlobalContext *g = new (memoryManager) GlobalContext(this, current);
-    ExecutionContext *oldNext = g->next;
-    memcpy(g, rootContext, sizeof(GlobalContext));
-    g->next = oldNext;
-    current = g;
+    GlobalContext *g = new (memoryManager) GlobalContext(this);
+    g->callData = rootContext->callData;
 
-    return current;
+    Q_ASSERT(currentContext() == g);
+    return g;
 }
 
 Returned<FunctionObject> *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *))
@@ -610,7 +612,7 @@ Returned<Object> *ExecutionEngine::newForEachIteratorObject(ExecutionContext *ct
 
 Returned<Object> *ExecutionEngine::qmlContextObject() const
 {
-    ExecutionContext *ctx = current;
+    ExecutionContext *ctx = currentContext();
 
     if (ctx->type == QV4::ExecutionContext::Type_SimpleCallContext && !ctx->outer)
         ctx = ctx->parent;
@@ -656,7 +658,7 @@ QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const
 
     QVector<StackFrame> stack;
 
-    QV4::ExecutionContext *c = current;
+    QV4::ExecutionContext *c = currentContext();
     while (c && frameLimit) {
         CallContext *callCtx = c->asCallContext();
         if (callCtx && callCtx->function) {
@@ -710,7 +712,7 @@ QUrl ExecutionEngine::resolvedUrl(const QString &file)
         return src;
 
     QUrl base;
-    QV4::ExecutionContext *c = current;
+    QV4::ExecutionContext *c = currentContext();
     while (c) {
         CallContext *callCtx = c->asCallContext();
         if (callCtx && callCtx->function) {
@@ -766,7 +768,7 @@ void ExecutionEngine::markObjects()
             setter->mark(this);
     }
 
-    ExecutionContext *c = current;
+    ExecutionContext *c = currentContext();
     while (c) {
         c->mark(this);
         c = c->parent;
@@ -902,8 +904,8 @@ ReturnedValue ExecutionEngine::throwException(const ValueRef value)
 ReturnedValue ExecutionEngine::catchException(ExecutionContext *catchingContext, StackTrace *trace)
 {
     Q_ASSERT(hasException);
-    while (current != catchingContext)
-        popContext();
+    Q_UNUSED(catchingContext);
+    Q_ASSERT(currentContext() == catchingContext);
     if (trace)
         *trace = exceptionStackTrace;
     exceptionStackTrace.clear();
index 67a7077..ecb5f2b 100644 (file)
@@ -111,11 +111,12 @@ class RegExp;
 class RegExpCache;
 struct QmlExtensions;
 struct Exception;
+struct ExecutionContextSaver;
 
 #define CHECK_STACK_LIMITS(v4) \
     if ((v4->jsStackTop <= v4->jsStackLimit) && (reinterpret_cast<quintptr>(&v4) >= v4->cStackLimit || v4->recheckCStackLimits())) {}  \
     else \
-        return v4->current->throwRangeError(QStringLiteral("Maximum call stack size exceeded."))
+        return v4->currentContext()->throwRangeError(QStringLiteral("Maximum call stack size exceeded."))
 
 
 struct Q_QML_EXPORT ExecutionEngine
@@ -125,7 +126,13 @@ struct Q_QML_EXPORT ExecutionEngine
     ExecutableAllocator *regExpAllocator;
     QScopedPointer<QQmlJS::EvalISelFactory> iselFactory;
 
+private:
+    friend struct ExecutionContextSaver;
+    friend struct ExecutionContext;
     ExecutionContext *current;
+public:
+    ExecutionContext *currentContext() const { return current; }
+
     GlobalContext *rootContext;
 
     SafeValue *jsStackTop;
index d5b4975..cf5c06d 100644 (file)
@@ -77,7 +77,6 @@ ErrorObject::ErrorObject(InternalClass *ic)
     , stack(0)
 {
     type = Type_ErrorObject;
-    setVTable(&static_vtbl);
 
     Scope scope(engine());
     ScopedValue protectThis(scope, this);
@@ -91,7 +90,6 @@ ErrorObject::ErrorObject(InternalClass *ic, const ValueRef message, ErrorType t)
     , stack(0)
 {
     type = Type_ErrorObject;
-    setVTable(&static_vtbl);
     subtype = t;
 
     Scope scope(engine());
@@ -116,7 +114,6 @@ ErrorObject::ErrorObject(InternalClass *ic, const QString &message, ErrorObject:
     , stack(0)
 {
     type = Type_ErrorObject;
-    setVTable(&static_vtbl);
     subtype = t;
 
     Scope scope(engine());
@@ -141,7 +138,6 @@ ErrorObject::ErrorObject(InternalClass *ic, const QString &message, const QStrin
     , stack(0)
 {
     type = Type_ErrorObject;
-    setVTable(&static_vtbl);
     subtype = t;
 
     Scope scope(engine());
@@ -207,13 +203,11 @@ DEFINE_MANAGED_VTABLE(SyntaxErrorObject);
 SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const ValueRef msg)
     : ErrorObject(engine->syntaxErrorClass, msg, SyntaxError)
 {
-    setVTable(&static_vtbl);
 }
 
 SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const QString &msg, const QString &fileName, int lineNumber, int columnNumber)
     : ErrorObject(engine->syntaxErrorClass, msg, fileName, lineNumber, columnNumber, SyntaxError)
 {
-    setVTable(&static_vtbl);
 }
 
 EvalErrorObject::EvalErrorObject(ExecutionEngine *engine, const ValueRef message)
index b9318e7..6e5c137 100644 (file)
@@ -247,7 +247,7 @@ ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData)
 {
     FunctionCtor *f = static_cast<FunctionCtor *>(that);
     ExecutionEngine *v4 = f->internalClass->engine;
-    ExecutionContext *ctx = v4->current;
+    ExecutionContext *ctx = v4->currentContext();
     QString arguments;
     QString body;
     if (callData->argc > 0) {
@@ -271,16 +271,16 @@ ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData)
     const bool parsed = parser.parseExpression();
 
     if (!parsed)
-        return v4->current->throwSyntaxError(QLatin1String("Parse error"));
+        return v4->currentContext()->throwSyntaxError(QLatin1String("Parse error"));
 
     using namespace QQmlJS::AST;
     FunctionExpression *fe = QQmlJS::AST::cast<FunctionExpression *>(parser.rootNode());
     if (!fe)
-        return v4->current->throwSyntaxError(QLatin1String("Parse error"));
+        return v4->currentContext()->throwSyntaxError(QLatin1String("Parse error"));
 
     QQmlJS::V4IR::Module module(v4->debugger != 0);
 
-    QQmlJS::RuntimeCodegen cg(v4->current, f->strictMode);
+    QQmlJS::RuntimeCodegen cg(v4->currentContext(), f->strictMode);
     cg.generateFromFunctionExpression(QString(), function, fe, &module);
 
     QV4::Compiler::JSUnitGenerator jsGenerator(&module);
@@ -447,7 +447,7 @@ ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData)
     InternalClass *ic = f->internalClassForConstructor();
     ScopedObject obj(scope, v4->newObject(ic));
 
-    ExecutionContext *context = v4->current;
+    ExecutionContext *context = v4->currentContext();
     callData->thisObject = obj.asReturnedValue();
     ExecutionContext *ctx = context->newCallContext(f.getPointer(), callData);
 
@@ -469,7 +469,7 @@ ReturnedValue ScriptFunction::call(Managed *that, CallData *callData)
         return Encode::undefined();
     CHECK_STACK_LIMITS(v4);
 
-    ExecutionContext *context = v4->current;
+    ExecutionContext *context = v4->currentContext();
     Scope scope(context);
 
     CallContext *ctx = context->newCallContext(f, callData);
@@ -529,9 +529,10 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData)
     InternalClass *ic = f->internalClassForConstructor();
     callData->thisObject = v4->newObject(ic);
 
-    ExecutionContext *context = v4->current;
+    ExecutionContext *context = v4->currentContext();
+    ExecutionContextSaver ctxSaver(context);
 
-    CallContext ctx(v4, context);
+    CallContext ctx(v4);
     ctx.strictMode = f->strictMode;
     ctx.callData = callData;
     ctx.function = f.getPointer();
@@ -543,12 +544,11 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData)
         callData->args[callData->argc] = Encode::undefined();
         ++callData->argc;
     }
-    v4->pushContext(&ctx);
+    Q_ASSERT(v4->currentContext() == &ctx);
 
     if (f->function->compiledFunction->hasQmlDependencies())
         QmlContextWrapper::registerQmlDependencies(v4, f->function->compiledFunction);
 
-    ExecutionContextSaver ctxSaver(context);
     Scoped<Object> result(scope, f->function->code(&ctx, f->function->codeData));
 
     if (!result)
@@ -566,9 +566,10 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData)
     SimpleScriptFunction *f = static_cast<SimpleScriptFunction *>(that);
 
     Scope scope(v4);
-    ExecutionContext *context = v4->current;
+    ExecutionContext *context = v4->currentContext();
+    ExecutionContextSaver ctxSaver(context);
 
-    CallContext ctx(v4, context);
+    CallContext ctx(v4);
     ctx.strictMode = f->strictMode;
     ctx.callData = callData;
     ctx.function = f;
@@ -580,12 +581,11 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData)
         callData->args[callData->argc] = Encode::undefined();
         ++callData->argc;
     }
-    v4->current = &ctx;
+    Q_ASSERT(v4->currentContext() == &ctx);
 
     if (f->function->compiledFunction->hasQmlDependencies())
         QmlContextWrapper::registerQmlDependencies(v4, f->function->compiledFunction);
 
-    ExecutionContextSaver ctxSaver(context);
     return f->function->code(&ctx, f->function->codeData);
 }
 
@@ -603,7 +603,7 @@ BuiltinFunction::BuiltinFunction(ExecutionContext *scope, const StringRef name,
 
 ReturnedValue BuiltinFunction::construct(Managed *f, CallData *)
 {
-    return f->internalClass->engine->current->throwTypeError();
+    return f->internalClass->engine->currentContext()->throwTypeError();
 }
 
 ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData)
@@ -614,14 +614,14 @@ ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData)
         return Encode::undefined();
     CHECK_STACK_LIMITS(v4);
 
-    ExecutionContext *context = v4->current;
+    ExecutionContext *context = v4->currentContext();
+    ExecutionContextSaver ctxSaver(context);
 
-    CallContext ctx(v4, context);
+    CallContext ctx(v4);
     ctx.strictMode = f->scope->strictMode; // ### needed? scope or parent context?
     ctx.callData = callData;
-    v4->pushContext(&ctx);
+    Q_ASSERT(v4->currentContext() == &ctx);
 
-    ExecutionContextSaver ctxSaver(context);
     return f->code(&ctx);
 }
 
@@ -633,14 +633,14 @@ ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData)
         return Encode::undefined();
     CHECK_STACK_LIMITS(v4);
 
-    ExecutionContext *context = v4->current;
+    ExecutionContext *context = v4->currentContext();
+    ExecutionContextSaver ctxSaver(context);
 
-    CallContext ctx(v4, context);
+    CallContext ctx(v4);
     ctx.strictMode = f->scope->strictMode; // ### needed? scope or parent context?
     ctx.callData = callData;
-    v4->pushContext(&ctx);
+    Q_ASSERT(v4->currentContext() == &ctx);
 
-    ExecutionContextSaver ctxSaver(context);
     return f->code(&ctx, f->index);
 }
 
index e0ee720..96534cb 100644 (file)
@@ -202,7 +202,7 @@ struct IndexedBuiltinFunction: FunctionObject
 
     static ReturnedValue construct(Managed *m, CallData *)
     {
-        return m->engine()->current->throwTypeError();
+        return m->engine()->currentContext()->throwTypeError();
     }
 
     static ReturnedValue call(Managed *that, CallData *callData);
index d4c4dbf..fa8af8e 100644 (file)
@@ -380,7 +380,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall)
         return Encode::undefined();
 
     ExecutionEngine *v4 = engine();
-    ExecutionContext *parentContext = v4->current;
+    ExecutionContext *parentContext = v4->currentContext();
     ExecutionContextSaver ctxSaver(parentContext);
 
     ExecutionContext *ctx = parentContext;
index 8f25480..d0e0e94 100644 (file)
@@ -108,7 +108,7 @@ void QV4Include::callback(const QV4::ValueRef callback, const QV4::ValueRef stat
     if (!f)
         return;
 
-    QV4::ExecutionContext *ctx = v4->current;
+    QV4::ExecutionContext *ctx = v4->currentContext();
     QV4::ScopedCallData callData(scope, 1);
     callData->thisObject = v4->globalObject->asReturnedValue();
     callData->args[0] = status;
@@ -153,7 +153,7 @@ void QV4Include::finished()
         QV4::ScopedObject qmlglobal(scope, m_qmlglobal.value());
         QV4::Script script(v4, qmlglobal, code, m_url.toString());
 
-        QV4::ExecutionContext *ctx = v4->current;
+        QV4::ExecutionContext *ctx = v4->currentContext();
         QV4::ScopedString status(scope, v4->newString(QStringLiteral("status")));
         script.parse();
         if (!scope.engine->hasException)
@@ -220,7 +220,7 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx)
 
             QV4::Script script(v4, qmlcontextobject, code, url.toString());
 
-            QV4::ExecutionContext *ctx = v4->current;
+            QV4::ExecutionContext *ctx = v4->currentContext();
             script.parse();
             if (!v4->hasException)
                 script.run();
index 729ed12..29ede3d 100644 (file)
@@ -297,7 +297,8 @@ void InternalClass::removeMember(Object *object, Identifier *id)
     }
 
     // create a new class and add it to the tree
-    object->internalClass = engine->emptyClass->changePrototype(prototype);
+    object->internalClass = engine->emptyClass->changeVTable(vtable);
+    object->internalClass = object->internalClass->changePrototype(prototype);
     for (uint i = 0; i < size; ++i) {
         if (i == propIdx)
             continue;
@@ -330,6 +331,7 @@ InternalClass *InternalClass::sealed()
         return m_sealed;
 
     m_sealed = engine->emptyClass;
+    m_sealed = m_sealed->changeVTable(vtable);
     m_sealed = m_sealed->changePrototype(prototype);
     for (uint i = 0; i < size; ++i) {
         PropertyAttributes attrs = propertyData.at(i);
@@ -347,6 +349,7 @@ InternalClass *InternalClass::frozen()
         return m_frozen;
 
     m_frozen = engine->emptyClass;
+    m_frozen = m_frozen->changeVTable(vtable);
     m_frozen = m_frozen->changePrototype(prototype);
     for (uint i = 0; i < size; ++i) {
         PropertyAttributes attrs = propertyData.at(i);
index 458b46b..2383709 100644 (file)
@@ -960,7 +960,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx)
 ReturnedValue JsonObject::fromJsonValue(ExecutionEngine *engine, const QJsonValue &value)
 {
     if (value.isString())
-        return engine->current->engine->newString(value.toString())->asReturnedValue();
+        return engine->currentContext()->engine->newString(value.toString())->asReturnedValue();
     else if (value.isDouble())
         return Encode(value.toDouble());
     else if (value.isBool())
index 29926e9..a870cda 100644 (file)
@@ -87,7 +87,7 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const ValueRef object)
     switch (object->type()) {
     case Value::Undefined_Type:
     case Value::Null_Type:
-        return engine->current->throwTypeError();
+        return engine->currentContext()->throwTypeError();
     case Value::Boolean_Type:
         proto = engine->booleanClass->prototype;
         break;
@@ -446,7 +446,7 @@ void Lookup::setterGeneric(Lookup *l, const ValueRef object, const ValueRef valu
     Scope scope(l->name->engine());
     ScopedObject o(scope, object);
     if (!o) {
-        o = __qmljs_convert_to_object(scope.engine->current, object);
+        o = __qmljs_convert_to_object(scope.engine->currentContext(), object);
         if (!o) // type error
             return;
         ScopedString s(scope, l->name);
index 9b52abb..fef7489 100644 (file)
@@ -184,22 +184,22 @@ void Managed::setVTable(const ManagedVTable *vt)
 
 ReturnedValue Managed::construct(Managed *m, CallData *)
 {
-    return m->engine()->current->throwTypeError();
+    return m->engine()->currentContext()->throwTypeError();
 }
 
 ReturnedValue Managed::call(Managed *m, CallData *)
 {
-    return m->engine()->current->throwTypeError();
+    return m->engine()->currentContext()->throwTypeError();
 }
 
 ReturnedValue Managed::getLookup(Managed *m, Lookup *)
 {
-    return m->engine()->current->throwTypeError();
+    return m->engine()->currentContext()->throwTypeError();
 }
 
 void Managed::setLookup(Managed *m, Lookup *, const ValueRef)
 {
-    m->engine()->current->throwTypeError();
+    m->engine()->currentContext()->throwTypeError();
 }
 
 bool Managed::isEqualTo(Managed *, Managed *)
index 388c71d..cee0614 100644 (file)
@@ -158,7 +158,7 @@ protected:
     Managed(InternalClass *internal)
         : _data(0), internalClass(internal)
     {
-        Q_ASSERT(internalClass->vtable);
+        Q_ASSERT(!internalClass || internalClass->vtable);
         inUse = 1; extensible = 1;
     }
 
index e2b3b6e..106525d 100644 (file)
@@ -168,8 +168,8 @@ void Object::putValue(Property *pd, PropertyAttributes attrs, const ValueRef val
     return;
 
   reject:
-    if (engine()->current->strictMode)
-        engine()->current->throwTypeError();
+    if (engine()->currentContext()->strictMode)
+        engine()->currentContext()->throwTypeError();
 }
 
 void Object::defineDefaultProperty(const StringRef name, ValueRef value)
@@ -720,7 +720,7 @@ void Object::internalPut(const StringRef name, const ValueRef value)
             bool ok;
             uint l = value->asArrayLength(&ok);
             if (!ok) {
-                engine()->current->throwRangeError(value);
+                engine()->currentContext()->throwRangeError(value);
                 return;
             }
             ok = setArrayLength(l);
@@ -768,11 +768,11 @@ void Object::internalPut(const StringRef name, const ValueRef value)
     }
 
   reject:
-    if (engine()->current->strictMode) {
+    if (engine()->currentContext()->strictMode) {
         QString message = QStringLiteral("Cannot assign to read-only property \"");
         message += name->toQString();
         message += QLatin1Char('\"');
-        engine()->current->throwTypeError(message);
+        engine()->currentContext()->throwTypeError(message);
     }
 }
 
@@ -843,8 +843,8 @@ void Object::internalPutIndexed(uint index, const ValueRef value)
     return;
 
   reject:
-    if (engine()->current->strictMode)
-        engine()->current->throwTypeError();
+    if (engine()->currentContext()->strictMode)
+        engine()->currentContext()->throwTypeError();
 }
 
 // Section 8.12.7
@@ -866,8 +866,8 @@ bool Object::internalDeleteProperty(const StringRef name)
             memmove(memberData + memberIdx, memberData + memberIdx + 1, (internalClass->size - memberIdx)*sizeof(Property));
             return true;
         }
-        if (engine()->current->strictMode)
-            engine()->current->throwTypeError();
+        if (engine()->currentContext()->strictMode)
+            engine()->currentContext()->throwTypeError();
         return false;
     }
 
@@ -896,8 +896,8 @@ bool Object::internalDeleteIndexedProperty(uint index)
         return true;
     }
 
-    if (engine()->current->strictMode)
-        engine()->current->throwTypeError();
+    if (engine()->currentContext()->strictMode)
+        engine()->currentContext()->throwTypeError();
     return false;
 }
 
index a39b3d9..7ca790b 100644 (file)
@@ -92,14 +92,14 @@ ReturnedValue ObjectCtor::construct(Managed *that, CallData *callData)
             obj->setPrototype(proto.getPointer());
         return obj.asReturnedValue();
     }
-    return __qmljs_to_object(v4->current, ValueRef(&callData->args[0]));
+    return __qmljs_to_object(v4->currentContext(), ValueRef(&callData->args[0]));
 }
 
 ReturnedValue ObjectCtor::call(Managed *m, CallData *callData)
 {
     if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull())
         return m->engine()->newObject()->asReturnedValue();
-    return __qmljs_to_object(m->engine()->current, ValueRef(&callData->args[0]));
+    return __qmljs_to_object(m->engine()->currentContext(), ValueRef(&callData->args[0]));
 }
 
 void ObjectPrototype::init(ExecutionEngine *v4, ObjectRef ctor)
index 6696be9..61f92a0 100644 (file)
@@ -668,7 +668,7 @@ QV4::ReturnedValue QObjectWrapper::get(Managed *m, const StringRef name, bool *h
     QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
     ExecutionEngine *v4 = m->engine();
     QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4);
-    return that->getQmlProperty(v4->current, qmlContext, name.getPointer(), IgnoreRevision, hasProperty, /*includeImports*/ true);
+    return that->getQmlProperty(v4->currentContext(), qmlContext, name.getPointer(), IgnoreRevision, hasProperty, /*includeImports*/ true);
 }
 
 void QObjectWrapper::put(Managed *m, const StringRef name, const ValueRef value)
@@ -680,10 +680,10 @@ void QObjectWrapper::put(Managed *m, const StringRef name, const ValueRef value)
         return;
 
     QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4);
-    if (!setQmlProperty(v4->current, qmlContext, that->m_object, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value)) {
+    if (!setQmlProperty(v4->currentContext(), qmlContext, that->m_object, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value)) {
         QString error = QLatin1String("Cannot assign to non-existent property \"") +
                         name->toQString() + QLatin1Char('\"');
-        v4->current->throwError(error);
+        v4->currentContext()->throwError(error);
     }
 }
 
@@ -763,7 +763,7 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
             Q_ASSERT(v4);
             QV4::Scope scope(v4);
             QV4::ScopedFunctionObject f(scope, This->function.value());
-            QV4::ExecutionContext *ctx = v4->current;
+            QV4::ExecutionContext *ctx = v4->currentContext();
 
             QV4::ScopedCallData callData(scope, argCount);
             callData->thisObject = This->thisObject.isUndefined() ? v4->globalObject->asReturnedValue() : This->thisObject.value();
@@ -1337,7 +1337,7 @@ static QV4::ReturnedValue CallPrecise(QObject *object, const QQmlPropertyData &d
     if (returnType == QMetaType::UnknownType) {
         QString typeName = QString::fromLatin1(unknownTypeError);
         QString error = QString::fromLatin1("Unknown method return type: %1").arg(typeName);
-        return QV8Engine::getV4(engine)->current->throwError(error);
+        return QV8Engine::getV4(engine)->currentContext()->throwError(error);
     }
 
     if (data.hasArguments()) {
@@ -1351,12 +1351,12 @@ static QV4::ReturnedValue CallPrecise(QObject *object, const QQmlPropertyData &d
         if (!args) {
             QString typeName = QString::fromLatin1(unknownTypeError);
             QString error = QString::fromLatin1("Unknown method parameter type: %1").arg(typeName);
-            return QV8Engine::getV4(engine)->current->throwError(error);
+            return QV8Engine::getV4(engine)->currentContext()->throwError(error);
         }
 
         if (args[0] > callArgs->argc) {
             QString error = QLatin1String("Insufficient arguments");
-            return QV8Engine::getV4(engine)->current->throwError(error);
+            return QV8Engine::getV4(engine)->currentContext()->throwError(error);
         }
 
         return CallMethod(object, data.coreIndex, returnType, args[0], args + 1, engine, callArgs);
@@ -1455,7 +1455,7 @@ static QV4::ReturnedValue CallOverloaded(QObject *object, const QQmlPropertyData
             candidate = RelatedMethod(object, candidate, dummy);
         }
 
-        return QV8Engine::getV4(engine)->current->throwError(error);
+        return QV8Engine::getV4(engine)->currentContext()->throwError(error);
     }
 }
 
@@ -1782,7 +1782,7 @@ ReturnedValue QObjectMethod::call(Managed *m, CallData *callData)
 
 ReturnedValue QObjectMethod::callInternal(CallData *callData)
 {
-    ExecutionContext *context = engine()->current;
+    ExecutionContext *context = engine()->currentContext();
     if (m_index == DestroyMethod)
         return method_destroy(context, callData->args, callData->argc);
     else if (m_index == ToStringMethod)
index 3b69c92..468fb34 100644 (file)
@@ -242,7 +242,7 @@ RegExpCtor::RegExpCtor(ExecutionContext *scope)
 
 ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
 {
-    ExecutionContext *ctx = m->engine()->current;
+    ExecutionContext *ctx = m->engine()->currentContext();
     Scope scope(ctx);
 
     ScopedValue r(scope, callData->argument(0));
index 62923b9..011607f 100644 (file)
@@ -314,7 +314,7 @@ QV4::ReturnedValue __qmljs_instanceof(ExecutionContext *ctx, const ValueRef left
 
     Scoped<Object> o(scope, f->protoProperty());
     if (!o) {
-        scope.engine->current->throwTypeError();
+        scope.engine->currentContext()->throwTypeError();
         return Encode(false);
     }
 
@@ -389,7 +389,7 @@ ReturnedValue __qmljs_object_default_value(Object *object, int typeHint)
     if (typeHint == NUMBER_HINT)
         qSwap(meth1, meth2);
 
-    ExecutionContext *ctx = engine->current;
+    ExecutionContext *ctx = engine->currentContext();
     Scope scope(ctx);
     ScopedCallData callData(scope, 0);
     callData->thisObject = object;
index d56e705..21f4574 100644 (file)
@@ -231,7 +231,7 @@ struct Scoped
     Scoped(const Scope &scope, const Value &v, _Convert)
     {
         ptr = scope.engine->jsStackTop++;
-        ptr->val = value_convert<T>(scope.engine->current, v);
+        ptr->val = value_convert<T>(scope.engine->currentContext(), v);
 #ifndef QT_NO_DEBUG
         ++scope.size;
 #endif
@@ -278,7 +278,7 @@ struct Scoped
     Scoped(const Scope &scope, const ReturnedValue &v, _Convert)
     {
         ptr = scope.engine->jsStackTop++;
-        ptr->val = value_convert<T>(scope.engine->current, QV4::Value::fromReturnedValue(v));
+        ptr->val = value_convert<T>(scope.engine->currentContext(), QV4::Value::fromReturnedValue(v));
 #ifndef QT_NO_DEBUG
         ++scope.size;
 #endif
index c1f86f9..4fd0569 100644 (file)
@@ -77,7 +77,7 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Objec
 
     defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1));
 
-    qmlContext = scope->engine->current->newQmlContext(this, qml);
+    qmlContext = scope->engine->currentContext()->newQmlContext(this, qml);
     scope->engine->popContext();
 }
 
@@ -97,7 +97,7 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml)
 
     defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1));
 
-    qmlContext = scope->engine->current->newQmlContext(this, qml);
+    qmlContext = scope->engine->currentContext()->newQmlContext(this, qml);
     scope->engine->popContext();
 }
 
@@ -242,7 +242,7 @@ void Script::parse()
     if (!vmFunction) {
         // ### FIX file/line number
         Scoped<Object> error(valueScope, v4->newSyntaxErrorObject(QStringLiteral("Syntax error")));
-        v4->current->throwError(error);
+        v4->currentContext()->throwError(error);
     }
 }
 
@@ -377,7 +377,7 @@ QV4::ReturnedValue Script::evaluate(ExecutionEngine *engine,  const QString &scr
     QV4::Scope scope(engine);
     QV4::Script qmlScript(engine, scopeObject, script, QString());
 
-    QV4::ExecutionContext *ctx = engine->current;
+    QV4::ExecutionContext *ctx = engine->currentContext();
     qmlScript.parse();
     QV4::ScopedValue result(scope);
     if (!scope.engine->hasException)
index 1389632..8b0e31c 100644 (file)
@@ -206,7 +206,7 @@ public:
     {
         /* Qt containers have int (rather than uint) allowable indexes. */
         if (index > INT_MAX) {
-            generateWarning(engine()->current, QLatin1String("Index out of range during indexed get"));
+            generateWarning(engine()->currentContext(), QLatin1String("Index out of range during indexed get"));
             if (hasProperty)
                 *hasProperty = false;
             return Encode::undefined();
@@ -237,7 +237,7 @@ public:
 
         /* Qt containers have int (rather than uint) allowable indexes. */
         if (index > INT_MAX) {
-            generateWarning(engine()->current, QLatin1String("Index out of range during indexed set"));
+            generateWarning(engine()->currentContext(), QLatin1String("Index out of range during indexed set"));
             return;
         }
 
@@ -275,7 +275,7 @@ public:
     {
         /* Qt containers have int (rather than uint) allowable indexes. */
         if (index > INT_MAX) {
-            generateWarning(engine()->current, QLatin1String("Index out of range during indexed query"));
+            generateWarning(engine()->currentContext(), QLatin1String("Index out of range during indexed query"));
             return QV4::Attr_Invalid;
         }
         if (m_isReference) {
index 06a2603..ee325db 100644 (file)
@@ -279,7 +279,7 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, QV8Engine *en
             s = properties->getIndexed(ii);
             serialize(data, s, engine);
 
-            QV4::ExecutionContext *ctx = v4->current;
+            QV4::ExecutionContext *ctx = v4->currentContext();
             str = s;
             val = o->get(str);
             if (scope.hasException())
index 57c59fe..d468fb6 100644 (file)
@@ -125,13 +125,13 @@ bool StringObject::deleteIndexedProperty(Managed *m, uint index)
     Scope scope(v4);
     Scoped<StringObject> o(scope, m->asStringObject());
     if (!o) {
-        v4->current->throwTypeError();
+        v4->currentContext()->throwTypeError();
         return false;
     }
 
     if (index < static_cast<uint>(o->value.stringValue()->toQString().length())) {
-        if (v4->current->strictMode)
-            v4->current->throwTypeError();
+        if (v4->currentContext()->strictMode)
+            v4->currentContext()->throwTypeError();
         return false;
     }
     return true;
@@ -181,7 +181,7 @@ ReturnedValue StringCtor::construct(Managed *m, CallData *callData)
     Scope scope(v4);
     ScopedValue value(scope);
     if (callData->argc)
-        value = callData->args[0].toString(v4->current);
+        value = callData->args[0].toString(v4->currentContext());
     else
         value = v4->newString(QString());
     return Encode(v4->newStringObject(value));
@@ -193,7 +193,7 @@ ReturnedValue StringCtor::call(Managed *m, CallData *callData)
     Scope scope(v4);
     ScopedValue value(scope);
     if (callData->argc)
-        value = callData->args[0].toString(v4->current);
+        value = callData->args[0].toString(v4->currentContext());
     else
         value = v4->newString(QString());
     return value.asReturnedValue();
index 4ae570c..30f7e8c 100644 (file)
@@ -90,7 +90,7 @@ double Value::toNumberImpl() const
         if (isString())
             return __qmljs_string_to_number(stringValue()->toQString());
         {
-            ExecutionContext *ctx = objectValue()->internalClass->engine->current;
+            ExecutionContext *ctx = objectValue()->internalClass->engine->currentContext();
             Scope scope(ctx);
             ScopedValue prim(scope, __qmljs_to_primitive(ValueRef::fromRawValue(this), NUMBER_HINT));
             return prim->toNumber();
@@ -121,7 +121,7 @@ QString Value::toQStringNoThrow() const
         if (isString())
             return stringValue()->toQString();
         {
-            ExecutionContext *ctx = objectValue()->internalClass->engine->current;
+            ExecutionContext *ctx = objectValue()->internalClass->engine->currentContext();
             Scope scope(ctx);
             ScopedValue ex(scope);
             bool caughtException = false;
@@ -174,7 +174,7 @@ QString Value::toQString() const
         if (isString())
             return stringValue()->toQString();
         {
-            ExecutionContext *ctx = objectValue()->internalClass->engine->current;
+            ExecutionContext *ctx = objectValue()->internalClass->engine->currentContext();
             Scope scope(ctx);
             ScopedValue prim(scope, __qmljs_to_primitive(ValueRef::fromRawValue(this), STRING_HINT));
             return prim->toQString();
index ffdc808..4a71c1a 100644 (file)
@@ -1546,7 +1546,7 @@ void QmlIncubatorObject::statusChanged(QQmlIncubator::Status s)
 
     QV4::ScopedFunctionObject f(scope, m_statusChanged);
     if (f) {
-        QV4::ExecutionContext *ctx = scope.engine->current;
+        QV4::ExecutionContext *ctx = scope.engine->currentContext();
         QV4::ScopedCallData callData(scope, 1);
         callData->thisObject = this;
         callData->args[0] = QV4::Primitive::fromUInt32(s);
index 2814b2b..b3c2105 100644 (file)
@@ -137,7 +137,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has
     QV4::Scope scope(v4);
     QmlContextWrapper *resource = m->as<QmlContextWrapper>();
     if (!resource)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
     // In V8 the JS global object would come _before_ the QML global object,
     // so simulate that here.
@@ -246,7 +246,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has
         // Search scope object
         if (scopeObject) {
             bool hasProp = false;
-            QV4::ScopedValue result(scope, QV4::QObjectWrapper::getQmlProperty(v4->current, context, scopeObject,
+            QV4::ScopedValue result(scope, QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, scopeObject,
                                                                                name.getPointer(), QV4::QObjectWrapper::CheckRevision, &hasProp));
             if (hasProp) {
                 if (hasProperty)
@@ -260,7 +260,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has
         // Search context object
         if (context->contextObject) {
             bool hasProp = false;
-            result = QV4::QObjectWrapper::getQmlProperty(v4->current, context, context->contextObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, &hasProp);
+            result = QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, context->contextObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, &hasProp);
             if (hasProp) {
                 if (hasProperty)
                     *hasProperty = true;
@@ -284,7 +284,7 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val
         return;
     QV4::Scoped<QmlContextWrapper> wrapper(scope, m->as<QmlContextWrapper>());
     if (!wrapper) {
-        v4->current->throwTypeError();
+        v4->currentContext()->throwTypeError();
         return;
     }
 
@@ -292,8 +292,8 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val
         if (wrapper && wrapper->readOnly) {
             QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
                             QLatin1Char('"');
-            Scoped<String> e(scope, v4->current->engine->newString(error));
-            v4->current->throwError(e);
+            Scoped<String> e(scope, v4->currentContext()->engine->newString(error));
+            v4->currentContext()->throwError(e);
             return;
         }
 
@@ -327,13 +327,13 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val
 
         // Search scope object
         if (scopeObject &&
-            QV4::QObjectWrapper::setQmlProperty(v4->current, context, scopeObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, value))
+            QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, scopeObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, value))
             return;
         scopeObject = 0;
 
         // Search context object
         if (context->contextObject &&
-            QV4::QObjectWrapper::setQmlProperty(v4->current, context, context->contextObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, value))
+            QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, context->contextObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, value))
             return;
 
         context = context->parent;
@@ -344,7 +344,7 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val
     if (wrapper->readOnly) {
         QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
                         QLatin1Char('"');
-        v4->current->throwError(error);
+        v4->currentContext()->throwError(error);
         return;
     }
 
index 3fd0003..499ade1 100644 (file)
@@ -155,7 +155,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
     QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
     QV4::Scope scope(v4);
     QV4::ScopedValue result(scope, QV4::Primitive::undefinedValue());
-    QV4::ExecutionContext *ctx = v4->current;
+    QV4::ExecutionContext *ctx = v4->currentContext();
     callData->thisObject = v4->globalObject;
     if (scopeObject()) {
         QV4::ScopedValue value(scope, QV4::QObjectWrapper::wrap(ctx->engine, scopeObject()));
@@ -294,7 +294,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje
     QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
 
     QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
-    QV4::ExecutionContext *ctx = v4->current;
+    QV4::ExecutionContext *ctx = v4->currentContext();
     QV4::Scope scope(v4);
 
     QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(ep->v8engine(), ctxt, scopeObject));
@@ -328,7 +328,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::qmlBinding(QQmlContextData *ctxt, Q
     QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
 
     QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
-    QV4::ExecutionContext *ctx = v4->current;
+    QV4::ExecutionContext *ctx = v4->currentContext();
     QV4::Scope scope(v4);
 
     QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(ep->v8engine(), ctxt, qmlScope));
index 2b3fcd8..7b975c2 100644 (file)
@@ -106,7 +106,7 @@ ReturnedValue QmlListWrapper::get(Managed *m, const StringRef name, bool *hasPro
     QV4::ExecutionEngine *v4 = m->engine();
     QmlListWrapper *w = m->as<QmlListWrapper>();
     if (!w)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
     if (name->equals(v4->id_length) && !w->object.isNull()) {
         quint32 count = w->property.count ? w->property.count(&w->property) : 0;
@@ -127,7 +127,7 @@ ReturnedValue QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProper
     QV4::ExecutionEngine *e = m->engine();
     QmlListWrapper *w = m->as<QmlListWrapper>();
     if (!w)
-        return e->current->throwTypeError();
+        return e->currentContext()->throwTypeError();
 
     quint32 count = w->property.count ? w->property.count(&w->property) : 0;
     if (index < count && w->property.at)
index 911761d..de100fd 100644 (file)
@@ -2806,7 +2806,7 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare
     QV4::ScopedValue qmlglobal(scope, QV4::QmlContextWrapper::qmlScope(v8engine, ctxt, 0));
     QV4::QmlContextWrapper::takeContextOwnership(qmlglobal);
 
-    QV4::ExecutionContext *ctx = QV8Engine::getV4(v8engine)->current;
+    QV4::ExecutionContext *ctx = QV8Engine::getV4(v8engine)->currentContext();
     m_program->qml = qmlglobal;
     m_program->run();
     if (scope.engine->hasException) {
index db594e1..9c350a5 100644 (file)
@@ -126,7 +126,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasPro
 
     Scoped<QmlTypeWrapper> w(scope,  m->as<QmlTypeWrapper>());
     if (!w)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
 
     if (hasProperty)
@@ -165,7 +165,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasPro
                 }
 
                 // check for property.
-                return QV4::QObjectWrapper::getQmlProperty(v4->current, context, qobjectSingleton, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, hasProperty);
+                return QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, qobjectSingleton, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, hasProperty);
             } else if (!siinfo->scriptApi(e).isUndefined()) {
                 // NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable.
                 QV4::ScopedObject o(scope, QJSValuePrivate::get(siinfo->scriptApi(e))->getValue(v4));
@@ -188,7 +188,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasPro
             } else if (w->object) {
                 QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
                 if (ao)
-                    return QV4::QObjectWrapper::getQmlProperty(v4->current, context, ao, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, hasProperty);
+                    return QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), context, ao, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, hasProperty);
 
                 // Fall through to base implementation
             }
@@ -236,7 +236,7 @@ void QmlTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value)
     if (v4->hasException)
         return;
     if (!w) {
-        v4->current->throwTypeError();
+        v4->currentContext()->throwTypeError();
         return;
     }
 
@@ -249,7 +249,7 @@ void QmlTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value)
         QObject *object = w->object;
         QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
         if (ao) 
-            QV4::QObjectWrapper::setQmlProperty(v4->current, context, ao, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value);
+            QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, ao, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value);
     } else if (type && type->isSingleton()) {
         QQmlEngine *e = v8engine->engine();
         QQmlType::SingletonInstanceInfo *siinfo = type->singletonInstanceInfo();
@@ -257,12 +257,12 @@ void QmlTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value)
 
         QObject *qobjectSingleton = siinfo->qobjectApi(e);
         if (qobjectSingleton) {
-            QV4::QObjectWrapper::setQmlProperty(v4->current, context, qobjectSingleton, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value);
+            QV4::QObjectWrapper::setQmlProperty(v4->currentContext(), context, qobjectSingleton, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, value);
         } else if (!siinfo->scriptApi(e).isUndefined()) {
             QV4::ScopedObject apiprivate(scope, QJSValuePrivate::get(siinfo->scriptApi(e))->value);
             if (!apiprivate) {
                 QString error = QLatin1String("Cannot assign to read-only property \"") + name->toQString() + QLatin1Char('\"');
-                v4->current->throwError(error);
+                v4->currentContext()->throwError(error);
                 return;
             } else {
                 apiprivate->put(name, value);
index 341daf2..50d7cbc 100644 (file)
@@ -209,7 +209,7 @@ PropertyAttributes QmlValueTypeWrapper::query(const Managed *m, StringRef name)
     const QmlValueTypeWrapper *r = m->as<const QmlValueTypeWrapper>();
     QV4::ExecutionEngine *v4 = m->engine();
     if (!r) {
-        v4->current->throwTypeError();
+        v4->currentContext()->throwTypeError();
         return PropertyAttributes();
     }
 
@@ -273,7 +273,7 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, const StringRef name, bool *h
     QmlValueTypeWrapper *r = m->as<QmlValueTypeWrapper>();
     QV4::ExecutionEngine *v4 = m->engine();
     if (!r)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
     // Note: readReferenceValue() can change the reference->type.
     if (r->objectType == QmlValueTypeWrapper::Reference) {
@@ -306,7 +306,7 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, const StringRef name, bool *h
     if (result->isFunction()) {
         // calling a Q_INVOKABLE function of a value type
         QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4);
-        return QV4::QObjectWrapper::getQmlProperty(v4->current, qmlContext, r->type, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision);
+        return QV4::QObjectWrapper::getQmlProperty(v4->currentContext(), qmlContext, r->type, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision);
     }
 
 #define VALUE_TYPE_LOAD(metatype, cpptype, constructor) \
@@ -339,7 +339,7 @@ void QmlValueTypeWrapper::put(Managed *m, const StringRef name, const ValueRef v
 
     Scoped<QmlValueTypeWrapper> r(scope, m->as<QmlValueTypeWrapper>());
     if (!r) {
-        v4->current->throwTypeError();
+        v4->currentContext()->throwTypeError();
         return;
     }
 
@@ -365,7 +365,7 @@ void QmlValueTypeWrapper::put(Managed *m, const StringRef name, const ValueRef v
                 // assigning a JS function to a non-var-property is not allowed.
                 QString error = QLatin1String("Cannot assign JavaScript function to value-type property");
                 Scoped<String> e(scope, r->v8->toString(error));
-                v4->current->throwError(e);
+                v4->currentContext()->throwError(e);
                 return;
             }
 
index 4b34792..ebe72b2 100644 (file)
@@ -956,7 +956,7 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
                     callData->args[ii] = ep->v8engine()->fromVariant(*(QVariant *)a[ii + 1]);
 
                 QV4::ScopedValue result(scope);
-                QV4::ExecutionContext *ctx = function->engine()->current;
+                QV4::ExecutionContext *ctx = function->engine()->currentContext();
                 result = function->call(callData);
                 if (scope.hasException()) {
                     QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
index e31b1c4..ad231d0 100644 (file)
@@ -906,7 +906,7 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty
     QV4::ExecutionEngine *v4 = m->engine();
     NamedNodeMap *r = m->as<NamedNodeMap>();
     if (!r)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
     QV8Engine *engine = v4->v8Engine;
 
@@ -925,7 +925,7 @@ ReturnedValue NamedNodeMap::get(Managed *m, const StringRef name, bool *hasPrope
     NamedNodeMap *r = m->as<NamedNodeMap>();
     QV4::ExecutionEngine *v4 = m->engine();
     if (!r)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
     name->makeIdentifier();
     if (name->equals(v4->id_length))
@@ -961,7 +961,7 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
     QV4::ExecutionEngine *v4 = m->engine();
     NodeList *r = m->as<NodeList>();
     if (!r)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
     QV8Engine *engine = v4->v8Engine;
 
@@ -980,7 +980,7 @@ ReturnedValue NodeList::get(Managed *m, const StringRef name, bool *hasProperty)
     QV4::ExecutionEngine *v4 = m->engine();
     NodeList *r = m->as<NodeList>();
     if (!r)
-        return v4->current->throwTypeError();
+        return v4->currentContext()->throwTypeError();
 
     name->makeIdentifier();
 
@@ -1535,7 +1535,7 @@ const QByteArray &QQmlXMLHttpRequest::rawResponseBody() const
 
 void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me)
 {
-    ExecutionContext *ctx = v4->current;
+    ExecutionContext *ctx = v4->currentContext();
     QV4::Scope scope(v4);
     Scoped<Object> o(scope, me);
     if (!o) {
@@ -1560,7 +1560,7 @@ void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me)
     s = v4->newString(QStringLiteral("ActivationObject"));
     Scoped<Object> activationObject(scope, o->get(s));
     if (!activationObject) {
-        v4->current->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject"));
+        v4->currentContext()->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject"));
         return;
     }
 
@@ -1580,7 +1580,7 @@ void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me)
 
 void QQmlXMLHttpRequest::dispatchCallback(const ValueRef me)
 {
-    ExecutionContext *ctx = v4->current;
+    ExecutionContext *ctx = v4->currentContext();
     dispatchCallbackImpl(me);
     if (v4->hasException) {
         QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
@@ -1656,7 +1656,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
         Scope scope(that->engine());
         Scoped<QQmlXMLHttpRequestCtor> ctor(scope, that->as<QQmlXMLHttpRequestCtor>());
         if (!ctor)
-            return that->engine()->current->throwTypeError();
+            return that->engine()->currentContext()->throwTypeError();
 
         QV8Engine *engine = that->engine()->v8Engine;
         QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager());
index d0fc1b1..e41a91e 100644 (file)
@@ -256,7 +256,7 @@ QV4::ReturnedValue QV8Engine::fromVariant(const QVariant &variant)
             case QMetaType::Double:
                 return QV4::Encode(*reinterpret_cast<const double*>(ptr));
             case QMetaType::QString:
-                return m_v4Engine->current->engine->newString(*reinterpret_cast<const QString*>(ptr))->asReturnedValue();
+                return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast<const QString*>(ptr))->asReturnedValue();
             case QMetaType::Float:
                 return QV4::Encode(*reinterpret_cast<const float*>(ptr));
             case QMetaType::Short:
@@ -667,7 +667,7 @@ QV4::ReturnedValue QV8Engine::metaTypeToJS(int type, const void *data)
     case QMetaType::Double:
         return QV4::Encode(*reinterpret_cast<const double*>(data));
     case QMetaType::QString:
-        return m_v4Engine->current->engine->newString(*reinterpret_cast<const QString*>(data))->asReturnedValue();
+        return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast<const QString*>(data))->asReturnedValue();
     case QMetaType::Float:
         return QV4::Encode(*reinterpret_cast<const float*>(data));
     case QMetaType::Short:
@@ -750,7 +750,7 @@ bool QV8Engine::metaTypeFromJS(const QV4::ValueRef value, int type, void *data)
         if (value->isUndefined() || value->isNull())
             *reinterpret_cast<QString*>(data) = QString();
         else
-            *reinterpret_cast<QString*>(data) = value->toString(m_v4Engine->current)->toQString();
+            *reinterpret_cast<QString*>(data) = value->toString(m_v4Engine->currentContext())->toQString();
         return true;
     case QMetaType::Float:
         *reinterpret_cast<float*>(data) = value->toNumber();
index 19e2a40..7276c0e 100644 (file)
@@ -76,7 +76,7 @@ struct DelegateModelGroupFunction: QV4::FunctionObject
 
     static QV4::ReturnedValue construct(QV4::Managed *m, QV4::CallData *)
     {
-        return m->engine()->current->throwTypeError();
+        return m->engine()->currentContext()->throwTypeError();
     }
 
     static QV4::ReturnedValue call(QV4::Managed *that, QV4::CallData *callData)
@@ -86,7 +86,7 @@ struct DelegateModelGroupFunction: QV4::FunctionObject
         QV4::Scoped<DelegateModelGroupFunction> f(scope, that, QV4::Scoped<DelegateModelGroupFunction>::Cast);
         QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject);
         if (!o)
-            return v4->current->throwTypeError(QStringLiteral("Not a valid VisualData object"));
+            return v4->currentContext()->throwTypeError(QStringLiteral("Not a valid VisualData object"));
 
         QV4::ScopedValue v(scope, callData->argument(0));
         return f->code(o->item, f->flag, v);
@@ -3197,7 +3197,7 @@ public:
         QV4::Scope scope(v4);
         QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, m->as<QQmlDelegateModelGroupChangeArray>());
         if (!array)
-            return v4->current->throwTypeError();
+            return v4->currentContext()->throwTypeError();
 
         if (index >= array->count()) {
             if (hasProperty)
@@ -3221,7 +3221,7 @@ public:
     {
         QQmlDelegateModelGroupChangeArray *array = m->as<QQmlDelegateModelGroupChangeArray>();
         if (!array)
-            return m->engine()->current->throwTypeError();
+            return m->engine()->currentContext()->throwTypeError();
 
         if (name->equals(m->engine()->id_length)) {
             if (hasProperty)
index 7607feb..53e45e2 100644 (file)
@@ -252,7 +252,7 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(i
 
     QV4::Scope scope(v4);
     QV4::ScopedFunctionObject f(scope, createsend.value());
-    QV4::ExecutionContext *ctx = v4->current;
+    QV4::ExecutionContext *ctx = v4->currentContext();
 
     QV4::ScopedValue v(scope);
     QV4::ScopedCallData callData(scope, 1);
@@ -356,7 +356,7 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d
     QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
     QV4::Scope scope(v4);
     QV4::ScopedFunctionObject f(scope, workerEngine->onmessage.value());
-    QV4::ExecutionContext *ctx = v4->current;
+    QV4::ExecutionContext *ctx = v4->currentContext();
 
     QV4::ScopedValue value(scope, QV4::Serialize::deserialize(data, workerEngine));
 
@@ -398,7 +398,7 @@ void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
 
         QV4::Script program(v4, activation, sourceCode, url.toString());
 
-        QV4::ExecutionContext *ctx = v4->current;
+        QV4::ExecutionContext *ctx = v4->currentContext();
         program.parse();
         if (!v4->hasException)
             program.run();
index 2bc9df3..b6eb2db 100644 (file)
@@ -3165,7 +3165,7 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint
     QV4::Scope scope(v4);
     QV4::Scoped<QQuickJSContext2DPixelData> r(scope, m->as<QQuickJSContext2DPixelData>());
     if (!m)
-        return m->engine()->current->throwTypeError();
+        return m->engine()->currentContext()->throwTypeError();
 
     if (r && index < static_cast<quint32>(r->image.width() * r->image.height() * 4)) {
         if (hasProperty)
@@ -3200,7 +3200,7 @@ void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const Q
 
     QV4::Scoped<QQuickJSContext2DPixelData> r(scope, m->as<QQuickJSContext2DPixelData>());
     if (!r) {
-        v4->current->throwTypeError();
+        v4->currentContext()->throwTypeError();
         return;
     }
 
index 41fa367..22fac20 100644 (file)
@@ -106,7 +106,7 @@ public:
 
 void MyQmlObject::v8function(QQmlV4Function *function)
 {
-    QV8Engine::getV4(function->engine())->current->throwError(QStringLiteral("Exception thrown from within QObject slot"));
+    QV8Engine::getV4(function->engine())->currentContext()->throwError(QStringLiteral("Exception thrown from within QObject slot"));
 }
 
 static QJSValue script_api(QQmlEngine *engine, QJSEngine *scriptEngine)
index 660be13..1e18e3c 100644 (file)
@@ -2267,7 +2267,7 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::ValueRef o, cons
     QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource);
     program.inheritContext = true;
 
-    QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current;
+    QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->currentContext();
     QV4::Scope scope(ctx);
 
     QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
@@ -2295,7 +2295,7 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o,
     QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource);
     program.inheritContext = true;
 
-    QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current;
+    QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->currentContext();
     QV4::Scope scope(ctx);
 
     QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
@@ -2324,7 +2324,7 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef
     QString functionSource = QLatin1String("(function(object) { return ") + 
                              QLatin1String(source) + QLatin1String(" })");
 
-    QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current;
+    QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->currentContext();
     QV4::Scope scope(ctx);
 
     QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource);