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
qqmljsastvisitor_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant
4
5#ifndef QQMLJSASTVISITOR_P_H
6#define QQMLJSASTVISITOR_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
19#include "qqmljsastfwd_p.h"
20#include "qqmljsglobal_p.h"
21
23
24// as done in https://en.wikipedia.org/wiki/X_Macro
25
26#define QQmlJSASTUiClassListToVisit
27 X(UiProgram)
28 X(UiHeaderItemList)
29 X(UiPragmaValueList)
30 X(UiPragma)
31 X(UiImport)
32 X(UiPublicMember)
33 X(UiSourceElement)
34 X(UiObjectDefinition)
35 X(UiObjectInitializer)
36 X(UiObjectBinding)
37 X(UiScriptBinding)
38 X(UiArrayBinding)
39 X(UiParameterList)
40 X(UiObjectMemberList)
41 X(UiArrayMemberList)
42 X(UiQualifiedId)
43 X(UiEnumDeclaration)
44 X(UiEnumMemberList)
45 X(UiVersionSpecifier)
46 X(UiInlineComponent)
47 X(UiAnnotation)
48 X(UiAnnotationList)
49 X(UiRequired)
50
51#define QQmlJSASTQQmlJSClassListToVisit
52 X(TypeExpression)
53 X(ThisExpression)
54 X(IdentifierExpression)
55 X(NullExpression)
56 X(TrueLiteral)
57 X(FalseLiteral)
58 X(SuperLiteral)
59 X(StringLiteral)
60 X(TemplateLiteral)
61 X(NumericLiteral)
62 X(RegExpLiteral)
63 X(ArrayPattern)
64 X(ObjectPattern)
65 X(PatternElementList)
66 X(PatternPropertyList)
67 X(PatternElement)
68 X(PatternProperty)
69 X(Elision)
70 X(NestedExpression)
71 X(IdentifierPropertyName)
72 X(StringLiteralPropertyName)
73 X(NumericLiteralPropertyName)
74 X(ComputedPropertyName)
75 X(ArrayMemberExpression)
76 X(FieldMemberExpression)
77 X(TaggedTemplate)
78 X(NewMemberExpression)
79 X(NewExpression)
80 X(CallExpression)
81 X(ArgumentList)
82 X(PostIncrementExpression)
83 X(PostDecrementExpression)
84 X(DeleteExpression)
85 X(VoidExpression)
86 X(TypeOfExpression)
87 X(PreIncrementExpression)
88 X(PreDecrementExpression)
89 X(UnaryPlusExpression)
90 X(UnaryMinusExpression)
91 X(TildeExpression)
92 X(NotExpression)
93 X(BinaryExpression)
94 X(ConditionalExpression)
95 X(CommaExpression)
96 X(Block)
97 X(StatementList)
98 X(VariableStatement)
99 X(VariableDeclarationList)
100 X(EmptyStatement)
101 X(ExpressionStatement)
102 X(IfStatement)
103 X(DoWhileStatement)
104 X(WhileStatement)
105 X(ForStatement)
106 X(ForEachStatement)
107 X(ContinueStatement)
108 X(BreakStatement)
109 X(ReturnStatement)
110 X(YieldExpression)
111 X(WithStatement)
112 X(SwitchStatement)
113 X(CaseBlock)
114 X(CaseClauses)
115 X(CaseClause)
116 X(DefaultClause)
117 X(LabelledStatement)
118 X(ThrowStatement)
119 X(TryStatement)
120 X(Catch)
121 X(Finally)
122 X(FunctionDeclaration)
123 X(FunctionExpression)
124 X(FormalParameterList)
125 X(ClassExpression)
126 X(ClassDeclaration)
127 X(ClassElementList)
128 X(Program)
129 X(NameSpaceImport)
130 X(ImportSpecifier)
131 X(ImportsList)
132 X(NamedImports)
133 X(FromClause)
134 X(ImportClause)
135 X(ImportDeclaration)
136 X(ExportSpecifier)
137 X(ExportsList)
138 X(ExportClause)
139 X(ExportDeclaration)
140 X(ESModule)
141 X(DebuggerStatement)
142 X(Type)
143 X(TypeAnnotation)
144
146
147namespace QQmlJS { namespace AST {
148
150{
151public:
177
179 virtual ~BaseVisitor();
180
181 virtual bool preVisit(Node *) = 0;
182 virtual void postVisit(Node *) = 0;
183
184#define X(name)
185 virtual bool visit(name *) = 0;
186 virtual void endVisit(name *) = 0;
188#undef X
189
190 virtual void throwRecursionDepthError() = 0;
191
193
194protected:
197};
198
200{
201public:
203
204 bool preVisit(Node *) override { return true; }
206
207#define X(name)
208 bool visit(name *) override { return true; }
209 void endVisit(name *) override { }
211#undef X
212};
213
215{
216public:
217 JSVisitor() = default;
218
219 bool preVisit(Node *) override { return true; }
221
222#define X(name)
223 bool visit(name *) override { return true; }
224 void endVisit(name *) override { }
226#undef X
227
228#define X(name)
229 bool visit(name *) override
230 {
231 Q_ASSERT(false);
232 return false;
233 }
234 void endVisit(name *) override { }
236#undef X
237}; // namespace AST
238} } // namespace AST
239
240QT_END_NAMESPACE
241
242#endif // QQMLJSASTVISITOR_P_H
friend size_t qHash(const SourceLocation &location, size_t seed=0)
SourceLocation startZeroLengthLocation() const
friend bool operator!=(const SourceLocation &a, const SourceLocation &b)
static quint32 offsetFrom(QStringView text, quint32 line, quint32 column, const SourceLocation &startHint=SourceLocation{})
friend SourceLocation combine(const SourceLocation &l1, const SourceLocation &l2)
static SourceLocation fromQSizeType(qsizetype offset, qsizetype length=0, qsizetype line=0, qsizetype column=0)
SourceLocation(quint32 offset=0, quint32 length=0, quint32 line=0, quint32 column=0)
SourceLocation endZeroLengthLocation(QStringView text) const
friend bool operator==(const SourceLocation &a, const SourceLocation &b)
static std::pair< quint32, quint32 > rowAndColumnFrom(QStringView text, quint32 offset, const SourceLocation &startHint=SourceLocation{})
FunctionExpression * asAnonymousFunctionDefinition(Node *n)
Definition qqmljsast.cpp:20
T lastListElement(T head)
T1 cast(T2 *ast)
ClassExpression * asAnonymousClassDefinition(Node *n)
Definition qqmljsast.cpp:30
@ InplaceRightShift
Definition qqmljsast_p.h:74
@ InplaceURightShift
Definition qqmljsast_p.h:79
#define QQMLJS_DECLARE_AST_NODE(name)
Definition qqmljsast_p.h:37
#define QQmlJSASTUiClassListToVisit
#define QQmlJSASTQQmlJSClassListToVisit
#define QQmlJSASTClassListToVisit
#define QML_PARSER_EXPORT
bool contains(const QString &name) const
int indexOf(const QString &name, int from=0) const