diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-11-23 19:32:33 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-11-23 19:32:33 +0100 |
commit | ff31a2e65dd43811570f550dfe25437e7f70023a (patch) | |
tree | 3ddfbf8861a841975efe8e9a22bcab442210bbdb /src | |
parent | 6b3ec4018544c67a086ee2d70321b3b225f6a178 (diff) | |
download | ghdl-ff31a2e65dd43811570f550dfe25437e7f70023a.tar.gz ghdl-ff31a2e65dd43811570f550dfe25437e7f70023a.tar.bz2 ghdl-ff31a2e65dd43811570f550dfe25437e7f70023a.zip |
files_map: add support for one gap.
Diffstat (limited to 'src')
-rw-r--r-- | src/files_map.adb | 20 | ||||
-rw-r--r-- | src/files_map.ads | 8 | ||||
-rw-r--r-- | src/vhdl/scanner.adb | 1 |
3 files changed, 28 insertions, 1 deletions
diff --git a/src/files_map.adb b/src/files_map.adb index b8e9311ff..5f16983ed 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -555,7 +555,9 @@ package body Files_Map is File_Length => 0, Lines => <>, Cache_Pos => Source_Ptr_Org, - Cache_Line => 1); + Cache_Line => 1, + Gap_Start => Source_Ptr_Last, + Gap_Last => Source_Ptr_Last); Lines_Tables.Init (Source_Files.Table (Res).Lines); File_Add_Line_Number (Res, 1, Source_Ptr_Org); return Res; @@ -766,6 +768,12 @@ package body Files_Map is Set_File_Length (Res, Length); + -- Set the gap. + Source_Files.Table (Res).Gap_Start := + Source_Ptr_Org + Length + 2; + Source_Files.Table (Res).Gap_Last := + Source_Files.Table (Res).Source'Last; + -- Compute the SHA1. declare use GNAT.SHA1; @@ -818,6 +826,16 @@ package body Files_Map is Source_Files.Table (Source_Files.Last).Last_Location + 1; end Unload_Last_Source_File; + procedure Skip_Gap (File : Source_File_Entry; Pos : in out Source_Ptr) + is + pragma Assert (File <= Source_Files.Last); + F : Source_File_Record renames Source_Files.Table (File); + begin + if Pos = F.Gap_Start then + Pos := F.Gap_Last + 1; + end if; + end Skip_Gap; + -- Check validity of FILE. -- Raise an exception in case of error. procedure Check_File (File : Source_File_Entry) is diff --git a/src/files_map.ads b/src/files_map.ads index 411195b4a..4f6ed2933 100644 --- a/src/files_map.ads +++ b/src/files_map.ads @@ -90,6 +90,10 @@ package Files_Map is function Location_Instance_To_Location (Loc : Location_Type) return Location_Type; + -- If POS points to the start of the gap of FILE, it will be updated + -- to the next character after the gap. + procedure Skip_Gap (File : Source_File_Entry; Pos : in out Source_Ptr); + -- Return a buffer (access to the contents of the file) for a file entry. function Get_File_Source (File : Source_File_Entry) return File_Buffer_Acc; @@ -281,6 +285,10 @@ private Cache_Line : Positive; Cache_Pos : Source_Ptr; + -- Gap + Gap_Start : Source_Ptr; + Gap_Last : Source_Ptr; + when Source_File_String => -- There is only one line. null; diff --git a/src/vhdl/scanner.adb b/src/vhdl/scanner.adb index 5d94fd470..1deac7fcc 100644 --- a/src/vhdl/scanner.adb +++ b/src/vhdl/scanner.adb @@ -1595,6 +1595,7 @@ package body Scanner is -- Scan_LF_Newline. procedure Scan_Next_Line is begin + Files_Map.Skip_Gap (Current_Context.Source_File, Pos); Current_Context.Line_Number := Current_Context.Line_Number + 1; Current_Context.Line_Pos := Pos; File_Add_Line_Number |