Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
glslast.cpp
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
3
// Qt-Security score:significant reason:default
4
5
6
#
include
"glslast_p.h"
7
#
include
"glslastvisitor_p.h"
8
#
include
"glslparsertable_p.h"
9
10
QT_BEGIN_NAMESPACE
11
12
using
namespace
GLSL;
13
14
void
AST::accept(Visitor *visitor)
15
{
16
if
(visitor->preVisit(
this
))
17
accept0(visitor);
18
visitor->postVisit(
this
);
19
}
20
21
void
AST::accept(AST *ast, Visitor *visitor)
22
{
23
if
(ast)
24
ast->accept(visitor);
25
}
26
27
void
TranslationUnitAST::accept0(Visitor *visitor)
28
{
29
if
(visitor->visit(
this
))
30
accept(declarations, visitor);
31
visitor->endVisit(
this
);
32
}
33
34
void
IdentifierExpressionAST::accept0(Visitor *visitor)
35
{
36
visitor->visit(
this
);
37
visitor->endVisit(
this
);
38
}
39
40
void
LiteralExpressionAST::accept0(Visitor *visitor)
41
{
42
visitor->visit(
this
);
43
visitor->endVisit(
this
);
44
}
45
46
void
BinaryExpressionAST::accept0(Visitor *visitor)
47
{
48
if
(visitor->visit(
this
)) {
49
accept(left, visitor);
50
accept(right, visitor);
51
}
52
visitor->endVisit(
this
);
53
}
54
55
void
UnaryExpressionAST::accept0(Visitor *visitor)
56
{
57
if
(visitor->visit(
this
))
58
accept(expr, visitor);
59
visitor->endVisit(
this
);
60
}
61
62
void
TernaryExpressionAST::accept0(Visitor *visitor)
63
{
64
if
(visitor->visit(
this
)) {
65
accept(first, visitor);
66
accept(second, visitor);
67
accept(third, visitor);
68
}
69
visitor->endVisit(
this
);
70
}
71
72
void
AssignmentExpressionAST::accept0(Visitor *visitor)
73
{
74
if
(visitor->visit(
this
)) {
75
accept(variable, visitor);
76
accept(value, visitor);
77
}
78
visitor->endVisit(
this
);
79
}
80
81
void
MemberAccessExpressionAST::accept0(Visitor *visitor)
82
{
83
if
(visitor->visit(
this
))
84
accept(expr, visitor);
85
visitor->endVisit(
this
);
86
}
87
88
void
FunctionCallExpressionAST::accept0(Visitor *visitor)
89
{
90
if
(visitor->visit(
this
)) {
91
accept(expr, visitor);
92
accept(id, visitor);
93
accept(arguments, visitor);
94
}
95
visitor->endVisit(
this
);
96
}
97
98
void
FunctionIdentifierAST::accept0(Visitor *visitor)
99
{
100
if
(visitor->visit(
this
))
101
accept(type, visitor);
102
visitor->endVisit(
this
);
103
}
104
105
void
DeclarationExpressionAST::accept0(Visitor *visitor)
106
{
107
if
(visitor->visit(
this
)) {
108
accept(type, visitor);
109
accept(initializer, visitor);
110
}
111
visitor->endVisit(
this
);
112
}
113
114
void
ExpressionStatementAST::accept0(Visitor *visitor)
115
{
116
if
(visitor->visit(
this
))
117
accept(expr, visitor);
118
visitor->endVisit(
this
);
119
}
120
121
void
CompoundStatementAST::accept0(Visitor *visitor)
122
{
123
if
(visitor->visit(
this
))
124
accept(statements, visitor);
125
visitor->endVisit(
this
);
126
}
127
128
void
IfStatementAST::accept0(Visitor *visitor)
129
{
130
if
(visitor->visit(
this
)) {
131
accept(condition, visitor);
132
accept(thenClause, visitor);
133
accept(elseClause, visitor);
134
}
135
visitor->endVisit(
this
);
136
}
137
138
void
WhileStatementAST::accept0(Visitor *visitor)
139
{
140
if
(visitor->visit(
this
)) {
141
accept(condition, visitor);
142
accept(body, visitor);
143
}
144
visitor->endVisit(
this
);
145
}
146
147
void
DoStatementAST::accept0(Visitor *visitor)
148
{
149
if
(visitor->visit(
this
)) {
150
accept(body, visitor);
151
accept(condition, visitor);
152
}
153
visitor->endVisit(
this
);
154
}
155
156
void
ForStatementAST::accept0(Visitor *visitor)
157
{
158
if
(visitor->visit(
this
)) {
159
accept(init, visitor);
160
accept(condition, visitor);
161
accept(increment, visitor);
162
accept(body, visitor);
163
}
164
visitor->endVisit(
this
);
165
}
166
167
void
JumpStatementAST::accept0(Visitor *visitor)
168
{
169
visitor->visit(
this
);
170
visitor->endVisit(
this
);
171
}
172
173
void
ReturnStatementAST::accept0(Visitor *visitor)
174
{
175
if
(visitor->visit(
this
))
176
accept(expr, visitor);
177
visitor->endVisit(
this
);
178
}
179
180
void
SwitchStatementAST::accept0(Visitor *visitor)
181
{
182
if
(visitor->visit(
this
)) {
183
accept(expr, visitor);
184
accept(body, visitor);
185
}
186
visitor->endVisit(
this
);
187
}
188
189
void
CaseLabelStatementAST::accept0(Visitor *visitor)
190
{
191
if
(visitor->visit(
this
))
192
accept(expr, visitor);
193
visitor->endVisit(
this
);
194
}
195
196
void
DeclarationStatementAST::accept0(Visitor *visitor)
197
{
198
if
(visitor->visit(
this
))
199
accept(decl, visitor);
200
visitor->endVisit(
this
);
201
}
202
203
BasicTypeAST::BasicTypeAST(
int
_token,
const
char
*_name)
204
: TypeAST(Kind_BasicType), token(_token), name(_name)
205
{
206
switch
(token) {
207
case
GLSLParserTable::T_VOID:
208
case
GLSLParserTable::T_BOOL:
209
case
GLSLParserTable::T_BVEC2:
210
case
GLSLParserTable::T_BVEC3:
211
case
GLSLParserTable::T_BVEC4:
212
prec = PrecNotValid;
213
break
;
214
default
:
215
prec = PrecUnspecified;
216
break
;
217
}
218
}
219
220
void
BasicTypeAST::accept0(Visitor *visitor)
221
{
222
visitor->visit(
this
);
223
visitor->endVisit(
this
);
224
}
225
226
TypeAST::Precision BasicTypeAST::precision()
const
227
{
228
return
prec;
229
}
230
231
bool
BasicTypeAST::setPrecision(Precision precision)
232
{
233
if
(prec == PrecNotValid)
234
return
false
;
235
prec = precision;
236
return
true
;
237
}
238
239
void
NamedTypeAST::accept0(Visitor *visitor)
240
{
241
visitor->visit(
this
);
242
visitor->endVisit(
this
);
243
}
244
245
TypeAST::Precision NamedTypeAST::precision()
const
246
{
247
// Named types are typically structs, which cannot have their precision set.
248
return
PrecNotValid;
249
}
250
251
bool
NamedTypeAST::setPrecision(Precision)
252
{
253
return
false
;
254
}
255
256
void
ArrayTypeAST::accept0(Visitor *visitor)
257
{
258
if
(visitor->visit(
this
)) {
259
accept(elementType, visitor);
260
accept(size, visitor);
261
}
262
visitor->endVisit(
this
);
263
}
264
265
TypeAST::Precision ArrayTypeAST::precision()
const
266
{
267
return
elementType ? elementType->precision() : PrecNotValid;
268
}
269
270
bool
ArrayTypeAST::setPrecision(Precision precision)
271
{
272
if
(elementType)
273
return
elementType->setPrecision(precision);
274
275
return
false
;
276
}
277
278
void
StructTypeAST::accept0(Visitor *visitor)
279
{
280
if
(visitor->visit(
this
))
281
accept(fields, visitor);
282
visitor->endVisit(
this
);
283
}
284
285
TypeAST::Precision StructTypeAST::precision()
const
286
{
287
return
PrecNotValid;
288
}
289
290
bool
StructTypeAST::setPrecision(Precision)
291
{
292
// Structs cannot have a precision set.
293
return
false
;
294
}
295
296
void
StructTypeAST::Field::accept0(Visitor *visitor)
297
{
298
if
(visitor->visit(
this
))
299
accept(type, visitor);
300
visitor->endVisit(
this
);
301
}
302
303
void
StructTypeAST::Field::setInnerType(TypeAST *innerType)
304
{
305
if
(!innerType)
306
return
;
307
TypeAST **parent = &type;
308
TypeAST *inner = type;
309
while
(inner !=
nullptr
) {
310
ArrayTypeAST *array = inner->asArrayType();
311
if
(!array)
312
break
;
313
parent = &(array->elementType);
314
inner = array->elementType;
315
}
316
*parent = innerType;
317
}
318
319
List<StructTypeAST::Field *> *StructTypeAST::fixInnerTypes(TypeAST *innerType, List<Field *> *fields)
320
{
321
if
(!fields)
322
return
fields;
323
List<Field *> *head = fields->next;
324
List<Field *> *current = head;
325
do
{
326
current->value->setInnerType(innerType);
327
current = current->next;
328
}
while
(current && current != head);
329
return
fields;
330
}
331
332
void
LayoutQualifierAST::accept0(Visitor *visitor)
333
{
334
if
(visitor->visit(
this
)) {
335
}
336
visitor->endVisit(
this
);
337
}
338
339
void
QualifiedTypeAST::accept0(Visitor *visitor)
340
{
341
if
(visitor->visit(
this
))
342
accept(type, visitor);
343
visitor->endVisit(
this
);
344
}
345
346
void
PrecisionDeclarationAST::accept0(Visitor *visitor)
347
{
348
if
(visitor->visit(
this
))
349
accept(type, visitor);
350
visitor->endVisit(
this
);
351
}
352
353
void
ParameterDeclarationAST::accept0(Visitor *visitor)
354
{
355
if
(visitor->visit(
this
))
356
accept(type, visitor);
357
visitor->endVisit(
this
);
358
}
359
360
void
VariableDeclarationAST::accept0(Visitor *visitor)
361
{
362
if
(visitor->visit(
this
)) {
363
accept(type, visitor);
364
accept(initializer, visitor);
365
}
366
visitor->endVisit(
this
);
367
}
368
369
TypeAST *VariableDeclarationAST::declarationType(List<DeclarationAST *> *decls)
370
{
371
VariableDeclarationAST *var = decls->value->asVariableDeclaration();
372
return
var ? var->type :
nullptr
;
373
}
374
375
void
TypeDeclarationAST::accept0(Visitor *visitor)
376
{
377
if
(visitor->visit(
this
))
378
accept(type, visitor);
379
visitor->endVisit(
this
);
380
}
381
382
void
TypeAndVariableDeclarationAST::accept0(Visitor *visitor)
383
{
384
if
(visitor->visit(
this
)) {
385
accept(typeDecl, visitor);
386
accept(varDecl, visitor);
387
}
388
visitor->endVisit(
this
);
389
}
390
391
void
InvariantDeclarationAST::accept0(Visitor *visitor)
392
{
393
visitor->visit(
this
);
394
visitor->endVisit(
this
);
395
}
396
397
void
InitDeclarationAST::accept0(Visitor *visitor)
398
{
399
if
(visitor->visit(
this
))
400
accept(decls, visitor);
401
visitor->endVisit(
this
);
402
}
403
404
void
FunctionDeclarationAST::accept0(Visitor *visitor)
405
{
406
if
(visitor->visit(
this
)) {
407
accept(returnType, visitor);
408
accept(params, visitor);
409
accept(body, visitor);
410
}
411
visitor->endVisit(
this
);
412
}
413
414
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtquick3d
src
glslparser
glslast.cpp
Generated on
for Qt by
1.18.0