fixed GetDeclSymbol

This commit is contained in:
ALEXks
2026-02-04 16:34:19 +03:00
parent 5a1377e7ea
commit 90b311d049
2 changed files with 26 additions and 4 deletions

View File

@@ -563,14 +563,36 @@ namespace Distribution
return declSymbol;
auto it = declPlacesSymbol.find(position_decl);
if (it == declPlacesSymbol.end())
if (it != declPlacesSymbol.end())
return it->second;
else // find nearest
{
MAP<PAIR<STRING, int>, Symbol*> currFile;
for (auto& [position, symb] : declPlacesSymbol)
{
if (position.first == position_decl.first)
currFile[position] = symb;
}
PAIR<int, Symbol*> nearest = { (int)0, NULL };
const int needed_pos = position_decl.second;
for (auto& [position, symb] : currFile)
{
if (nearest.second == NULL)
nearest = { abs(position.second - needed_pos), symb };
if (abs(position.second - needed_pos) < nearest.first)
nearest = { abs(position.second - needed_pos), symb };
}
if (nearest.second)
return nearest.second;
#if __SPF
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
#endif
return NULL;
}
return it->second;
return NULL;
}
Symbol* GetDeclSymbol() const { return declSymbol; }

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2455"
#define VERSION_SPF "2456"