annotate gcc/ada/lib.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- L I B --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package contains routines for accessing and outputting the library
kono
parents:
diff changeset
33 -- information. It contains the routine to load subsidiary units.
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 with Alloc;
kono
parents:
diff changeset
36 with Namet; use Namet;
kono
parents:
diff changeset
37 with Table;
kono
parents:
diff changeset
38 with Types; use Types;
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 package Lib is
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 type Unit_Ref_Table is array (Pos range <>) of Unit_Number_Type;
kono
parents:
diff changeset
43 -- Type to hold list of indirect references to unit number table
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 type Compiler_State_Type is (Parsing, Analyzing);
kono
parents:
diff changeset
46 Compiler_State : Compiler_State_Type;
kono
parents:
diff changeset
47 -- Indicates current state of compilation. This is used to implement the
kono
parents:
diff changeset
48 -- function In_Extended_Main_Source_Unit.
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 Parsing_Main_Extended_Source : Boolean := False;
kono
parents:
diff changeset
51 -- Set True if we are currently parsing a file that is part of the main
kono
parents:
diff changeset
52 -- extended source (the main unit, its spec, or one of its subunits). This
kono
parents:
diff changeset
53 -- flag to implement In_Extended_Main_Source_Unit.
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 Analysing_Subunit_Of_Main : Boolean := False;
kono
parents:
diff changeset
56 -- Set to True when analyzing a subunit of the main source. When True, if
kono
parents:
diff changeset
57 -- the subunit is preprocessed and -gnateG is specified, then the
kono
parents:
diff changeset
58 -- preprocessed file (.prep) is written.
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 --------------------------------------------
kono
parents:
diff changeset
61 -- General Approach to Library Management --
kono
parents:
diff changeset
62 --------------------------------------------
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 -- As described in GNote #1, when a unit is compiled, all its subsidiary
kono
parents:
diff changeset
65 -- units are recompiled, including the following:
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 -- (a) Corresponding spec for a body
kono
parents:
diff changeset
68 -- (b) Parent spec of a child library spec
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
69 -- (c) With'ed specs
111
kono
parents:
diff changeset
70 -- (d) Parent body of a subunit
kono
parents:
diff changeset
71 -- (e) Subunits corresponding to any specified stubs
kono
parents:
diff changeset
72 -- (f) Bodies of inlined subprograms that are called
kono
parents:
diff changeset
73 -- (g) Bodies of generic subprograms or packages that are instantiated
kono
parents:
diff changeset
74 -- (h) Bodies of packages containing either of the above two items
kono
parents:
diff changeset
75 -- (i) Specs and bodies of runtime units
kono
parents:
diff changeset
76 -- (j) Parent specs for with'ed child library units
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 -- If a unit is being compiled only for syntax checking, then no subsidiary
kono
parents:
diff changeset
79 -- units are loaded, the syntax check applies only to the main unit,
kono
parents:
diff changeset
80 -- i.e. the one contained in the source submitted to the library.
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 -- If a unit is being compiled for syntax and semantic checking, then only
kono
parents:
diff changeset
83 -- cases (a)-(d) loads are performed, since the full semantic checking can
kono
parents:
diff changeset
84 -- be carried out without needing (e)-(i) loads. In this case no object
kono
parents:
diff changeset
85 -- file, or library information file, is generated, so the missing units
kono
parents:
diff changeset
86 -- do not affect the results.
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 -- Specifications of library subprograms, subunits, and generic specs
kono
parents:
diff changeset
89 -- and bodies, can only be compiled in syntax/semantic checking mode,
kono
parents:
diff changeset
90 -- since no code is ever generated directly for these units. In the case
kono
parents:
diff changeset
91 -- of subunits, only the compilation of the ultimate parent unit generates
kono
parents:
diff changeset
92 -- actual code. If a subunit is submitted to the compiler in syntax/
kono
parents:
diff changeset
93 -- semantic checking mode, the parent (or parents in the nested case) are
kono
parents:
diff changeset
94 -- semantically checked only up to the point of the corresponding stub.
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 -- If code is being generated, then all the above units are required,
kono
parents:
diff changeset
97 -- although the need for bodies of inlined procedures can be suppressed
kono
parents:
diff changeset
98 -- by the use of a switch that sets the mode to ignore pragma Inline
kono
parents:
diff changeset
99 -- statements.
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 -- The two main sections of the front end, Par and Sem, are recursive.
kono
parents:
diff changeset
102 -- Compilation proceeds unit by unit making recursive calls as necessary.
kono
parents:
diff changeset
103 -- The process is controlled from the GNAT main program, which makes calls
kono
parents:
diff changeset
104 -- to Par and Sem sequence for the main unit.
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- Par parses the given unit, and then, after the parse is complete, uses
kono
parents:
diff changeset
107 -- the Par.Load subprogram to load all its subsidiary units in categories
kono
parents:
diff changeset
108 -- (a)-(d) above, installing pointers to the loaded units in the parse
kono
parents:
diff changeset
109 -- tree, as described in a later section of this spec. If any of these
kono
parents:
diff changeset
110 -- required units is missing, a fatal error is signalled, so that no
kono
parents:
diff changeset
111 -- attempt is made to run Sem in such cases, since it is assumed that
kono
parents:
diff changeset
112 -- too many cascaded errors would result, and the confusion would not
kono
parents:
diff changeset
113 -- be helpful.
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 -- Following the call to Par on the main unit, the entire tree of required
kono
parents:
diff changeset
116 -- units is thus loaded, and Sem is called on the main unit. The parameter
kono
parents:
diff changeset
117 -- passed to Sem is the unit to be analyzed. The visibility table, which
kono
parents:
diff changeset
118 -- is a single global structure, starts out containing only the entries
kono
parents:
diff changeset
119 -- for the visible entities in Standard. Every call to Sem establishes a
kono
parents:
diff changeset
120 -- new scope stack table, pushing an entry for Standard on entry to provide
kono
parents:
diff changeset
121 -- the proper initial scope environment.
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 -- Sem first proceeds to perform semantic analysis on the currently loaded
kono
parents:
diff changeset
124 -- units as follows:
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 -- In the case of a body (case (a) above), Sem analyzes the corresponding
kono
parents:
diff changeset
127 -- spec, using a recursive call to Sem. As is always expected to be the
kono
parents:
diff changeset
128 -- case with calls to Sem, any entities installed in the visibility table
kono
parents:
diff changeset
129 -- are removed on exit from Sem, so that these entities have to be
kono
parents:
diff changeset
130 -- reinstalled on return to continue the analysis of the body which of
kono
parents:
diff changeset
131 -- course needs visibility of these entities.
kono
parents:
diff changeset
132 --
kono
parents:
diff changeset
133 -- In the case of the parent of a child spec (case (b) above), a similar
kono
parents:
diff changeset
134 -- call is made to Sem to analyze the parent. Again, on return, the
kono
parents:
diff changeset
135 -- entities from the analyzed parent spec have to be installed in the
kono
parents:
diff changeset
136 -- visibility table of the caller (the child unit), which must have
kono
parents:
diff changeset
137 -- visibility to the entities in its parent spec.
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 -- For with'ed specs (case (c) above), a recursive call to Sem is made
kono
parents:
diff changeset
140 -- to analyze each spec in turn. After all the spec's have been analyzed,
kono
parents:
diff changeset
141 -- but not till that point, the entities from all the with'ed units are
kono
parents:
diff changeset
142 -- reinstalled in the visibility table so that the caller can proceed
kono
parents:
diff changeset
143 -- with the analysis of the unit doing the with's with the necessary
kono
parents:
diff changeset
144 -- entities made either potentially use visible or visible by selection
kono
parents:
diff changeset
145 -- as needed.
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 -- Case (d) arises when Sem is passed a subunit to analyze. This means
kono
parents:
diff changeset
148 -- that the main unit is a subunit, and the unit passed to Sem is either
kono
parents:
diff changeset
149 -- the main unit, or one of its ancestors that is still a subunit. Since
kono
parents:
diff changeset
150 -- analysis must start at the top of the tree, Sem essentially cancels
kono
parents:
diff changeset
151 -- the current call by immediately making a call to analyze the parent
kono
parents:
diff changeset
152 -- (when this call is finished it immediately returns, so logically this
kono
parents:
diff changeset
153 -- call is like a goto). The subunit will then be analyzed at the proper
kono
parents:
diff changeset
154 -- time as described for the stub case. Note that we also turn off the
kono
parents:
diff changeset
155 -- indication that code should be generated in this case, since the only
kono
parents:
diff changeset
156 -- time we generate code for subunits is when compiling the main parent.
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 -- Case (e), subunits corresponding to stubs, are handled as the stubs
kono
parents:
diff changeset
159 -- are encountered. There are three sub-cases:
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 -- If the subunit has already been loaded, then this means that the
kono
parents:
diff changeset
162 -- main unit was a subunit, and we are back on our way down to it
kono
parents:
diff changeset
163 -- after following the initial processing described for case (d).
kono
parents:
diff changeset
164 -- In this case we analyze this particular subunit, as described
kono
parents:
diff changeset
165 -- for the case where we are generating code, but when we get back
kono
parents:
diff changeset
166 -- we are all done, since the rest of the parent is irrelevant. To
kono
parents:
diff changeset
167 -- get out of the parent, we raise the exception Subunit_Found, which
kono
parents:
diff changeset
168 -- is handled at the outer level of Sem.
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 -- The cases where the subunit has not already been loaded correspond
kono
parents:
diff changeset
171 -- to cases where the main unit was a parent. In this case the action
kono
parents:
diff changeset
172 -- depends on whether or not we are generating code. If we are not
kono
parents:
diff changeset
173 -- generating code, then this is the case where we can simply ignore
kono
parents:
diff changeset
174 -- the subunit, since in checking mode we don't even want to insist
kono
parents:
diff changeset
175 -- that the subunit exist, much less waste time checking it.
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 -- If we are generating code, then we need to load and analyze
kono
parents:
diff changeset
178 -- all subunits. This is achieved with a call to Lib.Load to load
kono
parents:
diff changeset
179 -- and parse the unit, followed by processing that installs the
kono
parents:
diff changeset
180 -- context clause of the subunit, analyzes the subunit, and then
kono
parents:
diff changeset
181 -- removes the context clause (from the visibility chains of the
kono
parents:
diff changeset
182 -- parent). Note that we do *not* do a recursive call to Sem in
kono
parents:
diff changeset
183 -- this case, precisely because we need to do the analysis of the
kono
parents:
diff changeset
184 -- subunit with the current visibility table and scope stack.
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 -- Case (f) applies only to subprograms for which a pragma Inline is
kono
parents:
diff changeset
187 -- given, providing that the compiler is operating in the mode where
kono
parents:
diff changeset
188 -- pragma Inline's are activated. When the expander encounters a call
kono
parents:
diff changeset
189 -- to such a subprogram, it loads the body of the subprogram if it has
kono
parents:
diff changeset
190 -- not already been loaded, and calls Sem to process it.
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 -- Case (g) is similar to case (f), except that the body of a generic
kono
parents:
diff changeset
193 -- is unconditionally required, regardless of compiler mode settings.
kono
parents:
diff changeset
194 -- As in the subprogram case, when the expander encounters a generic
kono
parents:
diff changeset
195 -- instantiation, it loads the generic body of the subprogram if it
kono
parents:
diff changeset
196 -- has not already been loaded, and calls Sem to process it.
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 -- Case (h) arises when a package contains either an inlined subprogram
kono
parents:
diff changeset
199 -- which is called, or a generic which is instantiated. In this case the
kono
parents:
diff changeset
200 -- body of the package must be loaded and analyzed with a call to Sem.
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 -- Case (i) is handled by adding implicit with clauses to the context
kono
parents:
diff changeset
203 -- clauses of all units that potentially reference the relevant runtime
kono
parents:
diff changeset
204 -- entities. Note that since we have the full set of units available,
kono
parents:
diff changeset
205 -- the parser can always determine the set of runtime units that is
kono
parents:
diff changeset
206 -- needed. These with clauses do not have associated use clauses, so
kono
parents:
diff changeset
207 -- all references to the entities must be by selection. Once the with
kono
parents:
diff changeset
208 -- clauses have been added, subsequent processing is as for normal
kono
parents:
diff changeset
209 -- with clauses.
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 -- Case (j) is also handled by adding appropriate implicit with clauses
kono
parents:
diff changeset
212 -- to any unit that withs a child unit. Again there is no use clause,
kono
parents:
diff changeset
213 -- and subsequent processing proceeds as for an explicit with clause.
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 -- Sem thus completes the loading of all required units, except those
kono
parents:
diff changeset
216 -- required for inline subprogram bodies or inlined generics. If any
kono
parents:
diff changeset
217 -- of these load attempts fails, then the expander will not be called,
kono
parents:
diff changeset
218 -- even if code was to be generated. If the load attempts all succeed
kono
parents:
diff changeset
219 -- then the expander is called, though the attempt to generate code may
kono
parents:
diff changeset
220 -- still fail if an error occurs during a load attempt for an inlined
kono
parents:
diff changeset
221 -- body or a generic body.
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 -------------------------------------------
kono
parents:
diff changeset
224 -- Special Handling of Subprogram Bodies --
kono
parents:
diff changeset
225 -------------------------------------------
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 -- A subprogram body (in an adb file) may stand for both a spec and a body.
kono
parents:
diff changeset
228 -- A simple model (and one that was adopted through version 2.07) is simply
kono
parents:
diff changeset
229 -- to assume that such an adb file acts as its own spec if no ads file is
kono
parents:
diff changeset
230 -- is present.
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 -- However, this is not correct. RM 10.1.4(4) requires that such a body
kono
parents:
diff changeset
233 -- act as a spec unless a subprogram declaration of the same name is
kono
parents:
diff changeset
234 -- already present. The correct interpretation of this in GNAT library
kono
parents:
diff changeset
235 -- terms is to ignore an existing ads file of the same name unless this
kono
parents:
diff changeset
236 -- ads file contains a subprogram declaration with the same name.
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 -- If there is an ads file with a unit other than a subprogram declaration
kono
parents:
diff changeset
239 -- with the same name, then a fatal message is output, noting that this
kono
parents:
diff changeset
240 -- irrelevant file must be deleted before the body can be compiled. See
kono
parents:
diff changeset
241 -- ACVC test CA1020D to see how this processing is required.
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 -----------------
kono
parents:
diff changeset
244 -- Global Data --
kono
parents:
diff changeset
245 -----------------
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 Current_Sem_Unit : Unit_Number_Type := Main_Unit;
kono
parents:
diff changeset
248 -- Unit number of unit currently being analyzed/expanded. This is set when
kono
parents:
diff changeset
249 -- ever a new unit is entered, saving and restoring the old value, so that
kono
parents:
diff changeset
250 -- it always reflects the unit currently being analyzed. The initial value
kono
parents:
diff changeset
251 -- of Main_Unit ensures that a proper value is set initially, and in
kono
parents:
diff changeset
252 -- particular for analysis of configuration pragmas in gnat.adc.
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 Main_Unit_Entity : Entity_Id;
kono
parents:
diff changeset
255 -- Entity of main unit, same as Cunit_Entity (Main_Unit) except where
kono
parents:
diff changeset
256 -- Main_Unit is a body with a separate spec, in which case it is the
kono
parents:
diff changeset
257 -- entity for the spec.
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 -----------------
kono
parents:
diff changeset
260 -- Units Table --
kono
parents:
diff changeset
261 -----------------
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 -- The units table has an entry for each unit (source file) read in by the
kono
parents:
diff changeset
264 -- current compilation. The table is indexed by the unit number value.
kono
parents:
diff changeset
265 -- The first entry in the table, subscript Main_Unit, is for the main file.
kono
parents:
diff changeset
266 -- Each entry in this units table contains the following data.
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 -- Cunit
kono
parents:
diff changeset
269 -- Pointer to the N_Compilation_Unit node. Initially set to Empty by
kono
parents:
diff changeset
270 -- Lib.Load, and then reset to the required node by the parser when
kono
parents:
diff changeset
271 -- the unit is parsed.
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 -- Cunit_Entity
kono
parents:
diff changeset
274 -- Pointer to the entity node for the compilation unit. Initially set
kono
parents:
diff changeset
275 -- to Empty by Lib.Load, and then reset to the required entity by the
kono
parents:
diff changeset
276 -- parser when the unit is parsed.
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 -- Dependency_Num
kono
parents:
diff changeset
279 -- This is the number of the unit within the generated dependency
kono
parents:
diff changeset
280 -- lines (D lines in the ALI file) which are sorted into alphabetical
kono
parents:
diff changeset
281 -- order. The number is ones origin, so a value of 2 refers to the
kono
parents:
diff changeset
282 -- second generated D line. The Dependency_Num values are set as the
kono
parents:
diff changeset
283 -- D lines are generated, and are used to generate proper unit
kono
parents:
diff changeset
284 -- references in the generated xref information and SCO output.
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 -- Dynamic_Elab
kono
parents:
diff changeset
287 -- A flag indicating if this unit was compiled with dynamic elaboration
kono
parents:
diff changeset
288 -- checks specified (as the result of using the -gnatE compilation
kono
parents:
diff changeset
289 -- option or a pragma Elaboration_Checks (Dynamic)).
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 -- Error_Location
kono
parents:
diff changeset
292 -- This is copied from the Sloc field of the Enode argument passed
kono
parents:
diff changeset
293 -- to Load_Unit. It refers to the enclosing construct which caused
kono
parents:
diff changeset
294 -- this unit to be loaded, e.g. most typically the with clause that
kono
parents:
diff changeset
295 -- referenced the unit, and is used for error handling in Par.Load.
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 -- Expected_Unit
kono
parents:
diff changeset
298 -- This is the expected unit name for a file other than the main unit,
kono
parents:
diff changeset
299 -- since these are cases where we load the unit using Lib.Load and we
kono
parents:
diff changeset
300 -- know the unit that is expected. It must be the same as Unit_Name
kono
parents:
diff changeset
301 -- if it is set (see test in Par.Load). Expected_Unit is set to
kono
parents:
diff changeset
302 -- No_Name for the main unit.
kono
parents:
diff changeset
303
kono
parents:
diff changeset
304 -- Fatal_Error
kono
parents:
diff changeset
305 -- A flag that is initialized to None and gets set to Error if a fatal
kono
parents:
diff changeset
306 -- error occurs during the processing of a unit. A fatal error is one
kono
parents:
diff changeset
307 -- defined as serious enough to stop the next phase of the compiler
kono
parents:
diff changeset
308 -- from running (i.e. fatal error during parsing stops semantics,
kono
parents:
diff changeset
309 -- fatal error during semantics stops code generation). Note that
kono
parents:
diff changeset
310 -- currently, errors of any kind cause Fatal_Error to be set, but
kono
parents:
diff changeset
311 -- eventually perhaps only errors labeled as fatal errors should be
kono
parents:
diff changeset
312 -- this severe if we decide to try Sem on sources with minor errors.
kono
parents:
diff changeset
313 -- There are three settings (see declaration of Fatal_Type).
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 -- Generate_Code
kono
parents:
diff changeset
316 -- This flag is set True for all units in the current file for which
kono
parents:
diff changeset
317 -- code is to be generated. This includes the unit explicitly compiled,
kono
parents:
diff changeset
318 -- together with its specification, and any subunits.
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 -- Has_RACW
kono
parents:
diff changeset
321 -- A Boolean flag, initially set to False when a unit entry is created,
kono
parents:
diff changeset
322 -- and set to True if the unit defines a remote access to class wide
kono
parents:
diff changeset
323 -- (RACW) object. This is used for controlling generation of the RA
kono
parents:
diff changeset
324 -- attribute in the ali file.
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 -- Ident_String
kono
parents:
diff changeset
327 -- N_String_Literal node from a valid pragma Ident that applies to
kono
parents:
diff changeset
328 -- this unit. If no Ident pragma applies to the unit, then Empty.
kono
parents:
diff changeset
329
kono
parents:
diff changeset
330 -- Is_Predefined_Renaming
kono
parents:
diff changeset
331 -- True if this unit is a predefined renaming, as in "Text_IO renames
kono
parents:
diff changeset
332 -- Ada.Text_IO").
kono
parents:
diff changeset
333
kono
parents:
diff changeset
334 -- Is_Internal_Unit
kono
parents:
diff changeset
335 -- Same as In_Predefined_Unit, except units in the GNAT hierarchy are
kono
parents:
diff changeset
336 -- included.
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 -- Is_Predefined_Unit
kono
parents:
diff changeset
339 -- True if this unit is predefined (i.e. part of the Ada, System, or
kono
parents:
diff changeset
340 -- Interface hierarchies, or Is_Predefined_Renaming). Note that units
kono
parents:
diff changeset
341 -- in the GNAT hierarchy are not considered predefined.
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 -- Loading
kono
parents:
diff changeset
344 -- A flag that is used to catch circular WITH dependencies. It is set
kono
parents:
diff changeset
345 -- True when an entry is initially created in the file table, and set
kono
parents:
diff changeset
346 -- False when the load is completed, or ends with an error.
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 -- Main_Priority
kono
parents:
diff changeset
349 -- This field is used to indicate the priority of a possible main
kono
parents:
diff changeset
350 -- program, as set by a pragma Priority. A value of -1 indicates
kono
parents:
diff changeset
351 -- that the default priority is to be used (and is also used for
kono
parents:
diff changeset
352 -- entries that do not correspond to possible main programs).
kono
parents:
diff changeset
353
kono
parents:
diff changeset
354 -- Main_CPU
kono
parents:
diff changeset
355 -- This field is used to indicate the affinity of a possible main
kono
parents:
diff changeset
356 -- program, as set by a pragma CPU. A value of -1 indicates
kono
parents:
diff changeset
357 -- that the default affinity is to be used (and is also used for
kono
parents:
diff changeset
358 -- entries that do not correspond to possible main programs).
kono
parents:
diff changeset
359
kono
parents:
diff changeset
360 -- Munit_Index
kono
parents:
diff changeset
361 -- The index of the unit within the file for multiple unit per file
kono
parents:
diff changeset
362 -- mode. Set to zero in normal single unit per file mode.
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 -- No_Elab_Code_All
kono
parents:
diff changeset
365 -- A flag set when a pragma or aspect No_Elaboration_Code_All applies
kono
parents:
diff changeset
366 -- to the unit. This is used to implement the transitive WITH rules
kono
parents:
diff changeset
367 -- (and for no other purpose).
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 -- OA_Setting
kono
parents:
diff changeset
370 -- This is a character field containing L if Optimize_Alignment mode
kono
parents:
diff changeset
371 -- was set locally, and O/T/S for Off/Time/Space default if not.
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 -- Primary_Stack_Count
kono
parents:
diff changeset
374 -- The number of primary stacks belonging to tasks defined within the
kono
parents:
diff changeset
375 -- unit that have no Storage_Size specified when the either restriction
kono
parents:
diff changeset
376 -- No_Implicit_Heap_Allocations or No_Implicit_Task_Allocations is
kono
parents:
diff changeset
377 -- active. Only used by the binder to generate stacks for these tasks
kono
parents:
diff changeset
378 -- at bind time.
kono
parents:
diff changeset
379
kono
parents:
diff changeset
380 -- Sec_Stack_Count
kono
parents:
diff changeset
381 -- The number of secondary stacks belonging to tasks defined within the
kono
parents:
diff changeset
382 -- unit that have no Secondary_Stack_Size specified when the either
kono
parents:
diff changeset
383 -- the No_Implicit_Heap_Allocations or No_Implicit_Task_Allocations
kono
parents:
diff changeset
384 -- restrictions are active. Only used by the binder to generate stacks
kono
parents:
diff changeset
385 -- for these tasks at bind time.
kono
parents:
diff changeset
386
kono
parents:
diff changeset
387 -- Serial_Number
kono
parents:
diff changeset
388 -- This field holds a serial number used by New_Internal_Name to
kono
parents:
diff changeset
389 -- generate unique temporary numbers on a unit by unit basis. The
kono
parents:
diff changeset
390 -- only access to this field is via the Increment_Serial_Number
kono
parents:
diff changeset
391 -- routine which increments the current value and returns it. This
kono
parents:
diff changeset
392 -- serial number is separate for each unit.
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 -- Source_Index
kono
parents:
diff changeset
395 -- The index in the source file table of the corresponding source file.
kono
parents:
diff changeset
396 -- Set when the entry is created by a call to Lib.Load and then cannot
kono
parents:
diff changeset
397 -- be changed.
kono
parents:
diff changeset
398
kono
parents:
diff changeset
399 -- Unit_File_Name
kono
parents:
diff changeset
400 -- The name of the source file containing the unit. Set when the entry
kono
parents:
diff changeset
401 -- is created by a call to Lib.Load, and then cannot be changed.
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 -- Unit_Name
kono
parents:
diff changeset
404 -- The name of the unit. Initialized to No_Name by Lib.Load, and then
kono
parents:
diff changeset
405 -- set by the parser when the unit is parsed to the unit name actually
kono
parents:
diff changeset
406 -- found in the file (which should, in the absence of errors) be the
kono
parents:
diff changeset
407 -- same name as Expected_Unit.
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 -- Version
kono
parents:
diff changeset
410 -- This field holds the version of the unit, which is computed as
kono
parents:
diff changeset
411 -- the exclusive or of the checksums of this unit, and all its
kono
parents:
diff changeset
412 -- semantically dependent units. Access to the version number field
kono
parents:
diff changeset
413 -- is not direct, but is done through the routines described below.
kono
parents:
diff changeset
414 -- When a unit table entry is created, this field is initialized to
kono
parents:
diff changeset
415 -- the checksum of the corresponding source file. Version_Update is
kono
parents:
diff changeset
416 -- then called to reflect the contributions of any unit on which this
kono
parents:
diff changeset
417 -- unit is semantically dependent.
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 -- The units table is reset to empty at the start of the compilation of
kono
parents:
diff changeset
420 -- each main unit by Lib.Initialize. Entries are then added by calls to
kono
parents:
diff changeset
421 -- the Lib.Load procedure. The following subprograms are used to access
kono
parents:
diff changeset
422 -- and modify entries in the Units table. Individual entries are accessed
kono
parents:
diff changeset
423 -- using a unit number value which ranges from Main_Unit (the first entry,
kono
parents:
diff changeset
424 -- which is always for the current main unit) to Last_Unit.
kono
parents:
diff changeset
425
kono
parents:
diff changeset
426 Default_Main_Priority : constant Int := -1;
kono
parents:
diff changeset
427 -- Value used in Main_Priority field to indicate default main priority
kono
parents:
diff changeset
428
kono
parents:
diff changeset
429 Default_Main_CPU : constant Int := -1;
kono
parents:
diff changeset
430 -- Value used in Main_CPU field to indicate default main affinity
kono
parents:
diff changeset
431
kono
parents:
diff changeset
432 -- The following defines settings for the Fatal_Error field
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 type Fatal_Type is (
kono
parents:
diff changeset
435 None,
kono
parents:
diff changeset
436 -- No error detected for this unit
kono
parents:
diff changeset
437
kono
parents:
diff changeset
438 Error_Detected,
kono
parents:
diff changeset
439 -- Fatal error detected that prevents moving to the next phase. For
kono
parents:
diff changeset
440 -- example, a fatal error during parsing inhibits semantic analysis.
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 Error_Ignored);
kono
parents:
diff changeset
443 -- A fatal error was detected, but we are in Try_Semantics mode (as set
kono
parents:
diff changeset
444 -- by -gnatq or -gnatQ). This does not stop the compiler from proceding,
kono
parents:
diff changeset
445 -- but tools can use this status (e.g. ASIS looking at the generated
kono
parents:
diff changeset
446 -- tree) to know that a fatal error was detected.
kono
parents:
diff changeset
447
kono
parents:
diff changeset
448 function Cunit (U : Unit_Number_Type) return Node_Id;
kono
parents:
diff changeset
449 function Cunit_Entity (U : Unit_Number_Type) return Entity_Id;
kono
parents:
diff changeset
450 function Dependency_Num (U : Unit_Number_Type) return Nat;
kono
parents:
diff changeset
451 function Dynamic_Elab (U : Unit_Number_Type) return Boolean;
kono
parents:
diff changeset
452 function Error_Location (U : Unit_Number_Type) return Source_Ptr;
kono
parents:
diff changeset
453 function Expected_Unit (U : Unit_Number_Type) return Unit_Name_Type;
kono
parents:
diff changeset
454 function Fatal_Error (U : Unit_Number_Type) return Fatal_Type;
kono
parents:
diff changeset
455 function Generate_Code (U : Unit_Number_Type) return Boolean;
kono
parents:
diff changeset
456 function Ident_String (U : Unit_Number_Type) return Node_Id;
kono
parents:
diff changeset
457 function Has_RACW (U : Unit_Number_Type) return Boolean;
kono
parents:
diff changeset
458 function Is_Predefined_Renaming
kono
parents:
diff changeset
459 (U : Unit_Number_Type) return Boolean;
kono
parents:
diff changeset
460 function Is_Internal_Unit (U : Unit_Number_Type) return Boolean;
kono
parents:
diff changeset
461 function Is_Predefined_Unit
kono
parents:
diff changeset
462 (U : Unit_Number_Type) return Boolean;
kono
parents:
diff changeset
463 function Loading (U : Unit_Number_Type) return Boolean;
kono
parents:
diff changeset
464 function Main_CPU (U : Unit_Number_Type) return Int;
kono
parents:
diff changeset
465 function Main_Priority (U : Unit_Number_Type) return Int;
kono
parents:
diff changeset
466 function Munit_Index (U : Unit_Number_Type) return Nat;
kono
parents:
diff changeset
467 function No_Elab_Code_All (U : Unit_Number_Type) return Boolean;
kono
parents:
diff changeset
468 function OA_Setting (U : Unit_Number_Type) return Character;
kono
parents:
diff changeset
469 function Primary_Stack_Count
kono
parents:
diff changeset
470 (U : Unit_Number_Type) return Int;
kono
parents:
diff changeset
471 function Sec_Stack_Count (U : Unit_Number_Type) return Int;
kono
parents:
diff changeset
472 function Source_Index (U : Unit_Number_Type) return Source_File_Index;
kono
parents:
diff changeset
473 function Unit_File_Name (U : Unit_Number_Type) return File_Name_Type;
kono
parents:
diff changeset
474 function Unit_Name (U : Unit_Number_Type) return Unit_Name_Type;
kono
parents:
diff changeset
475 -- Get value of named field from given units table entry
kono
parents:
diff changeset
476
kono
parents:
diff changeset
477 procedure Set_Cunit (U : Unit_Number_Type; N : Node_Id);
kono
parents:
diff changeset
478 procedure Set_Cunit_Entity (U : Unit_Number_Type; E : Entity_Id);
kono
parents:
diff changeset
479 procedure Set_Dynamic_Elab (U : Unit_Number_Type; B : Boolean := True);
kono
parents:
diff changeset
480 procedure Set_Error_Location (U : Unit_Number_Type; W : Source_Ptr);
kono
parents:
diff changeset
481 procedure Set_Fatal_Error (U : Unit_Number_Type; V : Fatal_Type);
kono
parents:
diff changeset
482 procedure Set_Generate_Code (U : Unit_Number_Type; B : Boolean := True);
kono
parents:
diff changeset
483 procedure Set_Has_RACW (U : Unit_Number_Type; B : Boolean := True);
kono
parents:
diff changeset
484 procedure Set_Ident_String (U : Unit_Number_Type; N : Node_Id);
kono
parents:
diff changeset
485 procedure Set_Loading (U : Unit_Number_Type; B : Boolean := True);
kono
parents:
diff changeset
486 procedure Set_Main_CPU (U : Unit_Number_Type; P : Int);
kono
parents:
diff changeset
487 procedure Set_No_Elab_Code_All (U : Unit_Number_Type; B : Boolean := True);
kono
parents:
diff changeset
488 procedure Set_Main_Priority (U : Unit_Number_Type; P : Int);
kono
parents:
diff changeset
489 procedure Set_OA_Setting (U : Unit_Number_Type; C : Character);
kono
parents:
diff changeset
490 procedure Set_Unit_Name (U : Unit_Number_Type; N : Unit_Name_Type);
kono
parents:
diff changeset
491 -- Set value of named field for given units table entry. Note that we
kono
parents:
diff changeset
492 -- do not have an entry for each possible field, since some of the fields
kono
parents:
diff changeset
493 -- can only be set by specialized interfaces (defined below).
kono
parents:
diff changeset
494
kono
parents:
diff changeset
495 function Compilation_Switches_Last return Nat;
kono
parents:
diff changeset
496 -- Return the count of stored compilation switches
kono
parents:
diff changeset
497
kono
parents:
diff changeset
498 procedure Disable_Switch_Storing;
kono
parents:
diff changeset
499 -- Disable registration of switches by Store_Compilation_Switch. Used to
kono
parents:
diff changeset
500 -- avoid registering switches added automatically by the gcc driver at the
kono
parents:
diff changeset
501 -- end of the command line.
kono
parents:
diff changeset
502
kono
parents:
diff changeset
503 function Earlier_In_Extended_Unit
kono
parents:
diff changeset
504 (S1 : Source_Ptr;
kono
parents:
diff changeset
505 S2 : Source_Ptr) return Boolean;
kono
parents:
diff changeset
506 -- Given two Sloc values for which In_Same_Extended_Unit is true, determine
kono
parents:
diff changeset
507 -- if S1 appears before S2. Returns True if S1 appears before S2, and False
kono
parents:
diff changeset
508 -- otherwise. The result is undefined if S1 and S2 are not in the same
kono
parents:
diff changeset
509 -- extended unit. Note: this routine will not give reliable results if
kono
parents:
diff changeset
510 -- called after Sprint has been called with -gnatD set.
kono
parents:
diff changeset
511
kono
parents:
diff changeset
512 function Earlier_In_Extended_Unit
kono
parents:
diff changeset
513 (N1 : Node_Or_Entity_Id;
kono
parents:
diff changeset
514 N2 : Node_Or_Entity_Id) return Boolean;
kono
parents:
diff changeset
515 -- Same as above, but the inputs denote nodes or entities
kono
parents:
diff changeset
516
kono
parents:
diff changeset
517 procedure Enable_Switch_Storing;
kono
parents:
diff changeset
518 -- Enable registration of switches by Store_Compilation_Switch. Used to
kono
parents:
diff changeset
519 -- avoid registering switches added automatically by the gcc driver at the
kono
parents:
diff changeset
520 -- beginning of the command line.
kono
parents:
diff changeset
521
kono
parents:
diff changeset
522 function Entity_Is_In_Main_Unit (E : Entity_Id) return Boolean;
kono
parents:
diff changeset
523 -- Returns True if the entity E is declared in the main unit, or, in
kono
parents:
diff changeset
524 -- its corresponding spec, or one of its subunits. Entities declared
kono
parents:
diff changeset
525 -- within generic instantiations return True if the instantiation is
kono
parents:
diff changeset
526 -- itself "in the main unit" by this definition. Otherwise False.
kono
parents:
diff changeset
527
kono
parents:
diff changeset
528 function Exact_Source_Name (Loc : Source_Ptr) return String;
kono
parents:
diff changeset
529 -- Return name of entity at location Loc exactly as written in the source.
kono
parents:
diff changeset
530 -- This includes copying the wide character encodings exactly as they were
kono
parents:
diff changeset
531 -- used in the source, so the caller must be aware of the possibility of
kono
parents:
diff changeset
532 -- such encodings.
kono
parents:
diff changeset
533
kono
parents:
diff changeset
534 function Get_Compilation_Switch (N : Pos) return String_Ptr;
kono
parents:
diff changeset
535 -- Return the Nth stored compilation switch, or null if less than N
kono
parents:
diff changeset
536 -- switches have been stored. Used by ASIS and back ends written in Ada.
kono
parents:
diff changeset
537
kono
parents:
diff changeset
538 function Generic_May_Lack_ALI (Unum : Unit_Number_Type) return Boolean;
kono
parents:
diff changeset
539 -- Generic units must be separately compiled. Since we always use
kono
parents:
diff changeset
540 -- macro substitution for generics, the resulting object file is a dummy
kono
parents:
diff changeset
541 -- one with no code, but the ALI file has the normal form, and we need
kono
parents:
diff changeset
542 -- this ALI file so that the binder can work out a correct order of
kono
parents:
diff changeset
543 -- elaboration.
kono
parents:
diff changeset
544 --
kono
parents:
diff changeset
545 -- However, ancient versions of GNAT used to not generate code or ALI
kono
parents:
diff changeset
546 -- files for generic units, and this would yield complex order of
kono
parents:
diff changeset
547 -- elaboration issues. These were fixed in GNAT 3.10. The support for not
kono
parents:
diff changeset
548 -- compiling language-defined library generics was retained nonetheless
kono
parents:
diff changeset
549 -- to facilitate bootstrap. Specifically, it is convenient to have
kono
parents:
diff changeset
550 -- the same list of files to be compiled for all stages. So, if the
kono
parents:
diff changeset
551 -- bootstrap compiler does not generate code for a given file, then
kono
parents:
diff changeset
552 -- the stage1 compiler (and binder) also must deal with the case of
kono
parents:
diff changeset
553 -- that file not being compiled. The predicate Generic_May_Lack_ALI is
kono
parents:
diff changeset
554 -- True for those generic units for which missing ALI files are allowed.
kono
parents:
diff changeset
555
kono
parents:
diff changeset
556 function Get_Cunit_Unit_Number (N : Node_Id) return Unit_Number_Type;
kono
parents:
diff changeset
557 -- Return unit number of the unit whose N_Compilation_Unit node is the
kono
parents:
diff changeset
558 -- one passed as an argument. This must always succeed since the node
kono
parents:
diff changeset
559 -- could not have been built without making a unit table entry.
kono
parents:
diff changeset
560
kono
parents:
diff changeset
561 function Get_Cunit_Entity_Unit_Number
kono
parents:
diff changeset
562 (E : Entity_Id) return Unit_Number_Type;
kono
parents:
diff changeset
563 -- Return unit number of the unit whose compilation unit spec entity is
kono
parents:
diff changeset
564 -- the one passed as an argument. This must always succeed since the
kono
parents:
diff changeset
565 -- entity could not have been built without making a unit table entry.
kono
parents:
diff changeset
566
kono
parents:
diff changeset
567 function Get_Source_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type;
kono
parents:
diff changeset
568 pragma Inline (Get_Source_Unit);
kono
parents:
diff changeset
569 function Get_Source_Unit (S : Source_Ptr) return Unit_Number_Type;
kono
parents:
diff changeset
570 -- Return unit number of file identified by given source pointer value.
kono
parents:
diff changeset
571 -- This call must always succeed, since any valid source pointer value
kono
parents:
diff changeset
572 -- belongs to some previously loaded module. If the given source pointer
kono
parents:
diff changeset
573 -- value is within an instantiation, this function returns the unit number
kono
parents:
diff changeset
574 -- of the template, i.e. the unit containing the source code corresponding
kono
parents:
diff changeset
575 -- to the given Source_Ptr value. The version taking a Node_Id argument, N,
kono
parents:
diff changeset
576 -- simply applies the function to Sloc (N).
kono
parents:
diff changeset
577
kono
parents:
diff changeset
578 function Get_Code_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type;
kono
parents:
diff changeset
579 pragma Inline (Get_Code_Unit);
kono
parents:
diff changeset
580 function Get_Code_Unit (S : Source_Ptr) return Unit_Number_Type;
kono
parents:
diff changeset
581 -- This is like Get_Source_Unit, except that in the instantiation case,
kono
parents:
diff changeset
582 -- it uses the location of the top level instantiation, rather than the
kono
parents:
diff changeset
583 -- template, so it returns the unit number containing the code that
kono
parents:
diff changeset
584 -- corresponds to the node N, or the source location S.
kono
parents:
diff changeset
585
kono
parents:
diff changeset
586 function Get_Top_Level_Code_Unit
kono
parents:
diff changeset
587 (N : Node_Or_Entity_Id) return Unit_Number_Type;
kono
parents:
diff changeset
588 pragma Inline (Get_Code_Unit);
kono
parents:
diff changeset
589 function Get_Top_Level_Code_Unit (S : Source_Ptr) return Unit_Number_Type;
kono
parents:
diff changeset
590 -- This is like Get_Code_Unit, except that in the case of subunits, it
kono
parents:
diff changeset
591 -- returns the top-level unit to which the subunit belongs instead of
kono
parents:
diff changeset
592 -- the subunit.
kono
parents:
diff changeset
593 --
kono
parents:
diff changeset
594 -- Note: for nodes and slocs in declarations of library-level instances of
kono
parents:
diff changeset
595 -- generics these routines wrongly return the unit number corresponding to
kono
parents:
diff changeset
596 -- the body of the instance. In effect, locations of SPARK references in
kono
parents:
diff changeset
597 -- ALI files are bogus. However, fixing this is not worth the effort, since
kono
parents:
diff changeset
598 -- these references are only used for debugging.
kono
parents:
diff changeset
599
kono
parents:
diff changeset
600 function In_Extended_Main_Code_Unit
kono
parents:
diff changeset
601 (N : Node_Or_Entity_Id) return Boolean;
kono
parents:
diff changeset
602 -- Return True if the node is in the generated code of the extended main
kono
parents:
diff changeset
603 -- unit, defined as the main unit, its specification (if any), and all
kono
parents:
diff changeset
604 -- its subunits (considered recursively). Units for which this enquiry
kono
parents:
diff changeset
605 -- returns True are those for which code will be generated. Nodes from
kono
parents:
diff changeset
606 -- instantiations are included in the extended main unit for this call.
kono
parents:
diff changeset
607 -- If the main unit is itself a subunit, then the extended main code unit
kono
parents:
diff changeset
608 -- includes its parent unit, and the parent unit spec if it is separate.
kono
parents:
diff changeset
609 --
kono
parents:
diff changeset
610 -- This routine (and the following three routines) all return False if
kono
parents:
diff changeset
611 -- Sloc (N) is No_Location or Standard_Location. In an earlier version,
kono
parents:
diff changeset
612 -- they returned True for Standard_Location, but this was odd, and some
kono
parents:
diff changeset
613 -- archeology indicated that this was done for the sole benefit of the
kono
parents:
diff changeset
614 -- call in Restrict.Check_Restriction_No_Dependence, so we have moved
kono
parents:
diff changeset
615 -- the special case check to that routine. This avoids some difficulties
kono
parents:
diff changeset
616 -- with some other calls that malfunctioned with the odd return of True.
kono
parents:
diff changeset
617
kono
parents:
diff changeset
618 function In_Extended_Main_Code_Unit (Loc : Source_Ptr) return Boolean;
kono
parents:
diff changeset
619 -- Same function as above, but argument is a source pointer rather
kono
parents:
diff changeset
620 -- than a node.
kono
parents:
diff changeset
621
kono
parents:
diff changeset
622 function In_Extended_Main_Source_Unit
kono
parents:
diff changeset
623 (N : Node_Or_Entity_Id) return Boolean;
kono
parents:
diff changeset
624 -- Return True if the node is in the source text of the extended main
kono
parents:
diff changeset
625 -- unit, defined as the main unit, its specification (if any), and all
kono
parents:
diff changeset
626 -- its subunits (considered recursively). Units for which this enquiry
kono
parents:
diff changeset
627 -- returns True are those for which code will be generated. This differs
kono
parents:
diff changeset
628 -- from In_Extended_Main_Code_Unit only in that instantiations are not
kono
parents:
diff changeset
629 -- included for the purposes of this call. If the main unit is itself
kono
parents:
diff changeset
630 -- a subunit, then the extended main source unit includes its parent unit,
kono
parents:
diff changeset
631 -- and the parent unit spec if it is separate.
kono
parents:
diff changeset
632
kono
parents:
diff changeset
633 function In_Extended_Main_Source_Unit (Loc : Source_Ptr) return Boolean;
kono
parents:
diff changeset
634 -- Same function as above, but argument is a source pointer
kono
parents:
diff changeset
635
kono
parents:
diff changeset
636 function In_Predefined_Unit (N : Node_Or_Entity_Id) return Boolean;
kono
parents:
diff changeset
637 -- Returns True if the given node or entity appears within the source text
kono
parents:
diff changeset
638 -- of a predefined unit (i.e. within Ada, Interfaces, System or within one
kono
parents:
diff changeset
639 -- of the descendant packages of one of these three packages).
kono
parents:
diff changeset
640
kono
parents:
diff changeset
641 function In_Predefined_Unit (S : Source_Ptr) return Boolean;
kono
parents:
diff changeset
642 pragma Inline (In_Predefined_Unit);
kono
parents:
diff changeset
643 -- Same function as above but argument is a source pointer
kono
parents:
diff changeset
644
kono
parents:
diff changeset
645 function In_Internal_Unit (N : Node_Or_Entity_Id) return Boolean;
kono
parents:
diff changeset
646 function In_Internal_Unit (S : Source_Ptr) return Boolean;
kono
parents:
diff changeset
647 pragma Inline (In_Internal_Unit);
kono
parents:
diff changeset
648 -- Same as In_Predefined_Unit, except units in the GNAT hierarchy are
kono
parents:
diff changeset
649 -- included.
kono
parents:
diff changeset
650
kono
parents:
diff changeset
651 function In_Predefined_Renaming (N : Node_Or_Entity_Id) return Boolean;
kono
parents:
diff changeset
652 function In_Predefined_Renaming (S : Source_Ptr) return Boolean;
kono
parents:
diff changeset
653 pragma Inline (In_Predefined_Renaming);
kono
parents:
diff changeset
654 -- Returns True if N or S is in a predefined renaming unit
kono
parents:
diff changeset
655
kono
parents:
diff changeset
656 function In_Same_Code_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean;
kono
parents:
diff changeset
657 pragma Inline (In_Same_Code_Unit);
kono
parents:
diff changeset
658 -- Determines if the two nodes or entities N1 and N2 are in the same
kono
parents:
diff changeset
659 -- code unit, the criterion being that Get_Code_Unit yields the same
kono
parents:
diff changeset
660 -- value for each argument.
kono
parents:
diff changeset
661
kono
parents:
diff changeset
662 function In_Same_Extended_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean;
kono
parents:
diff changeset
663 pragma Inline (In_Same_Extended_Unit);
kono
parents:
diff changeset
664 -- Determines if two nodes or entities N1 and N2 are in the same
kono
parents:
diff changeset
665 -- extended unit, where an extended unit is defined as a unit and all
kono
parents:
diff changeset
666 -- its subunits (considered recursively, i.e. subunits of subunits are
kono
parents:
diff changeset
667 -- included). Returns true if S1 and S2 are in the same extended unit
kono
parents:
diff changeset
668 -- and False otherwise.
kono
parents:
diff changeset
669
kono
parents:
diff changeset
670 function In_Same_Extended_Unit (S1, S2 : Source_Ptr) return Boolean;
kono
parents:
diff changeset
671 pragma Inline (In_Same_Extended_Unit);
kono
parents:
diff changeset
672 -- Determines if the two source locations S1 and S2 are in the same
kono
parents:
diff changeset
673 -- extended unit, where an extended unit is defined as a unit and all
kono
parents:
diff changeset
674 -- its subunits (considered recursively, i.e. subunits of subunits are
kono
parents:
diff changeset
675 -- included). Returns true if S1 and S2 are in the same extended unit
kono
parents:
diff changeset
676 -- and False otherwise.
kono
parents:
diff changeset
677
kono
parents:
diff changeset
678 function In_Same_Source_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean;
kono
parents:
diff changeset
679 pragma Inline (In_Same_Source_Unit);
kono
parents:
diff changeset
680 -- Determines if the two nodes or entities N1 and N2 are in the same
kono
parents:
diff changeset
681 -- source unit, the criterion being that Get_Source_Unit yields the
kono
parents:
diff changeset
682 -- same value for each argument.
kono
parents:
diff changeset
683
kono
parents:
diff changeset
684 procedure Increment_Primary_Stack_Count (Increment : Int);
kono
parents:
diff changeset
685 -- Increment the Primary_Stack_Count field for the current unit by
kono
parents:
diff changeset
686 -- Increment.
kono
parents:
diff changeset
687
kono
parents:
diff changeset
688 procedure Increment_Sec_Stack_Count (Increment : Int);
kono
parents:
diff changeset
689 -- Increment the Sec_Stack_Count field for the current unit by Increment
kono
parents:
diff changeset
690
kono
parents:
diff changeset
691 function Increment_Serial_Number return Nat;
kono
parents:
diff changeset
692 -- Increment Serial_Number field for current unit, and return the
kono
parents:
diff changeset
693 -- incremented value.
kono
parents:
diff changeset
694
kono
parents:
diff changeset
695 procedure Initialize;
kono
parents:
diff changeset
696 -- Initialize internal tables
kono
parents:
diff changeset
697
kono
parents:
diff changeset
698 function Is_Loaded (Uname : Unit_Name_Type) return Boolean;
kono
parents:
diff changeset
699 -- Determines if unit with given name is already loaded, i.e. there is
kono
parents:
diff changeset
700 -- already an entry in the file table with this unit name for which the
kono
parents:
diff changeset
701 -- corresponding file was found and parsed. Note that the Fatal_Error value
kono
parents:
diff changeset
702 -- of this entry must be checked before proceeding with further processing.
kono
parents:
diff changeset
703
kono
parents:
diff changeset
704 function Last_Unit return Unit_Number_Type;
kono
parents:
diff changeset
705 -- Unit number of last allocated unit
kono
parents:
diff changeset
706
kono
parents:
diff changeset
707 procedure List (File_Names_Only : Boolean := False);
kono
parents:
diff changeset
708 -- Lists units in active library (i.e. generates output consisting of a
kono
parents:
diff changeset
709 -- sorted listing of the units represented in File table, except for the
kono
parents:
diff changeset
710 -- main unit). If File_Names_Only is set to True, then the list includes
kono
parents:
diff changeset
711 -- only file names, and no other information. Otherwise the unit name and
kono
parents:
diff changeset
712 -- time stamp are also output. File_Names_Only also restricts the list to
kono
parents:
diff changeset
713 -- exclude any predefined files.
kono
parents:
diff changeset
714
kono
parents:
diff changeset
715 procedure Lock;
kono
parents:
diff changeset
716 -- Lock internal tables before calling back end
kono
parents:
diff changeset
717
kono
parents:
diff changeset
718 function Num_Units return Nat;
kono
parents:
diff changeset
719 -- Number of units currently in unit table
kono
parents:
diff changeset
720
kono
parents:
diff changeset
721 procedure Remove_Unit (U : Unit_Number_Type);
kono
parents:
diff changeset
722 -- Remove unit U from unit table. Currently this is effective only if U is
kono
parents:
diff changeset
723 -- the last unit currently stored in the unit table.
kono
parents:
diff changeset
724
kono
parents:
diff changeset
725 procedure Replace_Linker_Option_String
kono
parents:
diff changeset
726 (S : String_Id;
kono
parents:
diff changeset
727 Match_String : String);
kono
parents:
diff changeset
728 -- Replace an existing Linker_Option if the prefix Match_String matches,
kono
parents:
diff changeset
729 -- otherwise call Store_Linker_Option_String.
kono
parents:
diff changeset
730
kono
parents:
diff changeset
731 procedure Store_Compilation_Switch (Switch : String);
kono
parents:
diff changeset
732 -- Called to register a compilation switch, either front-end or back-end,
kono
parents:
diff changeset
733 -- which may influence the generated output file(s). Switch is the text of
kono
parents:
diff changeset
734 -- the switch to store (except that -fRTS gets changed back to --RTS).
kono
parents:
diff changeset
735
kono
parents:
diff changeset
736 procedure Store_Linker_Option_String (S : String_Id);
kono
parents:
diff changeset
737 -- This procedure is called to register the string from a pragma
kono
parents:
diff changeset
738 -- Linker_Option. The argument is the Id of the string to register.
kono
parents:
diff changeset
739
kono
parents:
diff changeset
740 procedure Store_Note (N : Node_Id);
kono
parents:
diff changeset
741 -- This procedure is called to register a pragma N for which a notes
kono
parents:
diff changeset
742 -- entry is required.
kono
parents:
diff changeset
743
kono
parents:
diff changeset
744 procedure Synchronize_Serial_Number;
kono
parents:
diff changeset
745 -- This function increments the Serial_Number field for the current unit
kono
parents:
diff changeset
746 -- but does not return the incremented value. This is used when there
kono
parents:
diff changeset
747 -- is a situation where one path of control increments a serial number
kono
parents:
diff changeset
748 -- (using Increment_Serial_Number), and the other path does not and it is
kono
parents:
diff changeset
749 -- important to keep the serial numbers synchronized in the two cases (e.g.
kono
parents:
diff changeset
750 -- when the references in a package and a client must be kept consistent).
kono
parents:
diff changeset
751
kono
parents:
diff changeset
752 procedure Tree_Read;
kono
parents:
diff changeset
753 -- Initializes internal tables from current tree file using the relevant
kono
parents:
diff changeset
754 -- Table.Tree_Read routines.
kono
parents:
diff changeset
755
kono
parents:
diff changeset
756 procedure Tree_Write;
kono
parents:
diff changeset
757 -- Writes out internal tables to current tree file using the relevant
kono
parents:
diff changeset
758 -- Table.Tree_Write routines.
kono
parents:
diff changeset
759
kono
parents:
diff changeset
760 procedure Unlock;
kono
parents:
diff changeset
761 -- Unlock internal tables, in cases where the back end needs to modify them
kono
parents:
diff changeset
762
kono
parents:
diff changeset
763 function Version_Get (U : Unit_Number_Type) return Word_Hex_String;
kono
parents:
diff changeset
764 -- Returns the version as a string with 8 hex digits (upper case letters)
kono
parents:
diff changeset
765
kono
parents:
diff changeset
766 procedure Version_Referenced (S : String_Id);
kono
parents:
diff changeset
767 -- This routine is called from Exp_Attr to register the use of a Version
kono
parents:
diff changeset
768 -- or Body_Version attribute. The argument is the external name used to
kono
parents:
diff changeset
769 -- access the version string.
kono
parents:
diff changeset
770
kono
parents:
diff changeset
771 procedure Write_Unit_Info
kono
parents:
diff changeset
772 (Unit_Num : Unit_Number_Type;
kono
parents:
diff changeset
773 Item : Node_Id;
kono
parents:
diff changeset
774 Prefix : String := "";
kono
parents:
diff changeset
775 Withs : Boolean := False);
kono
parents:
diff changeset
776 -- Print out debugging information about the unit. Prefix precedes the rest
kono
parents:
diff changeset
777 -- of the printout. If Withs is True, we print out units with'ed by this
kono
parents:
diff changeset
778 -- unit (not counting limited withs).
kono
parents:
diff changeset
779
kono
parents:
diff changeset
780 ---------------------------------------------------------------
kono
parents:
diff changeset
781 -- Special Handling for Restriction_Set (No_Dependence) Case --
kono
parents:
diff changeset
782 ---------------------------------------------------------------
kono
parents:
diff changeset
783
kono
parents:
diff changeset
784 -- If we have a Restriction_Set attribute for No_Dependence => unit,
kono
parents:
diff changeset
785 -- and the unit is not given in a No_Dependence restriction that we
kono
parents:
diff changeset
786 -- can see, the attribute will return False.
kono
parents:
diff changeset
787
kono
parents:
diff changeset
788 -- We have to ensure in this case that the binder will reject any attempt
kono
parents:
diff changeset
789 -- to set a No_Dependence restriction in some other unit in the partition.
kono
parents:
diff changeset
790
kono
parents:
diff changeset
791 -- If the unit is in the semantic closure, then of course it is properly
kono
parents:
diff changeset
792 -- WITH'ed by someone, and the binder will do this job automatically as
kono
parents:
diff changeset
793 -- part of its normal processing.
kono
parents:
diff changeset
794
kono
parents:
diff changeset
795 -- But if the unit is not in the semantic closure, we must make sure the
kono
parents:
diff changeset
796 -- binder knows about it. The use of the Restriction_Set attribute giving
kono
parents:
diff changeset
797 -- a result of False does not mean of itself that we have to include the
kono
parents:
diff changeset
798 -- unit in the partition. So what we do is to generate a with (W) line in
kono
parents:
diff changeset
799 -- the ali file (with no file name information), but no corresponding D
kono
parents:
diff changeset
800 -- (dependency) line. This is recognized by the binder as meaning "Don't
kono
parents:
diff changeset
801 -- let anyone specify No_Dependence for this unit, but you don't have to
kono
parents:
diff changeset
802 -- include it if there is no real W line for the unit".
kono
parents:
diff changeset
803
kono
parents:
diff changeset
804 -- The following table keeps track of relevant units. It is used in the
kono
parents:
diff changeset
805 -- Lib.Writ circuit for outputting With lines to output the special with
kono
parents:
diff changeset
806 -- line with RA if the unit is not in the semantic closure.
kono
parents:
diff changeset
807
kono
parents:
diff changeset
808 package Restriction_Set_Dependences is new Table.Table (
kono
parents:
diff changeset
809 Table_Component_Type => Unit_Name_Type,
kono
parents:
diff changeset
810 Table_Index_Type => Int,
kono
parents:
diff changeset
811 Table_Low_Bound => 0,
kono
parents:
diff changeset
812 Table_Initial => 10,
kono
parents:
diff changeset
813 Table_Increment => 100,
kono
parents:
diff changeset
814 Table_Name => "Restriction_Attribute_Dependences");
kono
parents:
diff changeset
815
kono
parents:
diff changeset
816 private
kono
parents:
diff changeset
817 pragma Inline (Cunit);
kono
parents:
diff changeset
818 pragma Inline (Cunit_Entity);
kono
parents:
diff changeset
819 pragma Inline (Dependency_Num);
kono
parents:
diff changeset
820 pragma Inline (Fatal_Error);
kono
parents:
diff changeset
821 pragma Inline (Generate_Code);
kono
parents:
diff changeset
822 pragma Inline (Has_RACW);
kono
parents:
diff changeset
823 pragma Inline (Increment_Primary_Stack_Count);
kono
parents:
diff changeset
824 pragma Inline (Increment_Sec_Stack_Count);
kono
parents:
diff changeset
825 pragma Inline (Increment_Serial_Number);
kono
parents:
diff changeset
826 pragma Inline (Loading);
kono
parents:
diff changeset
827 pragma Inline (Main_CPU);
kono
parents:
diff changeset
828 pragma Inline (Main_Priority);
kono
parents:
diff changeset
829 pragma Inline (Munit_Index);
kono
parents:
diff changeset
830 pragma Inline (No_Elab_Code_All);
kono
parents:
diff changeset
831 pragma Inline (OA_Setting);
kono
parents:
diff changeset
832 pragma Inline (Set_Cunit);
kono
parents:
diff changeset
833 pragma Inline (Set_Cunit_Entity);
kono
parents:
diff changeset
834 pragma Inline (Set_Fatal_Error);
kono
parents:
diff changeset
835 pragma Inline (Set_Generate_Code);
kono
parents:
diff changeset
836 pragma Inline (Set_Has_RACW);
kono
parents:
diff changeset
837 pragma Inline (Is_Predefined_Renaming);
kono
parents:
diff changeset
838 pragma Inline (Is_Internal_Unit);
kono
parents:
diff changeset
839 pragma Inline (Is_Predefined_Unit);
kono
parents:
diff changeset
840 pragma Inline (Primary_Stack_Count);
kono
parents:
diff changeset
841 pragma Inline (Sec_Stack_Count);
kono
parents:
diff changeset
842 pragma Inline (Set_Loading);
kono
parents:
diff changeset
843 pragma Inline (Set_Main_CPU);
kono
parents:
diff changeset
844 pragma Inline (Set_Main_Priority);
kono
parents:
diff changeset
845 pragma Inline (Set_No_Elab_Code_All);
kono
parents:
diff changeset
846 pragma Inline (Set_OA_Setting);
kono
parents:
diff changeset
847 pragma Inline (Set_Unit_Name);
kono
parents:
diff changeset
848 pragma Inline (Source_Index);
kono
parents:
diff changeset
849 pragma Inline (Unit_File_Name);
kono
parents:
diff changeset
850 pragma Inline (Unit_Name);
kono
parents:
diff changeset
851
kono
parents:
diff changeset
852 -- The Units Table
kono
parents:
diff changeset
853
kono
parents:
diff changeset
854 type Unit_Record is record
kono
parents:
diff changeset
855 Unit_File_Name : File_Name_Type;
kono
parents:
diff changeset
856 Unit_Name : Unit_Name_Type;
kono
parents:
diff changeset
857 Munit_Index : Nat;
kono
parents:
diff changeset
858 Expected_Unit : Unit_Name_Type;
kono
parents:
diff changeset
859 Source_Index : Source_File_Index;
kono
parents:
diff changeset
860 Cunit : Node_Id;
kono
parents:
diff changeset
861 Cunit_Entity : Entity_Id;
kono
parents:
diff changeset
862 Dependency_Num : Int;
kono
parents:
diff changeset
863 Ident_String : Node_Id;
kono
parents:
diff changeset
864 Main_Priority : Int;
kono
parents:
diff changeset
865 Main_CPU : Int;
kono
parents:
diff changeset
866 Primary_Stack_Count : Int;
kono
parents:
diff changeset
867 Sec_Stack_Count : Int;
kono
parents:
diff changeset
868 Serial_Number : Nat;
kono
parents:
diff changeset
869 Version : Word;
kono
parents:
diff changeset
870 Error_Location : Source_Ptr;
kono
parents:
diff changeset
871 Fatal_Error : Fatal_Type;
kono
parents:
diff changeset
872 Generate_Code : Boolean;
kono
parents:
diff changeset
873 Has_RACW : Boolean;
kono
parents:
diff changeset
874 Dynamic_Elab : Boolean;
kono
parents:
diff changeset
875 No_Elab_Code_All : Boolean;
kono
parents:
diff changeset
876 Filler : Boolean;
kono
parents:
diff changeset
877 Loading : Boolean;
kono
parents:
diff changeset
878 OA_Setting : Character;
kono
parents:
diff changeset
879
kono
parents:
diff changeset
880 Is_Predefined_Renaming : Boolean;
kono
parents:
diff changeset
881 Is_Internal_Unit : Boolean;
kono
parents:
diff changeset
882 Is_Predefined_Unit : Boolean;
kono
parents:
diff changeset
883 Filler2 : Boolean;
kono
parents:
diff changeset
884 end record;
kono
parents:
diff changeset
885
kono
parents:
diff changeset
886 -- The following representation clause ensures that the above record
kono
parents:
diff changeset
887 -- has no holes. We do this so that when instances of this record are
kono
parents:
diff changeset
888 -- written by Tree_Gen, we do not write uninitialized values to the file.
kono
parents:
diff changeset
889
kono
parents:
diff changeset
890 for Unit_Record use record
kono
parents:
diff changeset
891 Unit_File_Name at 0 range 0 .. 31;
kono
parents:
diff changeset
892 Unit_Name at 4 range 0 .. 31;
kono
parents:
diff changeset
893 Munit_Index at 8 range 0 .. 31;
kono
parents:
diff changeset
894 Expected_Unit at 12 range 0 .. 31;
kono
parents:
diff changeset
895 Source_Index at 16 range 0 .. 31;
kono
parents:
diff changeset
896 Cunit at 20 range 0 .. 31;
kono
parents:
diff changeset
897 Cunit_Entity at 24 range 0 .. 31;
kono
parents:
diff changeset
898 Dependency_Num at 28 range 0 .. 31;
kono
parents:
diff changeset
899 Ident_String at 32 range 0 .. 31;
kono
parents:
diff changeset
900 Main_Priority at 36 range 0 .. 31;
kono
parents:
diff changeset
901 Main_CPU at 40 range 0 .. 31;
kono
parents:
diff changeset
902 Primary_Stack_Count at 44 range 0 .. 31;
kono
parents:
diff changeset
903 Sec_Stack_Count at 48 range 0 .. 31;
kono
parents:
diff changeset
904 Serial_Number at 52 range 0 .. 31;
kono
parents:
diff changeset
905 Version at 56 range 0 .. 31;
kono
parents:
diff changeset
906 Error_Location at 60 range 0 .. 31;
kono
parents:
diff changeset
907 Fatal_Error at 64 range 0 .. 7;
kono
parents:
diff changeset
908 Generate_Code at 65 range 0 .. 7;
kono
parents:
diff changeset
909 Has_RACW at 66 range 0 .. 7;
kono
parents:
diff changeset
910 Dynamic_Elab at 67 range 0 .. 7;
kono
parents:
diff changeset
911 No_Elab_Code_All at 68 range 0 .. 7;
kono
parents:
diff changeset
912 Filler at 69 range 0 .. 7;
kono
parents:
diff changeset
913 OA_Setting at 70 range 0 .. 7;
kono
parents:
diff changeset
914 Loading at 71 range 0 .. 7;
kono
parents:
diff changeset
915
kono
parents:
diff changeset
916 Is_Predefined_Renaming at 72 range 0 .. 7;
kono
parents:
diff changeset
917 Is_Internal_Unit at 73 range 0 .. 7;
kono
parents:
diff changeset
918 Is_Predefined_Unit at 74 range 0 .. 7;
kono
parents:
diff changeset
919 Filler2 at 75 range 0 .. 7;
kono
parents:
diff changeset
920 end record;
kono
parents:
diff changeset
921
kono
parents:
diff changeset
922 for Unit_Record'Size use 76 * 8;
kono
parents:
diff changeset
923 -- This ensures that we did not leave out any fields
kono
parents:
diff changeset
924
kono
parents:
diff changeset
925 package Units is new Table.Table (
kono
parents:
diff changeset
926 Table_Component_Type => Unit_Record,
kono
parents:
diff changeset
927 Table_Index_Type => Unit_Number_Type,
kono
parents:
diff changeset
928 Table_Low_Bound => Main_Unit,
kono
parents:
diff changeset
929 Table_Initial => Alloc.Units_Initial,
kono
parents:
diff changeset
930 Table_Increment => Alloc.Units_Increment,
kono
parents:
diff changeset
931 Table_Name => "Units");
kono
parents:
diff changeset
932
kono
parents:
diff changeset
933 -- The following table stores strings from pragma Linker_Option lines
kono
parents:
diff changeset
934
kono
parents:
diff changeset
935 type Linker_Option_Entry is record
kono
parents:
diff changeset
936 Option : String_Id;
kono
parents:
diff changeset
937 -- The string for the linker option line
kono
parents:
diff changeset
938
kono
parents:
diff changeset
939 Unit : Unit_Number_Type;
kono
parents:
diff changeset
940 -- The unit from which the linker option comes
kono
parents:
diff changeset
941 end record;
kono
parents:
diff changeset
942
kono
parents:
diff changeset
943 package Linker_Option_Lines is new Table.Table (
kono
parents:
diff changeset
944 Table_Component_Type => Linker_Option_Entry,
kono
parents:
diff changeset
945 Table_Index_Type => Integer,
kono
parents:
diff changeset
946 Table_Low_Bound => 1,
kono
parents:
diff changeset
947 Table_Initial => Alloc.Linker_Option_Lines_Initial,
kono
parents:
diff changeset
948 Table_Increment => Alloc.Linker_Option_Lines_Increment,
kono
parents:
diff changeset
949 Table_Name => "Linker_Option_Lines");
kono
parents:
diff changeset
950
kono
parents:
diff changeset
951 -- The following table stores references to pragmas that generate Notes
kono
parents:
diff changeset
952
kono
parents:
diff changeset
953 package Notes is new Table.Table (
kono
parents:
diff changeset
954 Table_Component_Type => Node_Id,
kono
parents:
diff changeset
955 Table_Index_Type => Integer,
kono
parents:
diff changeset
956 Table_Low_Bound => 1,
kono
parents:
diff changeset
957 Table_Initial => Alloc.Notes_Initial,
kono
parents:
diff changeset
958 Table_Increment => Alloc.Notes_Increment,
kono
parents:
diff changeset
959 Table_Name => "Notes");
kono
parents:
diff changeset
960
kono
parents:
diff changeset
961 -- The following table records the compilation switches used to compile
kono
parents:
diff changeset
962 -- the main unit. The table includes only switches. It excludes -o
kono
parents:
diff changeset
963 -- switches as well as artifacts of the gcc/gnat1 interface such as
kono
parents:
diff changeset
964 -- -quiet, -dumpbase, or -auxbase.
kono
parents:
diff changeset
965
kono
parents:
diff changeset
966 -- This table is set as part of the compiler argument scanning in
kono
parents:
diff changeset
967 -- Back_End. It can also be reset in -gnatc mode from the data in an
kono
parents:
diff changeset
968 -- existing ali file, and is read and written by the Tree_Read and
kono
parents:
diff changeset
969 -- Tree_Write routines for ASIS.
kono
parents:
diff changeset
970
kono
parents:
diff changeset
971 package Compilation_Switches is new Table.Table (
kono
parents:
diff changeset
972 Table_Component_Type => String_Ptr,
kono
parents:
diff changeset
973 Table_Index_Type => Nat,
kono
parents:
diff changeset
974 Table_Low_Bound => 1,
kono
parents:
diff changeset
975 Table_Initial => 30,
kono
parents:
diff changeset
976 Table_Increment => 100,
kono
parents:
diff changeset
977 Table_Name => "Compilation_Switches");
kono
parents:
diff changeset
978
kono
parents:
diff changeset
979 Load_Msg_Sloc : Source_Ptr;
kono
parents:
diff changeset
980 -- Location for placing error messages (a token in the main source text)
kono
parents:
diff changeset
981 -- This is set from Sloc (Enode) by Load only in the case where this Sloc
kono
parents:
diff changeset
982 -- is in the main source file. This ensures that not found messages and
kono
parents:
diff changeset
983 -- circular dependency messages reference the original with in this source.
kono
parents:
diff changeset
984
kono
parents:
diff changeset
985 type Load_Stack_Entry is record
kono
parents:
diff changeset
986 Unit_Number : Unit_Number_Type;
kono
parents:
diff changeset
987 With_Node : Node_Id;
kono
parents:
diff changeset
988 end record;
kono
parents:
diff changeset
989
kono
parents:
diff changeset
990 -- The Load_Stack table contains a list of unit numbers (indexes into the
kono
parents:
diff changeset
991 -- unit table) of units being loaded on a single dependency chain, and a
kono
parents:
diff changeset
992 -- flag to indicate whether this unit is loaded through a limited_with
kono
parents:
diff changeset
993 -- clause. The First entry is the main unit. The second entry, if present
kono
parents:
diff changeset
994 -- is a unit on which the first unit depends, etc. This stack is used to
kono
parents:
diff changeset
995 -- generate error messages showing the dependency chain if a file is not
kono
parents:
diff changeset
996 -- found, or whether a true circular dependency exists. The Load_Unit
kono
parents:
diff changeset
997 -- function makes an entry in this table when it is called, and removes
kono
parents:
diff changeset
998 -- the entry just before it returns.
kono
parents:
diff changeset
999
kono
parents:
diff changeset
1000 package Load_Stack is new Table.Table (
kono
parents:
diff changeset
1001 Table_Component_Type => Load_Stack_Entry,
kono
parents:
diff changeset
1002 Table_Index_Type => Int,
kono
parents:
diff changeset
1003 Table_Low_Bound => 0,
kono
parents:
diff changeset
1004 Table_Initial => Alloc.Load_Stack_Initial,
kono
parents:
diff changeset
1005 Table_Increment => Alloc.Load_Stack_Increment,
kono
parents:
diff changeset
1006 Table_Name => "Load_Stack");
kono
parents:
diff changeset
1007
kono
parents:
diff changeset
1008 procedure Sort (Tbl : in out Unit_Ref_Table);
kono
parents:
diff changeset
1009 -- This procedure sorts the given unit reference table in order of
kono
parents:
diff changeset
1010 -- ascending unit names, where the ordering relation is as described
kono
parents:
diff changeset
1011 -- by the comparison routines provided by package Uname.
kono
parents:
diff changeset
1012
kono
parents:
diff changeset
1013 -- The Version_Ref table records Body_Version and Version attribute
kono
parents:
diff changeset
1014 -- references. The entries are simply the strings for the external
kono
parents:
diff changeset
1015 -- names that correspond to the referenced values.
kono
parents:
diff changeset
1016
kono
parents:
diff changeset
1017 package Version_Ref is new Table.Table (
kono
parents:
diff changeset
1018 Table_Component_Type => String_Id,
kono
parents:
diff changeset
1019 Table_Index_Type => Nat,
kono
parents:
diff changeset
1020 Table_Low_Bound => 1,
kono
parents:
diff changeset
1021 Table_Initial => 20,
kono
parents:
diff changeset
1022 Table_Increment => 100,
kono
parents:
diff changeset
1023 Table_Name => "Version_Ref");
kono
parents:
diff changeset
1024
kono
parents:
diff changeset
1025 end Lib;