OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [nlists.ads] - Blame information for rev 320

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                               N L I S T S                                --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
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- --
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.                                     --
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/>.                                          --
26
--                                                                          --
27
-- GNAT was originally developed  by the GNAT team at  New York University. --
28
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29
--                                                                          --
30
------------------------------------------------------------------------------
31
 
32
--  This package provides facilities for manipulating lists of nodes (see
33
--  package Atree for format and implementation of tree nodes). The Link field
34
--  of the nodes is used as the forward pointer for these lists. See also
35
--  package Elists which provides another form of lists that are not threaded
36
--  through the nodes (and therefore allow nodes to be on multiple lists).
37
 
38
with System;
39
with Types; use Types;
40
 
41
package Nlists is
42
 
43
   --  A node list is a list of nodes in a special format that means that
44
   --  nodes can be on at most one such list. For each node list, a list
45
   --  header is allocated in the lists table, and a List_Id value references
46
   --  this header, which may be used to access the nodes in the list using
47
   --  the set of routines that define this interface.
48
 
49
   --  Note: node lists can contain either nodes or entities (extended nodes)
50
   --  or a mixture of nodes and extended nodes.
51
 
52
   function Last_List_Id return List_Id;
53
   pragma Inline (Last_List_Id);
54
   --  Returns Id of last allocated list header
55
 
56
   function Lists_Address return System.Address;
57
   pragma Inline (Lists_Address);
58
   --  Return address of Lists table (used in Back_End for Gigi call)
59
 
60
   function Num_Lists return Nat;
61
   pragma Inline (Num_Lists);
62
   --  Number of currently allocated lists
63
 
64
   function New_List return List_Id;
65
   --  Creates a new empty node list. Typically this is used to initialize
66
   --  a field in some other node which points to a node list where the list
67
   --  is then subsequently filled in using Append calls.
68
 
69
   function Empty_List return List_Id renames New_List;
70
   --  Used in contexts where an empty list (as opposed to an initially empty
71
   --  list to be filled in) is required.
72
 
73
   function New_List (Node : Node_Id) return List_Id;
74
   --  Build a new list initially containing the given node
75
 
76
   function New_List (Node1, Node2 : Node_Id) return List_Id;
77
   --  Build a new list initially containing the two given nodes
78
 
79
   function New_List (Node1, Node2, Node3 : Node_Id) return List_Id;
80
   --  Build a new list initially containing the three given nodes
81
 
82
   function New_List (Node1, Node2, Node3, Node4 : Node_Id) return List_Id;
83
   --  Build a new list initially containing the four given nodes
84
 
85
   function New_List
86
     (Node1 : Node_Id;
87
      Node2 : Node_Id;
88
      Node3 : Node_Id;
89
      Node4 : Node_Id;
90
      Node5 : Node_Id) return List_Id;
91
   --  Build a new list initially containing the five given nodes
92
 
93
   function New_List
94
     (Node1 : Node_Id;
95
      Node2 : Node_Id;
96
      Node3 : Node_Id;
97
      Node4 : Node_Id;
98
      Node5 : Node_Id;
99
      Node6 : Node_Id) return List_Id;
100
   --  Build a new list initially containing the six given nodes
101
 
102
   function New_Copy_List (List : List_Id) return List_Id;
103
   --  Creates a new list containing copies (made with Atree.New_Copy) of every
104
   --  node in the original list. If the argument is No_List, then the returned
105
   --  result is No_List. If the argument is an empty list, then the returned
106
   --  result is a new empty list.
107
 
108
   function New_Copy_List_Original (List : List_Id) return List_Id;
109
   --  Same as New_Copy_List but copies only nodes coming from source
110
 
111
   function First (List : List_Id) return Node_Id;
112
   pragma Inline (First);
113
   --  Obtains the first element of the given node list or, if the node list
114
   --  has no items or is equal to No_List, then Empty is returned.
115
 
116
   function First_Non_Pragma (List : List_Id) return Node_Id;
117
   --  Used when dealing with a list that can contain pragmas to skip past
118
   --  any initial pragmas and return the first element that is not a pragma.
119
   --  If the list is empty, or if it contains only pragmas, then Empty is
120
   --  returned. It is an error to call First_Non_Pragma with a Node_Id value
121
   --  or No_List (No_List is not considered to be the same as an empty list).
122
   --  This function also skips N_Null nodes which can result from rewriting
123
   --  unrecognized or incorrect pragmas.
124
 
125
   function Last (List : List_Id) return Node_Id;
126
   pragma Inline (Last);
127
   --  Obtains the last element of the given node list or, if the node list
128
   --  has no items, then Empty is returned. It is an error to call Last with
129
   --  a Node_Id or No_List. (No_List is not considered to be the same as an
130
   --  empty node list).
131
 
132
   function Last_Non_Pragma (List : List_Id) return Node_Id;
133
   --  Obtains the last element of a given node list that is not a pragma.
