/
n-dimens
/
pascalabcnet
Обзор
Документация
Войти
/
n-dimens
/
pascalabcnet
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Optimizer/OptimizerTools.cs
101 строка
3 KB
samuraiGH
replacing Hashtable with HashSet<T> and Dictionary<TKey, TValue> (#3343)
09 окт 2025, 18:40
Не верифицирован
09 окт 2025, 18:40
ab7d9dd
Код
Авторство
О чём код?
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System.Collections.Generic; using PascalABCCompiler.TreeRealization; using System.Collections; namespace PascalABCCompiler { public class VarInfo { public int cur_ass=0; public int cur_use=0; public int num_use = 0; public int act_num_use = 0; public int num_ass = 0; public location last_ass_loc=null; } public class FldInfo { public int cur_ass = 0; public int cur_use = 0; public int num_use = 0; } public class ParamInfo { public int cur_ass = 0; public int cur_use = 0; public int num_use = 0; public int act_num_use = 0; public int num_ass = 0; } public class OptimizerHelper { private Hashtable ht = new Hashtable(); private Dictionary<var_definition_node, List<CompilerWarningWithLocation>> warns = new Dictionary<var_definition_node, List<CompilerWarningWithLocation>>(); private HashSet<common_function_node> ext_funcs = new HashSet<common_function_node>(); public void AddVariable(var_definition_node vdn) { VarInfo vi = new VarInfo(); if (ht[vdn] == null) ht[vdn] = vi; } public VarInfo GetVariable(var_definition_node vdn) { return (VarInfo)ht[vdn]; } public void AddParameter(common_parameter vdn) { ParamInfo vi = new ParamInfo(); ht[vdn] = vi; } public ParamInfo GetParameter(common_parameter vdn) { return (ParamInfo)ht[vdn]; } public void AddField(class_field fld) { FldInfo vi = new FldInfo(); ht[fld] = vi; } public FldInfo GetField(class_field fld) { return (FldInfo)ht[fld]; } public void AddTempWarning(var_definition_node vdn, CompilerWarningWithLocation cw) { if ( !warns.TryGetValue(vdn, out var lst) ) { lst = new List<CompilerWarningWithLocation>(); warns[vdn] = lst; } lst.Add(cw); } public void AddRealWarning(var_definition_node vdn, List<CompilerWarningWithLocation> cw) { List<CompilerWarningWithLocation> lst = warns[vdn]; cw.AddRange(lst); } public void MarkAsExternal(common_function_node cfn) { ext_funcs.Add(cfn); } public bool IsExternal(common_function_node cfn) { return ext_funcs.Contains(cfn); } } }