aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-03-27 17:07:06 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-28 15:07:03 +0100
commit0ed744c1ef955cdb94cbd89c58283663da490d7d (patch)
treee07da64307bb70331ed0a9cbfa78ecd960b57b14 /src/qml/qml/qqmltypeloader.cpp
parent6bbd173a9cb36021ed284522ac628400469eab2f (diff)
Various cleanups
* Encapsulate the string pooling for the V4 data generation into a StringGenerator class. * Move type reference collection into the IR::Document, where it belongs (as it writes into the typeReferences there) * const fixes * Remove unused methods and members * Store unit and qml unit sizes right in the generated data structure. That makes copying easier (like we do when generating the QML data based on the JS fields) Change-Id: I053146ab0b00cc90ac7f72f867415962d1be121b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r--src/qml/qml/qqmltypeloader.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index a905519550..7f7ea1e5c1 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1172,7 +1172,7 @@ void QQmlDataLoader::shutdownThread()
}
QQmlTypeLoader::Blob::Blob(const QUrl &url, QQmlDataBlob::Type type, QQmlTypeLoader *loader)
- : QQmlDataBlob(url, type), m_typeLoader(loader), m_importCache(loader), m_stringPool(0), m_isSingleton(false)
+ : QQmlDataBlob(url, type), m_typeLoader(loader), m_importCache(loader), m_isSingleton(false)
{
}
@@ -2046,7 +2046,7 @@ void QQmlTypeData::done()
const TypeReference &type = *it;
Q_ASSERT(!type.typeData || type.typeData->isCompleteOrError());
if (type.typeData && type.typeData->isError()) {
- QString typeName = m_document->jsGenerator.strings.at(it.key());
+ QString typeName = m_document->stringAt(it.key());
QList<QQmlError> errors = type.typeData->errors();
QQmlError error;
@@ -2142,7 +2142,7 @@ void QQmlTypeData::dataReceived(const Data &data)
return;
}
- m_stringPool = &m_document->jsGenerator.strings;
+ m_document->collectTypeReferences();
m_importCache.setBaseUrl(finalUrl(), finalUrlString());
@@ -2172,7 +2172,7 @@ void QQmlTypeData::dataReceived(const Data &data)
QList<QQmlError> errors;
- foreach (QV4::CompiledData::Import *import, m_document->imports) {
+ foreach (const QV4::CompiledData::Import *import, m_document->imports) {
if (!addImport(import, &errors)) {
Q_ASSERT(errors.size());
QQmlError error(errors.takeFirst());
@@ -2232,6 +2232,11 @@ void QQmlTypeData::downloadProgressChanged(qreal p)
}
}
+QString QQmlTypeData::stringAt(int index) const
+{
+ return m_document->jsGenerator.stringTable.stringForIndex(index);
+}
+
void QQmlTypeData::compile()
{
Q_ASSERT(m_compiledData == 0);
@@ -2299,15 +2304,7 @@ void QQmlTypeData::resolveTypes()
}
}
- QV4::CompiledData::TypeReferenceMap typeReferences;
- QStringList names;
- if (m_document) {
- typeReferences = m_document->typeReferences;
- names = m_document->jsGenerator.strings;
- } else {
- // ### collect from available QV4::CompiledData::QmlUnit
- }
- for (QV4::CompiledData::TypeReferenceMap::ConstIterator unresolvedRef = typeReferences.constBegin(), end = typeReferences.constEnd();
+ for (QV4::CompiledData::TypeReferenceMap::ConstIterator unresolvedRef = m_document->typeReferences.constBegin(), end = m_document->typeReferences.constEnd();
unresolvedRef != end; ++unresolvedRef) {
TypeReference ref; // resolved reference
@@ -2319,7 +2316,7 @@ void QQmlTypeData::resolveTypes()
QQmlImportNamespace *typeNamespace = 0;
QList<QQmlError> errors;
- const QString name = names.at(unresolvedRef.key());
+ const QString name = stringAt(unresolvedRef.key());
bool typeFound = m_importCache.resolveType(name, &ref.type,
&majorVersion, &minorVersion, &typeNamespace, &errors);
if (!typeNamespace && !typeFound && !m_implicitImportLoaded) {
@@ -2606,8 +2603,6 @@ void QQmlScriptBlob::dataReceived(const Data &data)
return;
}
- m_stringPool = &m_irUnit.jsGenerator.strings;
-
QList<QQmlError> errors;
QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_typeLoader->engine());
m_scriptData->m_precompiledScript = QV4::Script::precompile(&m_irUnit.jsModule, &m_irUnit.jsGenerator, v4, m_scriptData->url, source, &errors);
@@ -2619,6 +2614,7 @@ void QQmlScriptBlob::dataReceived(const Data &data)
return;
}
+ m_irUnit.javaScriptCompilationUnit = m_scriptData->m_precompiledScript;
QmlIR::QmlUnitGenerator qmlGenerator;
QV4::CompiledData::QmlUnit *qmlUnit = qmlGenerator.generate(m_irUnit);
if (m_scriptData->m_precompiledScript) {
@@ -2687,6 +2683,11 @@ void QQmlScriptBlob::done()
m_importCache.populateCache(m_scriptData->importCache);
}
+QString QQmlScriptBlob::stringAt(int index) const
+{
+ return m_scriptData->m_precompiledScript->data->stringAt(index);
+}
+
void QQmlScriptBlob::scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace)
{
ScriptReference ref;