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