Cleanup
authorSimon Hausmann <simon.hausmann@digia.com>
Tue, 18 Mar 2014 21:59:36 +0000 (22:59 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 19 Mar 2014 07:32:45 +0000 (08:32 +0100)
Get rid of QQmlScript::Import in favor of operating on QV4::CompiledData::Import
structures throughout the type loader.

Change-Id: I29de369373a3dc4fd8e7f30517b804edcce93e7a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/qqmlimport.cpp
src/qml/qml/qqmlscript_p.h
src/qml/qml/qqmltypeloader.cpp
src/qml/qml/qqmltypeloader_p.h

index f153a6758695befa2829f43286eccdd3f0de6f63..980d4ed0268df0da55f04c4a7f165f10b45d7036 100644 (file)
@@ -296,7 +296,7 @@ public:
 
     QQmlImportNamespace::Import *addImportToNamespace(QQmlImportNamespace *nameSpace,
                                                       const QString &uri, const QString &url,
-                                                      int vmaj, int vmin, QQmlScript::Import::Type type,
+                                                      int vmaj, int vmin, QV4::CompiledData::Import::ImportType type,
                                                       QList<QQmlError> *errors, bool lowPrecedence = false);
 
    bool populatePluginPairVector(QVector<StaticPluginPair> &result, const QString &uri,
@@ -1211,7 +1211,7 @@ QQmlImportNamespace *QQmlImportsPrivate::importNamespace(const QString &prefix)
 
 QQmlImportNamespace::Import *QQmlImportsPrivate::addImportToNamespace(QQmlImportNamespace *nameSpace,
                                                                       const QString &uri, const QString &url, int vmaj, int vmin,
-                                                                      QQmlScript::Import::Type type,
+                                                                      QV4::CompiledData::Import::ImportType type,
                                                                       QList<QQmlError> *errors, bool lowPrecedence)
 {
     Q_ASSERT(nameSpace);
@@ -1224,7 +1224,7 @@ QQmlImportNamespace::Import *QQmlImportsPrivate::addImportToNamespace(QQmlImport
     import->url = url;
     import->majversion = vmaj;
     import->minversion = vmin;
-    import->isLibrary = (type == QQmlScript::Import::Library);
+    import->isLibrary = (type == QV4::CompiledData::Import::ImportLibrary);
 
     if (lowPrecedence)
         nameSpace->imports.append(import);
@@ -1245,7 +1245,7 @@ bool QQmlImportsPrivate::addLibraryImport(const QString& uri, const QString &pre
     QQmlImportNamespace *nameSpace = importNamespace(prefix);
     Q_ASSERT(nameSpace);
 
-    QQmlImportNamespace::Import *inserted = addImportToNamespace(nameSpace, uri, qmldirUrl, vmaj, vmin, QQmlScript::Import::Library, errors);
+    QQmlImportNamespace::Import *inserted = addImportToNamespace(nameSpace, uri, qmldirUrl, vmaj, vmin, QV4::CompiledData::Import::ImportLibrary, errors);
     Q_ASSERT(inserted);
 
     if (!incomplete) {
@@ -1375,7 +1375,7 @@ bool QQmlImportsPrivate::addFileImport(const QString& uri, const QString &prefix
     if (!url.endsWith(Slash) && !url.endsWith(Backslash))
         url += Slash;
 
-    QQmlImportNamespace::Import *inserted = addImportToNamespace(nameSpace, importUri, url, vmaj, vmin, QQmlScript::Import::File, errors, isImplicitImport);
+    QQmlImportNamespace::Import *inserted = addImportToNamespace(nameSpace, importUri, url, vmaj, vmin, QV4::CompiledData::Import::ImportFile, errors, isImplicitImport);
     Q_ASSERT(inserted);
 
     if (!incomplete && !qmldirIdentifier.isEmpty()) {
index 1d59d6117e0dbda5ecd490524758e5d234fa395b..3d8f66f84719d5437f766e2a27e4a06da338ad22 100644 (file)
@@ -102,23 +102,6 @@ struct LocationSpan
     }
 };
 
-class Import
-{
-public:
-    Import() : type(Library), majorVersion(-1), minorVersion(-1) {}
-
-    enum Type { Library, File, Script };
-    Type type;
-
-    QString uri;
-    QString qualifier;
-
-    int majorVersion;
-    int minorVersion;
-
-    QQmlScript::LocationSpan location;
-};
-
 class Object;
 class TypeReference : public QQmlPool::Class
 {
index efa47db9518307a85b0aa04ea10f50bb1593e09e..5b5b926b549c8d0bbfdc505fd70b8c1643eb9491 100644 (file)
@@ -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_isSingleton(false)
+  : QQmlDataBlob(url, type), m_typeLoader(loader), m_importCache(loader), m_stringPool(0), m_isSingleton(false)
 {
 }
 
@@ -1182,7 +1182,7 @@ QQmlTypeLoader::Blob::~Blob()
         m_qmldirs.at(ii)->release();
 }
 
-bool QQmlTypeLoader::Blob::fetchQmldir(const QUrl &url, const QQmlScript::Import *import, int priority, QList<QQmlError> *errors)
+bool QQmlTypeLoader::Blob::fetchQmldir(const QUrl &url, const QV4::CompiledData::Import *import, int priority, QList<QQmlError> *errors)
 {
     QQmlQmldirData *data = typeLoader()->getQmldir(url);
 
@@ -1203,17 +1203,17 @@ bool QQmlTypeLoader::Blob::fetchQmldir(const QUrl &url, const QQmlScript::Import
     return true;
 }
 
-bool QQmlTypeLoader::Blob::updateQmldir(QQmlQmldirData *data, const QQmlScript::Import *import, QList<QQmlError> *errors)
+bool QQmlTypeLoader::Blob::updateQmldir(QQmlQmldirData *data, const QV4::CompiledData::Import *import, QList<QQmlError> *errors)
 {
     QString qmldirIdentifier = data->url().toString();
     QString qmldirUrl = qmldirIdentifier.left(qmldirIdentifier.lastIndexOf(QLatin1Char('/')) + 1);
 
     typeLoader()->setQmldirContent(qmldirIdentifier, data->content());
 
-    if (!m_importCache.updateQmldirContent(typeLoader()->importDatabase(), import->uri, import->qualifier, qmldirIdentifier, qmldirUrl, errors))
+    if (!m_importCache.updateQmldirContent(typeLoader()->importDatabase(), stringAt(import->uriIndex), stringAt(import->qualifierIndex), qmldirIdentifier, qmldirUrl, errors))
         return false;
 
-    QHash<const QQmlScript::Import *, int>::iterator it = m_unresolvedImports.find(import);
+    QHash<const QV4::CompiledData::Import *, int>::iterator it = m_unresolvedImports.find(import);
     if (it != m_unresolvedImports.end()) {
         *it = data->priority();
     }
@@ -1221,7 +1221,8 @@ bool QQmlTypeLoader::Blob::updateQmldir(QQmlQmldirData *data, const QQmlScript::
     // Release this reference at destruction
     m_qmldirs << data;
 
-    if (!import->qualifier.isEmpty()) {
+    const QString &importQualifier = stringAt(import->qualifierIndex);
+    if (!importQualifier.isEmpty()) {
         // Does this library contain any qualified scripts?
         QUrl libraryUrl(qmldirUrl);
         const QmldirContent *qmldir = typeLoader()->qmldirContent(qmldirIdentifier, qmldirUrl);
@@ -1230,43 +1231,45 @@ bool QQmlTypeLoader::Blob::updateQmldir(QQmlQmldirData *data, const QQmlScript::
             QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
             addDependency(blob);
 
-            scriptImported(blob, import->location.start, script.nameSpace, import->qualifier);
+            scriptImported(blob, import->location, script.nameSpace, importQualifier);
         }
     }
 
     return true;
 }
 
-bool QQmlTypeLoader::Blob::addImport(const QQmlScript::Import &import, QList<QQmlError> *errors)
+bool QQmlTypeLoader::Blob::addImport(const QV4::CompiledData::Import *import, QList<QQmlError> *errors)
 {
     Q_ASSERT(errors);
 
     QQmlImportDatabase *importDatabase = typeLoader()->importDatabase();
 
-    if (import.type == QQmlScript::Import::Script) {
-        QUrl scriptUrl = finalUrl().resolved(QUrl(import.uri));
+    const QString &importUri = stringAt(import->uriIndex);
+    const QString &importQualifier = stringAt(import->qualifierIndex);
+    if (import->type == QV4::CompiledData::Import::ImportScript) {
+        QUrl scriptUrl = finalUrl().resolved(QUrl(importUri));
         QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
         addDependency(blob);
 
-        scriptImported(blob, import.location.start, import.qualifier, QString());
-    } else if (import.type == QQmlScript::Import::Library) {
+        scriptImported(blob, import->location, importQualifier, QString());
+    } else if (import->type == QV4::CompiledData::Import::ImportLibrary) {
         QString qmldirFilePath;
         QString qmldirUrl;
 
-        if (QQmlMetaType::isLockedModule(import.uri, import.majorVersion)) {
+        if (QQmlMetaType::isLockedModule(importUri, import->majorVersion)) {
             //Locked modules are checked first, to save on filesystem checks
-            if (!m_importCache.addLibraryImport(importDatabase, import.uri, import.qualifier, import.majorVersion,
-                                          import.minorVersion, QString(), QString(), false, errors))
+            if (!m_importCache.addLibraryImport(importDatabase, importUri, importQualifier, import->majorVersion,
+                                          import->minorVersion, QString(), QString(), false, errors))
                 return false;
 
-        } else if (m_importCache.locateQmldir(importDatabase, import.uri, import.majorVersion, import.minorVersion,
+        } else if (m_importCache.locateQmldir(importDatabase, importUri, import->majorVersion, import->minorVersion,
                                  &qmldirFilePath, &qmldirUrl)) {
             // This is a local library import
-            if (!m_importCache.addLibraryImport(importDatabase, import.uri, import.qualifier, import.majorVersion,
-                                          import.minorVersion, qmldirFilePath, qmldirUrl, false, errors))
+            if (!m_importCache.addLibraryImport(importDatabase, importUri, importQualifier, import->majorVersion,
+                                          import->minorVersion, qmldirFilePath, qmldirUrl, false, errors))
                 return false;
 
-            if (!import.qualifier.isEmpty()) {
+            if (!importQualifier.isEmpty()) {
                 // Does this library contain any qualified scripts?
                 QUrl libraryUrl(qmldirUrl);
                 const QmldirContent *qmldir = typeLoader()->qmldirContent(qmldirFilePath, qmldirUrl);
@@ -1275,34 +1278,34 @@ bool QQmlTypeLoader::Blob::addImport(const QQmlScript::Import &import, QList<QQm
                     QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
                     addDependency(blob);
 
-                    scriptImported(blob, import.location.start, script.nameSpace, import.qualifier);
+                    scriptImported(blob, import->location, script.nameSpace, importQualifier);
                 }
             }
         } else {
             // Is this a module?
-            if (QQmlMetaType::isAnyModule(import.uri)) {
-                if (!m_importCache.addLibraryImport(importDatabase, import.uri, import.qualifier, import.majorVersion,
-                                              import.minorVersion, QString(), QString(), false, errors))
+            if (QQmlMetaType::isAnyModule(importUri)) {
+                if (!m_importCache.addLibraryImport(importDatabase, importUri, importQualifier, import->majorVersion,
+                                              import->minorVersion, QString(), QString(), false, errors))
                     return false;
             } else {
                 // We haven't yet resolved this import
-                m_unresolvedImports.insert(&import, 0);
+                m_unresolvedImports.insert(import, 0);
 
                 // Query any network import paths for this library
                 QStringList remotePathList = importDatabase->importPathList(QQmlImportDatabase::Remote);
                 if (!remotePathList.isEmpty()) {
                     // Add this library and request the possible locations for it
-                    if (!m_importCache.addLibraryImport(importDatabase, import.uri, import.qualifier, import.majorVersion,
-                                                  import.minorVersion, QString(), QString(), true, errors))
+                    if (!m_importCache.addLibraryImport(importDatabase, importUri, importQualifier, import->majorVersion,
+                                                  import->minorVersion, QString(), QString(), true, errors))
                         return false;
 
                     // Probe for all possible locations
                     int priority = 0;
                     for (int version = QQmlImports::FullyVersioned; version <= QQmlImports::Unversioned; ++version) {
                         foreach (const QString &path, remotePathList) {
-                            QString qmldirUrl = QQmlImports::completeQmldirPath(import.uri, path, import.majorVersion, import.minorVersion,
+                            QString qmldirUrl = QQmlImports::completeQmldirPath(importUri, path, import->majorVersion, import->minorVersion,
                                                                                 static_cast<QQmlImports::ImportVersion>(version));
-                            if (!fetchQmldir(QUrl(qmldirUrl), &import, ++priority, errors))
+                            if (!fetchQmldir(QUrl(qmldirUrl), import, ++priority, errors))
                                 return false;
                         }
                     }
@@ -1310,25 +1313,25 @@ bool QQmlTypeLoader::Blob::addImport(const QQmlScript::Import &import, QList<QQm
             }
         }
     } else {
-        Q_ASSERT(import.type == QQmlScript::Import::File);
+        Q_ASSERT(import->type == QV4::CompiledData::Import::ImportFile);
 
         bool incomplete = false;
 
         QUrl qmldirUrl;
-        if (import.qualifier.isEmpty()) {
-            qmldirUrl = finalUrl().resolved(QUrl(import.uri + QLatin1String("/qmldir")));
+        if (importQualifier.isEmpty()) {
+            qmldirUrl = finalUrl().resolved(QUrl(importUri + QLatin1String("/qmldir")));
             if (!QQmlImports::isLocal(qmldirUrl)) {
                 // This is a remote file; the import is currently incomplete
                 incomplete = true;
             }
         }
 
-        if (!m_importCache.addFileImport(importDatabase, import.uri, import.qualifier, import.majorVersion,
-                                   import.minorVersion, incomplete, errors))
+        if (!m_importCache.addFileImport(importDatabase, importUri, importQualifier, import->majorVersion,
+                                   import->minorVersion, incomplete, errors))
             return false;
 
         if (incomplete) {
-            if (!fetchQmldir(qmldirUrl, &import, 1, errors))
+            if (!fetchQmldir(qmldirUrl, import, 1, errors))
                 return false;
         }
     }
@@ -1394,15 +1397,15 @@ void QQmlTypeLoader::Blob::dependencyComplete(QQmlDataBlob *blob)
     if (blob->type() == QQmlDataBlob::QmldirFile) {
         QQmlQmldirData *data = static_cast<QQmlQmldirData *>(blob);
 
-        const QQmlScript::Import *import = data->import();
+        const QV4::CompiledData::Import *import = data->import();
 
         QList<QQmlError> errors;
         if (!qmldirDataAvailable(data, &errors)) {
             Q_ASSERT(errors.size());
             QQmlError error(errors.takeFirst());
             error.setUrl(m_importCache.baseUrl());
-            error.setLine(import->location.start.line);
-            error.setColumn(import->location.start.column);
+            error.setLine(import->location.line);
+            error.setColumn(import->location.column);
             errors.prepend(error); // put it back on the list after filling out information.
             setError(errors);
         }
@@ -1413,7 +1416,7 @@ bool QQmlTypeLoader::Blob::qmldirDataAvailable(QQmlQmldirData *data, QList<QQmlE
 {
     bool resolve = true;
 
-    const QQmlScript::Import *import = data->import();
+    const QV4::CompiledData::Import *import = data->import();
     data->setImport(0);
 
     int priority = data->priority();
@@ -1421,7 +1424,7 @@ bool QQmlTypeLoader::Blob::qmldirDataAvailable(QQmlQmldirData *data, QList<QQmlE
 
     if (import) {
         // Do we need to resolve this import?
-        QHash<const QQmlScript::Import *, int>::iterator it = m_unresolvedImports.find(import);
+        QHash<const QV4::CompiledData::Import *, int>::iterator it = m_unresolvedImports.find(import);
         if (it != m_unresolvedImports.end()) {
             resolve = (*it == 0) || (*it > priority);
         }
@@ -1984,7 +1987,6 @@ QQmlTypeData::~QQmlTypeData()
 
     if (m_compiledData)
         m_compiledData->release();
-    delete m_implicitImport;
 }
 
 const QList<QQmlTypeData::ScriptReference> &QQmlTypeData::resolvedScripts() const
@@ -2092,6 +2094,7 @@ void QQmlTypeData::done()
         compile();
 
     m_document.reset();
+    m_implicitImport = 0;
 }
 
 void QQmlTypeData::completed()
@@ -2139,6 +2142,8 @@ void QQmlTypeData::dataReceived(const Data &data)
         return;
     }
 
+    m_stringPool = &m_document->jsGenerator.strings;
+
     m_importCache.setBaseUrl(finalUrl(), finalUrlString());
 
     // For remote URLs, we don't delay the loading of the implicit import
@@ -2150,9 +2155,10 @@ void QQmlTypeData::dataReceived(const Data &data)
             if (!loadImplicitImport())
                 return;
             // This qmldir is for the implicit import
-            m_implicitImport = new QQmlScript::Import;
-            m_implicitImport->uri = QLatin1String(".");
-            m_implicitImport->qualifier = QString();
+            QQmlJS::MemoryPool *pool = m_document->jsParserEngine.pool();
+            m_implicitImport = pool->New<QV4::CompiledData::Import>();
+            m_implicitImport->uriIndex = m_document->registerString(QLatin1String("."));
+            m_implicitImport->qualifierIndex = 0; // empty string
             m_implicitImport->majorVersion = -1;
             m_implicitImport->minorVersion = -1;
             QList<QQmlError> errors;
@@ -2166,34 +2172,13 @@ void QQmlTypeData::dataReceived(const Data &data)
 
     QList<QQmlError> errors;
 
-    if (m_imports.isEmpty()) {
-        m_imports.reserve(m_document->imports.count());
-        foreach (QV4::CompiledData::Import *i, m_document->imports) {
-            QQmlScript::Import import;
-            import.uri = m_document->stringAt(i->uriIndex);
-            import.qualifier = m_document->stringAt(i->qualifierIndex);
-            import.majorVersion = i->majorVersion;
-            import.minorVersion = i->minorVersion;
-            import.location.start.line = i->location.line;
-            import.location.start.column = i->location.column;
-
-            switch (i->type) {
-            case QV4::CompiledData::Import::ImportFile: import.type = QQmlScript::Import::File; break;
-            case QV4::CompiledData::Import::ImportLibrary: import.type = QQmlScript::Import::Library; break;
-            case QV4::CompiledData::Import::ImportScript: import.type = QQmlScript::Import::Script; break;
-            default: break;
-            }
-            m_imports << import;
-        }
-    }
-
-    foreach (const QQmlScript::Import &import, m_imports) {
+    foreach (QV4::CompiledData::Import *import, m_document->imports) {
         if (!addImport(import, &errors)) {
             Q_ASSERT(errors.size());
             QQmlError error(errors.takeFirst());
             error.setUrl(m_importCache.baseUrl());
-            error.setLine(import.location.start.line);
-            error.setColumn(import.location.start.column);
+            error.setLine(import->location.line);
+            error.setColumn(import->location.column);
             errors.prepend(error); // put it back on the list after filling out information.
             setError(errors);
             return;
@@ -2215,16 +2200,16 @@ void QQmlTypeData::allDependenciesDone()
     if (!m_typesResolved) {
         // Check that all imports were resolved
         QList<QQmlError> errors;
-        QHash<const QQmlScript::Import *, int>::const_iterator it = m_unresolvedImports.constBegin(), end = m_unresolvedImports.constEnd();
+        QHash<const QV4::CompiledData::Import *, int>::const_iterator it = m_unresolvedImports.constBegin(), end = m_unresolvedImports.constEnd();
         for ( ; it != end; ++it) {
             if (*it == 0) {
                 // This import was not resolved
-                foreach (const QQmlScript::Import *import, m_unresolvedImports.keys()) {
+                foreach (const QV4::CompiledData::Import *import, m_unresolvedImports.keys()) {
                     QQmlError error;
-                    error.setDescription(QQmlTypeLoader::tr("module \"%1\" is not installed").arg(import->uri));
+                    error.setDescription(QQmlTypeLoader::tr("module \"%1\" is not installed").arg(stringAt(import->uriIndex)));
                     error.setUrl(m_importCache.baseUrl());
-                    error.setLine(import->location.start.line);
-                    error.setColumn(import->location.start.column);
+                    error.setLine(import->location.line);
+                    error.setColumn(import->location.column);
                     errors.prepend(error);
                 }
             }
@@ -2439,7 +2424,7 @@ bool QQmlTypeData::resolveType(const QQmlScript::TypeReference *parserRef, int &
     return true;
 }
 
-void QQmlTypeData::scriptImported(QQmlScriptBlob *blob, const QQmlScript::Location &location, const QString &qualifier, const QString &/*nameSpace*/)
+void QQmlTypeData::scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &/*nameSpace*/)
 {
     ScriptReference ref;
     ref.script = blob;
@@ -2622,6 +2607,8 @@ 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);
@@ -2645,31 +2632,13 @@ void QQmlScriptBlob::dataReceived(const Data &data)
     m_importCache.setBaseUrl(finalUrl(), finalUrlString());
 
     for (quint32 i = 0; i < qmlUnit->nImports; ++i) {
-        const QV4::CompiledData::Import *imp = qmlUnit->importAt(i);
-        QQmlScript::Import import;
-        import.uri = qmlUnit->header.stringAt(imp->uriIndex);
-        import.qualifier = qmlUnit->header.stringAt(imp->qualifierIndex);
-        import.majorVersion = imp->majorVersion;
-        import.minorVersion = imp->minorVersion;
-        import.location.start.line = imp->location.line;
-        import.location.start.column = imp->location.column;
-
-        switch (imp->type) {
-        case QV4::CompiledData::Import::ImportFile: import.type = QQmlScript::Import::File; break;
-        case QV4::CompiledData::Import::ImportLibrary: import.type = QQmlScript::Import::Library; break;
-        case QV4::CompiledData::Import::ImportScript: import.type = QQmlScript::Import::Script; break;
-        default: break;
-        }
-        m_imports << import;
-    }
-
-    foreach (const QQmlScript::Import &import, m_imports) {
+        const QV4::CompiledData::Import *import = qmlUnit->importAt(i);
         if (!addImport(import, &errors)) {
             Q_ASSERT(errors.size());
             QQmlError error(errors.takeFirst());
             error.setUrl(m_importCache.baseUrl());
-            error.setLine(import.location.start.line);
-            error.setColumn(import.location.start.column);
+            error.setLine(import->location.line);
+            error.setColumn(import->location.column);
             errors.prepend(error); // put it back on the list after filling out information.
             setError(errors);
             return;
@@ -2719,7 +2688,7 @@ void QQmlScriptBlob::done()
     m_importCache.populateCache(m_scriptData->importCache);
 }
 
-void QQmlScriptBlob::scriptImported(QQmlScriptBlob *blob, const QQmlScript::Location &location, const QString &qualifier, const QString &nameSpace)
+void QQmlScriptBlob::scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace)
 {
     ScriptReference ref;
     ref.script = blob;
@@ -2740,12 +2709,12 @@ const QString &QQmlQmldirData::content() const
     return m_content;
 }
 
-const QQmlScript::Import *QQmlQmldirData::import() const
+const QV4::CompiledData::Import *QQmlQmldirData::import() const
 {
     return m_import;
 }
 
-void QQmlQmldirData::setImport(const QQmlScript::Import *import)
+void QQmlQmldirData::setImport(const QV4::CompiledData::Import *import)
 {
     m_import = import;
 }
index 24daa35a6f5c0553bbcfbf8a7741977085fe46be..3c0cd99909c36364d6513460de6a8dd633af501f 100644 (file)
@@ -279,25 +279,28 @@ public:
         const QQmlImports &imports() const { return m_importCache; }
 
     protected:
-        bool addImport(const QQmlScript::Import &import, QList<QQmlError> *errors);
+        bool addImport(const QV4::CompiledData::Import *import, QList<QQmlError> *errors);
         bool addPragma(const QmlIR::Pragma &pragma, QList<QQmlError> *errors);
 
-        bool fetchQmldir(const QUrl &url, const QQmlScript::Import *import, int priority, QList<QQmlError> *errors);
-        bool updateQmldir(QQmlQmldirData *data, const QQmlScript::Import *import, QList<QQmlError> *errors);
+        bool fetchQmldir(const QUrl &url, const QV4::CompiledData::Import *import, int priority, QList<QQmlError> *errors);
+        bool updateQmldir(QQmlQmldirData *data, const QV4::CompiledData::Import *import, QList<QQmlError> *errors);
 
     private:
         virtual bool qmldirDataAvailable(QQmlQmldirData *, QList<QQmlError> *);
 
-        virtual void scriptImported(QQmlScriptBlob *, const QQmlScript::Location &, const QString &, const QString &) {}
+        virtual void scriptImported(QQmlScriptBlob *, const QV4::CompiledData::Location &, const QString &, const QString &) {}
 
         virtual void dependencyError(QQmlDataBlob *);
         virtual void dependencyComplete(QQmlDataBlob *);
 
     protected:
+        const QString &stringAt(int index) const { Q_ASSERT(m_stringPool); return m_stringPool->at(index); }
+
         QQmlTypeLoader *m_typeLoader;
         QQmlImports m_importCache;
+        QStringList *m_stringPool; // used to resolve string indices in imports
         bool m_isSingleton;
-        QHash<const QQmlScript::Import *, int> m_unresolvedImports;
+        QHash<const QV4::CompiledData::Import*, int> m_unresolvedImports;
         QList<QQmlQmldirData *> m_qmldirs;
     };
 
@@ -399,7 +402,7 @@ public:
     {
         TypeReference() : type(0), majorVersion(0), minorVersion(0), typeData(0), needsCreation(true) {}
 
-        QQmlScript::Location location;
+        QV4::CompiledData::Location location;
         QQmlType *type;
         int majorVersion;
         int minorVersion;
@@ -412,7 +415,7 @@ public:
     {
         ScriptReference() : script(0) {}
 
-        QQmlScript::Location location;
+        QV4::CompiledData::Location location;
         QString qualifier;
         QQmlScriptBlob *script;
     };
@@ -454,10 +457,9 @@ private:
     void compile();
     bool resolveType(const QQmlScript::TypeReference *parserRef, int &majorVersion, int &minorVersion, TypeReference &ref);
 
-    virtual void scriptImported(QQmlScriptBlob *blob, const QQmlScript::Location &location, const QString &qualifier, const QString &nameSpace);
+    virtual void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace);
 
     QScopedPointer<QmlIR::Document> m_document;
-    QList<QQmlScript::Import> m_imports;
 
     QList<ScriptReference> m_scripts;
 
@@ -472,7 +474,7 @@ private:
 
     QList<TypeDataCallback *> m_callbacks;
 
-    QQmlScript::Import *m_implicitImport;
+    QV4::CompiledData::Import *m_implicitImport;
     bool m_implicitImportLoaded;
     bool loadImplicitImport();
 };
@@ -530,7 +532,7 @@ public:
     {
         ScriptReference() : script(0) {}
 
-        QQmlScript::Location location;
+        QV4::CompiledData::Location location;
         QString qualifier;
         QString nameSpace;
         QQmlScriptBlob *script;
@@ -543,11 +545,10 @@ protected:
     virtual void done();
 
 private:
-    virtual void scriptImported(QQmlScriptBlob *blob, const QQmlScript::Location &location, const QString &qualifier, const QString &nameSpace);
+    virtual void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace);
 
     QList<ScriptReference> m_scripts;
     QQmlScriptData *m_scriptData;
-    QList<QQmlScript::Import> m_imports; // ### temporary until addImport is changed
     QmlIR::Document m_irUnit;
 };
 
@@ -561,8 +562,8 @@ private:
 public:
     const QString &content() const;
 
-    const QQmlScript::Import *import() const;
-    void setImport(const QQmlScript::Import *);
+    const QV4::CompiledData::Import *import() const;
+    void setImport(const QV4::CompiledData::Import *);
 
     int priority() const;
     void setPriority(int);
@@ -572,7 +573,7 @@ protected:
 
 private:
     QString m_content;
-    const QQmlScript::Import *m_import;
+    const QV4::CompiledData::Import *m_import;
     int m_priority;
 };