diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-11 12:30:33 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-11 12:42:22 +0100 |
commit | 2940a57decc2433d2c0549c80d94801df6af686b (patch) | |
tree | ae88df4524fe8e700e662aac9f62b03b29a39409 /src | |
parent | df175003e9a77c62c6e0bb45db3274a23ec854d4 (diff) |
QmlCompiler: Allow AOT compilation of JS functions
Previously, only bindings were compiled.
Change-Id: I6e76c3f5e628e60538a0ed754fdd915978b88c1d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qmlcompiler/qqmljscompiler.cpp | 15 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljscompiler_p.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp index 938d1d68d6..6412f47d38 100644 --- a/src/qmlcompiler/qqmljscompiler.cpp +++ b/src/qmlcompiler/qqmljscompiler.cpp @@ -243,6 +243,21 @@ bool qCompileQmlFile(const QString &inputFileName, QQmlJSSaveFunction saveFuncti aotFunctionsByIndex[runtimeFunctionIndices[binding.value.compiledScriptIndex]] = *func; } }); + + std::for_each(object->functionsBegin(), object->functionsEnd(), + [&](const QmlIR::Function &function) { + + qCDebug(lcAotCompiler) << "Compiling function" + << irDocument.stringAt(function.nameIndex); + auto result = aotCompiler->compileFunction(function); + if (auto *error = std::get_if<QQmlJS::DiagnosticMessage>(&result)) { + qCDebug(lcAotCompiler) << "Could not compile function:" + << diagnosticErrorMessage(inputFileName, *error); + } else if (auto *func = std::get_if<QQmlJSAotFunction>(&result)) { + qCInfo(lcAotCompiler) << "Generated code:" << func->code; + aotFunctionsByIndex[runtimeFunctionIndices[function.index]] = *func; + } + }); } if (!checkArgumentsObjectUseInSignalHandlers(irDocument, error)) { diff --git a/src/qmlcompiler/qqmljscompiler_p.h b/src/qmlcompiler/qqmljscompiler_p.h index 6d40c28cc2..1bfb1369c1 100644 --- a/src/qmlcompiler/qqmljscompiler_p.h +++ b/src/qmlcompiler/qqmljscompiler_p.h @@ -77,6 +77,8 @@ public: virtual void setScopeObject(const QmlIR::Object *object) = 0; virtual std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage> compileBinding( const QmlIR::Binding &binding) = 0; + virtual std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage> compileFunction( + const QmlIR::Function &function) = 0; virtual QQmlJSAotFunction globalCode() const = 0; }; |