diff options
-rw-r--r-- | pyGHDL/libghdl/vhdl/utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pyGHDL/libghdl/vhdl/utils.py b/pyGHDL/libghdl/vhdl/utils.py index 3a82f45c0..4dd82e5ff 100644 --- a/pyGHDL/libghdl/vhdl/utils.py +++ b/pyGHDL/libghdl/vhdl/utils.py @@ -36,6 +36,8 @@ from pyTooling.Decorators import export from pyGHDL.libghdl._types import Iir, NameId from pyGHDL.libghdl._decorator import BindToLibGHDL +from pyGHDL.libghdl import name_table, files_map +from pyGHDL.libghdl.vhdl import nodes @export @@ -48,3 +50,12 @@ def Get_Source_Identifier(Decl: Iir) -> NameId: :param Decl: Iir Node. Type: ``Iir`` """ return 0 + +@export +def Get_Source_Identifier_Str(n: Iir) -> str: + loc = nodes.Get_Location(n) + l = name_table.Get_Name_Length(nodes.Get_Identifier(n)) + sfe = files_map.Location_To_File(loc) + pos = files_map.Location_File_To_Pos(loc, sfe) + buf = files_map.Get_File_Buffer(sfe) + return buf[pos:pos+l].decode("utf-8") |