From 2940a57decc2433d2c0549c80d94801df6af686b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 11 Nov 2020 12:30:33 +0100 Subject: QmlCompiler: Allow AOT compilation of JS functions Previously, only bindings were compiled. Change-Id: I6e76c3f5e628e60538a0ed754fdd915978b88c1d Reviewed-by: Fabian Kosmale --- src/qmlcompiler/qqmljscompiler.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/qmlcompiler/qqmljscompiler.cpp') 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(&result)) { + qCDebug(lcAotCompiler) << "Could not compile function:" + << diagnosticErrorMessage(inputFileName, *error); + } else if (auto *func = std::get_if(&result)) { + qCInfo(lcAotCompiler) << "Generated code:" << func->code; + aotFunctionsByIndex[runtimeFunctionIndices[function.index]] = *func; + } + }); } if (!checkArgumentsObjectUseInSignalHandlers(irDocument, error)) { -- cgit v1.2.3