diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/files_map.ads | 2 | ||||
-rw-r--r-- | src/str_table.adb | 17 | ||||
-rw-r--r-- | src/str_table.ads | 7 |
3 files changed, 21 insertions, 5 deletions
diff --git a/src/files_map.ads b/src/files_map.ads index c58161e39..cc317fdfb 100644 --- a/src/files_map.ads +++ b/src/files_map.ads @@ -78,7 +78,7 @@ package Files_Map is -- Return the directory of the file. function Get_Source_File_Directory (File : Source_File_Entry) - return Name_Id; + return Name_Id; -- Return the name of the file. function Get_File_Name (File : Source_File_Entry) return Name_Id; diff --git a/src/str_table.adb b/src/str_table.adb index 85f770015..4b4e15bf1 100644 --- a/src/str_table.adb +++ b/src/str_table.adb @@ -18,9 +18,13 @@ with GNAT.Table; package body Str_Table is + -- Be sure the elements are packed. + type El_Nat8 is new Nat8; + for El_Nat8'Size use 8; + package String8_Table is new GNAT.Table (Table_Index_Type => String8_Id, - Table_Component_Type => Nat8, + Table_Component_Type => El_Nat8, Table_Low_Bound => Null_String8 + 1, Table_Initial => 1024, Table_Increment => 100); @@ -35,7 +39,7 @@ package body Str_Table is procedure Append_String8 (El : Nat8) is begin - String8_Table.Append (El); + String8_Table.Append (El_Nat8 (El)); end Append_String8; procedure Append_String8_Char (El : Character) is @@ -50,12 +54,12 @@ package body Str_Table is function Element_String8 (Id : String8_Id; N : Pos32) return Nat8 is begin - return String8_Table.Table (Id + String8_Id (N - 1)); + return Nat8 (String8_Table.Table (Id + String8_Id (N - 1))); end Element_String8; procedure Set_Element_String8 (Id : String8_Id; N : Pos32; Val : Nat8) is begin - String8_Table.Table (Id + String8_Id (N - 1)) := Val; + String8_Table.Table (Id + String8_Id (N - 1)) := El_Nat8 (Val); end Set_Element_String8; function Char_String8 (Id : String8_Id; N : Pos32) return Character is @@ -73,6 +77,11 @@ package body Str_Table is return Res; end String_String8; + function String8_Address (Id : String8_Id) return System.Address is + begin + return String8_Table.Table (Id)'Address; + end String8_Address; + procedure Initialize is begin String8_Table.Free; diff --git a/src/str_table.ads b/src/str_table.ads index 7be26560e..17103673b 100644 --- a/src/str_table.ads +++ b/src/str_table.ads @@ -15,6 +15,7 @@ -- along with GHDL; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. +with System; with Types; use Types; package Str_Table is @@ -50,6 +51,12 @@ package Str_Table is -- Utility function: get the LEN elements as a string. function String_String8 (Id : String8_Id; Len : Nat32) return String; + -- Utility function: get the address of string8 ID. Note that as soon + -- as a character is appended (using Append_String8) or a string8 is + -- resized (using Resize_String8), an address previously returned is not + -- valid anymore. + function String8_Address (Id : String8_Id) return System.Address; + -- Free all the memory and reinitialize the package. procedure Initialize; end Str_Table; |