]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/elists.ads
[Ada] Remove ASIS tree generation
[thirdparty/gcc.git] / gcc / ada / elists.ads
CommitLineData
70482933
RK
1------------------------------------------------------------------------------
2-- --
3-- GNAT COMPILER COMPONENTS --
4-- --
5-- E L I S T S --
6-- --
7-- S p e c --
8-- --
4b490c1e 9-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
70482933
RK
10-- --
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- --
748086b7 13-- ware Foundation; either version 3, or (at your option) any later ver- --
70482933
RK
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 --
748086b7
JJ
16-- or FITNESS FOR A PARTICULAR PURPOSE. --
17-- --
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. --
21-- --
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/>. --
70482933
RK
26-- --
27-- GNAT was originally developed by the GNAT team at New York University. --
71ff80dc 28-- Extensive contributions were provided by Ada Core Technologies Inc. --
70482933
RK
29-- --
30------------------------------------------------------------------------------
31
32-- This package provides facilities for manipulating lists of nodes (see
33-- package Atree for format and implementation of tree nodes). Separate list
34-- elements are allocated to represent elements of these lists, so it is
35-- possible for a given node to be on more than one element list at a time.
36-- See also package Nlists, which provides another form that is threaded
37-- through the nodes themselves (using the Link field), which is more time
38-- and space efficient, but a node can be only one such list.
39
c7732bbe
EB
40-- WARNING: There is a C version of this package. Any changes to this
41-- source file must be properly reflected in the C header file elists.h
42
70482933
RK
43with Types; use Types;
44with System;
45
46package Elists is
47
48 -- An element list is represented by a header that is allocated in the
49 -- Elist header table. This header contains pointers to the first and
50 -- last elements in the list, or to No_Elmt if the list is empty.
51
52 -- The elements in the list each contain a pointer to the next element
53 -- and a pointer to the referenced node. Putting a node into an element
54 -- list causes no change at all to the node itself, so a node may be
55 -- included in multiple element lists, and the nodes thus included may
56 -- or may not be elements of node lists (see package Nlists).
57
58 procedure Initialize;
59 -- Initialize allocation of element list tables. Called at the start of
ba203461 60 -- compiling each new main source file.
70482933
RK
61
62 procedure Lock;
63 -- Lock tables used for element lists before calling backend
64
1c28fe3a
RD
65 procedure Unlock;
66 -- Unlock list tables, in cases where the back end needs to modify them
67
70482933
RK
68 function Last_Elist_Id return Elist_Id;
69 -- Returns Id of last allocated element list header
70
71 function Elists_Address return System.Address;
72 -- Return address of Elists table (used in Back_End for Gigi call)
73
74 function Num_Elists return Nat;
75 -- Number of currently allocated element lists
76
77 function Last_Elmt_Id return Elmt_Id;
78 -- Returns Id of last allocated list element
79
80 function Elmts_Address return System.Address;
81 -- Return address of Elmts table (used in Back_End for Gigi call)
82
ba1cbfb9 83 function Node (Elmt : Elmt_Id) return Node_Or_Entity_Id;
70482933
RK
84 pragma Inline (Node);
85 -- Returns the value of a given list element. Returns Empty if Elmt
86 -- is set to No_Elmt.
87
88 function New_Elmt_List return Elist_Id;
89 -- Creates a new empty element list. Typically this is used to initialize
90 -- a field in some other node which points to an element list where the
91 -- list is then subsequently filled in using Append calls.
92
93 function First_Elmt (List : Elist_Id) return Elmt_Id;
94 pragma Inline (First_Elmt);
ba1cbfb9
RD
95 -- Obtains the first element of the given element list or, if the list has
96 -- no items, then No_Elmt is returned.
70482933
RK
97
98 function Last_Elmt (List : Elist_Id) return Elmt_Id;
99 pragma Inline (Last_Elmt);
ba1cbfb9
RD
100 -- Obtains the last element of the given element list or, if the list has
101 -- no items, then No_Elmt is returned.
70482933 102
5a271a7f 103 function List_Length (List : Elist_Id) return Nat;
89f0276a 104 -- Returns number of elements in given List (zero if List = No_Elist)
5a271a7f 105
70482933
RK
106 function Next_Elmt (Elmt : Elmt_Id) return Elmt_Id;
107 pragma Inline (Next_Elmt);
108 -- This function returns the next element on an element list. The argument
109 -- must be a list element other than No_Elmt. Returns No_Elmt if the given
110 -- element is the last element of the list.
111
112 procedure Next_Elmt (Elmt : in out Elmt_Id);
113 pragma Inline (Next_Elmt);
114 -- Next_Elmt (Elmt) is equivalent to Elmt := Next_Elmt (Elmt)
115
116 function Is_Empty_Elmt_List (List : Elist_Id) return Boolean;
117 pragma Inline (Is_Empty_Elmt_List);
118 -- This function determines if a given tree id references an element list
119 -- that contains no items.
120
87ace727
RD
121 procedure Append_Elmt (N : Node_Or_Entity_Id; To : Elist_Id);
122 -- Appends N at the end of To, allocating a new element. N must be a
123 -- non-empty node or entity Id, and To must be an Elist (not No_Elist).
70482933 124
21c51f53
RD
125 procedure Append_New_Elmt (N : Node_Or_Entity_Id; To : in out Elist_Id);
126 pragma Inline (Append_New_Elmt);
127 -- Like Append_Elmt if Elist_Id is not No_List, but if Elist_Id is No_List,
128 -- then first assigns it an empty element list and then does the append.
129
87ace727
RD
130 procedure Append_Unique_Elmt (N : Node_Or_Entity_Id; To : Elist_Id);
131 -- Like Append_Elmt, except that a check is made to see if To already
132 -- contains N and if so the call has no effect.
70482933 133
87ace727
RD
134 procedure Prepend_Elmt (N : Node_Or_Entity_Id; To : Elist_Id);
135 -- Appends N at the beginning of To, allocating a new element
136
b619c88e
AC
137 procedure Prepend_Unique_Elmt (N : Node_Or_Entity_Id; To : Elist_Id);
138 -- Like Prepend_Elmt, except that a check is made to see if To already
139 -- contains N and if so the call has no effect.
140
87ace727
RD
141 procedure Insert_Elmt_After (N : Node_Or_Entity_Id; Elmt : Elmt_Id);
142 -- Add a new element (N) right after the pre-existing element Elmt
70482933
RK
143 -- It is invalid to call this subprogram with Elmt = No_Elmt.
144
ab8843fa
HK
145 function New_Copy_Elist (List : Elist_Id) return Elist_Id;
146 -- Replicate the contents of a list. Internal list nodes are not shared and
147 -- order of elements is preserved.
148
87ace727 149 procedure Replace_Elmt (Elmt : Elmt_Id; New_Node : Node_Or_Entity_Id);
70482933
RK
150 pragma Inline (Replace_Elmt);
151 -- Causes the given element of the list to refer to New_Node, the node
152 -- which was previously referred to by Elmt is effectively removed from
153 -- the list and replaced by New_Node.
154
ab8843fa
HK
155 procedure Remove (List : Elist_Id; N : Node_Or_Entity_Id);
156 -- Remove a node or an entity from a list. If the list does not contain the
157 -- item in question, the routine has no effect.
158
70482933
RK
159 procedure Remove_Elmt (List : Elist_Id; Elmt : Elmt_Id);
160 -- Removes Elmt from the given list. The node itself is not affected,
161 -- but the space used by the list element may be (but is not required
162 -- to be) freed for reuse in a subsequent Append_Elmt call.
163
164 procedure Remove_Last_Elmt (List : Elist_Id);
165 -- Removes the last element of the given list. The node itself is not
166 -- affected, but the space used by the list element may be (but is not
167 -- required to be) freed for reuse in a subsequent Append_Elmt call.
168
fe96ecb9
AC
169 function Contains (List : Elist_Id; N : Node_Or_Entity_Id) return Boolean;
170 -- Perform a sequential search to determine whether the given list contains
171 -- a node or an entity.
172
70482933
RK
173 function No (List : Elist_Id) return Boolean;
174 pragma Inline (No);
175 -- Tests given Id for equality with No_Elist. This allows notations like
176 -- "if No (Statements)" as opposed to "if Statements = No_Elist".
177
178 function Present (List : Elist_Id) return Boolean;
179 pragma Inline (Present);
180 -- Tests given Id for inequality with No_Elist. This allows notations like
181 -- "if Present (Statements)" as opposed to "if Statements /= No_Elist".
182
183 function No (Elmt : Elmt_Id) return Boolean;
184 pragma Inline (No);
185 -- Tests given Id for equality with No_Elmt. This allows notations like
186 -- "if No (Operation)" as opposed to "if Operation = No_Elmt".
187
188 function Present (Elmt : Elmt_Id) return Boolean;
189 pragma Inline (Present);
190 -- Tests given Id for inequality with No_Elmt. This allows notations like
191 -- "if Present (Operation)" as opposed to "if Operation /= No_Elmt".
192
193end Elists;