1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QQMLJSSHADOWCHECK_P_H
5#define QQMLJSSHADOWCHECK_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16
17#include <private/qqmljscompilepass_p.h>
18
19QT_BEGIN_NAMESPACE
20
21class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSShadowCheck : public QQmlJSCompilePass
22{
23public:
24 QQmlJSShadowCheck(const QV4::Compiler::JSUnitGenerator *jsUnitGenerator,
25 const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger)
26 : QQmlJSCompilePass(jsUnitGenerator, typeResolver, logger)
27 {}
28
29 ~QQmlJSShadowCheck() = default;
30
31 void run(InstructionAnnotations *annotations, const Function *function,
32 QQmlJS::DiagnosticMessage *error);
33
34private:
35 void generate_LoadProperty(int nameIndex) override;
36 void generate_GetLookup(int index) override;
37 void generate_StoreProperty(int nameIndex, int base) override;
38 void generate_SetLookup(int index, int base) override;
39 void generate_CallProperty(int nameIndex, int base, int argc, int argv) override;
40 void generate_CallPropertyLookup(int nameIndex, int base, int argc, int argv) override;
41
42 QV4::Moth::ByteCodeHandler::Verdict startInstruction(QV4::Moth::Instr::Type) override;
43 void endInstruction(QV4::Moth::Instr::Type) override;
44
45 void checkShadowing(
46 const QQmlJSRegisterContent &baseType, const QString &propertyName, int baseRegister);
47
48 InstructionAnnotations *m_annotations = nullptr;
49 State m_state;
50};
51
52QT_END_NAMESPACE
53
54#endif // QQMLJSSHADOWCHECK_P_H
55

source code of qtdeclarative/src/qmlcompiler/qqmljsshadowcheck_p.h