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