Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "glslengine_p.h"
5#include "glslsymbols_p.h"
6#include "glsltypes_p.h"
7#include "glslparser_p.h"
8
10
11using namespace GLSL;
12
14 : _kind(Error), _line(0)
15{
16}
17
19{
20 return _kind;
21}
22
24{
25 _kind = kind;
26}
27
29{
30 return _fileName;
31}
32
34{
35 _fileName = fileName;
36}
37
39{
40 return _line;
41}
42
44{
45 _line = line;
46}
47
49{
50 return _message;
51}
52
54{
55 _message = message;
56}
57
59 : _blockDiagnosticMessages(false)
60{
61}
62
64{
65 qDeleteAll(_symbols);
66}
67
69{
70 return &(*_identifiers.insert(s).first);
71}
72
73const QString *Engine::identifier(const char *s, int n)
74{
75 return &(*_identifiers.insert(QString::fromLatin1(s, n)).first);
76}
77
78std::unordered_set<QString> Engine::identifiers() const
79{
80 return _identifiers;
81}
82
84{
85 return &(*_numbers.insert(s).first);
86}
87
88const QString *Engine::number(const char *s, int n)
89{
90 return &(*_numbers.insert(QString::fromLatin1(s, n)).first);
91}
92
93std::unordered_set<QString> Engine::numbers() const
94{
95 return _numbers;
96}
97
99{
100 return &_pool;
101}
102
104{
105 static UndefinedType t;
106 return &t;
107}
108
110{
111 static VoidType t;
112 return &t;
113}
114
116{
117 static BoolType t;
118 return &t;
119}
120
122{
123 static IntType t;
124 return &t;
125}
126
128{
129 static UIntType t;
130 return &t;
131}
132
134{
135 static FloatType t;
136 return &t;
137}
138
140{
141 static DoubleType t;
142 return &t;
143}
144
146{
147 return _samplerTypes.intern(SamplerType(kind));
148}
149
150const VectorType *Engine::vectorType(const Type *elementType, int dimension)
151{
152 VectorType *type = const_cast<VectorType *>
153 (_vectorTypes.intern(VectorType(elementType, dimension)));
154 type->populateMembers(this);
155 return type;
156}
157
158const MatrixType *Engine::matrixType(const Type *elementType, int columns, int rows)
159{
160 return _matrixTypes.intern(MatrixType(elementType, columns, rows,
161 vectorType(elementType, rows)));
162}
163
164const ArrayType *Engine::arrayType(const Type *elementType)
165{
166 return _arrayTypes.intern(ArrayType(elementType));
167}
168
169
170QList<DiagnosticMessage> Engine::diagnosticMessages() const
171{
172 return _diagnosticMessages;
173}
174
176{
177 _diagnosticMessages.clear();
178}
179
181{
182 if (! _blockDiagnosticMessages)
183 _diagnosticMessages.append(m);
184}
185
187{
190 m.setLine(line);
191 m.setMessage(message);
193}
194
196{
199 m.setLine(line);
200 m.setMessage(message);
202}
203
205{
206 return _kind == Error;
207}
208
210{
211 return _kind == Warning;
212}
213
215{
216 Namespace *s = new Namespace();
217 _symbols.append(s);
218 return s;
219}
220
222{
223 Struct *s = new Struct(scope);
224 _symbols.append(s);
225 return s;
226}
227
229{
230 Block *s = new Block(scope);
231 _symbols.append(s);
232 return s;
233}
234
236{
237 Function *s = new Function(scope);
238 _symbols.append(s);
239 return s;
240}
241
243{
244 Argument *a = new Argument(function);
245 a->setName(name);
246 a->setType(type);
247 _symbols.append(a);
248 return a;
249}
250
251Variable *Engine::newVariable(Scope *scope, const QString &name, const Type *type, int qualifiers)
252{
253 Variable *var = new Variable(scope);
254 var->setName(name);
255 var->setType(type);
256 var->setQualifiers(qualifiers);
257 _symbols.append(var);
258 return var;
259}
260
262{
263 bool previous = _blockDiagnosticMessages;
264 _blockDiagnosticMessages = block;
265 return previous;
266}
267
269
void setFileName(const QString &fileName)
QString message() const
void setLine(int line)
void setMessage(const QString &message)
QString fileName() const
void setKind(Kind kind)
const UndefinedType * undefinedType()
std::unordered_set< QString > identifiers() const
Namespace * newNamespace()
std::unordered_set< QString > numbers() const
const UIntType * uintType()
Struct * newStruct(Scope *scope=nullptr)
const MatrixType * matrixType(const Type *elementType, int columns, int rows)
const BoolType * boolType()
bool blockDiagnosticMessages(bool block)
MemoryPool * pool()
const QString * identifier(const QString &s)
void clearDiagnosticMessages()
const ArrayType * arrayType(const Type *elementType)
const VoidType * voidType()
const IntType * intType()
const SamplerType * samplerType(int kind)
void error(int line, const QString &message)
void addDiagnosticMessage(const DiagnosticMessage &m)
const VectorType * vectorType(const Type *elementType, int dimension)
const DoubleType * doubleType()
void warning(int line, const QString &message)
Variable * newVariable(Scope *scope, const QString &name, const Type *type, int qualifiers=0)
const QString * number(const QString &s)
QList< DiagnosticMessage > diagnosticMessages() const
Argument * newArgument(Function *function, const QString &name, const Type *type)
Block * newBlock(Scope *scope=nullptr)
const FloatType * floatType()
Function * newFunction(Scope *scope=nullptr)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5871
qDeleteAll(list.begin(), list.end())
Definition glsl_p.h:22
Combined button and popup list for selecting options.
void(^ Block)(void)
const GLfloat * m
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum type
GLuint GLsizei const GLchar * message
GLuint name
GLfloat n
GLdouble s
[6]
Definition qopenglext.h:235
GLdouble GLdouble t
Definition qopenglext.h:243