diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-08-21 15:00:09 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-02 17:27:36 +0200 |
commit | da2f24d8e5c32fe4ed45dcb89aa357465f85fc1e (patch) | |
tree | 490d63078e83280990fc8c1b416d2d17600ea7d2 /src | |
parent | 29f946cdad013d759aad05cbd22f40d0c152d6f3 (diff) |
move methods to create a new context into the ExecutionContext class
This avoids one indirection when calling the methods and cleans up
the engine a bit.
Change-Id: I426f41e23f6a7262af95b9807b00920530fef642
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 26 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 29 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 2 |
6 files changed, 34 insertions, 36 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 21a11bbdec..7353d69d32 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -142,6 +142,32 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, const Va return c; } +WithContext *ExecutionContext::newWithContext(Object *with) +{ + WithContext *w = static_cast<WithContext *>(engine->memoryManager->allocContext(sizeof(WithContext))); + engine->current = w; + w->initWithContext(this, with); + return w; +} + +CatchContext *ExecutionContext::newCatchContext(String *exceptionVarName, const Value &exceptionValue) +{ + CatchContext *c = static_cast<CatchContext *>(engine->memoryManager->allocContext(sizeof(CatchContext))); + engine->current = c; + c->initCatchContext(this, exceptionVarName, exceptionValue); + return c; +} + +CallContext *ExecutionContext::newQmlContext(FunctionObject *f, Object *qml) +{ + CallContext *c = static_cast<CallContext *>(engine->memoryManager->allocContext(requiredMemoryForExecutionContect(f, 0))); + + engine->current = c; + c->initQmlContext(this, qml, f); + + return c; +} + void ExecutionContext::createMutableBinding(String *name, bool deletable) diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index dc2370f38d..0c1dfb1d71 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -59,6 +59,8 @@ struct Function; }; struct CallContext; +struct CatchContext; +struct WithContext; struct Q_QML_EXPORT ExecutionContext { @@ -114,7 +116,9 @@ struct Q_QML_EXPORT ExecutionContext CallContext *newCallContext(void *stackSpace, FunctionObject *f, const QV4::Value &thisObject, QV4::Value *args, int argc); CallContext *newCallContext(FunctionObject *f, const QV4::Value &thisObject, QV4::Value *args, int argc); - + WithContext *newWithContext(Object *with); + CatchContext *newCatchContext(String* exceptionVarName, const QV4::Value &exceptionValue); + CallContext *newQmlContext(FunctionObject *f, Object *qml); String * const *formals() const; unsigned int formalCount() const; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 3b87888ab9..8e198aaa33 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -307,35 +307,6 @@ InternalClass *ExecutionEngine::newClass(const InternalClass &other) return new (classPool.allocate(sizeof(InternalClass))) InternalClass(other); } -WithContext *ExecutionEngine::newWithContext(Object *with) -{ - WithContext *w = static_cast<WithContext *>(memoryManager->allocContext(sizeof(WithContext))); - ExecutionContext *p = current; - current = w; - w->initWithContext(p, with); - return w; -} - -CatchContext *ExecutionEngine::newCatchContext(String *exceptionVarName, const Value &exceptionValue) -{ - CatchContext *c = static_cast<CatchContext *>(memoryManager->allocContext(sizeof(CatchContext))); - ExecutionContext *p = current; - current = c; - c->initCatchContext(p, exceptionVarName, exceptionValue); - return c; -} - -CallContext *ExecutionEngine::newQmlContext(FunctionObject *f, Object *qml) -{ - CallContext *c = static_cast<CallContext *>(memoryManager->allocContext(requiredMemoryForExecutionContect(f, 0))); - - ExecutionContext *p = current; - current = c; - c->initQmlContext(p, qml, f); - - return c; -} - ExecutionContext *ExecutionEngine::pushGlobalContext() { GlobalContext *g = static_cast<GlobalContext *>(memoryManager->allocContext(sizeof(GlobalContext))); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 10e0681929..0b6756466c 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -236,9 +236,6 @@ struct Q_QML_EXPORT ExecutionEngine void enableDebugger(); - WithContext *newWithContext(Object *with); - CatchContext *newCatchContext(String* exceptionVarName, const QV4::Value &exceptionValue); - CallContext *newQmlContext(FunctionObject *f, Object *qml); ExecutionContext *pushGlobalContext(); void pushContext(SimpleCallContext *context); ExecutionContext *popContext(); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 322ca38546..8d28979b60 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1116,12 +1116,12 @@ void __qmljs_builtin_post_decrement_element(ExecutionContext *context, Value *re ExecutionContext *__qmljs_builtin_push_with_scope(const Value &o, ExecutionContext *ctx) { Object *obj = o.toObject(ctx); - return ctx->engine->newWithContext(obj); + return ctx->newWithContext(obj); } ExecutionContext *__qmljs_builtin_push_catch_scope(String *exceptionVarName, const Value &exceptionValue, ExecutionContext *ctx) { - return ctx->engine->newCatchContext(exceptionVarName, exceptionValue); + return ctx->newCatchContext(exceptionVarName, exceptionValue); } ExecutionContext *__qmljs_builtin_pop_scope(ExecutionContext *ctx) diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 7f8e9e205e..80cca830f5 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -74,7 +74,7 @@ struct QmlBindingWrapper : FunctionObject needsActivation = function->needsActivation(); defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1)); - qmlContext = scope->engine->newQmlContext(this, qml); + qmlContext = scope->engine->current->newQmlContext(this, qml); scope->engine->popContext(); } |