aboutsummaryrefslogtreecommitdiffstats
path: root/src/files_map.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-06 19:26:31 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-06 19:26:31 +0100
commita9c2b17053a324a92e86dd0e3bc65d34bae08db3 (patch)
tree4ee7cd7713aa0d8828102b59f012e43bcfc2f099 /src/files_map.adb
parent3a49c7ff29374c6f085e2d9dc46b200afbfc9a2c (diff)
downloadghdl-a9c2b17053a324a92e86dd0e3bc65d34bae08db3.tar.gz
ghdl-a9c2b17053a324a92e86dd0e3bc65d34bae08db3.tar.bz2
ghdl-a9c2b17053a324a92e86dd0e3bc65d34bae08db3.zip
files_map: add Discard_Source_File, Free_Source_File,
Diffstat (limited to 'src/files_map.adb')
-rw-r--r--src/files_map.adb29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/files_map.adb b/src/files_map.adb
index 24917592c..14da4c1fc 100644
--- a/src/files_map.adb
+++ b/src/files_map.adb
@@ -823,6 +823,15 @@ package body Files_Map is
return Res;
end Read_Source_File;
+ procedure Discard_Source_File (File : Source_File_Entry)
+ is
+ pragma Assert (File <= Source_Files.Last);
+ F : Source_File_Record renames Source_Files.Table (File);
+ begin
+ F.File_Name := Null_Identifier;
+ F.Directory := Null_Identifier;
+ end Discard_Source_File;
+
procedure Free_Source_File (File : Source_File_Entry)
is
procedure Free is new Ada.Unchecked_Deallocation
@@ -904,6 +913,18 @@ package body Files_Map is
return Source_Files.Table (File).File_Length;
end Get_File_Length;
+ function Get_Content_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
+ if F.Gap_Start >= F.File_Length then
+ return F.File_Length;
+ else
+ return F.File_Length - (F.Gap_Last - F.Gap_Start + 1);
+ end if;
+ end Get_Content_Length;
+
function Get_Buffer_Length (File : Source_File_Entry) return Source_Ptr
is
pragma Assert (File <= Source_Files.Last);
@@ -1161,8 +1182,12 @@ package body Files_Map is
end if;
case F.Kind is
when Source_File_File =>
- Log (" buf:" & Source_Ptr'Image (F.Source'First)
- & " -" & Source_Ptr'Image (F.Source'Last));
+ if F.Source = null then
+ Log (" no buf");
+ else
+ Log (" buf:" & Source_Ptr'Image (F.Source'First)
+ & " -" & Source_Ptr'Image (F.Source'Last));
+ end if;
Log_Line;
Log (" nbr lines:"
& Natural'Image (Lines_Tables.Last (F.Lines)));