1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- L I B . X R E F --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 1998-2011, 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. See the GNU General Public License --
|
17 |
|
|
-- for more details. You should have received a copy of the GNU General --
|
18 |
|
|
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
|
19 |
|
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
20 |
|
|
-- --
|
21 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
22 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
23 |
|
|
-- --
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
-- This package contains for collecting and outputting cross-reference
|
27 |
|
|
-- information.
|
28 |
|
|
|
29 |
|
|
with Einfo; use Einfo;
|
30 |
|
|
with Lib.Util; use Lib.Util;
|
31 |
|
|
with Put_Alfa;
|
32 |
|
|
|
33 |
|
|
package Lib.Xref is
|
34 |
|
|
|
35 |
|
|
-------------------------------------------------------
|
36 |
|
|
-- Format of Cross-Reference Information in ALI File --
|
37 |
|
|
-------------------------------------------------------
|
38 |
|
|
|
39 |
|
|
-- Cross-reference sections follow the dependency section (D lines) in
|
40 |
|
|
-- an ALI file, so that they need not be read by gnatbind, gnatmake etc.
|
41 |
|
|
|
42 |
|
|
-- A cross reference section has a header of the form
|
43 |
|
|
|
44 |
|
|
-- X dependency-number filename
|
45 |
|
|
|
46 |
|
|
-- This header precedes xref information (entities/references from
|
47 |
|
|
-- the unit), identified by dependency number and file name. The
|
48 |
|
|
-- dependency number is the index into the generated D lines and
|
49 |
|
|
-- is ones origin (e.g. 2 = reference to second generated D line).
|
50 |
|
|
|
51 |
|
|
-- Note that the filename here will reflect the original name if
|
52 |
|
|
-- a Source_Reference pragma was encountered (since all line number
|
53 |
|
|
-- references will be with respect to the original file).
|
54 |
|
|
|
55 |
|
|
-- The lines following the header look like
|
56 |
|
|
|
57 |
|
|
-- line type col level entity renameref instref typeref overref ref ref
|
58 |
|
|
|
59 |
|
|
-- line is the line number of the referenced entity. The name of
|
60 |
|
|
-- the entity starts in column col. Columns are numbered from one,
|
61 |
|
|
-- and if horizontal tab characters are present, the column number
|
62 |
|
|
-- is computed assuming standard 1,9,17,.. tab stops. For example,
|
63 |
|
|
-- if the entity is the first token on the line, and is preceded
|
64 |
|
|
-- by space-HT-space, then the column would be column 10.
|
65 |
|
|
|
66 |
|
|
-- type is a single letter identifying the type of the entity. See
|
67 |
|
|
-- next section (Cross-Reference Entity Identifiers) for a full list
|
68 |
|
|
-- of the characters used).
|
69 |
|
|
|
70 |
|
|
-- col is the column number of the referenced entity
|
71 |
|
|
|
72 |
|
|
-- level is a single character that separates the col and entity
|
73 |
|
|
-- fields. It is an asterisk (*) for a top level library entity that
|
74 |
|
|
-- is publicly visible, as well for an entity declared in the visible
|
75 |
|
|
-- part of a generic package, the plus sign (+) for a C/C++ static
|
76 |
|
|
-- entity, and space otherwise.
|
77 |
|
|
|
78 |
|
|
-- entity is the name of the referenced entity, with casing in
|
79 |
|
|
-- the canonical casing for the source file where it is defined.
|
80 |
|
|
|
81 |
|
|
-- renameref provides information on renaming. If the entity is
|
82 |
|
|
-- a package, object or overloadable entity which is declared by
|
83 |
|
|
-- a renaming declaration, and the renaming refers to an entity
|
84 |
|
|
-- with a simple identifier or expanded name, then renameref has
|
85 |
|
|
-- the form:
|
86 |
|
|
|
87 |
|
|
-- =line:col
|
88 |
|
|
|
89 |
|
|
-- Here line:col give the reference to the identifier that appears
|
90 |
|
|
-- in the renaming declaration. Note that we never need a file entry,
|
91 |
|
|
-- since this identifier is always in the current file in which the
|
92 |
|
|
-- entity is declared. Currently, renameref appears only for the
|
93 |
|
|
-- simple renaming case. If the renaming reference is a complex
|
94 |
|
|
-- expressions, then renameref is omitted. Here line/col give
|
95 |
|
|
-- line/column as defined above.
|
96 |
|
|
|
97 |
|
|
-- instref is only present for package and subprogram instances. The
|
98 |
|
|
-- information in instref is the location of the point of declaration
|
99 |
|
|
-- of the generic parent unit. This part has the form:
|
100 |
|
|
|
101 |
|
|
-- [file|line]
|
102 |
|
|
|
103 |
|
|
-- without column information, on the reasonable assumption that
|
104 |
|
|
-- there is only one unit per line (the same assumption is made in
|
105 |
|
|
-- references to entities declared within instances, see below).
|
106 |
|
|
|
107 |
|
|
-- typeref is the reference for a related type. This part is
|
108 |
|
|
-- optional. It is present for the following cases:
|
109 |
|
|
|
110 |
|
|
-- derived types (points to the parent type) LR=<>
|
111 |
|
|
-- access types (points to designated type) LR=()
|
112 |
|
|
-- array types (points to component type) LR=()
|
113 |
|
|
-- subtypes (points to ancestor type) LR={}
|
114 |
|
|
-- functions (points to result type) LR={}
|
115 |
|
|
-- enumeration literals (points to enum type) LR={}
|
116 |
|
|
-- objects and components (points to type) LR={}
|
117 |
|
|
|
118 |
|
|
-- For a type that implements multiple interfaces, there is an
|
119 |
|
|
-- entry of the form LR=<> for each of the interfaces appearing
|
120 |
|
|
-- in the type declaration. In the data structures of ali.ads,
|
121 |
|
|
-- the type that the entity extends (or the first interface if
|
122 |
|
|
-- there is no such type) is stored in Xref_Entity_Record.Tref*,
|
123 |
|
|
-- additional interfaces are stored in the list of references
|
124 |
|
|
-- with a special type of Interface_Reference.
|
125 |
|
|
|
126 |
|
|
-- For an array type, there is an entry of the form LR=<> for each
|
127 |
|
|
-- of the index types appearing in the type declaration. The index
|
128 |
|
|
-- types follow the entry for the component type. In the data
|
129 |
|
|
-- structures of ali.ads, however, the list of index types are
|
130 |
|
|
-- output in the list of references with a special Rtype set to
|
131 |
|
|
-- Array_Index_Reference.
|
132 |
|
|
|
133 |
|
|
-- In the above list LR shows the brackets used in the output which
|
134 |
|
|
-- has one of the two following forms:
|
135 |
|
|
|
136 |
|
|
-- L file | line type col R user entity
|
137 |
|
|
-- L name-in-lower-case R standard entity
|
138 |
|
|
|
139 |
|
|
-- For the form for a user entity, file is the dependency number
|
140 |
|
|
-- of the file containing the declaration of the related type.
|
141 |
|
|
-- This number and the following vertical bar are omitted if the
|
142 |
|
|
-- relevant type is defined in the same file as the current entity.
|
143 |
|
|
-- The line, type, col are defined as previously described, and
|
144 |
|
|
-- specify the location of the relevant type declaration in the
|
145 |
|
|
-- referenced file. For the standard entity form, the name between
|
146 |
|
|
-- the brackets is the normal name of the entity in lower case.
|
147 |
|
|
|
148 |
|
|
-- overref is present for overriding operations (procedures and
|
149 |
|
|
-- functions), and provides information on the operation that it
|
150 |
|
|
-- overrides. This information has the format:
|
151 |
|
|
|
152 |
|
|
-- '<' file | line 'o' col '>'
|
153 |
|
|
|
154 |
|
|
-- file is the dependency number of the file containing the
|
155 |
|
|
-- declaration of the overridden operation. It and the following
|
156 |
|
|
-- vertical bar are omitted if the file is the same as that of
|
157 |
|
|
-- the overriding operation.
|
158 |
|
|
|
159 |
|
|
-- There may be zero or more ref entries on each line
|
160 |
|
|
|
161 |
|
|
-- file | line type col [...]
|
162 |
|
|
|
163 |
|
|
-- file is the dependency number of the file with the reference.
|
164 |
|
|
-- It and the following vertical bar are omitted if the file is
|
165 |
|
|
-- the same as the previous ref, and the refs for the current
|
166 |
|
|
-- file are first (and do not need a bar).
|
167 |
|
|
|
168 |
|
|
-- line is the line number of the reference
|
169 |
|
|
|
170 |
|
|
-- col is the column number of the reference, as defined above
|
171 |
|
|
|
172 |
|
|
-- type is one of
|
173 |
|
|
-- b = body entity
|
174 |
|
|
-- c = completion of private or incomplete type
|
175 |
|
|
-- d = discriminant of type
|
176 |
|
|
-- D = object definition
|
177 |
|
|
-- e = end of spec
|
178 |
|
|
-- H = abstract type
|
179 |
|
|
-- i = implicit reference
|
180 |
|
|
-- k = implicit reference to parent unit in child unit
|
181 |
|
|
-- l = label on END line
|
182 |
|
|
-- m = modification
|
183 |
|
|
-- o = own variable reference (SPARK only)
|
184 |
|
|
-- p = primitive operation
|
185 |
|
|
-- P = overriding primitive operation
|
186 |
|
|
-- r = reference
|
187 |
|
|
-- R = subprogram reference in dispatching call
|
188 |
|
|
-- s = subprogram reference in a static call
|
189 |
|
|
-- t = end of body
|
190 |
|
|
-- w = WITH line
|
191 |
|
|
-- x = type extension
|
192 |
|
|
-- z = generic formal parameter
|
193 |
|
|
-- > = subprogram IN parameter
|
194 |
|
|
-- = = subprogram IN OUT parameter
|
195 |
|
|
-- < = subprogram OUT parameter
|
196 |
|
|
-- ^ = subprogram ACCESS parameter
|
197 |
|
|
|
198 |
|
|
-- b is used for spec entities that are repeated in a body,
|
199 |
|
|
-- including the unit (subprogram, package, task, protected body,
|
200 |
|
|
-- protected entry) name itself, and in the case of a subprogram,
|
201 |
|
|
-- the formals. This letter is also used for the occurrence of
|
202 |
|
|
-- entry names in accept statements. Such entities are not
|
203 |
|
|
-- considered to be definitions for cross-referencing purposes,
|
204 |
|
|
-- but rather are considered to be references to the corresponding
|
205 |
|
|
-- spec entities, marked with this special type.
|
206 |
|
|
|
207 |
|
|
-- c is similar to b but is used to mark the completion of a
|
208 |
|
|
-- private or incomplete type. As with b, the completion is not
|
209 |
|
|
-- regarded as a separate definition, but rather a reference to
|
210 |
|
|
-- the initial declaration, marked with this special type.
|
211 |
|
|
|
212 |
|
|
-- d is used to identify a discriminant of a type. If this is
|
213 |
|
|
-- an incomplete or private type with discriminants, the entry
|
214 |
|
|
-- denotes the occurrence of the discriminant in the partial view
|
215 |
|
|
-- which is also the point of definition of the discriminant. The
|
216 |
|
|
-- occurrence of the same discriminant in the full view is a
|
217 |
|
|
-- regular reference to it.
|
218 |
|
|
|
219 |
|
|
-- e is used to identify the end of a construct in the following
|
220 |
|
|
-- cases:
|
221 |
|
|
|
222 |
|
|
-- Block Statement end [block_IDENTIFIER];
|
223 |
|
|
-- Loop Statement end loop [loop_IDENTIFIER];
|
224 |
|
|
-- Package Specification end [[PARENT_UNIT_NAME .] IDENTIFIER];
|
225 |
|
|
-- Task Definition end [task_IDENTIFIER];
|
226 |
|
|
-- Protected Definition end [protected_IDENTIFIER];
|
227 |
|
|
-- Record Definition end record;
|
228 |
|
|
-- Enumeration Definition );
|
229 |
|
|
|
230 |
|
|
-- Note that 'e' entries are special in that they appear even
|
231 |
|
|
-- in referencing units (normally xref entries appear only for
|
232 |
|
|
-- references in the extended main source unit (see Lib) to which
|
233 |
|
|
-- the ali applies. But 'e' entries are really structural and
|
234 |
|
|
-- simply indicate where packages end. This information can be
|
235 |
|
|
-- used to reconstruct scope information for any entities
|
236 |
|
|
-- referenced from within the package. The line/column values
|
237 |
|
|
-- for these entries point to the semicolon ending the construct.
|
238 |
|
|
|
239 |
|
|
-- i is used to identify a reference to the entity in a generic
|
240 |
|
|
-- actual or in a default in a call. The node that denotes the
|
241 |
|
|
-- entity does not come from source, but it has the Sloc of the
|
242 |
|
|
-- source node that generates the implicit reference, and it is
|
243 |
|
|
-- useful to record this one.
|
244 |
|
|
|
245 |
|
|
-- k is another non-standard reference type, used to record a
|
246 |
|
|
-- reference from a child unit to its parent. For various cross-
|
247 |
|
|
-- referencing tools, we need a pointer from the xref entries for
|
248 |
|
|
-- the child to the parent. This is the opposite way round from
|
249 |
|
|
-- normal xref entries, since the reference is *from* the child
|
250 |
|
|
-- unit *to* the parent unit, yet appears in the xref entries for
|
251 |
|
|
-- the child. Consider this example:
|
252 |
|
|
--
|
253 |
|
|
-- package q is
|
254 |
|
|
-- end;
|
255 |
|
|
-- package q.r is
|
256 |
|
|
-- end q.r;
|
257 |
|
|
--
|
258 |
|
|
-- The ali file for q-r.ads has these entries
|
259 |
|
|
--
|
260 |
|
|
-- D q.ads
|
261 |
|
|
-- D q-r.ads
|
262 |
|
|
-- D system.ads
|
263 |
|
|
-- X 1 q.ads
|
264 |
|
|
-- 1K9*q 2e4 2|1r9 2r5
|
265 |
|
|
-- X 2 q-r.ads
|
266 |
|
|
-- 1K11*r 1|1k9 2|2l7 2e8
|
267 |
|
|
--
|
268 |
|
|
-- Here the 2|1r9 entry appearing in the section for the parent
|
269 |
|
|
-- is the normal reference from the child to the parent. The 1k9
|
270 |
|
|
-- entry in the section for the child duplicates this information
|
271 |
|
|
-- but appears in the child rather than the parent.
|
272 |
|
|
|
273 |
|
|
-- l is used to identify the occurrence in the source of the name
|
274 |
|
|
-- on an end line. This is just a syntactic reference which can be
|
275 |
|
|
-- ignored for semantic purposes (e.g. a call graph construction).
|
276 |
|
|
-- Again, in the case of an accept there can be multiple l lines.
|
277 |
|
|
|
278 |
|
|
-- o is used for variables referenced from a SPARK 'own'
|
279 |
|
|
-- definition. In the SPARK language, it is allowed to use a
|
280 |
|
|
-- variable before its actual declaration.
|
281 |
|
|
|
282 |
|
|
-- p is used to mark a primitive operation of the given entity.
|
283 |
|
|
-- For example, if we have a type Tx, and a primitive operation
|
284 |
|
|
-- Pq of this type, then an entry in the list of references to
|
285 |
|
|
-- Tx will point to the declaration of Pq. Note that this entry
|
286 |
|
|
-- type is unusual because it an implicit rather than explicit,
|
287 |
|
|
-- and the name of the reference does not match the name of the
|
288 |
|
|
-- entity for which a reference is generated. These entries are
|
289 |
|
|
-- generated only for entities declared in the extended main
|
290 |
|
|
-- source unit (main unit itself, its separate spec (if any).
|
291 |
|
|
-- and all subunits (considered recursively).
|
292 |
|
|
|
293 |
|
|
-- If the primitive operation overrides an inherited primitive
|
294 |
|
|
-- operation of the parent type, the letter 'P' is used in the
|
295 |
|
|
-- corresponding entry.
|
296 |
|
|
|
297 |
|
|
-- R is used to mark a dispatching call. The reference is to
|
298 |
|
|
-- the specification of the primitive operation of the root
|
299 |
|
|
-- type when the call has a controlling argument in its class.
|
300 |
|
|
|
301 |
|
|
-- s is used to mark a static subprogram call. The reference is
|
302 |
|
|
-- to the specification of the subprogram being called.
|
303 |
|
|
|
304 |
|
|
-- t is similar to e. It identifies the end of a corresponding
|
305 |
|
|
-- body (such a reference always links up with a b reference)
|
306 |
|
|
|
307 |
|
|
-- Subprogram Body end [DESIGNATOR];
|
308 |
|
|
-- Package Body end [[PARENT_UNIT_NAME .] IDENTIFIER];
|
309 |
|
|
-- Task Body end [task_IDENTIFIER];
|
310 |
|
|
-- Entry Body end [entry_IDENTIFIER];
|
311 |
|
|
-- Protected Body end [protected_IDENTIFIER]
|
312 |
|
|
-- Accept Statement end [entry_IDENTIFIER]];
|
313 |
|
|
|
314 |
|
|
-- Note that in the case of accept statements, there can
|
315 |
|
|
-- be multiple b and t entries for the same entity.
|
316 |
|
|
|
317 |
|
|
-- x is used to identify the reference as the entity from which a
|
318 |
|
|
-- tagged type is extended. This allows immediate access to the
|
319 |
|
|
-- parent of a tagged type.
|
320 |
|
|
|
321 |
|
|
-- z is used on the cross-reference line for a generic unit,
|
322 |
|
|
-- to mark the definition of a generic formal of the unit. This
|
323 |
|
|
-- entry type is similar to 'k' and 'p' in that it is an implicit
|
324 |
|
|
-- reference for an entity with a different name.
|
325 |
|
|
|
326 |
|
|
-- The characters >, <. =, and ^ are used on the cross-reference
|
327 |
|
|
-- line for a subprogram, to denote formal parameters and their
|
328 |
|
|
-- modes. As with the 'z' and 'p' entries, each such entry is
|
329 |
|
|
-- an implicit reference to an entity with a different name.
|
330 |
|
|
|
331 |
|
|
-- [..] is used for generic instantiation references. These
|
332 |
|
|
-- references are present only if the entity in question is
|
333 |
|
|
-- a generic entity, and in that case the [..] contains the
|
334 |
|
|
-- reference for the instantiation. In the case of nested
|
335 |
|
|
-- instantiations, this can be nested [...[...[...]]] etc. The
|
336 |
|
|
-- reference is of the form [file|line] no column is present since
|
337 |
|
|
-- it is assumed that only one instantiation appears on a single
|
338 |
|
|
-- source line. Note that the appearance of file numbers in such
|
339 |
|
|
-- references follows the normal rules (present only if needed,
|
340 |
|
|
-- and resets the current file for subsequent references).
|
341 |
|
|
|
342 |
|
|
-- Examples:
|
343 |
|
|
|
344 |
|
|
-- 44B5*Flag_Type{boolean} 5r23 6m45 3|9r35 11r56
|
345 |
|
|
|
346 |
|
|
-- This line gives references for the publicly visible Boolean
|
347 |
|
|
-- type Flag_Type declared on line 44, column 5. There are four
|
348 |
|
|
-- references
|
349 |
|
|
|
350 |
|
|
-- a reference on line 5, column 23 of the current file
|
351 |
|
|
|
352 |
|
|
-- a modification on line 6, column 45 of the current file
|
353 |
|
|
|
354 |
|
|
-- a reference on line 9, column 35 of unit number 3
|
355 |
|
|
|
356 |
|
|
-- a reference on line 11, column 56 of unit number 3
|
357 |
|
|
|
358 |
|
|
-- 2U13 p3=2:35 5b13 8r4 12r13 12t15
|
359 |
|
|
|
360 |
|
|
-- This line gives references for the non-publicly visible
|
361 |
|
|
-- procedure p3 declared on line 2, column 13. This procedure
|
362 |
|
|
-- renames the procedure whose identifier reference is at
|
363 |
|
|
-- line 2 column 35. There are four references:
|
364 |
|
|
|
365 |
|
|
-- the corresponding body entity at line 5, column 13,
|
366 |
|
|
-- of the current file.
|
367 |
|
|
|
368 |
|
|
-- a reference (e.g. a call) at line 8 column 4 of the
|
369 |
|
|
-- of the current file.
|
370 |
|
|
|
371 |
|
|
-- the END line of the body has an explicit reference to
|
372 |
|
|
-- the name of the procedure at line 12, column 13.
|
373 |
|
|
|
374 |
|
|
-- the body ends at line 12, column 15, just past this label
|
375 |
|
|
|
376 |
|
|
-- 16I9*My_Type<2|4I9> 18r8
|
377 |
|
|
|
378 |
|
|
-- This line gives references for the publicly visible Integer
|
379 |
|
|
-- derived type My_Type declared on line 16, column 9. It also
|
380 |
|
|
-- gives references to the parent type declared in the unit
|
381 |
|
|
-- number 2 on line 4, column 9. There is one reference:
|
382 |
|
|
|
383 |
|
|
-- a reference (e.g. a variable declaration) at line 18 column
|
384 |
|
|
-- 4 of the current file.
|
385 |
|
|
|
386 |
|
|
-- 10I3*Genv{integer} 3|4I10[6|12]
|
387 |
|
|
|
388 |
|
|
-- This line gives a reference for the entity Genv in a generic
|
389 |
|
|
-- package. The reference in file 3, line 4, col 10, refers to an
|
390 |
|
|
-- instance of the generic where the instantiation can be found in
|
391 |
|
|
-- file 6 at line 12.
|
392 |
|
|
|
393 |
|
|
-- Continuation lines are used if the reference list gets too long,
|
394 |
|
|
-- a continuation line starts with a period, and then has references
|
395 |
|
|
-- continuing from the previous line. The references are sorted first
|
396 |
|
|
-- by unit, then by position in the source.
|
397 |
|
|
|
398 |
|
|
-- Note on handling of generic entities. The cross-reference is oriented
|
399 |
|
|
-- towards source references, so the entities in a generic instantiation
|
400 |
|
|
-- are not considered distinct from the entities in the template. All
|
401 |
|
|
-- definitions and references from generic instantiations are suppressed,
|
402 |
|
|
-- since they will be generated from the template. Any references to
|
403 |
|
|
-- entities in a generic instantiation from outside the instantiation
|
404 |
|
|
-- are considered to be references to the original template entity.
|
405 |
|
|
|
406 |
|
|
----------------------------------------
|
407 |
|
|
-- Cross-Reference Entity Identifiers --
|
408 |
|
|
----------------------------------------
|
409 |
|
|
|
410 |
|
|
-- In the cross-reference section of the ali file, entity types are
|
411 |
|
|
-- identified by a single letter, indicating the entity type. The following
|
412 |
|
|
-- table indicates the letter. A space for an entry is used for entities
|
413 |
|
|
-- that do not appear in the cross-reference table.
|
414 |
|
|
|
415 |
|
|
-- For objects, the character * appears in this table. In the xref listing,
|
416 |
|
|
-- this character is replaced by the lower case letter that corresponds to
|
417 |
|
|
-- the type of the object. For example, if a variable is of a Float type,
|
418 |
|
|
-- then, since the type is represented by an upper case F, the object would
|
419 |
|
|
-- be represented by a lower case f.
|
420 |
|
|
|
421 |
|
|
-- A special exception is the case of booleans, whose entities are normal
|
422 |
|
|
-- E_Enumeration_Type or E_Enumeration_Subtype entities, but which appear
|
423 |
|
|
-- as B/b in the xref lines, rather than E/e.
|
424 |
|
|
|
425 |
|
|
-- For private types, the character + appears in the table. In this case
|
426 |
|
|
-- the kind of the underlying type is used, if available, to determine the
|
427 |
|
|
-- character to use in the xref listing. The listing will still include a
|
428 |
|
|
-- '+' for a generic private type, for example, but will retain the '*' for
|
429 |
|
|
-- an object or formal parameter of such a type.
|
430 |
|
|
|
431 |
|
|
-- For subprograms, the characters 'U' and 'V' appear in the table,
|
432 |
|
|
-- indicating procedures and functions. If the operation is abstract,
|
433 |
|
|
-- these letters are replaced in the xref by 'x' and 'y' respectively.
|
434 |
|
|
|
435 |
|
|
Xref_Entity_Letters : array (Entity_Kind) of Character :=
|
436 |
|
|
(E_Void => ' ',
|
437 |
|
|
E_Variable => '*',
|
438 |
|
|
E_Component => '*',
|
439 |
|
|
E_Constant => '*',
|
440 |
|
|
E_Discriminant => '*',
|
441 |
|
|
|
442 |
|
|
E_Loop_Parameter => '*',
|
443 |
|
|
E_In_Parameter => '*',
|
444 |
|
|
E_Out_Parameter => '*',
|
445 |
|
|
E_In_Out_Parameter => '*',
|
446 |
|
|
E_Generic_In_Out_Parameter => '*',
|
447 |
|
|
|
448 |
|
|
E_Generic_In_Parameter => '*',
|
449 |
|
|
E_Named_Integer => 'N',
|
450 |
|
|
E_Named_Real => 'N',
|
451 |
|
|
E_Enumeration_Type => 'E', -- B for boolean
|
452 |
|
|
E_Enumeration_Subtype => 'E', -- B for boolean
|
453 |
|
|
|
454 |
|
|
E_Signed_Integer_Type => 'I',
|
455 |
|
|
E_Signed_Integer_Subtype => 'I',
|
456 |
|
|
E_Modular_Integer_Type => 'M',
|
457 |
|
|
E_Modular_Integer_Subtype => 'M',
|
458 |
|
|
E_Ordinary_Fixed_Point_Type => 'O',
|
459 |
|
|
|
460 |
|
|
E_Ordinary_Fixed_Point_Subtype => 'O',
|
461 |
|
|
E_Decimal_Fixed_Point_Type => 'D',
|
462 |
|
|
E_Decimal_Fixed_Point_Subtype => 'D',
|
463 |
|
|
E_Floating_Point_Type => 'F',
|
464 |
|
|
E_Floating_Point_Subtype => 'F',
|
465 |
|
|
|
466 |
|
|
E_Access_Type => 'P',
|
467 |
|
|
E_Access_Subtype => 'P',
|
468 |
|
|
E_Access_Attribute_Type => 'P',
|
469 |
|
|
E_Allocator_Type => ' ',
|
470 |
|
|
E_General_Access_Type => 'P',
|
471 |
|
|
|
472 |
|
|
E_Access_Subprogram_Type => 'P',
|
473 |
|
|
E_Access_Protected_Subprogram_Type => 'P',
|
474 |
|
|
E_Anonymous_Access_Subprogram_Type => ' ',
|
475 |
|
|
E_Anonymous_Access_Protected_Subprogram_Type => ' ',
|
476 |
|
|
E_Anonymous_Access_Type => ' ',
|
477 |
|
|
|
478 |
|
|
E_Array_Type => 'A',
|
479 |
|
|
E_Array_Subtype => 'A',
|
480 |
|
|
E_String_Type => 'S',
|
481 |
|
|
E_String_Subtype => 'S',
|
482 |
|
|
E_String_Literal_Subtype => ' ',
|
483 |
|
|
|
484 |
|
|
E_Class_Wide_Type => 'C',
|
485 |
|
|
E_Class_Wide_Subtype => 'C',
|
486 |
|
|
E_Record_Type => 'R',
|
487 |
|
|
E_Record_Subtype => 'R',
|
488 |
|
|
E_Record_Type_With_Private => 'R',
|
489 |
|
|
|
490 |
|
|
E_Record_Subtype_With_Private => 'R',
|
491 |
|
|
E_Private_Type => '+',
|
492 |
|
|
E_Private_Subtype => '+',
|
493 |
|
|
E_Limited_Private_Type => '+',
|
494 |
|
|
E_Limited_Private_Subtype => '+',
|
495 |
|
|
|
496 |
|
|
E_Incomplete_Type => '+',
|
497 |
|
|
E_Incomplete_Subtype => '+',
|
498 |
|
|
E_Task_Type => 'T',
|
499 |
|
|
E_Task_Subtype => 'T',
|
500 |
|
|
E_Protected_Type => 'W',
|
501 |
|
|
|
502 |
|
|
E_Protected_Subtype => 'W',
|
503 |
|
|
E_Exception_Type => ' ',
|
504 |
|
|
E_Subprogram_Type => ' ',
|
505 |
|
|
E_Enumeration_Literal => 'n',
|
506 |
|
|
E_Function => 'V',
|
507 |
|
|
|
508 |
|
|
E_Operator => 'V',
|
509 |
|
|
E_Procedure => 'U',
|
510 |
|
|
E_Entry => 'Y',
|
511 |
|
|
E_Entry_Family => 'Y',
|
512 |
|
|
E_Block => 'q',
|
513 |
|
|
|
514 |
|
|
E_Entry_Index_Parameter => '*',
|
515 |
|
|
E_Exception => 'X',
|
516 |
|
|
E_Generic_Function => 'v',
|
517 |
|
|
E_Generic_Package => 'k',
|
518 |
|
|
E_Generic_Procedure => 'u',
|
519 |
|
|
|
520 |
|
|
E_Label => 'L',
|
521 |
|
|
E_Loop => 'l',
|
522 |
|
|
E_Return_Statement => ' ',
|
523 |
|
|
E_Package => 'K',
|
524 |
|
|
|
525 |
|
|
-- The following entities are not ones to which we gather the cross-
|
526 |
|
|
-- references, since it does not make sense to do so (e.g. references to
|
527 |
|
|
-- a package are to the spec, not the body) Indeed the occurrence of the
|
528 |
|
|
-- body entity is considered to be a reference to the spec entity.
|
529 |
|
|
|
530 |
|
|
E_Package_Body => ' ',
|
531 |
|
|
E_Protected_Object => ' ',
|
532 |
|
|
E_Protected_Body => ' ',
|
533 |
|
|
E_Task_Body => ' ',
|
534 |
|
|
E_Subprogram_Body => ' ');
|
535 |
|
|
|
536 |
|
|
-- The following table is for information purposes. It shows the use of
|
537 |
|
|
-- each character appearing as an entity type.
|
538 |
|
|
|
539 |
|
|
-- letter lower case usage UPPER CASE USAGE
|
540 |
|
|
|
541 |
|
|
-- a array object (except string) array type (except string)
|
542 |
|
|
-- b Boolean object Boolean type
|
543 |
|
|
-- c class-wide object class-wide type
|
544 |
|
|
-- d decimal fixed-point object decimal fixed-point type
|
545 |
|
|
-- e non-Boolean enumeration object non_Boolean enumeration type
|
546 |
|
|
-- f floating-point object floating-point type
|
547 |
|
|
-- g C/C++ macro C/C++ fun-like macro
|
548 |
|
|
-- h Interface (Ada 2005) Abstract type
|
549 |
|
|
-- i signed integer object signed integer type
|
550 |
|
|
-- j C++ class object C++ class
|
551 |
|
|
-- k generic package package
|
552 |
|
|
-- l label on loop label on statement
|
553 |
|
|
-- m modular integer object modular integer type
|
554 |
|
|
-- n enumeration literal named number
|
555 |
|
|
-- o ordinary fixed-point object ordinary fixed-point type
|
556 |
|
|
-- p access object access type
|
557 |
|
|
-- q label on block C/C++ include file
|
558 |
|
|
-- r record object record type
|
559 |
|
|
-- s string object string type
|
560 |
|
|
-- t task object task type
|
561 |
|
|
-- u generic procedure procedure
|
562 |
|
|
-- v generic function or operator function or operator
|
563 |
|
|
-- w protected object protected type
|
564 |
|
|
-- x abstract procedure exception
|
565 |
|
|
-- y abstract function entry or entry family
|
566 |
|
|
-- z generic formal parameter (unused)
|
567 |
|
|
|
568 |
|
|
--------------------------------------
|
569 |
|
|
-- Handling of Imported Subprograms --
|
570 |
|
|
--------------------------------------
|
571 |
|
|
|
572 |
|
|
-- If a pragma Import or Interface applies to a subprogram, the pragma is
|
573 |
|
|
-- the completion of the subprogram. This is noted in the ALI file by
|
574 |
|
|
-- making the occurrence of the subprogram in the pragma into a body
|
575 |
|
|
-- reference ('b') and by including the external name of the subprogram and
|
576 |
|
|
-- its language, bracketed by '<' and '>' in that reference. For example:
|
577 |
|
|
--
|
578 |
|
|
-- 3U13*elsewhere 4b<c,there>21
|
579 |
|
|
--
|
580 |
|
|
-- indicates that procedure elsewhere, declared at line 3, has a pragma
|
581 |
|
|
-- Import at line 4, that its body is in C, and that the link name as given
|
582 |
|
|
-- in the pragma is "there".
|
583 |
|
|
|
584 |
|
|
----------------------
|
585 |
|
|
-- Alfa Information --
|
586 |
|
|
----------------------
|
587 |
|
|
|
588 |
|
|
-- This package defines procedures for collecting Alfa information and
|
589 |
|
|
-- printing in ALI files.
|
590 |
|
|
|
591 |
|
|
package Alfa is
|
592 |
|
|
|
593 |
|
|
function Enclosing_Subprogram_Or_Package (N : Node_Id) return Entity_Id;
|
594 |
|
|
-- Return the closest enclosing subprogram of package
|
595 |
|
|
|
596 |
|
|
procedure Generate_Dereference
|
597 |
|
|
(N : Node_Id;
|
598 |
|
|
Typ : Character := 'r');
|
599 |
|
|
-- This procedure is called to record a dereference. N is the location
|
600 |
|
|
-- of the dereference.
|
601 |
|
|
|
602 |
|
|
type Node_Processing is access procedure (N : Node_Id);
|
603 |
|
|
|
604 |
|
|
procedure Traverse_Compilation_Unit
|
605 |
|
|
(CU : Node_Id;
|
606 |
|
|
Process : Node_Processing;
|
607 |
|
|
Inside_Stubs : Boolean);
|
608 |
|
|
-- This procedure is undocumented ???
|
609 |
|
|
|
610 |
|
|
procedure Traverse_All_Compilation_Units (Process : Node_Processing);
|
611 |
|
|
-- Call Process on all declarations through all compilation units
|
612 |
|
|
|
613 |
|
|
procedure Collect_Alfa (Sdep_Table : Unit_Ref_Table; Num_Sdep : Nat);
|
614 |
|
|
-- Collect Alfa information from library units (for files and scopes)
|
615 |
|
|
-- and from cross-references. Fill in the tables in library package
|
616 |
|
|
-- called Alfa.
|
617 |
|
|
|
618 |
|
|
procedure Output_Alfa is new Put_Alfa;
|
619 |
|
|
-- Output Alfa information to the ALI files, based on the information
|
620 |
|
|
-- collected in the tables in library package called Alfa, and using
|
621 |
|
|
-- routines in Lib.Util.
|
622 |
|
|
|
623 |
|
|
end Alfa;
|
624 |
|
|
|
625 |
|
|
-----------------
|
626 |
|
|
-- Subprograms --
|
627 |
|
|
-----------------
|
628 |
|
|
|
629 |
|
|
procedure Generate_Definition (E : Entity_Id);
|
630 |
|
|
-- Records the definition of an entity
|
631 |
|
|
|
632 |
|
|
procedure Generate_Operator_Reference
|
633 |
|
|
(N : Node_Id;
|
634 |
|
|
T : Entity_Id);
|
635 |
|
|
-- Node N is an operator node, whose entity has been set. If this entity
|
636 |
|
|
-- is a user defined operator (i.e. an operator not defined in package
|
637 |
|
|
-- Standard), then a reference to the operator is recorded at node N.
|
638 |
|
|
-- T is the operand type of the operator. A reference to the operator is an
|
639 |
|
|
-- implicit reference to the type, and that needs to be recorded to avoid
|
640 |
|
|
-- spurious warnings on unused entities, when the operator is a renaming of
|
641 |
|
|
-- a predefined operator.
|
642 |
|
|
|
643 |
|
|
procedure Generate_Reference
|
644 |
|
|
(E : Entity_Id;
|
645 |
|
|
N : Node_Id;
|
646 |
|
|
Typ : Character := 'r';
|
647 |
|
|
Set_Ref : Boolean := True;
|
648 |
|
|
Force : Boolean := False);
|
649 |
|
|
-- This procedure is called to record a reference. N is the location of the
|
650 |
|
|
-- reference and E is the referenced entity. Typ is one of:
|
651 |
|
|
--
|
652 |
|
|
-- a character already described in the description of ref entries above
|
653 |
|
|
-- ' ' for dummy reference (see below)
|
654 |
|
|
--
|
655 |
|
|
-- Note: all references to incomplete or private types are to the original
|
656 |
|
|
-- (incomplete or private type) declaration. The full declaration is
|
657 |
|
|
-- treated as a reference with type 'c'.
|
658 |
|
|
--
|
659 |
|
|
-- Note: all references to packages or subprograms are to the entity for
|
660 |
|
|
-- the spec. The entity in the body is treated as a reference with type
|
661 |
|
|
-- 'b'. Similar handling for references to subprogram formals.
|
662 |
|
|
--
|
663 |
|
|
-- The call has no effect if N is not in the extended main source unit
|
664 |
|
|
-- This check is omitted for type 'e' references (where it is useful to
|
665 |
|
|
-- have structural scoping information for other than the main source),
|
666 |
|
|
-- and for 'p' (since we want to pick up inherited primitive operations
|
667 |
|
|
-- that are defined in other packages).
|
668 |
|
|
--
|
669 |
|
|
-- The call also has no effect if any of the following conditions hold:
|
670 |
|
|
--
|
671 |
|
|
-- cross-reference collection is disabled
|
672 |
|
|
-- entity does not come from source (and Force is False)
|
673 |
|
|
-- reference does not come from source (and Force is False)
|
674 |
|
|
-- the entity is not one for which xrefs are appropriate
|
675 |
|
|
-- the type letter is blank
|
676 |
|
|
-- the node N is not an identifier, defining identifier, or expanded name
|
677 |
|
|
-- the type is 'p' and the entity is not in the extended main source
|
678 |
|
|
--
|
679 |
|
|
-- If all these conditions are met, then the Is_Referenced flag of E is set
|
680 |
|
|
-- (unless Set_Ref is False) and a cross-reference entry is recorded for
|
681 |
|
|
-- later output when Output_References is called.
|
682 |
|
|
--
|
683 |
|
|
-- Note: the dummy space entry is for the convenience of some callers,
|
684 |
|
|
-- who find it easier to pass a space to suppress the entry than to do
|
685 |
|
|
-- a specific test. The call has no effect if the type is a space.
|
686 |
|
|
--
|
687 |
|
|
-- The parameter Set_Ref is normally True, and indicates that in addition
|
688 |
|
|
-- to generating a cross-reference, the Referenced flag of the specified
|
689 |
|
|
-- entity should be set. If this parameter is False, then setting of the
|
690 |
|
|
-- Referenced flag is inhibited.
|
691 |
|
|
--
|
692 |
|
|
-- The parameter Force is set to True to force a reference to be generated
|
693 |
|
|
-- even if Comes_From_Source is false. This is used for certain implicit
|
694 |
|
|
-- references, and also for end label references.
|
695 |
|
|
|
696 |
|
|
procedure Generate_Reference_To_Formals (E : Entity_Id);
|
697 |
|
|
-- Add a reference to the definition of each formal on the line for
|
698 |
|
|
-- a subprogram.
|
699 |
|
|
|
700 |
|
|
procedure Generate_Reference_To_Generic_Formals (E : Entity_Id);
|
701 |
|
|
-- Add a reference to the definition of each generic formal on the line
|
702 |
|
|
-- for a generic unit.
|
703 |
|
|
|
704 |
|
|
procedure Output_References;
|
705 |
|
|
-- Output references to the current ali file
|
706 |
|
|
|
707 |
|
|
procedure Initialize;
|
708 |
|
|
-- Initialize internal tables
|
709 |
|
|
|
710 |
|
|
end Lib.Xref;
|