1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include "glsl.h" 29 #include <QString> 30 31 namespace GLSL { 32 33 class Symbol; 34 class Scope; 35 36 class GLSL_EXPORT Symbol 37 { 38 public: 39 Symbol(Scope *scope = nullptr); 40 virtual ~Symbol(); 41 42 Scope *scope() const; 43 void setScope(Scope *scope); 44 45 QString name() const; 46 void setName(const QString &name); 47 asScope()48 virtual Scope *asScope() { return nullptr; } asStruct()49 virtual Struct *asStruct() { return nullptr; } asFunction()50 virtual Function *asFunction() { return nullptr; } asArgument()51 virtual Argument *asArgument() { return nullptr; } asBlock()52 virtual Block *asBlock() { return nullptr; } asVariable()53 virtual Variable *asVariable() { return nullptr; } asOverloadSet()54 virtual OverloadSet *asOverloadSet() { return nullptr; } asNamespace()55 virtual Namespace *asNamespace() { return nullptr; } 56 57 virtual const Type *type() const = 0; 58 59 private: 60 Scope *_scope; 61 QString _name; 62 }; 63 64 class GLSL_EXPORT Scope: public Symbol 65 { 66 public: 67 Scope(Scope *sscope = nullptr); 68 69 Symbol *lookup(const QString &name) const; 70 71 virtual QList<Symbol *> members() const; 72 virtual void add(Symbol *symbol) = 0; 73 virtual Symbol *find(const QString &name) const = 0; 74 asScope()75 Scope *asScope() override { return this; } 76 }; 77 78 } // namespace GLSL 79