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);
37 const QStringList &qmldirFiles, QQmlJSLogger *logger,
38 const ContextPropertyInfo &contextPropertyInfo)
39 : QQmlJSAotCompiler(importer, fileName, qmldirFiles, logger),
40 m_contextPropertyInfo(contextPropertyInfo)
42 m_flags |= QQmlJSAotCompiler::IsLintCompiler;
46 const QmlIR::Document *document)
49 m_document = document;
50 m_unitGenerator = &document->jsGenerator;
53std::variant<QQmlJSAotFunction, QList<QQmlJS::DiagnosticMessage>>
54QQmlJSLinterCodegen::compileBinding(
const QV4::Compiler::Context *context,
55 const QmlIR::Binding &irBinding, QQmlJS::AST::Node *astNode)
57 const QString name = m_document->stringAt(irBinding.propertyNameIndex);
58 m_logger->setCompileErrorPrefix(
59 u"Could not determine signature of binding for %1: "_s.arg(name));
61 QQmlJSFunctionInitializer initializer(
62 &m_typeResolver, m_currentObject->location, m_currentScope->location, m_logger);
63 QQmlJSCompilePass::Function function = initializer.run(context, name, astNode, irBinding);
65 m_logger->iterateCurrentFunctionMessages([
this](
const Message &error) {
66 diagnose(error.message, error.type, error.loc);
69 m_logger->setCompileErrorPrefix(u"Could not compile binding for %1: "_s.arg(name));
70 m_logger->setCompileSkipPrefix(u"Compilation of binding for %1 was skipped: "_s.arg(name));
72 analyzeFunction(context, &function);
73 if (
const auto errors = finalizeBindingOrFunction())
76 return QQmlJSAotFunction {};
79std::variant<QQmlJSAotFunction, QList<QQmlJS::DiagnosticMessage>>
80QQmlJSLinterCodegen::compileFunction(
const QV4::Compiler::Context *context,
81 const QString &name, QQmlJS::AST::Node *astNode)
83 m_logger->setCompileErrorPrefix(u"Could not determine signature of function %1: "_s.arg(name));
85 QQmlJSFunctionInitializer initializer(
86 &m_typeResolver, m_currentObject->location, m_currentScope->location, m_logger);
87 QQmlJSCompilePass::Function function = initializer.run(context, name, astNode);
89 m_logger->iterateCurrentFunctionMessages([
this](
const Message &error) {
90 diagnose(error.message, error.type, error.loc);
93 m_logger->setCompileErrorPrefix(u"Could not compile function %1: "_s.arg(name));
94 m_logger->setCompileSkipPrefix(u"Compilation of function %1 was skipped: "_s.arg(name));
95 analyzeFunction(context, &function);
97 if (
const auto errors = finalizeBindingOrFunction())
100 return QQmlJSAotFunction {};
105 m_passManager = passManager;
106 auto managerPriv = QQmlSA::PassManagerPrivate::get(passManager);
107 managerPriv->m_typeResolver = typeResolver();
111 QQmlJSCompilePass::Function *function)
114 QQmlJSCompilePass::BlocksAndAnnotations blocksAndAnnotations =
115 QQmlJSBasicBlocks(context, m_unitGenerator, &m_typeResolver, m_logger)
116 .run(function, ValidateBasicBlocks, dummy);
119 m_unitGenerator, &m_typeResolver, m_logger, blocksAndAnnotations.basicBlocks,
120 blocksAndAnnotations.annotations, m_passManager, m_contextPropertyInfo);
121 lintTypePropgator.setScopesById(m_scopesById);
122 lintTypePropgator.setIdMemberShadows(&m_idMemberShadows);
123 blocksAndAnnotations = lintTypePropgator.run(function);
125 if (m_logger->categorySeverity(qmlCompiler) == QQmlJS::WarningSeverity::Disable)
128 if (!m_logger->currentFunctionHasCompileError()) {
129 blocksAndAnnotations = QQmlJSShadowCheck(m_unitGenerator, &m_typeResolver, m_logger,
130 blocksAndAnnotations.basicBlocks,
131 blocksAndAnnotations.annotations)
135 if (!m_logger->currentFunctionHasCompileError()) {
136 blocksAndAnnotations = QQmlJSStorageInitializer(m_unitGenerator, &m_typeResolver, m_logger,
137 blocksAndAnnotations.basicBlocks,
138 blocksAndAnnotations.annotations)
142 if (!m_logger->currentFunctionHasCompileError()) {
143 blocksAndAnnotations = QQmlJSStorageGeneralizer(m_unitGenerator, &m_typeResolver, m_logger,
144 blocksAndAnnotations.basicBlocks,
145 blocksAndAnnotations.annotations)
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)