1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- WARNING: There is a C version of this package. Any changes to this source
33 -- file must be properly reflected in the corresponding C header a-nlists.h
36 with Atree; use Atree;
37 with Debug; use Debug;
38 with Output; use Output;
39 with Sinfo; use Sinfo;
42 package body Nlists is
44 use Atree_Private_Part;
45 -- Get access to Nodes table
47 ----------------------------------
48 -- Implementation of Node Lists --
49 ----------------------------------
51 -- A node list is represented by a list header which contains
54 type List_Header is record
55 First : Node_Or_Entity_Id;
56 -- Pointer to first node in list. Empty if list is empty
58 Last : Node_Or_Entity_Id;
59 -- Pointer to last node in list. Empty if list is empty
62 -- Pointer to parent of list. Empty if list has no parent
65 -- The node lists are stored in a table indexed by List_Id values
67 package Lists is new Table.Table (
68 Table_Component_Type => List_Header,
69 Table_Index_Type => List_Id'Base,
70 Table_Low_Bound => First_List_Id,
71 Table_Initial => Alloc.Lists_Initial,
72 Table_Increment => Alloc.Lists_Increment,
73 Table_Name => "Lists");
75 -- The nodes in the list all have the In_List flag set, and their Link
76 -- fields (which otherwise point to the parent) contain the List_Id of
77 -- the list header giving immediate access to the list containing the
78 -- node, and its parent and first and last elements.
80 -- Two auxiliary tables, indexed by Node_Id values and built in parallel
81 -- with the main nodes table and always having the same size contain the
82 -- list link values that allow locating the previous and next node in a
83 -- list. The entries in these tables are valid only if the In_List flag
84 -- is set in the corresponding node. Next_Node is Empty at the end of a
85 -- list and Prev_Node is Empty at the start of a list.
87 package Next_Node is new Table.Table (
88 Table_Component_Type => Node_Or_Entity_Id,
89 Table_Index_Type => Node_Or_Entity_Id'Base,
90 Table_Low_Bound => First_Node_Id,
91 Table_Initial => Alloc.Orig_Nodes_Initial,
92 Table_Increment => Alloc.Orig_Nodes_Increment,
93 Table_Name => "Next_Node");
95 package Prev_Node is new Table.Table (
96 Table_Component_Type => Node_Or_Entity_Id,
97 Table_Index_Type => Node_Or_Entity_Id'Base,
98 Table_Low_Bound => First_Node_Id,
99 Table_Initial => Alloc.Orig_Nodes_Initial,
100 Table_Increment => Alloc.Orig_Nodes_Increment,
101 Table_Name => "Prev_Node");
103 -----------------------
104 -- Local Subprograms --
105 -----------------------
107 procedure Set_First (List : List_Id; To : Node_Or_Entity_Id);
108 pragma Inline (Set_First);
109 -- Sets First field of list header List to reference To
111 procedure Set_Last (List : List_Id; To : Node_Or_Entity_Id);
112 pragma Inline (Set_Last);
113 -- Sets Last field of list header List to reference To
115 procedure Set_List_Link (Node : Node_Or_Entity_Id; To : List_Id);
116 pragma Inline (Set_List_Link);
117 -- Sets list link of Node to list header To
119 procedure Set_Next (Node : Node_Or_Entity_Id; To : Node_Or_Entity_Id);
120 pragma Inline (Set_Next);
121 -- Sets the Next_Node pointer for Node to reference To
123 procedure Set_Prev (Node : Node_Or_Entity_Id; To : Node_Or_Entity_Id);
124 pragma Inline (Set_Prev);
125 -- Sets the Prev_Node pointer for Node to reference To
127 --------------------------
128 -- Allocate_List_Tables --
129 --------------------------
131 procedure Allocate_List_Tables (N : Node_Or_Entity_Id) is
132 Old_Last : constant Node_Or_Entity_Id'Base := Next_Node.Last;
135 pragma Assert (N >= Old_Last);
136 Next_Node.Set_Last (N);
137 Prev_Node.Set_Last (N);
139 -- Make sure we have no uninitialized junk in any new entires added.
140 -- This ensures that Tree_Gen will not write out any uninitialized junk.
142 for J in Old_Last + 1 .. N loop
143 Next_Node.Table (J) := Empty;
144 Prev_Node.Table (J) := Empty;
146 end Allocate_List_Tables;
152 procedure Append (Node : Node_Or_Entity_Id; To : List_Id) is
153 L : constant Node_Or_Entity_Id := Last (To);
155 procedure Append_Debug;
156 pragma Inline (Append_Debug);
157 -- Output debug information if Debug_Flag_N set
163 procedure Append_Debug is
166 Write_Str ("Append node ");
167 Write_Int (Int (Node));
168 Write_Str (" to list ");
169 Write_Int (Int (To));
174 -- Start of processing for Append
177 pragma Assert (not Is_List_Member (Node));
183 pragma Debug (Append_Debug);
186 Set_First (To, Node);
193 Nodes.Table (Node).In_List := True;
195 Set_Next (Node, Empty);
197 Set_List_Link (Node, To);
204 procedure Append_List (List : List_Id; To : List_Id) is
206 procedure Append_List_Debug;
207 pragma Inline (Append_List_Debug);
208 -- Output debug information if Debug_Flag_N set
210 -----------------------
211 -- Append_List_Debug --
212 -----------------------
214 procedure Append_List_Debug is
217 Write_Str ("Append list ");
218 Write_Int (Int (List));
219 Write_Str (" to list ");
220 Write_Int (Int (To));
223 end Append_List_Debug;
225 -- Start of processing for Append_List
228 if Is_Empty_List (List) then
233 L : constant Node_Or_Entity_Id := Last (To);
234 F : constant Node_Or_Entity_Id := First (List);
235 N : Node_Or_Entity_Id;
238 pragma Debug (Append_List_Debug);
242 Set_List_Link (N, To);
254 Set_Last (To, Last (List));
256 Set_First (List, Empty);
257 Set_Last (List, Empty);
266 procedure Append_List_To (To : List_Id; List : List_Id) is
268 Append_List (List, To);
275 procedure Append_To (To : List_Id; Node : Node_Or_Entity_Id) is
284 function First (List : List_Id) return Node_Or_Entity_Id is
286 if List = No_List then
289 pragma Assert (List <= Lists.Last);
290 return Lists.Table (List).First;
294 ----------------------
295 -- First_Non_Pragma --
296 ----------------------
298 function First_Non_Pragma (List : List_Id) return Node_Or_Entity_Id is
299 N : constant Node_Or_Entity_Id := First (List);
301 if Nkind (N) /= N_Pragma
303 Nkind (N) /= N_Null_Statement
307 return Next_Non_Pragma (N);
309 end First_Non_Pragma;
315 procedure Initialize is
316 E : constant List_Id := Error_List;
323 -- Allocate Error_List list header
325 Lists.Increment_Last;
326 Set_Parent (E, Empty);
327 Set_First (E, Empty);
335 function In_Same_List (N1, N2 : Node_Or_Entity_Id) return Boolean is
337 return List_Containing (N1) = List_Containing (N2);
344 procedure Insert_After
345 (After : Node_Or_Entity_Id;
346 Node : Node_Or_Entity_Id)
348 procedure Insert_After_Debug;
349 pragma Inline (Insert_After_Debug);
350 -- Output debug information if Debug_Flag_N set
352 ------------------------
353 -- Insert_After_Debug --
354 ------------------------
356 procedure Insert_After_Debug is
359 Write_Str ("Insert node");
360 Write_Int (Int (Node));
361 Write_Str (" after node ");
362 Write_Int (Int (After));
365 end Insert_After_Debug;
367 -- Start of processing for Insert_After
371 (Is_List_Member (After) and then not Is_List_Member (Node));
377 pragma Debug (Insert_After_Debug);
380 Before : constant Node_Or_Entity_Id := Next (After);
381 LC : constant List_Id := List_Containing (After);
384 if Present (Before) then
385 Set_Prev (Before, Node);
390 Set_Next (After, Node);
392 Nodes.Table (Node).In_List := True;
394 Set_Prev (Node, After);
395 Set_Next (Node, Before);
396 Set_List_Link (Node, LC);
404 procedure Insert_Before
405 (Before : Node_Or_Entity_Id;
406 Node : Node_Or_Entity_Id)
408 procedure Insert_Before_Debug;
409 pragma Inline (Insert_Before_Debug);
410 -- Output debug information if Debug_Flag_N set
412 -------------------------
413 -- Insert_Before_Debug --
414 -------------------------
416 procedure Insert_Before_Debug is
419 Write_Str ("Insert node");
420 Write_Int (Int (Node));
421 Write_Str (" before node ");
422 Write_Int (Int (Before));
425 end Insert_Before_Debug;
427 -- Start of processing for Insert_Before
431 (Is_List_Member (Before) and then not Is_List_Member (Node));
437 pragma Debug (Insert_Before_Debug);
440 After : constant Node_Or_Entity_Id := Prev (Before);
441 LC : constant List_Id := List_Containing (Before);
444 if Present (After) then
445 Set_Next (After, Node);
447 Set_First (LC, Node);
450 Set_Prev (Before, Node);
452 Nodes.Table (Node).In_List := True;
454 Set_Prev (Node, After);
455 Set_Next (Node, Before);
456 Set_List_Link (Node, LC);
460 -----------------------
461 -- Insert_List_After --
462 -----------------------
464 procedure Insert_List_After (After : Node_Or_Entity_Id; List : List_Id) is
466 procedure Insert_List_After_Debug;
467 pragma Inline (Insert_List_After_Debug);
468 -- Output debug information if Debug_Flag_N set
470 -----------------------------
471 -- Insert_List_After_Debug --
472 -----------------------------
474 procedure Insert_List_After_Debug is
477 Write_Str ("Insert list ");
478 Write_Int (Int (List));
479 Write_Str (" after node ");
480 Write_Int (Int (After));
483 end Insert_List_After_Debug;
485 -- Start of processing for Insert_List_After
488 pragma Assert (Is_List_Member (After));
490 if Is_Empty_List (List) then
495 Before : constant Node_Or_Entity_Id := Next (After);
496 LC : constant List_Id := List_Containing (After);
497 F : constant Node_Or_Entity_Id := First (List);
498 L : constant Node_Or_Entity_Id := Last (List);
499 N : Node_Or_Entity_Id;
502 pragma Debug (Insert_List_After_Debug);
506 Set_List_Link (N, LC);
511 if Present (Before) then
512 Set_Prev (Before, L);
519 Set_Next (L, Before);
521 Set_First (List, Empty);
522 Set_Last (List, Empty);
525 end Insert_List_After;
527 ------------------------
528 -- Insert_List_Before --
529 ------------------------
531 procedure Insert_List_Before (Before : Node_Or_Entity_Id; List : List_Id) is
533 procedure Insert_List_Before_Debug;
534 pragma Inline (Insert_List_Before_Debug);
535 -- Output debug information if Debug_Flag_N set
537 ------------------------------
538 -- Insert_List_Before_Debug --
539 ------------------------------
541 procedure Insert_List_Before_Debug is
544 Write_Str ("Insert list ");
545 Write_Int (Int (List));
546 Write_Str (" before node ");
547 Write_Int (Int (Before));
550 end Insert_List_Before_Debug;
552 -- Start of processing for Insert_List_Before
555 pragma Assert (Is_List_Member (Before));
557 if Is_Empty_List (List) then
562 After : constant Node_Or_Entity_Id := Prev (Before);
563 LC : constant List_Id := List_Containing (Before);
564 F : constant Node_Or_Entity_Id := First (List);
565 L : constant Node_Or_Entity_Id := Last (List);
566 N : Node_Or_Entity_Id;
569 pragma Debug (Insert_List_Before_Debug);
573 Set_List_Link (N, LC);
578 if Present (After) then
584 Set_Prev (Before, L);
586 Set_Next (L, Before);
588 Set_First (List, Empty);
589 Set_Last (List, Empty);
592 end Insert_List_Before;
598 function Is_Empty_List (List : List_Id) return Boolean is
600 return First (List) = Empty;
607 function Is_List_Member (Node : Node_Or_Entity_Id) return Boolean is
609 return Nodes.Table (Node).In_List;
612 -----------------------
613 -- Is_Non_Empty_List --
614 -----------------------
616 function Is_Non_Empty_List (List : List_Id) return Boolean is
618 return First (List) /= Empty;
619 end Is_Non_Empty_List;
625 function Last (List : List_Id) return Node_Or_Entity_Id is
627 pragma Assert (List <= Lists.Last);
628 return Lists.Table (List).Last;
635 function Last_List_Id return List_Id is
640 ---------------------
641 -- Last_Non_Pragma --
642 ---------------------
644 function Last_Non_Pragma (List : List_Id) return Node_Or_Entity_Id is
645 N : constant Node_Or_Entity_Id := Last (List);
647 if Nkind (N) /= N_Pragma then
650 return Prev_Non_Pragma (N);
654 ---------------------
655 -- List_Containing --
656 ---------------------
658 function List_Containing (Node : Node_Or_Entity_Id) return List_Id is
660 pragma Assert (Is_List_Member (Node));
661 return List_Id (Nodes.Table (Node).Link);
668 function List_Length (List : List_Id) return Nat is
670 Node : Node_Or_Entity_Id;
674 Node := First (List);
675 while Present (Node) loop
676 Result := Result + 1;
687 function Lists_Address return System.Address is
689 return Lists.Table (First_List_Id)'Address;
698 Lists.Locked := True;
701 Prev_Node.Locked := True;
702 Next_Node.Locked := True;
712 function New_Copy_List (List : List_Id) return List_Id is
714 E : Node_Or_Entity_Id;
717 if List = No_List then
724 while Present (E) loop
725 Append (New_Copy (E), NL);
733 ----------------------------
734 -- New_Copy_List_Original --
735 ----------------------------
737 function New_Copy_List_Original (List : List_Id) return List_Id is
739 E : Node_Or_Entity_Id;
742 if List = No_List then
749 while Present (E) loop
750 if Comes_From_Source (E) then
751 Append (New_Copy (E), NL);
759 end New_Copy_List_Original;
765 function New_List return List_Id is
767 procedure New_List_Debug;
768 pragma Inline (New_List_Debug);
769 -- Output debugging information if Debug_Flag_N is set
775 procedure New_List_Debug is
778 Write_Str ("Allocate new list, returned ID = ");
779 Write_Int (Int (Lists.Last));
784 -- Start of processing for New_List
787 Lists.Increment_Last;
790 List : constant List_Id := Lists.Last;
793 Set_Parent (List, Empty);
794 Set_First (List, Empty);
795 Set_Last (List, Empty);
797 pragma Debug (New_List_Debug);
802 -- Since the one argument case is common, we optimize to build the right
803 -- list directly, rather than first building an empty list and then doing
804 -- the insertion, which results in some unnecessary work.
806 function New_List (Node : Node_Or_Entity_Id) return List_Id is
808 procedure New_List_Debug;
809 pragma Inline (New_List_Debug);
810 -- Output debugging information if Debug_Flag_N is set
816 procedure New_List_Debug is
819 Write_Str ("Allocate new list, returned ID = ");
820 Write_Int (Int (Lists.Last));
825 -- Start of processing for New_List
832 pragma Assert (not Is_List_Member (Node));
834 Lists.Increment_Last;
837 List : constant List_Id := Lists.Last;
840 Set_Parent (List, Empty);
841 Set_First (List, Node);
842 Set_Last (List, Node);
844 Nodes.Table (Node).In_List := True;
845 Set_List_Link (Node, List);
846 Set_Prev (Node, Empty);
847 Set_Next (Node, Empty);
848 pragma Debug (New_List_Debug);
855 (Node1 : Node_Or_Entity_Id;
856 Node2 : Node_Or_Entity_Id) return List_Id
858 L : constant List_Id := New_List (Node1);
865 (Node1 : Node_Or_Entity_Id;
866 Node2 : Node_Or_Entity_Id;
867 Node3 : Node_Or_Entity_Id) return List_Id
869 L : constant List_Id := New_List (Node1);
877 (Node1 : Node_Or_Entity_Id;
878 Node2 : Node_Or_Entity_Id;
879 Node3 : Node_Or_Entity_Id;
880 Node4 : Node_Or_Entity_Id) return List_Id
882 L : constant List_Id := New_List (Node1);
891 (Node1 : Node_Or_Entity_Id;
892 Node2 : Node_Or_Entity_Id;
893 Node3 : Node_Or_Entity_Id;
894 Node4 : Node_Or_Entity_Id;
895 Node5 : Node_Or_Entity_Id) return List_Id
897 L : constant List_Id := New_List (Node1);
907 (Node1 : Node_Or_Entity_Id;
908 Node2 : Node_Or_Entity_Id;
909 Node3 : Node_Or_Entity_Id;
910 Node4 : Node_Or_Entity_Id;
911 Node5 : Node_Or_Entity_Id;
912 Node6 : Node_Or_Entity_Id) return List_Id
914 L : constant List_Id := New_List (Node1);
928 function Next (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id is
930 pragma Assert (Is_List_Member (Node));
931 return Next_Node.Table (Node);
934 procedure Next (Node : in out Node_Or_Entity_Id) is
939 -----------------------
940 -- Next_Node_Address --
941 -----------------------
943 function Next_Node_Address return System.Address is
945 return Next_Node.Table (First_Node_Id)'Address;
946 end Next_Node_Address;
948 ---------------------
949 -- Next_Non_Pragma --
950 ---------------------
952 function Next_Non_Pragma
953 (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id
955 N : Node_Or_Entity_Id;
961 exit when not Nkind_In (N, N_Pragma, N_Null_Statement);
967 procedure Next_Non_Pragma (Node : in out Node_Or_Entity_Id) is
969 Node := Next_Non_Pragma (Node);
976 function No (List : List_Id) return Boolean is
978 return List = No_List;
985 function Num_Lists return Nat is
987 return Int (Lists.Last) - Int (Lists.First) + 1;
994 function Parent (List : List_Id) return Node_Or_Entity_Id is
996 pragma Assert (List <= Lists.Last);
997 return Lists.Table (List).Parent;
1004 function Pick (List : List_Id; Index : Pos) return Node_Or_Entity_Id is
1005 Elmt : Node_Or_Entity_Id;
1008 Elmt := First (List);
1009 for J in 1 .. Index - 1 loop
1010 Elmt := Next (Elmt);
1020 procedure Prepend (Node : Node_Or_Entity_Id; To : List_Id) is
1021 F : constant Node_Or_Entity_Id := First (To);
1023 procedure Prepend_Debug;
1024 pragma Inline (Prepend_Debug);
1025 -- Output debug information if Debug_Flag_N set
1031 procedure Prepend_Debug is
1033 if Debug_Flag_N then
1034 Write_Str ("Prepend node ");
1035 Write_Int (Int (Node));
1036 Write_Str (" to list ");
1037 Write_Int (Int (To));
1042 -- Start of processing for Prepend_Debug
1045 pragma Assert (not Is_List_Member (Node));
1047 if Node = Error then
1051 pragma Debug (Prepend_Debug);
1054 Set_Last (To, Node);
1059 Set_First (To, Node);
1061 Nodes.Table (Node).In_List := True;
1064 Set_Prev (Node, Empty);
1065 Set_List_Link (Node, To);
1072 procedure Prepend_List (List : List_Id; To : List_Id) is
1074 procedure Prepend_List_Debug;
1075 pragma Inline (Prepend_List_Debug);
1076 -- Output debug information if Debug_Flag_N set
1078 ------------------------
1079 -- Prepend_List_Debug --
1080 ------------------------
1082 procedure Prepend_List_Debug is
1084 if Debug_Flag_N then
1085 Write_Str ("Prepend list ");
1086 Write_Int (Int (List));
1087 Write_Str (" to list ");
1088 Write_Int (Int (To));
1091 end Prepend_List_Debug;
1093 -- Start of processing for Prepend_List
1096 if Is_Empty_List (List) then
1101 F : constant Node_Or_Entity_Id := First (To);
1102 L : constant Node_Or_Entity_Id := Last (List);
1103 N : Node_Or_Entity_Id;
1106 pragma Debug (Prepend_List_Debug);
1110 Set_List_Link (N, To);
1122 Set_First (To, First (List));
1124 Set_First (List, Empty);
1125 Set_Last (List, Empty);
1130 ---------------------
1131 -- Prepend_List_To --
1132 ---------------------
1134 procedure Prepend_List_To (To : List_Id; List : List_Id) is
1136 Prepend_List (List, To);
1137 end Prepend_List_To;
1143 procedure Prepend_To (To : List_Id; Node : Node_Or_Entity_Id) is
1152 function Present (List : List_Id) return Boolean is
1154 return List /= No_List;
1161 function Prev (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id is
1163 pragma Assert (Is_List_Member (Node));
1164 return Prev_Node.Table (Node);
1167 procedure Prev (Node : in out Node_Or_Entity_Id) is
1169 Node := Prev (Node);
1172 -----------------------
1173 -- Prev_Node_Address --
1174 -----------------------
1176 function Prev_Node_Address return System.Address is
1178 return Prev_Node.Table (First_Node_Id)'Address;
1179 end Prev_Node_Address;
1181 ---------------------
1182 -- Prev_Non_Pragma --
1183 ---------------------
1185 function Prev_Non_Pragma
1186 (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id
1188 N : Node_Or_Entity_Id;
1194 exit when Nkind (N) /= N_Pragma;
1198 end Prev_Non_Pragma;
1200 procedure Prev_Non_Pragma (Node : in out Node_Or_Entity_Id) is
1202 Node := Prev_Non_Pragma (Node);
1203 end Prev_Non_Pragma;
1209 procedure Remove (Node : Node_Or_Entity_Id) is
1210 Lst : constant List_Id := List_Containing (Node);
1211 Prv : constant Node_Or_Entity_Id := Prev (Node);
1212 Nxt : constant Node_Or_Entity_Id := Next (Node);
1214 procedure Remove_Debug;
1215 pragma Inline (Remove_Debug);
1216 -- Output debug information if Debug_Flag_N set
1222 procedure Remove_Debug is
1224 if Debug_Flag_N then
1225 Write_Str ("Remove node ");
1226 Write_Int (Int (Node));
1231 -- Start of processing for Remove
1234 pragma Debug (Remove_Debug);
1237 Set_First (Lst, Nxt);
1239 Set_Next (Prv, Nxt);
1243 Set_Last (Lst, Prv);
1245 Set_Prev (Nxt, Prv);
1248 Nodes.Table (Node).In_List := False;
1249 Set_Parent (Node, Empty);
1256 function Remove_Head (List : List_Id) return Node_Or_Entity_Id is
1257 Frst : constant Node_Or_Entity_Id := First (List);
1259 procedure Remove_Head_Debug;
1260 pragma Inline (Remove_Head_Debug);
1261 -- Output debug information if Debug_Flag_N set
1263 -----------------------
1264 -- Remove_Head_Debug --
1265 -----------------------
1267 procedure Remove_Head_Debug is
1269 if Debug_Flag_N then
1270 Write_Str ("Remove head of list ");
1271 Write_Int (Int (List));
1274 end Remove_Head_Debug;
1276 -- Start of processing for Remove_Head
1279 pragma Debug (Remove_Head_Debug);
1281 if Frst = Empty then
1286 Nxt : constant Node_Or_Entity_Id := Next (Frst);
1289 Set_First (List, Nxt);
1292 Set_Last (List, Empty);
1294 Set_Prev (Nxt, Empty);
1297 Nodes.Table (Frst).In_List := False;
1298 Set_Parent (Frst, Empty);
1308 function Remove_Next
1309 (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id
1311 Nxt : constant Node_Or_Entity_Id := Next (Node);
1313 procedure Remove_Next_Debug;
1314 pragma Inline (Remove_Next_Debug);
1315 -- Output debug information if Debug_Flag_N set
1317 -----------------------
1318 -- Remove_Next_Debug --
1319 -----------------------
1321 procedure Remove_Next_Debug is
1323 if Debug_Flag_N then
1324 Write_Str ("Remove next node after ");
1325 Write_Int (Int (Node));
1328 end Remove_Next_Debug;
1330 -- Start of processing for Remove_Next
1333 if Present (Nxt) then
1335 Nxt2 : constant Node_Or_Entity_Id := Next (Nxt);
1336 LC : constant List_Id := List_Containing (Node);
1339 pragma Debug (Remove_Next_Debug);
1340 Set_Next (Node, Nxt2);
1343 Set_Last (LC, Node);
1345 Set_Prev (Nxt2, Node);
1348 Nodes.Table (Nxt).In_List := False;
1349 Set_Parent (Nxt, Empty);
1360 procedure Set_First (List : List_Id; To : Node_Or_Entity_Id) is
1362 Lists.Table (List).First := To;
1369 procedure Set_Last (List : List_Id; To : Node_Or_Entity_Id) is
1371 Lists.Table (List).Last := To;
1378 procedure Set_List_Link (Node : Node_Or_Entity_Id; To : List_Id) is
1380 Nodes.Table (Node).Link := Union_Id (To);
1387 procedure Set_Next (Node : Node_Or_Entity_Id; To : Node_Or_Entity_Id) is
1389 Next_Node.Table (Node) := To;
1396 procedure Set_Parent (List : List_Id; Node : Node_Or_Entity_Id) is
1398 pragma Assert (List <= Lists.Last);
1399 Lists.Table (List).Parent := Node;
1406 procedure Set_Prev (Node : Node_Or_Entity_Id; To : Node_Or_Entity_Id) is
1408 Prev_Node.Table (Node) := To;
1415 procedure Tree_Read is
1418 Next_Node.Tree_Read;
1419 Prev_Node.Tree_Read;
1426 procedure Tree_Write is
1429 Next_Node.Tree_Write;
1430 Prev_Node.Tree_Write;
1439 Lists.Locked := False;
1440 Prev_Node.Locked := False;
1441 Next_Node.Locked := False;