Get rid of all uses of Managed::engine()
authorLars Knoll <lars.knoll@theqtcompany.com>
Sun, 11 Jan 2015 15:30:29 +0000 (16:30 +0100)
committerLars Knoll <lars.knoll@digia.com>
Wed, 21 Jan 2015 12:18:55 +0000 (13:18 +0100)
Change-Id: I596f14554d81f5e9af9996294d96047f2e810bef
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
31 files changed:
src/imports/localstorage/plugin.cpp
src/qml/jsruntime/qv4argumentsobject.cpp
src/qml/jsruntime/qv4arraybuffer.cpp
src/qml/jsruntime/qv4arrayobject.cpp
src/qml/jsruntime/qv4booleanobject.cpp
src/qml/jsruntime/qv4context_p.h
src/qml/jsruntime/qv4dataview.cpp
src/qml/jsruntime/qv4dateobject.cpp
src/qml/jsruntime/qv4errorobject.cpp
src/qml/jsruntime/qv4functionobject.cpp
src/qml/jsruntime/qv4functionobject_p.h
src/qml/jsruntime/qv4managed.cpp
src/qml/jsruntime/qv4managed_p.h
src/qml/jsruntime/qv4numberobject.cpp
src/qml/jsruntime/qv4object.cpp
src/qml/jsruntime/qv4objectproto.cpp
src/qml/jsruntime/qv4qobjectwrapper.cpp
src/qml/jsruntime/qv4regexpobject.cpp
src/qml/jsruntime/qv4script.cpp
src/qml/jsruntime/qv4stringobject.cpp
src/qml/jsruntime/qv4typedarray.cpp
src/qml/jsruntime/qv4value.cpp
src/qml/qml/qqmlcontextwrapper.cpp
src/qml/qml/qqmllistwrapper.cpp
src/qml/qml/qqmltypewrapper.cpp
src/qml/qml/qqmlvaluetypewrapper.cpp
src/qml/qml/qqmlxmlhttprequest.cpp
src/qml/qml/v8/qqmlbuiltinfunctions.cpp
src/qml/types/qqmldelegatemodel.cpp
src/quick/items/context2d/qquickcontext2d.cpp
tools/qmljs/qmljs.cpp

index 2de47b2..5b99783 100644 (file)
@@ -240,13 +240,13 @@ static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, Execut
 
 ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(Managed *m, uint index, bool *hasProperty)
 {
-    QV4::Scope scope(m->engine());
+    QV4::Scope scope(static_cast<QQmlSqlDatabaseWrapper *>(m)->engine());
     Q_ASSERT(m->as<QQmlSqlDatabaseWrapper>());
     QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, static_cast<QQmlSqlDatabaseWrapper *>(m));
     if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
         return Object::getIndexed(m, index, hasProperty);
 
-    return qmlsqldatabase_rows_index(r, m->engine(), index, hasProperty);
+    return qmlsqldatabase_rows_index(r, scope.engine, index, hasProperty);
 }
 
 static ReturnedValue qmlsqldatabase_rows_item(CallContext *ctx)
