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
glslsymbols.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
7#include "glsltypes_p.h"
8#include <QDebug>
9
11
12using namespace GLSL;
13
14Argument::Argument(Function *scope)
15 : Symbol(scope)
16 , _type(nullptr)
17{
18}
19
20const Type *Argument::type() const
21{
22 return _type;
23}
24
25void Argument::setType(const Type *type)
26{
27 _type = type;
28}
29
30Block::Block(Scope *enclosingScope)
31 : Scope(enclosingScope)
32{
33}
34
35QList<Symbol *> Block::members() const
36{
37 return _members.values();
38}
39
40void Block::add(Symbol *symbol)
41{
42 _members.insert(symbol->name(), symbol);
43}
44
45const Type *Block::type() const
46{
47 // ### assert?
48 return nullptr;
49}
50
51Symbol *Block::find(const QString &name) const
52{
53 return _members.value(name);
54}
55
56Variable::Variable(Scope *scope)
57 : Symbol(scope)
58 , _type(nullptr)
59 , _qualifiers(0)
60{
61}
62
63const Type *Variable::type() const
64{
65 return _type;
66}
67
68void Variable::setType(const Type *type)
69{
70 _type = type;
71}
72
73Namespace::Namespace()
74{
75}
76
77Namespace::~Namespace()
78{
79 qDeleteAll(_overloadSets);
80}
81
82QList<Symbol *> Namespace::members() const
83{
84 return _members.values();
85}
86
87void Namespace::add(Symbol *symbol)
88{
89 Symbol *&sym = _members[symbol->name()];
90 if (! sym) {
91 sym = symbol;
92 } else if (Function *fun = symbol->asFunction()) {
93 if (OverloadSet *o = sym->asOverloadSet()) {
94 o->addFunction(fun);
95 } else if (Function *firstFunction = sym->asFunction()) {
96 o = new OverloadSet(this);
97 _overloadSets.append(o);
98 o->setName(symbol->name());
99 o->addFunction(firstFunction);
100 o->addFunction(fun);
101 sym = o;
102 } else {
103 // ### warning? return false?
104 }
105 } else {
106 // ### warning? return false?
107 }
108}
109
110const Type *Namespace::type() const
111{
112 return nullptr;
113}
114
115Symbol *Namespace::find(const QString &name) const
116{
117 return _members.value(name);
118}
119
120QT_END_NAMESPACE
Combined button and popup list for selecting options.