diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2014-11-07 03:37:02 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-11-11 03:11:12 +0100 |
commit | a4b8bea95f95d4258dc04e7924eab4a11e072acb (patch) | |
tree | eab5efb771451dc057319fe38a061e42269fa5c5 /src/qml/jsruntime | |
parent | b7d9a8fd5baa6ae64fbac1ca40748470a33fbf9e (diff) |
Use Heap objects as members
Change-Id: I4f447747480fb7e15975b810e2a8623acc9cde61
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 47 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 7 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 19 |
4 files changed, 49 insertions, 26 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index caa98604c8..145e99e3a3 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -112,7 +112,7 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) if (ctx->d()->type >= Heap::ExecutionContext::Type_CallContext) { CallContext *c = static_cast<CallContext *>(ctx); if (!c->d()->activation) - c->d()->activation = d()->engine->newObject()->getPointer(); + c->d()->activation = d()->engine->newObject()->getPointer()->d(); activation = c->d()->activation; break; } @@ -131,7 +131,7 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) Heap::GlobalContext::GlobalContext(ExecutionEngine *eng) : Heap::ExecutionContext(eng, Heap::ExecutionContext::Type_GlobalContext) { - global = eng->globalObject; + global = eng->globalObject->d(); } Heap::WithContext::WithContext(ExecutionEngine *engine, QV4::Object *with) @@ -142,7 +142,7 @@ Heap::WithContext::WithContext(ExecutionEngine *engine, QV4::Object *with) lookups = parent->d()->lookups; compilationUnit = parent->d()->compilationUnit; - withObject = with; + withObject = with->d(); } Heap::CatchContext::CatchContext(ExecutionEngine *engine, QV4::String *exceptionVarName, const ValueRef exceptionValue) @@ -170,7 +170,7 @@ Heap::CallContext::CallContext(ExecutionEngine *engine, QV4::Object *qml, QV4::F strictMode = true; outer = function->scope(); - activation = qml; + activation = qml->d(); if (function->function()) { compilationUnit = function->function()->compilationUnit; @@ -211,9 +211,9 @@ bool ExecutionContext::deleteProperty(String *name) for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { if (ctx->d()->type == Heap::ExecutionContext::Type_WithContext) { hasWith = true; - WithContext *w = static_cast<WithContext *>(ctx); - if (w->d()->withObject->hasProperty(name)) - return w->d()->withObject->deleteProperty(name); + ScopedObject withObject(scope, static_cast<WithContext *>(ctx)->d()->withObject); + if (withObject->hasProperty(name)) + return withObject->deleteProperty(name); } else if (ctx->d()->type == Heap::ExecutionContext::Type_CatchContext) { CatchContext *c = static_cast<CatchContext *>(ctx); if (c->d()->exceptionVarName->isEqualTo(name)) @@ -227,12 +227,13 @@ bool ExecutionContext::deleteProperty(String *name) // ### throw in strict mode? return false; } - if (c->d()->activation && c->d()->activation->hasProperty(name)) - return c->d()->activation->deleteProperty(name); + ScopedObject activation(scope, c->d()->activation); + if (activation && activation->hasProperty(name)) + return activation->deleteProperty(name); } else if (ctx->d()->type == Heap::ExecutionContext::Type_GlobalContext) { - GlobalContext *g = static_cast<GlobalContext *>(ctx); - if (g->d()->global->hasProperty(name)) - return g->d()->global->deleteProperty(name); + ScopedObject global(scope, static_cast<GlobalContext *>(ctx)->d()->global); + if (global->hasProperty(name)) + return global->deleteProperty(name); } } @@ -375,9 +376,10 @@ ReturnedValue ExecutionContext::getProperty(String *name) return c->d()->locals[index - c->d()->function->formalParameterCount()].asReturnedValue(); } } - if (c->d()->activation) { + ScopedObject activation(scope, c->d()->activation); + if (activation) { bool hasProperty = false; - v = c->d()->activation->get(name, &hasProperty); + v = activation->get(name, &hasProperty); if (hasProperty) return v.asReturnedValue(); } @@ -387,9 +389,9 @@ ReturnedValue ExecutionContext::getProperty(String *name) } else if (ctx->d()->type == Heap::ExecutionContext::Type_GlobalContext) { - GlobalContext *g = static_cast<GlobalContext *>(ctx); + ScopedObject global(scope, static_cast<GlobalContext *>(ctx)->d()->global); bool hasProperty = false; - v = g->d()->global->get(name, &hasProperty); + v = global->get(name, &hasProperty); if (hasProperty) return v.asReturnedValue(); } @@ -412,7 +414,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base) bool hasCatchScope = false; for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { if (ctx->d()->type == Heap::ExecutionContext::Type_WithContext) { - Object *w = static_cast<WithContext *>(ctx)->d()->withObject; + ScopedObject w(scope, static_cast<WithContext *>(ctx)->d()->withObject); hasWith = true; bool hasProperty = false; v = w->get(name, &hasProperty); @@ -441,12 +443,13 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base) return c->d()->locals[index - c->d()->function->formalParameterCount()].asReturnedValue(); } } - if (c->d()->activation) { + ScopedObject activation(scope, c->d()->activation); + if (activation) { bool hasProperty = false; - v = c->d()->activation->get(name, &hasProperty); + v = activation->get(name, &hasProperty); if (hasProperty) { if (ctx->d()->type == Heap::ExecutionContext::Type_QmlContext) - base = c->d()->activation; + base = activation; return v.asReturnedValue(); } } @@ -456,9 +459,9 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base) } else if (ctx->d()->type == Heap::ExecutionContext::Type_GlobalContext) { - GlobalContext *g = static_cast<GlobalContext *>(ctx); + ScopedObject global(scope, static_cast<GlobalContext *>(ctx)->d()->global); bool hasProperty = false; - v = g->d()->global->get(name, &hasProperty); + v = global->get(name, &hasProperty); if (hasProperty) return v.asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 6bb926db92..b950481f76 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -109,7 +109,7 @@ struct CallContext : ExecutionContext { locals = 0; activation = 0; } - CallContext(ExecutionEngine *engine, Object *qml, QV4::FunctionObject *function); + CallContext(ExecutionEngine *engine, QV4::Object *qml, QV4::FunctionObject *function); QV4::FunctionObject *function; int realArgumentCount; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 19750e15cf..d724bafaa2 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -395,7 +395,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) // set up the global object // globalObject = newObject()->getPointer(); - rootContext->d()->global = globalObject; + rootContext->d()->global = globalObject->d(); rootContext->d()->callData->thisObject = globalObject; Q_ASSERT(globalObject->internalClass()->vtable); @@ -724,7 +724,10 @@ Returned<Object> *ExecutionEngine::qmlContextObject() const if (ctx->d()->type != Heap::ExecutionContext::Type_QmlContext) return 0; - return static_cast<CallContext *>(ctx)->d()->activation->asReturned<Object>(); + Scope scope(ctx); + ScopedObject activation(scope, static_cast<CallContext *>(ctx)->d()->activation); + + return activation->asReturned<Object>(); } QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 58437bea62..e1bef1dede 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -118,7 +118,25 @@ namespace Heap { struct Base; struct MemberData; struct ArrayData; + + struct String; + struct Object; + struct ObjectPrototype; + struct ExecutionContext; + struct GlobalContext; + struct CallContext; + struct ScriptFunction; + + struct BooleanObject; + struct NumberObject; + struct StringObject; + struct ArrayObject; + struct DateObject; + struct FunctionObject; + struct ErrorObject; + struct ArgumentsObject; + struct QObjectWrapper; } class MemoryManager; @@ -146,7 +164,6 @@ struct FunctionObject; struct ErrorObject; struct ArgumentsObject; struct Managed; -struct Lookup; struct ExecutionEngine; struct QObjectWrapper; |