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