nlists.adb (Prepend_Debug): Remove parameters and nest within Prepend.

* nlists.adb (Prepend_Debug): Remove parameters and nest within
	Prepend.
	(Remove_Next_Debug): Same fix

	* nlists.ads: Correct bad comments for Prev and Prev_Non_Pragma (we do
	maintain back pointers now, though we did not used to, and comments
	were out of date).
	(Prepend): Remove pragma Inline.
	(Remove_Next): Same cleanup

From-SVN: r91891
This commit is contained in:
Arnaud Charlet 2004-12-08 12:48:04 +01:00
parent 6a2b39bdda
commit 07233820c3
2 changed files with 97 additions and 96 deletions

View File

@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
@ -106,14 +106,6 @@ package body Nlists is
-- Local Subprograms -- -- Local Subprograms --
----------------------- -----------------------
procedure Prepend_Debug (Node : Node_Id; To : List_Id);
pragma Inline (Prepend_Debug);
-- Output debug information if Debug_Flag_N set
procedure Remove_Next_Debug (Node : Node_Id);
pragma Inline (Remove_Next_Debug);
-- Output debug information if Debug_Flag_N set
procedure Set_First (List : List_Id; To : Node_Id); procedure Set_First (List : List_Id; To : Node_Id);
pragma Inline (Set_First); pragma Inline (Set_First);
-- Sets First field of list header List to reference To -- Sets First field of list header List to reference To
@ -155,6 +147,10 @@ package body Nlists is
pragma Inline (Append_Debug); pragma Inline (Append_Debug);
-- Output debug information if Debug_Flag_N set -- Output debug information if Debug_Flag_N set
------------------
-- Append_Debug --
------------------
procedure Append_Debug is procedure Append_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -202,6 +198,10 @@ package body Nlists is
pragma Inline (Append_List_Debug); pragma Inline (Append_List_Debug);
-- Output debug information if Debug_Flag_N set -- Output debug information if Debug_Flag_N set
-----------------------
-- Append_List_Debug --
-----------------------
procedure Append_List_Debug is procedure Append_List_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -288,9 +288,6 @@ package body Nlists is
-- First -- -- First --
----------- -----------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
function First (List : List_Id) return Node_Id is function First (List : List_Id) return Node_Id is
begin begin
if List = No_List then if List = No_List then
@ -349,6 +346,10 @@ package body Nlists is
pragma Inline (Insert_After_Debug); pragma Inline (Insert_After_Debug);
-- Output debug information if Debug_Flag_N set -- Output debug information if Debug_Flag_N set
------------------------
-- Insert_After_Debug --
------------------------
procedure Insert_After_Debug is procedure Insert_After_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -403,6 +404,10 @@ package body Nlists is
pragma Inline (Insert_Before_Debug); pragma Inline (Insert_Before_Debug);
-- Output debug information if Debug_Flag_N set -- Output debug information if Debug_Flag_N set
-------------------------
-- Insert_Before_Debug --
-------------------------
procedure Insert_Before_Debug is procedure Insert_Before_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -457,6 +462,10 @@ package body Nlists is
pragma Inline (Insert_List_After_Debug); pragma Inline (Insert_List_After_Debug);
-- Output debug information if Debug_Flag_N set -- Output debug information if Debug_Flag_N set
-----------------------------
-- Insert_List_After_Debug --
-----------------------------
procedure Insert_List_After_Debug is procedure Insert_List_After_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -520,6 +529,10 @@ package body Nlists is
pragma Inline (Insert_List_Before_Debug); pragma Inline (Insert_List_Before_Debug);
-- Output debug information if Debug_Flag_N set -- Output debug information if Debug_Flag_N set
------------------------------
-- Insert_List_Before_Debug --
------------------------------
procedure Insert_List_Before_Debug is procedure Insert_List_Before_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -604,9 +617,6 @@ package body Nlists is
-- Last -- -- Last --
---------- ----------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
function Last (List : List_Id) return Node_Id is function Last (List : List_Id) return Node_Id is
begin begin
pragma Assert (List in First_List_Id .. Lists.Last); pragma Assert (List in First_List_Id .. Lists.Last);
@ -779,6 +789,10 @@ package body Nlists is
pragma Inline (New_List_Debug); pragma Inline (New_List_Debug);
-- Output debugging information if Debug_Flag_N is set -- Output debugging information if Debug_Flag_N is set
--------------------
-- New_List_Debug --
--------------------
procedure New_List_Debug is procedure New_List_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -816,6 +830,10 @@ package body Nlists is
pragma Inline (New_List_Debug); pragma Inline (New_List_Debug);
-- Output debugging information if Debug_Flag_N is set -- Output debugging information if Debug_Flag_N is set
--------------------
-- New_List_Debug --
--------------------
procedure New_List_Debug is procedure New_List_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -856,7 +874,6 @@ package body Nlists is
function New_List (Node1, Node2 : Node_Id) return List_Id is function New_List (Node1, Node2 : Node_Id) return List_Id is
L : constant List_Id := New_List (Node1); L : constant List_Id := New_List (Node1);
begin begin
Append (Node2, L); Append (Node2, L);
return L; return L;
@ -864,7 +881,6 @@ package body Nlists is
function New_List (Node1, Node2, Node3 : Node_Id) return List_Id is function New_List (Node1, Node2, Node3 : Node_Id) return List_Id is
L : constant List_Id := New_List (Node1); L : constant List_Id := New_List (Node1);
begin begin
Append (Node2, L); Append (Node2, L);
Append (Node3, L); Append (Node3, L);
@ -873,7 +889,6 @@ package body Nlists is
function New_List (Node1, Node2, Node3, Node4 : Node_Id) return List_Id is function New_List (Node1, Node2, Node3, Node4 : Node_Id) return List_Id is
L : constant List_Id := New_List (Node1); L : constant List_Id := New_List (Node1);
begin begin
Append (Node2, L); Append (Node2, L);
Append (Node3, L); Append (Node3, L);
@ -886,11 +901,9 @@ package body Nlists is
Node2 : Node_Id; Node2 : Node_Id;
Node3 : Node_Id; Node3 : Node_Id;
Node4 : Node_Id; Node4 : Node_Id;
Node5 : Node_Id) Node5 : Node_Id) return List_Id
return List_Id
is is
L : constant List_Id := New_List (Node1); L : constant List_Id := New_List (Node1);
begin begin
Append (Node2, L); Append (Node2, L);
Append (Node3, L); Append (Node3, L);
@ -905,11 +918,9 @@ package body Nlists is
Node3 : Node_Id; Node3 : Node_Id;
Node4 : Node_Id; Node4 : Node_Id;
Node5 : Node_Id; Node5 : Node_Id;
Node6 : Node_Id) Node6 : Node_Id) return List_Id
return List_Id
is is
L : constant List_Id := New_List (Node1); L : constant List_Id := New_List (Node1);
begin begin
Append (Node2, L); Append (Node2, L);
Append (Node3, L); Append (Node3, L);
@ -923,9 +934,6 @@ package body Nlists is
-- Next -- -- Next --
---------- ----------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
function Next (Node : Node_Id) return Node_Id is function Next (Node : Node_Id) return Node_Id is
begin begin
pragma Assert (Is_List_Member (Node)); pragma Assert (Is_List_Member (Node));
@ -974,9 +982,6 @@ package body Nlists is
-- No -- -- No --
-------- --------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
function No (List : List_Id) return Boolean is function No (List : List_Id) return Boolean is
begin begin
return List = No_List; return List = No_List;
@ -999,10 +1004,8 @@ package body Nlists is
begin begin
if U in Node_Range then if U in Node_Range then
return Parent (Node_Id (U)); return Parent (Node_Id (U));
elsif U in List_Range then elsif U in List_Range then
return Parent (List_Id (U)); return Parent (List_Id (U));
else else
return 99_999_999; return 99_999_999;
end if; end if;
@ -1041,6 +1044,27 @@ package body Nlists is
procedure Prepend (Node : Node_Id; To : List_Id) is procedure Prepend (Node : Node_Id; To : List_Id) is
F : constant Node_Id := First (To); F : constant Node_Id := First (To);
procedure Prepend_Debug;
pragma Inline (Prepend_Debug);
-- Output debug information if Debug_Flag_N set
-------------------
-- Prepend_Debug --
-------------------
procedure Prepend_Debug is
begin
if Debug_Flag_N then
Write_Str ("Prepend node ");
Write_Int (Int (Node));
Write_Str (" to list ");
Write_Int (Int (To));
Write_Eol;
end if;
end Prepend_Debug;
-- Start of processing for Prepend_Debug
begin begin
pragma Assert (not Is_List_Member (Node)); pragma Assert (not Is_List_Member (Node));
@ -1048,7 +1072,7 @@ package body Nlists is
return; return;
end if; end if;
pragma Debug (Prepend_Debug (Node, To)); pragma Debug (Prepend_Debug);
if No (F) then if No (F) then
Set_Last (To, Node); Set_Last (To, Node);
@ -1065,21 +1089,6 @@ package body Nlists is
Set_List_Link (Node, To); Set_List_Link (Node, To);
end Prepend; end Prepend;
-------------------
-- Prepend_Debug --
-------------------
procedure Prepend_Debug (Node : Node_Id; To : List_Id) is
begin
if Debug_Flag_N then
Write_Str ("Prepend node ");
Write_Int (Int (Node));
Write_Str (" to list ");
Write_Int (Int (To));
Write_Eol;
end if;
end Prepend_Debug;
---------------- ----------------
-- Prepend_To -- -- Prepend_To --
---------------- ----------------
@ -1102,9 +1111,6 @@ package body Nlists is
-- Prev -- -- Prev --
---------- ----------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
function Prev (Node : Node_Id) return Node_Id is function Prev (Node : Node_Id) return Node_Id is
begin begin
pragma Assert (Is_List_Member (Node)); pragma Assert (Is_List_Member (Node));
@ -1160,6 +1166,10 @@ package body Nlists is
pragma Inline (Remove_Debug); pragma Inline (Remove_Debug);
-- Output debug information if Debug_Flag_N set -- Output debug information if Debug_Flag_N set
------------------
-- Remove_Debug --
------------------
procedure Remove_Debug is procedure Remove_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -1201,6 +1211,10 @@ package body Nlists is
pragma Inline (Remove_Head_Debug); pragma Inline (Remove_Head_Debug);
-- Output debug information if Debug_Flag_N set -- Output debug information if Debug_Flag_N set
-----------------------
-- Remove_Head_Debug --
-----------------------
procedure Remove_Head_Debug is procedure Remove_Head_Debug is
begin begin
if Debug_Flag_N then if Debug_Flag_N then
@ -1245,6 +1259,25 @@ package body Nlists is
function Remove_Next (Node : Node_Id) return Node_Id is function Remove_Next (Node : Node_Id) return Node_Id is
Nxt : constant Node_Id := Next (Node); Nxt : constant Node_Id := Next (Node);
procedure Remove_Next_Debug;
pragma Inline (Remove_Next_Debug);
-- Output debug information if Debug_Flag_N set
-----------------------
-- Remove_Next_Debug --
-----------------------
procedure Remove_Next_Debug is
begin
if Debug_Flag_N then
Write_Str ("Remove next node after ");
Write_Int (Int (Node));
Write_Eol;
end if;
end Remove_Next_Debug;
-- Start of processing for Remove_Next
begin begin
if Present (Nxt) then if Present (Nxt) then
declare declare
@ -1252,7 +1285,7 @@ package body Nlists is
LC : constant List_Id := List_Containing (Node); LC : constant List_Id := List_Containing (Node);
begin begin
pragma Debug (Remove_Next_Debug (Node)); pragma Debug (Remove_Next_Debug);
Set_Next (Node, Nxt2); Set_Next (Node, Nxt2);
if No (Nxt2) then if No (Nxt2) then
@ -1269,26 +1302,10 @@ package body Nlists is
return Nxt; return Nxt;
end Remove_Next; end Remove_Next;
-----------------------
-- Remove_Next_Debug --
-----------------------
procedure Remove_Next_Debug (Node : Node_Id) is
begin
if Debug_Flag_N then
Write_Str ("Remove next node after ");
Write_Int (Int (Node));
Write_Eol;
end if;
end Remove_Next_Debug;
--------------- ---------------
-- Set_First -- -- Set_First --
--------------- ---------------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
procedure Set_First (List : List_Id; To : Node_Id) is procedure Set_First (List : List_Id; To : Node_Id) is
begin begin
Lists.Table (List).First := To; Lists.Table (List).First := To;
@ -1298,9 +1315,6 @@ package body Nlists is
-- Set_Last -- -- Set_Last --
-------------- --------------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
procedure Set_Last (List : List_Id; To : Node_Id) is procedure Set_Last (List : List_Id; To : Node_Id) is
begin begin
Lists.Table (List).Last := To; Lists.Table (List).Last := To;
@ -1310,9 +1324,6 @@ package body Nlists is
-- Set_List_Link -- -- Set_List_Link --
------------------- -------------------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
procedure Set_List_Link (Node : Node_Id; To : List_Id) is procedure Set_List_Link (Node : Node_Id; To : List_Id) is
begin begin
Nodes.Table (Node).Link := Union_Id (To); Nodes.Table (Node).Link := Union_Id (To);
@ -1322,9 +1333,6 @@ package body Nlists is
-- Set_Next -- -- Set_Next --
-------------- --------------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
procedure Set_Next (Node : Node_Id; To : Node_Id) is procedure Set_Next (Node : Node_Id; To : Node_Id) is
begin begin
Next_Node.Table (Node) := To; Next_Node.Table (Node) := To;
@ -1344,9 +1352,6 @@ package body Nlists is
-- Set_Prev -- -- Set_Prev --
-------------- --------------
-- This subprogram is deliberately placed early on, out of alphabetical
-- order, so that it can be properly inlined from within this unit.
procedure Set_Prev (Node : Node_Id; To : Node_Id) is procedure Set_Prev (Node : Node_Id; To : Node_Id) is
begin begin
Prev_Node.Table (Node) := To; Prev_Node.Table (Node) := To;

