OSDN Git Service

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