nlists.adb (Prepend_Debug): Remove parameters and nest within Prepend.
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 8 Dec 2004 11:48:04 +0000 (12:48 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 8 Dec 2004 11:48:04 +0000 (12:48 +0100)
* 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

gcc/ada/nlists.adb
gcc/ada/nlists.ads

index 7a2d2fd..1517fed 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -106,14 +106,6 @@ package body Nlists is
    -- 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);
    pragma Inline (Set_First);
    --  Sets First field of list header List to reference To
@@ -155,6 +147,10 @@ package body Nlists is
       pragma Inline (Append_Debug);
       --  Output debug information if Debug_Flag_N set
 
+      ------------------
+      -- Append_Debug --
+      ------------------
+
       procedure Append_Debug is
       begin
          if Debug_Flag_N then
@@ -202,6 +198,10 @@ package body Nlists is
       pragma Inline (Append_List_Debug);
       --  Output debug information if Debug_Flag_N set
 
+      -----------------------
+      -- Append_List_Debug --
+      -----------------------
+
       procedure Append_List_Debug is
       begin
          if Debug_Flag_N then
@@ -288,9 +288,6 @@ package body Nlists is
    -- 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
    begin
       if List = No_List then
@@ -349,6 +346,10 @@ package body Nlists is
       pragma Inline (Insert_After_Debug);
       --  Output debug information if Debug_Flag_N set
 
+      ------------------------
+      -- Insert_After_Debug --
+      ------------------------
+
       procedure Insert_After_Debug is
       begin
          if Debug_Flag_N then
@@ -403,6 +404,10 @@ package body Nlists is
       pragma Inline (Insert_Before_Debug);
       --  Output debug information if Debug_Flag_N set
 
+      -------------------------
+      -- Insert_Before_Debug --
+      -------------------------
+
       procedure Insert_Before_Debug is
       begin
          if Debug_Flag_N then
@@ -457,6 +462,10 @@ package body Nlists is
       pragma Inline (Insert_List_After_Debug);
       --  Output debug information if Debug_Flag_N set
 
+      -----------------------------
+      -- Insert_List_After_Debug --
+      -----------------------------
+
       procedure Insert_List_After_Debug is
       begin
          if Debug_Flag_N then
@@ -520,6 +529,10 @@ package body Nlists is
       pragma Inline (Insert_List_Before_Debug);
       --  Output debug information if Debug_Flag_N set
 
+      ------------------------------
+      -- Insert_List_Before_Debug --
+      ------------------------------
+
       procedure Insert_List_Before_Debug is
       begin
          if Debug_Flag_N then
@@ -604,9 +617,6 @@ package body Nlists is
    -- 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
    begin
       pragma Assert (List in First_List_Id .. Lists.Last);
@@ -779,6 +789,10 @@ package body Nlists is
       pragma Inline (New_List_Debug);
       --  Output debugging information if Debug_Flag_N is set
 
+      --------------------
+      -- New_List_Debug --
+      --------------------
+
       procedure New_List_Debug is
       begin
          if Debug_Flag_N then
@@ -816,6 +830,10 @@ package body Nlists is
       pragma Inline (New_List_Debug);
       --  Output debugging information if Debug_Flag_N is set
 
+      --------------------
+      -- New_List_Debug --
+      --------------------
+
       procedure New_List_Debug is
       begin
          if Debug_Flag_N then
@@ -856,7 +874,6 @@ package body Nlists is
 
    function New_List (Node1, Node2 : Node_Id) return List_Id is
       L : constant List_Id := New_List (Node1);
-
    begin
       Append (Node2, L);
       return L;
@@ -864,7 +881,6 @@ package body Nlists is
 
    function New_List (Node1, Node2, Node3 : Node_Id) return List_Id is
       L : constant List_Id := New_List (Node1);
-
    begin
       Append (Node2, 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
       L : constant List_Id := New_List (Node1);
-
    begin
       Append (Node2, L);
       Append (Node3, L);
@@ -886,11 +901,9 @@ package body Nlists is
       Node2 : Node_Id;
       Node3 : Node_Id;
       Node4 : Node_Id;
-      Node5 : Node_Id)
-      return  List_Id
+      Node5 : Node_Id) return List_Id
    is
       L : constant List_Id := New_List (Node1);
-
    begin
       Append (Node2, L);
       Append (Node3, L);
@@ -905,11 +918,9 @@ package body Nlists is
       Node3 : Node_Id;
       Node4 : Node_Id;
       Node5 : Node_Id;
-      Node6 : Node_Id)
-      return  List_Id
+      Node6 : Node_Id) return List_Id
    is
       L : constant List_Id := New_List (Node1);
-
    begin
       Append (Node2, L);
       Append (Node3, L);
@@ -923,9 +934,6 @@ package body Nlists is
    -- 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
    begin
       pragma Assert (Is_List_Member (Node));
@@ -958,7 +966,7 @@ package body Nlists is
       loop
          N := Next (N);
          exit when Nkind (N) /= N_Pragma
-                    and then
+                     and then
                    Nkind (N) /= N_Null_Statement;
       end loop;
 
@@ -974,9 +982,6 @@ package body Nlists is
    -- 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
    begin
       return List = No_List;
