1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2006, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 pragma Style_Checks
(All_Checks
);
35 -- Subprogram ordering not enforced in this unit
36 -- (because of some logical groupings).
38 with Atree
; use Atree
;
39 with Einfo
; use Einfo
;
40 with Fname
; use Fname
;
41 with Namet
; use Namet
;
42 with Output
; use Output
;
43 with Sinfo
; use Sinfo
;
44 with Sinput
; use Sinput
;
45 with Stand
; use Stand
;
46 with Stringt
; use Stringt
;
47 with Tree_IO
; use Tree_IO
;
48 with Uname
; use Uname
;
52 Switch_Storing_Enabled
: Boolean := True;
53 -- Set to False by Disable_Switch_Storing
55 -----------------------
56 -- Local Subprograms --
57 -----------------------
60 Yes_Before
, -- S1 is in same extended unit as S2 and appears before it
61 Yes_Same
, -- S1 is in same extended unit as S2, Slocs are the same
62 Yes_After
, -- S1 is in same extended unit as S2, and appears after it
63 No
); -- S2 is not in same extended unit as S2
65 function Check_Same_Extended_Unit
(S1
, S2
: Source_Ptr
) return SEU_Result
;
66 -- Used by In_Same_Extended_Unit and Earlier_In_Extended_Unit. Returns
67 -- value as described above.
69 function Get_Code_Or_Source_Unit
71 Unwind_Instances
: Boolean) return Unit_Number_Type
;
72 -- Common code for Get_Code_Unit (get unit of instantiation for location)
73 -- and Get_Source_Unit (get unit of template for location).
75 --------------------------------------------
76 -- Access Functions for Unit Table Fields --
77 --------------------------------------------
79 function Cunit
(U
: Unit_Number_Type
) return Node_Id
is
81 return Units
.Table
(U
).Cunit
;
84 function Cunit_Entity
(U
: Unit_Number_Type
) return Entity_Id
is
86 return Units
.Table
(U
).Cunit_Entity
;
89 function Dependency_Num
(U
: Unit_Number_Type
) return Nat
is
91 return Units
.Table
(U
).Dependency_Num
;
94 function Dynamic_Elab
(U
: Unit_Number_Type
) return Boolean is
96 return Units
.Table
(U
).Dynamic_Elab
;
99 function Error_Location
(U
: Unit_Number_Type
) return Source_Ptr
is
101 return Units
.Table
(U
).Error_Location
;
104 function Expected_Unit
(U
: Unit_Number_Type
) return Unit_Name_Type
is
106 return Units
.Table
(U
).Expected_Unit
;
109 function Fatal_Error
(U
: Unit_Number_Type
) return Boolean is
111 return Units
.Table
(U
).Fatal_Error
;
114 function Generate_Code
(U
: Unit_Number_Type
) return Boolean is
116 return Units
.Table
(U
).Generate_Code
;
119 function Has_RACW
(U
: Unit_Number_Type
) return Boolean is
121 return Units
.Table
(U
).Has_RACW
;
124 function Ident_String
(U
: Unit_Number_Type
) return Node_Id
is
126 return Units
.Table
(U
).Ident_String
;
129 function Loading
(U
: Unit_Number_Type
) return Boolean is
131 return Units
.Table
(U
).Loading
;
134 function Main_Priority
(U
: Unit_Number_Type
) return Int
is
136 return Units
.Table
(U
).Main_Priority
;
139 function Munit_Index
(U
: Unit_Number_Type
) return Nat
is
141 return Units
.Table
(U
).Munit_Index
;
144 function Source_Index
(U
: Unit_Number_Type
) return Source_File_Index
is
146 return Units
.Table
(U
).Source_Index
;
149 function Unit_File_Name
(U
: Unit_Number_Type
) return File_Name_Type
is
151 return Units
.Table
(U
).Unit_File_Name
;
154 function Unit_Name
(U
: Unit_Number_Type
) return Unit_Name_Type
is
156 return Units
.Table
(U
).Unit_Name
;
159 ------------------------------------------
160 -- Subprograms to Set Unit Table Fields --
161 ------------------------------------------
163 procedure Set_Cunit
(U
: Unit_Number_Type
; N
: Node_Id
) is
165 Units
.Table
(U
).Cunit
:= N
;
168 procedure Set_Cunit_Entity
(U
: Unit_Number_Type
; E
: Entity_Id
) is
170 Units
.Table
(U
).Cunit_Entity
:= E
;
171 Set_Is_Compilation_Unit
(E
);
172 end Set_Cunit_Entity
;
174 procedure Set_Dynamic_Elab
(U
: Unit_Number_Type
; B
: Boolean := True) is
176 Units
.Table
(U
).Dynamic_Elab
:= B
;
177 end Set_Dynamic_Elab
;
179 procedure Set_Error_Location
(U
: Unit_Number_Type
; W
: Source_Ptr
) is
181 Units
.Table
(U
).Error_Location
:= W
;
182 end Set_Error_Location
;
184 procedure Set_Fatal_Error
(U
: Unit_Number_Type
; B
: Boolean := True) is
186 Units
.Table
(U
).Fatal_Error
:= B
;
189 procedure Set_Generate_Code
(U
: Unit_Number_Type
; B
: Boolean := True) is
191 Units
.Table
(U
).Generate_Code
:= B
;
192 end Set_Generate_Code
;
194 procedure Set_Has_RACW
(U
: Unit_Number_Type
; B
: Boolean := True) is
196 Units
.Table
(U
).Has_RACW
:= B
;
199 procedure Set_Ident_String
(U
: Unit_Number_Type
; N
: Node_Id
) is
201 Units
.Table
(U
).Ident_String
:= N
;
202 end Set_Ident_String
;
204 procedure Set_Loading
(U
: Unit_Number_Type
; B
: Boolean := True) is
206 Units
.Table
(U
).Loading
:= B
;
209 procedure Set_Main_Priority
(U
: Unit_Number_Type
; P
: Int
) is
211 Units
.Table
(U
).Main_Priority
:= P
;
212 end Set_Main_Priority
;
214 procedure Set_Unit_Name
(U
: Unit_Number_Type
; N
: Unit_Name_Type
) is
216 Units
.Table
(U
).Unit_Name
:= N
;
219 ------------------------------
220 -- Check_Same_Extended_Unit --
221 ------------------------------
223 function Check_Same_Extended_Unit
(S1
, S2
: Source_Ptr
) return SEU_Result
is
226 Sind1
: Source_File_Index
;
227 Sind2
: Source_File_Index
;
230 Unum1
: Unit_Number_Type
;
231 Unum2
: Unit_Number_Type
;
238 if S1
= No_Location
or else S2
= No_Location
then
241 elsif S1
= Standard_Location
then
242 if S2
= Standard_Location
then
248 elsif S2
= Standard_Location
then
254 Unum1
:= Get_Code_Unit
(Sloc1
);
255 Unum2
:= Get_Code_Unit
(Sloc2
);
258 Sind1
:= Get_Source_File_Index
(Sloc1
);
259 Sind2
:= Get_Source_File_Index
(Sloc2
);
261 if Sind1
= Sind2
then
262 if Sloc1
< Sloc2
then
264 elsif Sloc1
> Sloc2
then
271 -- OK, the two nodes are in separate source elements, but this is not
272 -- decisive, because of the issue of subunits and instantiations.
274 -- First we deal with subunits, since if the subunit is in an
275 -- instantiation, we know that the parent is in the corresponding
276 -- instantiation, since that is the only way we can have a subunit
277 -- that is part of an instantiation.
279 Unit1
:= Unit
(Cunit
(Unum1
));
280 Unit2
:= Unit
(Cunit
(Unum2
));
282 if Nkind
(Unit1
) = N_Subunit
283 and then Present
(Corresponding_Stub
(Unit1
))
285 -- Both in subunits. They could have a common ancestor. If they
286 -- do, then the deeper one must have a longer unit name. Replace
287 -- the deeper one with its corresponding stub, in order to find
288 -- nearest common ancestor, if any.
290 if Nkind
(Unit2
) = N_Subunit
291 and then Present
(Corresponding_Stub
(Unit2
))
293 if Length_Of_Name
(Unit_Name
(Unum1
)) <
294 Length_Of_Name
(Unit_Name
(Unum2
))
296 Sloc2
:= Sloc
(Corresponding_Stub
(Unit2
));
297 Unum2
:= Get_Source_Unit
(Sloc2
);
301 Sloc1
:= Sloc
(Corresponding_Stub
(Unit1
));
302 Unum1
:= Get_Source_Unit
(Sloc1
);
306 -- Nod1 in subunit, Nod2 not
309 Sloc1
:= Sloc
(Corresponding_Stub
(Unit1
));
310 Unum1
:= Get_Source_Unit
(Sloc1
);
314 -- Nod2 in subunit, Nod1 not
316 elsif Nkind
(Unit2
) = N_Subunit
317 and then Present
(Corresponding_Stub
(Unit2
))
319 Sloc2
:= Sloc
(Corresponding_Stub
(Unit2
));
320 Unum2
:= Get_Source_Unit
(Sloc2
);
324 -- At this stage we know that neither is a subunit, so we deal
325 -- with instantiations, since we culd have a common ancestor
327 Inst1
:= Instantiation
(Sind1
);
328 Inst2
:= Instantiation
(Sind2
);
330 if Inst1
/= No_Location
then
332 -- Both are instantiations
334 if Inst2
/= No_Location
then
336 Depth1
:= Instantiation_Depth
(Sloc1
);
337 Depth2
:= Instantiation_Depth
(Sloc2
);
339 if Depth1
< Depth2
then
341 Unum2
:= Get_Source_Unit
(Sloc2
);
344 elsif Depth1
> Depth2
then
346 Unum1
:= Get_Source_Unit
(Sloc1
);
352 Unum1
:= Get_Source_Unit
(Sloc1
);
353 Unum2
:= Get_Source_Unit
(Sloc2
);
357 -- Only first node is in instantiation
361 Unum1
:= Get_Source_Unit
(Sloc1
);
365 -- Only second node is instantiation
367 elsif Inst2
/= No_Location
then
369 Unum2
:= Get_Source_Unit
(Sloc2
);
373 -- No instantiations involved, so we are not in the same unit
374 -- However, there is one case still to check, namely the case
375 -- where one location is in the spec, and the other in the
376 -- corresponding body (the spec location is earlier).
378 if Nkind
(Unit1
) = N_Subprogram_Body
380 Nkind
(Unit1
) = N_Package_Body
382 if Library_Unit
(Cunit
(Unum1
)) = Cunit
(Unum2
) then
386 elsif Nkind
(Unit2
) = N_Subprogram_Body
388 Nkind
(Unit2
) = N_Package_Body
390 if Library_Unit
(Cunit
(Unum2
)) = Cunit
(Unum1
) then
395 -- If that special case does not occur, then we are certain that
396 -- the two locations are really in separate units.
403 end Check_Same_Extended_Unit
;
405 -------------------------------
406 -- Compilation_Switches_Last --
407 -------------------------------
409 function Compilation_Switches_Last
return Nat
is
411 return Compilation_Switches
.Last
;
412 end Compilation_Switches_Last
;
414 procedure Disable_Switch_Storing
is
416 Switch_Storing_Enabled
:= False;
417 end Disable_Switch_Storing
;
419 ------------------------------
420 -- Earlier_In_Extended_Unit --
421 ------------------------------
423 function Earlier_In_Extended_Unit
(S1
, S2
: Source_Ptr
) return Boolean is
425 return Check_Same_Extended_Unit
(S1
, S2
) = Yes_Before
;
426 end Earlier_In_Extended_Unit
;
428 ----------------------------
429 -- Entity_Is_In_Main_Unit --
430 ----------------------------
432 function Entity_Is_In_Main_Unit
(E
: Entity_Id
) return Boolean is
438 while S
/= Standard_Standard
loop
439 if S
= Main_Unit_Entity
then
441 elsif Ekind
(S
) = E_Package
and then Is_Child_Unit
(S
) then
449 end Entity_Is_In_Main_Unit
;
451 ---------------------------------
452 -- Generic_Separately_Compiled --
453 ---------------------------------
455 function Generic_Separately_Compiled
(E
: Entity_Id
) return Boolean is
457 -- We do not generate object files for internal generics, because
458 -- the only thing they would contain is the elaboration boolean, and
459 -- we are careful to elaborate all predefined units first anyway, so
460 -- this boolean is not needed.
462 if Is_Internal_File_Name
463 (Fname
=> Unit_File_Name
(Get_Source_Unit
(E
)),
464 Renamings_Included
=> True)
468 -- All other generic units do generate object files
473 end Generic_Separately_Compiled
;
475 function Generic_Separately_Compiled
476 (Sfile
: File_Name_Type
) return Boolean
479 -- Exactly the same as previous function, but works directly on a file
482 if Is_Internal_File_Name
484 Renamings_Included
=> True)
488 -- All other generic units do generate object files
493 end Generic_Separately_Compiled
;
495 -----------------------------
496 -- Get_Code_Or_Source_Unit --
497 -----------------------------
499 function Get_Code_Or_Source_Unit
501 Unwind_Instances
: Boolean) return Unit_Number_Type
504 -- Search table unless we have No_Location, which can happen if the
505 -- relevant location has not been set yet. Happens for example when
506 -- we obtain Sloc (Cunit (Main_Unit)) before it is set.
508 if S
/= No_Location
then
510 Source_File
: Source_File_Index
;
511 Source_Unit
: Unit_Number_Type
;
514 Source_File
:= Get_Source_File_Index
(S
);
516 if Unwind_Instances
then
517 while Template
(Source_File
) /= No_Source_File
loop
518 Source_File
:= Template
(Source_File
);
522 Source_Unit
:= Unit
(Source_File
);
524 if Source_Unit
/= No_Unit
then
530 -- If S was No_Location, or was not in the table, we must be in the main
531 -- source unit (and the value has not been placed in the table yet),
532 -- or in one of the configuration pragma files.
535 end Get_Code_Or_Source_Unit
;
541 function Get_Code_Unit
(S
: Source_Ptr
) return Unit_Number_Type
is
543 return Get_Code_Or_Source_Unit
(Top_Level_Location
(S
),
544 Unwind_Instances
=> False);
547 function Get_Code_Unit
(N
: Node_Or_Entity_Id
) return Unit_Number_Type
is
549 return Get_Code_Unit
(Sloc
(N
));
552 ----------------------------
553 -- Get_Compilation_Switch --
554 ----------------------------
556 function Get_Compilation_Switch
(N
: Pos
) return String_Ptr
is
558 if N
<= Compilation_Switches
.Last
then
559 return Compilation_Switches
.Table
(N
);
564 end Get_Compilation_Switch
;
566 ----------------------------------
567 -- Get_Cunit_Entity_Unit_Number --
568 ----------------------------------
570 function Get_Cunit_Entity_Unit_Number
571 (E
: Entity_Id
) return Unit_Number_Type
574 for U
in Units
.First
.. Units
.Last
loop
575 if Cunit_Entity
(U
) = E
then
580 -- If not in the table, must be the main source unit, and we just
581 -- have not got it put into the table yet.
584 end Get_Cunit_Entity_Unit_Number
;
586 ---------------------------
587 -- Get_Cunit_Unit_Number --
588 ---------------------------
590 function Get_Cunit_Unit_Number
(N
: Node_Id
) return Unit_Number_Type
is
592 for U
in Units
.First
.. Units
.Last
loop
593 if Cunit
(U
) = N
then
598 -- If not in the table, must be the main source unit, and we just
599 -- have not got it put into the table yet.
602 end Get_Cunit_Unit_Number
;
604 ---------------------
605 -- Get_Source_Unit --
606 ---------------------
608 function Get_Source_Unit
(S
: Source_Ptr
) return Unit_Number_Type
is
610 return Get_Code_Or_Source_Unit
(S
, Unwind_Instances
=> True);
613 function Get_Source_Unit
(N
: Node_Or_Entity_Id
) return Unit_Number_Type
is
615 return Get_Source_Unit
(Sloc
(N
));
618 --------------------------------
619 -- In_Extended_Main_Code_Unit --
620 --------------------------------
622 function In_Extended_Main_Code_Unit
623 (N
: Node_Or_Entity_Id
) return Boolean
626 if Sloc
(N
) = Standard_Location
then
629 elsif Sloc
(N
) = No_Location
then
632 -- Special case Itypes to test the Sloc of the associated node. The
633 -- reason we do this is for possible calls from gigi after -gnatD
634 -- processing is complete in sprint. This processing updates the
635 -- sloc fields of all nodes in the tree, but itypes are not in the
636 -- tree so their slocs do not get updated.
638 elsif Nkind
(N
) = N_Defining_Identifier
639 and then Is_Itype
(N
)
641 return In_Extended_Main_Code_Unit
(Associated_Node_For_Itype
(N
));
643 -- Otherwise see if we are in the main unit
645 elsif Get_Code_Unit
(Sloc
(N
)) = Get_Code_Unit
(Cunit
(Main_Unit
)) then
648 -- Node may be in spec (or subunit etc) of main unit
652 In_Same_Extended_Unit
(N
, Cunit
(Main_Unit
));
654 end In_Extended_Main_Code_Unit
;
656 function In_Extended_Main_Code_Unit
(Loc
: Source_Ptr
) return Boolean is
658 if Loc
= Standard_Location
then
661 elsif Loc
= No_Location
then
664 -- Otherwise see if we are in the main unit
666 elsif Get_Code_Unit
(Loc
) = Get_Code_Unit
(Cunit
(Main_Unit
)) then
669 -- Location may be in spec (or subunit etc) of main unit
673 In_Same_Extended_Unit
(Loc
, Sloc
(Cunit
(Main_Unit
)));
675 end In_Extended_Main_Code_Unit
;
677 ----------------------------------
678 -- In_Extended_Main_Source_Unit --
679 ----------------------------------
681 function In_Extended_Main_Source_Unit
682 (N
: Node_Or_Entity_Id
) return Boolean
684 Nloc
: constant Source_Ptr
:= Sloc
(N
);
685 Mloc
: constant Source_Ptr
:= Sloc
(Cunit
(Main_Unit
));
688 -- If Mloc is not set, it means we are still parsing the main unit,
689 -- so everything so far is in the extended main source unit.
691 if Mloc
= No_Location
then
694 -- Special value cases
696 elsif Nloc
= Standard_Location
then
699 elsif Nloc
= No_Location
then
702 -- Special case Itypes to test the Sloc of the associated node. The
703 -- reason we do this is for possible calls from gigi after -gnatD
704 -- processing is complete in sprint. This processing updates the
705 -- sloc fields of all nodes in the tree, but itypes are not in the
706 -- tree so their slocs do not get updated.
708 elsif Nkind
(N
) = N_Defining_Identifier
709 and then Is_Itype
(N
)
711 return In_Extended_Main_Source_Unit
(Associated_Node_For_Itype
(N
));
713 -- Otherwise compare original locations to see if in same unit
717 In_Same_Extended_Unit
718 (Original_Location
(Nloc
), Original_Location
(Mloc
));
720 end In_Extended_Main_Source_Unit
;
722 function In_Extended_Main_Source_Unit
723 (Loc
: Source_Ptr
) return Boolean
725 Mloc
: constant Source_Ptr
:= Sloc
(Cunit
(Main_Unit
));
728 -- If Mloc is not set, it means we are still parsing the main unit,
729 -- so everything so far is in the extended main source unit.
731 if Mloc
= No_Location
then
734 -- Special value cases
736 elsif Loc
= Standard_Location
then
739 elsif Loc
= No_Location
then
742 -- Otherwise compare original locations to see if in same unit
746 In_Same_Extended_Unit
747 (Original_Location
(Loc
), Original_Location
(Mloc
));
749 end In_Extended_Main_Source_Unit
;
751 ------------------------
752 -- In_Predefined_Unit --
753 ------------------------
755 function In_Predefined_Unit
(N
: Node_Or_Entity_Id
) return Boolean is
757 return In_Predefined_Unit
(Sloc
(N
));
758 end In_Predefined_Unit
;
760 function In_Predefined_Unit
(S
: Source_Ptr
) return Boolean is
761 Unit
: constant Unit_Number_Type
:= Get_Source_Unit
(S
);
762 File
: constant File_Name_Type
:= Unit_File_Name
(Unit
);
764 return Is_Predefined_File_Name
(File
);
765 end In_Predefined_Unit
;
767 -----------------------
768 -- In_Same_Code_Unit --
769 -----------------------
771 function In_Same_Code_Unit
(N1
, N2
: Node_Or_Entity_Id
) return Boolean is
772 S1
: constant Source_Ptr
:= Sloc
(N1
);
773 S2
: constant Source_Ptr
:= Sloc
(N2
);
776 if S1
= No_Location
or else S2
= No_Location
then
779 elsif S1
= Standard_Location
then
780 return S2
= Standard_Location
;
782 elsif S2
= Standard_Location
then
786 return Get_Code_Unit
(N1
) = Get_Code_Unit
(N2
);
787 end In_Same_Code_Unit
;
789 ---------------------------
790 -- In_Same_Extended_Unit --
791 ---------------------------
793 function In_Same_Extended_Unit
794 (N1
, N2
: Node_Or_Entity_Id
) return Boolean
797 return Check_Same_Extended_Unit
(Sloc
(N1
), Sloc
(N2
)) /= No
;
798 end In_Same_Extended_Unit
;
800 function In_Same_Extended_Unit
(S1
, S2
: Source_Ptr
) return Boolean is
802 return Check_Same_Extended_Unit
(S1
, S2
) /= No
;
803 end In_Same_Extended_Unit
;
805 -------------------------
806 -- In_Same_Source_Unit --
807 -------------------------
809 function In_Same_Source_Unit
(N1
, N2
: Node_Or_Entity_Id
) return Boolean is
810 S1
: constant Source_Ptr
:= Sloc
(N1
);
811 S2
: constant Source_Ptr
:= Sloc
(N2
);
814 if S1
= No_Location
or else S2
= No_Location
then
817 elsif S1
= Standard_Location
then
818 return S2
= Standard_Location
;
820 elsif S2
= Standard_Location
then
824 return Get_Source_Unit
(N1
) = Get_Source_Unit
(N2
);
825 end In_Same_Source_Unit
;
827 -----------------------------
828 -- Increment_Serial_Number --
829 -----------------------------
831 function Increment_Serial_Number
return Nat
is
832 TSN
: Int
renames Units
.Table
(Current_Sem_Unit
).Serial_Number
;
836 end Increment_Serial_Number
;
842 procedure Initialize
is
844 Linker_Option_Lines
.Init
;
847 Compilation_Switches
.Init
;
854 function Is_Loaded
(Uname
: Unit_Name_Type
) return Boolean is
856 for Unum
in Units
.First
.. Units
.Last
loop
857 if Uname
= Unit_Name
(Unum
) then
869 function Last_Unit
return Unit_Number_Type
is
878 procedure List
(File_Names_Only
: Boolean := False) is separate;
886 Linker_Option_Lines
.Locked
:= True;
887 Load_Stack
.Locked
:= True;
888 Units
.Locked
:= True;
889 Linker_Option_Lines
.Release
;
898 function Num_Units
return Nat
is
900 return Int
(Units
.Last
) - Int
(Main_Unit
) + 1;
907 procedure Remove_Unit
(U
: Unit_Number_Type
) is
909 if U
= Units
.Last
then
910 Units
.Decrement_Last
;
914 ----------------------------------
915 -- Replace_Linker_Option_String --
916 ----------------------------------
918 procedure Replace_Linker_Option_String
919 (S
: String_Id
; Match_String
: String)
922 if Match_String
'Length > 0 then
923 for J
in 1 .. Linker_Option_Lines
.Last
loop
924 String_To_Name_Buffer
(Linker_Option_Lines
.Table
(J
).Option
);
926 if Match_String
= Name_Buffer
(1 .. Match_String
'Length) then
927 Linker_Option_Lines
.Table
(J
).Option
:= S
;
933 Store_Linker_Option_String
(S
);
934 end Replace_Linker_Option_String
;
940 procedure Sort
(Tbl
: in out Unit_Ref_Table
) is separate;
942 ------------------------------
943 -- Store_Compilation_Switch --
944 ------------------------------
946 procedure Store_Compilation_Switch
(Switch
: String) is
948 if Switch_Storing_Enabled
then
949 Compilation_Switches
.Increment_Last
;
950 Compilation_Switches
.Table
(Compilation_Switches
.Last
) :=
953 -- Fix up --RTS flag which has been transformed by the gcc driver
956 if Switch'Last >= Switch'First + 4
957 and then Switch (Switch'First .. Switch'First + 4) = "-fRTS"
959 Compilation_Switches.Table
960 (Compilation_Switches.Last) (Switch'First + 1) := '-';
963 end Store_Compilation_Switch;
965 --------------------------------
966 -- Store_Linker_Option_String --
967 --------------------------------
969 procedure Store_Linker_Option_String (S : String_Id) is
971 Linker_Option_Lines.Increment_Last;
972 Linker_Option_Lines.Table (Linker_Option_Lines.Last) :=
973 (Option => S, Unit => Current_Sem_Unit);
974 end Store_Linker_Option_String;
976 -------------------------------
977 -- Synchronize_Serial_Number --
978 -------------------------------
980 procedure Synchronize_Serial_Number is
981 TSN : Int renames Units.Table (Current_Sem_Unit).Serial_Number;
984 end Synchronize_Serial_Number;
990 procedure Tree_Read is
997 -- Read Compilation_Switches table
1000 Compilation_Switches.Set_Last (N);
1002 for J in 1 .. N loop
1004 Compilation_Switches.Table (J) := S;
1012 procedure Tree_Write is
1016 -- Write Compilation_Switches table
1018 Tree_Write_Int (Compilation_Switches.Last);
1020 for J in 1 .. Compilation_Switches.Last loop
1021 Tree_Write_Str (Compilation_Switches.Table (J));
1029 function Version_Get (U : Unit_Number_Type) return Word_Hex_String is
1031 return Get_Hex_String (Units.Table (U).Version);
1034 ------------------------
1035 -- Version_Referenced --
1036 ------------------------
1038 procedure Version_Referenced (S : String_Id) is
1040 Version_Ref.Append (S);
1041 end Version_Referenced;