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
glslengine.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
"glslengine_p.h"
7
#
include
"glslsymbols_p.h"
8
#
include
"glsltypes_p.h"
9
#
include
"glslparser_p.h"
10
11
QT_BEGIN_NAMESPACE
12
13
using
namespace
GLSL;
14
15
DiagnosticMessage::DiagnosticMessage()
16
: _kind(Error), _line(0)
17
{
18
}
19
20
DiagnosticMessage::Kind DiagnosticMessage::kind()
const
21
{
22
return
_kind;
23
}
24
25
void
DiagnosticMessage::setKind(Kind kind)
26
{
27
_kind = kind;
28
}
29
30
QString DiagnosticMessage::fileName()
const
31
{
32
return
_fileName;
33
}
34
35
void
DiagnosticMessage::setFileName(
const
QString &fileName)
36
{
37
_fileName = fileName;
38
}
39
40
int
DiagnosticMessage::line()
const
41
{
42
return
_line;
43
}
44
45
void
DiagnosticMessage::setLine(
int
line)
46
{
47
_line = line;
48
}
49
50
QString DiagnosticMessage::message()
const
51
{
52
return
_message;
53
}
54
55
void
DiagnosticMessage::setMessage(
const
QString &message)
56
{
57
_message = message;
58
}
59
60
Engine::Engine()
61
: _blockDiagnosticMessages(
false
)
62
{
63
}
64
65
Engine::~Engine()
66
{
67
qDeleteAll(_symbols);
68
}
69
70
const
QString *Engine::identifier(
const
QString &s)
71
{
72
return
&(*_identifiers.insert(s).first);
73
}
74
75
const
QString *Engine::identifier(
const
char
*s,
int
n)
76
{
77
return
&(*_identifiers.insert(QString::fromLatin1(s, n)).first);
78
}
79
80
std::unordered_set<QString> Engine::identifiers()
const
81
{
82
return
_identifiers;
83
}
84
85
const
QString *Engine::number(
const
QString &s)
86
{
87
return
&(*_numbers.insert(s).first);
88
}
89
90
const
QString *Engine::number(
const
char
*s,
int
n)
91
{
92
return
&(*_numbers.insert(QString::fromLatin1(s, n)).first);
93
}
94
95
std::unordered_set<QString> Engine::numbers()
const
96
{
97
return
_numbers;
98
}
99
100
MemoryPool *Engine::pool()
101
{
102
return
&_pool;
103
}
104
105
const
UndefinedType *Engine::undefinedType()
106
{
107
static
UndefinedType t;
108
return
&t;
109
}
110
111
const
VoidType *Engine::voidType()
112
{
113
static
VoidType t;
114
return
&t;
115
}
116
117
const
BoolType *Engine::boolType()
118
{
119
static
BoolType t;
120
return
&t;
121
}
122
123
const
IntType *Engine::intType()
124
{
125
static
IntType t;
126
return
&t;
127
}
128
129
const
UIntType *Engine::uintType()
130
{
131
static
UIntType t;
132
return
&t;
133
}
134
135
const
FloatType *Engine::floatType()
136
{
137
static
FloatType t;
138
return
&t;
139
}
140
141
const
DoubleType *Engine::doubleType()
142
{
143
static
DoubleType t;
144
return
&t;
145
}
146
147
const
SamplerType *Engine::samplerType(
int
kind)
148
{
149
return
_samplerTypes.intern(SamplerType(kind));
150
}
151
152
const
VectorType *Engine::vectorType(
const
Type *elementType,
int
dimension)
153
{
154
VectorType *type =
const_cast
<VectorType *>
155
(_vectorTypes.intern(VectorType(elementType, dimension)));
156
type->populateMembers(
this
);
157
return
type;
158
}
159
160
const
MatrixType *Engine::matrixType(
const
Type *elementType,
int
columns,
int
rows)
161
{
162
return
_matrixTypes.intern(MatrixType(elementType, columns, rows,
163
vectorType(elementType, rows)));
164
}
165
166
const
ArrayType *Engine::arrayType(
const
Type *elementType)
167
{
168
return
_arrayTypes.intern(ArrayType(elementType));
169
}
170
171
172
QList<DiagnosticMessage> Engine::diagnosticMessages()
const
173
{
174
return
_diagnosticMessages;
175
}
176
177
void
Engine::clearDiagnosticMessages()
178
{
179
_diagnosticMessages.clear();
180
}
181
182
void
Engine::addDiagnosticMessage(
const
DiagnosticMessage &m)
183
{
184
if
(! _blockDiagnosticMessages)
185
_diagnosticMessages.append(m);
186
}
187
188
void
Engine::warning(
int
line,
const
QString &message)
189
{
190
DiagnosticMessage m;
191
m.setKind(DiagnosticMessage::Warning);
192
m.setLine(line);
193
m.setMessage(message);
194
addDiagnosticMessage(m);
195
}
196
197
void
Engine::error(
int
line,
const
QString &message)
198
{
199
DiagnosticMessage m;
200
m.setKind(DiagnosticMessage::Error);
201
m.setLine(line);
202
m.setMessage(message);
203
addDiagnosticMessage(m);
204
}
205
206
bool
DiagnosticMessage::isError()
const
207
{
208
return
_kind == Error;
209
}
210
211
bool
DiagnosticMessage::isWarning()
const
212
{
213
return
_kind == Warning;
214
}
215
216
Namespace *Engine::newNamespace()
217
{
218
Namespace *s =
new
Namespace();
219
_symbols.append(s);
220
return
s;
221
}
222
223
Struct *Engine::newStruct(Scope *scope)
224
{
225
Struct *s =
new
Struct(scope);
226
_symbols.append(s);
227
return
s;
228
}
229
230
Block *Engine::newBlock(Scope *scope)
231
{
232
Block *s =
new
Block(scope);
233
_symbols.append(s);
234
return
s;
235
}
236
237
Function *Engine::newFunction(Scope *scope)
238
{
239
Function *s =
new
Function(scope);
240
_symbols.append(s);
241
return
s;
242
}
243
244
Argument *Engine::newArgument(Function *function,
const
QString &name,
const
Type *type)
245
{
246
Argument *a =
new
Argument(function);
247
a->setName(name);
248
a->setType(type);
249
_symbols.append(a);
250
return
a;
251
}
252
253
Variable *Engine::newVariable(Scope *scope,
const
QString &name,
const
Type *type,
int
qualifiers)
254
{
255
Variable *var =
new
Variable(scope);
256
var->setName(name);
257
var->setType(type);
258
var->setQualifiers(qualifiers);
259
_symbols.append(var);
260
return
var;
261
}
262
263
bool
Engine::blockDiagnosticMessages(
bool
block)
264
{
265
bool
previous = _blockDiagnosticMessages;
266
_blockDiagnosticMessages = block;
267
return
previous;
268
}
269
270
QT_END_NAMESPACE
qtquick3d
src
glslparser
glslengine.cpp
Generated on
for Qt by
1.16.1