| 1 | /* |
| 2 | * Copyright 2021 Google LLC |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SKSL_MANGLER |
| 9 | #define SKSL_MANGLER |
| 10 | |
| 11 | #include <string> |
| 12 | #include <string_view> |
| 13 | |
| 14 | namespace SkSL { |
| 15 | |
| 16 | class SymbolTable; |
| 17 | |
| 18 | class Mangler { |
| 19 | public: |
| 20 | /** |
| 21 | * Mangles baseName to create a name that is unique within symbolTable. |
| 22 | */ |
| 23 | std::string uniqueName(std::string_view baseName, SymbolTable* symbolTable); |
| 24 | |
| 25 | void reset() { |
| 26 | fCounter = 0; |
| 27 | } |
| 28 | |
| 29 | private: |
| 30 | int fCounter = 0; |
| 31 | }; |
| 32 | |
| 33 | } // namespace SkSL |
| 34 | |
| 35 | #endif |