134
   --  If the list is empty, or if it contains only pragmas, then Empty is
135
   --  returned. It is an error to call Last_Non_Pragma with a Node_Id or
136
   --  No_List. (No_List is not considered to be the same as an empty list).
137
 
138
   function List_Length (List : List_Id) return Nat;
139
   pragma Inline (List_Length);
140
   --  Returns number of items in the given list. It is an error to call
141
   --  this function with No_List (No_List is not considered to be the same
142
   --  as an empty list).
143
 
144
   function Next (Node : Node_Id) return Node_Id;
145
   pragma Inline (Next);
146
   --  This function returns the next node on a node list, or Empty if Node is
147
   --  the last element of the node list. The argument must be a member of a
148
   --  node list.
149
 
150
   procedure Next (Node : in out Node_Id);
151
   pragma Inline (Next);
152
   --  Equivalent to Node := Next (Node);
153
 
154
   function Next_Non_Pragma (Node : Node_Id) return Node_Id;
155
   --  This function returns the next node on a node list, skipping past any
156
   --  pragmas, or Empty if there is no non-pragma entry left. The argument
157
   --  must be a member of a node list. This function also skips N_Null nodes
158
   --  which can result from rewriting unrecognized or incorrect pragmas.
159
 
160
   procedure Next_Non_Pragma (Node : in out Node_Id);
161
   pragma Inline (Next_Non_Pragma);
162
   --  Equivalent to Node := Next_Non_Pragma (Node);
163
 
164
   function Prev (Node : Node_Id) return Node_Id;
165
   pragma Inline (Prev);
166
   --  This function returns the previous node on a node list, or Empty
167
   --  if Node is the first element of the node list. The argument must be
168
   --  a member of a node list. Note: the implementation does maintain back
169
   --  pointers, so this function executes quickly in constant time.
170
 
171
   function Pick (List : List_Id; Index : Pos) return Node_Id;
172
   --  Given a list, picks out the Index'th entry (1 = first entry). The
173
   --  caller must ensure that Index is in range.
174
 
175
   procedure Prev (Node : in out Node_Id);
176
   pragma Inline (Prev);
177
   --  Equivalent to Node := Prev (Node);
178
 
179
   function Prev_Non_Pragma (Node : Node_Id) return Node_Id;
180
   pragma Inline (Prev_Non_Pragma);
181
   --  This function returns the previous node on a node list, skipping any
182
   --  pragmas. If Node is the first element of the list, or if the only
183
   --  elements preceding it are pragmas, then Empty is returned. The
184
   --  argument must be a member of a node list. Note: the implementation
185
   --  does maintain back pointers, so this function executes quickly in
186
   --  constant time.
187
 
188
   procedure Prev_Non_Pragma (Node : in out Node_Id);
189
   pragma Inline (Prev_Non_Pragma);
190
   --  Equivalent to Node := Prev_Non_Pragma (Node);
191
 
192
   function Is_Empty_List (List : List_Id) return Boolean;
193
   pragma Inline (Is_Empty_List);
194
   --  This function determines if a given list id references a node list that
195
   --  contains no items. No_List as an argument returns True.
196
 
197
   function Is_Non_Empty_List (List : List_Id) return Boolean;
198
   pragma Inline (Is_Non_Empty_List);
199
   --  This function determines if a given list id references a node list that
200
   --  contains at least one item. No_List as an argument returns False.
201
 
202
   function Is_List_Member (Node : Node_Id) return Boolean;
203
   pragma Inline (Is_List_Member);
204
   --  This function determines if a given node is a member of a node list.
205
   --  It is an error for Node to be Empty, or to be a node list.
206
 
207
   function List_Containing (Node : Node_Id) return List_Id;
208
   pragma Inline (List_Containing);
209
   --  This function provides a pointer to the node list containing Node.
210
   --  Node must be a member of a node list.
211
 
212
   procedure Append (Node : Node_Id; To : List_Id);
213
   --  Appends Node at the end of node list To. Node must be a non-empty node
214
   --  that is not already a member of a node list, and To must be a
215
   --  node list. An attempt to append an error node is ignored without
216
   --  complaint and the list is unchanged.
217
 
218
   procedure Append_To (To : List_Id; Node : Node_Id);
219
   pragma Inline (Append_To);
220
   --  Like Append, but arguments are the other way round
221
 
222
   procedure Append_List (List : List_Id; To : List_Id);
223
   --  Appends node list List to the end of node list To. On return,
224
   --  List is reset to be empty.
225
 
226
   procedure Append_List_To (To : List_Id; List : List_Id);
227
   pragma Inline (Append_List_To);
228
   --  Like Append_List, but arguments are the other way round
229
 
230
   procedure Insert_After (After : Node_Id; Node : Node_Id);
231
   --  Insert Node, which must be a non-empty node that is not already a
232
   --  member of a node list, immediately past node After, which must be a
233
   --  node that is currently a member of a node list. An attempt to insert