@@ -999,10 +1004,8 @@ package body Nlists is
    begin
       if U in Node_Range then
          return Parent (Node_Id (U));
-
       elsif U in List_Range then
          return Parent (List_Id (U));
-
       else
          return 99_999_999;
       end if;
@@ -1041,6 +1044,27 @@ package body Nlists is
    procedure Prepend (Node : Node_Id; To : List_Id) is
       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
       pragma Assert (not Is_List_Member (Node));
 
@@ -1048,7 +1072,7 @@ package body Nlists is
          return;
       end if;
 
-      pragma Debug (Prepend_Debug (Node, To));
+      pragma Debug (Prepend_Debug);
 
       if No (F) then
          Set_Last (To, Node);
@@ -1065,21 +1089,6 @@ package body Nlists is
       Set_List_Link (Node, To);
    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 --
    ----------------
@@ -1102,9 +1111,6 @@ package body Nlists is
    -- 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
    begin
       pragma Assert (Is_List_Member (Node));
@@ -1160,6 +1166,10 @@ package body Nlists is
       pragma Inline (Remove_Debug);
       --  Output debug information if Debug_Flag_N set
 
+      ------------------
+      -- Remove_Debug --
+      ------------------
+
       procedure Remove_Debug is
       begin
          if Debug_Flag_N then
@@ -1201,6 +1211,10 @@ package body Nlists is
       pragma Inline (Remove_Head_Debug);
       --  Output debug information if Debug_Flag_N set
 
+      -----------------------
+      -- Remove_Head_Debug --
+      -----------------------
+
       procedure Remove_Head_Debug is
       begin
          if Debug_Flag_N then
@@ -1245,6 +1259,25 @@ package body Nlists is
    function Remove_Next (Node : Node_Id) return Node_Id is
       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
       if Present (Nxt) then
          declare
@@ -1252,7 +1285,7 @@ package body Nlists is
             LC   : constant List_Id := List_Containing (Node);
 
          begin
-            pragma Debug (Remove_Next_Debug (Node));
+            pragma Debug (Remove_Next_Debug);
             Set_Next (Node, Nxt2);
 
             if No (Nxt2) then
@@ -1269,26 +1302,10 @@ package body Nlists is
       return Nxt;
    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 --
    ---------------
 
-   --  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
    begin
       Lists.Table (List).First := To;
@@ -1298,9 +1315,6 @@ package body Nlists is
    -- 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
    begin
       Lists.Table (List).Last := To;
@@ -1310,9 +1324,6 @@ package body Nlists is
    -- 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
    begin
       Nodes.Table (Node).Link := Union_Id (To);
@@ -1322,9 +1333,6 @@ package body Nlists is
    -- 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
    begin
       Next_Node.Table (Node) := To;
@@ -1344,9 +1352,6 @@ package body Nlists is
    -- 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
    begin
       Prev_Node.Table (Node) := To;
index 4eb3372..b3d9e86 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -89,8 +89,7 @@ package Nlists is
       Node2 : Node_Id;
       Node3 : Node_Id;
       Node4 : Node_Id;
-      Node5 : Node_Id)
-      return  List_Id;
+      Node5 : Node_Id) return List_Id;
    --  Build a new list initially containing the five given nodes
 
    function New_List
@@ -99,9 +98,8 @@ package Nlists is
       Node3 : Node_Id;
       Node4 : Node_Id;
       Node5 : Node_Id;
-      Node6 : Node_Id)
-      return  List_Id;
-   --  Build a new list initially containing the five given nodes
+      Node6 : Node_Id) return List_Id;
+   --  Build a new list initially containing the six given nodes
 
    function New_Copy_List (List : List_Id) return List_Id;
    --  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;
    pragma Inline (Prev);
-   --  This function returns the previous node on a node list list, or Empty if
-   --  Node is the first element of the node list. The argument must be a
-   --  member of a node list. Note that the implementation does not maintain
-   --  back pointers, so this function potentially requires traversal of the
-   --  entire list, or more accurately of the part of the list preceding Node.
+   --  This function returns the previous node on a node list list, or Empty
+   --  if Node is the first element of the node list. The argument must be
+   --  a member of a node list. Note: the implementation does maintain back
+   --  pointers, so this function executes quickly in constant time.
 
    function Pick (List : List_Id; Index : Pos) return Node_Id;
    --  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
    --  pragmas. If Node is the first element of the list, or if the only
    --  elements preceding it are pragmas, then Empty is returned. The
-   --  argument must be a member of a node list. Like Prev, this function
-   --  may require expensive traversal of the head section of the list.
+   --  argument must be a member of a node list. Note: the implementation
+   --  does maintain back pointers, so this function executes quickly in
+   --  constant time.
 
    procedure Prev_Non_Pragma (Node : in out Node_Id);
    pragma Inline (Prev_Non_Pragma);
@@ -261,7 +259,6 @@ package Nlists is
    --  List is reset to be the empty node list.
 
    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
    --  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
@@ -281,7 +278,6 @@ package Nlists is
    --  is empty, then Empty is returned.
 
    function Remove_Next (Node : Node_Id) return Node_Id;
-   pragma Inline (Remove_Next);
    --  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
    --  returned. Node must be a member of a list. Unlike Remove, Remove_Next