index 48e8bb6..5e00244 100644 (file)
@@ -201,7 +201,7 @@ DEFINE_OBJECT_VTABLE(ArgumentsGetterFunction);
 
 ReturnedValue ArgumentsGetterFunction::call(Managed *getter, CallData *callData)
 {
-    ExecutionEngine *v4 = getter->engine();
+    ExecutionEngine *v4 = static_cast<ArgumentsGetterFunction *>(getter)->engine();
     Scope scope(v4);
     Scoped<ArgumentsGetterFunction> g(scope, static_cast<ArgumentsGetterFunction *>(getter));
     Scoped<ArgumentsObject> o(scope, callData->thisObject.as<ArgumentsObject>());
@@ -216,7 +216,7 @@ DEFINE_OBJECT_VTABLE(ArgumentsSetterFunction);
 
 ReturnedValue ArgumentsSetterFunction::call(Managed *setter, CallData *callData)
 {
-    ExecutionEngine *v4 = setter->engine();
+    ExecutionEngine *v4 = static_cast<ArgumentsSetterFunction *>(setter)->engine();
     Scope scope(v4);
     Scoped<ArgumentsSetterFunction> s(scope, static_cast<ArgumentsSetterFunction *>(setter));
     Scoped<ArgumentsObject> o(scope, callData->thisObject.as<ArgumentsObject>());
index 60ab527..5d2c95b 100644 (file)
@@ -46,7 +46,7 @@ Heap::ArrayBufferCtor::ArrayBufferCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue ArrayBufferCtor::construct(Managed *m, CallData *callData)
 {
-    ExecutionEngine *v4 = m->engine();
+    ExecutionEngine *v4 = static_cast<Object *>(m)->engine();
 
     Scope scope(v4);
     ScopedValue l(scope, callData->argument(0));
index 078b7fe..6c677e8 100644 (file)
@@ -49,7 +49,7 @@ Heap::ArrayCtor::ArrayCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData)
 {
-    ExecutionEngine *v4 = m->engine();
+    ExecutionEngine *v4 = static_cast<ArrayCtor *>(m)->engine();
     Scope scope(v4);
     ScopedArrayObject a(scope, v4->newArrayObject());
     uint len;
index 0b3ae4e..c606e37 100644 (file)
@@ -45,10 +45,10 @@ Heap::BooleanCtor::BooleanCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<BooleanCtor *>(m)->engine());
     bool n = callData->argc ? callData->args[0].toBoolean() : false;
     ScopedValue b(scope, QV4::Primitive::fromBoolean(n));
-    return Encode(m->engine()->newBooleanObject(b));
+    return Encode(scope.engine->newBooleanObject(b));
 }
 
 ReturnedValue BooleanCtor::call(Managed *, CallData *callData)
index 48319c7..0b70677 100644 (file)
@@ -140,6 +140,8 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
     V4_MANAGED(ExecutionContext, Managed)
     Q_MANAGED_TYPE(ExecutionContext)
 
+    ExecutionEngine *engine() const { return d()->engine; }
+
     Heap::CallContext *newCallContext(FunctionObject *f, CallData *callData);
     Heap::WithContext *newWithContext(Object *with);
     Heap::CatchContext *newCatchContext(String *exceptionVarName, const ValueRef exceptionValue);
index f50ce76..55a41a7 100644 (file)
@@ -48,7 +48,7 @@ Heap::DataViewCtor::DataViewCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue DataViewCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<Object *>(m)->engine());
     Scoped<ArrayBuffer> buffer(scope, callData->argument(0));
     if (!buffer)
         return scope.engine->throwTypeError();
index bfc97b1..fde0818 100644 (file)
@@ -650,13 +650,13 @@ Heap::DateCtor::DateCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue DateCtor::construct(Managed *m, CallData *callData)
 {
+    Scope scope(static_cast<DateCtor *>(m)->engine());
     double t = 0;
 
     if (callData->argc == 0)
         t = currentTime();
 
     else if (callData->argc == 1) {
-        Scope scope(m->engine());
         ScopedValue arg(scope, callData->args[0]);
         if (DateObject *d = arg->asDateObject())
             arg = d->date();
@@ -683,13 +683,13 @@ ReturnedValue DateCtor::construct(Managed *m, CallData *callData)
         t = TimeClip(UTC(t));
     }
 
-    return Encode(m->engine()->newDateObject(Primitive::fromDouble(t)));
+    return Encode(scope.engine->newDateObject(Primitive::fromDouble(t)));
 }
 
 ReturnedValue DateCtor::call(Managed *m, CallData *)
 {
     double t = currentTime();
-    return m->engine()->newString(ToString(t))->asReturnedValue();
+    return static_cast<DateCtor *>(m)->engine()->newString(ToString(t))->asReturnedValue();
 }
 
 void DatePrototype::init(ExecutionEngine *engine, Object *ctor)
index bf966e5..30c7fe1 100644 (file)
@@ -257,9 +257,9 @@ Heap::ErrorCtor::ErrorCtor(QV4::ExecutionContext *scope, const QString &name)
 
 ReturnedValue ErrorCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<ErrorCtor *>(m)->engine());
     ScopedValue v(scope, callData->argument(0));
-    return Encode(m->engine()->newErrorObject(v));
+    return Encode(scope.engine->newErrorObject(v));
 }
 
 ReturnedValue ErrorCtor::call(Managed *that, CallData *callData)
@@ -274,9 +274,9 @@ Heap::EvalErrorCtor::EvalErrorCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue EvalErrorCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<EvalErrorCtor *>(m)->engine());
     ScopedValue v(scope, callData->argument(0));
-    return (m->engine()->memoryManager->alloc<EvalErrorObject>(m->engine(), v))->asReturnedValue();
+    return (scope.engine->memoryManager->alloc<EvalErrorObject>(scope.engine, v))->asReturnedValue();
 }
 
 Heap::RangeErrorCtor::RangeErrorCtor(QV4::ExecutionContext *scope)
