File : ali.ads


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