| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- L I B . L O A D -- |
| 6 |
-- -- |
| 7 |
-- B o d y -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1992-2025, 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 |
with Atree; use Atree; |
| 27 |
with Debug; use Debug; |
| 28 |
with Einfo; use Einfo; |
| 29 |
with Einfo.Entities; use Einfo.Entities; |
| 30 |
with Errout; use Errout; |
| 31 |
with Fname; use Fname; |
| 32 |
with Fname.UF; use Fname.UF; |
| 33 |
with Nlists; use Nlists; |
| 34 |
with Nmake; use Nmake; |
| 35 |
with Opt; use Opt; |
| 36 |
with Osint; use Osint; |
| 37 |
with Osint.C; use Osint.C; |
| 38 |
with Output; use Output; |
| 39 |
with Par; |
| 40 |
with Restrict; use Restrict; |
| 41 |
with Scn; use Scn; |
| 42 |
with Sinfo; use Sinfo; |
| 43 |
with Sinfo.Nodes; use Sinfo.Nodes; |
| 44 |
with Sinfo.Utils; use Sinfo.Utils; |
| 45 |
with Sinput; use Sinput; |
| 46 |
with Sinput.L; use Sinput.L; |
| 47 |
with Stand; use Stand; |
| 48 |
with Tbuild; use Tbuild; |
| 49 |
with Uname; use Uname; |
| 50 |
|
| 51 |
package body Lib.Load is |
| 52 |
|
| 53 |
----------------------- |
| 54 |
-- Local Subprograms -- |
| 55 |
----------------------- |
| 56 |
|
| 57 |
function From_Limited_With_Chain return Boolean; |
| 58 |
-- Check whether a possible circular dependence includes units that |
| 59 |
-- have been loaded through limited_with clauses, in which case there |
| 60 |
-- is no real circularity. |
| 61 |
|
| 62 |
function Spec_Is_Irrelevant |
| 63 |
(Spec_Unit : Unit_Number_Type; |
| 64 |
Body_Unit : Unit_Number_Type) return Boolean; |
| 65 |
-- The Spec_Unit and Body_Unit parameters are the unit numbers of the |
| 66 |
-- spec file that corresponds to the main unit which is a body. This |
| 67 |
-- function determines if the spec file is irrelevant and will be |
| 68 |
-- overridden by the body as described in RM 10.1.4(4). See description |
| 69 |
-- in "Special Handling of Subprogram Bodies" for further details. |
| 70 |
|
| 71 |
procedure Write_Dependency_Chain; |
| 72 |
-- This procedure is used to generate error message info lines that |
| 73 |
-- trace the current dependency chain when a load error occurs. |
| 74 |
|
| 75 |
------------------------------ |
| 76 |
-- Change_Main_Unit_To_Spec -- |
| 77 |
------------------------------ |
| 78 |
|
| 79 |
procedure Change_Main_Unit_To_Spec is |
| 80 |
U : Unit_Record renames Units.Table (Main_Unit); |
| 81 |
N : File_Name_Type; |
| 82 |
X : Source_File_Index; |
| 83 |
|
| 84 |
begin |
| 85 |
-- Get name of unit body |
| 86 |
|
| 87 |
Get_Name_String (U.Unit_File_Name); |
| 88 |
|
| 89 |
-- Note: for the following we should really generalize and consult the |
| 90 |
-- file name pattern data, but for now we just deal with the common |
| 91 |
-- naming cases, which is good enough in practice. |
| 92 |
|
| 93 |
-- Change .adb to .ads |
| 94 |
|
| 95 |
if Name_Len >= 5 |
| 96 |
and then Name_Buffer (Name_Len - 3 .. Name_Len) = ".adb" |
| 97 |
then |
| 98 |
Name_Buffer (Name_Len) := 's'; |
| 99 |
|
| 100 |
-- Change .2.ada to .1.ada (Rational convention) |
| 101 |
|
| 102 |
elsif Name_Len >= 7 |
| 103 |
and then Name_Buffer (Name_Len - 5 .. Name_Len) = ".2.ada" |
| 104 |
then |
| 105 |
Name_Buffer (Name_Len - 4) := '1'; |
| 106 |
|
| 107 |
-- Change .ada to _.ada (DEC convention) |
| 108 |
|
| 109 |
elsif Name_Len >= 5 |
| 110 |
and then Name_Buffer (Name_Len - 3 .. Name_Len) = ".ada" |
| 111 |
then |
| 112 |
Name_Buffer (Name_Len - 3 .. Name_Len + 1) := "_.ada"; |
| 113 |
Name_Len := Name_Len + 1; |
| 114 |
|
| 115 |
-- No match, don't make the change |
| 116 |
|
| 117 |
else |
| 118 |
return; |
| 119 |
end if; |
| 120 |
|
| 121 |
-- Try loading the spec |
| 122 |
|
| 123 |
N := Name_Find; |
| 124 |
X := Load_Source_File (N); |
| 125 |
|
| 126 |
-- No change if we did not find the spec |
| 127 |
|
| 128 |
if X <= No_Source_File then |
| 129 |
return; |
| 130 |
end if; |
| 131 |
|
| 132 |
-- Otherwise modify Main_Unit entry to point to spec |
| 133 |
|
| 134 |
U.Unit_File_Name := N; |
| 135 |
U.Source_Index := X; |
| 136 |
end Change_Main_Unit_To_Spec; |
| 137 |
|
| 138 |
------------------------------- |
| 139 |
-- Create_Dummy_Package_Unit -- |
| 140 |
------------------------------- |
| 141 |
|
| 142 |
function Create_Dummy_Package_Unit |
| 143 |
(With_Node : Node_Id; |
| 144 |
Spec_Name : Unit_Name_Type) return Unit_Number_Type |
| 145 |
is |
| 146 |
Unum : Unit_Number_Type; |
| 147 |
Cunit_Entity : Entity_Id; |
| 148 |
Cunit : Node_Id; |
| 149 |
Du_Name : Node_Or_Entity_Id; |
| 150 |
End_Lab : Node_Id; |
| 151 |
Fname : constant File_Name_Type := |
| 152 |
Get_File_Name (Spec_Name, Subunit => False); |
| 153 |
Pre_Name : constant Boolean := |
| 154 |
Is_Predefined_File_Name (Fname, Renamings_Included => False); |
| 155 |
Ren_Name : constant Boolean := |
| 156 |
Is_Predefined_Renaming_File_Name (Fname); |
| 157 |
GNAT_Name : constant Boolean := |
| 158 |
Is_GNAT_File_Name (Fname); |
| 159 |
Save_CS : constant Boolean := Get_Comes_From_Source_Default; |
| 160 |
|
| 161 |
begin |
| 162 |
-- The created dummy package unit does not come from source |
| 163 |
|
| 164 |
Set_Comes_From_Source_Default (False); |
| 165 |
|
| 166 |
-- Normal package |
| 167 |
|
| 168 |
if Nkind (Name (With_Node)) = N_Identifier then |
| 169 |
Cunit_Entity := |
| 170 |
Make_Defining_Identifier (No_Location, |
| 171 |
Chars => Chars (Name (With_Node))); |
| 172 |
Du_Name := Cunit_Entity; |
| 173 |
End_Lab := New_Occurrence_Of (Cunit_Entity, No_Location); |
| 174 |
|
| 175 |
-- Child package |
| 176 |
|
| 177 |
else |
| 178 |
Cunit_Entity := |
| 179 |
Make_Defining_Identifier (No_Location, |
| 180 |
Chars => Chars (Selector_Name (Name (With_Node)))); |
| 181 |
Du_Name := |
| 182 |
Make_Defining_Program_Unit_Name (No_Location, |
| 183 |
Name => Copy_Separate_Tree (Prefix (Name (With_Node))), |
| 184 |
Defining_Identifier => Cunit_Entity); |
| 185 |
|
| 186 |
Set_Is_Child_Unit (Cunit_Entity); |
| 187 |
|
| 188 |
End_Lab := |
| 189 |
Make_Designator (No_Location, |
| 190 |
Name => Copy_Separate_Tree (Prefix (Name (With_Node))), |
| 191 |
Identifier => New_Occurrence_Of (Cunit_Entity, No_Location)); |
| 192 |
end if; |
| 193 |
|
| 194 |
Set_Scope (Cunit_Entity, Standard_Standard); |
| 195 |
|
| 196 |
Cunit := |
| 197 |
Make_Compilation_Unit (No_Location, |
| 198 |
Context_Items => Empty_List, |
| 199 |
Unit => |
| 200 |
Make_Package_Declaration (No_Location, |
| 201 |
Specification => |
| 202 |
Make_Package_Specification (No_Location, |
| 203 |
Defining_Unit_Name => Du_Name, |
| 204 |
Visible_Declarations => Empty_List, |
| 205 |
End_Label => End_Lab)), |
| 206 |
Aux_Decls_Node => |
| 207 |
Make_Compilation_Unit_Aux (No_Location)); |
| 208 |
|
| 209 |
-- Mark the dummy package as analyzed to prevent analysis of this |
| 210 |
-- (non-existent) unit in -gnatQ mode because at the moment the |
| 211 |
-- structure and attributes of this dummy package does not allow |
| 212 |
-- a normal analysis of this unit |
| 213 |
|
| 214 |
Set_Analyzed (Cunit); |
| 215 |
|
| 216 |
Units.Increment_Last; |
| 217 |
Unum := Units.Last; |
| 218 |
|
| 219 |
Units.Table (Unum) := |
| 220 |
(Cunit => Cunit, |
| 221 |
Cunit_Entity => Cunit_Entity, |
| 222 |
Dependency_Num => 0, |
| 223 |
Dynamic_Elab => False, |
| 224 |
Error_Location => Sloc (With_Node), |
| 225 |
Expected_Unit => Spec_Name, |
| 226 |
Fatal_Error => Error_Detected, |
| 227 |
Generate_Code => False, |
| 228 |
Has_RACW => False, |
| 229 |
Filler => False, |
| 230 |
Ident_String => Empty, |
| 231 |
|
| 232 |
Is_Predefined_Renaming => Ren_Name, |
| 233 |
Is_Predefined_Unit => Pre_Name or Ren_Name, |
| 234 |
Is_Internal_Unit => Pre_Name or Ren_Name or GNAT_Name, |
| 235 |
Filler2 => False, |
| 236 |
|
| 237 |
Loading => False, |
| 238 |
Main_Priority => Default_Main_Priority, |
| 239 |
Main_CPU => Default_Main_CPU, |
| 240 |
Primary_Stack_Count => 0, |
| 241 |
Sec_Stack_Count => 0, |
| 242 |
Munit_Index => 0, |
| 243 |
No_Elab_Code_All => False, |
| 244 |
Serial_Number => 0, |
| 245 |
Source_Index => No_Source_File, |
| 246 |
Unit_File_Name => Fname, |
| 247 |
Unit_Name => Spec_Name, |
| 248 |
Version => 0, |
| 249 |
OA_Setting => 'O'); |
| 250 |
|
| 251 |
Init_Unit_Name (Unum, Spec_Name); |
| 252 |
|
| 253 |
Set_Comes_From_Source_Default (Save_CS); |
| 254 |
Set_Error_Posted (Cunit_Entity); |
| 255 |
Set_Error_Posted (Cunit); |
| 256 |
return Unum; |
| 257 |
end Create_Dummy_Package_Unit; |
| 258 |
|
| 259 |
----------------------------- |
| 260 |
-- From_Limited_With_Chain -- |
| 261 |
----------------------------- |
| 262 |
|
| 263 |
function From_Limited_With_Chain return Boolean is |
| 264 |
Curr_Num : constant Unit_Number_Type := |
| 265 |
Load_Stack.Table (Load_Stack.Last).Unit_Number; |
| 266 |
|
| 267 |
begin |
| 268 |
-- True if the current load operation is through a limited_with clause |
| 269 |
-- and we are not within a loop of regular with_clauses. |
| 270 |
|
| 271 |
for U in reverse Load_Stack.First .. Load_Stack.Last - 1 loop |
| 272 |
if Load_Stack.Table (U).Unit_Number = Curr_Num then |
| 273 |
return False; |
| 274 |
|
| 275 |
elsif Present (Load_Stack.Table (U).With_Node) |
| 276 |
and then Limited_Present (Load_Stack.Table (U).With_Node) |
| 277 |
then |
| 278 |
return True; |
| 279 |
end if; |
| 280 |
end loop; |
| 281 |
|
| 282 |
return False; |
| 283 |
end From_Limited_With_Chain; |
| 284 |
|
| 285 |
---------------- |
| 286 |
-- Initialize -- |
| 287 |
---------------- |
| 288 |
|
| 289 |
procedure Initialize is |
| 290 |
begin |
| 291 |
Units.Init; |
| 292 |
Load_Stack.Init; |
| 293 |
end Initialize; |
| 294 |
|
| 295 |
------------------------ |
| 296 |
-- Initialize_Version -- |
| 297 |
------------------------ |
| 298 |
|
| 299 |
procedure Initialize_Version (U : Unit_Number_Type) is |
| 300 |
begin |
| 301 |
Units.Table (U).Version := Source_Checksum (Source_Index (U)); |
| 302 |
end Initialize_Version; |
| 303 |
|
| 304 |
---------------------- |
| 305 |
-- Load_Main_Source -- |
| 306 |
---------------------- |
| 307 |
|
| 308 |
procedure Load_Main_Source is |
| 309 |
Fname : constant File_Name_Type := Next_Main_Source; |
| 310 |
Pre_Name : constant Boolean := |
| 311 |
Is_Predefined_File_Name (Fname, Renamings_Included => False); |
| 312 |
Ren_Name : constant Boolean := |
| 313 |
Is_Predefined_Renaming_File_Name (Fname); |
| 314 |
GNAT_Name : constant Boolean := |
| 315 |
Is_GNAT_File_Name (Fname); |
| 316 |
Saved_Error_Count : constant Nat := Total_Errors_Detected; |
| 317 |
Version : Word := 0; |
| 318 |
|
| 319 |
begin |
| 320 |
Load_Stack.Increment_Last; |
| 321 |
Load_Stack.Table (Load_Stack.Last) := (Main_Unit, Empty); |
| 322 |
|
| 323 |
-- Initialize unit table entry for Main_Unit. Note that we don't know |
| 324 |
-- the unit name yet, that gets filled in when the parser parses the |
| 325 |
-- main unit, at which time a check is made that it matches the main |
| 326 |
-- file name, and then the Unit_Name field is set. The Cunit and |
| 327 |
-- Cunit_Entity fields also get filled in later by the parser. |
| 328 |
|
| 329 |
Units.Increment_Last; |
| 330 |
|
| 331 |
Units.Table (Main_Unit).Unit_File_Name := Fname; |
| 332 |
|
| 333 |
if Fname /= No_File then |
| 334 |
Main_Source_File := Load_Source_File (Fname); |
| 335 |
Current_Error_Source_File := Main_Source_File; |
| 336 |
|
| 337 |
if Main_Source_File > No_Source_File then |
| 338 |
Version := Source_Checksum (Main_Source_File); |
| 339 |
|
| 340 |
-- If we get here and Saved_Error_Count /= Total_Errors_Detected, |
| 341 |
-- then an error occurred during preprocessing. In this case |
| 342 |
-- we have already generated an error message during preprocessing |
| 343 |
-- and we do not want to emit an incorrect "file foo.adb not found" |
| 344 |
-- message here. |
| 345 |
|
| 346 |
elsif Saved_Error_Count = Total_Errors_Detected then |
| 347 |
|
| 348 |
-- To avoid emitting a source location (since there is no file), |
| 349 |
-- we write a custom error message instead of using the machinery |
| 350 |
-- in errout.adb. |
| 351 |
|
| 352 |
Set_Standard_Error; |
| 353 |
|
| 354 |
if Main_Source_File = No_Access_To_Source_File then |
| 355 |
Write_Str |
| 356 |
("no read access for file """ & Get_Name_String (Fname) |
| 357 |
& """"); |
| 358 |
else |
| 359 |
Write_Str |
| 360 |
("file """ & Get_Name_String (Fname) & """ not found"); |
| 361 |
end if; |
| 362 |
|
| 363 |
Write_Eol; |
| 364 |
Set_Standard_Output; |
| 365 |
end if; |
| 366 |
|
| 367 |
Units.Table (Main_Unit) := |
| 368 |
(Cunit => Empty, |
| 369 |
Cunit_Entity => Empty, |
| 370 |
Dependency_Num => 0, |
| 371 |
Dynamic_Elab => False, |
| 372 |
Error_Location => No_Location, |
| 373 |
Expected_Unit => No_Unit_Name, |
| 374 |
Fatal_Error => None, |
| 375 |
Generate_Code => True, |
| 376 |
Has_RACW => False, |
| 377 |
Filler => False, |
| 378 |
Ident_String => Empty, |
| 379 |
|
| 380 |
Is_Predefined_Renaming => Ren_Name, |
| 381 |
Is_Predefined_Unit => Pre_Name or Ren_Name, |
| 382 |
Is_Internal_Unit => Pre_Name or Ren_Name or GNAT_Name, |
| 383 |
Filler2 => False, |
| 384 |
|
| 385 |
Loading => True, |
| 386 |
Main_Priority => Default_Main_Priority, |
| 387 |
Main_CPU => Default_Main_CPU, |
| 388 |
Primary_Stack_Count => 0, |
| 389 |
Sec_Stack_Count => 0, |
| 390 |
|
| 391 |
Munit_Index => 0, |
| 392 |
No_Elab_Code_All => False, |
| 393 |
Serial_Number => 0, |
| 394 |
Source_Index => Main_Source_File, |
| 395 |
Unit_File_Name => Fname, |
| 396 |
Unit_Name => No_Unit_Name, |
| 397 |
Version => Version, |
| 398 |
OA_Setting => 'O'); |
| 399 |
end if; |
| 400 |
end Load_Main_Source; |
| 401 |
|
| 402 |
--------------- |
| 403 |
-- Load_Unit -- |
| 404 |
--------------- |
| 405 |
|
| 406 |
function Load_Unit |
| 407 |
(Load_Name : Unit_Name_Type; |
| 408 |
Required : Boolean; |
| 409 |
Error_Node : Node_Id; |
| 410 |
Subunit : Boolean; |
| 411 |
Corr_Body : Unit_Number_Type := No_Unit; |
| 412 |
Renamings : Boolean := False; |
| 413 |
With_Node : Node_Id := Empty; |
| 414 |
PMES : Boolean := False) return Unit_Number_Type |
| 415 |
is |
| 416 |
Calling_Unit : Unit_Number_Type; |
| 417 |
Uname_Actual : Unit_Name_Type; |
| 418 |
Unum : Unit_Number_Type; |
| 419 |
Unump : Unit_Number_Type; |
| 420 |
Fname : File_Name_Type; |
| 421 |
Pre_Name : Boolean; |
| 422 |
Ren_Name : Boolean; |
| 423 |
GNAT_Name : Boolean; |
| 424 |
Src_Ind : Source_File_Index; |
| 425 |
Save_PMES : constant Boolean := Parsing_Main_Extended_Source; |
| 426 |
|
| 427 |
Save_Cunit_Restrictions : constant Save_Cunit_Boolean_Restrictions := |
| 428 |
Cunit_Boolean_Restrictions_Save; |
| 429 |
-- Save current restrictions for restore at end |
| 430 |
|
| 431 |
begin |
| 432 |
Parsing_Main_Extended_Source := PMES; |
| 433 |
|
| 434 |
-- Initialize restrictions to config restrictions for unit to load if |
| 435 |
-- it is part of the main extended source, otherwise reset them. |
| 436 |
|
| 437 |
-- Note: it's a bit odd but PMES is False for subunits, which is why |
| 438 |
-- we have the OR here. |
| 439 |
|
| 440 |
if PMES or Subunit then |
| 441 |
Restore_Config_Cunit_Boolean_Restrictions; |
| 442 |
else |
| 443 |
Reset_Cunit_Boolean_Restrictions; |
| 444 |
end if; |
| 445 |
|
| 446 |
-- If renamings are allowed and we have a child unit name, then we |
| 447 |
-- must first load the parent to deal with finding the real name. |
| 448 |
-- Retain the with_clause that names the child, so that if it is |
| 449 |
-- limited, the parent is loaded under the same condition. |
| 450 |
|
| 451 |
if Renamings and then Is_Child_Name (Load_Name) then |
| 452 |
Unump := |
| 453 |
Load_Unit |
| 454 |
(Load_Name => Get_Parent_Spec_Name (Load_Name), |
| 455 |
Required => Required, |
| 456 |
Subunit => False, |
| 457 |
Renamings => True, |
| 458 |
Error_Node => Error_Node, |
| 459 |
With_Node => With_Node); |
| 460 |
|
| 461 |
if Unump = No_Unit then |
| 462 |
Unum := No_Unit; |
| 463 |
goto Done; |
| 464 |
end if; |
| 465 |
|
| 466 |
-- If parent is a renaming, then we use the renamed package as |
| 467 |
-- the actual parent for the subsequent load operation. |
| 468 |
|
| 469 |
if Nkind (Unit (Cunit (Unump))) = N_Package_Renaming_Declaration then |
| 470 |
Uname_Actual := |
| 471 |
New_Child |
| 472 |
(Load_Name, Get_Unit_Name (Name (Unit (Cunit (Unump))))); |
| 473 |
|
| 474 |
-- If the load is for a with_clause, for visibility purposes both |
| 475 |
-- the renamed entity and renaming one must be available in the |
| 476 |
-- current unit: the renamed one in order to retrieve the child |
| 477 |
-- unit, and the original one because it may be used as a prefix |
| 478 |
-- in the body of the current unit. We add an explicit with_clause |
| 479 |
-- for the original parent so that the renaming declaration is |
| 480 |
-- properly loaded and analyzed. |
| 481 |
|
| 482 |
if Present (With_Node) then |
| 483 |
Insert_After (With_Node, |
| 484 |
Make_With_Clause (Sloc (With_Node), |
| 485 |
Name => Copy_Separate_Tree (Prefix (Name (With_Node))))); |
| 486 |
end if; |
| 487 |
|
| 488 |
-- Save the renaming entity, to establish its visibility when |
| 489 |
-- installing the context. The implicit with is on this entity, |
| 490 |
-- not on the package it renames. This is somewhat redundant given |
| 491 |
-- the with_clause just created, but it simplifies subsequent |
| 492 |
-- expansion of the current with_clause. |
| 493 |
|
| 494 |
if Nkind (Error_Node) = N_With_Clause |
| 495 |
and then Nkind (Name (Error_Node)) = N_Selected_Component |
| 496 |
then |
| 497 |
declare |
| 498 |
Par : Node_Id := Name (Error_Node); |
| 499 |
|
| 500 |
begin |
| 501 |
while Nkind (Par) = N_Selected_Component |
| 502 |
and then Chars (Selector_Name (Par)) /= |
| 503 |
Chars (Cunit_Entity (Unump)) |
| 504 |
loop |
| 505 |
Par := Prefix (Par); |
| 506 |
end loop; |
| 507 |
|
| 508 |
-- Case of some intermediate parent is a renaming |
| 509 |
|
| 510 |
if Nkind (Par) = N_Selected_Component then |
| 511 |
Set_Entity (Selector_Name (Par), Cunit_Entity (Unump)); |
| 512 |
|
| 513 |
-- Case where the ultimate parent is a renaming |
| 514 |
|
| 515 |
else |
| 516 |
Set_Entity (Par, Cunit_Entity (Unump)); |
| 517 |
end if; |
| 518 |
end; |
| 519 |
end if; |
| 520 |
|
| 521 |
-- If the parent is not a renaming, then get its name (this may |
| 522 |
-- be different from the parent spec name obtained above because |
| 523 |
-- of renamings higher up in the hierarchy). |
| 524 |
|
| 525 |
else |
| 526 |
Uname_Actual := New_Child (Load_Name, Unit_Name (Unump)); |
| 527 |
end if; |
| 528 |
|
| 529 |
-- Here if unit to be loaded is not a child unit |
| 530 |
|
| 531 |
else |
| 532 |
Uname_Actual := Load_Name; |
| 533 |
end if; |
| 534 |
|
| 535 |
Fname := Get_File_Name (Uname_Actual, Subunit); |
| 536 |
Pre_Name := |
| 537 |
Is_Predefined_File_Name (Fname, Renamings_Included => False); |
| 538 |
Ren_Name := Is_Predefined_Renaming_File_Name (Fname); |
| 539 |
GNAT_Name := Is_GNAT_File_Name (Fname); |
| 540 |
|
| 541 |
if Debug_Flag_L then |
| 542 |
Write_Eol; |
| 543 |
Write_Str ("*** Load request for unit: "); |
| 544 |
Write_Unit_Name (Load_Name); |
| 545 |
|
| 546 |
if Required then |
| 547 |
Write_Str (" (Required = True)"); |
| 548 |
else |
| 549 |
Write_Str (" (Required = False)"); |
| 550 |
end if; |
| 551 |
|
| 552 |
Write_Eol; |
| 553 |
|
| 554 |
if Uname_Actual /= Load_Name then |
| 555 |
Write_Str ("*** Actual unit loaded: "); |
| 556 |
Write_Unit_Name (Uname_Actual); |
| 557 |
end if; |
| 558 |
end if; |
| 559 |
|
| 560 |
-- Capture error location if it is for the main unit. The idea is to |
| 561 |
-- post errors on the main unit location, not the most recent unit. |
| 562 |
-- Note: Unit_Name (Main_Unit) is not set if we are parsing gnat.adc. |
| 563 |
|
| 564 |
if Present (Error_Node) |
| 565 |
and then Present (Unit_Name (Main_Unit)) |
| 566 |
then |
| 567 |
-- It seems like In_Extended_Main_Source_Unit (Error_Node) would |
| 568 |
-- do the trick here, but that's wrong, it is much too early to |
| 569 |
-- call this routine. We are still in the parser, and the required |
| 570 |
-- semantic information is not established yet. So we base the |
| 571 |
-- judgment on unit names. |
| 572 |
|
| 573 |
Get_External_Unit_Name_String (Unit_Name (Main_Unit)); |
| 574 |
|
| 575 |
declare |
| 576 |
Main_Unit_Name : constant String := Name_Buffer (1 .. Name_Len); |
| 577 |
|
| 578 |
begin |
| 579 |
Get_External_Unit_Name_String |
| 580 |
(Unit_Name (Get_Source_Unit (Error_Node))); |
| 581 |
|
| 582 |
-- If the two names are identical, then for sure we are part |
| 583 |
-- of the extended main unit |
| 584 |
|
| 585 |
if Main_Unit_Name = Name_Buffer (1 .. Name_Len) then |
| 586 |
Load_Msg_Sloc := Sloc (Error_Node); |
| 587 |
|
| 588 |
-- If the load is called from a with_type clause, the error |
| 589 |
-- node is correct. |
| 590 |
|
| 591 |
-- Otherwise, check for the subunit case, and if so, consider |
| 592 |
-- we have a match if one name is a prefix of the other name. |
| 593 |
|
| 594 |
else |
| 595 |
if Nkind (Unit (Cunit (Main_Unit))) = N_Subunit |
| 596 |
or else |
| 597 |
Nkind (Unit (Cunit (Get_Source_Unit (Error_Node)))) = |
| 598 |
N_Subunit |
| 599 |
then |
| 600 |
Name_Len := Integer'Min (Name_Len, Main_Unit_Name'Length); |
| 601 |
|
| 602 |
if Name_Buffer (1 .. Name_Len) |
| 603 |
= |
| 604 |
Main_Unit_Name (1 .. Name_Len) |
| 605 |
then |
| 606 |
Load_Msg_Sloc := Sloc (Error_Node); |
| 607 |
end if; |
| 608 |
end if; |
| 609 |
end if; |
| 610 |
end; |
| 611 |
end if; |
| 612 |
|
| 613 |
-- If we are generating error messages, then capture calling unit |
| 614 |
|
| 615 |
if Present (Error_Node) then |
| 616 |
Calling_Unit := Get_Source_Unit (Error_Node); |
| 617 |
else |
| 618 |
Calling_Unit := No_Unit; |
| 619 |
end if; |
| 620 |
|
| 621 |
-- See if we already have an entry for this unit |
| 622 |
|
| 623 |
Unum := Unit_Names.Get (Uname_Actual); |
| 624 |
if Unum = No_Unit then |
| 625 |
Unum := Units.Last + 1; |
| 626 |
end if; |
| 627 |
|
| 628 |
-- Whether or not the entry was found, Unum is now the right value, |
| 629 |
-- since it is one more than Units.Last (i.e. the index of the new |
| 630 |
-- entry we will create) in the not found case. |
| 631 |
|
| 632 |
-- A special check is necessary in the unit not found case. If the unit |
| 633 |
-- is not found, but the file in which it lives has already been loaded, |
| 634 |
-- then we have the problem that the file does not contain the unit that |
| 635 |
-- is needed. We simply treat this as a file not found condition. |
| 636 |
|
| 637 |
-- We skip this test in multiple unit per file mode since in this |
| 638 |
-- case we can have multiple units from the same source file. |
| 639 |
|
| 640 |
if Unum > Units.Last and then Get_Unit_Index (Uname_Actual) = 0 then |
| 641 |
for J in Units.First .. Units.Last loop |
| 642 |
if Fname = Units.Table (J).Unit_File_Name then |
| 643 |
if Debug_Flag_L then |
| 644 |
Write_Str (" file does not contain unit, Unit_Number = "); |
| 645 |
Write_Int (Int (Unum)); |
| 646 |
Write_Eol; |
| 647 |
Write_Eol; |
| 648 |
end if; |
| 649 |
|
| 650 |
if Present (Error_Node) then |
| 651 |
Get_Name_String (Fname); |
| 652 |
|
| 653 |
if Is_Predefined_File_Name (Fname) then |
| 654 |
Error_Msg_Unit_1 := Uname_Actual; |
| 655 |
Error_Msg |
| 656 |
("$$ is not a language defined unit", |
| 657 |
Load_Msg_Sloc, |
| 658 |
Error_Node); |
| 659 |
else |
| 660 |
Error_Msg_File_1 := Fname; |
| 661 |
Error_Msg_Unit_1 := Uname_Actual; |
| 662 |
Error_Msg |
| 663 |
("file{ does not contain unit$", |
| 664 |
Load_Msg_Sloc, |
| 665 |
Error_Node); |
| 666 |
end if; |
| 667 |
|
| 668 |
Write_Dependency_Chain; |
| 669 |
Unum := No_Unit; |
| 670 |
goto Done; |
| 671 |
|
| 672 |
else |
| 673 |
Unum := No_Unit; |
| 674 |
goto Done; |
| 675 |
end if; |
| 676 |
end if; |
| 677 |
end loop; |
| 678 |
end if; |
| 679 |
|
| 680 |
-- If we are proceeding with load, then make load stack entry, |
| 681 |
-- and indicate the kind of with_clause responsible for the load. |
| 682 |
|
| 683 |
Load_Stack.Increment_Last; |
| 684 |
Load_Stack.Table (Load_Stack.Last) := (Unum, With_Node); |
| 685 |
|
| 686 |
-- Case of entry already in table |
| 687 |
|
| 688 |
if Unum <= Units.Last then |
| 689 |
|
| 690 |
-- Here is where we check for a circular dependency, which is |
| 691 |
-- an attempt to load a unit which is currently in the process |
| 692 |
-- of being loaded. We do *not* care about a circular chain that |
| 693 |
-- leads back to a body, because this kind of circular dependence |
| 694 |
-- legitimately occurs (e.g. two package bodies that contain |
| 695 |
-- inlined subprograms referenced by each other). |
| 696 |
|
| 697 |
-- Ada 2005 (AI-50217): We also ignore limited_with clauses, because |
| 698 |
-- their purpose is precisely to create legal circular structures. |
| 699 |
|
| 700 |
if Loading (Unum) |
| 701 |
and then (Is_Spec_Name (Units.Table (Unum).Unit_Name) |
| 702 |
or else Acts_As_Spec (Units.Table (Unum).Cunit)) |
| 703 |
and then (Nkind (Error_Node) /= N_With_Clause |
| 704 |
or else not Limited_Present (Error_Node)) |
| 705 |
and then not From_Limited_With_Chain |
| 706 |
then |
| 707 |
if Debug_Flag_L then |
| 708 |
Write_Str (" circular dependency encountered"); |
| 709 |
Write_Eol; |
| 710 |
end if; |
| 711 |
|
| 712 |
if Present (Error_Node) then |
| 713 |
Error_Msg |
| 714 |
("circular unit dependency", Load_Msg_Sloc, Error_Node); |
| 715 |
Write_Dependency_Chain; |
| 716 |
else |
| 717 |
Load_Stack.Decrement_Last; |
| 718 |
end if; |
| 719 |
|
| 720 |
Unum := No_Unit; |
| 721 |
goto Done; |
| 722 |
end if; |
| 723 |
|
| 724 |
if Debug_Flag_L then |
| 725 |
Write_Str (" unit already in file table, Unit_Number = "); |
| 726 |
Write_Int (Int (Unum)); |
| 727 |
Write_Eol; |
| 728 |
end if; |
| 729 |
|
| 730 |
Load_Stack.Decrement_Last; |
| 731 |
goto Done; |
| 732 |
|
| 733 |
-- Unit is not already in table, so try to open the file |
| 734 |
|
| 735 |
else |
| 736 |
if Debug_Flag_L then |
| 737 |
Write_Str (" attempt unit load, Unit_Number = "); |
| 738 |
Write_Int (Int (Unum)); |
| 739 |
Write_Eol; |
| 740 |
end if; |
| 741 |
|
| 742 |
Src_Ind := Load_Source_File (Fname); |
| 743 |
|
| 744 |
-- Make a partial entry in the file table, used even in the file not |
| 745 |
-- found case to print the dependency chain including the last entry |
| 746 |
|
| 747 |
Units.Increment_Last; |
| 748 |
Init_Unit_Name (Unum, Uname_Actual); |
| 749 |
|
| 750 |
-- File was found |
| 751 |
|
| 752 |
if Src_Ind > No_Source_File then |
| 753 |
Units.Table (Unum) := |
| 754 |
(Cunit => Empty, |
| 755 |
Cunit_Entity => Empty, |
| 756 |
Dependency_Num => 0, |
| 757 |
Dynamic_Elab => False, |
| 758 |
Error_Location => Sloc (Error_Node), |
| 759 |
Expected_Unit => Uname_Actual, |
| 760 |
Fatal_Error => None, |
| 761 |
Generate_Code => False, |
| 762 |
Has_RACW => False, |
| 763 |
Filler => False, |
| 764 |
Ident_String => Empty, |
| 765 |
|
| 766 |
Is_Predefined_Renaming => Ren_Name, |
| 767 |
Is_Predefined_Unit => Pre_Name or Ren_Name, |
| 768 |
Is_Internal_Unit => Pre_Name or Ren_Name or GNAT_Name, |
| 769 |
Filler2 => False, |
| 770 |
|
| 771 |
Loading => True, |
| 772 |
Main_Priority => Default_Main_Priority, |
| 773 |
Main_CPU => Default_Main_CPU, |
| 774 |
Primary_Stack_Count => 0, |
| 775 |
Sec_Stack_Count => 0, |
| 776 |
Munit_Index => 0, |
| 777 |
No_Elab_Code_All => False, |
| 778 |
Serial_Number => 0, |
| 779 |
Source_Index => Src_Ind, |
| 780 |
Unit_File_Name => Fname, |
| 781 |
Unit_Name => Uname_Actual, |
| 782 |
Version => Source_Checksum (Src_Ind), |
| 783 |
OA_Setting => 'O'); |
| 784 |
|
| 785 |
-- Parse the new unit |
| 786 |
|
| 787 |
declare |
| 788 |
Save_Index : constant Nat := Multiple_Unit_Index; |
| 789 |
Save_PMES : constant Boolean := Parsing_Main_Extended_Source; |
| 790 |
|
| 791 |
begin |
| 792 |
Multiple_Unit_Index := Get_Unit_Index (Uname_Actual); |
| 793 |
Units.Table (Unum).Munit_Index := Multiple_Unit_Index; |
| 794 |
Initialize_Scanner (Unum, Source_Index (Unum)); |
| 795 |
|
| 796 |
if Calling_Unit = Main_Unit and then Subunit then |
| 797 |
Parsing_Main_Extended_Source := True; |
| 798 |
end if; |
| 799 |
|
| 800 |
Discard_List (Par (Configuration_Pragmas => False)); |
| 801 |
|
| 802 |
Parsing_Main_Extended_Source := Save_PMES; |
| 803 |
|
| 804 |
Multiple_Unit_Index := Save_Index; |
| 805 |
Set_Loading (Unum, False); |
| 806 |
end; |
| 807 |
|
| 808 |
-- If spec is irrelevant, then post errors and quit |
| 809 |
|
| 810 |
if Corr_Body /= No_Unit |
| 811 |
and then Spec_Is_Irrelevant (Unum, Corr_Body) |
| 812 |
then |
| 813 |
Error_Msg_File_1 := Unit_File_Name (Corr_Body); |
| 814 |
Error_Msg |
| 815 |
("cannot compile subprogram in file {!", |
| 816 |
Load_Msg_Sloc, |
| 817 |
Error_Node); |
| 818 |
Error_Msg_File_1 := Unit_File_Name (Unum); |
| 819 |
Error_Msg |
| 820 |
("\incorrect spec in file { must be removed first!", |
| 821 |
Load_Msg_Sloc, |
| 822 |
Error_Node); |
| 823 |
Unum := No_Unit; |
| 824 |
goto Done; |
| 825 |
end if; |
| 826 |
|
| 827 |
-- If loaded unit had an error, then caller inherits setting |
| 828 |
|
| 829 |
if Present (Error_Node) then |
| 830 |
case Units.Table (Unum).Fatal_Error is |
| 831 |
|
| 832 |
-- Nothing to do if with'ed unit had no error |
| 833 |
|
| 834 |
when None => |
| 835 |
null; |
| 836 |
|
| 837 |
-- If with'ed unit had a detected fatal error, propagate it |
| 838 |
|
| 839 |
when Error_Detected => |
| 840 |
Units.Table (Calling_Unit).Fatal_Error := Error_Detected; |
| 841 |
|
| 842 |
-- If with'ed unit had an ignored error, then propagate it |
| 843 |
-- but do not overide an existing setting. |
| 844 |
|
| 845 |
when Error_Ignored => |
| 846 |
if Units.Table (Calling_Unit).Fatal_Error = None then |
| 847 |
Units.Table (Calling_Unit).Fatal_Error := |
| 848 |
Error_Ignored; |
| 849 |
end if; |
| 850 |
end case; |
| 851 |
end if; |
| 852 |
|
| 853 |
-- Remove load stack entry and return the entry in the file table |
| 854 |
|
| 855 |
Load_Stack.Decrement_Last; |
| 856 |
|
| 857 |
-- All done, return unit number |
| 858 |
|
| 859 |
goto Done; |
| 860 |
|
| 861 |
-- Case of file not found |
| 862 |
|
| 863 |
else |
| 864 |
if Debug_Flag_L then |
| 865 |
if Src_Ind = No_Access_To_Source_File then |
| 866 |
Write_Str (" no read access to file, load failed"); |
| 867 |
else |
| 868 |
Write_Str (" file was not found, load failed"); |
| 869 |
end if; |
| 870 |
|
| 871 |
Write_Eol; |
| 872 |
end if; |
| 873 |
|
| 874 |
-- Generate message if unit required |
| 875 |
|
| 876 |
if Required then |
| 877 |
Get_Name_String (Fname); |
| 878 |
|
| 879 |
if Is_Predefined_File_Name (Fname) then |
| 880 |
|
| 881 |
-- This is a predefined library unit which is not present |
| 882 |
-- in the run time. If a predefined unit is not available |
| 883 |
-- it may very likely be the case that there is also pragma |
| 884 |
-- Restriction forbidding its usage. This is typically the |
| 885 |
-- case when building a configurable run time, where the |
| 886 |
-- usage of certain run-time units is restricted by means |
| 887 |
-- of both the corresponding pragma Restriction (such as |
| 888 |
-- No_Calendar), and by not including the unit. Hence, we |
| 889 |
-- check whether this predefined unit is forbidden, so that |
| 890 |
-- the message about the restriction violation is generated, |
| 891 |
-- if needed. |
| 892 |
|
| 893 |
if Present (Error_Node) then |
| 894 |
Check_Restricted_Unit (Load_Name, Error_Node); |
| 895 |
end if; |
| 896 |
|
| 897 |
Error_Msg_Unit_1 := Uname_Actual; |
| 898 |
Error_Msg -- CODEFIX |
| 899 |
("$$ is not a predefined library unit", |
| 900 |
Load_Msg_Sloc, |
| 901 |
Error_Node); |
| 902 |
|
| 903 |
else |
| 904 |
Error_Msg_File_1 := Fname; |
| 905 |
|
| 906 |
if Src_Ind = No_Access_To_Source_File then |
| 907 |
Error_Msg |
| 908 |
("no read access to file{", |
| 909 |
Load_Msg_Sloc, |
| 910 |
Error_Node |
| 911 |
); |
| 912 |
else |
| 913 |
Error_Msg ("file{ not found", Load_Msg_Sloc, Error_Node); |
| 914 |
end if; |
| 915 |
end if; |
| 916 |
|
| 917 |
Write_Dependency_Chain; |
| 918 |
|
| 919 |
-- Remove unit from stack, to avoid cascaded errors on |
| 920 |
-- subsequent missing files. |
| 921 |
|
| 922 |
Load_Stack.Decrement_Last; |
| 923 |
Remove_Unit (Unum); |
| 924 |
|
| 925 |
-- If unit not required, remove load stack entry and the junk |
| 926 |
-- file table entry, and return No_Unit to indicate not found. |
| 927 |
|
| 928 |
else |
| 929 |
Load_Stack.Decrement_Last; |
| 930 |
Remove_Unit (Unum); |
| 931 |
end if; |
| 932 |
|
| 933 |
Unum := No_Unit; |
| 934 |
goto Done; |
| 935 |
end if; |
| 936 |
end if; |
| 937 |
|
| 938 |
-- Here to exit, with result in Unum |
| 939 |
|
| 940 |
<<Done>> |
| 941 |
Parsing_Main_Extended_Source := Save_PMES; |
| 942 |
Cunit_Boolean_Restrictions_Restore (Save_Cunit_Restrictions); |
| 943 |
return Unum; |
| 944 |
end Load_Unit; |
| 945 |
|
| 946 |
-------------------------- |
| 947 |
-- Make_Child_Decl_Unit -- |
| 948 |
-------------------------- |
| 949 |
|
| 950 |
procedure Make_Child_Decl_Unit (N : Node_Id) is |
| 951 |
Unit_Decl : constant Node_Id := Spec_Lib_Unit (N); |
| 952 |
Unit_Num : constant Unit_Number_Type := Get_Cunit_Unit_Number (N); |
| 953 |
|
| 954 |
begin |
| 955 |
Units.Increment_Last; |
| 956 |
Units.Table (Units.Last) := Units.Table (Unit_Num); |
| 957 |
Units.Table (Units.Last).Cunit := Unit_Decl; |
| 958 |
Units.Table (Units.Last).Cunit_Entity := |
| 959 |
Defining_Identifier |
| 960 |
(Defining_Unit_Name (Specification (Unit (Unit_Decl)))); |
| 961 |
Init_Unit_Name (Units.Last, Get_Spec_Name (Unit_Name (Unit_Num))); |
| 962 |
|
| 963 |
-- The library unit created for of a child subprogram unit plays no |
| 964 |
-- role in code generation and binding, so label it accordingly. |
| 965 |
|
| 966 |
Units.Table (Units.Last).Generate_Code := False; |
| 967 |
Set_Has_No_Elaboration_Code (Unit_Decl); |
| 968 |
end Make_Child_Decl_Unit; |
| 969 |
|
| 970 |
------------------------ |
| 971 |
-- Make_Instance_Unit -- |
| 972 |
------------------------ |
| 973 |
|
| 974 |
-- If the unit is an instance, it appears as a package declaration, but |
| 975 |
-- contains both declaration and body of the instance. The body becomes |
| 976 |
-- the main unit of the compilation, and the declaration is inserted |
| 977 |
-- at the end of the unit table. The main unit now has the name of a |
| 978 |
-- body, which is constructed from the name of the original spec, |
| 979 |
-- and is attached to the compilation node of the original unit. The |
| 980 |
-- declaration has been attached to a new compilation unit node, and |
| 981 |
-- code will have to be generated for it. |
| 982 |
|
| 983 |
procedure Make_Instance_Unit (N : Node_Id; In_Main : Boolean) is |
| 984 |
Sind : constant Source_File_Index := Source_Index (Main_Unit); |
| 985 |
|
| 986 |
begin |
| 987 |
Units.Increment_Last; |
| 988 |
|
| 989 |
if In_Main then |
| 990 |
Units.Table (Units.Last) := Units.Table (Main_Unit); |
| 991 |
Units.Table (Units.Last).Cunit := Spec_Lib_Unit (N); |
| 992 |
Init_Unit_Name (Units.Last, Unit_Name (Main_Unit)); |
| 993 |
|
| 994 |
Units.Table (Main_Unit).Cunit := N; |
| 995 |
Units.Table (Main_Unit).Version := Source_Checksum (Sind); |
| 996 |
Init_Unit_Name (Main_Unit, |
| 997 |
Get_Body_Name |
| 998 |
(Unit_Name (Get_Cunit_Unit_Number (Spec_Lib_Unit (N))))); |
| 999 |
|
| 1000 |
else |
| 1001 |
-- Duplicate information from instance unit, for the body. The unit |
| 1002 |
-- node N has been rewritten as a body, but it was placed in the |
| 1003 |
-- units table when first loaded as a declaration. |
| 1004 |
|
| 1005 |
Units.Table (Units.Last) := Units.Table (Get_Cunit_Unit_Number (N)); |
| 1006 |
Units.Table (Units.Last).Cunit := Spec_Lib_Unit (N); |
| 1007 |
end if; |
| 1008 |
end Make_Instance_Unit; |
| 1009 |
|
| 1010 |
------------------------ |
| 1011 |
-- Spec_Is_Irrelevant -- |
| 1012 |
------------------------ |
| 1013 |
|
| 1014 |
function Spec_Is_Irrelevant |
| 1015 |
(Spec_Unit : Unit_Number_Type; |
| 1016 |
Body_Unit : Unit_Number_Type) return Boolean |
| 1017 |
is |
| 1018 |
Sunit : constant Node_Id := Cunit (Spec_Unit); |
| 1019 |
Bunit : constant Node_Id := Cunit (Body_Unit); |
| 1020 |
|
| 1021 |
begin |
| 1022 |
-- The spec is irrelevant if the body is a subprogram body, and the spec |
| 1023 |
-- is other than a subprogram spec or generic subprogram spec. Note that |
| 1024 |
-- the names must be the same, we don't need to check that, because we |
| 1025 |
-- already know that from the fact that the file names are the same. |
| 1026 |
|
| 1027 |
return |
| 1028 |
Nkind (Unit (Bunit)) = N_Subprogram_Body |
| 1029 |
and then Nkind (Unit (Sunit)) /= N_Subprogram_Declaration |
| 1030 |
and then Nkind (Unit (Sunit)) /= N_Generic_Subprogram_Declaration; |
| 1031 |
end Spec_Is_Irrelevant; |
| 1032 |
|
| 1033 |
-------------------- |
| 1034 |
-- Version_Update -- |
| 1035 |
-------------------- |
| 1036 |
|
| 1037 |
procedure Version_Update (U : Node_Id; From : Node_Id) is |
| 1038 |
Unum : constant Unit_Number_Type := Get_Cunit_Unit_Number (U); |
| 1039 |
Fnum : constant Unit_Number_Type := Get_Cunit_Unit_Number (From); |
| 1040 |
begin |
| 1041 |
if Source_Index (Fnum) > No_Source_File then |
| 1042 |
Units.Table (Unum).Version := |
| 1043 |
Units.Table (Unum).Version |
| 1044 |
xor |
| 1045 |
Source_Checksum (Source_Index (Fnum)); |
| 1046 |
end if; |
| 1047 |
end Version_Update; |
| 1048 |
|
| 1049 |
---------------------------- |
| 1050 |
-- Write_Dependency_Chain -- |
| 1051 |
---------------------------- |
| 1052 |
|
| 1053 |
procedure Write_Dependency_Chain is |
| 1054 |
begin |
| 1055 |
-- The dependency chain is only written if it is at least two entries |
| 1056 |
-- deep, otherwise it is trivial (the main unit depending on a unit |
| 1057 |
-- that it obviously directly depends on). |
| 1058 |
|
| 1059 |
if Load_Stack.Last - 1 > Load_Stack.First then |
| 1060 |
for U in Load_Stack.First .. Load_Stack.Last - 1 loop |
| 1061 |
Error_Msg_Unit_1 := |
| 1062 |
Unit_Name (Load_Stack.Table (U).Unit_Number); |
| 1063 |
Error_Msg_Unit_2 := |
| 1064 |
Unit_Name (Load_Stack.Table (U + 1).Unit_Number); |
| 1065 |
Error_Msg ("$ depends on $!", Load_Msg_Sloc); |
| 1066 |
end loop; |
| 1067 |
end if; |
| 1068 |
end Write_Dependency_Chain; |
| 1069 |
|
| 1070 |
end Lib.Load; |