@@ -286,9 +286,9 @@ Heap::RangeErrorCtor::RangeErrorCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue RangeErrorCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<RangeErrorCtor *>(m)->engine());
     ScopedValue v(scope, callData->argument(0));
-    return (m->engine()->memoryManager->alloc<RangeErrorObject>(scope.engine, v))->asReturnedValue();
+    return (scope.engine->memoryManager->alloc<RangeErrorObject>(scope.engine, v))->asReturnedValue();
 }
 
 Heap::ReferenceErrorCtor::ReferenceErrorCtor(QV4::ExecutionContext *scope)
@@ -298,9 +298,9 @@ Heap::ReferenceErrorCtor::ReferenceErrorCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue ReferenceErrorCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<ReferenceErrorCtor *>(m)->engine());
     ScopedValue v(scope, callData->argument(0));
-    return (m->engine()->memoryManager->alloc<ReferenceErrorObject>(scope.engine, v))->asReturnedValue();
+    return (scope.engine->memoryManager->alloc<ReferenceErrorObject>(scope.engine, v))->asReturnedValue();
 }
 
 Heap::SyntaxErrorCtor::SyntaxErrorCtor(QV4::ExecutionContext *scope)
@@ -310,9 +310,9 @@ Heap::SyntaxErrorCtor::SyntaxErrorCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue SyntaxErrorCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<SyntaxErrorCtor *>(m)->engine());
     ScopedValue v(scope, callData->argument(0));
-    return (m->engine()->memoryManager->alloc<SyntaxErrorObject>(scope.engine, v))->asReturnedValue();
+    return (scope.engine->memoryManager->alloc<SyntaxErrorObject>(scope.engine, v))->asReturnedValue();
 }
 
 Heap::TypeErrorCtor::TypeErrorCtor(QV4::ExecutionContext *scope)
@@ -322,9 +322,9 @@ Heap::TypeErrorCtor::TypeErrorCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue TypeErrorCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<TypeErrorCtor *>(m)->engine());
     ScopedValue v(scope, callData->argument(0));
-    return (m->engine()->memoryManager->alloc<TypeErrorObject>(scope.engine, v))->asReturnedValue();
+    return (scope.engine->memoryManager->alloc<TypeErrorObject>(scope.engine, v))->asReturnedValue();
 }
 
 Heap::URIErrorCtor::URIErrorCtor(QV4::ExecutionContext *scope)
@@ -334,9 +334,9 @@ Heap::URIErrorCtor::URIErrorCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue URIErrorCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<URIErrorCtor *>(m)->engine());
     ScopedValue v(scope, callData->argument(0));
-    return (m->engine()->memoryManager->alloc<URIErrorObject>(scope.engine, v))->asReturnedValue();
+    return (scope.engine->memoryManager->alloc<URIErrorObject>(scope.engine, v))->asReturnedValue();
 }
 
 void ErrorPrototype::init(ExecutionEngine *engine, Object *ctor, Object *obj)
index 5c5674d..4f55929 100644 (file)
@@ -221,7 +221,7 @@ Heap::FunctionCtor::FunctionCtor(QV4::ExecutionContext *scope)
 // 15.3.2
 ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData)
 {
-    Scope scope(that->engine());
+    Scope scope(static_cast<Object *>(that)->engine());
     Scoped<FunctionCtor> f(scope, static_cast<FunctionCtor *>(that));
     ScopedContext ctx(scope, scope.engine->currentContext());
     QString arguments;
@@ -393,7 +393,7 @@ Heap::ScriptFunction::ScriptFunction(QV4::ExecutionContext *scope, Function *fun
 
 ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData)
 {
-    ExecutionEngine *v4 = that->engine();
+    ExecutionEngine *v4 = static_cast<Object *>(that)->engine();
     if (v4->hasException)
         return Encode::undefined();
     CHECK_STACK_LIMITS(v4);
@@ -425,7 +425,7 @@ ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData)
 
 ReturnedValue ScriptFunction::call(Managed *that, CallData *callData)
 {
-    ExecutionEngine *v4 = that->engine();
+    ExecutionEngine *v4 = static_cast<Object *>(that)->engine();
     if (v4->hasException)
         return Encode::undefined();
     CHECK_STACK_LIMITS(v4);
@@ -475,7 +475,7 @@ Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, F
 
 ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData)
 {
-    ExecutionEngine *v4 = that->engine();
+    ExecutionEngine *v4 = static_cast<Object *>(that)->engine();
     if (v4->hasException)
         return Encode::undefined();
     CHECK_STACK_LIMITS(v4);
index c00597d..b971ca6 100644 (file)
@@ -186,7 +186,7 @@ struct IndexedBuiltinFunction: FunctionObject
 
     static ReturnedValue construct(Managed *m, CallData *)
     {
-        return m->engine()->throwTypeError();
+        return static_cast<IndexedBuiltinFunction *>(m)->engine()->throwTypeError();
     }
 
     static ReturnedValue call(Managed *that, CallData *callData);
index b783d70..e2bbda8 100644 (file)
@@ -56,11 +56,6 @@ const ManagedVTable Managed::static_vtbl =
 };
 
 
-ExecutionEngine *Managed::engine() const
-{
-    return internalClass()->engine;
-}
-
 QString Managed::className() const
 {
     const char *s = 0;
index 99d6cda..a237858 100644 (file)
@@ -229,8 +229,6 @@ public:
     };
     Q_MANAGED_TYPE(Invalid)
 
-    ExecutionEngine *engine() const;
-
     template <typename T>
     T *as() {
         Q_ASSERT(internalClass());
index 67bf92d..dcde8f1 100644 (file)
@@ -52,10 +52,10 @@ Heap::NumberCtor::NumberCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue NumberCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<NumberCtor *>(m)->engine());
     double dbl = callData->argc ? callData->args[0].toNumber() : 0.;
     ScopedValue d(scope, QV4::Primitive::fromDouble(dbl));
-    return Encode(m->engine()->newNumberObject(d));
+    return Encode(scope.engine->newNumberObject(d));
 }
 
 ReturnedValue NumberCtor::call(Managed *, CallData *callData)
