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
glslast_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
3
// Qt-Security score:significant reason:default
4
5
6
#
ifndef
QSSG_GLSLAST_H
7
#
define
QSSG_GLSLAST_H
8
9
//
10
// W A R N I N G
11
// -------------
12
//
13
// This file is not part of the Qt API. It exists purely as an
14
// implementation detail. This header file may change from version to
15
// version without notice, or even be removed.
16
//
17
// We mean it.
18
//
19
20
#
include
<
QtQuick3DGlslParser
/
private
/
glsl_p
.
h
>
21
#
include
<
QtQuick3DGlslParser
/
private
/
glslmemorypool_p
.
h
>
22
#
include
<
qstring
.
h
>
23
24
QT_BEGIN_NAMESPACE
25
26
namespace
GLSL
{
27
28
class
AST;
29
class
TranslationUnitAST;
30
class
ExpressionAST;
31
class
IdentifierExpressionAST;
32
class
LiteralExpressionAST;
33
class
BinaryExpressionAST;
34
class
UnaryExpressionAST;
35
class
TernaryExpressionAST;
36
class
AssignmentExpressionAST;
37
class
MemberAccessExpressionAST;
38
class
FunctionCallExpressionAST;
39
class
FunctionIdentifierAST;
40
class
DeclarationExpressionAST;
41
class
StatementAST;
42
class
ExpressionStatementAST;
43
class
CompoundStatementAST;
44
class
IfStatementAST;
45
class
WhileStatementAST;
46
class
DoStatementAST;
47
class
ForStatementAST;
48
class
JumpStatementAST;
49
class
ReturnStatementAST;
50
class
SwitchStatementAST;
51
class
CaseLabelStatementAST;
52
class
DeclarationStatementAST;
53
class
TypeAST;
54
class
BasicTypeAST;
55
class
NamedTypeAST;
56
class
ArrayTypeAST;
57
class
StructTypeAST;
58
class
LayoutQualifierAST;
59
class
QualifiedTypeAST;
60
class
DeclarationAST;
61
class
PrecisionDeclarationAST;
62
class
ParameterDeclarationAST;
63
class
VariableDeclarationAST;
64
class
TypeDeclarationAST;
65
class
TypeAndVariableDeclarationAST;
66
class
InvariantDeclarationAST;
67
class
InitDeclarationAST;
68
class
FunctionDeclarationAST;
69
class
Visitor;
70
71
template
<
typename
T
>
72
class
Q_QUICK3DGLSLPARSER_EXPORT
List
:
public
Managed
73
{
74
public
:
75
List
(
const
T
&
value_
)
76
:
value
(
value_
),
next
(
this
),
lineno
(0) {}
77
78
List
(
List
*
previous
,
const
T
&
value_
)
79
:
value
(
value_
),
lineno
(0)
80
{
81
next
=
previous
->
next
;
82
previous
->
next
=
this
;
83
}
84
85
List
*
finish
()
86
{
87
List
*
head
=
next
;
88
next
=
nullptr
;
89
return
head
;
90
}
91
92
T
value
;
93
List
*
next
;
94
int
lineno
;
95
};
96
97
// Append two lists, which are assumed to still be circular, pre-finish.
98
template
<
typename
T
>
99
List
<
T
> *
appendLists
(
List
<
T
> *
first
,
List
<
T
> *
second
)
100
{
101
if
(!
first
)
102
return
second
;
103
else
if
(!
second
)
104
return
first
;
105
List
<
T
> *
firstHead
=
first
->
next
;
106
List
<
T
> *
secondHead
=
second
->
next
;
107
first
->
next
=
secondHead
;
108
second
->
next
=
firstHead
;
109
return
second
;
110
}
111
112
class
Q_QUICK3DGLSLPARSER_EXPORT
AST
:
public
Managed
113
{
114
public
:
115
enum
Kind
{
116
Kind_Undefined
,
117
118
// Translation unit
119
Kind_TranslationUnit
,
120
121
// Primary expressions
122
Kind_Identifier
,
123
Kind_Literal
,
124
125
// Unary expressions
126
Kind_PreIncrement
,
127
Kind_PostIncrement
,
128
Kind_PreDecrement
,
129
Kind_PostDecrement
,
130
Kind_UnaryPlus
,
131
Kind_UnaryMinus
,
132
Kind_LogicalNot
,
133
Kind_BitwiseNot
,
134
135
// Binary expressions
136
Kind_Plus
,
137
Kind_Minus
,
138
Kind_Multiply
,
139
Kind_Divide
,
140
Kind_Modulus
,
141
Kind_ShiftLeft
,
142
Kind_ShiftRight
,
143
Kind_Equal
,
144
Kind_NotEqual
,
145
Kind_LessThan
,
146
Kind_LessEqual
,
147
Kind_GreaterThan
,
148
Kind_GreaterEqual
,
149
Kind_LogicalAnd
,
150
Kind_LogicalOr
,
151
Kind_LogicalXor
,
152
Kind_BitwiseAnd
,
153
Kind_BitwiseOr
,
154
Kind_BitwiseXor
,
155
Kind_Comma
,
156
Kind_ArrayAccess
,
157
158
// Other expressions
159
Kind_Conditional
,
160
Kind_MemberAccess
,
161
Kind_FunctionCall
,
162
Kind_MemberFunctionCall
,
163
Kind_FunctionIdentifier
,
164
Kind_DeclarationExpression
,
165
166
// Assignment expressions
167
Kind_Assign
,
168
Kind_AssignPlus
,
169
Kind_AssignMinus
,
170
Kind_AssignMultiply
,
171
Kind_AssignDivide
,
172
Kind_AssignModulus
,
173
Kind_AssignShiftLeft
,
174
Kind_AssignShiftRight
,
175
Kind_AssignAnd
,
176
Kind_AssignOr
,
177
Kind_AssignXor
,
178
179
// Statements
180
Kind_ExpressionStatement
,
181
Kind_CompoundStatement
,
182
Kind_If
,
183
Kind_While
,
184
Kind_Do
,
185
Kind_For
,
186
Kind_Break
,
187
Kind_Continue
,
188
Kind_Discard
,
189
Kind_Return
,
190
Kind_ReturnExpression
,
191
Kind_Switch
,
192
Kind_CaseLabel
,
193
Kind_DefaultLabel
,
194
Kind_DeclarationStatement
,
195
196
// Types
197
Kind_BasicType
,
198
Kind_NamedType
,
199
Kind_ArrayType
,
200
Kind_OpenArrayType
,
201
Kind_StructType
,
202
Kind_AnonymousStructType
,
203
Kind_StructField
,
204
Kind_LayoutQualifier
,
205
Kind_QualifiedType
,
206
207
// Declarations
208
Kind_PrecisionDeclaration
,
209
Kind_ParameterDeclaration
,
210
Kind_VariableDeclaration
,
211
Kind_TypeDeclaration
,
212
Kind_TypeAndVariableDeclaration
,
213
Kind_InvariantDeclaration
,
214
Kind_InitDeclaration
,
215
Kind_FunctionDeclaration
216
};
217
218
virtual
TranslationUnitAST
*
asTranslationUnit
() {
return
nullptr
; }
219
220
virtual
ExpressionAST
*
asExpression
() {
return
nullptr
; }
221
virtual
IdentifierExpressionAST
*
asIdentifierExpression
() {
return
nullptr
; }
222
virtual
LiteralExpressionAST
*
asLiteralExpression
() {
return
nullptr
; }
223
virtual
BinaryExpressionAST
*
asBinaryExpression
() {
return
nullptr
; }
224
virtual
UnaryExpressionAST
*
asUnaryExpression
() {
return
nullptr
; }
225
virtual
TernaryExpressionAST
*
asTernaryExpression
() {
return
nullptr
; }
226
virtual
AssignmentExpressionAST
*
asAssignmentExpression
() {
return
nullptr
; }
227
virtual
MemberAccessExpressionAST
*
asMemberAccessExpression
() {
return
nullptr
; }
228
virtual
FunctionCallExpressionAST
*
asFunctionCallExpression
() {
return
nullptr
; }
229
virtual
FunctionIdentifierAST
*
asFunctionIdentifier
() {
return
nullptr
; }
230
virtual
DeclarationExpressionAST
*
asDeclarationExpression
() {
return
nullptr
; }
231
232
virtual
StatementAST
*
asStatement
() {
return
nullptr
; }
233
virtual
ExpressionStatementAST
*
asExpressionStatement
() {
return
nullptr
; }
234
virtual
CompoundStatementAST
*
asCompoundStatement
() {
return
nullptr
; }
235
virtual
IfStatementAST
*
asIfStatement
() {
return
nullptr
; }
236
virtual
WhileStatementAST
*
asWhileStatement
() {
return
nullptr
; }
237
virtual
DoStatementAST
*
asDoStatement
() {
return
nullptr
; }
238
virtual
ForStatementAST
*
asForStatement
() {
return
nullptr
; }
239
virtual
JumpStatementAST
*
asJumpStatement
() {
return
nullptr
; }
240
virtual
ReturnStatementAST
*
asReturnStatement
() {
return
nullptr
; }
241
virtual
SwitchStatementAST
*
asSwitchStatement
() {
return
nullptr
; }
242
virtual
CaseLabelStatementAST
*
asCaseLabelStatement
() {
return
nullptr
; }
243
virtual
DeclarationStatementAST
*
asDeclarationStatement
() {
return
nullptr
; }
244
245
virtual
TypeAST
*
asType
() {
return
nullptr
; }
246
virtual
BasicTypeAST
*
asBasicType
() {
return
nullptr
; }
247
virtual
NamedTypeAST
*
asNamedType
() {
return
nullptr
; }
248
virtual
ArrayTypeAST
*
asArrayType
() {
return
nullptr
; }
249
virtual
StructTypeAST
*
asStructType
() {
return
nullptr
; }
250
virtual
QualifiedTypeAST
*
asQualifiedType
() {
return
nullptr
; }
251
virtual
LayoutQualifierAST
*
asLayoutQualifier
() {
return
nullptr
; }
252
253
virtual
DeclarationAST
*
asDeclaration
() {
return
nullptr
; }
254
virtual
PrecisionDeclarationAST
*
asPrecisionDeclaration
() {
return
nullptr
; }
255
virtual
ParameterDeclarationAST
*
asParameterDeclaration
() {
return
nullptr
; }
256
virtual
VariableDeclarationAST
*
asVariableDeclaration
() {
return
nullptr
; }
257
virtual
TypeDeclarationAST
*
asTypeDeclaration
() {
return
nullptr
; }
258
virtual
TypeAndVariableDeclarationAST
*
asTypeAndVariableDeclaration
() {
return
nullptr
; }
259
virtual
InvariantDeclarationAST
*
asInvariantDeclaration
() {
return
nullptr
; }
260
virtual
InitDeclarationAST
*
asInitDeclaration
() {
return
nullptr
; }
261
virtual
FunctionDeclarationAST
*
asFunctionDeclaration
() {
return
nullptr
; }
262
263
void
accept
(
Visitor
*
visitor
);
264
static
void
accept
(
AST
*
ast
,
Visitor
*
visitor
);
265
266
template
<
typename
T
>
267
static
void
accept
(
List
<
T
> *
it
,
Visitor
*
visitor
)
268
{
269
for
(;
it
;
it
=
it
->
next
)
270
accept
(
it
->
value
,
visitor
);
271
}
272
273
virtual
void
accept0
(
Visitor
*
visitor
) = 0;
274
275
protected
:
276
AST
(
Kind
_kind
) :
kind
(
_kind
),
lineno
(0) {}
277
278
template
<
typename
T
>
279
static
List
<
T
> *
finish
(
List
<
T
> *
list
)
280
{
281
if
(!
list
)
282
return
nullptr
;
283
return
list
->
finish
();
// convert the circular list with a linked list.
284
}
285
286
public
:
// attributes
287
int
kind
;
288
int
lineno
;
289
290
protected
:
291
~
AST
()
override
{}
// Managed types cannot be deleted.
292
};
293
294
class
Q_QUICK3DGLSLPARSER_EXPORT
TranslationUnitAST
:
public
AST
295
{
296
public
:
297
TranslationUnitAST
(
List
<
DeclarationAST
*> *
declarations_
)
298
:
AST
(
Kind_TranslationUnit
),
declarations
(
finish
(
declarations_
)) {}
299
300
TranslationUnitAST
*
asTranslationUnit
()
override
{
return
this
; }
301
302
void
accept0
(
Visitor
*
visitor
)
override
;
303
304
public
:
// attributes
305
List
<
DeclarationAST
*> *
declarations
;
306
};
307
308
class
Q_QUICK3DGLSLPARSER_EXPORT
ExpressionAST
:
public
AST
309
{
310
protected
:
311
ExpressionAST
(
Kind
_kind
) :
AST
(
_kind
) {}
312
313
public
:
314
ExpressionAST
*
asExpression
()
override
{
return
this
; }
315
};
316
317
class
Q_QUICK3DGLSLPARSER_EXPORT
IdentifierExpressionAST
:
public
ExpressionAST
318
{
319
public
:
320
IdentifierExpressionAST
(
const
QString
*
_name
)
321
:
ExpressionAST
(
Kind_Identifier
),
name
(
_name
) {}
322
323
IdentifierExpressionAST
*
asIdentifierExpression
()
override
{
return
this
; }
324
325
void
accept0
(
Visitor
*
visitor
)
override
;
326
327
public
:
// attributes
328
const
QString
*
name
;
329
};
330
331
class
Q_QUICK3DGLSLPARSER_EXPORT
LiteralExpressionAST
:
public
ExpressionAST
332
{
333
public
:
334
LiteralExpressionAST
(
const
QString
*
_value
)
335
:
ExpressionAST
(
Kind_Literal
),
value
(
_value
) {}
336
337
LiteralExpressionAST
*
asLiteralExpression
()
override
{
return
this
; }
338
339
void
accept0
(
Visitor
*
visitor
)
override
;
340
341
public
:
// attributes
342
const
QString
*
value
;
343
};
344
345
class
Q_QUICK3DGLSLPARSER_EXPORT
BinaryExpressionAST
:
public
ExpressionAST
346
{
347
public
:
348
BinaryExpressionAST
(
Kind
_kind
,
ExpressionAST
*
_left
,
ExpressionAST
*
_right
)
349
:
ExpressionAST
(
_kind
),
left
(
_left
),
right
(
_right
) {}
350
351
BinaryExpressionAST
*
asBinaryExpression
()
override
{
return
this
; }
352
353
void
accept0
(
Visitor
*
visitor
)
override
;
354
355
public
:
// attributes
356
ExpressionAST
*
left
;
357
ExpressionAST
*
right
;
358
};
359
360
class
Q_QUICK3DGLSLPARSER_EXPORT
UnaryExpressionAST
:
public
ExpressionAST
361
{
362
public
:
363
UnaryExpressionAST
(
Kind
_kind
,
ExpressionAST
*
_expr
)
364
:
ExpressionAST
(
_kind
),
expr
(
_expr
) {}
365
366
UnaryExpressionAST
*
asUnaryExpression
()
override
{
return
this
; }
367
368
void
accept0
(
Visitor
*
visitor
)
override
;
369
370
public
:
// attributes
371
ExpressionAST
*
expr
;
372
};
373
374
class
Q_QUICK3DGLSLPARSER_EXPORT
TernaryExpressionAST
:
public
ExpressionAST
375
{
376
public
:
377
TernaryExpressionAST
(
Kind
_kind
,
ExpressionAST
*
_first
,
ExpressionAST
*
_second
,
ExpressionAST
*
_third
)
378
:
ExpressionAST
(
_kind
),
first
(
_first
),
second
(
_second
),
third
(
_third
) {}
379
380
TernaryExpressionAST
*
asTernaryExpression
()
override
{
return
this
; }
381
382
void
accept0
(
Visitor
*
visitor
)
override
;
383
384
public
:
// attributes
385
ExpressionAST
*
first
;
386
ExpressionAST
*
second
;
387
ExpressionAST
*
third
;
388
};
389
390
class
Q_QUICK3DGLSLPARSER_EXPORT
AssignmentExpressionAST
:
public
ExpressionAST
391
{
392
public
:
393
AssignmentExpressionAST
(
Kind
_kind
,
ExpressionAST
*
_variable
,
ExpressionAST
*
_value
)
394
:
ExpressionAST
(
_kind
),
variable
(
_variable
),
value
(
_value
) {}
395
396
AssignmentExpressionAST
*
asAssignmentExpression
()
override
{
return
this
; }
397
398
void
accept0
(
Visitor
*
visitor
)
override
;
399
400
public
:
// attributes
401
ExpressionAST
*
variable
;
402
ExpressionAST
*
value
;
403
};
404
405
class
Q_QUICK3DGLSLPARSER_EXPORT
MemberAccessExpressionAST
:
public
ExpressionAST
406
{
407
public
:
408
MemberAccessExpressionAST
(
ExpressionAST
*
_expr
,
const
QString
*
_field
)
409
:
ExpressionAST
(
Kind_MemberAccess
),
expr
(
_expr
),
field
(
_field
) {}
410
411
MemberAccessExpressionAST
*
asMemberAccessExpression
()
override
{
return
this
; }
412
413
void
accept0
(
Visitor
*
visitor
)
override
;
414
415
public
:
// attributes
416
ExpressionAST
*
expr
;
417
const
QString
*
field
;
418
};
419
420
class
Q_QUICK3DGLSLPARSER_EXPORT
FunctionCallExpressionAST
:
public
ExpressionAST
421
{
422
public
:
423
FunctionCallExpressionAST
(
FunctionIdentifierAST
*
_id
,
424
List
<
ExpressionAST
*> *
_arguments
)
425
:
ExpressionAST
(
Kind_FunctionCall
),
expr
(
nullptr
),
id
(
_id
)
426
,
arguments
(
finish
(
_arguments
)) {}
427
FunctionCallExpressionAST
(
ExpressionAST
*
_expr
,
FunctionIdentifierAST
*
_id
,
428
List
<
ExpressionAST
*> *
_arguments
)
429
:
ExpressionAST
(
Kind_MemberFunctionCall
),
expr
(
_expr
),
id
(
_id
)
430
,
arguments
(
finish
(
_arguments
)) {}
431
432
FunctionCallExpressionAST
*
asFunctionCallExpression
()
override
{
return
this
; }
433
434
void
accept0
(
Visitor
*
visitor
)
override
;
435
436
public
:
// attributes
437
ExpressionAST
*
expr
;
438
FunctionIdentifierAST
*
id
;
439
List
<
ExpressionAST
*> *
arguments
;
440
};
441
442
class
Q_QUICK3DGLSLPARSER_EXPORT
FunctionIdentifierAST
:
public
AST
443
{
444
public
:
445
FunctionIdentifierAST
(
const
QString
*
_name
)
446
:
AST
(
Kind_FunctionIdentifier
),
name
(
_name
),
type
(
nullptr
) {}
447
FunctionIdentifierAST
(
TypeAST
*
_type
)
448
:
AST
(
Kind_FunctionIdentifier
),
name
(
nullptr
),
type
(
_type
) {}
449
450
FunctionIdentifierAST
*
asFunctionIdentifier
()
override
{
return
this
; }
451
452
void
accept0
(
Visitor
*
visitor
)
override
;
453
454
public
:
// attributes
455
const
QString
*
name
;
456
TypeAST
*
type
;
457
};
458
459
class
Q_QUICK3DGLSLPARSER_EXPORT
DeclarationExpressionAST
:
public
ExpressionAST
460
{
461
public
:
462
DeclarationExpressionAST
(
TypeAST
*
_type
,
const
QString
*
_name
,
463
ExpressionAST
*
_initializer
)
464
:
ExpressionAST
(
Kind_DeclarationExpression
),
type
(
_type
)
465
,
name
(
_name
),
initializer
(
_initializer
) {}
466
467
DeclarationExpressionAST
*
asDeclarationExpression
()
override
{
return
this
; }
468
469
void
accept0
(
Visitor
*
visitor
)
override
;
470
471
public
:
// attributes
472
TypeAST
*
type
;
473
const
QString
*
name
;
474
ExpressionAST
*
initializer
;
475
};
476
477
class
Q_QUICK3DGLSLPARSER_EXPORT
StatementAST
:
public
AST
478
{
479
protected
:
480
StatementAST
(
Kind
_kind
) :
AST
(
_kind
) {}
481
482
public
:
483
StatementAST
*
asStatement
()
override
{
return
this
; }
484
};
485
486
class
Q_QUICK3DGLSLPARSER_EXPORT
ExpressionStatementAST
:
public
StatementAST
487
{
488
public
:
489
ExpressionStatementAST
(
ExpressionAST
*
_expr
)
490
:
StatementAST
(
Kind_ExpressionStatement
),
expr
(
_expr
) {}
491
492
ExpressionStatementAST
*
asExpressionStatement
()
override
{
return
this
; }
493
494
void
accept0
(
Visitor
*
visitor
)
override
;
495
496
public
:
// attributes
497
ExpressionAST
*
expr
;
498
};
499
500
class
Q_QUICK3DGLSLPARSER_EXPORT
CompoundStatementAST
:
public
StatementAST
501
{
502
public
:
503
CompoundStatementAST
()
504
:
StatementAST
(
Kind_CompoundStatement
),
statements
(
nullptr
)
505
,
start
(0),
end
(0),
symbol
(
nullptr
) {}
506
CompoundStatementAST
(
List
<
StatementAST
*> *
_statements
)
507
:
StatementAST
(
Kind_CompoundStatement
),
statements
(
finish
(
_statements
))
508
,
start
(0),
end
(0),
symbol
(
nullptr
) {}
509
510
CompoundStatementAST
*
asCompoundStatement
()
override
{
return
this
; }
511
512
void
accept0
(
Visitor
*
visitor
)
override
;
513
514
public
:
// attributes
515
List
<
StatementAST
*> *
statements
;
516
int
start
;
517
int
end
;
518
Block
*
symbol
;
// decoration
519
};
520
521
class
Q_QUICK3DGLSLPARSER_EXPORT
IfStatementAST
:
public
StatementAST
522
{
523
public
:
524
IfStatementAST
(
ExpressionAST
*
_condition
,
StatementAST
*
_thenClause
,
StatementAST
*
_elseClause
)
525
:
StatementAST
(
Kind_If
),
condition
(
_condition
)
526
,
thenClause
(
_thenClause
),
elseClause
(
_elseClause
) {}
527
528
IfStatementAST
*
asIfStatement
()
override
{
return
this
; }
529
530
void
accept0
(
Visitor
*
visitor
)
override
;
531
532
public
:
// attributes
533
ExpressionAST
*
condition
;
534
StatementAST
*
thenClause
;
535
StatementAST
*
elseClause
;
536
};
537
538
class
Q_QUICK3DGLSLPARSER_EXPORT
WhileStatementAST
:
public
StatementAST
539
{
540
public
:
541
WhileStatementAST
(
ExpressionAST
*
_condition
,
StatementAST
*
_body
)
542
:
StatementAST
(
Kind_While
),
condition
(
_condition
),
body
(
_body
) {}
543
544
WhileStatementAST
*
asWhileStatement
()
override
{
return
this
; }
545
546
void
accept0
(
Visitor
*
visitor
)
override
;
547
548
public
:
// attributes
549
ExpressionAST
*
condition
;
550
StatementAST
*
body
;
551
};
552
553
class
Q_QUICK3DGLSLPARSER_EXPORT
DoStatementAST
:
public
StatementAST
554
{
555
public
:
556
DoStatementAST
(
StatementAST
*
_body
,
ExpressionAST
*
_condition
)
557
:
StatementAST
(
Kind_Do
),
body
(
_body
),
condition
(
_condition
) {}
558
559
DoStatementAST
*
asDoStatement
()
override
{
return
this
; }
560
561
void
accept0
(
Visitor
*
visitor
)
override
;
562
563
public
:
// attributes
564
StatementAST
*
body
;
565
ExpressionAST
*
condition
;
566
};
567
568
class
Q_QUICK3DGLSLPARSER_EXPORT
ForStatementAST
:
public
StatementAST
569
{
570
public
:
571
ForStatementAST
(
StatementAST
*
_init
,
ExpressionAST
*
_condition
,
ExpressionAST
*
_increment
,
StatementAST
*
_body
)
572
:
StatementAST
(
Kind_For
),
init
(
_init
),
condition
(
_condition
),
increment
(
_increment
),
body
(
_body
) {}
573
574
ForStatementAST
*
asForStatement
()
override
{
return
this
; }
575
576
void
accept0
(
Visitor
*
visitor
)
override
;
577
578
public
:
// attributes
579
StatementAST
*
init
;
580
ExpressionAST
*
condition
;
581
ExpressionAST
*
increment
;
582
StatementAST
*
body
;
583
};
584
585
class
Q_QUICK3DGLSLPARSER_EXPORT
JumpStatementAST
:
public
StatementAST
586
{
587
public
:
588
JumpStatementAST
(
Kind
_kind
) :
StatementAST
(
_kind
) {}
589
590
JumpStatementAST
*
asJumpStatement
()
override
{
return
this
; }
591
592
void
accept0
(
Visitor
*
visitor
)
override
;
593
};
594
595
class
Q_QUICK3DGLSLPARSER_EXPORT
ReturnStatementAST
:
public
StatementAST
596
{
597
public
:
598
ReturnStatementAST
() :
StatementAST
(
Kind_Return
),
expr
(
nullptr
) {}
599
ReturnStatementAST
(
ExpressionAST
*
_expr
)
600
:
StatementAST
(
Kind_ReturnExpression
),
expr
(
_expr
) {}
601
602
ReturnStatementAST
*
asReturnStatement
()
override
{
return
this
; }
603
604
void
accept0
(
Visitor
*
visitor
)
override
;
605
606
public
:
// attributes
607
ExpressionAST
*
expr
;
608
};
609
610
class
Q_QUICK3DGLSLPARSER_EXPORT
SwitchStatementAST
:
public
StatementAST
611
{
612
public
:
613
SwitchStatementAST
(
ExpressionAST
*
_expr
,
StatementAST
*
_body
)
614
:
StatementAST
(
Kind_Switch
),
expr
(
_expr
),
body
(
_body
) {}
615
616
SwitchStatementAST
*
asSwitchStatement
()
override
{
return
this
; }
617
618
void
accept0
(
Visitor
*
visitor
)
override
;
619
620
public
:
// attributes
621
ExpressionAST
*
expr
;
622
StatementAST
*
body
;
623
};
624
625
class
Q_QUICK3DGLSLPARSER_EXPORT
CaseLabelStatementAST
:
public
StatementAST
626
{
627
public
:
628
CaseLabelStatementAST
() :
StatementAST
(
Kind_DefaultLabel
),
expr
(
nullptr
) {}
629
CaseLabelStatementAST
(
ExpressionAST
*
_expr
)
630
:
StatementAST
(
Kind_CaseLabel
),
expr
(
_expr
) {}
631
632
CaseLabelStatementAST
*
asCaseLabelStatement
()
override
{
return
this
; }
633
634
void
accept0
(
Visitor
*
visitor
)
override
;
635
636
public
:
// attributes
637
ExpressionAST
*
expr
;
638
};
639
640
class
Q_QUICK3DGLSLPARSER_EXPORT
DeclarationStatementAST
:
public
StatementAST
641
{
642
public
:
643
DeclarationStatementAST
(
DeclarationAST
*
_decl
)
644
:
StatementAST
(
Kind_DeclarationStatement
),
decl
(
_decl
) {}
645
646
DeclarationStatementAST
*
asDeclarationStatement
()
override
{
return
this
; }
647
648
void
accept0
(
Visitor
*
visitor
)
override
;
649
650
public
:
// attributes
651
DeclarationAST
*
decl
;
652
};
653
654
class
Q_QUICK3DGLSLPARSER_EXPORT
TypeAST
:
public
AST
655
{
656
protected
:
657
TypeAST
(
Kind
_kind
) :
AST
(
_kind
) {}
658
659
public
:
660
enum
Precision
661
{
662
PrecNotValid
,
// Precision not valid (e.g. structs).
663
PrecUnspecified
,
// Precision not known, but can be validly set.
664
Lowp
,
665
Mediump
,
666
Highp
667
};
668
669
TypeAST
*
asType
()
override
{
return
this
; }
670
671
virtual
Precision
precision
()
const
= 0;
672
673
// Set the precision for the innermost basic type. Returns false if it
674
// is not valid to set a precision (e.g. structs).
675
virtual
bool
setPrecision
(
Precision
precision
) = 0;
676
};
677
678
class
Q_QUICK3DGLSLPARSER_EXPORT
BasicTypeAST
:
public
TypeAST
679
{
680
public
:
681
// Pass the parser's token code: T_VOID, T_VEC4, etc.
682
BasicTypeAST
(
int
_token
,
const
char
*
_name
);
683
684
BasicTypeAST
*
asBasicType
()
override
{
return
this
; }
685
686
void
accept0
(
Visitor
*
visitor
)
override
;
687
688
Precision
precision
()
const
override
;
689
bool
setPrecision
(
Precision
precision
)
override
;
690
691
public
:
// attributes
692
Precision
prec
;
693
int
token
;
694
const
char
*
name
;
695
};
696
697
class
Q_QUICK3DGLSLPARSER_EXPORT
NamedTypeAST
:
public
TypeAST
698
{
699
public
:
700
NamedTypeAST
(
const
QString
*
_name
) :
TypeAST
(
Kind_NamedType
),
name
(
_name
) {}
701
702
NamedTypeAST
*
asNamedType
()
override
{
return
this
; }
703
704
void
accept0
(
Visitor
*
visitor
)
override
;
705
706
Precision
precision
()
const
override
;
707
bool
setPrecision
(
Precision
precision
)
override
;
708
709
public
:
// attributes
710
const
QString
*
name
;
711
};
712
713
class
Q_QUICK3DGLSLPARSER_EXPORT
ArrayTypeAST
:
public
TypeAST
714
{
715
public
:
716
ArrayTypeAST
(
TypeAST
*
_elementType
)
717
:
TypeAST
(
Kind_OpenArrayType
),
elementType
(
_elementType
),
size
(
nullptr
) {}
718
ArrayTypeAST
(
TypeAST
*
_elementType
,
ExpressionAST
*
_size
)
719
:
TypeAST
(
Kind_ArrayType
),
elementType
(
_elementType
),
size
(
_size
) {}
720
721
ArrayTypeAST
*
asArrayType
()
override
{
return
this
; }
722
723
void
accept0
(
Visitor
*
visitor
)
override
;
724
725
Precision
precision
()
const
override
;
726
bool
setPrecision
(
Precision
precision
)
override
;
727
728
public
:
// attributes
729
TypeAST
*
elementType
;
730
ExpressionAST
*
size
;
731
};
732
733
class
Q_QUICK3DGLSLPARSER_EXPORT
StructTypeAST
:
public
TypeAST
734
{
735
public
:
736
class
Field
:
public
AST
737
{
738
public
:
739
Field
(
const
QString
*
_name
)
740
:
AST
(
Kind_StructField
),
name
(
_name
),
type
(
nullptr
) {}
741
742
// Takes the outer shell of an array type with the innermost
743
// element type set to null. The fixInnerTypes() function will
744
// set the innermost element type to a meaningful value.
745
Field
(
const
QString
*
_name
,
TypeAST
*
_type
)
746
:
AST
(
Kind_StructField
),
name
(
_name
),
type
(
_type
) {}
747
748
void
accept0
(
Visitor
*
visitor
)
override
;
749
750
void
setInnerType
(
TypeAST
*
innerType
);
751
752
const
QString
*
name
;
753
TypeAST
*
type
;
754
};
755
756
StructTypeAST
(
List
<
Field
*> *
_fields
)
757
:
TypeAST
(
Kind_AnonymousStructType
),
name
(
nullptr
),
fields
(
finish
(
_fields
)) {}
758
StructTypeAST
(
const
QString
*
_name
,
List
<
Field
*> *
_fields
)
759
:
TypeAST
(
Kind_StructType
),
name
(
_name
),
fields
(
finish
(
_fields
)) {}
760
761
StructTypeAST
*
asStructType
()
override
{
return
this
; }
762
763
void
accept0
(
Visitor
*
visitor
)
override
;
764
765
Precision
precision
()
const
override
;
766
bool
setPrecision
(
Precision
precision
)
override
;
767
768
// Fix the inner types of a field list. The "innerType" will
769
// be copied into the "array holes" of all fields.
770
static
List
<
Field
*> *
fixInnerTypes
(
TypeAST
*
innerType
,
List
<
Field
*> *
fields
);
771
772
public
:
// attributes
773
const
QString
*
name
;
774
List
<
Field
*> *
fields
;
775
};
776
777
class
Q_QUICK3DGLSLPARSER_EXPORT
LayoutQualifierAST
:
public
AST
778
{
779
public
:
780
LayoutQualifierAST
(
const
QString
*
_name
,
const
QString
*
_number
)
781
:
AST
(
Kind_LayoutQualifier
),
name
(
_name
),
number
(
_number
) {}
782
783
LayoutQualifierAST
*
asLayoutQualifier
()
override
{
return
this
; }
784
void
accept0
(
Visitor
*
visitor
)
override
;
785
786
public
:
// attributes
787
const
QString
*
name
;
788
const
QString
*
number
;
789
};
790
791
class
Q_QUICK3DGLSLPARSER_EXPORT
QualifiedTypeAST
:
public
TypeAST
792
{
793
public
:
794
QualifiedTypeAST
(
int
_qualifiers
,
TypeAST
*
_type
,
List
<
LayoutQualifierAST
*> *
_layout_list
)
795
:
TypeAST
(
Kind_QualifiedType
),
qualifiers
(
_qualifiers
),
type
(
_type
)
796
,
layout_list
(
finish
(
_layout_list
)) {}
797
798
enum
799
{
800
StorageMask
= 0x000000FF,
801
NoStorage
= 0x00000000,
802
Const
= 0x00000001,
803
Attribute
= 0x00000002,
804
Varying
= 0x00000003,
805
CentroidVarying
= 0x00000004,
806
In
= 0x00000005,
807
Out
= 0x00000006,
808
CentroidIn
= 0x00000007,
809
CentroidOut
= 0x00000008,
810
PatchIn
= 0x00000009,
811
PatchOut
= 0x0000000A,
812
SampleIn
= 0x0000000B,
813
SampleOut
= 0x0000000C,
814
Uniform
= 0x0000000D,
815
InterpolationMask
= 0x00000F00,
816
NoInterpolation
= 0x00000000,
817
Smooth
= 0x00000100,
818
Flat
= 0x00000200,
819
NoPerspective
= 0x00000300,
820
Invariant
= 0x00010000,
821
Struct
= 0x00020000
822
};
823
824
QualifiedTypeAST
*
asQualifiedType
()
override
{
return
this
; }
825
826
void
accept0
(
Visitor
*
visitor
)
override
;
827
828
Precision
precision
()
const
override
{
return
type
->
precision
(); }
829
bool
setPrecision
(
Precision
precision
)
override
{
return
type
->
setPrecision
(
precision
); }
830
831
public
:
// attributes
832
int
qualifiers
;
833
TypeAST
*
type
;
834
List
<
LayoutQualifierAST
*> *
layout_list
;
835
};
836
837
class
Q_QUICK3DGLSLPARSER_EXPORT
DeclarationAST
:
public
AST
838
{
839
protected
:
840
DeclarationAST
(
Kind
_kind
) :
AST
(
_kind
) {}
841
842
public
:
843
DeclarationAST
*
asDeclaration
()
override
{
return
this
; }
844
};
845
846
class
Q_QUICK3DGLSLPARSER_EXPORT
PrecisionDeclarationAST
:
public
DeclarationAST
847
{
848
public
:
849
PrecisionDeclarationAST
(
TypeAST
::
Precision
_precision
,
TypeAST
*
_type
)
850
:
DeclarationAST
(
Kind_PrecisionDeclaration
)
851
,
precision
(
_precision
),
type
(
_type
) {}
852
853
PrecisionDeclarationAST
*
asPrecisionDeclaration
()
override
{
return
this
; }
854
855
void
accept0
(
Visitor
*
visitor
)
override
;
856
857
public
:
// attributes
858
TypeAST
::
Precision
precision
;
859
TypeAST
*
type
;
860
};
861
862
class
Q_QUICK3DGLSLPARSER_EXPORT
ParameterDeclarationAST
:
public
DeclarationAST
863
{
864
public
:
865
enum
Qualifier
866
{
867
In
,
868
Out
,
869
InOut
870
};
871
ParameterDeclarationAST
(
TypeAST
*
_type
,
Qualifier
_qualifier
,
872
const
QString
*
_name
)
873
:
DeclarationAST
(
Kind_ParameterDeclaration
),
type
(
_type
)
874
,
qualifier
(
_qualifier
),
name
(
_name
) {}
875
876
ParameterDeclarationAST
*
asParameterDeclaration
()
override
{
return
this
; }
877
878
void
accept0
(
Visitor
*
visitor
)
override
;
879
880
public
:
// attributes
881
TypeAST
*
type
;
882
Qualifier
qualifier
;
883
const
QString
*
name
;
884
};
885
886
class
Q_QUICK3DGLSLPARSER_EXPORT
VariableDeclarationAST
:
public
DeclarationAST
887
{
888
public
:
889
VariableDeclarationAST
(
TypeAST
*
_type
,
const
QString
*
_name
,
890
ExpressionAST
*
_initializer
=
nullptr
)
891
:
DeclarationAST
(
Kind_VariableDeclaration
),
type
(
_type
)
892
,
name
(
_name
),
initializer
(
_initializer
) {}
893
894
VariableDeclarationAST
*
asVariableDeclaration
()
override
{
return
this
; }
895
896
void
accept0
(
Visitor
*
visitor
)
override
;
897
898
static
TypeAST
*
declarationType
(
List
<
DeclarationAST
*> *
decls
);
899
900
public
:
// attributes
901
TypeAST
*
type
;
902
const
QString
*
name
;
903
ExpressionAST
*
initializer
;
904
};
905
906
class
Q_QUICK3DGLSLPARSER_EXPORT
TypeDeclarationAST
:
public
DeclarationAST
907
{
908
public
:
909
TypeDeclarationAST
(
TypeAST
*
_type
)
910
:
DeclarationAST
(
Kind_TypeDeclaration
),
type
(
_type
) {}
911
912
TypeDeclarationAST
*
asTypeDeclaration
()
override
{
return
this
; }
913
914
void
accept0
(
Visitor
*
visitor
)
override
;
915
916
public
:
// attributes
917
TypeAST
*
type
;
918
};
919
920
class
Q_QUICK3DGLSLPARSER_EXPORT
TypeAndVariableDeclarationAST
:
public
DeclarationAST
921
{
922
public
:
923
TypeAndVariableDeclarationAST
(
TypeDeclarationAST
*
_typeDecl
,
924
VariableDeclarationAST
*
_varDecl
)
925
:
DeclarationAST
(
Kind_TypeAndVariableDeclaration
)
926
,
typeDecl
(
_typeDecl
),
varDecl
(
_varDecl
) {}
927
928
TypeAndVariableDeclarationAST
*
asTypeAndVariableDeclaration
()
override
{
return
this
; }
929
930
void
accept0
(
Visitor
*
visitor
)
override
;
931
932
public
:
// attributes
933
TypeDeclarationAST
*
typeDecl
;
934
VariableDeclarationAST
*
varDecl
;
935
};
936
937
class
Q_QUICK3DGLSLPARSER_EXPORT
InvariantDeclarationAST
:
public
DeclarationAST
938
{
939
public
:
940
InvariantDeclarationAST
(
const
QString
*
_name
)
941
:
DeclarationAST
(
Kind_InvariantDeclaration
),
name
(
_name
) {}
942
943
InvariantDeclarationAST
*
asInvariantDeclaration
()
override
{
return
this
; }
944
945
void
accept0
(
Visitor
*
visitor
)
override
;
946
947
public
:
// attributes
948
const
QString
*
name
;
949
};
950
951
class
Q_QUICK3DGLSLPARSER_EXPORT
InitDeclarationAST
:
public
DeclarationAST
952
{
953
public
:
954
InitDeclarationAST
(
List
<
DeclarationAST
*> *
_decls
)
955
:
DeclarationAST
(
Kind_InitDeclaration
),
decls
(
finish
(
_decls
)) {}
956
957
InitDeclarationAST
*
asInitDeclaration
()
override
{
return
this
; }
958
959
void
accept0
(
Visitor
*
visitor
)
override
;
960
961
public
:
// attributes
962
List
<
DeclarationAST
*> *
decls
;
963
};
964
965
class
Q_QUICK3DGLSLPARSER_EXPORT
FunctionDeclarationAST
:
public
DeclarationAST
966
{
967
public
:
968
FunctionDeclarationAST
(
TypeAST
*
_returnType
,
const
QString
*
_name
)
969
:
DeclarationAST
(
Kind_FunctionDeclaration
),
returnType
(
_returnType
)
970
,
name
(
_name
),
params
(
nullptr
),
body
(
nullptr
) {}
971
972
FunctionDeclarationAST
*
asFunctionDeclaration
()
override
{
return
this
; }
973
974
void
accept0
(
Visitor
*
visitor
)
override
;
975
976
void
finishParams
() {
params
=
finish
(
params
); }
977
978
bool
isPrototype
()
const
{
return
body
==
nullptr
; }
979
980
public
:
// attributes
981
TypeAST
*
returnType
;
982
const
QString
*
name
;
983
List
<
ParameterDeclarationAST
*> *
params
;
984
StatementAST
*
body
;
985
};
986
987
}
// namespace GLSL
988
989
QT_END_NAMESPACE
990
991
#
endif
// QSSG_GLSLAST_H
GLSL::AST
Definition
glslast_p.h:113
GLSL::ArrayTypeAST
Definition
glslast_p.h:714
GLSL::AssignmentExpressionAST
Definition
glslast_p.h:391
GLSL::BasicTypeAST
Definition
glslast_p.h:679
GLSL::BinaryExpressionAST
Definition
glslast_p.h:346
GLSL::CaseLabelStatementAST
Definition
glslast_p.h:626
GLSL::CompoundStatementAST
Definition
glslast_p.h:501
GLSL::DeclarationAST
Definition
glslast_p.h:838
GLSL::DeclarationExpressionAST
Definition
glslast_p.h:460
GLSL::DeclarationStatementAST
Definition
glslast_p.h:641
GLSL::DoStatementAST
Definition
glslast_p.h:554
GLSL::ExpressionAST
Definition
glslast_p.h:309
GLSL::ExpressionStatementAST
Definition
glslast_p.h:487
GLSL::ForStatementAST
Definition
glslast_p.h:569
GLSL::FunctionCallExpressionAST
Definition
glslast_p.h:421
GLSL::FunctionDeclarationAST
Definition
glslast_p.h:966
GLSL::FunctionIdentifierAST
Definition
glslast_p.h:443
GLSL::IdentifierExpressionAST
Definition
glslast_p.h:318
GLSL::IfStatementAST
Definition
glslast_p.h:522
GLSL::InitDeclarationAST
Definition
glslast_p.h:952
GLSL::InvariantDeclarationAST
Definition
glslast_p.h:938
GLSL::JumpStatementAST
Definition
glslast_p.h:586
GLSL::LayoutQualifierAST
Definition
glslast_p.h:778
GLSL::List
Definition
glslast_p.h:73
GLSL::LiteralExpressionAST
Definition
glslast_p.h:332
GLSL::MemberAccessExpressionAST
Definition
glslast_p.h:406
GLSL::NamedTypeAST
Definition
glslast_p.h:698
GLSL::ParameterDeclarationAST
Definition
glslast_p.h:863
GLSL::PrecisionDeclarationAST
Definition
glslast_p.h:847
GLSL::QualifiedTypeAST
Definition
glslast_p.h:792
GLSL::ReturnStatementAST
Definition
glslast_p.h:596
GLSL::StatementAST
Definition
glslast_p.h:478
GLSL::StructTypeAST
Definition
glslast_p.h:734
GLSL::SwitchStatementAST
Definition
glslast_p.h:611
GLSL::TernaryExpressionAST
Definition
glslast_p.h:375
GLSL::TranslationUnitAST
Definition
glslast_p.h:295
GLSL::TypeAST
Definition
glslast_p.h:655
GLSL::TypeAndVariableDeclarationAST
Definition
glslast_p.h:921
GLSL::TypeDeclarationAST
Definition
glslast_p.h:907
GLSL::UnaryExpressionAST
Definition
glslast_p.h:361
GLSL::VariableDeclarationAST
Definition
glslast_p.h:887
GLSL::WhileStatementAST
Definition
glslast_p.h:539
GLSL
Definition
glslast_p.h:26
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qtquick3d
src
glslparser
glslast_p.h
Generated on
for Qt by
1.16.1