Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / ada / ali.ads
blobb9f953126c05915cb2a60f3aca14b9bf4f0ec75d
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A L I --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2010, 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 ranges.
46 -- The following type definitions show the ranges used for the subscripts
47 -- (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 ignored as
107 -- 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. Not set
126 -- if 'M' appears in Ignore_Lines.
128 Main_Priority : Int;
129 -- Indicates priority value if Main_Program field indicates that this
130 -- can be a main program. A value of -1 (No_Main_Priority) indicates
131 -- that no parameter was found, or no M line was present. Not set if
132 -- 'M' appears in Ignore_Lines.
134 Main_CPU : Int;
135 -- Indicates processor if Main_Program field indicates that this can
136 -- be a main program. A value of -1 (No_Main_CPU) indicates that no C
137 -- parameter was found, or no M line was present. Not set if 'M' appears
138 -- in Ignore_Lines.
140 Time_Slice_Value : Int;
141 -- Indicates value of time slice parameter from T=xxx on main program
142 -- line. A value of -1 indicates that no T=xxx parameter was found, or
143 -- no M line was present. Not set if 'M' appears in Ignore_Lines.
145 Allocator_In_Body : Boolean;
146 -- Set True if an AB switch appears on the main program line. False
147 -- if no M line, or AB not present, or 'M appears in Ignore_Lines.
149 WC_Encoding : Character;
150 -- Wide character encoding if main procedure. Otherwise not relevant.
151 -- Not set if 'M' appears in Ignore_Lines.
153 Locking_Policy : Character;
154 -- Indicates locking policy for units in this file. Space means tasking
155 -- was not used, or that no Locking_Policy pragma was present or that
156 -- this is a language defined unit. Otherwise set to first character
157 -- (upper case) of policy name. Not set if 'P' appears in Ignore_Lines.
159 Queuing_Policy : Character;
160 -- Indicates queuing policy for units in this file. Space means tasking
161 -- was not used, or that no Queuing_Policy pragma was present or that
162 -- this is a language defined unit. Otherwise set to first character
163 -- (upper case) of policy name. Not set if 'P' appears in Ignore_Lines.
165 Task_Dispatching_Policy : Character;
166 -- Indicates task dispatching policy for units in this file. Space means
167 -- tasking was not used, or that no Task_Dispatching_Policy pragma was
168 -- present or that this is a language defined unit. Otherwise set to
169 -- first character (upper case) of policy name. Not set if 'P' appears
170 -- in Ignore_Lines.
172 Compile_Errors : Boolean;
173 -- Set to True if compile errors for unit. Note that No_Object will
174 -- always be set as well in this case. Not set if 'P' appears in
175 -- Ignore_Lines.
177 Float_Format : Character;
178 -- Set to float format (set to I if no float-format given). Not set if
179 -- 'P' appears in Ignore_Lines.
181 No_Object : Boolean;
182 -- Set to True if no object file generated. Not set if 'P' appears in
183 -- Ignore_Lines.
185 Normalize_Scalars : Boolean;
186 -- Set to True if file was compiled with Normalize_Scalars. Not set if
187 -- 'P' appears in Ignore_Lines.
189 Unit_Exception_Table : Boolean;
190 -- Set to True if unit exception table pointer generated. Not set if 'P'
191 -- appears in Ignore_Lines.
193 Zero_Cost_Exceptions : Boolean;
194 -- Set to True if file was compiled with zero cost exceptions. Not set
195 -- if 'P' appears in Ignore_Lines.
197 Restrictions : Restrictions_Info;
198 -- Restrictions information reconstructed from R lines
200 First_Interrupt_State : Interrupt_State_Id;
201 Last_Interrupt_State : Interrupt_State_Id'Base;
202 -- These point to the first and last entries in the interrupt state
203 -- table for this unit. If no entries, then Last_Interrupt_State =
204 -- First_Interrupt_State - 1 (that's why the 'Base reference is there,
205 -- it can be one less than the lower bound of the subtype). Not set if
206 -- 'I' appears in Ignore_Lines
208 First_Specific_Dispatching : Priority_Specific_Dispatching_Id;
209 Last_Specific_Dispatching : Priority_Specific_Dispatching_Id'Base;
210 -- These point to the first and last entries in the priority specific
211 -- dispatching table for this unit. If there are no entries, then
212 -- Last_Specific_Dispatching = First_Specific_Dispatching - 1. That
213 -- is why the 'Base reference is there, it can be one less than the
214 -- lower bound of the subtype. Not set if 'S' appears in Ignore_Lines.
216 end record;
218 No_Main_Priority : constant Int := -1;
219 -- Code for no main priority set
221 No_Main_CPU : constant Int := -1;
222 -- Code for no main cpu set
224 package ALIs is new Table.Table (
225 Table_Component_Type => ALIs_Record,
226 Table_Index_Type => ALI_Id,
227 Table_Low_Bound => First_ALI_Entry,
228 Table_Initial => 500,
229 Table_Increment => 200,
230 Table_Name => "ALIs");
232 ----------------
233 -- Unit Table --
234 ----------------
236 -- Each unit within an ALI file generates an entry in the unit table
238 No_Unit_Id : constant Unit_Id := Unit_Id'First;
239 -- Special value indicating no unit table entry
241 First_Unit_Entry : constant Unit_Id := No_Unit_Id + 1;
242 -- Id of first actual entry in table
244 type Unit_Type is (Is_Spec, Is_Body, Is_Spec_Only, Is_Body_Only);
245 -- Indicates type of entry, if both body and spec appear in the ALI file,
246 -- then the first unit is marked Is_Body, and the second is marked Is_Spec.
247 -- If only a spec appears, then it is marked as Is_Spec_Only, and if only
248 -- a body appears, then it is marked Is_Body_Only).
250 subtype Version_String is String (1 .. 8);
251 -- Version string, taken from unit record
253 type Unit_Record is record
255 My_ALI : ALI_Id;
256 -- Corresponding ALI entry
258 Uname : Unit_Name_Type;
259 -- Name of Unit
261 Sfile : File_Name_Type;
262 -- Name of source file
264 Preelab : Boolean;
265 -- Indicates presence of PR parameter for a preelaborated package
267 No_Elab : Boolean;
268 -- Indicates presence of NE parameter for a unit that has does not
269 -- have an elaboration routine (since it has no elaboration code).
271 Pure : Boolean;
272 -- Indicates presence of PU parameter for a package having pragma Pure
274 Dynamic_Elab : Boolean;
275 -- Set to True if the unit was compiled with dynamic elaboration checks
276 -- (i.e. either -gnatE or pragma Elaboration_Checks (RM) was used to
277 -- compile the unit).
279 Elaborate_Body : Boolean;
280 -- Indicates presence of EB parameter for a package which has a pragma
281 -- Elaborate_Body, and also for generic package instantiations.
283 Set_Elab_Entity : Boolean;
284 -- Indicates presence of EE parameter for a unit which has an
285 -- elaboration entity which must be set true as part of the
286 -- elaboration of the entity.
288 Has_RACW : Boolean;
289 -- Indicates presence of RA parameter for a package that declares at
290 -- least one Remote Access to Class_Wide (RACW) object.
292 Remote_Types : Boolean;
293 -- Indicates presence of RT parameter for a package which has a
294 -- pragma Remote_Types.
296 Shared_Passive : Boolean;
297 -- Indicates presence of SP parameter for a package which has a pragma
298 -- Shared_Passive.
300 RCI : Boolean;
301 -- Indicates presence of RC parameter for a package which has a pragma
302 -- Remote_Call_Interface.
304 Predefined : Boolean;
305 -- Indicates if unit is language predefined (or a child of such a unit)
307 Internal : Boolean;
308 -- Indicates if unit is an internal unit (or a child of such a unit)
310 First_With : With_Id;
311 -- Id of first withs table entry for this file
313 Last_With : With_Id;
314 -- Id of last withs table entry for this file
316 First_Arg : Arg_Id;
317 -- Id of first args table entry for this file
319 Last_Arg : Arg_Id;
320 -- Id of last args table entry for this file
322 Utype : Unit_Type;
323 -- Type of entry
325 Is_Generic : Boolean;
326 -- True for generic unit (i.e. a generic declaration, or a generic
327 -- body). False for a non-generic unit.
329 Unit_Kind : Character;
330 -- Indicates the nature of the unit. 'p' for Packages and 's' for
331 -- subprograms.
333 Version : Version_String;
334 -- Version of unit
336 Icasing : Casing_Type;
337 -- Indicates casing of identifiers in source file for this unit. This
338 -- is used for informational output, and also for constructing the main
339 -- unit if it is being built in Ada.
341 Kcasing : Casing_Type;
342 -- Indicates casing of keywords in source file for this unit. This is
343 -- used for informational output, and also for constructing the main
344 -- unit if it is being built in Ada.
346 Elab_Position : aliased Natural;
347 -- Initialized to zero. Set non-zero when a unit is chosen and
348 -- placed in the elaboration order. The value represents the
349 -- ordinal position in the elaboration order.
351 Init_Scalars : Boolean;
352 -- Set True if IS qualifier appears in ALI file, indicating that
353 -- an Initialize_Scalars pragma applies to the unit.
355 SAL_Interface : Boolean;
356 -- Set True when this is an interface to a standalone library
358 Directly_Scanned : Boolean;
359 -- True iff it is a unit from an ALI file specified to gnatbind
361 Body_Needed_For_SAL : Boolean;
362 -- Indicates that the source for the body of the unit (subprogram,
363 -- package, or generic unit) must be included in a standalone library.
365 Elaborate_Body_Desirable : Boolean;
366 -- Indicates that the front end elaboration circuitry decided that it
367 -- would be a good idea if this package had Elaborate_Body. The binder
368 -- will attempt, but does not promise, to place the elaboration call
369 -- for the body right after the call for the spec, or at least as close
370 -- together as possible.
372 Optimize_Alignment : Character;
373 -- Optimize_Alignment setting. Set to L/S/T/O for OL/OS/OT/OO present
375 end record;
377 package Units is new Table.Table (
378 Table_Component_Type => Unit_Record,
379 Table_Index_Type => Unit_Id,
380 Table_Low_Bound => First_Unit_Entry,
381 Table_Initial => 100,
382 Table_Increment => 200,
383 Table_Name => "Unit");
385 ---------------------------
386 -- Interrupt State Table --
387 ---------------------------
389 -- An entry is made in this table for each I (interrupt state) line
390 -- encountered in the input ALI file. The First/Last_Interrupt_Id
391 -- fields of the ALI file entry show the range of entries defined
392 -- within a particular ALI file.
394 type Interrupt_State_Record is record
395 Interrupt_Id : Nat;
396 -- Id from interrupt state entry
398 Interrupt_State : Character;
399 -- State from interrupt state entry ('u'/'r'/'s')
401 IS_Pragma_Line : Nat;
402 -- Line number of Interrupt_State pragma
403 end record;
405 package Interrupt_States is new Table.Table (
406 Table_Component_Type => Interrupt_State_Record,
407 Table_Index_Type => Interrupt_State_Id'Base,
408 Table_Low_Bound => Interrupt_State_Id'First,
409 Table_Initial => 100,
410 Table_Increment => 200,
411 Table_Name => "Interrupt_States");
413 -----------------------------------------
414 -- Priority Specific Dispatching Table --
415 -----------------------------------------
417 -- An entry is made in this table for each S (priority specific
418 -- dispatching) line encountered in the input ALI file. The
419 -- First/Last_Specific_Dispatching_Id fields of the ALI file
420 -- entry show the range of entries defined within a particular
421 -- ALI file.
423 type Specific_Dispatching_Record is record
424 Dispatching_Policy : Character;
425 -- First character (upper case) of the corresponding policy name
427 First_Priority : Nat;
428 -- Lower bound of the priority range to which the specified dispatching
429 -- policy applies.
431 Last_Priority : Nat;
432 -- Upper bound of the priority range to which the specified dispatching
433 -- policy applies.
435 PSD_Pragma_Line : Nat;
436 -- Line number of Priority_Specific_Dispatching pragma
437 end record;
439 package Specific_Dispatching is new Table.Table (
440 Table_Component_Type => Specific_Dispatching_Record,
441 Table_Index_Type => Priority_Specific_Dispatching_Id'Base,
442 Table_Low_Bound => Priority_Specific_Dispatching_Id'First,
443 Table_Initial => 100,
444 Table_Increment => 200,
445 Table_Name => "Priority_Specific_Dispatching");
447 --------------
448 -- Switches --
449 --------------
451 -- These switches record status information about ali files that
452 -- have been read, for quick reference without searching tables.
454 -- Note: a switch will be left set at its default value if the line
455 -- which might otherwise set it is ignored (from Ignore_Lines).
457 Dynamic_Elaboration_Checks_Specified : Boolean := False;
458 -- Set to False by Initialize_ALI. Set to True if Scan_ALI reads
459 -- a unit for which dynamic elaboration checking is enabled.
461 Float_Format_Specified : Character := ' ';
462 -- Set to blank by Initialize_ALI. Set to appropriate float format
463 -- character (V or I, see Opt.Float_Format) if an ali file that
464 -- is read contains an F line setting the floating point format.
466 Initialize_Scalars_Used : Boolean := False;
467 -- Set True if an ali file contains the Initialize_Scalars flag
469 Locking_Policy_Specified : Character := ' ';
470 -- Set to blank by Initialize_ALI. Set to the appropriate locking policy
471 -- character if an ali file contains a P line setting the locking policy.
473 No_Normalize_Scalars_Specified : Boolean := False;
474 -- Set to False by Initialize_ALI. Set to True if an ali file indicates
475 -- that the file was compiled without normalize scalars.
477 No_Object_Specified : Boolean := False;
478 -- Set to False by Initialize_ALI. Set to True if an ali file contains
479 -- the No_Object flag.
481 Normalize_Scalars_Specified : Boolean := False;
482 -- Set to False by Initialize_ALI. Set to True if an ali file indicates
483 -- that the file was compiled in Normalize_Scalars mode.
485 Queuing_Policy_Specified : Character := ' ';
486 -- Set to blank by Initialize_ALI. Set to the appropriate queuing policy
487 -- character if an ali file contains a P line setting the queuing policy.
489 Cumulative_Restrictions : Restrictions_Info := No_Restrictions;
490 -- This variable records the cumulative contributions of R lines in all
491 -- ali files, showing whether a restriction pragma exists anywhere, and
492 -- accumulating the aggregate knowledge of violations.
494 Stack_Check_Switch_Set : Boolean := False;
495 -- Set to True if at least one ALI file contains '-fstack-check' in its
496 -- argument list.
498 Static_Elaboration_Model_Used : Boolean := False;
499 -- Set to False by Initialize_ALI. Set to True if any ALI file for a
500 -- non-internal unit compiled with the static elaboration model is
501 -- encountered.
503 Task_Dispatching_Policy_Specified : Character := ' ';
504 -- Set to blank by Initialize_ALI. Set to the appropriate task dispatching
505 -- policy character if an ali file contains a P line setting the
506 -- task dispatching policy.
508 Unreserve_All_Interrupts_Specified : Boolean := False;
509 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
510 -- has P line specifying unreserve all interrupts mode.
512 Zero_Cost_Exceptions_Specified : Boolean := False;
513 -- Set to False by Initialize_ALI. Set to True if an ali file is read that
514 -- has a P line specifying the generation of zero cost exceptions.
516 -----------------
517 -- Withs Table --
518 -----------------
520 -- Each With line (W line) in an ALI file generates a Withs table entry
522 -- Note: there will be no entries in this table if 'W' lines are ignored
524 No_With_Id : constant With_Id := With_Id'First;
525 -- Special value indicating no withs table entry
527 First_With_Entry : constant With_Id := No_With_Id + 1;
528 -- Id of first actual entry in table
530 type With_Record is record
532 Uname : Unit_Name_Type;
533 -- Name of Unit
535 Sfile : File_Name_Type;
536 -- Name of source file, set to No_File in generic case
538 Afile : File_Name_Type;
539 -- Name of ALI file, set to No_File in generic case
541 Elaborate : Boolean;
542 -- Indicates presence of E parameter
544 Elaborate_All : Boolean;
545 -- Indicates presence of EA parameter
547 Elab_All_Desirable : Boolean;
548 -- Indicates presence of AD parameter
550 Elab_Desirable : Boolean;
551 -- Indicates presence of ED parameter
553 SAL_Interface : Boolean := False;
554 -- True if the Unit is an Interface of a Stand-Alone Library
556 Limited_With : Boolean := False;
557 -- True if unit is named in a limited_with_clause
558 end record;
560 package Withs is new Table.Table (
561 Table_Component_Type => With_Record,
562 Table_Index_Type => With_Id,
563 Table_Low_Bound => First_With_Entry,
564 Table_Initial => 5000,
565 Table_Increment => 200,
566 Table_Name => "Withs");
568 ---------------------
569 -- Arguments Table --
570 ---------------------
572 -- Each Arg line (A line) in an ALI file generates an Args table entry
574 -- Note: there will be no entries in this table if 'A' lines are ignored
576 No_Arg_Id : constant Arg_Id := Arg_Id'First;
577 -- Special value indicating no args table entry
579 First_Arg_Entry : constant Arg_Id := No_Arg_Id + 1;
580 -- Id of first actual entry in table
582 package Args is new Table.Table (
583 Table_Component_Type => String_Ptr,
584 Table_Index_Type => Arg_Id,
585 Table_Low_Bound => First_Arg_Entry,
586 Table_Initial => 1000,
587 Table_Increment => 100,
588 Table_Name => "Args");
590 --------------------------
591 -- Linker_Options Table --
592 --------------------------
594 -- If an ALI file has one of more Linker_Options lines, then a single
595 -- entry is made in this table. If more than one Linker_Options lines
596 -- appears in a given ALI file, then the arguments are concatenated
597 -- to form the entry in this table, using a NUL character as the
598 -- separator, and a final NUL character is appended to the end.
600 -- Note: there will be no entries in this table if 'L' lines are ignored
602 type Linker_Option_Record is record
603 Name : Name_Id;
604 -- Name entry containing concatenated list of Linker_Options
605 -- arguments separated by NUL and ended by NUL as described above.
607 Unit : Unit_Id;
608 -- Unit_Id for the entry
610 Internal_File : Boolean;
611 -- Set True if the linker options are from an internal file. This is
612 -- used to insert certain standard entries after all the user entries
613 -- but before the entries from the run-time.
615 Original_Pos : Positive;
616 -- Keep track of original position in the linker options table. This
617 -- is used to implement a stable sort when we sort the linker options
618 -- table.
619 end record;
621 -- The indexes of active entries in this table range from 1 to the
622 -- value of Linker_Options.Last. The zero'th element is for sort call.
624 package Linker_Options is new Table.Table (
625 Table_Component_Type => Linker_Option_Record,
626 Table_Index_Type => Integer,
627 Table_Low_Bound => 0,
628 Table_Initial => 200,
629 Table_Increment => 400,
630 Table_Name => "Linker_Options");
632 -----------------
633 -- Notes Table --
634 -----------------
636 -- The notes table records entries from N lines
638 type Notes_Record is record
639 Pragma_Type : Character;
640 -- 'A', 'C', 'I', 'S', 'T' for Annotate/Comment/Ident/Subtitle/Title
642 Pragma_Line : Nat;
643 -- Line number of pragma
645 Pragma_Col : Nat;
646 -- Column number of pragma
648 Unit : Unit_Id;
649 -- Unit_Id for the entry
651 Pragma_Args : Name_Id;
652 -- Pragma arguments. No_Name if no arguments, otherwise a single
653 -- name table entry consisting of all the characters on the notes
654 -- line from the first non-blank character following the source
655 -- location to the last character on the line.
656 end record;
658 -- The indexes of active entries in this table range from 1 to the
659 -- value of Linker_Options.Last. The zero'th element is for convenience
660 -- if the table needs to be sorted.
662 package Notes is new Table.Table (
663 Table_Component_Type => Notes_Record,
664 Table_Index_Type => Integer,
665 Table_Low_Bound => 0,
666 Table_Initial => 200,
667 Table_Increment => 400,
668 Table_Name => "Notes");
670 -------------------------------------------
671 -- External Version Reference Hash Table --
672 -------------------------------------------
674 -- This hash table keeps track of external version reference strings
675 -- as read from E lines in the ali file. The stored values do not
676 -- include the terminating quote characters.
678 -- Note: there will be no entries in this table if 'E' lines are ignored
680 type Vindex is range 0 .. 98;
681 -- Type to define range of headers
683 function SHash (S : String_Ptr) return Vindex;
684 -- Hash function for this table
686 function SEq (F1, F2 : String_Ptr) return Boolean;
687 -- Equality function for this table
689 package Version_Ref is new Simple_HTable (
690 Header_Num => Vindex,
691 Element => Boolean,
692 No_Element => False,
693 Key => String_Ptr,
694 Hash => SHash,
695 Equal => SEq);
697 -------------------------
698 -- No_Dependency Table --
699 -------------------------
701 -- Each R line for a No_Dependency Restriction generates an entry in
702 -- this No_Dependency table.
704 type No_Dep_Record is record
705 ALI_File : ALI_Id;
706 -- ALI File containing the entry
708 No_Dep_Unit : Name_Id;
709 -- Id for names table entry including entire name, including periods
710 end record;
712 package No_Deps is new Table.Table (
713 Table_Component_Type => No_Dep_Record,
714 Table_Index_Type => Integer,
715 Table_Low_Bound => 0,
716 Table_Initial => 200,
717 Table_Increment => 400,
718 Table_Name => "No_Deps");
720 ------------------------------------
721 -- Sdep (Source Dependency) Table --
722 ------------------------------------
724 -- Each source dependency (D line) in an ALI file generates an entry in the
725 -- Sdep table.
727 -- Note: there will be no entries in this table if 'D' lines are ignored
729 No_Sdep_Id : constant Sdep_Id := Sdep_Id'First;
730 -- Special value indicating no Sdep table entry
732 First_Sdep_Entry : Sdep_Id := No_Sdep_Id + 1;
733 -- Id of first Sdep entry for current ali file. This is initialized to the
734 -- first Sdep entry in the table, and then incremented appropriately as
735 -- successive ALI files are scanned.
737 type Sdep_Record is record
739 Sfile : File_Name_Type;
740 -- Name of source file
742 Stamp : Time_Stamp_Type;
743 -- Time stamp value. Note that this will be all zero characters for the
744 -- dummy entries for missing or non-dependent files.
746 Checksum : Word;
747 -- Checksum value. Note that this will be all zero characters for the
748 -- dummy entries for missing or non-dependent files
750 Dummy_Entry : Boolean;
751 -- Set True for dummy entries that correspond to missing files or files
752 -- where no dependency relationship exists.
754 Subunit_Name : Name_Id;
755 -- Name_Id for subunit name if present, else No_Name
757 Rfile : File_Name_Type;
758 -- Reference file name. Same as Sfile unless a Source_Reference pragma
759 -- was used, in which case it reflects the name used in the pragma.
761 Start_Line : Nat;
762 -- Starting line number in file. Always 1, unless a Source_Reference
763 -- pragma was used, in which case it reflects the line number value
764 -- given in the pragma.
766 end record;
768 package Sdep is new Table.Table (
769 Table_Component_Type => Sdep_Record,
770 Table_Index_Type => Sdep_Id,
771 Table_Low_Bound => First_Sdep_Entry,
772 Table_Initial => 5000,
773 Table_Increment => 200,
774 Table_Name => "Sdep");
776 ----------------------------
777 -- Use of Name Table Info --
778 ----------------------------
780 -- All unit names and file names are entered into the Names table. The Info
781 -- fields of these entries are used as follows:
783 -- Unit name Info field has Unit_Id of unit table entry
784 -- ALI file name Info field has ALI_Id of ALI table entry
785 -- Source file name Info field has Source_Id of source table entry
787 --------------------------
788 -- Cross-Reference Data --
789 --------------------------
791 -- The following table records cross-reference sections, there is one entry
792 -- for each X header line in the ALI file for an xref section.
794 -- Note: there will be no entries in this table if 'X' lines are ignored
796 type Xref_Section_Record is record
797 File_Num : Sdep_Id;
798 -- Dependency number for file (entry in Sdep.Table)
800 File_Name : File_Name_Type;
801 -- Name of file
803 First_Entity : Nat;
804 -- First entry in Xref_Entity table
806 Last_Entity : Nat;
807 -- Last entry in Xref_Entity table
808 end record;
810 package Xref_Section is new Table.Table (
811 Table_Component_Type => Xref_Section_Record,
812 Table_Index_Type => Nat,
813 Table_Low_Bound => 1,
814 Table_Initial => 50,
815 Table_Increment => 300,
816 Table_Name => "Xref_Section");
818 -- The following is used to indicate whether a typeref field is present
819 -- for the entity, and if so what kind of typeref field.
821 type Tref_Kind is (
822 Tref_None, -- No typeref present
823 Tref_Access, -- Access type typeref (points to designated type)
824 Tref_Derived, -- Derived type typeref (points to parent type)
825 Tref_Type); -- All other cases
827 type Visibility_Kind is
828 (Global, -- Library level entity
829 Static, -- Static C/C++ entity
830 Other); -- Local and other entity
832 -- The following table records entities for which xrefs are recorded
834 type Xref_Entity_Record is record
835 Line : Pos;
836 -- Line number of definition
838 Etype : Character;
839 -- Set to the identification character for the entity. See section
840 -- "Cross-Reference Entity Identifiers" in lib-xref.ads for details.
842 Col : Pos;
843 -- Column number of definition
845 Visibility : Visibility_Kind;
846 -- Visiblity of entity
848 Entity : Name_Id;
849 -- Name of entity
851 Iref_File_Num : Sdep_Id;
852 -- This field is set to the dependency reference for the file containing
853 -- the generic entity that this one instantiates, or to No_Sdep_Id if
854 -- the current entity is not an instantiation
856 Iref_Line : Nat;
857 -- This field is set to the line number in Iref_File_Num of the generic
858 -- entity that this one instantiates, or to zero if the current entity
859 -- is not an instantiation.
861 Rref_Line : Nat;
862 -- This field is set to the line number of a renaming reference if
863 -- one is present, or to zero if no renaming reference is present
865 Rref_Col : Nat;
866 -- This field is set to the column number of a renaming reference
867 -- if one is present, or to zero if no renaming reference is present.
869 Tref : Tref_Kind;
870 -- Indicates if a typeref is present, and if so what kind. Set to
871 -- Tref_None if no typeref field is present.
873 Tref_File_Num : Sdep_Id;
874 -- This field is set to No_Sdep_Id if no typeref is present, or
875 -- if the typeref refers to an entity in standard. Otherwise it
876 -- it is the dependency reference for the file containing the
877 -- declaration of the typeref entity.
879 Tref_Line : Nat;
880 -- This field is set to zero if no typeref is present, or if the
881 -- typeref refers to an entity in standard. Otherwise it contains
882 -- the line number of the declaration of the typeref entity.
884 Tref_Type : Character;
885 -- This field is set to blank if no typeref is present, or if the
886 -- typeref refers to an entity in standard. Otherwise it contains
887 -- the identification character for the typeref entity. See section
888 -- "Cross-Reference Entity Identifiers" in lib-xref.ads for details.
890 Tref_Col : Nat;
891 -- This field is set to zero if no typeref is present, or if the
892 -- typeref refers to an entity in standard. Otherwise it contains
893 -- the column number of the declaration of the parent type.
895 Tref_Standard_Entity : Name_Id;
896 -- This field is set to No_Name if no typeref is present or if the
897 -- typeref refers to a declared entity rather than an entity in
898 -- package Standard. If there is a typeref that references an
899 -- entity in package Standard, then this field is a Name_Id
900 -- reference for the entity name.
902 Oref_File_Num : Sdep_Id;
903 -- This field is set to No_Sdep_Id if the entity doesn't override any
904 -- other entity, or to the dependency reference for the overridden
905 -- entity.
907 Oref_Line : Nat;
908 Oref_Col : Nat;
909 -- These two fields are set to the line and column of the overridden
910 -- entity.
912 First_Xref : Nat;
913 -- Index into Xref table of first cross-reference
915 Last_Xref : Nat;
916 -- Index into Xref table of last cross-reference. The value in
917 -- Last_Xref can be less than the First_Xref value to indicate
918 -- that no entries are present in the Xref Table.
919 end record;
921 package Xref_Entity is new Table.Table (
922 Table_Component_Type => Xref_Entity_Record,
923 Table_Index_Type => Nat,
924 Table_Low_Bound => 1,
925 Table_Initial => 500,
926 Table_Increment => 300,
927 Table_Name => "Xref_Entity");
929 Array_Index_Reference : constant Character := '*';
930 Interface_Reference : constant Character := 'I';
931 -- Some special types of references. In the ALI file itself, these
932 -- are output as attributes of the entity, not as references, but
933 -- there is no provision in Xref_Entity_Record for storing multiple
934 -- such references.
936 -- The following table records actual cross-references
938 type Xref_Record is record
939 File_Num : Sdep_Id;
940 -- Set to the file dependency number for the cross-reference. Note
941 -- that if no file entry is present explicitly, this is just a copy
942 -- of the reference for the current cross-reference section.
944 Line : Nat;
945 -- Line number for the reference. This is zero when referencing a
946 -- predefined entity, but in this case Name is set.
948 Rtype : Character;
949 -- Indicates type of reference, using code used in ALI file:
950 -- r = reference
951 -- m = modification
952 -- b = body entity
953 -- c = completion of private or incomplete type
954 -- x = type extension
955 -- i = implicit reference
956 -- Array_Index_Reference = reference to the index of an array
957 -- Interface_Reference = reference to an interface implemented
958 -- by the type
959 -- See description in lib-xref.ads for further details
961 Col : Nat;
962 -- Column number for the reference
964 Name : Name_Id := No_Name;
965 -- This is only used when referencing a predefined entity. Currently,
966 -- this only occurs for array indexes.
968 -- Note: for instantiation references, Rtype is set to ' ', and Col is
969 -- set to zero. One or more such entries can follow any other reference.
970 -- When there is more than one such entry, this is to be read as:
971 -- e.g. ref1 ref2 ref3
972 -- ref1 is a reference to an entity that was instantied at ref2.
973 -- ref2 itself is also the result of an instantiation, that took
974 -- place at ref3
975 end record;
977 package Xref is new Table.Table (
978 Table_Component_Type => Xref_Record,
979 Table_Index_Type => Nat,
980 Table_Low_Bound => 1,
981 Table_Initial => 2000,
982 Table_Increment => 300,
983 Table_Name => "Xref");
985 --------------------------------------
986 -- Subprograms for Reading ALI File --
987 --------------------------------------
989 procedure Initialize_ALI;
990 -- Initialize the ALI tables. Also resets all switch values to defaults
992 function Scan_ALI
993 (F : File_Name_Type;
994 T : Text_Buffer_Ptr;
995 Ignore_ED : Boolean;
996 Err : Boolean;
997 Read_Xref : Boolean := False;
998 Read_Lines : String := "";
999 Ignore_Lines : String := "X";
1000 Ignore_Errors : Boolean := False;
1001 Directly_Scanned : Boolean := False) return ALI_Id;
1002 -- Given the text, T, of an ALI file, F, scan and store the information
1003 -- from the file, and return the Id of the resulting entry in the ALI
1004 -- table. Switch settings may be modified as described above in the
1005 -- switch description settings.
1007 -- Ignore_ED is normally False. If set to True, it indicates that
1008 -- all AD/ED (elaboration desirable) indications in the ALI file are
1009 -- to be ignored. This parameter is obsolete now that the -f switch
1010 -- is removed from gnatbind, and should be removed ???
1012 -- Err determines the action taken on an incorrectly formatted file.
1013 -- If Err is False, then an error message is output, and the program
1014 -- is terminated. If Err is True, then no error message is output,
1015 -- and No_ALI_Id is returned.
1017 -- Ignore_Lines requests that Scan_ALI ignore any lines that start
1018 -- with any given key character. The default value of X causes all
1019 -- Xref lines to be ignored. The corresponding data in the ALI
1020 -- tables will not be filled in this case. It is not possible
1021 -- to ignore U (unit) lines, they are always read.
1023 -- Read_Lines requests that Scan_ALI process only lines that start
1024 -- with one of the given characters. The corresponding data in the
1025 -- ALI file for any characters not given in the list will not be
1026 -- set. The default value of the null string indicates that all
1027 -- lines should be read (unless Ignore_Lines is specified). U
1028 -- (unit) lines are always read regardless of the value of this
1029 -- parameter.
1031 -- Note: either Ignore_Lines or Read_Lines should be non-null, but not
1032 -- both. If both are provided then only the Read_Lines value is used,
1033 -- and the Ignore_Lines parameter is ignored.
1035 -- Read_XREF is set True to read and acquire the cross-reference
1036 -- information. If Read_XREF is set to True, then the effect is to ignore
1037 -- all lines other than U, W, D and X lines and the Ignore_Lines and
1038 -- Read_Lines parameters are ignored (i.e. the use of True for Read_XREF
1039 -- is equivalent to specifying an argument of "UWDX" for Read_Lines.
1041 -- Ignore_Errors is normally False. If it is set True, then Scan_ALI
1042 -- will do its best to scan through a file and extract all information
1043 -- it can, even if there are errors. In this case Err is only set if
1044 -- Scan_ALI was completely unable to process the file (e.g. it did not
1045 -- look like an ALI file at all). Ignore_Errors is intended to improve
1046 -- the downward compatibility of new compilers with old tools.
1048 -- Directly_Scanned is normally False. If it is set to True, then the
1049 -- units (spec and/or body) corresponding to the ALI file are marked as
1050 -- such. It is used to decide for what units gnatbind should generate
1051 -- the symbols corresponding to 'Version or 'Body_Version in
1052 -- Stand-Alone Libraries.
1054 end ALI;