diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-10-23 16:24:58 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-29 21:56:07 +0100 |
commit | ba6fc15d729304c136447242de2410fbf4f020cd (patch) | |
tree | 3ad8a9575de295c9102eae125f64246bec854852 /src/qml/compiler/qv4codegen.cpp | |
parent | c32265bfc562db23b7c894306ec61fd22111a7b1 (diff) |
Speed up id object lookups
We can resolve lookups for objects referenced by id at QML compile time
and use a run-time helper to extract the id object out of the QML context
data by index instead of name.
Dependencies to id objects are also tracked at compile time and registered
separately before entering the generated function code.
The lookup of id objects is encoded in the IR as special member lookups.
Members will also then in the future be used to for property lookups in context
and scope properties, as well as any other property lookups in QObjects where
we can determine the meta-object.
Change-Id: I36cf3ceb11b51a983da6cad5b61c3bf574acc20a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 70dbdb1af5..cb15c2c885 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1448,6 +1448,10 @@ V4IR::Expr *Codegen::identifier(const QString &name, int line, int col) f = f->outer; } + // This hook allows implementing QML lookup semantics + if (V4IR::Expr *fallback = fallbackNameLookup(name, line, col)) + return fallback; + if (!e->parent && (!f || !f->insideWithOrCatch) && _env->compilationMode != EvalCode && e->compilationMode != QmlBinding) return _block->GLOBALNAME(name, line, col); @@ -1456,6 +1460,14 @@ V4IR::Expr *Codegen::identifier(const QString &name, int line, int col) } +V4IR::Expr *Codegen::fallbackNameLookup(const QString &name, int line, int col) const +{ + Q_UNUSED(name) + Q_UNUSED(line) + Q_UNUSED(col) + return 0; +} + bool Codegen::visit(IdentifierExpression *ast) { if (hasError) |