* lto.c (do_stream_out): Add PART parameter; open dump file.
[official-gcc.git] / gcc / ada / ali.ads
blobaaf0110ae13042841d2efc40bf9c5ff5938bc5eb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A L I --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2018, 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
85 Afile : File_Name_Type;
86 -- Name of ALI file
88 Ofile_Full_Name : File_Name_Type;
89 -- Full name of object file corresponding to the ALI file
91 Sfile : File_Name_Type;
92 -- Name of source file that generates this ALI file (which is equal
93 -- to the name of the source file in the first unit table entry for
94 -- this ALI file, since the body if present is always first).
96 Ver : String (1 .. Ver_Len_Max);
97 -- Value of library version (V line in ALI file). Not set if
98 -- V lines are ignored as a result of the Ignore_Lines parameter.
100 Ver_Len : Natural;
101 -- Length of characters stored in Ver. Not set if V lines are ignored as
102 -- a result of the Ignore_Lines parameter.
104 SAL_Interface : Boolean;
105 -- Set True when this is an interface to a standalone library
107 First_Unit : Unit_Id;
108 -- Id of first Unit table entry for this file
110 Last_Unit : Unit_Id;
111 -- Id of last Unit table entry for this file
113 First_Sdep : Sdep_Id;
114 -- Id of first Sdep table entry for this file
116 Last_Sdep : Sdep_Id;
117 -- Id of last Sdep table entry for this file
119 Main_Program : Main_Program_Type;
120 -- Indicator of whether first unit can be used as main program. Not set
121 -- if 'M' appears in Ignore_Lines.
123 Main_Priority : Int;
124 -- Indicates priority value if Main_Program field indicates that this
125 -- can be a main program. A value of -1 (No_Main_Priority) indicates
126 -- that no parameter was found, or no M line was present. Not set if
127 -- 'M' appears in Ignore_Lines.
129 Main_CPU : Int;
130 -- Indicates processor if Main_Program field indicates that this can
131 -- be a main program. A value of -1 (No_Main_CPU) indicates that no C
132 -- parameter was found, or no M line was present. Not set if 'M' appears
133 -- in Ignore_Lines.
135 Time_Slice_Value : Int;
136 -- Indicates value of time slice parameter from T=xxx on main program
137 -- line. A value of -1 indicates that no T=xxx parameter was found, or
138 -- no M line was present. 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 tasking
146 -- was not used, or that no Locking_Policy pragma was present or that
147 -- this is a language defined unit. Otherwise set to first character
148 -- (upper case) of policy name. Not set if 'P' appears in Ignore_Lines.
150 Partition_Elaboration_Policy : Character;
151 -- Indicates partition elaboration policy for units in this file. Space
152 -- means that no Partition_Elaboration_Policy pragma was present or that
153 -- this is a language defined unit. Otherwise set to first character
154 -- (upper case) of policy name. Not set if 'P' appears in Ignore_Lines.
156 Queuing_Policy : Character;
157 -- Indicates queuing policy for units in this file. Space means tasking
158 -- was not used, or that no Queuing_Policy pragma was present or that
159 -- this is a language defined unit. Otherwise set to first character
160 -- (upper case) of policy name. Not set if 'P' appears in Ignore_Lines.
162 Task_Dispatching_Policy : Character;
163 -- Indicates task dispatching policy for units in this file. Space means
164 -- tasking was not used, or that no Task_Dispatching_Policy pragma was
165 -- present or that this is a language defined unit. Otherwise set to
166 -- first character (upper case) of policy name. Not set if 'P' appears
167 -- in Ignore_Lines.
169 Compile_Errors : Boolean;
170 -- Set to True if compile errors for unit. Note that No_Object will
171 -- always be set as well in this case. Not set if 'P' appears in
172 -- Ignore_Lines.
174 GNATprove_Mode : Boolean;
175 -- Set to True if ALI and object file produced in GNATprove_Mode as
176 -- signalled by GP appearing on the P line. Not set if 'P' appears in
177 -- Ignore_Lines.
179 No_Component_Reordering : Boolean;
180 -- Set to True if file was compiled with a configuration pragma file
181 -- containing pragma No_Component_Reordering. Not set if 'P' appears
182 -- in Ignore_Lines.
184 No_Object : Boolean;
185 -- Set to True if no object file generated. Not set if 'P' appears in
186 -- Ignore_Lines.
188 Normalize_Scalars : Boolean;
189 -- Set to True if file was compiled with Normalize_Scalars. Not set if
190 -- 'P' appears in Ignore_Lines.
192 SSO_Default : Character;
193 -- Set to 'H' or 'L' if file was compiled with a configuration pragma
194 -- file containing Default_Scalar_Storage_Order (High/Low_Order_First).
195 -- Set to ' ' if neither pragma was present. Not set if 'P' appears in
196 -- Ignore_Lines.
198 Unit_Exception_Table : Boolean;
199 -- Set to True if unit exception table pointer generated. Not set if 'P'
200 -- appears in Ignore_Lines.
202 Frontend_Exceptions : Boolean;
203 -- Set to True if file was compiled with front-end exceptions. Not set
204 -- if 'P' appears in Ignore_Lines.
206 Zero_Cost_Exceptions : Boolean;
207 -- Set to True if file was compiled with zero cost exceptions. Not set
208 -- if 'P' appears in Ignore_Lines.
210 Restrictions : Restrictions_Info;
211 -- Restrictions information reconstructed from R lines
213 First_Interrupt_State : Interrupt_State_Id;
214 Last_Interrupt_State : Interrupt_State_Id'Base;
215 -- These point to the first and last entries in the interrupt state
216 -- table for this unit. If no entries, then Last_Interrupt_State =
217 -- First_Interrupt_State - 1 (that's why the 'Base reference is there,
218 -- it can be one less than the lower bound of the subtype). Not set if
219 -- 'I' appears in Ignore_Lines
221 First_Specific_Dispatching : Priority_Specific_Dispatching_Id;
222 Last_Specific_Dispatching : Priority_Specific_Dispatching_Id'Base;
223 -- These point to the first and last entries in the priority specific
224 -- dispatching table for this unit. If there are no entries, then
225 -- Last_Specific_Dispatching = First_Specific_Dispatching - 1. That
226 -- is why the 'Base reference is there, it can be one less than the
227 -- lower bound of the subtype. Not set if 'S' appears in Ignore_Lines.
228 end record;
230 No_Main_Priority : constant Int := -1;
231 -- Code for no main priority set
233 No_Main_CPU : constant Int := -1;
234 -- Code for no main cpu set
236 package ALIs is new Table.Table (
237 Table_Component_Type => ALIs_Record,
238 Table_Index_Type => ALI_Id,
239 Table_Low_Bound => First_ALI_Entry,
240 Table_Initial => 500,
241 Table_Increment => 200,
242 Table_Name => "ALIs");
244 ----------------
245 -- Unit Table --
246 ----------------
248 -- Each unit within an ALI file generates an entry in the unit table
250 No_Unit_Id : constant Unit_Id := Unit_Id'First;
251 -- Special value indicating no unit table entry
253 First_Unit_Entry : constant Unit_Id := No_Unit_Id + 1;
254 -- Id of first actual entry in table
256 type Unit_Type is (Is_Spec, Is_Body, Is_Spec_Only, Is_Body_Only);
257 -- Indicates type of entry, if both body and spec appear in the ALI file,
258 -- then the first unit is marked Is_Body, and the second is marked Is_Spec.
259 -- If only a spec appears, then it is marked as Is_Spec_Only, and if only
260 -- a body appears, then it is marked Is_Body_Only).
262 subtype Version_String is String (1 .. 8);
263 -- Version string, taken from unit record
265 type Unit_Record is record
266 My_ALI : ALI_Id;
267 -- Corresponding ALI entry
269 Uname : Unit_Name_Type;
270 -- Name of Unit
272 Sfile : File_Name_Type;
273 -- Name of source file
275 Preelab : Boolean;
276 -- Indicates presence of PR parameter for a preelaborated package
278 No_Elab : Boolean;
279 -- Indicates presence of NE parameter for a unit that has does not
280 -- have an elaboration routine (since it has no elaboration code).
282 Pure : Boolean;
283 -- Indicates presence of PU parameter for a package having pragma Pure
285 Dynamic_Elab : Boolean;
286 -- Set to True if the unit was compiled with dynamic elaboration checks
287 -- (i.e. either -gnatE or pragma Elaboration_Checks (RM) was used to
288 -- compile the unit).
290 Elaborate_Body : Boolean;
291 -- Indicates presence of EB parameter for a package which has a pragma
292 -- Elaborate_Body, and also for generic package instantiations.
294 Set_Elab_Entity : Boolean;
295 -- Indicates presence of EE parameter for a unit which has an
296 -- elaboration entity which must be set true as part of the
297 -- elaboration of the unit.
299 Has_RACW : Boolean;
300 -- Indicates presence of RA parameter for a package that declares at
301 -- least one Remote Access to Class_Wide (RACW) object.
303 Remote_Types : Boolean;
304 -- Indicates presence of RT parameter for a package which has a
305 -- pragma Remote_Types.
307 Serious_Errors : Boolean;
308 -- Indicates presence of SE parameter indicating that compilation of
309 -- the unit encountered as serious error.
311 Shared_Passive : Boolean;
312 -- Indicates presence of SP parameter for a package which has a pragma
313 -- Shared_Passive.
315 RCI : Boolean;
316 -- Indicates presence of RC parameter for a package which has a pragma
317 -- Remote_Call_Interface.
319 Predefined : Boolean;
320 -- Indicates if unit is language predefined (or a child of such a unit)
322 Internal : Boolean;
323 -- Indicates if unit is an internal unit (or a child of such a unit)
325 First_With : With_Id;
326 -- Id of first withs table entry for this file
328 Last_With : With_Id;
329 -- Id of last withs table entry for this file
331 First_Arg : Arg_Id;
332 -- Id of first args table entry for this file
334 Last_Arg : Arg_Id;
335 -- Id of last args table entry for this file
337 Utype : Unit_Type;
338 -- Type of entry
340 Is_Generic : Boolean;
341 -- True for generic unit (i.e. a generic declaration, or a generic
342 -- body). False for a non-generic unit.
344 Unit_Kind : Character;
345 -- Indicates the nature of the unit. 'p' for Packages and 's' for
346 -- subprograms.
348 Version : Version_String;
349 -- Version of unit
351 Icasing : Casing_Type;
352 -- Indicates casing of identifiers in source file for this unit. This
353 -- is used for informational output, and also for constructing the main
354 -- unit if it is being built in Ada.
356 Kcasing : Casing_Type;
357 -- Indicates casing of keywords in source file for this unit. This is
358 -- used for informational output, and also for constructing the main
359 -- unit if it is being built in Ada.
361 Elab_Position : Nat;
362 -- Initialized to zero. Set non-zero when a unit is chosen and
363 -- placed in the elaboration order. The value represents the
364 -- ordinal position in the elaboration order.
366 Init_Scalars : Boolean;
367 -- Set True if IS qualifier appears in ALI file, indicating that
368 -- an Initialize_Scalars pragma applies to the unit.
370 SAL_Interface : Boolean;
371 -- Set True when this is an interface to a standalone library
373 Directly_Scanned : Boolean;
374 -- True iff it is a unit from an ALI file specified to gnatbind
376 Body_Needed_For_SAL : Boolean;
377 -- Indicates that the source for the body of the unit (subprogram,
378 -- package, or generic unit) must be included in a standalone library.
380 Elaborate_Body_Desirable : Boolean;
381 -- Indicates that the front end elaboration circuitry decided that it
382 -- would be a good idea if this package had Elaborate_Body. The binder
383 -- will attempt, but does not promise, to place the elaboration call
384 -- for the body right after the call for the spec, or at least as close
385 -- together as possible.
387 Optimize_Alignment : Character;
388 -- Optimize_Alignment setting. Set to L/S/T/O for OL/OS/OT/OO present.
390 Has_Finalizer : Boolean;
391 -- Indicates whether a package body or a spec has a library-level
392 -- finalization routine.
394 Primary_Stack_Count : Int;
395 -- Indicates the number of task objects declared in this unit that have
396 -- default sized primary stacks.
398 Sec_Stack_Count : Int;
399 -- Indicates the number of task objects declared in this unit that have
400 -- default sized secondary stacks.
401 end record;
403 package Units is new Table.Table (
404 Table_Component_Type => Unit_Record,
405 Table_Index_Type => Unit_Id,
406 Table_Low_Bound => First_Unit_Entry,
407 Table_Initial => 100,
408 Table_Increment => 200,
409 Table_Name => "Unit");
411 ---------------------------
412 -- Interrupt State Table --
413 ---------------------------
415 -- An entry is made in this table for each I (interrupt state) line
416 -- encountered in the input ALI file. The First/Last_Interrupt_Id
417 -- fields of the ALI file entry show the range of entries defined
418 -- within a particular ALI file.
420 type Interrupt_State_Record is record
421 Interrupt_Id : Nat;
422 -- Id from interrupt state entry
424 Interrupt_State : Character;
425 -- State from interrupt state entry ('u'/'r'/'s')
427 IS_Pragma_Line : Nat;
428 -- Line number of Interrupt_State pragma
429 end record;
431 package Interrupt_States is new Table.Table (
432 Table_Component_Type => Interrupt_State_Record,
433 Table_Index_Type => Interrupt_State_Id'Base,
434 Table_Low_Bound => Interrupt_State_Id'First,
435 Table_Initial => 100,
436 Table_Increment => 200,
437 Table_Name => "Interrupt_States");
439 -----------------------------------------
440 -- Priority Specific Dispatching Table --
441 -----------------------------------------
443 -- An entry is made in this table for each S (priority specific
444 -- dispatching) line encountered in the input ALI file. The
445 -- First/Last_Specific_Dispatching_Id fields of the ALI file
446 -- entry show the range of entries defined within a particular
447 -- ALI file.
449 type Specific_Dispatching_Record is record
450 Dispatching_Policy : Character;
451 -- First character (upper case) of the corresponding policy name
453 First_Priority : Nat;
454 -- Lower bound of the priority range to which the specified dispatching
455 -- policy applies.
457 Last_Priority : Nat;
458 -- Upper bound of the priority range to which the specified dispatching
459 -- policy applies.
461 PSD_Pragma_Line : Nat;
462 -- Line number of Priority_Specific_Dispatching pragma
463 end record;
465 package Specific_Dispatching is new Table.Table (
466 Table_Component_Type => Specific_Dispatching_Record,
467 Table_Index_Type => Priority_Specific_Dispatching_Id'Base,
468 Table_Low_Bound => Priority_Specific_Dispatching_Id'First,
469 Table_Initial => 100,
470 Table_Increment => 200,
471 Table_Name => "Priority_Specific_Dispatching");
473 --------------
474 -- Switches --
475 --------------
477 -- These switches record status information about ali files that
478 -- have been read, for quick reference without searching tables.
480 -- Note: a switch will be left set at its default value if the line
481 -- which might otherwise set it is ignored (from Ignore_Lines).
483 Dynamic_Elaboration_Checks_Specified : Boolean := False;
484 -- Set to False by Initialize_ALI. Set to True if Scan_ALI reads
485 -- a unit for which dynamic elaboration checking is enabled.
487 Frontend_Exceptions_Specified : Boolean := False;
488 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
489 -- has a P line specifying the generation of front-end exceptions.
491 GNATprove_Mode_Specified : Boolean := False;
492 -- Set to True if an ali file was produced in GNATprove mode.
494 Initialize_Scalars_Used : Boolean := False;
495 -- Set True if an ali file contains the Initialize_Scalars flag
497 Locking_Policy_Specified : Character := ' ';
498 -- Set to blank by Initialize_ALI. Set to the appropriate locking policy
499 -- character if an ali file contains a P line setting the locking policy.
501 No_Normalize_Scalars_Specified : Boolean := False;
502 -- Set to False by Initialize_ALI. Set to True if an ali file indicates
503 -- that the file was compiled without normalize scalars.
505 No_Component_Reordering_Specified : Boolean := False;
506 -- Set to False by Initialize_ALI. Set to True if an ali file contains
507 -- the No_Component_Reordering flag.
509 No_Object_Specified : Boolean := False;
510 -- Set to False by Initialize_ALI. Set to True if an ali file contains
511 -- the No_Object flag.
513 Normalize_Scalars_Specified : Boolean := False;
514 -- Set to False by Initialize_ALI. Set to True if an ali file indicates
515 -- that the file was compiled in Normalize_Scalars mode.
517 Partition_Elaboration_Policy_Specified : Character := ' ';
518 -- Set to blank by Initialize_ALI. Set to the appropriate partition
519 -- elaboration policy character if an ali file contains a P line setting
520 -- the policy.
522 Queuing_Policy_Specified : Character := ' ';
523 -- Set to blank by Initialize_ALI. Set to the appropriate queuing policy
524 -- character if an ali file contains a P line setting the queuing policy.
526 Cumulative_Restrictions : Restrictions_Info := No_Restrictions;
527 -- This variable records the cumulative contributions of R lines in all
528 -- ali files, showing whether a restriction pragma exists anywhere, and
529 -- accumulating the aggregate knowledge of violations.
531 SSO_Default_Specified : Boolean := False;
532 -- Set to True if at least one ALI file contains an OH/OL flag indicating
533 -- that it was compiled with a configuration pragmas file containing the
534 -- pragma Default_Scalar_Storage_Order (OH/OL present in ALI file P line).
536 Stack_Check_Switch_Set : Boolean := False;
537 -- Set to True if at least one ALI file contains '-fstack-check' in its
538 -- argument list.
540 Task_Dispatching_Policy_Specified : Character := ' ';
541 -- Set to blank by Initialize_ALI. Set to the appropriate task dispatching
542 -- policy character if an ali file contains a P line setting the
543 -- task dispatching policy.
545 Unreserve_All_Interrupts_Specified : Boolean := False;
546 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
547 -- has P line specifying unreserve all interrupts mode.
549 Zero_Cost_Exceptions_Specified : Boolean := False;
550 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
551 -- has a P line specifying the generation of zero cost exceptions.
553 -----------------
554 -- Withs Table --
555 -----------------
557 -- Each With line (W line) in an ALI file generates a Withs table entry
559 -- Note: there will be no entries in this table if 'W' lines are ignored
561 No_With_Id : constant With_Id := With_Id'First;
562 -- Special value indicating no withs table entry
564 First_With_Entry : constant With_Id := No_With_Id + 1;
565 -- Id of first actual entry in table
567 type With_Record is record
568 Uname : Unit_Name_Type;
569 -- Name of Unit
571 Sfile : File_Name_Type;
572 -- Name of source file, set to No_File in generic case
574 Afile : File_Name_Type;
575 -- Name of ALI file, set to No_File in generic case
577 Elaborate : Boolean;
578 -- Indicates presence of E parameter
580 Elaborate_All : Boolean;
581 -- Indicates presence of EA parameter
583 Elab_All_Desirable : Boolean;
584 -- Indicates presence of AD parameter
586 Elab_Desirable : Boolean;
587 -- Indicates presence of ED parameter
589 SAL_Interface : Boolean := False;
590 -- True if the Unit is an Interface of a Stand-Alone Library
592 Implicit_With : Boolean := False;
593 -- True if this is an implicit with generated by the compiler
595 Limited_With : Boolean := False;
596 -- True if this is a limited_with_clause
597 end record;
599 package Withs is new Table.Table (
600 Table_Component_Type => With_Record,
601 Table_Index_Type => With_Id,
602 Table_Low_Bound => First_With_Entry,
603 Table_Initial => 5000,
604 Table_Increment => 200,
605 Table_Name => "Withs");
607 ---------------------
608 -- Arguments Table --
609 ---------------------
611 -- Each Arg line (A line) in an ALI file generates an Args table entry
613 -- Note: there will be no entries in this table if 'A' lines are ignored
615 No_Arg_Id : constant Arg_Id := Arg_Id'First;
616 -- Special value indicating no args table entry
618 First_Arg_Entry : constant Arg_Id := No_Arg_Id + 1;
619 -- Id of first actual entry in table
621 package Args is new Table.Table (
622 Table_Component_Type => String_Ptr,
623 Table_Index_Type => Arg_Id,
624 Table_Low_Bound => First_Arg_Entry,
625 Table_Initial => 1000,
626 Table_Increment => 100,
627 Table_Name => "Args");
629 --------------------------
630 -- Linker_Options Table --
631 --------------------------
633 -- If an ALI file has one of more Linker_Options lines, then a single
634 -- entry is made in this table. If more than one Linker_Options lines
635 -- appears in a given ALI file, then the arguments are concatenated
636 -- to form the entry in this table, using a NUL character as the
637 -- separator, and a final NUL character is appended to the end.
639 -- Note: there will be no entries in this table if 'L' lines are ignored
641 type Linker_Option_Record is record
642 Name : Name_Id;
643 -- Name entry containing concatenated list of Linker_Options
644 -- arguments separated by NUL and ended by NUL as described above.
646 Unit : Unit_Id;
647 -- Unit_Id for the entry
649 Internal_File : Boolean;
650 -- Set True if the linker options are from an internal file. This is
651 -- used to insert certain standard entries after all the user entries
652 -- but before the entries from the run-time.
654 Original_Pos : Positive;
655 -- Keep track of original position in the linker options table. This
656 -- is used to implement a stable sort when we sort the linker options
657 -- table.
658 end record;
660 -- The indexes of active entries in this table range from 1 to the
661 -- value of Linker_Options.Last. The zero'th element is for sort call.
663 package Linker_Options is new Table.Table (
664 Table_Component_Type => Linker_Option_Record,
665 Table_Index_Type => Integer,
666 Table_Low_Bound => 0,
667 Table_Initial => 200,
668 Table_Increment => 400,
669 Table_Name => "Linker_Options");
671 -----------------
672 -- Notes Table --
673 -----------------
675 -- The notes table records entries from N lines
677 type Notes_Record is record
678 Pragma_Type : Character;
679 -- 'A', 'C', 'I', 'S', 'T' for Annotate/Comment/Ident/Subtitle/Title
681 Pragma_Line : Nat;
682 -- Line number of pragma
684 Pragma_Col : Nat;
685 -- Column number of pragma
687 Pragma_Source_File : File_Name_Type;
688 -- Source file of pragma
690 Pragma_Args : Name_Id;
691 -- Pragma arguments. No_Name if no arguments, otherwise a single
692 -- name table entry consisting of all the characters on the notes
693 -- line from the first non-blank character following the source
694 -- location to the last character on the line.
695 end record;
697 -- The indexes of active entries in this table range from 1 to the
698 -- value of Linker_Options.Last. The zero'th element is for convenience
699 -- if the table needs to be sorted.
701 package Notes is new Table.Table (
702 Table_Component_Type => Notes_Record,
703 Table_Index_Type => Integer,
704 Table_Low_Bound => 0,
705 Table_Initial => 200,
706 Table_Increment => 400,
707 Table_Name => "Notes");
709 -------------------------------------------
710 -- External Version Reference Hash Table --
711 -------------------------------------------
713 -- This hash table keeps track of external version reference strings
714 -- as read from E lines in the ali file. The stored values do not
715 -- include the terminating quote characters.
717 -- Note: there will be no entries in this table if 'E' lines are ignored
719 type Vindex is range 0 .. 98;
720 -- Type to define range of headers
722 function SHash (S : String_Ptr) return Vindex;
723 -- Hash function for this table
725 function SEq (F1, F2 : String_Ptr) return Boolean;
726 -- Equality function for this table
728 package Version_Ref is new Simple_HTable (
729 Header_Num => Vindex,
730 Element => Boolean,
731 No_Element => False,
732 Key => String_Ptr,
733 Hash => SHash,
734 Equal => SEq);
736 -------------------------
737 -- No_Dependency Table --
738 -------------------------
740 -- Each R line for a No_Dependency Restriction generates an entry in
741 -- this No_Dependency table.
743 type No_Dep_Record is record
744 ALI_File : ALI_Id;
745 -- ALI File containing the entry
747 No_Dep_Unit : Name_Id;
748 -- Id for names table entry including entire name, including periods
749 end record;
751 package No_Deps is new Table.Table (
752 Table_Component_Type => No_Dep_Record,
753 Table_Index_Type => Integer,
754 Table_Low_Bound => 0,
755 Table_Initial => 200,
756 Table_Increment => 400,
757 Table_Name => "No_Deps");
759 ------------------------------------
760 -- Sdep (Source Dependency) Table --
761 ------------------------------------
763 -- Each source dependency (D line) in an ALI file generates an entry in the
764 -- Sdep table.
766 -- Note: there will be no entries in this table if 'D' lines are ignored
768 No_Sdep_Id : constant Sdep_Id := Sdep_Id'First;
769 -- Special value indicating no Sdep table entry
771 First_Sdep_Entry : Sdep_Id := No_Sdep_Id + 1;
772 -- Id of first Sdep entry for current ali file. This is initialized to the
773 -- first Sdep entry in the table, and then incremented appropriately as
774 -- successive ALI files are scanned.
776 type Sdep_Record is record
777 Sfile : File_Name_Type;
778 -- Name of source file
780 Stamp : Time_Stamp_Type;
781 -- Time stamp value. Note that this will be all zero characters for the
782 -- dummy entries for missing or non-dependent files.
784 Checksum : Word;
785 -- Checksum value. Note that this will be all zero characters for the
786 -- dummy entries for missing or non-dependent files
788 Dummy_Entry : Boolean;
789 -- Set True for dummy entries that correspond to missing files or files
790 -- where no dependency relationship exists.
792 Subunit_Name : Name_Id;
793 -- Name_Id for subunit name if present, else No_Name
795 Unit_Name : Name_Id;
796 -- Name_Id for the unit name if not a subunit (No_Name for a subunit)
797 Rfile : File_Name_Type;
798 -- Reference file name. Same as Sfile unless a Source_Reference pragma
799 -- was used, in which case it reflects the name used in the pragma.
801 Start_Line : Nat;
802 -- Starting line number in file. Always 1, unless a Source_Reference
803 -- pragma was used, in which case it reflects the line number value
804 -- given in the pragma.
806 end record;
808 package Sdep is new Table.Table (
809 Table_Component_Type => Sdep_Record,
810 Table_Index_Type => Sdep_Id,
811 Table_Low_Bound => First_Sdep_Entry,
812 Table_Initial => 5000,
813 Table_Increment => 200,
814 Table_Name => "Sdep");
816 ----------------------------
817 -- Use of Name Table Info --
818 ----------------------------
820 -- All unit names and file names are entered into the Names table. The Info
821 -- fields of these entries are used as follows:
823 -- Unit name Info field has Unit_Id of unit table entry
824 -- ALI file name Info field has ALI_Id of ALI table entry
825 -- Source file name Info field has Source_Id of source table entry
827 --------------------------
828 -- Cross-Reference Data --
829 --------------------------
831 -- The following table records cross-reference sections, there is one entry
832 -- for each X header line in the ALI file for an xref section.
834 -- Note: there will be no entries in this table if 'X' lines are ignored
836 type Xref_Section_Record is record
837 File_Num : Sdep_Id;
838 -- Dependency number for file (entry in Sdep.Table)
840 File_Name : File_Name_Type;
841 -- Name of file
843 First_Entity : Nat;
844 -- First entry in Xref_Entity table
846 Last_Entity : Nat;
847 -- Last entry in Xref_Entity table
848 end record;
850 package Xref_Section is new Table.Table (
851 Table_Component_Type => Xref_Section_Record,
852 Table_Index_Type => Nat,
853 Table_Low_Bound => 1,
854 Table_Initial => 50,
855 Table_Increment => 300,
856 Table_Name => "Xref_Section");
858 -- The following is used to indicate whether a typeref field is present
859 -- for the entity, and if so what kind of typeref field.
861 type Tref_Kind is (
862 Tref_None, -- No typeref present
863 Tref_Access, -- Access type typeref (points to designated type)
864 Tref_Derived, -- Derived type typeref (points to parent type)
865 Tref_Type); -- All other cases
867 type Visibility_Kind is
868 (Global, -- Library level entity
869 Static, -- Static C/C++ entity
870 Other); -- Local and other entity
872 -- The following table records entities for which xrefs are recorded
874 type Xref_Entity_Record is record
875 Line : Pos;
876 -- Line number of definition
878 Etype : Character;
879 -- Set to the identification character for the entity. See section
880 -- "Cross-Reference Entity Identifiers" in lib-xref.ads for details.
882 Col : Pos;
883 -- Column number of definition
885 Visibility : Visibility_Kind;
886 -- Visibility of entity
888 Entity : Name_Id;
889 -- Name of entity
891 Iref_File_Num : Sdep_Id;
892 -- This field is set to the dependency reference for the file containing
893 -- the generic entity that this one instantiates, or to No_Sdep_Id if
894 -- the current entity is not an instantiation
896 Iref_Line : Nat;
897 -- This field is set to the line number in Iref_File_Num of the generic
898 -- entity that this one instantiates, or to zero if the current entity
899 -- is not an instantiation.
901 Rref_Line : Nat;
902 -- This field is set to the line number of a renaming reference if
903 -- one is present, or to zero if no renaming reference is present
905 Rref_Col : Nat;
906 -- This field is set to the column number of a renaming reference
907 -- if one is present, or to zero if no renaming reference is present.
909 Tref : Tref_Kind;
910 -- Indicates if a typeref is present, and if so what kind. Set to
911 -- Tref_None if no typeref field is present.
913 Tref_File_Num : Sdep_Id;
914 -- This field is set to No_Sdep_Id if no typeref is present, or
915 -- if the typeref refers to an entity in standard. Otherwise it
916 -- it is the dependency reference for the file containing the
917 -- declaration of the typeref entity.
919 Tref_Line : Nat;
920 -- This field is set to zero if no typeref is present, or if the
921 -- typeref refers to an entity in standard. Otherwise it contains
922 -- the line number of the declaration of the typeref entity.
924 Tref_Type : Character;
925 -- This field is set to blank if no typeref is present, or if the
926 -- typeref refers to an entity in standard. Otherwise it contains
927 -- the identification character for the typeref entity. See section
928 -- "Cross-Reference Entity Identifiers" in lib-xref.ads for details.
930 Tref_Col : Nat;
931 -- This field is set to zero if no typeref is present, or if the
932 -- typeref refers to an entity in standard. Otherwise it contains
933 -- the column number of the declaration of the parent type.
935 Tref_Standard_Entity : Name_Id;
936 -- This field is set to No_Name if no typeref is present or if the
937 -- typeref refers to a declared entity rather than an entity in
938 -- package Standard. If there is a typeref that references an
939 -- entity in package Standard, then this field is a Name_Id
940 -- reference for the entity name.
942 Oref_File_Num : Sdep_Id;
943 -- This field is set to No_Sdep_Id if the entity doesn't override any
944 -- other entity, or to the dependency reference for the overridden
945 -- entity.
947 Oref_Line : Nat;
948 Oref_Col : Nat;
949 -- These two fields are set to the line and column of the overridden
950 -- entity.
952 First_Xref : Nat;
953 -- Index into Xref table of first cross-reference
955 Last_Xref : Nat;
956 -- Index into Xref table of last cross-reference. The value in
957 -- Last_Xref can be less than the First_Xref value to indicate
958 -- that no entries are present in the Xref Table.
959 end record;
961 package Xref_Entity is new Table.Table (
962 Table_Component_Type => Xref_Entity_Record,
963 Table_Index_Type => Nat,
964 Table_Low_Bound => 1,
965 Table_Initial => 500,
966 Table_Increment => 300,
967 Table_Name => "Xref_Entity");
969 Array_Index_Reference : constant Character := '*';
970 Interface_Reference : constant Character := 'I';
971 -- Some special types of references. In the ALI file itself, these
972 -- are output as attributes of the entity, not as references, but
973 -- there is no provision in Xref_Entity_Record for storing multiple
974 -- such references.
976 -- The following table records actual cross-references
978 type Xref_Record is record
979 File_Num : Sdep_Id;
980 -- Set to the file dependency number for the cross-reference. Note
981 -- that if no file entry is present explicitly, this is just a copy
982 -- of the reference for the current cross-reference section.
984 Line : Nat;
985 -- Line number for the reference. This is zero when referencing a
986 -- predefined entity, but in this case Name is set.
988 Rtype : Character;
989 -- Indicates type of reference, using code used in ALI file:
990 -- r = reference
991 -- m = modification
992 -- b = body entity
993 -- c = completion of private or incomplete type
994 -- x = type extension
995 -- i = implicit reference
996 -- Array_Index_Reference = reference to the index of an array
997 -- Interface_Reference = reference to an interface implemented
998 -- by the type
999 -- See description in lib-xref.ads for further details
1001 Col : Nat;
1002 -- Column number for the reference
1004 Name : Name_Id := No_Name;
1005 -- This is only used when referencing a predefined entity. Currently,
1006 -- this only occurs for array indexes.
1008 -- Note: for instantiation references, Rtype is set to ' ', and Col is
1009 -- set to zero. One or more such entries can follow any other reference.
1010 -- When there is more than one such entry, this is to be read as:
1011 -- e.g. ref1 ref2 ref3
1012 -- ref1 is a reference to an entity that was instantied at ref2.
1013 -- ref2 itself is also the result of an instantiation, that took
1014 -- place at ref3
1016 Imported_Lang : Name_Id := No_Name;
1017 Imported_Name : Name_Id := No_Name;
1018 -- Language and name of imported entity reference
1019 end record;
1021 package Xref is new Table.Table (
1022 Table_Component_Type => Xref_Record,
1023 Table_Index_Type => Nat,
1024 Table_Low_Bound => 1,
1025 Table_Initial => 2000,
1026 Table_Increment => 300,
1027 Table_Name => "Xref");
1029 --------------------------------------
1030 -- Subprograms for Reading ALI File --
1031 --------------------------------------
1033 procedure Initialize_ALI;
1034 -- Initialize the ALI tables. Also resets all switch values to defaults
1036 function Scan_ALI
1037 (F : File_Name_Type;
1038 T : Text_Buffer_Ptr;
1039 Ignore_ED : Boolean;
1040 Err : Boolean;
1041 Read_Xref : Boolean := False;
1042 Read_Lines : String := "";
1043 Ignore_Lines : String := "X";
1044 Ignore_Errors : Boolean := False;
1045 Directly_Scanned : Boolean := False) return ALI_Id;
1046 -- Given the text, T, of an ALI file, F, scan and store the information
1047 -- from the file, and return the Id of the resulting entry in the ALI
1048 -- table. Switch settings may be modified as described above in the
1049 -- switch description settings.
1051 -- Ignore_ED is normally False. If set to True, it indicates that
1052 -- all AD/ED (elaboration desirable) indications in the ALI file are
1053 -- to be ignored. This parameter is obsolete now that the -f switch
1054 -- is removed from gnatbind, and should be removed ???
1056 -- Err determines the action taken on an incorrectly formatted file.
1057 -- If Err is False, then an error message is output, and the program
1058 -- is terminated. If Err is True, then no error message is output,
1059 -- and No_ALI_Id is returned.
1061 -- Ignore_Lines requests that Scan_ALI ignore any lines that start
1062 -- with any given key character. The default value of X causes all
1063 -- Xref lines to be ignored. The corresponding data in the ALI
1064 -- tables will not be filled in this case. It is not possible
1065 -- to ignore U (unit) lines, they are always read.
1067 -- Read_Lines requests that Scan_ALI process only lines that start
1068 -- with one of the given characters. The corresponding data in the
1069 -- ALI file for any characters not given in the list will not be
1070 -- set. The default value of the null string indicates that all
1071 -- lines should be read (unless Ignore_Lines is specified). U
1072 -- (unit) lines are always read regardless of the value of this
1073 -- parameter.
1075 -- Note: either Ignore_Lines or Read_Lines should be non-null, but not
1076 -- both. If both are provided then only the Read_Lines value is used,
1077 -- and the Ignore_Lines parameter is ignored.
1079 -- Read_XREF is set True to read and acquire the cross-reference
1080 -- information. If Read_XREF is set to True, then the effect is to ignore
1081 -- all lines other than U, W, D and X lines and the Ignore_Lines and
1082 -- Read_Lines parameters are ignored (i.e. the use of True for Read_XREF
1083 -- is equivalent to specifying an argument of "UWDX" for Read_Lines.
1085 -- Ignore_Errors is normally False. If it is set True, then Scan_ALI
1086 -- will do its best to scan through a file and extract all information
1087 -- it can, even if there are errors. In this case Err is only set if
1088 -- Scan_ALI was completely unable to process the file (e.g. it did not
1089 -- look like an ALI file at all). Ignore_Errors is intended to improve
1090 -- the downward compatibility of new compilers with old tools.
1092 -- Directly_Scanned is normally False. If it is set to True, then the
1093 -- units (spec and/or body) corresponding to the ALI file are marked as
1094 -- such. It is used to decide for what units gnatbind should generate
1095 -- the symbols corresponding to 'Version or 'Body_Version in
1096 -- Stand-Alone Libraries.
1098 end ALI;