From 90b311d0498b70b6f62ce6e48c04adaa490e27cf Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 4 Feb 2026 16:34:19 +0300 Subject: [PATCH] fixed GetDeclSymbol --- src/Distribution/Array.h | 28 +++++++++++++++++++++++++--- src/Utils/version.h | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Distribution/Array.h b/src/Distribution/Array.h index 9ac4f44..0a3dea1 100644 --- a/src/Distribution/Array.h +++ b/src/Distribution/Array.h @@ -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, Symbol*> currFile; + for (auto& [position, symb] : declPlacesSymbol) + { + if (position.first == position_decl.first) + currFile[position] = symb; + } + + PAIR 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; } diff --git a/src/Utils/version.h b/src/Utils/version.h index 90774df..05eebf9 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2455" +#define VERSION_SPF "2456"