aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlirbuilder_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2014-12-05 16:32:56 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2015-01-08 22:08:19 +0100
commit9d7b27f5bf44a46707e6d50ebf51ecf73f91dd1b (patch)
tree69ec84f34655b892c8bc855aa9a378a4bb2716fa /src/qml/compiler/qqmlirbuilder_p.h
parentbede2a3ac794120be65fa50bfbc8ed04082c10e0 (diff)
Clean up JS .import/.pragma directive scanning
There's a scanner in QQmlJS::Lexer::scanDirectives that can parse those, so let's get rid of extra parser that operates on a string. Instead this way we can do the scanning all in one shot, avoid detaching a copy of the source code string and (most importantly) bring the parser closer to the copy in Qt Creator, which uses the directives approach to extract imports and pragma. Change-Id: Iff6eb8d91a45d8a70f383f953115692be48259de Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
Diffstat (limited to 'src/qml/compiler/qqmlirbuilder_p.h')
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index cc22023f8e..6177b96878 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -41,6 +41,7 @@
#include <private/qqmljsmemorypool_p.h>
#include <private/qv4codegen_p.h>
#include <private/qv4compiler_p.h>
+#include <private/qqmljslexer_p.h>
#include <QTextStream>
#include <QCoreApplication>
@@ -326,10 +327,23 @@ struct Q_QML_PRIVATE_EXPORT Document
int registerString(const QString &str) { return jsGenerator.registerString(str); }
QString stringAt(int index) const { return jsGenerator.stringForIndex(index); }
- void extractScriptMetaData(QString &script, QQmlJS::DiagnosticMessage *error);
static void removeScriptPragmas(QString &script);
};
+struct Q_QML_PRIVATE_EXPORT ScriptDirectivesCollector : public QQmlJS::Directives
+{
+ ScriptDirectivesCollector(QQmlJS::Engine *engine, QV4::Compiler::JSUnitGenerator *unitGenerator);
+
+ QQmlJS::Engine *engine;
+ QV4::Compiler::JSUnitGenerator *jsGenerator;
+ QList<const QV4::CompiledData::Import *> imports;
+ bool hasPragmaLibrary;
+
+ virtual void pragmaLibrary();
+ virtual void importFile(const QString &jsfile, const QString &module, int lineNumber, int column);
+ virtual void importModule(const QString &uri, const QString &version, const QString &module, int lineNumber, int column);
+};
+
struct Q_QML_PRIVATE_EXPORT IRBuilder : public QQmlJS::AST::Visitor
{
Q_DECLARE_TR_FUNCTIONS(QQmlCodeGenerator)