diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-12-12 18:23:58 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-12-12 18:23:58 +0100 |
commit | ccf8b3bf2854641388619e68325998b9ddd229de (patch) | |
tree | a45395387f2a9ac26e542c91c6ea51fa57eff50a /src | |
parent | 85c222d979afd8077568b0c2de4eb922bf34efd2 (diff) | |
download | ghdl-ccf8b3bf2854641388619e68325998b9ddd229de.tar.gz ghdl-ccf8b3bf2854641388619e68325998b9ddd229de.tar.bz2 ghdl-ccf8b3bf2854641388619e68325998b9ddd229de.zip |
Add Location_File_Line_To_Offset.
Diffstat (limited to 'src')
-rw-r--r-- | src/files_map.adb | 11 | ||||
-rw-r--r-- | src/files_map.ads | 5 | ||||
-rw-r--r-- | src/vhdl/python/libghdl/thin.py | 2 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/files_map.adb b/src/files_map.adb index e9d0a2e9e..46d09b04b 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -415,6 +415,17 @@ package body Files_Map is return Coord_To_Col (File, Line_Pos, Natural (Pos - Line_Pos)); end Location_File_Line_To_Col; + function Location_File_Line_To_Offset + (Loc : Location_Type; File : Source_File_Entry; Line : Positive) + return Natural + is + F : Source_File_Record renames Source_Files.Table (File); + Line_Pos : constant Source_Ptr := F.Lines.Table (Line); + Pos : constant Source_Ptr := Location_File_To_Pos (Loc, File); + begin + return Natural (Pos - Line_Pos); + end Location_File_Line_To_Offset; + -- Convert the first digit of VAL into a character (base 10). function Digit_To_Char (Val: Natural) return Character is begin diff --git a/src/files_map.ads b/src/files_map.ads index d2f2a0a4d..17b1d033c 100644 --- a/src/files_map.ads +++ b/src/files_map.ads @@ -156,6 +156,11 @@ package Files_Map is function Location_File_To_Line (Location : Location_Type; File : Source_File_Entry) return Positive; + -- Get the offset in the line LINE of LOC. + function Location_File_Line_To_Offset + (Loc : Location_Type; File : Source_File_Entry; Line : Positive) + return Natural; + -- Get logical column (with HT expanded) from LOC, FILE and LINE. function Location_File_Line_To_Col (Loc : Location_Type; File : Source_File_Entry; Line : Positive) diff --git a/src/vhdl/python/libghdl/thin.py b/src/vhdl/python/libghdl/thin.py index 250fdda71..43ed6ce2f 100644 --- a/src/vhdl/python/libghdl/thin.py +++ b/src/vhdl/python/libghdl/thin.py @@ -88,6 +88,8 @@ Location_File_To_Pos = libghdl.files_map__location_file_to_pos Location_File_To_Line = libghdl.files_map__location_file_to_line +Location_File_Line_To_Offset = libghdl.files_map__location_file_line_to_offset + Location_File_Line_To_Col = libghdl.files_map__location_file_line_to_col Get_File_Name = libghdl.files_map__get_file_name |