From f6ee4a75bfba5341a9116193810c5ccf771d1cf0 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 8 Nov 2019 19:29:52 +0100 Subject: dyn_tables: move Table_Initial generic to argument of --- src/dyn_interning.adb | 2 +- src/dyn_interning.ads | 3 +-- src/dyn_tables.adb | 2 +- src/dyn_tables.ads | 6 +----- src/files_map-editor.adb | 4 ++-- src/files_map.adb | 2 +- src/files_map.ads | 5 +++-- src/synth/netlists-concats.adb | 2 +- src/synth/netlists-concats.ads | 2 +- src/synth/netlists-utils.ads | 8 ++++++-- src/tables.adb | 2 +- src/tables.ads | 3 +-- 12 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/dyn_interning.adb b/src/dyn_interning.adb index 96f4edc04..0550194f6 100644 --- a/src/dyn_interning.adb +++ b/src/dyn_interning.adb @@ -26,7 +26,7 @@ package body Dyn_Interning is begin Inst.Size := Initial_Size; Inst.Hash_Table := new Hash_Array'(0 .. Initial_Size - 1 => No_Index); - Wrapper_Tables.Init (Inst.Els); + Wrapper_Tables.Init (Inst.Els, 128); pragma Assert (Wrapper_Tables.Last (Inst.Els) = No_Index); end Init; diff --git a/src/dyn_interning.ads b/src/dyn_interning.ads index c1bdab420..5412b6772 100644 --- a/src/dyn_interning.ads +++ b/src/dyn_interning.ads @@ -77,8 +77,7 @@ private package Wrapper_Tables is new Dyn_Tables (Table_Index_Type => Index_Type, Table_Component_Type => Element_Wrapper, - Table_Low_Bound => No_Index + 1, - Table_Initial => 128); + Table_Low_Bound => No_Index + 1); type Hash_Array is array (Hash_Value_Type range <>) of Index_Type; type Hash_Array_Acc is access Hash_Array; diff --git a/src/dyn_tables.adb b/src/dyn_tables.adb index c7fcc41e8..91857f002 100644 --- a/src/dyn_tables.adb +++ b/src/dyn_tables.adb @@ -105,7 +105,7 @@ package body Dyn_Tables is end if; end Set_Last; - procedure Init (T : in out Instance) + procedure Init (T : in out Instance; Table_Initial : Positive) is -- Direct interface to malloc. function Cmalloc (Size : size_t) return Table_Thin_Ptr; diff --git a/src/dyn_tables.ads b/src/dyn_tables.ads index 8f6f96513..19bb5e7ac 100644 --- a/src/dyn_tables.ads +++ b/src/dyn_tables.ads @@ -31,10 +31,6 @@ generic -- Table_Index_Type'First, as otherwise Last may raise constraint error -- when the table is empty. Table_Low_Bound : Table_Index_Type; - - -- Initial number of elements. - Table_Initial : Positive; - package Dyn_Tables is -- Ada type for the array. type Table_Type is @@ -64,7 +60,7 @@ package Dyn_Tables is end record; -- Initialize the table. This must be done by users. - procedure Init (T : in out Instance); + procedure Init (T : in out Instance; Table_Initial : Positive); -- Logical bounds of the array. First : constant Table_Index_Type := Table_Low_Bound; diff --git a/src/files_map-editor.adb b/src/files_map-editor.adb index 578425fa8..63a72f460 100644 --- a/src/files_map-editor.adb +++ b/src/files_map-editor.adb @@ -51,7 +51,7 @@ package body Files_Map.Editor is P : Source_Ptr; Nl : Natural; begin - Lines_Tables.Init (F.Lines); + Lines_Tables.Init (F.Lines, Lines_Table_Init); L := 1; P := Source_Ptr_Org; @@ -414,7 +414,7 @@ package body Files_Map.Editor is -- Reset line table. Lines_Tables.Free (F.Lines); - Lines_Tables.Init (F.Lines); + Lines_Tables.Init (F.Lines, Lines_Table_Init); File_Add_Line_Number (File, 1, Source_Ptr_Org); end Fill_Text_Ptr; diff --git a/src/files_map.adb b/src/files_map.adb index 14da4c1fc..bbf8c8087 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -580,7 +580,7 @@ package body Files_Map is Cache_Line => 1, Gap_Start => Source_Ptr_Last, Gap_Last => Source_Ptr_Last); - Lines_Tables.Init (Source_Files.Table (Res).Lines); + Lines_Tables.Init (Source_Files.Table (Res).Lines, Lines_Table_Init); File_Add_Line_Number (Res, 1, Source_Ptr_Org); return Res; end Create_Source_File_Entry; diff --git a/src/files_map.ads b/src/files_map.ads index 131da8ffa..ca7763b4f 100644 --- a/src/files_map.ads +++ b/src/files_map.ads @@ -265,11 +265,12 @@ package Files_Map is procedure Initialize; private + Lines_Table_Init : Natural := 64; + package Lines_Tables is new Dyn_Tables (Table_Component_Type => Source_Ptr, Table_Index_Type => Natural, - Table_Low_Bound => 1, - Table_Initial => 64); + Table_Low_Bound => 1); -- There are several kinds of source file. type Source_File_Kind is diff --git a/src/synth/netlists-concats.adb b/src/synth/netlists-concats.adb index d8df7bbc3..f3e3b8223 100644 --- a/src/synth/netlists-concats.adb +++ b/src/synth/netlists-concats.adb @@ -32,7 +32,7 @@ package body Netlists.Concats is else -- Switch to the dynamic array. C.Len := C.Len + 1; - Net_Tables.Init (C.Darr); + Net_Tables.Init (C.Darr, 2 * Static_Last); Net_Tables.Set_Last (C.Darr, C.Len); C.Darr.Table (C.Sarr'Range) := C.Sarr; C.Darr.Table (C.Len) := N; diff --git a/src/synth/netlists-concats.ads b/src/synth/netlists-concats.ads index f3994de4e..122a43a38 100644 --- a/src/synth/netlists-concats.ads +++ b/src/synth/netlists-concats.ads @@ -30,7 +30,7 @@ package Netlists.Concats is -- Get the concatenation of all nets in C. Reset C. procedure Build (Ctxt : Context_Acc; C : in out Concat_Type; N : out Net); private - Static_Last : constant Int32 := 16; + Static_Last : constant := 16; package Net_Tables renames Netlists.Utils.Net_Tables; diff --git a/src/synth/netlists-utils.ads b/src/synth/netlists-utils.ads index 029bd496c..b8ccb3e93 100644 --- a/src/synth/netlists-utils.ads +++ b/src/synth/netlists-utils.ads @@ -71,6 +71,10 @@ package Netlists.Utils is package Net_Tables is new Dyn_Tables (Table_Component_Type => Net, Table_Index_Type => Int32, - Table_Low_Bound => 1, - Table_Initial => 32); + Table_Low_Bound => 1); + + package Instance_Tables is new Dyn_Tables + (Table_Component_Type => Instance, + Table_Index_Type => Int32, + Table_Low_Bound => 1); end Netlists.Utils; diff --git a/src/tables.adb b/src/tables.adb index 3b8a888b8..027ded8e3 100644 --- a/src/tables.adb +++ b/src/tables.adb @@ -44,7 +44,7 @@ package body Tables is procedure Init is begin - Dyn_Table.Init (T); + Dyn_Table.Init (T, Table_Initial); end Init; function Last return Table_Index_Type is diff --git a/src/tables.ads b/src/tables.ads index b7a4b0344..e8b86d19e 100644 --- a/src/tables.ads +++ b/src/tables.ads @@ -39,8 +39,7 @@ generic package Tables is package Dyn_Table is new Dyn_Tables (Table_Component_Type, Table_Index_Type, - Table_Low_Bound, - Table_Initial); + Table_Low_Bound); T : Dyn_Table.Instance; -- cgit v1.2.3