aboutsummaryrefslogtreecommitdiffstats
path: root/src/lists.ads
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-05-09 18:20:41 +0200
committerTristan Gingold <tgingold@free.fr>2019-05-09 18:20:41 +0200
commitb9c2c358ac74c66736537d5b1eb44d42819f6ec1 (patch)
treef04c0faad2b7d566bac6783e7166a060ede6a693 /src/lists.ads
parentf526c1f41a2f5a8a5f70ee33f82d9e6b84117142 (diff)
downloadghdl-b9c2c358ac74c66736537d5b1eb44d42819f6ec1.tar.gz
ghdl-b9c2c358ac74c66736537d5b1eb44d42819f6ec1.tar.bz2
ghdl-b9c2c358ac74c66736537d5b1eb44d42819f6ec1.zip
Make lists a generic package, add vhdl-lists.
Diffstat (limited to 'src/lists.ads')
-rw-r--r--src/lists.ads15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lists.ads b/src/lists.ads
index fc015d84a..06fd601d9 100644
--- a/src/lists.ads
+++ b/src/lists.ads
@@ -16,8 +16,9 @@
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
with Types; use Types;
-with Vhdl.Nodes_Priv; use Vhdl.Nodes_Priv;
+generic
+ type El_Type is range <>;
package Lists is
type List_Type is new Nat32;
for List_Type'Size use 32;
@@ -73,13 +74,13 @@ package Lists is
procedure Initialize;
-- Append ELEMENT to the list. It's an O(1) operation.
- procedure Append_Element (List : List_Type; Element : Node_Type);
+ procedure Append_Element (List : List_Type; Element : El_Type);
-- Return the first element of the list.
- function Get_First_Element (List : List_Type) return Node_Type;
+ function Get_First_Element (List : List_Type) return El_Type;
-- Append EL if not already in LIST. It's an O(n) operation.
- procedure Add_Element (List : List_Type; El : Node_Type);
+ procedure Add_Element (List : List_Type; El : El_Type);
-- Return the number of elements in the list.
-- This is also 1 + the position of the last element.
@@ -101,8 +102,8 @@ package Lists is
function Iterate (List : List_Type) return Iterator;
function Is_Valid (It : Iterator) return Boolean;
procedure Next (It : in out Iterator);
- function Get_Element (It : Iterator) return Node_Type;
- procedure Set_Element (It : Iterator; El : Node_Type);
+ function Get_Element (It : Iterator) return El_Type;
+ procedure Set_Element (It : Iterator; El : El_Type);
-- Use the C convention for all these subprograms, so that the Iterator is
-- always passed by reference.
@@ -123,7 +124,7 @@ private
Chunk_Len : constant := 7;
type Node_Type_Array is
- array (Nat32 range 0 .. Chunk_Len - 1) of Node_Type;
+ array (Nat32 range 0 .. Chunk_Len - 1) of El_Type;
type Chunk_Type is record
Next : Chunk_Index_Type;