diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-06-03 18:28:31 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-06-03 18:28:31 +0200 |
commit | 296a2651cfe3ab9e66ed2562e5599afee3776027 (patch) | |
tree | 5f992a1f95ba885b57ae07bf317e5c65b9661d22 | |
parent | 9019ecb269279a658a720a1d3f4a2340003995b8 (diff) | |
download | ghdl-296a2651cfe3ab9e66ed2562e5599afee3776027.tar.gz ghdl-296a2651cfe3ab9e66ed2562e5599afee3776027.tar.bz2 ghdl-296a2651cfe3ab9e66ed2562e5599afee3776027.zip |
files_map: add get_buffer_length
-rw-r--r-- | src/files_map.adb | 11 | ||||
-rw-r--r-- | src/files_map.ads | 3 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/files_map.adb b/src/files_map.adb index d6ee415b1..fc7ba06e9 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -717,7 +717,7 @@ package body Files_Map is -- Read_Source_File call must follow its Create_Source_File. pragma Assert (F.First_Location = Next_Location); - F.Last_Location := Next_Location + Location_Type (Length) + 1; + F.Last_Location := Next_Location + Location_Type (Length) - 1; Next_Location := F.Last_Location + 1; end; @@ -897,13 +897,20 @@ package body Files_Map is end; end Set_File_Length; - -- Return the length of the file (which is the size of the file buffer). function Get_File_Length (File: Source_File_Entry) return Source_Ptr is begin Check_File (File); return Source_Files.Table (File).File_Length; end Get_File_Length; + function Get_Buffer_Length (File : Source_File_Entry) return Source_Ptr + is + pragma Assert (File <= Source_Files.Last); + F : Source_File_Record renames Source_Files.Table (File); + begin + return Source_Ptr (F.Last_Location - F.First_Location - 1); + end Get_Buffer_Length; + -- Return the name of the file. function Get_File_Name (File: Source_File_Entry) return Name_Id is begin diff --git a/src/files_map.ads b/src/files_map.ads index 2e0dd0ae2..e2b66fd7d 100644 --- a/src/files_map.ads +++ b/src/files_map.ads @@ -106,6 +106,9 @@ package Files_Map is procedure Set_File_Length (File : Source_File_Entry; Length : Source_Ptr); function Get_File_Length (File : Source_File_Entry) return Source_Ptr; + -- Get the length of the buffer, which includes the gap. + function Get_Buffer_Length (File : Source_File_Entry) return Source_Ptr; + -- Return the name of the file. function Get_File_Name (File : Source_File_Entry) return Name_Id; |