PR tree-optimization/82929
[official-gcc.git] / gcc / ada / ali.ads
blob3fa4d99fb09c32c697de1c2180871e6919ec7de3
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A L I --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2017, 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 by
28 -- 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 type ALI_Id is range 0 .. 99_999_999;
46 -- Id values used for ALIs table entries
48 type Unit_Id is range 0 .. 99_999_999;
49 -- Id values used for Unit table entries
51 type With_Id is range 0 .. 99_999_999;
52 -- Id values used for Withs table entries
54 type Arg_Id is range 0 .. 99_999_999;
55 -- Id values used for argument table entries
57 type Sdep_Id is range 0 .. 99_999_999;
58 -- Id values used for Sdep table entries
60 type Source_Id is range 0 .. 99_999_999;
61 -- Id values used for Source table entries
63 type Interrupt_State_Id is range 0 .. 99_999_999;
64 -- Id values used for Interrupt_State table entries
66 type Priority_Specific_Dispatching_Id is range 0 .. 99_999_999;
67 -- Id values used for Priority_Specific_Dispatching table entries
69 --------------------
70 -- ALI File Table --
71 --------------------
73 -- Each ALI file read generates an entry in the ALIs table
75 No_ALI_Id : constant ALI_Id := ALI_Id'First;
76 -- Special value indicating no ALI entry
78 First_ALI_Entry : constant ALI_Id := No_ALI_Id + 1;
79 -- Id of first actual entry in table
81 type Main_Program_Type is (None, Proc, Func);
82 -- Indicator of whether unit can be used as main program
84 type ALIs_Record is record
86 Afile : File_Name_Type;
87 -- Name of ALI file
89 Ofile_Full_Name : File_Name_Type;
90 -- Full name of object file corresponding to the ALI file
92 Sfile : File_Name_Type;
93 -- Name of source file that generates this ALI file (which is equal
94 -- to the name of the source file in the first unit table entry for
95 -- this ALI file, since the body if present is always first).
97 Ver : String (1 .. Ver_Len_Max);
98 -- Value of library version (V line in ALI file). Not set if
99 -- V lines are ignored as a result of the Ignore_Lines parameter.
101 Ver_Len : Natural;
102 -- Length of characters stored in Ver. Not set if V lines are ignored as
103 -- a result of the Ignore_Lines parameter.
105 SAL_Interface : Boolean;
106 -- Set True when this is an interface to a standalone library
108 First_Unit : Unit_Id;
109 -- Id of first Unit table entry for this file
111 Last_Unit : Unit_Id;
112 -- Id of last Unit table entry for this file
114 First_Sdep : Sdep_Id;
115 -- Id of first Sdep table entry for this file
117 Last_Sdep : Sdep_Id;
118 -- Id of last Sdep table entry for this file
120 Main_Program : Main_Program_Type;
121 -- Indicator of whether first unit can be used as main program. Not set
122 -- if 'M' appears in Ignore_Lines.
124 Main_Priority : Int;
125 -- Indicates priority value if Main_Program field indicates that this
126 -- can be a main program. A value of -1 (No_Main_Priority) indicates
127 -- that no parameter was found, or no M line was present. Not set if
128 -- 'M' appears in Ignore_Lines.
130 Main_CPU : Int;
131 -- Indicates processor if Main_Program field indicates that this can
132 -- be a main program. A value of -1 (No_Main_CPU) indicates that no C
133 -- parameter was found, or no M line was present. Not set if 'M' appears
134 -- in Ignore_Lines.
136 Time_Slice_Value : Int;
137 -- Indicates value of time slice parameter from T=xxx on main program
138 -- line. A value of -1 indicates that no T=xxx parameter was found, or
139 -- no M line was present. Not set if 'M' appears in Ignore_Lines.
141 WC_Encoding : Character;
142 -- Wide character encoding if main procedure. Otherwise not relevant.
143 -- Not set if 'M' appears in Ignore_Lines.
145 Locking_Policy : Character;
146 -- Indicates locking policy for units in this file. Space means tasking
147 -- was not used, or that no Locking_Policy pragma was present or that
148 -- this is a language defined unit. Otherwise set to first character
149 -- (upper case) of policy name. Not set if 'P' appears in Ignore_Lines.
151 Partition_Elaboration_Policy : Character;
152 -- Indicates partition elaboration policy for units in this file. Space
153 -- means that no Partition_Elaboration_Policy pragma was present or that
154 -- this is a language defined unit. Otherwise set to first character
155 -- (upper case) of policy name. Not set if 'P' appears in Ignore_Lines.
157 Queuing_Policy : Character;
158 -- Indicates queuing policy for units in this file. Space means tasking
159 -- was not used, or that no Queuing_Policy pragma was present or that
160 -- this is a language defined unit. Otherwise set to first character
161 -- (upper case) of policy name. Not set if 'P' appears in Ignore_Lines.
163 Task_Dispatching_Policy : Character;
164 -- Indicates task dispatching policy for units in this file. Space means
165 -- tasking was not used, or that no Task_Dispatching_Policy pragma was
166 -- present or that this is a language defined unit. Otherwise set to
167 -- first character (upper case) of policy name. Not set if 'P' appears
168 -- in Ignore_Lines.
170 Compile_Errors : Boolean;
171 -- Set to True if compile errors for unit. Note that No_Object will
172 -- always be set as well in this case. Not set if 'P' appears in
173 -- Ignore_Lines.
175 GNATprove_Mode : Boolean;
176 -- Set to True if ALI and object file produced in GNATprove_Mode as
177 -- signalled by GP appearing on the P line. Not set if 'P' appears in
178 -- Ignore_Lines.
180 No_Component_Reordering : Boolean;
181 -- Set to True if file was compiled with a configuration pragma file
182 -- containing pragma No_Component_Reordering. Not set if 'P' appears
183 -- in Ignore_Lines.
185 No_Object : Boolean;
186 -- Set to True if no object file generated. Not set if 'P' appears in
187 -- Ignore_Lines.
189 Normalize_Scalars : Boolean;
190 -- Set to True if file was compiled with Normalize_Scalars. Not set if
191 -- 'P' appears in Ignore_Lines.
193 SSO_Default : Character;
194 -- Set to 'H' or 'L' if file was compiled with a configuration pragma
195 -- file containing Default_Scalar_Storage_Order (High/Low_Order_First).
196 -- Set to ' ' if neither pragma was present. Not set if 'P' appears in
197 -- Ignore_Lines.
199 Unit_Exception_Table : Boolean;
200 -- Set to True if unit exception table pointer generated. Not set if 'P'
201 -- appears in Ignore_Lines.
203 Frontend_Exceptions : Boolean;
204 -- Set to True if file was compiled with front-end exceptions. Not set
205 -- if 'P' appears in Ignore_Lines.
207 Zero_Cost_Exceptions : Boolean;
208 -- Set to True if file was compiled with zero cost exceptions. Not set
209 -- if 'P' appears in Ignore_Lines.
211 Restrictions : Restrictions_Info;
212 -- Restrictions information reconstructed from R lines
214 First_Interrupt_State : Interrupt_State_Id;
215 Last_Interrupt_State : Interrupt_State_Id'Base;
216 -- These point to the first and last entries in the interrupt state
217 -- table for this unit. If no entries, then Last_Interrupt_State =
218 -- First_Interrupt_State - 1 (that's why the 'Base reference is there,
219 -- it can be one less than the lower bound of the subtype). Not set if
220 -- 'I' appears in Ignore_Lines
222 First_Specific_Dispatching : Priority_Specific_Dispatching_Id;
223 Last_Specific_Dispatching : Priority_Specific_Dispatching_Id'Base;
224 -- These point to the first and last entries in the priority specific
225 -- dispatching table for this unit. If there are no entries, then
226 -- Last_Specific_Dispatching = First_Specific_Dispatching - 1. That
227 -- is why the 'Base reference is there, it can be one less than the
228 -- lower bound of the subtype. Not set if 'S' appears in Ignore_Lines.
230 end record;
232 No_Main_Priority : constant Int := -1;
233 -- Code for no main priority set
235 No_Main_CPU : constant Int := -1;
236 -- Code for no main cpu set
238 package ALIs is new Table.Table (
239 Table_Component_Type => ALIs_Record,
240 Table_Index_Type => ALI_Id,
241 Table_Low_Bound => First_ALI_Entry,
242 Table_Initial => 500,
243 Table_Increment => 200,
244 Table_Name => "ALIs");
246 ----------------
247 -- Unit Table --
248 ----------------
250 -- Each unit within an ALI file generates an entry in the unit table
252 No_Unit_Id : constant Unit_Id := Unit_Id'First;
253 -- Special value indicating no unit table entry
255 First_Unit_Entry : constant Unit_Id := No_Unit_Id + 1;
256 -- Id of first actual entry in table
258 type Unit_Type is (Is_Spec, Is_Body, Is_Spec_Only, Is_Body_Only);
259 -- Indicates type of entry, if both body and spec appear in the ALI file,
260 -- then the first unit is marked Is_Body, and the second is marked Is_Spec.
261 -- If only a spec appears, then it is marked as Is_Spec_Only, and if only
262 -- a body appears, then it is marked Is_Body_Only).
264 subtype Version_String is String (1 .. 8);
265 -- Version string, taken from unit record
267 type Unit_Record is record
269 My_ALI : ALI_Id;
270 -- Corresponding ALI entry
272 Uname : Unit_Name_Type;
273 -- Name of Unit
275 Sfile : File_Name_Type;
276 -- Name of source file
278 Preelab : Boolean;
279 -- Indicates presence of PR parameter for a preelaborated package
281 No_Elab : Boolean;
282 -- Indicates presence of NE parameter for a unit that has does not
283 -- have an elaboration routine (since it has no elaboration code).
285 Pure : Boolean;
286 -- Indicates presence of PU parameter for a package having pragma Pure
288 Dynamic_Elab : Boolean;
289 -- Set to True if the unit was compiled with dynamic elaboration checks
290 -- (i.e. either -gnatE or pragma Elaboration_Checks (RM) was used to
291 -- compile the unit).
293 Elaborate_Body : Boolean;
294 -- Indicates presence of EB parameter for a package which has a pragma
295 -- Elaborate_Body, and also for generic package instantiations.
297 Set_Elab_Entity : Boolean;
298 -- Indicates presence of EE parameter for a unit which has an
299 -- elaboration entity which must be set true as part of the
300 -- elaboration of the unit.
302 Has_RACW : Boolean;
303 -- Indicates presence of RA parameter for a package that declares at
304 -- least one Remote Access to Class_Wide (RACW) object.
306 Remote_Types : Boolean;
307 -- Indicates presence of RT parameter for a package which has a
308 -- pragma Remote_Types.
310 Serious_Errors : Boolean;
311 -- Indicates presence of SE parameter indicating that compilation of
312 -- the unit encountered as serious error.
314 Shared_Passive : Boolean;
315 -- Indicates presence of SP parameter for a package which has a pragma
316 -- Shared_Passive.
318 RCI : Boolean;
319 -- Indicates presence of RC parameter for a package which has a pragma
320 -- Remote_Call_Interface.
322 Predefined : Boolean;
323 -- Indicates if unit is language predefined (or a child of such a unit)
325 Internal : Boolean;
326 -- Indicates if unit is an internal unit (or a child of such a unit)
328 First_With : With_Id;
329 -- Id of first withs table entry for this file
331 Last_With : With_Id;
332 -- Id of last withs table entry for this file
334 First_Arg : Arg_Id;
335 -- Id of first args table entry for this file
337 Last_Arg : Arg_Id;
338 -- Id of last args table entry for this file
340 Utype : Unit_Type;
341 -- Type of entry
343 Is_Generic : Boolean;
344 -- True for generic unit (i.e. a generic declaration, or a generic
345 -- body). False for a non-generic unit.
347 Unit_Kind : Character;
348 -- Indicates the nature of the unit. 'p' for Packages and 's' for
349 -- subprograms.
351 Version : Version_String;
352 -- Version of unit
354 Icasing : Casing_Type;
355 -- Indicates casing of identifiers in source file for this unit. This
356 -- is used for informational output, and also for constructing the main
357 -- unit if it is being built in Ada.
359 Kcasing : Casing_Type;
360 -- Indicates casing of keywords in source file for this unit. This is
361 -- used for informational output, and also for constructing the main
362 -- unit if it is being built in Ada.
364 Elab_Position : Nat;
365 -- Initialized to zero. Set non-zero when a unit is chosen and
366 -- placed in the elaboration order. The value represents the
367 -- ordinal position in the elaboration order.
369 Init_Scalars : Boolean;
370 -- Set True if IS qualifier appears in ALI file, indicating that
371 -- an Initialize_Scalars pragma applies to the unit.
373 SAL_Interface : Boolean;
374 -- Set True when this is an interface to a standalone library
376 Directly_Scanned : Boolean;
377 -- True iff it is a unit from an ALI file specified to gnatbind
379 Body_Needed_For_SAL : Boolean;
380 -- Indicates that the source for the body of the unit (subprogram,
381 -- package, or generic unit) must be included in a standalone library.
383 Elaborate_Body_Desirable : Boolean;
384 -- Indicates that the front end elaboration circuitry decided that it
385 -- would be a good idea if this package had Elaborate_Body. The binder
386 -- will attempt, but does not promise, to place the elaboration call
387 -- for the body right after the call for the spec, or at least as close
388 -- together as possible.
390 Optimize_Alignment : Character;
391 -- Optimize_Alignment setting. Set to L/S/T/O for OL/OS/OT/OO present.
393 Has_Finalizer : Boolean;
394 -- Indicates whether a package body or a spec has a library-level
395 -- finalization routine.
397 Primary_Stack_Count : Int;
398 -- Indicates the number of task objects declared in this unit that have
399 -- default sized primary stacks.
401 Sec_Stack_Count : Int;
402 -- Indicates the number of task objects declared in this unit that have
403 -- default sized secondary stacks.
404 end record;
406 package Units is new Table.Table (
407 Table_Component_Type => Unit_Record,
408 Table_Index_Type => Unit_Id,
409 Table_Low_Bound => First_Unit_Entry,
410 Table_Initial => 100,
411 Table_Increment => 200,
412 Table_Name => "Unit");
414 ---------------------------
415 -- Interrupt State Table --
416 ---------------------------
418 -- An entry is made in this table for each I (interrupt state) line
419 -- encountered in the input ALI file. The First/Last_Interrupt_Id
420 -- fields of the ALI file entry show the range of entries defined
421 -- within a particular ALI file.
423 type Interrupt_State_Record is record
424 Interrupt_Id : Nat;
425 -- Id from interrupt state entry
427 Interrupt_State : Character;
428 -- State from interrupt state entry ('u'/'r'/'s')
430 IS_Pragma_Line : Nat;
431 -- Line number of Interrupt_State pragma
432 end record;
434 package Interrupt_States is new Table.Table (
435 Table_Component_Type => Interrupt_State_Record,
436 Table_Index_Type => Interrupt_State_Id'Base,
437 Table_Low_Bound => Interrupt_State_Id'First,
438 Table_Initial => 100,
439 Table_Increment => 200,
440 Table_Name => "Interrupt_States");
442 -----------------------------------------
443 -- Priority Specific Dispatching Table --
444 -----------------------------------------
446 -- An entry is made in this table for each S (priority specific
447 -- dispatching) line encountered in the input ALI file. The
448 -- First/Last_Specific_Dispatching_Id fields of the ALI file
449 -- entry show the range of entries defined within a particular
450 -- ALI file.
452 type Specific_Dispatching_Record is record
453 Dispatching_Policy : Character;
454 -- First character (upper case) of the corresponding policy name
456 First_Priority : Nat;
457 -- Lower bound of the priority range to which the specified dispatching
458 -- policy applies.
460 Last_Priority : Nat;
461 -- Upper bound of the priority range to which the specified dispatching
462 -- policy applies.
464 PSD_Pragma_Line : Nat;
465 -- Line number of Priority_Specific_Dispatching pragma
466 end record;
468 package Specific_Dispatching is new Table.Table (
469 Table_Component_Type => Specific_Dispatching_Record,
470 Table_Index_Type => Priority_Specific_Dispatching_Id'Base,
471 Table_Low_Bound => Priority_Specific_Dispatching_Id'First,
472 Table_Initial => 100,
473 Table_Increment => 200,
474 Table_Name => "Priority_Specific_Dispatching");
476 --------------
477 -- Switches --
478 --------------
480 -- These switches record status information about ali files that
481 -- have been read, for quick reference without searching tables.
483 -- Note: a switch will be left set at its default value if the line
484 -- which might otherwise set it is ignored (from Ignore_Lines).
486 Dynamic_Elaboration_Checks_Specified : Boolean := False;
487 -- Set to False by Initialize_ALI. Set to True if Scan_ALI reads
488 -- a unit for which dynamic elaboration checking is enabled.
490 Frontend_Exceptions_Specified : Boolean := False;
491 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
492 -- has a P line specifying the generation of front-end exceptions.
494 GNATprove_Mode_Specified : Boolean := False;
495 -- Set to True if an ali file was produced in GNATprove mode.
497 Initialize_Scalars_Used : Boolean := False;
498 -- Set True if an ali file contains the Initialize_Scalars flag
500 Locking_Policy_Specified : Character := ' ';
501 -- Set to blank by Initialize_ALI. Set to the appropriate locking policy
502 -- character if an ali file contains a P line setting the locking policy.
504 No_Normalize_Scalars_Specified : Boolean := False;
505 -- Set to False by Initialize_ALI. Set to True if an ali file indicates
506 -- that the file was compiled without normalize scalars.
508 No_Component_Reordering_Specified : Boolean := False;
509 -- Set to False by Initialize_ALI. Set to True if an ali file contains
510 -- the No_Component_Reordering flag.
512 No_Object_Specified : Boolean := False;
513 -- Set to False by Initialize_ALI. Set to True if an ali file contains
514 -- the No_Object flag.
516 Normalize_Scalars_Specified : Boolean := False;
517 -- Set to False by Initialize_ALI. Set to True if an ali file indicates
518 -- that the file was compiled in Normalize_Scalars mode.
520 Partition_Elaboration_Policy_Specified : Character := ' ';
521 -- Set to blank by Initialize_ALI. Set to the appropriate partition
522 -- elaboration policy character if an ali file contains a P line setting
523 -- the policy.
525 Queuing_Policy_Specified : Character := ' ';
526 -- Set to blank by Initialize_ALI. Set to the appropriate queuing policy
527 -- character if an ali file contains a P line setting the queuing policy.
529 Cumulative_Restrictions : Restrictions_Info := No_Restrictions;
530 -- This variable records the cumulative contributions of R lines in all
531 -- ali files, showing whether a restriction pragma exists anywhere, and
532 -- accumulating the aggregate knowledge of violations.
534 SSO_Default_Specified : Boolean := False;
535 -- Set to True if at least one ALI file contains an OH/OL flag indicating
536 -- that it was compiled with a configuration pragmas file containing the
537 -- pragma Default_Scalar_Storage_Order (OH/OL present in ALI file P line).
539 Stack_Check_Switch_Set : Boolean := False;
540 -- Set to True if at least one ALI file contains '-fstack-check' in its
541 -- argument list.
543 Task_Dispatching_Policy_Specified : Character := ' ';
544 -- Set to blank by Initialize_ALI. Set to the appropriate task dispatching
545 -- policy character if an ali file contains a P line setting the
546 -- task dispatching policy.
548 Unreserve_All_Interrupts_Specified : Boolean := False;
549 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
550 -- has P line specifying unreserve all interrupts mode.
552 Zero_Cost_Exceptions_Specified : Boolean := False;
553 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
554 -- has a P line specifying the generation of zero cost exceptions.
556 -----------------
557 -- Withs Table --
558 -----------------
560 -- Each With line (W line) in an ALI file generates a Withs table entry
562 -- Note: there will be no entries in this table if 'W' lines are ignored
564 No_With_Id : constant With_Id := With_Id'First;
565 -- Special value indicating no withs table entry
567 First_With_Entry : constant With_Id := No_With_Id + 1;
568 -- Id of first actual entry in table
570 type With_Record is record
572 Uname : Unit_Name_Type;
573 -- Name of Unit
575 Sfile : File_Name_Type;
576 -- Name of source file, set to No_File in generic case
578 Afile : File_Name_Type;
579 -- Name of ALI file, set to No_File in generic case
581 Elaborate : Boolean;
582 -- Indicates presence of E parameter
584 Elaborate_All : Boolean;
585 -- Indicates presence of EA parameter
587 Elab_All_Desirable : Boolean;
588 -- Indicates presence of AD parameter
590 Elab_Desirable : Boolean;
591 -- Indicates presence of ED parameter
593 SAL_Interface : Boolean := False;
594 -- True if the Unit is an Interface of a Stand-Alone Library
596 Limited_With : Boolean := False;
597 -- True if unit is named in a limited_with_clause
599 Implicit_With_From_Instantiation : Boolean := False;
600 -- True if this is an implicit with from a generic instantiation
601 end record;
603 package Withs is new Table.Table (
604 Table_Component_Type => With_Record,
605 Table_Index_Type => With_Id,
606 Table_Low_Bound => First_With_Entry,
607 Table_Initial => 5000,
608 Table_Increment => 200,
609 Table_Name => "Withs");
611 ---------------------
612 -- Arguments Table --
613 ---------------------
615 -- Each Arg line (A line) in an ALI file generates an Args table entry
617 -- Note: there will be no entries in this table if 'A' lines are ignored
619 No_Arg_Id : constant Arg_Id := Arg_Id'First;
620 -- Special value indicating no args table entry
622 First_Arg_Entry : constant Arg_Id := No_Arg_Id + 1;
623 -- Id of first actual entry in table
625 package Args is new Table.Table (
626 Table_Component_Type => String_Ptr,
627 Table_Index_Type => Arg_Id,
628 Table_Low_Bound => First_Arg_Entry,
629 Table_Initial => 1000,
630 Table_Increment => 100,
631 Table_Name => "Args");
633 --------------------------
634 -- Linker_Options Table --
635 --------------------------
637 -- If an ALI file has one of more Linker_Options lines, then a single
638 -- entry is made in this table. If more than one Linker_Options lines
639 -- appears in a given ALI file, then the arguments are concatenated
640 -- to form the entry in this table, using a NUL character as the
641 -- separator, and a final NUL character is appended to the end.
643 -- Note: there will be no entries in this table if 'L' lines are ignored
645 type Linker_Option_Record is record
646 Name : Name_Id;
647 -- Name entry containing concatenated list of Linker_Options
648 -- arguments separated by NUL and ended by NUL as described above.
650 Unit : Unit_Id;
651 -- Unit_Id for the entry
653 Internal_File : Boolean;
654 -- Set True if the linker options are from an internal file. This is
655 -- used to insert certain standard entries after all the user entries
656 -- but before the entries from the run-time.
658 Original_Pos : Positive;
659 -- Keep track of original position in the linker options table. This
660 -- is used to implement a stable sort when we sort the linker options
661 -- table.
662 end record;
664 -- The indexes of active entries in this table range from 1 to the
665 -- value of Linker_Options.Last. The zero'th element is for sort call.
667 package Linker_Options is new Table.Table (
668 Table_Component_Type => Linker_Option_Record,
669 Table_Index_Type => Integer,
670 Table_Low_Bound => 0,
671 Table_Initial => 200,
672 Table_Increment => 400,
673 Table_Name => "Linker_Options");
675 -----------------
676 -- Notes Table --
677 -----------------
679 -- The notes table records entries from N lines
681 type Notes_Record is record
682 Pragma_Type : Character;
683 -- 'A', 'C', 'I', 'S', 'T' for Annotate/Comment/Ident/Subtitle/Title
685 Pragma_Line : Nat;
686 -- Line number of pragma
688 Pragma_Col : Nat;
689 -- Column number of pragma
691 Pragma_Source_File : File_Name_Type;
692 -- Source file of pragma
694 Pragma_Args : Name_Id;
695 -- Pragma arguments. No_Name if no arguments, otherwise a single
696 -- name table entry consisting of all the characters on the notes
697 -- line from the first non-blank character following the source
698 -- location to the last character on the line.
699 end record;
701 -- The indexes of active entries in this table range from 1 to the
702 -- value of Linker_Options.Last. The zero'th element is for convenience
703 -- if the table needs to be sorted.
705 package Notes is new Table.Table (
706 Table_Component_Type => Notes_Record,
707 Table_Index_Type => Integer,
708 Table_Low_Bound => 0,
709 Table_Initial => 200,
710 Table_Increment => 400,
711 Table_Name => "Notes");
713 -------------------------------------------
714 -- External Version Reference Hash Table --
715 -------------------------------------------
717 -- This hash table keeps track of external version reference strings
718 -- as read from E lines in the ali file. The stored values do not
719 -- include the terminating quote characters.
721 -- Note: there will be no entries in this table if 'E' lines are ignored
723 type Vindex is range 0 .. 98;
724 -- Type to define range of headers
726 function SHash (S : String_Ptr) return Vindex;
727 -- Hash function for this table
729 function SEq (F1, F2 : String_Ptr) return Boolean;
730 -- Equality function for this table
732 package Version_Ref is new Simple_HTable (
733 Header_Num => Vindex,
734 Element => Boolean,
735 No_Element => False,
736 Key => String_Ptr,
737 Hash => SHash,
738 Equal => SEq);
740 -------------------------
741 -- No_Dependency Table --
742 -------------------------
744 -- Each R line for a No_Dependency Restriction generates an entry in
745 -- this No_Dependency table.
747 type No_Dep_Record is record
748 ALI_File : ALI_Id;
749 -- ALI File containing the entry
751 No_Dep_Unit : Name_Id;
752 -- Id for names table entry including entire name, including periods
753 end record;
755 package No_Deps is new Table.Table (
756 Table_Component_Type => No_Dep_Record,
757 Table_Index_Type => Integer,
758 Table_Low_Bound => 0,
759 Table_Initial => 200,
760 Table_Increment => 400,
761 Table_Name => "No_Deps");
763 ------------------------------------
764 -- Sdep (Source Dependency) Table --
765 ------------------------------------
767 -- Each source dependency (D line) in an ALI file generates an entry in the
768 -- Sdep table.
770 -- Note: there will be no entries in this table if 'D' lines are ignored
772 No_Sdep_Id : constant Sdep_Id := Sdep_Id'First;
773 -- Special value indicating no Sdep table entry
775 First_Sdep_Entry : Sdep_Id := No_Sdep_Id + 1;
776 -- Id of first Sdep entry for current ali file. This is initialized to the
777 -- first Sdep entry in the table, and then incremented appropriately as
778 -- successive ALI files are scanned.
780 type Sdep_Record is record
782 Sfile : File_Name_Type;
783 -- Name of source file
785 Stamp : Time_Stamp_Type;
786 -- Time stamp value. Note that this will be all zero characters for the
787 -- dummy entries for missing or non-dependent files.
789 Checksum : Word;
790 -- Checksum value. Note that this will be all zero characters for the
791 -- dummy entries for missing or non-dependent files
793 Dummy_Entry : Boolean;
794 -- Set True for dummy entries that correspond to missing files or files
795 -- where no dependency relationship exists.
797 Subunit_Name : Name_Id;
798 -- Name_Id for subunit name if present, else No_Name
800 Unit_Name : Name_Id;
801 -- Name_Id for the unit name if not a subunit (No_Name for a subunit)
802 Rfile : File_Name_Type;
803 -- Reference file name. Same as Sfile unless a Source_Reference pragma
804 -- was used, in which case it reflects the name used in the pragma.
806 Start_Line : Nat;
807 -- Starting line number in file. Always 1, unless a Source_Reference
808 -- pragma was used, in which case it reflects the line number value
809 -- given in the pragma.
811 end record;
813 package Sdep is new Table.Table (
814 Table_Component_Type => Sdep_Record,
815 Table_Index_Type => Sdep_Id,
816 Table_Low_Bound => First_Sdep_Entry,
817 Table_Initial => 5000,
818 Table_Increment => 200,
819 Table_Name => "Sdep");
821 ----------------------------
822 -- Use of Name Table Info --
823 ----------------------------
825 -- All unit names and file names are entered into the Names table. The Info
826 -- fields of these entries are used as follows:
828 -- Unit name Info field has Unit_Id of unit table entry
829 -- ALI file name Info field has ALI_Id of ALI table entry
830 -- Source file name Info field has Source_Id of source table entry
832 --------------------------
833 -- Cross-Reference Data --
834 --------------------------
836 -- The following table records cross-reference sections, there is one entry
837 -- for each X header line in the ALI file for an xref section.
839 -- Note: there will be no entries in this table if 'X' lines are ignored
841 type Xref_Section_Record is record
842 File_Num : Sdep_Id;
843 -- Dependency number for file (entry in Sdep.Table)
845 File_Name : File_Name_Type;
846 -- Name of file
848 First_Entity : Nat;
849 -- First entry in Xref_Entity table
851 Last_Entity : Nat;
852 -- Last entry in Xref_Entity table
853 end record;
855 package Xref_Section is new Table.Table (
856 Table_Component_Type => Xref_Section_Record,
857 Table_Index_Type => Nat,
858 Table_Low_Bound => 1,
859 Table_Initial => 50,
860 Table_Increment => 300,
861 Table_Name => "Xref_Section");
863 -- The following is used to indicate whether a typeref field is present
864 -- for the entity, and if so what kind of typeref field.
866 type Tref_Kind is (
867 Tref_None, -- No typeref present
868 Tref_Access, -- Access type typeref (points to designated type)
869 Tref_Derived, -- Derived type typeref (points to parent type)
870 Tref_Type); -- All other cases
872 type Visibility_Kind is
873 (Global, -- Library level entity
874 Static, -- Static C/C++ entity
875 Other); -- Local and other entity
877 -- The following table records entities for which xrefs are recorded
879 type Xref_Entity_Record is record
880 Line : Pos;
881 -- Line number of definition
883 Etype : Character;
884 -- Set to the identification character for the entity. See section
885 -- "Cross-Reference Entity Identifiers" in lib-xref.ads for details.
887 Col : Pos;
888 -- Column number of definition
890 Visibility : Visibility_Kind;
891 -- Visibility of entity
893 Entity : Name_Id;
894 -- Name of entity
896 Iref_File_Num : Sdep_Id;
897 -- This field is set to the dependency reference for the file containing
898 -- the generic entity that this one instantiates, or to No_Sdep_Id if
899 -- the current entity is not an instantiation
901 Iref_Line : Nat;
902 -- This field is set to the line number in Iref_File_Num of the generic
903 -- entity that this one instantiates, or to zero if the current entity
904 -- is not an instantiation.
906 Rref_Line : Nat;
907 -- This field is set to the line number of a renaming reference if
908 -- one is present, or to zero if no renaming reference is present
910 Rref_Col : Nat;
911 -- This field is set to the column number of a renaming reference
912 -- if one is present, or to zero if no renaming reference is present.
914 Tref : Tref_Kind;
915 -- Indicates if a typeref is present, and if so what kind. Set to
916 -- Tref_None if no typeref field is present.
918 Tref_File_Num : Sdep_Id;
919 -- This field is set to No_Sdep_Id if no typeref is present, or
920 -- if the typeref refers to an entity in standard. Otherwise it
921 -- it is the dependency reference for the file containing the
922 -- declaration of the typeref entity.
924 Tref_Line : Nat;
925 -- This field is set to zero if no typeref is present, or if the
926 -- typeref refers to an entity in standard. Otherwise it contains
927 -- the line number of the declaration of the typeref entity.
929 Tref_Type : Character;
930 -- This field is set to blank if no typeref is present, or if the
931 -- typeref refers to an entity in standard. Otherwise it contains
932 -- the identification character for the typeref entity. See section
933 -- "Cross-Reference Entity Identifiers" in lib-xref.ads for details.
935 Tref_Col : Nat;
936 -- This field is set to zero if no typeref is present, or if the
937 -- typeref refers to an entity in standard. Otherwise it contains
938 -- the column number of the declaration of the parent type.
940 Tref_Standard_Entity : Name_Id;
941 -- This field is set to No_Name if no typeref is present or if the
942 -- typeref refers to a declared entity rather than an entity in
943 -- package Standard. If there is a typeref that references an
944 -- entity in package Standard, then this field is a Name_Id
945 -- reference for the entity name.
947 Oref_File_Num : Sdep_Id;
948 -- This field is set to No_Sdep_Id if the entity doesn't override any
949 -- other entity, or to the dependency reference for the overridden
950 -- entity.
952 Oref_Line : Nat;
953 Oref_Col : Nat;
954 -- These two fields are set to the line and column of the overridden
955 -- entity.
957 First_Xref : Nat;
958 -- Index into Xref table of first cross-reference
960 Last_Xref : Nat;
961 -- Index into Xref table of last cross-reference. The value in
962 -- Last_Xref can be less than the First_Xref value to indicate
963 -- that no entries are present in the Xref Table.
964 end record;
966 package Xref_Entity is new Table.Table (
967 Table_Component_Type => Xref_Entity_Record,
968 Table_Index_Type => Nat,
969 Table_Low_Bound => 1,
970 Table_Initial => 500,
971 Table_Increment => 300,
972 Table_Name => "Xref_Entity");
974 Array_Index_Reference : constant Character := '*';
975 Interface_Reference : constant Character := 'I';
976 -- Some special types of references. In the ALI file itself, these
977 -- are output as attributes of the entity, not as references, but
978 -- there is no provision in Xref_Entity_Record for storing multiple
979 -- such references.
981 -- The following table records actual cross-references
983 type Xref_Record is record
984 File_Num : Sdep_Id;
985 -- Set to the file dependency number for the cross-reference. Note
986 -- that if no file entry is present explicitly, this is just a copy
987 -- of the reference for the current cross-reference section.
989 Line : Nat;
990 -- Line number for the reference. This is zero when referencing a
991 -- predefined entity, but in this case Name is set.
993 Rtype : Character;
994 -- Indicates type of reference, using code used in ALI file:
995 -- r = reference
996 -- m = modification
997 -- b = body entity
998 -- c = completion of private or incomplete type
999 -- x = type extension
1000 -- i = implicit reference
1001 -- Array_Index_Reference = reference to the index of an array
1002 -- Interface_Reference = reference to an interface implemented
1003 -- by the type
1004 -- See description in lib-xref.ads for further details
1006 Col : Nat;
1007 -- Column number for the reference
1009 Name : Name_Id := No_Name;
1010 -- This is only used when referencing a predefined entity. Currently,
1011 -- this only occurs for array indexes.
1013 -- Note: for instantiation references, Rtype is set to ' ', and Col is
1014 -- set to zero. One or more such entries can follow any other reference.
1015 -- When there is more than one such entry, this is to be read as:
1016 -- e.g. ref1 ref2 ref3
1017 -- ref1 is a reference to an entity that was instantied at ref2.
1018 -- ref2 itself is also the result of an instantiation, that took
1019 -- place at ref3
1021 Imported_Lang : Name_Id := No_Name;
1022 Imported_Name : Name_Id := No_Name;
1023 -- Language and name of imported entity reference
1024 end record;
1026 package Xref is new Table.Table (
1027 Table_Component_Type => Xref_Record,
1028 Table_Index_Type => Nat,
1029 Table_Low_Bound => 1,
1030 Table_Initial => 2000,
1031 Table_Increment => 300,
1032 Table_Name => "Xref");
1034 --------------------------------------
1035 -- Subprograms for Reading ALI File --
1036 --------------------------------------
1038 procedure Initialize_ALI;
1039 -- Initialize the ALI tables. Also resets all switch values to defaults
1041 function Scan_ALI
1042 (F : File_Name_Type;
1043 T : Text_Buffer_Ptr;
1044 Ignore_ED : Boolean;
1045 Err : Boolean;
1046 Read_Xref : Boolean := False;
1047 Read_Lines : String := "";
1048 Ignore_Lines : String := "X";
1049 Ignore_Errors : Boolean := False;
1050 Directly_Scanned : Boolean := False) return ALI_Id;
1051 -- Given the text, T, of an ALI file, F, scan and store the information
1052 -- from the file, and return the Id of the resulting entry in the ALI
1053 -- table. Switch settings may be modified as described above in the
1054 -- switch description settings.
1056 -- Ignore_ED is normally False. If set to True, it indicates that
1057 -- all AD/ED (elaboration desirable) indications in the ALI file are
1058 -- to be ignored. This parameter is obsolete now that the -f switch
1059 -- is removed from gnatbind, and should be removed ???
1061 -- Err determines the action taken on an incorrectly formatted file.
1062 -- If Err is False, then an error message is output, and the program
1063 -- is terminated. If Err is True, then no error message is output,
1064 -- and No_ALI_Id is returned.
1066 -- Ignore_Lines requests that Scan_ALI ignore any lines that start
1067 -- with any given key character. The default value of X causes all
1068 -- Xref lines to be ignored. The corresponding data in the ALI
1069 -- tables will not be filled in this case. It is not possible
1070 -- to ignore U (unit) lines, they are always read.
1072 -- Read_Lines requests that Scan_ALI process only lines that start
1073 -- with one of the given characters. The corresponding data in the
1074 -- ALI file for any characters not given in the list will not be
1075 -- set. The default value of the null string indicates that all
1076 -- lines should be read (unless Ignore_Lines is specified). U
1077 -- (unit) lines are always read regardless of the value of this
1078 -- parameter.
1080 -- Note: either Ignore_Lines or Read_Lines should be non-null, but not
1081 -- both. If both are provided then only the Read_Lines value is used,
1082 -- and the Ignore_Lines parameter is ignored.
1084 -- Read_XREF is set True to read and acquire the cross-reference
1085 -- information. If Read_XREF is set to True, then the effect is to ignore
1086 -- all lines other than U, W, D and X lines and the Ignore_Lines and
1087 -- Read_Lines parameters are ignored (i.e. the use of True for Read_XREF
1088 -- is equivalent to specifying an argument of "UWDX" for Read_Lines.
1090 -- Ignore_Errors is normally False. If it is set True, then Scan_ALI
1091 -- will do its best to scan through a file and extract all information
1092 -- it can, even if there are errors. In this case Err is only set if
1093 -- Scan_ALI was completely unable to process the file (e.g. it did not
1094 -- look like an ALI file at all). Ignore_Errors is intended to improve
1095 -- the downward compatibility of new compilers with old tools.
1097 -- Directly_Scanned is normally False. If it is set to True, then the
1098 -- units (spec and/or body) corresponding to the ALI file are marked as
1099 -- such. It is used to decide for what units gnatbind should generate
1100 -- the symbols corresponding to 'Version or 'Body_Version in
1101 -- Stand-Alone Libraries.
1103 end ALI;