1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2002, Free Software Foundation, Inc. --
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. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Atree
; use Atree
;
28 with Casing
; use Casing
;
29 with Csets
; use Csets
;
30 with Debug
; use Debug
;
31 with Einfo
; use Einfo
;
32 with Elists
; use Elists
;
33 with Fname
; use Fname
;
34 with Fname
.UF
; use Fname
.UF
;
36 with Lib
.Load
; use Lib
.Load
;
37 with Namet
; use Namet
;
38 with Nlists
; use Nlists
;
39 with Nmake
; use Nmake
;
40 with Output
; use Output
;
42 with Restrict
; use Restrict
;
44 with Sem_Ch7
; use Sem_Ch7
;
45 with Sem_Util
; use Sem_Util
;
46 with Sinfo
; use Sinfo
;
47 with Stand
; use Stand
;
48 with Snames
; use Snames
;
49 with Tbuild
; use Tbuild
;
50 with Uname
; use Uname
;
52 package body Rtsfind
is
58 -- The unit table has one entry for each unit included in the definition
59 -- of the type RTU_Id in the spec. The table entries are initialized in
60 -- Initialize to set the Entity field to Empty, indicating that the
61 -- corresponding unit has not yet been loaded. The fields are set when
62 -- a unit is loaded to contain the defining entity for the unit, the
63 -- unit name, and the unit number.
65 type RT_Unit_Table_Record
is record
67 Uname
: Unit_Name_Type
;
68 Unum
: Unit_Number_Type
;
72 RT_Unit_Table
: array (RTU_Id
) of RT_Unit_Table_Record
;
74 --------------------------
75 -- Runtime Entity Table --
76 --------------------------
78 -- There is one entry in the runtime entity table for each entity that is
79 -- included in the definition of the RE_Id type in the spec. The entries
80 -- are set by Initialize_Rtsfind to contain Empty, indicating that the
81 -- entity has not yet been located. Once the entity is located for the
82 -- first time, its ID is stored in this array, so that subsequent calls
83 -- for the same entity can be satisfied immediately.
85 RE_Table
: array (RE_Id
) of Entity_Id
;
87 --------------------------
88 -- Generation of WITH's --
89 --------------------------
91 -- When a unit is implicitly loaded as a result of a call to RTE, it
92 -- is necessary to create an implicit with to ensure that the object
93 -- is correctly loaded by the binder. Such with statements are only
94 -- required when the request is from the extended main unit (if a
95 -- client needs a with, that will be taken care of when the client
98 -- We always attach the with to the main unit. This is not perfectly
99 -- accurate in terms of elaboration requirements, but it is close
100 -- enough, since the units that are accessed using rtsfind do not
101 -- have delicate elaboration requirements.
103 -- The flag Withed in the unit table record is initially set to False.
104 -- It is set True if a with has been generated for the main unit for
105 -- the corresponding unit.
107 -----------------------
108 -- Local Subprograms --
109 -----------------------
111 procedure Load_Fail
(S
: String; U_Id
: RTU_Id
; Ent_Name
: String := "");
112 -- Internal procedure called if we can't find the entity or unit.
113 -- The parameter is a detailed error message that is to be given.
114 -- S is a reason for failing to compile the file. U_Id is the unit
115 -- id, and Ent_Name, if non-null, is the associated entity name.
117 function Get_Unit_Name
(U_Id
: RTU_Id
) return Unit_Name_Type
;
118 -- Retrieves the Unit Name given a unit id represented by its
119 -- enumaration value in RTU_Id.
121 procedure Load_RTU
(U_Id
: RTU_Id
; Use_Setting
: Boolean := False);
122 -- Load the unit whose Id is given if not already loaded. The unit is
123 -- loaded, analyzed, and added to the with list, and the entry in
124 -- RT_Unit_Table is updated to reflect the load. The second parameter
125 -- indicates the initial setting for the Is_Potentially_Use_Visible
126 -- flag of the entity for the loaded unit (if it is indeed loaded).
127 -- A value of False means nothing special need be done. A value of
128 -- True indicates that this flag must be set to True. It is needed
129 -- only in the Text_IO_Kludge procedure, which may materialize an
130 -- entity of Text_IO (or Wide_Text_IO) that was previously unknown.
132 function RE_Chars
(E
: RE_Id
) return Name_Id
;
133 -- Given a RE_Id value returns the Chars of the corresponding entity.
139 function Get_Unit_Name
(U_Id
: RTU_Id
) return Unit_Name_Type
is
140 Uname_Chars
: constant String := RTU_Id
'Image (U_Id
);
143 Name_Len
:= Uname_Chars
'Length;
144 Name_Buffer
(1 .. Name_Len
) := Uname_Chars
;
145 Set_Casing
(All_Lower_Case
);
147 if U_Id
in Ada_Child
then
148 Name_Buffer
(4) := '.';
150 if U_Id
in Ada_Calendar_Child
then
151 Name_Buffer
(13) := '.';
153 elsif U_Id
in Ada_Finalization_Child
then
154 Name_Buffer
(17) := '.';
156 elsif U_Id
in Ada_Real_Time_Child
then
157 Name_Buffer
(14) := '.';
159 elsif U_Id
in Ada_Streams_Child
then
160 Name_Buffer
(12) := '.';
162 elsif U_Id
in Ada_Text_IO_Child
then
163 Name_Buffer
(12) := '.';
165 elsif U_Id
in Ada_Wide_Text_IO_Child
then
166 Name_Buffer
(17) := '.';
169 elsif U_Id
in Interfaces_Child
then
170 Name_Buffer
(11) := '.';
172 elsif U_Id
in System_Child
then
173 Name_Buffer
(7) := '.';
175 if U_Id
in System_Tasking_Child
then
176 Name_Buffer
(15) := '.';
179 if U_Id
in System_Tasking_Restricted_Child
then
180 Name_Buffer
(26) := '.';
183 if U_Id
in System_Tasking_Protected_Objects_Child
then
184 Name_Buffer
(33) := '.';
187 if U_Id
in System_Tasking_Async_Delays_Child
then
188 Name_Buffer
(28) := '.';
192 -- Add %s at end for spec
194 Name_Buffer
(Name_Len
+ 1) := '%';
195 Name_Buffer
(Name_Len
+ 2) := 's';
196 Name_Len
:= Name_Len
+ 2;
205 procedure Initialize
is
207 -- Initialize the unit table
210 RT_Unit_Table
(J
).Entity
:= Empty
;
214 RE_Table
(J
) := Empty
;
222 function Is_RTE
(Ent
: Entity_Id
; E
: RE_Id
) return Boolean is
223 E_Unit_Name
: Unit_Name_Type
;
224 Ent_Unit_Name
: Unit_Name_Type
;
234 -- If E has already a corresponding entity, check it directly,
235 -- going to full views if they exist to deal with the incomplete
236 -- and private type cases properly.
238 elsif Present
(RE_Table
(E
)) then
241 if Is_Type
(E1
) and then Present
(Full_View
(E1
)) then
242 E1
:= Full_View
(E1
);
247 if Is_Type
(E2
) and then Present
(Full_View
(E2
)) then
248 E2
:= Full_View
(E2
);
254 -- If the unit containing E is not loaded, we already know that
255 -- the entity we have cannot have come from this unit.
257 E_Unit_Name
:= Get_Unit_Name
(RE_Unit_Table
(E
));
259 if not Is_Loaded
(E_Unit_Name
) then
263 -- Here the unit containing the entity is loaded. We have not made
264 -- an explicit call to RTE to get the entity in question, but we may
265 -- have obtained a reference to it indirectly from some other entity
266 -- in the same unit, or some other unit that references it.
268 -- Get the defining unit of the entity
272 if Ekind
(S
) /= E_Package
then
276 Ent_Unit_Name
:= Get_Unit_Name
(Unit_Declaration_Node
(S
));
278 -- If the defining unit of the entity we are testing is not the
279 -- unit containing E, then they cannot possibly match.
281 if Ent_Unit_Name
/= E_Unit_Name
then
285 -- If the units match, then compare the names (remember that no
286 -- overloading is permitted in entities fetched using Rtsfind).
288 if RE_Chars
(E
) = Chars
(Ent
) then
291 -- If front-end inlining is enabled, we may be within a body that
292 -- contains inlined functions, which has not been retrieved through
293 -- rtsfind, and therefore is not yet recorded in the RT_Unit_Table.
294 -- Add the unit information now, it must be fully available.
297 U
: RT_Unit_Table_Record
298 renames RT_Unit_Table
(RE_Unit_Table
(E
));
300 if No
(U
.Entity
) then
302 U
.Uname
:= E_Unit_Name
;
303 U
.Unum
:= Get_Source_Unit
(S
);
313 ----------------------------
314 -- Is_Text_IO_Kludge_Unit --
315 ----------------------------
317 function Is_Text_IO_Kludge_Unit
(Nam
: Node_Id
) return Boolean is
322 if Nkind
(Nam
) /= N_Expanded_Name
then
327 Sel
:= Selector_Name
(Nam
);
329 if Nkind
(Sel
) /= N_Expanded_Name
330 or else Nkind
(Prf
) /= N_Identifier
331 or else Chars
(Prf
) /= Name_Ada
337 Sel
:= Selector_Name
(Sel
);
340 Nkind
(Prf
) = N_Identifier
342 (Chars
(Prf
) = Name_Text_IO
or else Chars
(Prf
) = Name_Wide_Text_IO
)
344 Nkind
(Sel
) = N_Identifier
346 Chars
(Sel
) in Text_IO_Package_Name
;
348 end Is_Text_IO_Kludge_Unit
;
354 procedure Load_Fail
(S
: String; U_Id
: RTU_Id
; Ent_Name
: String := "") is
358 Write_Str
("fatal error: run-time library configuration error");
361 if Ent_Name
/= "" then
362 Write_Str
("cannot locate """);
364 -- Copy name skipping initial RE_ or RO_XX characters
366 if Ent_Name
(1 .. 2) = "RE" then
367 for J
in 4 .. Ent_Name
'Length loop
368 Name_Buffer
(J
- 3) := Ent_Name
(J
);
371 for J
in 7 .. Ent_Name
'Length loop
372 Name_Buffer
(J
- 6) := Ent_Name
(J
);
376 Name_Len
:= Ent_Name
'Length - 3;
377 Set_Casing
(Mixed_Case
);
378 Write_Str
(Name_Buffer
(1 .. Name_Len
));
379 Write_Str
(""" in file """);
382 Write_Str
("cannot load file """);
386 (Get_File_Name
(RT_Unit_Table
(U_Id
).Uname
, Subunit
=> False));
392 raise Unrecoverable_Error
;
399 procedure Load_RTU
(U_Id
: RTU_Id
; Use_Setting
: Boolean := False) is
401 U
: RT_Unit_Table_Record
renames RT_Unit_Table
(U_Id
);
402 Priv_Par
: Elist_Id
:= New_Elmt_List
;
405 procedure Save_Private_Visibility
;
406 -- If the current unit is the body of child unit or the spec of a
407 -- private child unit, the private declarations of the parent (s)
408 -- are visible. If the unit to be loaded is another public sibling,
409 -- its compilation will affect the visibility of the common ancestors.
410 -- Indicate those that must be restored.
412 procedure Restore_Private_Visibility
;
413 -- Restore the visibility of ancestors after compiling RTU.
415 --------------------------------
416 -- Restore_Private_Visibility --
417 --------------------------------
419 procedure Restore_Private_Visibility
is
423 E_Par
:= First_Elmt
(Priv_Par
);
425 while Present
(E_Par
) loop
426 if not In_Private_Part
(Node
(E_Par
)) then
427 Install_Private_Declarations
(Node
(E_Par
));
432 end Restore_Private_Visibility
;
434 -----------------------------
435 -- Save_Private_Visibility --
436 -----------------------------
438 procedure Save_Private_Visibility
is
442 Par
:= Scope
(Current_Scope
);
445 and then Par
/= Standard_Standard
447 if Ekind
(Par
) = E_Package
448 and then Is_Compilation_Unit
(Par
)
449 and then In_Private_Part
(Par
)
451 Append_Elmt
(Par
, Priv_Par
);
456 end Save_Private_Visibility
;
458 -- Start of processing for Load_RTU
461 -- Nothing to do if unit is already loaded
463 if Present
(U
.Entity
) then
467 -- Otherwise we need to load the unit, First build unit name
468 -- from the enumeration literal name in type RTU_Id.
470 U
.Uname
:= Get_Unit_Name
(U_Id
);
472 Loaded
:= Is_Loaded
(U
.Uname
);
474 -- Now do the load call, note that setting Error_Node to Empty is
475 -- a signal to Load_Unit that we will regard a failure to find the
476 -- file as a fatal error, and that it should not output any kind
477 -- of diagnostics, since we will take care of it here.
481 (Load_Name
=> U
.Uname
,
484 Error_Node
=> Empty
);
486 if U
.Unum
= No_Unit
then
487 Load_Fail
("unit not found", U_Id
);
489 elsif Fatal_Error
(U
.Unum
) then
490 Load_Fail
("parser errors", U_Id
);
493 -- Make sure that the unit is analyzed
496 Was_Analyzed
: Boolean := Analyzed
(Cunit
(Current_Sem_Unit
));
499 -- Pretend that the current unit is analysed, in case it is
500 -- System or some such. This allows us to put some declarations,
501 -- such as exceptions and packed arrays of Boolean, into System
502 -- even though expanding them requires System...
504 -- This is a bit odd but works fine. If the RTS unit does not depend
505 -- in any way on the current unit, then it never gets back into the
506 -- current unit's tree, and the change we make to the current unit
507 -- tree is never noticed by anyone (it is undone in a moment). That
508 -- is the normal situation.
510 -- If the RTS Unit *does* depend on the current unit, for instance,
511 -- when you are compiling System, then you had better have finished
512 -- Analyzing the part of System that is depended on before you try
513 -- to load the RTS Unit. This means having the System ordered in an
514 -- appropriate manner.
516 Set_Analyzed
(Cunit
(Current_Sem_Unit
), True);
518 if not Analyzed
(Cunit
(U
.Unum
)) then
520 Save_Private_Visibility
;
521 Semantics
(Cunit
(U
.Unum
));
522 Restore_Private_Visibility
;
524 if Fatal_Error
(U
.Unum
) then
525 Load_Fail
("semantic errors", U_Id
);
531 Set_Analyzed
(Cunit
(Current_Sem_Unit
), Was_Analyzed
);
534 Lib_Unit
:= Unit
(Cunit
(U
.Unum
));
535 U
.Entity
:= Defining_Entity
(Lib_Unit
);
538 Set_Is_Potentially_Use_Visible
(U
.Entity
, True);
546 function RE_Chars
(E
: RE_Id
) return Name_Id
is
547 RE_Name_Chars
: constant String := RE_Id
'Image (E
);
550 -- Copy name skipping initial RE_ or RO_XX characters
552 if RE_Name_Chars
(1 .. 2) = "RE" then
553 for J
in 4 .. RE_Name_Chars
'Last loop
554 Name_Buffer
(J
- 3) := Fold_Lower
(RE_Name_Chars
(J
));
557 Name_Len
:= RE_Name_Chars
'Length - 3;
560 for J
in 7 .. RE_Name_Chars
'Last loop
561 Name_Buffer
(J
- 6) := Fold_Lower
(RE_Name_Chars
(J
));
564 Name_Len
:= RE_Name_Chars
'Length - 6;
574 function RTE
(E
: RE_Id
) return Entity_Id
is
575 U_Id
: constant RTU_Id
:= RE_Unit_Table
(E
);
576 U
: RT_Unit_Table_Record
renames RT_Unit_Table
(U_Id
);
582 Ravenscar
: constant Boolean := Restricted_Profile
;
584 -- The following flag is used to disable front-end inlining when RTE
585 -- is invoked. This prevents the analysis of other runtime bodies when
586 -- a particular spec is loaded through Rtsfind. This is both efficient,
587 -- and it prevents spurious visibility conflicts between use-visible
588 -- user entities, and entities in run-time packages.
590 -- In No_Run_Time mode, subprograms marked Inlined_Always must be
591 -- inlined, so in the case we retain the Front_End_Inlining mode.
593 Save_Front_End_Inlining
: Boolean;
596 -- Reject programs that make use of distribution features not supported
597 -- on the current target. On such targets (VMS, Vxworks, others?) we
598 -- only provide a minimal body for System.Rpc that only supplies an
599 -- implementation of partition_id.
601 function Find_Local_Entity
(E
: RE_Id
) return Entity_Id
;
602 -- This function is used when entity E is in this compilation's main
603 -- unit. It gets the value from the already compiled declaration.
605 function Make_Unit_Name
(N
: Node_Id
) return Node_Id
;
606 -- If the unit is a child unit, build fully qualified name for use
613 procedure Check_RPC
is
614 Body_Name
: Unit_Name_Type
;
615 Unum
: Unit_Number_Type
;
618 -- Bypass this check if debug flag -gnatdR set
620 if Debug_Flag_RR
then
624 -- Otherwise we need the check if we are going after one of
625 -- the critical entities in System.RPC in stubs mode.
627 if (Distribution_Stub_Mode
= Generate_Receiver_Stub_Body
629 Distribution_Stub_Mode
= Generate_Caller_Stub_Body
)
630 and then (E
= RE_Do_Rpc
631 or else E
= RE_Do_Apc
632 or else E
= RE_Params_Stream_Type
633 or else E
= RE_RPC_Receiver
)
635 -- Load body of System.Rpc, and abort if this is the body that is
636 -- provided by GNAT, for which these features are not supported
637 -- on current target. We identify the gnat body by the presence
638 -- of a local entity called Gnat in the first declaration.
640 Lib_Unit
:= Unit
(Cunit
(U
.Unum
));
641 Body_Name
:= Get_Body_Name
(Get_Unit_Name
(Lib_Unit
));
644 (Load_Name
=> Body_Name
,
650 if Unum
/= No_Unit
then
652 Decls
: List_Id
:= Declarations
(Unit
(Cunit
(Unum
)));
656 and then Nkind
(First
(Decls
)) = N_Object_Declaration
658 Chars
(Defining_Identifier
(First
(Decls
))) = Name_Gnat
661 Write_Str
("distribution feature not supported");
663 raise Unrecoverable_Error
;
670 ------------------------
671 -- Find_System_Entity --
672 ------------------------
674 function Find_Local_Entity
(E
: RE_Id
) return Entity_Id
is
675 RE_Str
: String renames RE_Id
'Image (E
);
678 Save_Nam
: constant String := Name_Buffer
(1 .. Name_Len
);
679 -- Save name buffer and length over call
682 Name_Len
:= Natural'Max (0, RE_Str
'Length - 3);
683 Name_Buffer
(1 .. Name_Len
) :=
684 RE_Str
(RE_Str
'First + 3 .. RE_Str
'Last);
686 Ent
:= Entity_Id
(Get_Name_Table_Info
(Name_Find
));
688 Name_Len
:= Save_Nam
'Length;
689 Name_Buffer
(1 .. Name_Len
) := Save_Nam
;
692 end Find_Local_Entity
;
698 function Make_Unit_Name
(N
: Node_Id
) return Node_Id
is
703 Nam
:= New_Reference_To
(U
.Entity
, Standard_Location
);
704 Scop
:= Scope
(U
.Entity
);
706 if Nkind
(N
) = N_Defining_Program_Unit_Name
then
707 while Scop
/= Standard_Standard
loop
709 Make_Expanded_Name
(Standard_Location
,
710 Chars
=> Chars
(U
.Entity
),
711 Prefix
=> New_Reference_To
(Scop
, Standard_Location
),
712 Selector_Name
=> Nam
);
713 Set_Entity
(Nam
, U
.Entity
);
715 Scop
:= Scope
(Scop
);
722 -- Start of processing for RTE
726 -- Check violation of no run time and ravenscar mode
729 and then not OK_To_Use_In_No_Run_Time_Mode
(U_Id
)
732 or else not OK_To_Use_In_Ravenscar_Mode
(U_Id
)
734 Disallow_In_No_Run_Time_Mode
(Current_Error_Node
);
739 -- Doing a rtsfind in system.ads is special, as we cannot do this
740 -- when compiling System itself. So if we are compiling system then
741 -- we should already have acquired and processed the declaration
742 -- of the entity. The test is to see if this compilation's main unit
743 -- is System. If so, return the value from the already compiled
744 -- declaration and otherwise do a regular find.
746 -- Not pleasant, but these kinds of annoying recursion when
747 -- writing an Ada compiler in Ada have to be broken somewhere!
749 if Present
(Main_Unit_Entity
)
750 and then Chars
(Main_Unit_Entity
) = Name_System
751 and then Analyzed
(Main_Unit_Entity
)
752 and then not Is_Child_Unit
(Main_Unit_Entity
)
754 return Find_Local_Entity
(E
);
757 Save_Front_End_Inlining
:= Front_End_Inlining
;
758 Front_End_Inlining
:= No_Run_Time
;
760 -- Load unit if unit not previously loaded
762 if No
(RE_Table
(E
)) then
764 Lib_Unit
:= Unit
(Cunit
(U
.Unum
));
766 -- In the subprogram case, we are all done, the entity we want
767 -- is the entity for the subprogram itself. Note that we do not
768 -- bother to check that it is the entity that was requested.
769 -- the only way that could fail to be the case is if runtime is
770 -- hopelessly misconfigured, and it isn't worth testing for this.
772 if Nkind
(Lib_Unit
) = N_Subprogram_Declaration
then
773 RE_Table
(E
) := U
.Entity
;
775 -- Otherwise we must have the package case, and here we have to
776 -- search the package entity chain for the entity we want. The
777 -- entity we want must be present in this chain, or we have a
778 -- misconfigured runtime.
781 pragma Assert
(Nkind
(Lib_Unit
) = N_Package_Declaration
);
782 Ename
:= RE_Chars
(E
);
784 Pkg_Ent
:= First_Entity
(U
.Entity
);
786 while Present
(Pkg_Ent
) loop
787 if Ename
= Chars
(Pkg_Ent
) then
788 RE_Table
(E
) := Pkg_Ent
;
793 Next_Entity
(Pkg_Ent
);
796 -- If we didn't find the unit we want, something is wrong
797 -- although in no run time mode, we already gave a suitable
798 -- message, and so we simply return Empty, and the caller must
799 -- be prepared to handle this if the RTE call is otherwise
800 -- possible in high integrity mode.
803 and then not OK_To_Use_In_No_Run_Time_Mode
(U_Id
)
805 Front_End_Inlining
:= Save_Front_End_Inlining
;
809 Load_Fail
("entity not in package", U_Id
, RE_Id
'Image (E
));
815 -- See if we have to generate a with for this entity. We generate
816 -- a with if the current unit is part of the extended main code
817 -- unit, and if we have not already added the with. The with is
818 -- added to the appropriate unit (the current one).
823 In_Extended_Main_Code_Unit
(Cunit_Entity
(Current_Sem_Unit
))
832 Lib_Unit
:= Unit
(Cunit
(U
.Unum
));
834 Make_With_Clause
(Standard_Location
,
837 (Defining_Unit_Name
(Specification
(Lib_Unit
))));
838 Set_Library_Unit
(Withn
, Cunit
(U
.Unum
));
839 Set_Corresponding_Spec
(Withn
, U
.Entity
);
840 Set_First_Name
(Withn
, True);
841 Set_Implicit_With
(Withn
, True);
843 Mark_Rewrite_Insertion
(Withn
);
844 Append
(Withn
, Context_Items
(Cunit
(Current_Sem_Unit
)));
848 Front_End_Inlining
:= Save_Front_End_Inlining
;
856 procedure Text_IO_Kludge
(Nam
: Node_Id
) is
859 type Name_Map_Type
is array (Text_IO_Package_Name
) of RTU_Id
;
861 Name_Map
: Name_Map_Type
:= Name_Map_Type
'(
862 Name_Decimal_IO => Ada_Text_IO_Decimal_IO,
863 Name_Enumeration_IO => Ada_Text_IO_Enumeration_IO,
864 Name_Fixed_IO => Ada_Text_IO_Fixed_IO,
865 Name_Float_IO => Ada_Text_IO_Float_IO,
866 Name_Integer_IO => Ada_Text_IO_Integer_IO,
867 Name_Modular_IO => Ada_Text_IO_Modular_IO);
869 Wide_Name_Map : Name_Map_Type := Name_Map_Type'(
870 Name_Decimal_IO
=> Ada_Wide_Text_IO_Decimal_IO
,
871 Name_Enumeration_IO
=> Ada_Wide_Text_IO_Enumeration_IO
,
872 Name_Fixed_IO
=> Ada_Wide_Text_IO_Fixed_IO
,
873 Name_Float_IO
=> Ada_Wide_Text_IO_Float_IO
,
874 Name_Integer_IO
=> Ada_Wide_Text_IO_Integer_IO
,
875 Name_Modular_IO
=> Ada_Wide_Text_IO_Modular_IO
);
878 -- Nothing to do if name is not identifier or a selected component
879 -- whose selector_name is not an identifier.
881 if Nkind
(Nam
) = N_Identifier
then
884 elsif Nkind
(Nam
) = N_Selected_Component
885 and then Nkind
(Selector_Name
(Nam
)) = N_Identifier
887 Chrs
:= Chars
(Selector_Name
(Nam
));
893 -- Nothing to do if name is not one of the Text_IO subpackages
894 -- Otherwise look through loaded units, and if we find Text_IO
895 -- or Wide_Text_IO already loaded, then load the proper child.
897 if Chrs
in Text_IO_Package_Name
then
898 for U
in Main_Unit
.. Last_Unit
loop
899 Get_Name_String
(Unit_File_Name
(U
));
901 if Name_Len
= 12 then
903 -- Here is where we do the loads if we find one of the
904 -- units Ada.Text_IO or Ada.Wide_Text_IO. An interesting
905 -- detail is that these units may already be used (i.e.
906 -- their In_Use flags may be set). Normally when the In_Use
907 -- flag is set, the Is_Potentially_Use_Visible flag of all
908 -- entities in the package is set, but the new entity we
909 -- are mysteriously adding was not there to have its flag
910 -- set at the time. So that's why we pass the extra parameter
911 -- to RTU_Find, to make sure the flag does get set now.
912 -- Given that those generic packages are in fact child units,
913 -- we must indicate that they are visible.
915 if Name_Buffer
(1 .. 12) = "a-textio.ads" then
916 Load_RTU
(Name_Map
(Chrs
), In_Use
(Cunit_Entity
(U
)));
917 Set_Is_Visible_Child_Unit
918 (RT_Unit_Table
(Name_Map
(Chrs
)).Entity
);
920 elsif Name_Buffer
(1 .. 12) = "a-witeio.ads" then
921 Load_RTU
(Wide_Name_Map
(Chrs
), In_Use
(Cunit_Entity
(U
)));
922 Set_Is_Visible_Child_Unit
923 (RT_Unit_Table
(Wide_Name_Map
(Chrs
)).Entity
);