234
   --  an error node is ignored without complaint (and the list is unchanged).
235
 
236
   procedure Insert_List_After (After : Node_Id; List : List_Id);
237
   --  Inserts the entire contents of node list List immediately after node
238
   --  After, which must be a member of a node list. On return, the node list
239
   --  List is reset to be the empty node list.
240
 
241
   procedure Insert_Before (Before : Node_Id; Node : Node_Id);
242
   --  Insert Node, which must be a non-empty node that is not already a
243
   --  member of a node list, immediately before Before, which must be a node
244
   --  that is currently a member of a node list. An attempt to insert an
245
   --  error node is ignored without complaint (and the list is unchanged).
246
 
247
   procedure Insert_List_Before (Before : Node_Id; List : List_Id);
248
   --  Inserts the entire contents of node list List immediately before node
249
   --  Before, which must be a member of a node list. On return, the node list
250
   --  List is reset to be the empty node list.
251
 
252
   procedure Prepend (Node : Node_Id; To : List_Id);
253
   --  Prepends Node at the start of node list To. Node must be a non-empty
254
   --  node that is not already a member of a node list, and To must be a
255
   --  node list. An attempt to prepend an error node is ignored without
256
   --  complaint and the list is unchanged.
257
 
258
   procedure Prepend_To (To : List_Id; Node : Node_Id);
259
   pragma Inline (Prepend_To);
260
   --  Like Prepend, but arguments are the other way round
261
 
262
   procedure Remove (Node : Node_Id);
263
   --  Removes Node, which must be a node that is a member of a node list,
264
   --  from this node list. The contents of Node are not otherwise affected.
265
 
266
   function Remove_Head (List : List_Id) return Node_Id;
267
   --  Removes the head element of a node list, and returns the node (whose
268
   --  contents are not otherwise affected) as the result. If the node list
269
   --  is empty, then Empty is returned.
270
 
271
   function Remove_Next (Node : Node_Id) return Node_Id;
272
   --  Removes the item immediately following the given node, and returns it
273
   --  as the result. If Node is the last element of the list, then Empty is
274
   --  returned. Node must be a member of a list. Unlike Remove, Remove_Next
275
   --  is fast and does not involve any list traversal.
276
 
277
   procedure Initialize;
278
   --  Called at the start of compilation of each new main source file to
279
   --  initialize the allocation of the list table. Note that Initialize
280
   --  must not be called if Tree_Read is used.
281
 
282
   procedure Lock;
283
   --  Called to lock tables before back end is called
284
 
285
   procedure Unlock;
286
   --  Unlock tables, in cases where the back end needs to modify them
287
 
288
   procedure Tree_Read;
289
   --  Initializes internal tables from current tree file using the relevant
290
   --  Table.Tree_Read routines. Note that Initialize should not be called if
291
   --  Tree_Read is used. Tree_Read includes all necessary initialization.
292
 
293
   procedure Tree_Write;
294
   --  Writes out internal tables to current tree file using the relevant
295
   --  Table.Tree_Write routines.
296
 
297
   function Parent (List : List_Id) return Node_Id;
298
   pragma Inline (Parent);
299
   --  Node lists may have a parent in the same way as a node. The function
300
   --  accesses the Parent value, which is either Empty when a list header
301
   --  is first created, or the value that has been set by Set_Parent.
302
 
303
   procedure Set_Parent (List : List_Id; Node : Node_Id);
304
   pragma Inline (Set_Parent);
305
   --  Sets the parent field of the given list to reference the given node
306
 
307
   function No (List : List_Id) return Boolean;
308
   pragma Inline (No);
309
   --  Tests given Id for equality with No_List. This allows notations like
310
   --  "if No (Statements)" as opposed to "if Statements = No_List".
311
 
312
   function Present (List : List_Id) return Boolean;
313
   pragma Inline (Present);
314
   --  Tests given Id for inequality with No_List. This allows notations like
315
   --  "if Present (Statements)" as opposed to "if Statements /= No_List".
316
 
317
   procedure Allocate_List_Tables (N : Node_Id);
318
   --  Called when nodes table is expanded to include node N. This call
319
   --  makes sure that list structures internal to Nlists are adjusted
320
   --  appropriately to reflect this increase in the size of the nodes table.
321
 
322
   function Next_Node_Address return System.Address;
323
   function Prev_Node_Address return System.Address;
324
   --  These functions return the addresses of the Next_Node and Prev_Node
325
   --  tables (used in Back_End for Gigi).
326
 
327
   function p (U : Union_Id) return Node_Id;
328
   --  This function is intended for use from the debugger, it determines
329
   --  whether U is a Node_Id or List_Id, and calls the appropriate Parent
330
   --  function and returns the parent Node in either case. This is shorter
331
   --  to type, and avoids the overloading problem of using Parent. It
332
   --  should NEVER be used except from the debugger. If p is called with
333
   --  other than a node or list id value, it returns 99_999_999.
334
 
335
end Nlists;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.