index 020607a..64cfc24 100644 (file)
@@ -367,12 +367,12 @@ bool Object::hasOwnProperty(uint index) const
 
 ReturnedValue Object::construct(Managed *m, CallData *)
 {
-    return m->engine()->throwTypeError();
+    return static_cast<Object *>(m)->engine()->throwTypeError();
 }
 
 ReturnedValue Object::call(Managed *m, CallData *)
 {
-    return m->engine()->throwTypeError();
+    return static_cast<Object *>(m)->engine()->throwTypeError();
 }
 
 ReturnedValue Object::get(Managed *m, String *name, bool *hasProperty)
@@ -466,7 +466,7 @@ ReturnedValue Object::getLookup(Managed *m, Lookup *l)
 
 void Object::setLookup(Managed *m, Lookup *l, const ValueRef value)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<Object *>(m)->engine());
     ScopedObject o(scope, static_cast<Object *>(m));
     ScopedString name(scope, scope.engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
 
@@ -574,7 +574,7 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name
         PropertyAttributes a = o->internalClass()->propertyData[it->memberIndex];
         ++it->memberIndex;
         if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) {
-            *name = m->engine()->newString(n->string);
+            *name = o->engine()->newString(n->string);
             *attrs = a;
             pd->copy(p, a);
             return;
@@ -1096,7 +1096,7 @@ void Object::copyArrayData(Object *other)
 
 uint Object::getLength(const Managed *m)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<const Object *>(m)->engine());
     ScopedValue v(scope, static_cast<Object *>(const_cast<Managed *>(m))->get(scope.engine->id_length));
     return v->toUInt32();
 }
