xref: /aosp_15_r20/external/angle/src/compiler/translator/SymbolUniqueId.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2017 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // SymbolUniqueId.h: Encapsulates a unique id for a symbol.
7 
8 #ifndef COMPILER_TRANSLATOR_SYMBOLUNIQUEID_H_
9 #define COMPILER_TRANSLATOR_SYMBOLUNIQUEID_H_
10 
11 #include "compiler/translator/Common.h"
12 
13 namespace sh
14 {
15 
16 class TSymbolTable;
17 class TSymbol;
18 
19 class TSymbolUniqueId
20 {
21   public:
22     POOL_ALLOCATOR_NEW_DELETE
23     explicit TSymbolUniqueId(const TSymbol &symbol);
24     constexpr TSymbolUniqueId(const TSymbolUniqueId &) = default;
25     TSymbolUniqueId &operator=(const TSymbolUniqueId &);
26     bool operator==(const TSymbolUniqueId &) const;
27     bool operator!=(const TSymbolUniqueId &) const;
28 
get()29     constexpr int get() const { return mId; }
30 
31   private:
32     friend class TSymbolTable;
33     explicit TSymbolUniqueId(TSymbolTable *symbolTable);
34 
35     friend class BuiltInId;
TSymbolUniqueId(int staticId)36     constexpr TSymbolUniqueId(int staticId) : mId(staticId) {}
37 
38     int mId;
39 };
40 
41 enum class SymbolType : uint8_t
42 {
43     BuiltIn,
44     UserDefined,
45     AngleInternal,
46     Empty  // Meaning symbol without a name.
47 };
48 
49 enum class SymbolClass : uint8_t
50 {
51     Function,
52     Variable,
53     Struct,
54     InterfaceBlock
55 };
56 
57 }  // namespace sh
58 
59 #endif  // COMPILER_TRANSLATOR_SYMBOLUNIQUEID_H_
60