QmlJS: Make the qml instantiating component chain more useful.

By actually storing the documents instead of only the root and id
environments.
This commit is contained in:
Christian Kamm
2010-06-25 17:10:14 +02:00
parent 1fbfd196bb
commit 4271d2a21f
3 changed files with 21 additions and 16 deletions

View File

@@ -30,6 +30,7 @@
#include "qmljsinterpreter.h" #include "qmljsinterpreter.h"
#include "qmljsevaluate.h" #include "qmljsevaluate.h"
#include "qmljslink.h" #include "qmljslink.h"
#include "qmljsbind.h"
#include "qmljsscopebuilder.h" #include "qmljsscopebuilder.h"
#include "qmljscomponentversion.h" #include "qmljscomponentversion.h"
#include "parser/qmljsast_p.h" #include "parser/qmljsast_p.h"
@@ -1353,7 +1354,6 @@ ScopeChain::ScopeChain()
} }
ScopeChain::QmlComponentChain::QmlComponentChain() ScopeChain::QmlComponentChain::QmlComponentChain()
: rootObject(0), ids(0)
{ {
} }
@@ -1366,8 +1366,7 @@ void ScopeChain::QmlComponentChain::clear()
{ {
qDeleteAll(instantiatingComponents); qDeleteAll(instantiatingComponents);
instantiatingComponents.clear(); instantiatingComponents.clear();
rootObject = 0; document = Document::Ptr(0);
ids = 0;
} }
void ScopeChain::QmlComponentChain::add(QList<const ObjectValue *> *list) const 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) foreach (QmlComponentChain *parent, instantiatingComponents)
parent->add(list); parent->add(list);
if (rootObject) if (!document)
list->append(rootObject); return;
if (ids)
if (ObjectValue *root = document->bind()->rootObjectValue())
list->append(root);
if (ObjectValue *ids = document->bind()->idEnvironment())
list->append(ids); list->append(ids);
} }
@@ -1393,11 +1395,18 @@ void ScopeChain::update()
parent->add(&_all); parent->add(&_all);
} }
if (qmlComponentScope.rootObject && ! qmlScopeObjects.contains(qmlComponentScope.rootObject)) ObjectValue *root = 0;
_all += qmlComponentScope.rootObject; 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; _all += qmlScopeObjects;
if (qmlComponentScope.ids) if (ids)
_all += qmlComponentScope.ids; _all += ids;
if (qmlTypes) if (qmlTypes)
_all += qmlTypes; _all += qmlTypes;
_all += jsScopes; _all += jsScopes;

View File

@@ -248,8 +248,7 @@ public:
~QmlComponentChain(); ~QmlComponentChain();
QList<QmlComponentChain *> instantiatingComponents; QList<QmlComponentChain *> instantiatingComponents;
const ObjectValue *rootObject; Document::Ptr document;
const ObjectValue *ids;
void add(QList<const ObjectValue *> *list) const; void add(QList<const ObjectValue *> *list) const;
void clear(); void clear();

View File

@@ -112,10 +112,7 @@ void Link::makeComponentChain(
} }
// build this component scope // build this component scope
if (bind->rootObjectValue()) target->document = doc;
target->rootObject = bind->rootObjectValue();
target->ids = bind->idEnvironment();
} }
void Link::linkImports() void Link::linkImports()