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([
this](
const Message &error) {
64 diagnose(error.message, error.type, error.loc);
67 m_logger->setCompileErrorPrefix(u"Could not compile binding for %1: "_s.arg(name));
68 m_logger->setCompileSkipPrefix(u"Compilation of binding for %1 was skipped: "_s.arg(name));
70 analyzeFunction(context, &function);
71 if (
const auto errors = finalizeBindingOrFunction())
74 return QQmlJSAotFunction {};
77std::variant<QQmlJSAotFunction, QList<QQmlJS::DiagnosticMessage>>
78QQmlJSLinterCodegen::compileFunction(
const QV4::Compiler::Context *context,
79 const QString &name, QQmlJS::AST::Node *astNode)
81 m_logger->setCompileErrorPrefix(u"Could not determine signature of function %1: "_s.arg(name));
83 QQmlJSFunctionInitializer initializer(
84 &m_typeResolver, m_currentObject->location, m_currentScope->location, m_logger);
85 QQmlJSCompilePass::Function function = initializer.run(context, name, astNode);
87 m_logger->iterateCurrentFunctionMessages([
this](
const Message &error) {
88 diagnose(error.message, error.type, error.loc);
91 m_logger->setCompileErrorPrefix(u"Could not compile function %1: "_s.arg(name));
92 m_logger->setCompileSkipPrefix(u"Compilation of function %1 was skipped: "_s.arg(name));
93 analyzeFunction(context, &function);
95 if (
const auto errors = finalizeBindingOrFunction())
98 return QQmlJSAotFunction {};
103 m_passManager = passManager;
104 auto managerPriv = QQmlSA::PassManagerPrivate::get(passManager);
105 managerPriv->m_typeResolver = typeResolver();
109 QQmlJSCompilePass::Function *function)
112 QQmlJSCompilePass::BlocksAndAnnotations blocksAndAnnotations =
113 QQmlJSBasicBlocks(context, m_unitGenerator, &m_typeResolver, m_logger)
114 .run(function, ValidateBasicBlocks, dummy);
117 m_context, blocksAndAnnotations.basicBlocks,
118 blocksAndAnnotations.annotations, m_passManager);
119 lintTypePropgator.setIdMemberShadows(&m_idMemberShadows);
120 blocksAndAnnotations = lintTypePropgator.run(function);
122 if (m_logger->categorySeverity(qmlCompiler) == QQmlJS::WarningSeverity::Disable)
125 if (!m_logger->currentFunctionHasCompileError()) {
126 blocksAndAnnotations = QQmlJSShadowCheck(m_unitGenerator, &m_typeResolver, m_logger,
127 blocksAndAnnotations.basicBlocks,
128 blocksAndAnnotations.annotations)
132 if (!m_logger->currentFunctionHasCompileError()) {
133 blocksAndAnnotations = QQmlJSStorageInitializer(m_unitGenerator, &m_typeResolver, m_logger,
134 blocksAndAnnotations.basicBlocks,
135 blocksAndAnnotations.annotations)
139 if (!m_logger->currentFunctionHasCompileError()) {
140 blocksAndAnnotations = QQmlJSStorageGeneralizer(m_unitGenerator, &m_typeResolver, m_logger,
141 blocksAndAnnotations.basicBlocks,
142 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)