-- --
-- B o d y --
-- --
--- --
--- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
--- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
--- MA 02111-1307, USA. --
+-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
+-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- is the last item in the list. The Node field points to the node which
-- is referenced by the corresponding list entry.
- --------------------------
- -- Element List Tables --
- --------------------------
+ -------------------------
+ -- Element List Tables --
+ -------------------------
type Elist_Header is record
First : Elmt_Id;
package Elists is new Table.Table (
Table_Component_Type => Elist_Header,
- Table_Index_Type => Elist_Id,
+ Table_Index_Type => Elist_Id'Base,
Table_Low_Bound => First_Elist_Id,
Table_Initial => Alloc.Elists_Initial,
Table_Increment => Alloc.Elists_Increment,
Table_Name => "Elists");
type Elmt_Item is record
- Node : Node_Id;
+ Node : Node_Or_Entity_Id;
Next : Union_Id;
end record;
package Elmts is new Table.Table (
Table_Component_Type => Elmt_Item,
- Table_Index_Type => Elmt_Id,
+ Table_Index_Type => Elmt_Id'Base,
Table_Low_Bound => First_Elmt_Id,
Table_Initial => Alloc.Elmts_Initial,
Table_Increment => Alloc.Elmts_Increment,
-- Append_Elmt --
-----------------
- procedure Append_Elmt (Node : Node_Id; To : Elist_Id) is
+ procedure Append_Elmt (N : Node_Or_Entity_Id; To : Elist_Id) is
L : constant Elmt_Id := Elists.Table (To).Last;
begin
Elmts.Increment_Last;
- Elmts.Table (Elmts.Last).Node := Node;
+ Elmts.Table (Elmts.Last).Node := N;
Elmts.Table (Elmts.Last).Next := Union_Id (To);
if L = No_Elmt then
Write_Int (Int (Elmts.Last));
Write_Str (" to list Elist_Id = ");
Write_Int (Int (To));
- Write_Str (" referencing Node_Id = ");
- Write_Int (Int (Node));
+ Write_Str (" referencing Node_Or_Entity_Id = ");
+ Write_Int (Int (N));
Write_Eol;
end if;
end Append_Elmt;
+ ------------------------
+ -- Append_Unique_Elmt --
+ ------------------------
+
+ procedure Append_Unique_Elmt (N : Node_Or_Entity_Id; To : Elist_Id) is
+ Elmt : Elmt_Id;
+ begin
+ Elmt := First_Elmt (To);
+ loop
+ if No (Elmt) then
+ Append_Elmt (N, To);
+ return;
+ elsif Node (Elmt) = N then
+ return;
+ else
+ Next_Elmt (Elmt);
+ end if;
+ end loop;
+ end Append_Unique_Elmt;
+
--------------------
-- Elists_Address --
--------------------
-- Insert_Elmt_After --
-----------------------
- procedure Insert_Elmt_After (Node : Node_Id; Elmt : Elmt_Id) is
- N : constant Union_Id := Elmts.Table (Elmt).Next;
+ procedure Insert_Elmt_After (N : Node_Or_Entity_Id; Elmt : Elmt_Id) is
+ Nxt : constant Union_Id := Elmts.Table (Elmt).Next;
begin
-
pragma Assert (Elmt /= No_Elmt);
Elmts.Increment_Last;
- Elmts.Table (Elmts.Last).Node := Node;
- Elmts.Table (Elmts.Last).Next := N;
+ Elmts.Table (Elmts.Last).Node := N;
+ Elmts.Table (Elmts.Last).Next := Nxt;
Elmts.Table (Elmt).Next := Union_Id (Elmts.Last);
- if N in Elist_Range then
- Elists.Table (Elist_Id (N)).Last := Elmts.Last;
+ if Nxt in Elist_Range then
+ Elists.Table (Elist_Id (Nxt)).Last := Elmts.Last;
end if;
end Insert_Elmt_After;
return Elmt = No_Elmt;
end No;
- -----------
+ ----------
-- Node --
- -----------
+ ----------
- function Node (Elmt : Elmt_Id) return Node_Id is
+ function Node (Elmt : Elmt_Id) return Node_Or_Entity_Id is
begin
if Elmt = No_Elmt then
return Empty;
-- Prepend_Elmt --
------------------
- procedure Prepend_Elmt (Node : Node_Id; To : Elist_Id) is
+ procedure Prepend_Elmt (N : Node_Or_Entity_Id; To : Elist_Id) is
F : constant Elmt_Id := Elists.Table (To).First;
begin
Elmts.Increment_Last;
- Elmts.Table (Elmts.Last).Node := Node;
+ Elmts.Table (Elmts.Last).Node := N;
if F = No_Elmt then
Elists.Table (To).Last := Elmts.Last;
end if;
Elists.Table (To).First := Elmts.Last;
-
end Prepend_Elmt;
-------------
-- Replace_Elmt --
------------------
- procedure Replace_Elmt (Elmt : Elmt_Id; New_Node : Node_Id) is
+ procedure Replace_Elmt (Elmt : Elmt_Id; New_Node : Node_Or_Entity_Id) is
begin
Elmts.Table (Elmt).Node := New_Node;
end Replace_Elmt;
Elmts.Tree_Write;
end Tree_Write;
+ ------------
+ -- Unlock --
+ ------------
+
+ procedure Unlock is
+ begin
+ Elists.Locked := False;
+ Elmts.Locked := False;
+ end Unlock;
+
end Elists;