From 4271d2a21f4fce2ac76e65a783a3fa3f960c2cb3 Mon Sep 17 00:00:00 2001 From: Christian Kamm <christian.d.kamm@nokia.com> Date: Fri, 25 Jun 2010 17:10:14 +0200 Subject: [PATCH] QmlJS: Make the qml instantiating component chain more useful. By actually storing the documents instead of only the root and id environments. --- src/libs/qmljs/qmljsinterpreter.cpp | 29 +++++++++++++++++++---------- src/libs/qmljs/qmljsinterpreter.h | 3 +-- src/libs/qmljs/qmljslink.cpp | 5 +---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 4f222c3f314..7214a188bb8 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -30,6 +30,7 @@ #include "qmljsinterpreter.h" #include "qmljsevaluate.h" #include "qmljslink.h" +#include "qmljsbind.h" #include "qmljsscopebuilder.h" #include "qmljscomponentversion.h" #include "parser/qmljsast_p.h" @@ -1353,7 +1354,6 @@ ScopeChain::ScopeChain() } ScopeChain::QmlComponentChain::QmlComponentChain() - : rootObject(0), ids(0) { } @@ -1366,8 +1366,7 @@ void ScopeChain::QmlComponentChain::clear() { qDeleteAll(instantiatingComponents); instantiatingComponents.clear(); - rootObject = 0; - ids = 0; + document = Document::Ptr(0); } void ScopeChain::QmlComponentChain::add(QList<const ObjectValue *> *list) const @@ -1375,9 +1374,12 @@ void ScopeChain::QmlComponentChain::add(QList<const ObjectValue *> *list) const foreach (QmlComponentChain *parent, instantiatingComponents) parent->add(list); - if (rootObject) - list->append(rootObject); - if (ids) + if (!document) + return; + + if (ObjectValue *root = document->bind()->rootObjectValue()) + list->append(root); + if (ObjectValue *ids = document->bind()->idEnvironment()) list->append(ids); } @@ -1393,11 +1395,18 @@ void ScopeChain::update() parent->add(&_all); } - if (qmlComponentScope.rootObject && ! qmlScopeObjects.contains(qmlComponentScope.rootObject)) - _all += qmlComponentScope.rootObject; + ObjectValue *root = 0; + ObjectValue *ids = 0; + if (qmlComponentScope.document) { + root = qmlComponentScope.document->bind()->rootObjectValue(); + ids = qmlComponentScope.document->bind()->idEnvironment(); + } + + if (root && !qmlScopeObjects.contains(root)) + _all += root; _all += qmlScopeObjects; - if (qmlComponentScope.ids) - _all += qmlComponentScope.ids; + if (ids) + _all += ids; if (qmlTypes) _all += qmlTypes; _all += jsScopes; diff --git a/src/libs/qmljs/qmljsinterpreter.h b/src/libs/qmljs/qmljsinterpreter.h index d17df9406b8..1855d52c933 100644 --- a/src/libs/qmljs/qmljsinterpreter.h +++ b/src/libs/qmljs/qmljsinterpreter.h @@ -248,8 +248,7 @@ public: ~QmlComponentChain(); QList<QmlComponentChain *> instantiatingComponents; - const ObjectValue *rootObject; - const ObjectValue *ids; + Document::Ptr document; void add(QList<const ObjectValue *> *list) const; void clear(); diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp index 72aea358116..9f5c29a3c89 100644 --- a/src/libs/qmljs/qmljslink.cpp +++ b/src/libs/qmljs/qmljslink.cpp @@ -112,10 +112,7 @@ void Link::makeComponentChain( } // build this component scope - if (bind->rootObjectValue()) - target->rootObject = bind->rootObjectValue(); - - target->ids = bind->idEnvironment(); + target->document = doc; } void Link::linkImports() -- GitLab