diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-08-06 16:41:28 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-08 09:00:05 +0200 |
commit | 5b456c8da4462f9e11fa4da78a9e6ea86423a1e8 (patch) | |
tree | c8a24054a711d0ca4aed52ddcc480fcd25b32c91 /src/qml/jsruntime | |
parent | dea991ec5b6e1e8546dfd3695c12425ee27d2ef3 (diff) |
Beginning of a new qml parser
The goal is to parse QML and JavaScript binding expressions/functions in one
go and generate data structures that allow for the parsing to happen in a thread
and the instantiation of the object tree in another thread, just reading from
the generated data structures. This will replace qqmlcompiler and the VME.
This new way of loading QML is currently hidden behind the QML_NEW_COMPILER=1
environment variable. There's lots of work left to fill in the gaps in object
construction, Component support, Component.onComplete, error messages, etc. etc.
Change-Id: I5e40643cff169f469f0b6ce151584ffee5ca5e90
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4function_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 79 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script_p.h | 14 |
3 files changed, 48 insertions, 46 deletions
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index 595955a8ec..735dc558e1 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -47,7 +47,6 @@ #include <QtCore/QByteArray> #include <QtCore/qurl.h> -#include <config.h> #include "qv4value_def_p.h" #include <private/qv4compileddata_p.h> diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 9d0fed34fe..aef8ac8838 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -59,39 +59,44 @@ using namespace QV4; -struct QmlBindingWrapper : FunctionObject +QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Object *qml) + : FunctionObject(scope, scope->engine->id_eval) + , qml(qml) { - Q_MANAGED + vtbl = &static_vtbl; + function = f; + function->compilationUnit->ref(); + usesArgumentsObject = function->usesArgumentsObject(); + needsActivation = function->needsActivation(); + defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1)); + + qmlContext = scope->engine->current->newQmlContext(this, qml); + scope->engine->popContext(); +} - QmlBindingWrapper(ExecutionContext *scope, Function *f, Object *qml) - : FunctionObject(scope, scope->engine->id_eval) - , qml(qml) - { - vtbl = &static_vtbl; - function = f; - function->compilationUnit->ref(); - usesArgumentsObject = function->usesArgumentsObject(); - needsActivation = function->needsActivation(); - defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1)); - - qmlContext = scope->engine->current->newQmlContext(this, qml); - scope->engine->popContext(); - } +Value QmlBindingWrapper::call(Managed *that, const CallData &) +{ + ExecutionEngine *engine = that->engine(); + QmlBindingWrapper *This = static_cast<QmlBindingWrapper *>(that); - static Value call(Managed *that, const CallData &); - static void markObjects(Managed *m) - { - QmlBindingWrapper *wrapper = static_cast<QmlBindingWrapper*>(m); - if (wrapper->qml) - wrapper->qml->mark(); - FunctionObject::markObjects(m); - wrapper->qmlContext->mark(); - } + CallContext *ctx = This->qmlContext; + std::fill(ctx->locals, ctx->locals + ctx->function->varCount, Value::undefinedValue()); + engine->pushContext(ctx); + Value result = This->function->code(ctx, This->function->codeData); + engine->popContext(); -private: - Object *qml; - CallContext *qmlContext; -}; + return result; + +} + +void QmlBindingWrapper::markObjects(Managed *m) +{ + QmlBindingWrapper *wrapper = static_cast<QmlBindingWrapper*>(m); + if (wrapper->qml) + wrapper->qml->mark(); + FunctionObject::markObjects(m); + wrapper->qmlContext->mark(); +} DEFINE_MANAGED_VTABLE(QmlBindingWrapper); @@ -121,22 +126,6 @@ struct CompilationUnitHolder : public QV4::Object DEFINE_MANAGED_VTABLE(CompilationUnitHolder); -Value QmlBindingWrapper::call(Managed *that, const CallData &) -{ - ExecutionEngine *engine = that->engine(); - QmlBindingWrapper *This = static_cast<QmlBindingWrapper *>(that); - - CallContext *ctx = This->qmlContext; - std::fill(ctx->locals, ctx->locals + ctx->function->varCount, Value::undefinedValue()); - engine->pushContext(ctx); - Value result = This->function->code(ctx, This->function->codeData); - engine->popContext(); - - return result; - -} - - Script::~Script() { } diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index 250fd73704..b3bce6b427 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -43,6 +43,7 @@ #include "qv4global_p.h" #include "qv4engine_p.h" +#include "qv4functionobject_p.h" QT_BEGIN_NAMESPACE @@ -50,6 +51,19 @@ namespace QV4 { struct ExecutionContext; +struct QmlBindingWrapper : FunctionObject { + Q_MANAGED + + QmlBindingWrapper(ExecutionContext *scope, Function *f, Object *qml); + + static Value call(Managed *that, const CallData &); + static void markObjects(Managed *m); + +private: + Object *qml; + CallContext *qmlContext; +}; + struct Q_QML_EXPORT Script { Script(ExecutionContext *scope, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0) : sourceFile(source), line(line), column(column), sourceCode(sourceCode) |