aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/synth/synth-vhdl_insts.adb18
-rw-r--r--src/vhdl/vhdl-utils.adb19
-rw-r--r--src/vhdl/vhdl-utils.ads6
3 files changed, 25 insertions, 18 deletions
diff --git a/src/synth/synth-vhdl_insts.adb b/src/synth/synth-vhdl_insts.adb
index c60b1b1a5..1297c71b9 100644
--- a/src/synth/synth-vhdl_insts.adb
+++ b/src/synth/synth-vhdl_insts.adb
@@ -20,7 +20,6 @@ with GNAT.SHA1;
with Types; use Types;
with Types_Utils; use Types_Utils;
-with Files_Map;
with Name_Table;
with Libraries;
with Hash; use Hash;
@@ -208,23 +207,6 @@ package body Synth.Vhdl_Insts is
end case;
end Hash_Const;
- 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 Create_Module_Name (Params : Inst_Params) return Sname
is
use GNAT.SHA1;
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));
diff --git a/src/vhdl/vhdl-utils.ads b/src/vhdl/vhdl-utils.ads
index fbea75776..b2d38334e 100644
--- a/src/vhdl/vhdl-utils.ads
+++ b/src/vhdl/vhdl-utils.ads
@@ -421,6 +421,12 @@ package Vhdl.Utils is
Res : in out String;
Off : in out Natural);
+ -- Like Get_Identifier but return a Name_Id for the same casing as it
+ -- appears in the source file.
+ -- Not useful for analysis as VHDL is case insentive, but could be
+ -- useful for error messages or tooling.
+ function Get_Source_Identifier (Decl : Node) return Name_Id;
+
-- IIR wrapper around Get_HDL_Node/Set_HDL_Node.
function Get_HDL_Node (N : PSL_Node) return Iir;
procedure Set_HDL_Node (N : PSL_Node; Expr : Iir);