aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-utils.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-09-15 05:32:49 +0200
committerTristan Gingold <tgingold@free.fr>2021-09-15 05:32:49 +0200
commit32da824fdd74614455fc104e56f879ee16f595d1 (patch)
tree80d6245fae17cf58500dc9213f20e518330bff15 /src/vhdl/vhdl-utils.adb
parente8f911451c357efb95fd4632148e44de5c633f5e (diff)
downloadghdl-32da824fdd74614455fc104e56f879ee16f595d1.tar.gz
ghdl-32da824fdd74614455fc104e56f879ee16f595d1.tar.bz2
ghdl-32da824fdd74614455fc104e56f879ee16f595d1.zip
vhdl: move Get_Source_Identifier to vhdl-utils
Diffstat (limited to 'src/vhdl/vhdl-utils.adb')
-rw-r--r--src/vhdl/vhdl-utils.adb19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-utils.adb b/src/vhdl/vhdl-utils.adb
index c18892620..16351ad86 100644
--- a/src/vhdl/vhdl-utils.adb
+++ b/src/vhdl/vhdl-utils.adb
@@ -18,6 +18,8 @@ with Name_Table;
with Str_Table;
with Std_Names; use Std_Names;
with Flags;
+with Files_Map;
+
with Vhdl.Std_Package;
with Vhdl.Errors; use Vhdl.Errors;
with PSL.Nodes;
@@ -1988,6 +1990,23 @@ package body Vhdl.Utils is
end case;
end Get_File_Signature;
+ function Get_Source_Identifier (Decl : Node) return Name_Id
+ is
+ use Files_Map;
+ use Name_Table;
+ Loc : constant Location_Type := Get_Location (Decl);
+ Len : constant Natural := Get_Name_Length (Get_Identifier (Decl));
+ subtype Ident_Str is String (1 .. Len);
+ File : Source_File_Entry;
+ Pos : Source_Ptr;
+ Buf : File_Buffer_Acc;
+ begin
+ Location_To_File_Pos (Loc, File, Pos);
+ Buf := Get_File_Source (File);
+ return Get_Identifier
+ (Ident_Str (Buf (Pos .. Pos + Source_Ptr (Len - 1))));
+ end Get_Source_Identifier;
+
function Get_HDL_Node (N : PSL_Node) return Iir is
begin
return Iir (PSL.Nodes.Get_HDL_Node (N));