Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / ada / ali.ads
blob94715b31196ef5d0ea0fa544529ac3f3fc0309b2
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A L I --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2007, 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 ------------------------------------------------------------------------------
26 -- This package defines the internal data structures used for representation
27 -- of Ada Library Information (ALI) acquired from the ALI files generated
28 -- by the front end.
30 with Casing; use Casing;
31 with Gnatvsn; use Gnatvsn;
32 with Namet; use Namet;
33 with Rident; use Rident;
34 with Table;
35 with Types; use Types;
37 with GNAT.HTable; use GNAT.HTable;
39 package ALI is
41 --------------
42 -- Id Types --
43 --------------
45 -- The various entries are stored in tables with distinct subscript
46 -- ranges. The following type definitions indicate the ranges used
47 -- for the subscripts (Id values) for the various tables.
49 type ALI_Id is range 0 .. 999_999;
50 -- Id values used for ALIs table entries
52 type Unit_Id is range 1_000_000 .. 1_999_999;
53 -- Id values used for Unit table entries
55 type With_Id is range 2_000_000 .. 2_999_999;
56 -- Id values used for Withs table entries
58 type Arg_Id is range 3_000_000 .. 3_999_999;
59 -- Id values used for argument table entries
61 type Sdep_Id is range 4_000_000 .. 4_999_999;
62 -- Id values used for Sdep table entries
64 type Source_Id is range 5_000_000 .. 5_999_999;
65 -- Id values used for Source table entries
67 type Interrupt_State_Id is range 6_000_000 .. 6_999_999;
68 -- Id values used for Interrupt_State table entries
70 type Priority_Specific_Dispatching_Id is range 7_000_000 .. 7_999_999;
71 -- Id values used for Priority_Specific_Dispatching table entries
73 --------------------
74 -- ALI File Table --
75 --------------------
77 -- Each ALI file read generates an entry in the ALIs table
79 No_ALI_Id : constant ALI_Id := ALI_Id'First;
80 -- Special value indicating no ALI entry
82 First_ALI_Entry : constant ALI_Id := No_ALI_Id + 1;
83 -- Id of first actual entry in table
85 type Main_Program_Type is (None, Proc, Func);
86 -- Indicator of whether unit can be used as main program
88 type ALIs_Record is record
90 Afile : File_Name_Type;
91 -- Name of ALI file
93 Ofile_Full_Name : File_Name_Type;
94 -- Full name of object file corresponding to the ALI file
96 Sfile : File_Name_Type;
97 -- Name of source file that generates this ALI file (which is equal
98 -- to the name of the source file in the first unit table entry for
99 -- this ALI file, since the body if present is always first).
101 Ver : String (1 .. Ver_Len_Max);
102 -- Value of library version (V line in ALI file). Not set if
103 -- V lines are ignored as a result of the Ignore_Lines parameter.
105 Ver_Len : Natural;
106 -- Length of characters stored in Ver. Not set if V lines are
107 -- ignored as a result of the Ignore_Lines parameter.
109 SAL_Interface : Boolean;
110 -- Set True when this is an interface to a standalone library
112 First_Unit : Unit_Id;
113 -- Id of first Unit table entry for this file
115 Last_Unit : Unit_Id;
116 -- Id of last Unit table entry for this file
118 First_Sdep : Sdep_Id;
119 -- Id of first Sdep table entry for this file
121 Last_Sdep : Sdep_Id;
122 -- Id of last Sdep table entry for this file
124 Main_Program : Main_Program_Type;
125 -- Indicator of whether first unit can be used as main program.
126 -- Not set if 'M' appears in Ignore_Lines.
128 Main_Priority : Int;
129 -- Indicates priority value if Main_Program field indicates that
130 -- this can be a main program. A value of -1 (No_Main_Priority)
131 -- indicates that no parameter was found, or no M line was present.
132 -- Not set if 'M' appears in Ignore_Lines.
134 Time_Slice_Value : Int;
135 -- Indicates value of time slice parameter from T=xxx on main program
136 -- line. A value of -1 indicates that no T=xxx parameter was found,
137 -- or no M line was present.
138 -- Not set if 'M' appears in Ignore_Lines.
140 WC_Encoding : Character;
141 -- Wide character encoding if main procedure. Otherwise not relevant.
142 -- Not set if 'M' appears in Ignore_Lines.
144 Locking_Policy : Character;
145 -- Indicates locking policy for units in this file. Space means
146 -- tasking was not used, or that no Locking_Policy pragma was
147 -- present or that this is a language defined unit. Otherwise set
148 -- to first character (upper case) of policy name.
149 -- Not set if 'P' appears in Ignore_Lines.
151 Queuing_Policy : Character;
152 -- Indicates queuing policy for units in this file. Space means
153 -- tasking was not used, or that no Queuing_Policy pragma was
154 -- present or that this is a language defined unit. Otherwise set
155 -- to first character (upper case) of policy name.
156 -- Not set if 'P' appears in Ignore_Lines.
158 Task_Dispatching_Policy : Character;
159 -- Indicates task dispatching policy for units in this file. Space
160 -- means tasking was not used, or that no Task_Dispatching_Policy
161 -- pragma was present or that this is a language defined unit.
162 -- Otherwise set to first character (upper case) of policy name.
163 -- Not set if 'P' appears in Ignore_Lines.
165 Compile_Errors : Boolean;
166 -- Set to True if compile errors for unit. Note that No_Object
167 -- will always be set as well in this case.
168 -- Not set if 'P' appears in Ignore_Lines.
170 Float_Format : Character;
171 -- Set to float format (set to I if no float-format given).
172 -- Not set if 'P' appears in Ignore_Lines.
174 No_Object : Boolean;
175 -- Set to True if no object file generated.
176 -- Not set if 'P' appears in Ignore_Lines.
178 Normalize_Scalars : Boolean;
179 -- Set to True if file was compiled with Normalize_Scalars.
180 -- Not set if 'P' appears in Ignore_Lines.
182 Unit_Exception_Table : Boolean;
183 -- Set to True if unit exception table pointer generated.
184 -- Not set if 'P' appears in Ignore_Lines.
186 Zero_Cost_Exceptions : Boolean;
187 -- Set to True if file was compiled with zero cost exceptions.
188 -- Not set if 'P' appears in Ignore_Lines.
190 Restrictions : Restrictions_Info;
191 -- Restrictions information reconstructed from R lines
193 First_Interrupt_State : Interrupt_State_Id;
194 Last_Interrupt_State : Interrupt_State_Id'Base;
195 -- These point to the first and last entries in the interrupt
196 -- state table for this unit. If there are no entries, then
197 -- Last_Interrupt_State = First_Interrupt_State - 1 (that's
198 -- why the 'Base reference is there, it can be one less than
199 -- the lower bound of the subtype).
200 -- Not set if 'I' appears in Ignore_Lines
202 First_Specific_Dispatching : Priority_Specific_Dispatching_Id;
203 Last_Specific_Dispatching : Priority_Specific_Dispatching_Id'Base;
204 -- These point to the first and last entries in the priority specific
205 -- dispatching table for this unit. If there are no entries, then
206 -- Last_Specific_Dispatching = First_Specific_Dispatching - 1. That
207 -- is why the 'Base reference is there, it can be one less than the
208 -- lower bound of the subtype. Not set if 'S' appears in Ignore_Lines.
210 end record;
212 No_Main_Priority : constant Int := -1;
213 -- Code for no main priority set
215 package ALIs is new Table.Table (
216 Table_Component_Type => ALIs_Record,
217 Table_Index_Type => ALI_Id,
218 Table_Low_Bound => First_ALI_Entry,
219 Table_Initial => 500,
220 Table_Increment => 200,
221 Table_Name => "ALIs");
223 ----------------
224 -- Unit Table --
225 ----------------
227 -- Each unit within an ALI file generates an entry in the unit table
229 No_Unit_Id : constant Unit_Id := Unit_Id'First;
230 -- Special value indicating no unit table entry
232 First_Unit_Entry : constant Unit_Id := No_Unit_Id + 1;
233 -- Id of first actual entry in table
235 type Unit_Type is (Is_Spec, Is_Body, Is_Spec_Only, Is_Body_Only);
236 -- Indicates type of entry, if both body and spec appear in the ALI file,
237 -- then the first unit is marked Is_Body, and the second is marked Is_Spec.
238 -- If only a spec appears, then it is marked as Is_Spec_Only, and if only
239 -- a body appears, then it is marked Is_Body_Only).
241 subtype Version_String is String (1 .. 8);
242 -- Version string, taken from unit record
244 type Unit_Record is record
246 My_ALI : ALI_Id;
247 -- Corresponding ALI entry
249 Uname : Unit_Name_Type;
250 -- Name of Unit
252 Sfile : File_Name_Type;
253 -- Name of source file
255 Preelab : Boolean;
256 -- Indicates presence of PR parameter for a preelaborated package
258 No_Elab : Boolean;
259 -- Indicates presence of NE parameter for a unit that has does not
260 -- have an elaboration routine (since it has no elaboration code).
262 Pure : Boolean;
263 -- Indicates presence of PU parameter for a package having pragma Pure
265 Dynamic_Elab : Boolean;
266 -- Set to True if the unit was compiled with dynamic elaboration checks
267 -- (i.e. either -gnatE or pragma Elaboration_Checks (RM) was used to
268 -- compile the unit).
270 Elaborate_Body : Boolean;
271 -- Indicates presence of EB parameter for a package which has a pragma
272 -- Elaborate_Body, and also for generic package instantiations.
274 Set_Elab_Entity : Boolean;
275 -- Indicates presence of EE parameter for a unit which has an
276 -- elaboration entity which must be set true as part of the
277 -- elaboration of the entity.
279 Has_RACW : Boolean;
280 -- Indicates presence of RA parameter for a package that declares at
281 -- least one Remote Access to Class_Wide (RACW) object.
283 Remote_Types : Boolean;
284 -- Indicates presence of RT parameter for a package which has a
285 -- pragma Remote_Types.
287 Shared_Passive : Boolean;
288 -- Indicates presence of SP parameter for a package which has a pragma
289 -- Shared_Passive.
291 RCI : Boolean;
292 -- Indicates presence of RC parameter for a package which has a pragma
293 -- Remote_Call_Interface.
295 Predefined : Boolean;
296 -- Indicates if unit is language predefined (or a child of such a unit)
298 Internal : Boolean;
299 -- Indicates if unit is an internal unit (or a child of such a unit)
301 First_With : With_Id;
302 -- Id of first withs table entry for this file
304 Last_With : With_Id;
305 -- Id of last withs table entry for this file
307 First_Arg : Arg_Id;
308 -- Id of first args table entry for this file
310 Last_Arg : Arg_Id;
311 -- Id of last args table entry for this file
313 Utype : Unit_Type;
314 -- Type of entry
316 Is_Generic : Boolean;
317 -- True for generic unit (i.e. a generic declaration, or a generic
318 -- body). False for a non-generic unit.
320 Unit_Kind : Character;
321 -- Indicates the nature of the unit. 'p' for Packages and 's' for
322 -- subprograms.
324 Version : Version_String;
325 -- Version of unit
327 Icasing : Casing_Type;
328 -- Indicates casing of identifiers in source file for this unit. This
329 -- is used for informational output, and also for constructing the main
330 -- unit if it is being built in Ada.
332 Kcasing : Casing_Type;
333 -- Indicates casing of keywords in source file for this unit. This is
334 -- used for informational output, and also for constructing the main
335 -- unit if it is being built in Ada.
337 Elab_Position : aliased Natural;
338 -- Initialized to zero. Set non-zero when a unit is chosen and
339 -- placed in the elaboration order. The value represents the
340 -- ordinal position in the elaboration order.
342 Init_Scalars : Boolean;
343 -- Set True if IS qualifier appears in ALI file, indicating that
344 -- an Initialize_Scalars pragma applies to the unit.
346 SAL_Interface : Boolean;
347 -- Set True when this is an interface to a standalone library
349 Body_Needed_For_SAL : Boolean;
350 -- Indicates that the source for the body of the unit (subprogram,
351 -- package, or generic unit) must be included in a standalone library.
353 Elaborate_Body_Desirable : Boolean;
354 -- Indicates that the front end elaboration circuitry decided that it
355 -- would be a good idea if this package had Elaborate_Body. The binder
356 -- will attempt, but does not promise, to place the elaboration call
357 -- for the body right after the call for the spec, or at least as close
358 -- together as possible.
360 end record;
362 package Units is new Table.Table (
363 Table_Component_Type => Unit_Record,
364 Table_Index_Type => Unit_Id,
365 Table_Low_Bound => First_Unit_Entry,
366 Table_Initial => 100,
367 Table_Increment => 200,
368 Table_Name => "Unit");
370 ---------------------------
371 -- Interrupt State Table --
372 ---------------------------
374 -- An entry is made in this table for each I (interrupt state) line
375 -- encountered in the input ALI file. The First/Last_Interrupt_Id
376 -- fields of the ALI file entry show the range of entries defined
377 -- within a particular ALI file.
379 type Interrupt_State_Record is record
380 Interrupt_Id : Nat;
381 -- Id from interrupt state entry
383 Interrupt_State : Character;
384 -- State from interrupt state entry ('u'/'r'/'s')
386 IS_Pragma_Line : Nat;
387 -- Line number of Interrupt_State pragma
388 end record;
390 package Interrupt_States is new Table.Table (
391 Table_Component_Type => Interrupt_State_Record,
392 Table_Index_Type => Interrupt_State_Id'Base,
393 Table_Low_Bound => Interrupt_State_Id'First,
394 Table_Initial => 100,
395 Table_Increment => 200,
396 Table_Name => "Interrupt_States");
398 -----------------------------------------
399 -- Priority Specific Dispatching Table --
400 -----------------------------------------
402 -- An entry is made in this table for each S (priority specific
403 -- dispatching) line encountered in the input ALI file. The
404 -- First/Last_Specific_Dispatching_Id fields of the ALI file
405 -- entry show the range of entries defined within a particular
406 -- ALI file.
408 type Specific_Dispatching_Record is record
409 Dispatching_Policy : Character;
410 -- First character (upper case) of the corresponding policy name
412 First_Priority : Nat;
413 -- Lower bound of the priority range to which the specified dispatching
414 -- policy applies.
416 Last_Priority : Nat;
417 -- Upper bound of the priority range to which the specified dispatching
418 -- policy applies.
420 PSD_Pragma_Line : Nat;
421 -- Line number of Priority_Specific_Dispatching pragma
422 end record;
424 package Specific_Dispatching is new Table.Table (
425 Table_Component_Type => Specific_Dispatching_Record,
426 Table_Index_Type => Priority_Specific_Dispatching_Id'Base,
427 Table_Low_Bound => Priority_Specific_Dispatching_Id'First,
428 Table_Initial => 100,
429 Table_Increment => 200,
430 Table_Name => "Priority_Specific_Dispatching");
432 --------------
433 -- Switches --
434 --------------
436 -- These switches record status information about ali files that
437 -- have been read, for quick reference without searching tables.
439 -- Note: a switch will be left set at its default value if the line
440 -- which might otherwise set it is ignored (from Ignore_Lines).
442 Dynamic_Elaboration_Checks_Specified : Boolean := False;
443 -- Set to False by Initialize_ALI. Set to True if Scan_ALI reads
444 -- a unit for which dynamic elaboration checking is enabled.
446 Float_Format_Specified : Character := ' ';
447 -- Set to blank by Initialize_ALI. Set to appropriate float format
448 -- character (V or I, see Opt.Float_Format) if an an ali file that
449 -- is read contains an F line setting the floating point format.
451 Initialize_Scalars_Used : Boolean := False;
452 -- Set True if an ali file contains the Initialize_Scalars flag
454 Locking_Policy_Specified : Character := ' ';
455 -- Set to blank by Initialize_ALI. Set to the appropriate locking policy
456 -- character if an ali file contains a P line setting the locking policy.
458 No_Normalize_Scalars_Specified : Boolean := False;
459 -- Set to False by Initialize_ALI. Set to True if an ali file indicates
460 -- that the file was compiled without normalize scalars.
462 No_Object_Specified : Boolean := False;
463 -- Set to False by Initialize_ALI. Set to True if an ali file contains
464 -- the No_Object flag.
466 Normalize_Scalars_Specified : Boolean := False;
467 -- Set to False by Initialize_ALI. Set to True if an ali file indicates
468 -- that the file was compiled in Normalize_Scalars mode.
470 Queuing_Policy_Specified : Character := ' ';
471 -- Set to blank by Initialize_ALI. Set to the appropriate queuing policy
472 -- character if an ali file contains a P line setting the queuing policy.
474 Cumulative_Restrictions : Restrictions_Info := No_Restrictions;
475 -- This variable records the cumulative contributions of R lines in all
476 -- ali files, showing whether a restriction pragma exists anywhere, and
477 -- accumulating the aggregate knowledge of violations.
479 Stack_Check_Switch_Set : Boolean := False;
480 -- Set to True if at least one ALI file contains '-fstack-check' in its
481 -- argument list.
483 Static_Elaboration_Model_Used : Boolean := False;
484 -- Set to False by Initialize_ALI. Set to True if any ALI file for a
485 -- non-internal unit compiled with the static elaboration model is
486 -- encountered.
488 Task_Dispatching_Policy_Specified : Character := ' ';
489 -- Set to blank by Initialize_ALI. Set to the appropriate task dispatching
490 -- policy character if an ali file contains a P line setting the
491 -- task dispatching policy.
493 Unreserve_All_Interrupts_Specified : Boolean := False;
494 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
495 -- has P line specifying unreserve all interrupts mode.
497 Zero_Cost_Exceptions_Specified : Boolean := False;
498 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
499 -- has a P line specifying the generation of zero cost exceptions.
501 -----------------
502 -- Withs Table --
503 -----------------
505 -- Each With line (W line) in an ALI file generates a Withs table entry
507 -- Note: there will be no entries in this table if 'W' lines are ignored
509 No_With_Id : constant With_Id := With_Id'First;
510 -- Special value indicating no withs table entry
512 First_With_Entry : constant With_Id := No_With_Id + 1;
513 -- Id of first actual entry in table
515 type With_Record is record
517 Uname : Unit_Name_Type;
518 -- Name of Unit
520 Sfile : File_Name_Type;
521 -- Name of source file, set to No_File in generic case
523 Afile : File_Name_Type;
524 -- Name of ALI file, set to No_File in generic case
526 Elaborate : Boolean;
527 -- Indicates presence of E parameter
529 Elaborate_All : Boolean;
530 -- Indicates presence of EA parameter
532 Elab_All_Desirable : Boolean;
533 -- Indicates presence of AD parameter
535 Elab_Desirable : Boolean;
536 -- Indicates presence of ED parameter
538 SAL_Interface : Boolean := False;
539 -- True if the Unit is an Interface of a Stand-Alone Library
541 end record;
543 package Withs is new Table.Table (
544 Table_Component_Type => With_Record,
545 Table_Index_Type => With_Id,
546 Table_Low_Bound => First_With_Entry,
547 Table_Initial => 5000,
548 Table_Increment => 200,
549 Table_Name => "Withs");
551 ---------------------
552 -- Arguments Table --
553 ---------------------
555 -- Each Arg line (A line) in an ALI file generates an Args table entry
557 -- Note: there will be no entries in this table if 'A' lines are ignored
559 No_Arg_Id : constant Arg_Id := Arg_Id'First;
560 -- Special value indicating no args table entry
562 First_Arg_Entry : constant Arg_Id := No_Arg_Id + 1;
563 -- Id of first actual entry in table
565 package Args is new Table.Table (
566 Table_Component_Type => String_Ptr,
567 Table_Index_Type => Arg_Id,
568 Table_Low_Bound => First_Arg_Entry,
569 Table_Initial => 1000,
570 Table_Increment => 100,
571 Table_Name => "Args");
573 --------------------------
574 -- Linker_Options Table --
575 --------------------------
577 -- If an ALI file has one of more Linker_Options lines, then a single
578 -- entry is made in this table. If more than one Linker_Options lines
579 -- appears in a given ALI file, then the arguments are concatenated
580 -- to form the entry in this table, using a NUL character as the
581 -- separator, and a final NUL character is appended to the end.
583 -- Note: there will be no entries in this table if 'L' lines are ignored
585 type Linker_Option_Record is record
586 Name : Name_Id;
587 -- Name entry containing concatenated list of Linker_Options
588 -- arguments separated by NUL and ended by NUL as described above.
590 Unit : Unit_Id;
591 -- Unit_Id for the entry
593 Internal_File : Boolean;
594 -- Set True if the linker options are from an internal file. This is
595 -- used to insert certain standard entries after all the user entries
596 -- but before the entries from the run-time.
598 Original_Pos : Positive;
599 -- Keep track of original position in the linker options table. This
600 -- is used to implement a stable sort when we sort the linker options
601 -- table.
602 end record;
604 -- Declare the Linker_Options Table
606 -- The indexes of active entries in this table range from 1 to the
607 -- value of Linker_Options.Last. The zero'th element is for sort call.
609 package Linker_Options is new Table.Table (
610 Table_Component_Type => Linker_Option_Record,
611 Table_Index_Type => Integer,
612 Table_Low_Bound => 0,
613 Table_Initial => 200,
614 Table_Increment => 400,
615 Table_Name => "Linker_Options");
617 -------------------------------------------
618 -- External Version Reference Hash Table --
619 -------------------------------------------
621 -- This hash table keeps track of external version reference strings
622 -- as read from E lines in the ali file. The stored values do not
623 -- include the terminating quote characters.
625 -- Note: there will be no entries in this table if 'E' lines are ignored
627 type Vindex is range 0 .. 98;
628 -- Type to define range of headers
630 function SHash (S : String_Ptr) return Vindex;
631 -- Hash function for this table
633 function SEq (F1, F2 : String_Ptr) return Boolean;
634 -- Equality function for this table
636 package Version_Ref is new Simple_HTable (
637 Header_Num => Vindex,
638 Element => Boolean,
639 No_Element => False,
640 Key => String_Ptr,
641 Hash => SHash,
642 Equal => SEq);
644 -------------------------
645 -- No_Dependency Table --
646 -------------------------
648 -- Each R line for a No_Dependency Restriction generates an entry in
649 -- this No_Dependency table.
651 type No_Dep_Record is record
652 ALI_File : ALI_Id;
653 -- ALI File containing the entry
655 No_Dep_Unit : Name_Id;
656 -- Id for names table entry including entire name, including periods
657 end record;
659 package No_Deps is new Table.Table (
660 Table_Component_Type => No_Dep_Record,
661 Table_Index_Type => Integer,
662 Table_Low_Bound => 0,
663 Table_Initial => 200,
664 Table_Increment => 400,
665 Table_Name => "No_Deps");
667 ------------------------------------
668 -- Sdep (Source Dependency) Table --
669 ------------------------------------
671 -- Each source dependency (D line) in an ALI file generates an
672 -- entry in the Sdep table.
674 -- Note: there will be no entries in this table if 'D' lines are ignored
676 No_Sdep_Id : constant Sdep_Id := Sdep_Id'First;
677 -- Special value indicating no Sdep table entry
679 First_Sdep_Entry : Sdep_Id := No_Sdep_Id + 1;
680 -- Id of first Sdep entry for current ali file. This is initialized to
681 -- the first Sdep entry in the table, and then incremented appropriately
682 -- as successive ALI files are scanned.
684 type Sdep_Record is record
686 Sfile : File_Name_Type;
687 -- Name of source file
689 Stamp : Time_Stamp_Type;
690 -- Time stamp value. Note that this will be all zero characters
691 -- for the dummy entries for missing or non-dependent files.
693 Checksum : Word;
694 -- Checksum value. Note that this will be all zero characters
695 -- for the dummy entries for missing or non-dependent files
697 Dummy_Entry : Boolean;
698 -- Set True for dummy entries that correspond to missing files
699 -- or files where no dependency relationship exists.
701 Subunit_Name : Name_Id;
702 -- Name_Id for subunit name if present, else No_Name
704 Rfile : File_Name_Type;
705 -- Reference file name. Same as Sfile unless a Source_Reference
706 -- pragma was used, in which case it reflects the name used in
707 -- the pragma.
709 Start_Line : Nat;
710 -- Starting line number in file. Always 1, unless a Source_Reference
711 -- pragma was used, in which case it reflects the line number value
712 -- given in the pragma.
714 end record;
716 package Sdep is new Table.Table (
717 Table_Component_Type => Sdep_Record,
718 Table_Index_Type => Sdep_Id,
719 Table_Low_Bound => First_Sdep_Entry,
720 Table_Initial => 5000,
721 Table_Increment => 200,
722 Table_Name => "Sdep");
724 ----------------------------
725 -- Use of Name Table Info --
726 ----------------------------
728 -- All unit names and file names are entered into the Names table. The
729 -- Info fields of these entries are used as follows:
731 -- Unit name Info field has Unit_Id of unit table entry
732 -- ALI file name Info field has ALI_Id of ALI table entry
733 -- Source file name Info field has Source_Id of source table entry
735 --------------------------
736 -- Cross-Reference Data --
737 --------------------------
739 -- The following table records cross-reference sections, there is one
740 -- entry for each X header line in the ALI file for an xref section.
742 -- Note: there will be no entries in this table if 'X' lines are ignored
744 type Xref_Section_Record is record
745 File_Num : Sdep_Id;
746 -- Dependency number for file (entry in Sdep.Table)
748 File_Name : File_Name_Type;
749 -- Name of file
751 First_Entity : Nat;
752 -- First entry in Xref_Entity table
754 Last_Entity : Nat;
755 -- Last entry in Xref_Entity table
756 end record;
758 package Xref_Section is new Table.Table (
759 Table_Component_Type => Xref_Section_Record,
760 Table_Index_Type => Nat,
761 Table_Low_Bound => 1,
762 Table_Initial => 50,
763 Table_Increment => 300,
764 Table_Name => "Xref_Section");
766 -- The following is used to indicate whether a typeref field is present
767 -- for the entity, and if so what kind of typeref field.
769 type Tref_Kind is (
770 Tref_None, -- No typeref present
771 Tref_Access, -- Access type typeref (points to designated type)
772 Tref_Derived, -- Derived type typeref (points to parent type)
773 Tref_Type); -- All other cases
775 -- The following table records entities for which xrefs are recorded
777 type Xref_Entity_Record is record
778 Line : Pos;
779 -- Line number of definition
781 Etype : Character;
782 -- Set to the identification character for the entity. See section
783 -- "Cross-Reference Entity Identifiers" in lib-xref.ads for details.
785 Col : Pos;
786 -- Column number of definition
788 Lib : Boolean;
789 -- True if entity is library level entity
791 Entity : Name_Id;
792 -- Name of entity
794 Iref_File_Num : Sdep_Id;
795 -- This field is set to the dependency reference for the file containing
796 -- the generic entity that this one instantiates, or to No_Sdep_Id if
797 -- the current entity is not an instantiation
799 Iref_Line : Nat;
800 -- This field is set to the line number in Iref_File_Num of the generic
801 -- entity that this one instantiates, or to zero if the current entity
802 -- is not an instantiation.
804 Rref_Line : Nat;
805 -- This field is set to the line number of a renaming reference if
806 -- one is present, or to zero if no renaming reference is present
808 Rref_Col : Nat;
809 -- This field is set to the column number of a renaming reference
810 -- if one is present, or to zero if no renaming reference is present.
812 Tref : Tref_Kind;
813 -- Indicates if a typeref is present, and if so what kind. Set to
814 -- Tref_None if no typeref field is present.
816 Tref_File_Num : Sdep_Id;
817 -- This field is set to No_Sdep_Id if no typeref is present, or
818 -- if the typeref refers to an entity in standard. Otherwise it
819 -- it is the dependency reference for the file containing the
820 -- declaration of the typeref entity.
822 Tref_Line : Nat;
823 -- This field is set to zero if no typeref is present, or if the
824 -- typeref refers to an entity in standard. Otherwise it contains
825 -- the line number of the declaration of the typeref entity.
827 Tref_Type : Character;
828 -- This field is set to blank if no typeref is present, or if the
829 -- typeref refers to an entity in standard. Otherwise it contains
830 -- the identification character for the typeref entity. See section
831 -- "Cross-Reference Entity Identifiers" in lib-xref.ads for details.
833 Tref_Col : Nat;
834 -- This field is set to zero if no typeref is present, or if the
835 -- typeref refers to an entity in standard. Otherwise it contains
836 -- the column number of the declaration of the parent type.
838 Tref_Standard_Entity : Name_Id;
839 -- This field is set to No_Name if no typeref is present or if the
840 -- typeref refers to a declared entity rather than an entity in
841 -- package Standard. If there is a typeref that references an
842 -- entity in package Standard, then this field is a Name_Id
843 -- reference for the entity name.
845 Oref_File_Num : Sdep_Id;
846 -- This field is set to No_Sdep_Id if the entity doesn't override any
847 -- other entity, or to the dependency reference for the overriden
848 -- entity.
850 Oref_Line : Nat;
851 Oref_Col : Nat;
852 -- These two fields are set to the line and column of the overriden
853 -- entity.
855 First_Xref : Nat;
856 -- Index into Xref table of first cross-reference
858 Last_Xref : Nat;
859 -- Index into Xref table of last cross-reference. The value in
860 -- Last_Xref can be less than the First_Xref value to indicate
861 -- that no entries are present in the Xref Table.
862 end record;
864 package Xref_Entity is new Table.Table (
865 Table_Component_Type => Xref_Entity_Record,
866 Table_Index_Type => Nat,
867 Table_Low_Bound => 1,
868 Table_Initial => 500,
869 Table_Increment => 300,
870 Table_Name => "Xref_Entity");
872 Array_Index_Reference : constant Character := '*';
873 Interface_Reference : constant Character := 'I';
874 -- Some special types of references. In the ALI file itself, these
875 -- are output as attributes of the entity, not as references, but
876 -- there is no provision in Xref_Entity_Record for storing multiple
877 -- such references.
879 -- The following table records actual cross-references
881 type Xref_Record is record
882 File_Num : Sdep_Id;
883 -- Set to the file dependency number for the cross-reference. Note
884 -- that if no file entry is present explicitly, this is just a copy
885 -- of the reference for the current cross-reference section.
887 Line : Nat;
888 -- Line number for the reference. This is zero when referencing a
889 -- predefined entity, but in this case Name is set.
891 Rtype : Character;
892 -- Indicates type of reference, using code used in ALI file:
893 -- r = reference
894 -- m = modification
895 -- b = body entity
896 -- c = completion of private or incomplete type
897 -- x = type extension
898 -- i = implicit reference
899 -- Array_Index_Reference = reference to the index of an array
900 -- Interface_Reference = reference to an interface implemented
901 -- by the type
902 -- See description in lib-xref.ads for further details
904 Col : Nat;
905 -- Column number for the reference
907 Name : Name_Id := No_Name;
908 -- This is only used when referencing a predefined entity. Currently,
909 -- this only occurs for array indexes.
911 -- Note: for instantiation references, Rtype is set to ' ', and Col is
912 -- set to zero. One or more such entries can follow any other reference.
913 -- When there is more than one such entry, this is to be read as:
914 -- e.g. ref1 ref2 ref3
915 -- ref1 is a reference to an entity that was instantied at ref2.
916 -- ref2 itself is also the result of an instantiation, that took
917 -- place at ref3
918 end record;
920 package Xref is new Table.Table (
921 Table_Component_Type => Xref_Record,
922 Table_Index_Type => Nat,
923 Table_Low_Bound => 1,
924 Table_Initial => 2000,
925 Table_Increment => 300,
926 Table_Name => "Xref");
928 --------------------------------------
929 -- Subprograms for Reading ALI File --
930 --------------------------------------
932 procedure Initialize_ALI;
933 -- Initialize the ALI tables. Also resets all switch values to defaults
935 function Scan_ALI
936 (F : File_Name_Type;
937 T : Text_Buffer_Ptr;
938 Ignore_ED : Boolean;
939 Err : Boolean;
940 Read_Xref : Boolean := False;
941 Read_Lines : String := "";
942 Ignore_Lines : String := "X";
943 Ignore_Errors : Boolean := False) return ALI_Id;
944 -- Given the text, T, of an ALI file, F, scan and store the information
945 -- from the file, and return the Id of the resulting entry in the ALI
946 -- table. Switch settings may be modified as described above in the
947 -- switch description settings.
949 -- Ignore_ED is normally False. If set to True, it indicates that
950 -- all AD/ED (elaboration desirable) indications in the ALI file are
951 -- to be ignored. This parameter is obsolete now that the -f switch
952 -- is removed from gnatbind, and should be removed ???
954 -- Err determines the action taken on an incorrectly formatted file.
955 -- If Err is False, then an error message is output, and the program
956 -- is terminated. If Err is True, then no error message is output,
957 -- and No_ALI_Id is returned.
959 -- Ignore_Lines requests that Scan_ALI ignore any lines that start
960 -- with any given key character. The default value of X causes all
961 -- Xref lines to be ignored. The corresponding data in the ALI
962 -- tables will not be filled in in this case. It is not possible
963 -- to ignore U (unit) lines, they are always read.
965 -- Read_Lines requests that Scan_ALI process only lines that start
966 -- with one of the given characters. The corresponding data in the
967 -- ALI file for any characters not given in the list will not be
968 -- set. The default value of the null string indicates that all
969 -- lines should be read (unless Ignore_Lines is specified). U
970 -- (unit) lines are always read regardless of the value of this
971 -- parameter.
973 -- Note: either Ignore_Lines or Read_Lines should be non-null.
974 -- but not both. If both are given then only the Read_Lines
975 -- value is processed, and the Ignore_Lines parameter is
976 -- not processed.
978 -- Read_XREF is set True to read and acquire the cross-reference
979 -- information. If Read_XREF is set to True, then the effect is
980 -- to ignore all lines other than U, W, D and X lines and the
981 -- Ignore_Lines and Read_Lines parameters are ignored (i.e. the
982 -- use of True for Read_XREF is equivalent to specifying an
983 -- argument of "UWDX" for Read_Lines.
985 -- Ignore_Errors is normally False. If it is set True, then Scan_ALI
986 -- will do its best to scan through a file and extract all information
987 -- it can, even if there are errors. In this case Err is only set if
988 -- Scan_ALI was completely unable to process the file (e.g. it did not
989 -- look like an ALI file at all). Ignore_Errors is intended to improve
990 -- the downward compatibility of new compilers with old tools.
992 end ALI;