8#include <private/qqmljsbasicblocks_p.h>
9#include <private/qqmljsfunctioninitializer_p.h>
10#include <private/qqmljsimportvisitor_p.h>
11#include <private/qqmljsshadowcheck_p.h>
12#include <private/qqmljsstoragegeneralizer_p.h>
13#include <private/qqmljsstorageinitializer_p.h>
19using namespace Qt::StringLiterals;
23 return lhs.name == rhs.name && lhs.idScope == rhs.idScope
24 && lhs.memberOwnerScope == rhs.memberOwnerScope;
32 return qHashMulti(seed, idShadowsMember.name, idShadowsMember.idScope,
33 idShadowsMember.memberOwnerScope);
36 const QStringList &qmldirFiles, QQmlJSLogger *logger,
37 const QQmlJS::LinterContext &context)
40 m_flags |= QQmlJSAotCompiler::IsLintCompiler;
44 const QmlIR::Document *document)
47 m_document = document;
48 m_unitGenerator = &document->jsGenerator;
51std::variant<QQmlJSAotFunction, QList<QQmlJS::DiagnosticMessage>>
52QQmlJSLinterCodegen::compileBinding(
const QV4::Compiler::Context *context,
53 const QmlIR::Binding &irBinding, QQmlJS::AST::Node *astNode)
55 const QString name = m_document->stringAt(irBinding.propertyNameIndex);
56 m_logger->setCompileErrorPrefix(
57 u"Could not determine signature of binding for %1: "_s.arg(name));
59 QQmlJSFunctionInitializer initializer(
60 &m_typeResolver, m_currentObject->location, m_currentScope->location, m_logger);
61 QQmlJSCompilePass::Function function = initializer.run(context, name, astNode, irBinding);
63 m_logger->iterateCurrentFunctionMessages(
64 [
this](
const Message &error) { diagnose(error.message, error.msgType(), error.loc); });
66 m_logger->setCompileErrorPrefix(u"Could not compile binding for %1: "_s.arg(name));
67 m_logger->setCompileSkipPrefix(u"Compilation of binding for %1 was skipped: "_s.arg(name));
69 analyzeFunction(context, &function);
70 if (
const auto errors = finalizeBindingOrFunction())
73 return QQmlJSAotFunction {};
76std::variant<QQmlJSAotFunction, QList<QQmlJS::DiagnosticMessage>>
77QQmlJSLinterCodegen::compileFunction(
const QV4::Compiler::Context *context,
78 const QString &name, QQmlJS::AST::Node *astNode)
80 m_logger->setCompileErrorPrefix(u"Could not determine signature of function %1: "_s.arg(name));
82 QQmlJSFunctionInitializer initializer(
83 &m_typeResolver, m_currentObject->location, m_currentScope->location, m_logger);
84 QQmlJSCompilePass::Function function = initializer.run(context, name, astNode);
86 m_logger->iterateCurrentFunctionMessages(
87 [
this](
const Message &error) { diagnose(error.message, error.msgType(), error.loc); });
89 m_logger->setCompileErrorPrefix(u"Could not compile function %1: "_s.arg(name));
90 m_logger->setCompileSkipPrefix(u"Compilation of function %1 was skipped: "_s.arg(name));
91 analyzeFunction(context, &function);
93 if (
const auto errors = finalizeBindingOrFunction())
96 return QQmlJSAotFunction {};
101 m_passManager = passManager;
102 auto managerPriv = QQmlSA::PassManagerPrivate::get(passManager);
103 managerPriv->m_typeResolver = typeResolver();
107 QQmlJSCompilePass::Function *function)
110 QQmlJSCompilePass::BlocksAndAnnotations blocksAndAnnotations =
111 QQmlJSBasicBlocks(context, m_unitGenerator, &m_typeResolver, m_logger)
112 .run(function, ValidateBasicBlocks, dummy);
115 m_context, blocksAndAnnotations.basicBlocks,
116 blocksAndAnnotations.annotations, m_passManager);
117 lintTypePropgator.setIdMemberShadows(&m_idMemberShadows);
118 blocksAndAnnotations = lintTypePropgator.run(function);
120 if (m_logger->categorySeverity(qmlCompiler) == QQmlJS::WarningSeverity::Disable)
123 if (!m_logger->currentFunctionHasCompileError()) {
124 blocksAndAnnotations = QQmlJSShadowCheck(m_unitGenerator, &m_typeResolver, m_logger,
125 blocksAndAnnotations.basicBlocks,
126 blocksAndAnnotations.annotations)
130 if (!m_logger->currentFunctionHasCompileError()) {
131 blocksAndAnnotations = QQmlJSStorageInitializer(m_unitGenerator, &m_typeResolver, m_logger,
132 blocksAndAnnotations.basicBlocks,
133 blocksAndAnnotations.annotations)
137 if (!m_logger->currentFunctionHasCompileError()) {
138 blocksAndAnnotations = QQmlJSStorageGeneralizer(m_unitGenerator, &m_typeResolver, m_logger,
139 blocksAndAnnotations.basicBlocks,
140 blocksAndAnnotations.annotations)
QQmlJSLinterCodegen(QQmlJSImporter *importer, const QString &fileName, const QStringList &qmldirFiles, QQmlJSLogger *logger, const QQmlJS::LinterContext &context)
void setDocument(const QmlIR::JSCodeGen *codegen, const QmlIR::Document *document) override
void setPassManager(QQmlSA::PassManager *passManager)
Combined button and popup list for selecting options.
bool operator==(const IdMemberShadow &lhs, const IdMemberShadow &rhs)
bool operator!=(const IdMemberShadow &lhs, const IdMemberShadow &rhs)
size_t qHash(const IdMemberShadow &idShadowsMember, size_t seed)