diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-25 16:36:41 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-02 14:48:43 +0100 |
commit | 963875db263e4d1a04e03c4bb4fc20542bc8c21e (patch) | |
tree | cbb63607672e9d302d30389c8fe7553b27807b1f /src/qml/qml | |
parent | 278ca02350c68a78c89bb34d99ee65968372a5fd (diff) |
[new compiler] Compile functions and bindings in appropriate scopes
This enables accelerated property access also for this code path.
Change-Id: Iafb177b1fe7878e6c54cfb258f2e8d8ea32aa59e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlcompiler.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlcustomparser.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlcustomparser_p.h | 4 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index b26b5530a3..3e2fc91cf5 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -3642,6 +3642,8 @@ bool QQmlCompiler::completeComponentBuild() const QQmlScript::Parser &parser = unit->parser(); QQmlJS::Engine *jsEngine = parser.jsEngine(); QQmlJS::MemoryPool *pool = jsEngine->pool(); + QStringList stringPool; + stringPool.append(QString()); for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) { @@ -3659,7 +3661,9 @@ bool QQmlCompiler::completeComponentBuild() ComponentCompileState::PerObjectCompileData *cd = &compileState->jsCompileData[b->bindingContext.object]; QtQml::CompiledFunctionOrExpression f; f.node = node; - f.name = binding.property->name().toString().prepend(QStringLiteral("expression for ")); + QString name = binding.property->name().toString().prepend(QStringLiteral("expression for ")); + stringPool.append(name); + f.nameIndex = stringPool.count() - 1; f.disableAcceleratedLookups = binding.disableLookupAcceleration; cd->functionsToCompile.append(f); binding.compiledIndex = cd->functionsToCompile.count() - 1; @@ -3672,7 +3676,7 @@ bool QQmlCompiler::completeComponentBuild() const QString &sourceCode = jsEngine->code(); AST::UiProgram *qmlRoot = parser.qmlRoot(); - JSCodeGen jsCodeGen(unit->finalUrlString(), sourceCode, jsModule.data(), jsEngine, qmlRoot, output->importCache); + JSCodeGen jsCodeGen(unit->finalUrlString(), sourceCode, jsModule.data(), jsEngine, qmlRoot, output->importCache, stringPool); JSCodeGen::ObjectIdMapping idMapping; if (compileState->ids.count() > 0) { diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp index fc14fae275..f661317794 100644 --- a/src/qml/qml/qqmlcustomparser.cpp +++ b/src/qml/qml/qqmlcustomparser.cpp @@ -333,9 +333,9 @@ QQmlBinding::Identifier QQmlCustomParser::bindingIdentifier(const QV4::CompiledD return compiler->bindingIdentifier(binding, this); } -QQmlJS::AST::Node *QQmlCustomParser::astForBinding(int scriptIndex) const +QQmlJS::AST::Node *QQmlCustomParser::astForBinding(int objectIndex, int scriptIndex) const { - return compiler->astForBinding(scriptIndex); + return compiler->astForBinding(objectIndex, scriptIndex); } struct StaticQtMetaObject : public QObject diff --git a/src/qml/qml/qqmlcustomparser_p.h b/src/qml/qml/qqmlcustomparser_p.h index d06a8c1551..96810c2f40 100644 --- a/src/qml/qml/qqmlcustomparser_p.h +++ b/src/qml/qml/qqmlcustomparser_p.h @@ -119,7 +119,7 @@ struct QQmlCustomParserCompilerBackend virtual QQmlBinding::Identifier bindingIdentifier(const QQmlScript::Variant&, const QString&, QQmlCustomParser *) { return QQmlBinding::Invalid; } virtual QQmlBinding::Identifier bindingIdentifier(const QV4::CompiledData::Binding *, QQmlCustomParser *) { return QQmlBinding::Invalid; } - virtual QQmlJS::AST::Node *astForBinding(int) const { return 0; } + virtual QQmlJS::AST::Node *astForBinding(int, int) const { return 0; } }; class Q_QML_PRIVATE_EXPORT QQmlCustomParser @@ -162,7 +162,7 @@ protected: QQmlBinding::Identifier bindingIdentifier(const QQmlScript::Variant&, const QString&); QQmlBinding::Identifier bindingIdentifier(const QV4::CompiledData::Binding *binding); - QQmlJS::AST::Node *astForBinding(int scriptIndex) const; + QQmlJS::AST::Node *astForBinding(int objectIndex, int scriptIndex) const; private: QList<QQmlError> exceptions; |