aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-06-03 18:28:46 +0200
committerTristan Gingold <tgingold@free.fr>2019-06-03 18:32:36 +0200
commit8c3ee7c18f21962176668130a923608da1f52928 (patch)
treef894ad52dcaa2d0777d0974f4093b01ffa91b585
parent296a2651cfe3ab9e66ed2562e5599afee3776027 (diff)
downloadghdl-8c3ee7c18f21962176668130a923608da1f52928.tar.gz
ghdl-8c3ee7c18f21962176668130a923608da1f52928.tar.bz2
ghdl-8c3ee7c18f21962176668130a923608da1f52928.zip
files_map-editor: add Fill_Text_Ptr.
-rw-r--r--src/files_map-editor.adb29
-rw-r--r--src/files_map-editor.ads8
-rw-r--r--src/vhdl/python/libghdl/thin/files_map_editor.py2
3 files changed, 34 insertions, 5 deletions
diff --git a/src/files_map-editor.adb b/src/files_map-editor.adb
index 06b5d3385..6253d1cf7 100644
--- a/src/files_map-editor.adb
+++ b/src/files_map-editor.adb
@@ -373,6 +373,35 @@ package body Files_Map.Editor is
Text_Ptr (0 .. Text_Len - 1));
end Replace_Text_Ptr;
+ procedure Fill_Text_Ptr (File : Source_File_Entry;
+ Text_Ptr : File_Buffer_Ptr;
+ Text_Len : Source_Ptr)
+ is
+ pragma Assert (File <= Source_Files.Last);
+ F : Source_File_Record renames Source_Files.Table (File);
+ Buf_Len : constant Source_Ptr := Get_Buffer_Length (File);
+ begin
+ if Text_Len + 2 > Buf_Len then
+ raise Constraint_Error;
+ end if;
+
+ if Text_Len > 0 then
+ F.Source (Source_Ptr_Org .. Source_Ptr_Org + Text_Len - 1) :=
+ Text_Ptr (Source_Ptr_Org .. Source_Ptr_Org + Text_Len - 1);
+ end if;
+ Set_File_Length (File, Text_Len);
+ Set_Gap (File, Text_Len + 2, Buf_Len - 1);
+
+ -- Clear cache.
+ F.Cache_Line := 1;
+ F.Cache_Pos := Source_Ptr_Org;
+
+ -- Reset line table.
+ Lines_Tables.Free (F.Lines);
+ Lines_Tables.Init (F.Lines);
+ File_Add_Line_Number (File, 1, Source_Ptr_Org);
+ end Fill_Text_Ptr;
+
procedure Set_Gap (File : Source_File_Entry;
First : Source_Ptr;
Last : Source_Ptr)
diff --git a/src/files_map-editor.ads b/src/files_map-editor.ads
index 5e2cb21e7..a2e3175e1 100644
--- a/src/files_map-editor.ads
+++ b/src/files_map-editor.ads
@@ -32,10 +32,10 @@ package Files_Map.Editor is
Text_Ptr : File_Buffer_Ptr;
Text_Len : Source_Ptr);
- -- Set the position of the GAP in FILE.
- procedure Set_Gap (File : Source_File_Entry;
- First : Source_Ptr;
- Last : Source_Ptr);
+ -- Replace the content of FILE with TEXT.
+ procedure Fill_Text_Ptr (File : Source_File_Entry;
+ Text_Ptr : File_Buffer_Ptr;
+ Text_Len : Source_Ptr);
-- Recompute lines number.
procedure Compute_Lines (File : Source_File_Entry);
diff --git a/src/vhdl/python/libghdl/thin/files_map_editor.py b/src/vhdl/python/libghdl/thin/files_map_editor.py
index 27ea6feda..e19317d0e 100644
--- a/src/vhdl/python/libghdl/thin/files_map_editor.py
+++ b/src/vhdl/python/libghdl/thin/files_map_editor.py
@@ -1,6 +1,6 @@
from libghdl import libghdl
-Set_Gap = libghdl.files_map__editor__set_gap
Replace_Text = libghdl.files_map__editor__replace_text_ptr
+Fill_Text = libghdl.files_map__editor__fill_text_ptr
Check_Buffer_Content = libghdl.files_map__editor__check_buffer_content