1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QSSG_GLSLSYMBOL_H |
5 | #define QSSG_GLSLSYMBOL_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtQuick3DGlslParser/private/glsl_p.h> |
19 | #include <QString> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | namespace GLSL { |
24 | |
25 | class Symbol; |
26 | class Scope; |
27 | |
28 | class Q_QUICK3DGLSLPARSER_EXPORT Symbol |
29 | { |
30 | public: |
31 | Symbol(Scope *scope = nullptr); |
32 | virtual ~Symbol(); |
33 | |
34 | Scope *scope() const; |
35 | void setScope(Scope *scope); |
36 | |
37 | QString name() const; |
38 | void setName(const QString &name); |
39 | |
40 | virtual Scope *asScope() { return nullptr; } |
41 | virtual Struct *asStruct() { return nullptr; } |
42 | virtual Function *asFunction() { return nullptr; } |
43 | virtual Argument *asArgument() { return nullptr; } |
44 | virtual Block *asBlock() { return nullptr; } |
45 | virtual Variable *asVariable() { return nullptr; } |
46 | virtual OverloadSet *asOverloadSet() { return nullptr; } |
47 | virtual Namespace *asNamespace() { return nullptr; } |
48 | |
49 | virtual const Type *type() const = 0; |
50 | |
51 | private: |
52 | Scope *_scope; |
53 | QString _name; |
54 | }; |
55 | |
56 | class Q_QUICK3DGLSLPARSER_EXPORT Scope: public Symbol |
57 | { |
58 | public: |
59 | Scope(Scope *sscope = nullptr); |
60 | |
61 | Symbol *lookup(const QString &name) const; |
62 | |
63 | virtual QList<Symbol *> members() const; |
64 | virtual void add(Symbol *symbol) = 0; |
65 | virtual Symbol *find(const QString &name) const = 0; |
66 | |
67 | Scope *asScope() override { return this; } |
68 | }; |
69 | |
70 | } // namespace GLSL |
71 | |
72 | QT_END_NAMESPACE |
73 | |
74 | #endif // QSSG_GLSLSYMBOL_H |
75 | |