• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2020 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 
7 #ifndef COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_IDGEN_H_
8 #define COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_IDGEN_H_
9 
10 #include "common/angleutils.h"
11 #include "compiler/translator/TranslatorMetalDirect/Name.h"
12 
13 namespace sh
14 {
15 
16 // For creating new fresh names.
17 // All names created are marked as SymbolType::AngleInternal.
18 class IdGen : angle::NonCopyable
19 {
20   public:
21     IdGen();
22 
23     Name createNewName(const ImmutableString &baseName);
24     Name createNewName(const Name &baseName);
25     Name createNewName(const char *baseName);
26     Name createNewName(std::initializer_list<ImmutableString> baseNames);
27     Name createNewName(std::initializer_list<Name> baseNames);
28     Name createNewName(std::initializer_list<const char *> baseNames);
29 
30   private:
31     template <typename String, typename StringToImmutable>
32     Name createNewName(size_t count, const String *baseNames, const StringToImmutable &toImmutable);
33 
34   private:
35     unsigned mNext = 0;          // `unsigned` because of "%u" use in sprintf
36     std::string mNewNameBuffer;  // reusable buffer to avoid tons of reallocations
37 };
38 
39 }  // namespace sh
40 
41 #endif  // COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_IDGEN_H_
42