@@ -1157,9 +1157,9 @@ Heap::ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list)
 
 ReturnedValue ArrayObject::getLookup(Managed *m, Lookup *l)
 {
-    Scope scope(m->engine());
-    ScopedString name(scope, m->engine()->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
-    if (name->equals(m->engine()->id_length)) {
+    Scope scope(static_cast<Object *>(m)->engine());
+    ScopedString name(scope, scope.engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
+    if (name->equals(scope.engine->id_length)) {
         // special case, as the property is on the object itself
         l->getter = Lookup::arrayLengthGetter;
         ArrayObject *a = static_cast<ArrayObject *>(m);
index 8762935..b1bc6ab 100644 (file)
@@ -56,9 +56,9 @@ Heap::ObjectCtor::ObjectCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue ObjectCtor::construct(Managed *that, CallData *callData)
 {
-    ExecutionEngine *v4 = that->engine();
-    Scope scope(v4);
     ObjectCtor *ctor = static_cast<ObjectCtor *>(that);
+    ExecutionEngine *v4 = ctor->engine();
+    Scope scope(v4);
     if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull()) {
         ScopedObject obj(scope, v4->newObject());
         ScopedObject proto(scope, ctor->get(v4->id_prototype));
@@ -71,9 +71,11 @@ ReturnedValue ObjectCtor::construct(Managed *that, CallData *callData)
 
 ReturnedValue ObjectCtor::call(Managed *m, CallData *callData)
 {
+    ObjectCtor *ctor = static_cast<ObjectCtor *>(m);
+    ExecutionEngine *v4 = ctor->engine();
     if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull())
-        return m->engine()->newObject()->asReturnedValue();
-    return RuntimeHelpers::toObject(m->engine(), ValueRef(&callData->args[0]));
+        return v4->newObject()->asReturnedValue();
+    return RuntimeHelpers::toObject(v4, ValueRef(&callData->args[0]));
 }
 
 void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
index 1d6a89a..e4c141c 100644 (file)
@@ -677,14 +677,14 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
 QV4::ReturnedValue QObjectWrapper::get(Managed *m, String *name, bool *hasProperty)
 {
     QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
-    QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(m->engine());
+    QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(that->engine());
     return that->getQmlProperty(qmlContext, name, IgnoreRevision, hasProperty, /*includeImports*/ true);
 }
 
 void QObjectWrapper::put(Managed *m, String *name, const ValueRef value)
 {
     QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
-    ExecutionEngine *v4 = m->engine();
+    ExecutionEngine *v4 = that->engine();
 
     if (v4->hasException || QQmlData::wasDeleted(that->d()->object))
         return;
index cd1d156..b9d2279 100644 (file)
@@ -239,7 +239,7 @@ void Heap::RegExpCtor::clearLastMatch()
 
 ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<Object *>(m)->engine());
     ScopedContext ctx(scope, scope.engine->currentContext());
 
     ScopedValue r(scope, callData->argument(0));
index f7afd00..9f49678 100644 (file)
@@ -124,7 +124,7 @@ Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Ob
 
 ReturnedValue QmlBindingWrapper::call(Managed *that, CallData *)
 {
-    ExecutionEngine *engine = that->engine();
+    ExecutionEngine *engine = static_cast<Object *>(that)->engine();
     CHECK_STACK_LIMITS(engine);
 
     Scope scope(engine);
index 5ce4b5b..aab1505 100644 (file)
@@ -105,13 +105,10 @@ Property *Heap::StringObject::getIndex(uint index) const
 
 bool StringObject::deleteIndexedProperty(Managed *m, uint index)
 {
-    ExecutionEngine *v4 = m->engine();
+    ExecutionEngine *v4 = static_cast<StringObject *>(m)->engine();
     Scope scope(v4);
     Scoped<StringObject> o(scope, m->asStringObject());
-    if (!o) {
-        v4->throwTypeError();
-        return false;
-    }
+    Q_ASSERT(!!o);
 
     if (index < static_cast<uint>(o->d()->value.stringValue()->toQString().length())) {
         if (v4->currentContext()->strictMode)
@@ -166,7 +163,7 @@ Heap::StringCtor::StringCtor(QV4::ExecutionContext *scope)
 
 ReturnedValue StringCtor::construct(Managed *m, CallData *callData)
 {
-    ExecutionEngine *v4 = m->engine();
+    ExecutionEngine *v4 = static_cast<Object *>(m)->engine();
     Scope scope(v4);
     ScopedValue value(scope);
     if (callData->argc)
@@ -178,7 +175,7 @@ ReturnedValue StringCtor::construct(Managed *m, CallData *callData)
 
 ReturnedValue StringCtor::call(Managed *m, CallData *callData)
 {
-    ExecutionEngine *v4 = m->engine();
+    ExecutionEngine *v4 = static_cast<Object *>(m)->engine();
     Scope scope(v4);
     ScopedValue value(scope);
     if (callData->argc)
index 11b6756..2277d37 100644 (file)
@@ -201,7 +201,7 @@ Heap::TypedArrayCtor::TypedArrayCtor(QV4::ExecutionContext *scope, TypedArray::T
 
 ReturnedValue TypedArrayCtor::construct(Managed *m, CallData *callData)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<Object *>(m)->engine());
     Scoped<TypedArrayCtor> that(scope, static_cast<TypedArrayCtor *>(m));
 
     if (!callData->argc || !callData->args[0].isObject()) {
@@ -346,7 +346,7 @@ void TypedArray::markObjects(Heap::Base *that, ExecutionEngine *e)
 
 ReturnedValue TypedArray::getIndexed(Managed *m, uint index, bool *hasProperty)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<Object *>(m)->engine());
     Scoped<TypedArray> a(scope, static_cast<TypedArray *>(m));
 
     uint bytesPerElement = a->d()->type->bytesPerElement;
@@ -363,10 +363,11 @@ ReturnedValue TypedArray::getIndexed(Managed *m, uint index, bool *hasProperty)
 
 void TypedArray::putIndexed(Managed *m, uint index, const ValueRef value)
 {
-    if (m->engine()->hasException)
+    ExecutionEngine *v4 = static_cast<Object *>(m)->engine();
+    if (v4->hasException)
         return;
 
-    Scope scope(m->engine());
+    Scope scope(v4);
     Scoped<TypedArray> a(scope, static_cast<TypedArray *>(m));
 
     uint bytesPerElement = a->d()->type->bytesPerElement;
index d1289bb..7846280 100644 (file)
@@ -88,7 +88,8 @@ double Value::toNumberImpl() const
         if (isString())
             return RuntimeHelpers::stringToNumber(stringValue()->toQString());
         {
-            Scope scope(managed()->engine());
+            Q_ASSERT(isObject());
+            Scope scope(objectValue()->engine());
             ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), NUMBER_HINT));
             if (scope.engine->hasException)
                 return 0;
@@ -123,7 +124,8 @@ QString Value::toQStringNoThrow() const
         if (isString())
             return stringValue()->toQString();
         {
-            Scope scope(managed()->engine());
+            Q_ASSERT(isObject());
+            Scope scope(objectValue()->engine());
             ScopedValue ex(scope);
             bool caughtException = false;
             ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), STRING_HINT));
@@ -175,7 +177,8 @@ QString Value::toQString() const
         if (isString())
             return stringValue()->toQString();
         {
-            Scope scope(managed()->engine());
+            Q_ASSERT(isObject());
+            Scope scope(objectValue()->engine());
             ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), STRING_HINT));
             return prim->toQString();
         }
index dda5187..0c16ae1 100644 (file)
@@ -126,9 +126,9 @@ void QmlContextWrapper::takeContextOwnership(const ValueRef qmlglobal)
 ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<QmlContextWrapper>());
-    QV4::ExecutionEngine *v4 = m->engine();
-    QV4::Scope scope(v4);
     QmlContextWrapper *resource = static_cast<QmlContextWrapper *>(m);
+    QV4::ExecutionEngine *v4 = resource->engine();
+    QV4::Scope scope(v4);
 
     // In V8 the JS global object would come _before_ the QML global object,
     // so simulate that here.
@@ -268,11 +268,12 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
 void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value)
 {
     Q_ASSERT(m->as<QmlContextWrapper>());
-    ExecutionEngine *v4 = m->engine();
+    QmlContextWrapper *resource = static_cast<QmlContextWrapper *>(m);
+    ExecutionEngine *v4 = resource->engine();
     QV4::Scope scope(v4);
     if (scope.hasException())
         return;
-    QV4::Scoped<QmlContextWrapper> wrapper(scope, static_cast<QmlContextWrapper *>(m));
+    QV4::Scoped<QmlContextWrapper> wrapper(scope, resource);
 
     PropertyAttributes attrs;
     Property *pd  = wrapper->__getOwnProperty__(name, &attrs);
@@ -428,7 +429,7 @@ Heap::QQmlIdObjectsArray::QQmlIdObjectsArray(ExecutionEngine *engine, QV4::QmlCo
 
 ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasProperty)
 {
-    Scope scope(m->engine());
+    Scope scope(static_cast<QV4::QQmlIdObjectsArray*>(m)->engine());
     Scoped<QQmlIdObjectsArray> This(scope, static_cast<QV4::QQmlIdObjectsArray*>(m));
     Scoped<QmlContextWrapper> contextWrapper(scope, This->d()->contextWrapper);
     QQmlContextData *context = contextWrapper->getContext();
@@ -446,8 +447,7 @@ ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasPr
     if (hasProperty)
         *hasProperty = true;
 
-    ExecutionEngine *v4 = m->engine();
-    QQmlEnginePrivate *ep = v4->qmlEngine() ? QQmlEnginePrivate::get(v4->qmlEngine()) : 0;
+    QQmlEnginePrivate *ep = scope.engine->qmlEngine() ? QQmlEnginePrivate::get(scope.engine->qmlEngine()) : 0;
     if (ep)
         ep->captureProperty(&context->idValues[index].bindings);
 
index 022a60f..af955ff 100644 (file)
@@ -95,8 +95,8 @@ QVariant QmlListWrapper::toVariant() const
 ReturnedValue QmlListWrapper::get(Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<QmlListWrapper>());
-    QV4::ExecutionEngine *v4 = m->engine();
     QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
+    QV4::ExecutionEngine *v4 = w->engine();
 
     if (name->equals(v4->id_length) && !w->d()->object.isNull()) {
         quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
@@ -115,8 +115,8 @@ ReturnedValue QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProper
     Q_UNUSED(hasProperty);
 
     Q_ASSERT(m->as<QmlListWrapper>());
-    QV4::ExecutionEngine *v4 = m->engine();
     QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
+    QV4::ExecutionEngine *v4 = w->engine();
 
     quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
     if (index < count && w->d()->property.at) {
index a72950e..77d472e 100644 (file)
@@ -125,10 +125,10 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<QmlTypeWrapper>());
 
-    QV4::ExecutionEngine *v4 = m->engine();
+    QV4::ExecutionEngine *v4 = static_cast<QmlTypeWrapper *>(m)->engine();
     QV4::Scope scope(v4);
 
-    Scoped<QmlTypeWrapper> w(scope,  static_cast<QmlTypeWrapper *>(m));
+    Scoped<QmlTypeWrapper> w(scope, static_cast<QmlTypeWrapper *>(m));
 
     if (hasProperty)
         *hasProperty = true;
@@ -232,7 +232,7 @@ void QmlTypeWrapper::put(Managed *m, String *name, const ValueRef value)
 {
     Q_ASSERT(m->as<QmlTypeWrapper>());
     QmlTypeWrapper *w = static_cast<QmlTypeWrapper *>(m);
-    QV4::ExecutionEngine *v4 = m->engine();
+    QV4::ExecutionEngine *v4 = w->engine();
     if (v4->hasException)
         return;
 
index d36549f..1e138be 100644 (file)
@@ -287,7 +287,7 @@ ReturnedValue QQmlValueTypeWrapper::get(Managed *m, String *name, bool *hasPrope
 {
     Q_ASSERT(m->as<QQmlValueTypeWrapper>());
     QQmlValueTypeWrapper *r = static_cast<QQmlValueTypeWrapper *>(m);
-    QV4::ExecutionEngine *v4 = m->engine();
+    QV4::ExecutionEngine *v4 = r->engine();
 
     // Note: readReferenceValue() can change the reference->type.
     if (QQmlValueTypeReference *reference = r->as<QQmlValueTypeReference>()) {
@@ -340,7 +340,7 @@ ReturnedValue QQmlValueTypeWrapper::get(Managed *m, String *name, bool *hasPrope
 void QQmlValueTypeWrapper::put(Managed *m, String *name, const ValueRef value)
 {
     Q_ASSERT(m->as<QQmlValueTypeWrapper>());
-    ExecutionEngine *v4 = m->engine();
+    ExecutionEngine *v4 = static_cast<QQmlValueTypeWrapper *>(m)->engine();
     Scope scope(v4);
     if (scope.hasException())
         return;
index 6d73097..7c4413a 100644 (file)
@@ -872,8 +872,8 @@ bool Node::isNull() const
 
 ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty)
 {
-    QV4::ExecutionEngine *v4 = m->engine();
     NamedNodeMap *r = m->as<NamedNodeMap>();
+    QV4::ExecutionEngine *v4 = r->engine();
     if (!r) {
         if (hasProperty)
             *hasProperty = false;
@@ -894,7 +894,7 @@ ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<NamedNodeMap>());
     NamedNodeMap *r = static_cast<NamedNodeMap *>(m);
-    QV4::ExecutionEngine *v4 = m->engine();
+    QV4::ExecutionEngine *v4 = r->engine();
 
     name->makeIdentifier(v4);
     if (name->equals(v4->id_length))
@@ -922,8 +922,8 @@ ReturnedValue NamedNodeMap::create(ExecutionEngine *v4, NodeImpl *data, const QL
 ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
 {
     Q_ASSERT(m->as<NodeList>());
-    QV4::ExecutionEngine *v4 = m->engine();
     NodeList *r = static_cast<NodeList *>(m);
+    QV4::ExecutionEngine *v4 = r->engine();
 
     if ((int)index < r->d()->d->children.count()) {
         if (hasProperty)
@@ -938,8 +938,8 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
 ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<NodeList>());
-    QV4::ExecutionEngine *v4 = m->engine();
     NodeList *r = static_cast<NodeList *>(m);
+    QV4::ExecutionEngine *v4 = r->engine();
 
     name->makeIdentifier(v4);
 
@@ -1614,13 +1614,13 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
     }
     static ReturnedValue construct(Managed *that, QV4::CallData *)
     {
-        Scope scope(that->engine());
+        Scope scope(static_cast<QQmlXMLHttpRequestCtor *>(that)->engine());
         Scoped<QQmlXMLHttpRequestCtor> ctor(scope, that->as<QQmlXMLHttpRequestCtor>());
         if (!ctor)
-            return that->engine()->throwTypeError();
+            return scope.engine->throwTypeError();
 
         QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(scope.engine, scope.engine->v8Engine->networkAccessManager());
-        Scoped<QQmlXMLHttpRequestWrapper> w(scope, that->engine()->memoryManager->alloc<QQmlXMLHttpRequestWrapper>(that->engine(), r));
+        Scoped<QQmlXMLHttpRequestWrapper> w(scope, scope.engine->memoryManager->alloc<QQmlXMLHttpRequestWrapper>(scope.engine, r));
         ScopedObject proto(scope, ctor->d()->proto);
         w->setPrototype(proto);
         return w.asReturnedValue();
index 360c560..0878063 100644 (file)
@@ -1158,7 +1158,7 @@ void QQmlBindingFunction::initBindingLocation()
 
 ReturnedValue QQmlBindingFunction::call(Managed *that, CallData *callData)
 {
-    Scope scope(that->engine());
+    Scope scope(static_cast<QQmlBindingFunction*>(that)->engine());
     ScopedFunctionObject function(scope, static_cast<QQmlBindingFunction*>(that)->d()->originalFunction);
     return function->call(callData);
 }
index 8d9a06f..61c3e17 100644 (file)
@@ -88,12 +88,12 @@ struct DelegateModelGroupFunction : QV4::FunctionObject
 
     static QV4::ReturnedValue construct(QV4::Managed *m, QV4::CallData *)
     {
-        return m->engine()->throwTypeError();
+        return static_cast<DelegateModelGroupFunction *>(m)->engine()->throwTypeError();
     }
 
     static QV4::ReturnedValue call(QV4::Managed *that, QV4::CallData *callData)
     {
-        QV4::ExecutionEngine *v4 = that->engine();
+        QV4::ExecutionEngine *v4 = static_cast<DelegateModelGroupFunction *>(that)->engine();
         QV4::Scope scope(v4);
         QV4::Scoped<DelegateModelGroupFunction> f(scope, that, QV4::Scoped<DelegateModelGroupFunction>::Cast);
         QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject);
@@ -3282,7 +3282,7 @@ public:
     static QV4::ReturnedValue getIndexed(QV4::Managed *m, uint index, bool *hasProperty)
     {
         Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
-        QV4::ExecutionEngine *v4 = m->engine();
+        QV4::ExecutionEngine *v4 = static_cast<QQmlDelegateModelGroupChangeArray *>(m)->engine();
         QV4::Scope scope(v4);
         QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, static_cast<QQmlDelegateModelGroupChangeArray *>(m));
 
@@ -3309,7 +3309,7 @@ public:
         Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
         QQmlDelegateModelGroupChangeArray *array = static_cast<QQmlDelegateModelGroupChangeArray *>(m);
 
-        if (name->equals(m->engine()->id_length)) {
+        if (name->equals(array->engine()->id_length)) {
             if (hasProperty)
                 *hasProperty = true;
             return QV4::Encode(array->count());
index 59e4b02..87b42f6 100644 (file)
@@ -3094,7 +3094,7 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(QV4::CallContext
 QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint index, bool *hasProperty)
 {
     Q_ASSERT(m->as<QQuickJSContext2DPixelData>());
-    QV4::ExecutionEngine *v4 = m->engine();
+    QV4::ExecutionEngine *v4 = static_cast<QQuickJSContext2DPixelData *>(m)->engine();
     QV4::Scope scope(v4);
     QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<QQuickJSContext2DPixelData *>(m));
 
@@ -3125,7 +3125,7 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint
 void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const QV4::ValueRef value)
 {
     Q_ASSERT(m->as<QQuickJSContext2DPixelData>());
-    QV4::ExecutionEngine *v4 = m->engine();
+    QV4::ExecutionEngine *v4 = static_cast<QQuickJSContext2DPixelData *>(m)->engine();
     QV4::Scope scope(v4);
     if (scope.hasException())
         return;
index ef0a362..2309069 100644 (file)
@@ -100,7 +100,7 @@ struct GC: public FunctionObject
 
     static ReturnedValue call(Managed *m, CallData *)
     {
-        m->engine()->memoryManager->runGC();
+        static_cast<GC *>(m)->engine()->memoryManager->runGC();
         return Encode::undefined();
     }
 };