pascalabcnet/CoreUtils/GeneratedNamesManager.cs
Александр Земляк 1f4b44c2c0
Исправление ошибок при перекомпиляции pcu файлов (#3398)
* Move yield string constants to StringConstants class

* Add GeneratedNamesManager class to store all generated names during unit compilation

* Make GeneratedNamesManager class non static

* Add Utils project to installer files

* Add GeneratedNamesManager usage in CapturedVariablesSubstitutionsManager

* Move GeneratedNamesManager initialization in CompilationUnit constructor

* More GeneratedNamesManager usage

* QuestionPointDesugarVisitor fix
2026-03-08 18:30:33 +03:00

23 lines
820 B
C#

using System.Collections.Generic;
namespace PascalABCCompiler.CoreUtils
{
/// <summary>
/// Хранилище для сгенерированных компилятором переменных
/// </summary>
public class GeneratedNamesManager
{
private readonly Dictionary<string, int> counters = new Dictionary<string, int>();
/// <summary>
/// Возвращает уникальное имя для переданного префикса (используется автоинкремент)
/// </summary>
public string GenerateName(string prefix, string suffix = "")
{
counters.TryGetValue(prefix, out int current);
counters[prefix] = current + 1;
return $"{prefix}{current}{suffix}";
}
}
}