diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-16 10:57:25 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-17 11:06:12 +0000 |
commit | f43c1d902d908c6cd523b0174338ac0c98a30647 (patch) | |
tree | 50fa2c720dd86aa073efcb935e22bb967e01b5de /src/qml/jsruntime/qv4script.cpp | |
parent | 29275ef53ec8e1edb7aad66af94058786c7d1e2f (diff) |
Add support for importing ES modules in .qml files
This is a straight-forward hook into the module implementation in
QV4::ExecutionEngine. Modules are pre-compiled in the QML type loader
thread. That thread keeps track of all pending loading scripts through
the type loader's m_scriptCache. Once a module is compiled, it's
thread-safely registered with the execution engine.
Script instantiation and evaluation is done solely in the QQmlEngine's
thread.
ES Modules are identified in imports as well as qmldir files by the .mjs
extension.
Change-Id: Ie9c59785118afcb49f43a1e176a9f7db00f09428
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4script.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 37c4f27ca9..070c048c8f 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -185,23 +185,7 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(QV4::Compi parser.parseProgram(); - QList<QQmlError> errors; - - const auto diagnosticMessages = parser.diagnosticMessages(); - for (const DiagnosticMessage &m : diagnosticMessages) { - if (m.isWarning()) { - qWarning("%s:%d : %s", qPrintable(fileName), m.loc.startLine, qPrintable(m.message)); - continue; - } - - QQmlError error; - error.setUrl(QUrl(fileName)); - error.setDescription(m.message); - error.setLine(m.loc.startLine); - error.setColumn(m.loc.startColumn); - errors << error; - } - + QList<QQmlError> errors = QQmlEnginePrivate::qmlErrorFromDiagnostics(fileName, parser.diagnosticMessages()); if (!errors.isEmpty()) { if (reportedErrors) *reportedErrors << errors; |