Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmljsshadowcheck_p.h
Go to the documentation of this file.
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// Qt-Security score:significant
4
5#ifndef QQMLJSSHADOWCHECK_P_H
6#define QQMLJSSHADOWCHECK_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17
18#include <private/qqmljscompilepass_p.h>
19
21
22class Q_QMLCOMPILER_EXPORT QQmlJSShadowCheck : public QQmlJSCompilePass
23{
24public:
25 QQmlJSShadowCheck(const QV4::Compiler::JSUnitGenerator *jsUnitGenerator,
26 const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger,
27 const BasicBlocks &basicBlocks, const InstructionAnnotations &annotations)
28 : QQmlJSCompilePass(jsUnitGenerator, typeResolver, logger, basicBlocks, annotations)
29 {}
30
31 ~QQmlJSShadowCheck() = default;
32
33 BlocksAndAnnotations run(const Function *function);
34
35private:
36 struct ResettableStore {
37 QQmlJSRegisterContent accumulatorIn;
38 int instructionOffset = -1;
39 };
40
41 void handleStore(int base, const QString &memberName);
42
43 void generate_LoadProperty(int nameIndex) override;
44 void generate_GetLookup(int index) override;
45 void generate_GetOptionalLookup(int index, int offset) override;
46 void generate_StoreProperty(int nameIndex, int base) override;
47 void generate_SetLookup(int index, int base) override;
48 void generate_CallProperty(int nameIndex, int base, int argc, int argv) override;
49 void generate_CallPropertyLookup(int nameIndex, int base, int argc, int argv) override;
50
51 QV4::Moth::ByteCodeHandler::Verdict startInstruction(QV4::Moth::Instr::Type) override;
52 void endInstruction(QV4::Moth::Instr::Type) override;
53
54 enum Shadowability { NotShadowable, Shadowable };
55 Shadowability checkShadowing(
56 QQmlJSRegisterContent baseType, const QString &propertyName, int baseRegister);
57
58 void checkResettable(QQmlJSRegisterContent accumulatorIn, int instructionOffset);
59
60 Shadowability checkBaseType(QQmlJSRegisterContent baseType);
61
62 QList<ResettableStore> m_resettableStores;
63 QList<QQmlJSRegisterContent> m_baseTypes;
64 QSet<QQmlJSRegisterContent> m_adjustedTypes;
65
66 State m_state;
67};
68
69QT_END_NAMESPACE
70
71#endif // QQMLJSSHADOWCHECK_P_H