OSDN Git Service

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