View File

@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2003 Free Software Foundation, Inc. -- -- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
@ -89,8 +89,7 @@ package Nlists is
Node2 : Node_Id; Node2 : Node_Id;
Node3 : Node_Id; Node3 : Node_Id;
Node4 : Node_Id; Node4 : Node_Id;
Node5 : Node_Id) Node5 : Node_Id) return List_Id;
return List_Id;
-- Build a new list initially containing the five given nodes -- Build a new list initially containing the five given nodes
function New_List function New_List
@ -99,9 +98,8 @@ package Nlists is
Node3 : Node_Id; Node3 : Node_Id;
Node4 : Node_Id; Node4 : Node_Id;
Node5 : Node_Id; Node5 : Node_Id;
Node6 : Node_Id) Node6 : Node_Id) return List_Id;
return List_Id; -- Build a new list initially containing the six given nodes
-- Build a new list initially containing the five given nodes
function New_Copy_List (List : List_Id) return List_Id; function New_Copy_List (List : List_Id) return List_Id;
-- Creates a new list containing copies (made with Atree.New_Copy) of every -- Creates a new list containing copies (made with Atree.New_Copy) of every
@ -174,11 +172,10 @@ package Nlists is
function Prev (Node : Node_Id) return Node_Id; function Prev (Node : Node_Id) return Node_Id;
pragma Inline (Prev); pragma Inline (Prev);
-- This function returns the previous node on a node list list, or Empty if -- This function returns the previous node on a node list list, or Empty
-- Node is the first element of the node list. The argument must be a -- if Node is the first element of the node list. The argument must be
-- member of a node list. Note that the implementation does not maintain -- a member of a node list. Note: the implementation does maintain back
-- back pointers, so this function potentially requires traversal of the -- pointers, so this function executes quickly in constant time.
-- entire list, or more accurately of the part of the list preceding Node.
function Pick (List : List_Id; Index : Pos) return Node_Id; function Pick (List : List_Id; Index : Pos) return Node_Id;
-- Given a list, picks out the Index'th entry (1 = first entry). The -- Given a list, picks out the Index'th entry (1 = first entry). The
@ -193,8 +190,9 @@ package Nlists is
-- This function returns the previous node on a node list, skipping any -- This function returns the previous node on a node list, skipping any
-- pragmas. If Node is the first element of the list, or if the only -- pragmas. If Node is the first element of the list, or if the only
-- elements preceding it are pragmas, then Empty is returned. The -- elements preceding it are pragmas, then Empty is returned. The
-- argument must be a member of a node list. Like Prev, this function -- argument must be a member of a node list. Note: the implementation
-- may require expensive traversal of the head section of the list. -- does maintain back pointers, so this function executes quickly in
-- constant time.
procedure Prev_Non_Pragma (Node : in out Node_Id); procedure Prev_Non_Pragma (Node : in out Node_Id);
pragma Inline (Prev_Non_Pragma); pragma Inline (Prev_Non_Pragma);
@ -261,7 +259,6 @@ package Nlists is
-- List is reset to be the empty node list. -- List is reset to be the empty node list.
procedure Prepend (Node : Node_Id; To : List_Id); procedure Prepend (Node : Node_Id; To : List_Id);
pragma Inline (Prepend);
-- Prepends Node at the start of node list To. Node must be a non-empty -- Prepends Node at the start of node list To. Node must be a non-empty
-- node that is not already a member of a node list, and To must be a -- node that is not already a member of a node list, and To must be a
-- node list. An attempt to prepend an error node is ignored without -- node list. An attempt to prepend an error node is ignored without
@ -281,7 +278,6 @@ package Nlists is
-- is empty, then Empty is returned. -- is empty, then Empty is returned.
function Remove_Next (Node : Node_Id) return Node_Id; function Remove_Next (Node : Node_Id) return Node_Id;
pragma Inline (Remove_Next);
-- Removes the item immediately following the given node, and returns it -- Removes the item immediately following the given node, and returns it
-- as the result. If Node is the last element of the list, then Empty is -- as the result. If Node is the last element of the list, then Empty is
-- returned. Node must be a member of a list. Unlike Remove, Remove_Next -- returned. Node must be a member of a list. Unlike Remove, Remove_Next