1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, 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 Output
; use Output
;
42 with Sinfo
; use Sinfo
;
43 with Sinput
; use Sinput
;
44 with Stand
; use Stand
;
45 with Stringt
; use Stringt
;
46 with Tree_IO
; use Tree_IO
;
47 with Uname
; use Uname
;
51 Switch_Storing_Enabled
: Boolean := True;
52 -- Set to False by Disable_Switch_Storing
54 -----------------------
55 -- Local Subprograms --
56 -----------------------
59 Yes_Before
, -- S1 is in same extended unit as S2 and appears before it
60 Yes_Same
, -- S1 is in same extended unit as S2, Slocs are the same
61 Yes_After
, -- S1 is in same extended unit as S2, and appears after it
62 No
); -- S2 is not in same extended unit as S2
64 function Check_Same_Extended_Unit
(S1
, S2
: Source_Ptr
) return SEU_Result
;
65 -- Used by In_Same_Extended_Unit and Earlier_In_Extended_Unit. Returns
66 -- value as described above.
68 function Get_Code_Or_Source_Unit
70 Unwind_Instances
: Boolean) return Unit_Number_Type
;
71 -- Common code for Get_Code_Unit (get unit of instantiation for location)
72 -- and Get_Source_Unit (get unit of template for location).
74 --------------------------------------------
75 -- Access Functions for Unit Table Fields --
76 --------------------------------------------
78 function Cunit
(U
: Unit_Number_Type
) return Node_Id
is
80 return Units
.Table
(U
).Cunit
;
83 function Cunit_Entity
(U
: Unit_Number_Type
) return Entity_Id
is
85 return Units
.Table
(U
).Cunit_Entity
;
88 function Dependency_Num
(U
: Unit_Number_Type
) return Nat
is
90 return Units
.Table
(U
).Dependency_Num
;
93 function Dynamic_Elab
(U
: Unit_Number_Type
) return Boolean is
95 return Units
.Table
(U
).Dynamic_Elab
;
98 function Error_Location
(U
: Unit_Number_Type
) return Source_Ptr
is
100 return Units
.Table
(U
).Error_Location
;
103 function Expected_Unit
(U
: Unit_Number_Type
) return Unit_Name_Type
is
105 return Units
.Table
(U
).Expected_Unit
;
108 function Fatal_Error
(U
: Unit_Number_Type
) return Boolean is
110 return Units
.Table
(U
).Fatal_Error
;
113 function Generate_Code
(U
: Unit_Number_Type
) return Boolean is
115 return Units
.Table
(U
).Generate_Code
;
118 function Has_RACW
(U
: Unit_Number_Type
) return Boolean is
120 return Units
.Table
(U
).Has_RACW
;
123 function Is_Compiler_Unit
(U
: Unit_Number_Type
) return Boolean is
125 return Units
.Table
(U
).Is_Compiler_Unit
;
126 end Is_Compiler_Unit
;
128 function Ident_String
(U
: Unit_Number_Type
) return Node_Id
is
130 return Units
.Table
(U
).Ident_String
;
133 function Loading
(U
: Unit_Number_Type
) return Boolean is
135 return Units
.Table
(U
).Loading
;
138 function Main_Priority
(U
: Unit_Number_Type
) return Int
is
140 return Units
.Table
(U
).Main_Priority
;
143 function Munit_Index
(U
: Unit_Number_Type
) return Nat
is
145 return Units
.Table
(U
).Munit_Index
;
148 function Source_Index
(U
: Unit_Number_Type
) return Source_File_Index
is
150 return Units
.Table
(U
).Source_Index
;
153 function Unit_File_Name
(U
: Unit_Number_Type
) return File_Name_Type
is
155 return Units
.Table
(U
).Unit_File_Name
;
158 function Unit_Name
(U
: Unit_Number_Type
) return Unit_Name_Type
is
160 return Units
.Table
(U
).Unit_Name
;
163 ------------------------------------------
164 -- Subprograms to Set Unit Table Fields --
165 ------------------------------------------
167 procedure Set_Cunit
(U
: Unit_Number_Type
; N
: Node_Id
) is
169 Units
.Table
(U
).Cunit
:= N
;
172 procedure Set_Cunit_Entity
(U
: Unit_Number_Type
; E
: Entity_Id
) is
174 Units
.Table
(U
).Cunit_Entity
:= E
;
175 Set_Is_Compilation_Unit
(E
);
176 end Set_Cunit_Entity
;
178 procedure Set_Dynamic_Elab
(U
: Unit_Number_Type
; B
: Boolean := True) is
180 Units
.Table
(U
).Dynamic_Elab
:= B
;
181 end Set_Dynamic_Elab
;
183 procedure Set_Error_Location
(U
: Unit_Number_Type
; W
: Source_Ptr
) is
185 Units
.Table
(U
).Error_Location
:= W
;
186 end Set_Error_Location
;
188 procedure Set_Fatal_Error
(U
: Unit_Number_Type
; B
: Boolean := True) is
190 Units
.Table
(U
).Fatal_Error
:= B
;
193 procedure Set_Generate_Code
(U
: Unit_Number_Type
; B
: Boolean := True) is
195 Units
.Table
(U
).Generate_Code
:= B
;
196 end Set_Generate_Code
;
198 procedure Set_Has_RACW
(U
: Unit_Number_Type
; B
: Boolean := True) is
200 Units
.Table
(U
).Has_RACW
:= B
;
203 procedure Set_Is_Compiler_Unit
204 (U
: Unit_Number_Type
;
208 Units
.Table
(U
).Is_Compiler_Unit
:= B
;
209 end Set_Is_Compiler_Unit
;
211 procedure Set_Ident_String
(U
: Unit_Number_Type
; N
: Node_Id
) is
213 Units
.Table
(U
).Ident_String
:= N
;
214 end Set_Ident_String
;
216 procedure Set_Loading
(U
: Unit_Number_Type
; B
: Boolean := True) is
218 Units
.Table
(U
).Loading
:= B
;
221 procedure Set_Main_Priority
(U
: Unit_Number_Type
; P
: Int
) is
223 Units
.Table
(U
).Main_Priority
:= P
;
224 end Set_Main_Priority
;
226 procedure Set_Unit_Name
(U
: Unit_Number_Type
; N
: Unit_Name_Type
) is
228 Units
.Table
(U
).Unit_Name
:= N
;
231 ------------------------------
232 -- Check_Same_Extended_Unit --
233 ------------------------------
235 function Check_Same_Extended_Unit
(S1
, S2
: Source_Ptr
) return SEU_Result
is
238 Sind1
: Source_File_Index
;
239 Sind2
: Source_File_Index
;
242 Unum1
: Unit_Number_Type
;
243 Unum2
: Unit_Number_Type
;
250 if S1
= No_Location
or else S2
= No_Location
then
253 elsif S1
= Standard_Location
then
254 if S2
= Standard_Location
then
260 elsif S2
= Standard_Location
then
266 Unum1
:= Get_Code_Unit
(Sloc1
);
267 Unum2
:= Get_Code_Unit
(Sloc2
);
270 Sind1
:= Get_Source_File_Index
(Sloc1
);
271 Sind2
:= Get_Source_File_Index
(Sloc2
);
273 if Sind1
= Sind2
then
274 if Sloc1
< Sloc2
then
276 elsif Sloc1
> Sloc2
then
283 -- OK, the two nodes are in separate source elements, but this is not
284 -- decisive, because of the issue of subunits and instantiations.
286 -- First we deal with subunits, since if the subunit is in an
287 -- instantiation, we know that the parent is in the corresponding
288 -- instantiation, since that is the only way we can have a subunit
289 -- that is part of an instantiation.
291 Unit1
:= Unit
(Cunit
(Unum1
));
292 Unit2
:= Unit
(Cunit
(Unum2
));
294 if Nkind
(Unit1
) = N_Subunit
295 and then Present
(Corresponding_Stub
(Unit1
))
297 -- Both in subunits. They could have a common ancestor. If they
298 -- do, then the deeper one must have a longer unit name. Replace
299 -- the deeper one with its corresponding stub, in order to find
300 -- nearest common ancestor, if any.
302 if Nkind
(Unit2
) = N_Subunit
303 and then Present
(Corresponding_Stub
(Unit2
))
305 if Length_Of_Name
(Unit_Name
(Unum1
)) <
306 Length_Of_Name
(Unit_Name
(Unum2
))
308 Sloc2
:= Sloc
(Corresponding_Stub
(Unit2
));
309 Unum2
:= Get_Source_Unit
(Sloc2
);
313 Sloc1
:= Sloc
(Corresponding_Stub
(Unit1
));
314 Unum1
:= Get_Source_Unit
(Sloc1
);
318 -- Nod1 in subunit, Nod2 not
321 Sloc1
:= Sloc
(Corresponding_Stub
(Unit1
));
322 Unum1
:= Get_Source_Unit
(Sloc1
);
326 -- Nod2 in subunit, Nod1 not
328 elsif Nkind
(Unit2
) = N_Subunit
329 and then Present
(Corresponding_Stub
(Unit2
))
331 Sloc2
:= Sloc
(Corresponding_Stub
(Unit2
));
332 Unum2
:= Get_Source_Unit
(Sloc2
);
336 -- At this stage we know that neither is a subunit, so we deal
337 -- with instantiations, since we culd have a common ancestor
339 Inst1
:= Instantiation
(Sind1
);
340 Inst2
:= Instantiation
(Sind2
);
342 if Inst1
/= No_Location
then
344 -- Both are instantiations
346 if Inst2
/= No_Location
then
348 Depth1
:= Instantiation_Depth
(Sloc1
);
349 Depth2
:= Instantiation_Depth
(Sloc2
);
351 if Depth1
< Depth2
then
353 Unum2
:= Get_Source_Unit
(Sloc2
);
356 elsif Depth1
> Depth2
then
358 Unum1
:= Get_Source_Unit
(Sloc1
);
364 Unum1
:= Get_Source_Unit
(Sloc1
);
365 Unum2
:= Get_Source_Unit
(Sloc2
);
369 -- Only first node is in instantiation
373 Unum1
:= Get_Source_Unit
(Sloc1
);
377 -- Only second node is instantiation
379 elsif Inst2
/= No_Location
then
381 Unum2
:= Get_Source_Unit
(Sloc2
);
385 -- No instantiations involved, so we are not in the same unit
386 -- However, there is one case still to check, namely the case
387 -- where one location is in the spec, and the other in the
388 -- corresponding body (the spec location is earlier).
390 if Nkind
(Unit1
) = N_Subprogram_Body
392 Nkind
(Unit1
) = N_Package_Body
394 if Library_Unit
(Cunit
(Unum1
)) = Cunit
(Unum2
) then
398 elsif Nkind
(Unit2
) = N_Subprogram_Body
400 Nkind
(Unit2
) = N_Package_Body
402 if Library_Unit
(Cunit
(Unum2
)) = Cunit
(Unum1
) then
407 -- If that special case does not occur, then we are certain that
408 -- the two locations are really in separate units.
415 end Check_Same_Extended_Unit
;
417 -------------------------------
418 -- Compilation_Switches_Last --
419 -------------------------------
421 function Compilation_Switches_Last
return Nat
is
423 return Compilation_Switches
.Last
;
424 end Compilation_Switches_Last
;
426 procedure Disable_Switch_Storing
is
428 Switch_Storing_Enabled
:= False;
429 end Disable_Switch_Storing
;
431 ------------------------------
432 -- Earlier_In_Extended_Unit --
433 ------------------------------
435 function Earlier_In_Extended_Unit
(S1
, S2
: Source_Ptr
) return Boolean is
437 return Check_Same_Extended_Unit
(S1
, S2
) = Yes_Before
;
438 end Earlier_In_Extended_Unit
;
440 ----------------------------
441 -- Entity_Is_In_Main_Unit --
442 ----------------------------
444 function Entity_Is_In_Main_Unit
(E
: Entity_Id
) return Boolean is
450 while S
/= Standard_Standard
loop
451 if S
= Main_Unit_Entity
then
453 elsif Ekind
(S
) = E_Package
and then Is_Child_Unit
(S
) then
461 end Entity_Is_In_Main_Unit
;
463 --------------------------
464 -- Generic_May_Lack_ALI --
465 --------------------------
467 function Generic_May_Lack_ALI
(Sfile
: File_Name_Type
) return Boolean is
469 -- We allow internal generic units to be used without having a
470 -- corresponding ALI files to help bootstrapping with older compilers
471 -- that did not support generating ALIs for such generics. It is safe
472 -- to do so because the only thing the generated code would contain
473 -- is the elaboration boolean, and we are careful to elaborate all
474 -- predefined units first anyway.
476 return Is_Internal_File_Name
478 Renamings_Included
=> True);
479 end Generic_May_Lack_ALI
;
481 -----------------------------
482 -- Get_Code_Or_Source_Unit --
483 -----------------------------
485 function Get_Code_Or_Source_Unit
487 Unwind_Instances
: Boolean) return Unit_Number_Type
490 -- Search table unless we have No_Location, which can happen if the
491 -- relevant location has not been set yet. Happens for example when
492 -- we obtain Sloc (Cunit (Main_Unit)) before it is set.
494 if S
/= No_Location
then
496 Source_File
: Source_File_Index
;
497 Source_Unit
: Unit_Number_Type
;
500 Source_File
:= Get_Source_File_Index
(S
);
502 if Unwind_Instances
then
503 while Template
(Source_File
) /= No_Source_File
loop
504 Source_File
:= Template
(Source_File
);
508 Source_Unit
:= Unit
(Source_File
);
510 if Source_Unit
/= No_Unit
then
516 -- If S was No_Location, or was not in the table, we must be in the main
517 -- source unit (and the value has not been placed in the table yet),
518 -- or in one of the configuration pragma files.
521 end Get_Code_Or_Source_Unit
;
527 function Get_Code_Unit
(S
: Source_Ptr
) return Unit_Number_Type
is
529 return Get_Code_Or_Source_Unit
(Top_Level_Location
(S
),
530 Unwind_Instances
=> False);
533 function Get_Code_Unit
(N
: Node_Or_Entity_Id
) return Unit_Number_Type
is
535 return Get_Code_Unit
(Sloc
(N
));
538 ----------------------------
539 -- Get_Compilation_Switch --
540 ----------------------------
542 function Get_Compilation_Switch
(N
: Pos
) return String_Ptr
is
544 if N
<= Compilation_Switches
.Last
then
545 return Compilation_Switches
.Table
(N
);
550 end Get_Compilation_Switch
;
552 ----------------------------------
553 -- Get_Cunit_Entity_Unit_Number --
554 ----------------------------------
556 function Get_Cunit_Entity_Unit_Number
557 (E
: Entity_Id
) return Unit_Number_Type
560 for U
in Units
.First
.. Units
.Last
loop
561 if Cunit_Entity
(U
) = E
then
566 -- If not in the table, must be the main source unit, and we just
567 -- have not got it put into the table yet.
570 end Get_Cunit_Entity_Unit_Number
;
572 ---------------------------
573 -- Get_Cunit_Unit_Number --
574 ---------------------------
576 function Get_Cunit_Unit_Number
(N
: Node_Id
) return Unit_Number_Type
is
578 for U
in Units
.First
.. Units
.Last
loop
579 if Cunit
(U
) = N
then
584 -- If not in the table, must be the main source unit, and we just
585 -- have not got it put into the table yet.
588 end Get_Cunit_Unit_Number
;
590 ---------------------
591 -- Get_Source_Unit --
592 ---------------------
594 function Get_Source_Unit
(S
: Source_Ptr
) return Unit_Number_Type
is
596 return Get_Code_Or_Source_Unit
(S
, Unwind_Instances
=> True);
599 function Get_Source_Unit
(N
: Node_Or_Entity_Id
) return Unit_Number_Type
is
601 return Get_Source_Unit
(Sloc
(N
));
604 --------------------------------
605 -- In_Extended_Main_Code_Unit --
606 --------------------------------
608 function In_Extended_Main_Code_Unit
609 (N
: Node_Or_Entity_Id
) return Boolean
612 if Sloc
(N
) = Standard_Location
then
615 elsif Sloc
(N
) = No_Location
then
618 -- Special case Itypes to test the Sloc of the associated node. The
619 -- reason we do this is for possible calls from gigi after -gnatD
620 -- processing is complete in sprint. This processing updates the
621 -- sloc fields of all nodes in the tree, but itypes are not in the
622 -- tree so their slocs do not get updated.
624 elsif Nkind
(N
) = N_Defining_Identifier
625 and then Is_Itype
(N
)
627 return In_Extended_Main_Code_Unit
(Associated_Node_For_Itype
(N
));
629 -- Otherwise see if we are in the main unit
631 elsif Get_Code_Unit
(Sloc
(N
)) = Get_Code_Unit
(Cunit
(Main_Unit
)) then
634 -- Node may be in spec (or subunit etc) of main unit
638 In_Same_Extended_Unit
(N
, Cunit
(Main_Unit
));
640 end In_Extended_Main_Code_Unit
;
642 function In_Extended_Main_Code_Unit
(Loc
: Source_Ptr
) return Boolean is
644 if Loc
= Standard_Location
then
647 elsif Loc
= No_Location
then
650 -- Otherwise see if we are in the main unit
652 elsif Get_Code_Unit
(Loc
) = Get_Code_Unit
(Cunit
(Main_Unit
)) then
655 -- Location may be in spec (or subunit etc) of main unit
659 In_Same_Extended_Unit
(Loc
, Sloc
(Cunit
(Main_Unit
)));
661 end In_Extended_Main_Code_Unit
;
663 ----------------------------------
664 -- In_Extended_Main_Source_Unit --
665 ----------------------------------
667 function In_Extended_Main_Source_Unit
668 (N
: Node_Or_Entity_Id
) return Boolean
670 Nloc
: constant Source_Ptr
:= Sloc
(N
);
671 Mloc
: constant Source_Ptr
:= Sloc
(Cunit
(Main_Unit
));
674 -- If Mloc is not set, it means we are still parsing the main unit,
675 -- so everything so far is in the extended main source unit.
677 if Mloc
= No_Location
then
680 -- Special value cases
682 elsif Nloc
= Standard_Location
then
685 elsif Nloc
= No_Location
then
688 -- Special case Itypes to test the Sloc of the associated node. The
689 -- reason we do this is for possible calls from gigi after -gnatD
690 -- processing is complete in sprint. This processing updates the
691 -- sloc fields of all nodes in the tree, but itypes are not in the
692 -- tree so their slocs do not get updated.
694 elsif Nkind
(N
) = N_Defining_Identifier
695 and then Is_Itype
(N
)
697 return In_Extended_Main_Source_Unit
(Associated_Node_For_Itype
(N
));
699 -- Otherwise compare original locations to see if in same unit
703 In_Same_Extended_Unit
704 (Original_Location
(Nloc
), Original_Location
(Mloc
));
706 end In_Extended_Main_Source_Unit
;
708 function In_Extended_Main_Source_Unit
709 (Loc
: Source_Ptr
) return Boolean
711 Mloc
: constant Source_Ptr
:= Sloc
(Cunit
(Main_Unit
));
714 -- If Mloc is not set, it means we are still parsing the main unit,
715 -- so everything so far is in the extended main source unit.
717 if Mloc
= No_Location
then
720 -- Special value cases
722 elsif Loc
= Standard_Location
then
725 elsif Loc
= No_Location
then
728 -- Otherwise compare original locations to see if in same unit
732 In_Same_Extended_Unit
733 (Original_Location
(Loc
), Original_Location
(Mloc
));
735 end In_Extended_Main_Source_Unit
;
737 ------------------------
738 -- In_Predefined_Unit --
739 ------------------------
741 function In_Predefined_Unit
(N
: Node_Or_Entity_Id
) return Boolean is
743 return In_Predefined_Unit
(Sloc
(N
));
744 end In_Predefined_Unit
;
746 function In_Predefined_Unit
(S
: Source_Ptr
) return Boolean is
747 Unit
: constant Unit_Number_Type
:= Get_Source_Unit
(S
);
748 File
: constant File_Name_Type
:= Unit_File_Name
(Unit
);
750 return Is_Predefined_File_Name
(File
);
751 end In_Predefined_Unit
;
753 -----------------------
754 -- In_Same_Code_Unit --
755 -----------------------
757 function In_Same_Code_Unit
(N1
, N2
: Node_Or_Entity_Id
) return Boolean is
758 S1
: constant Source_Ptr
:= Sloc
(N1
);
759 S2
: constant Source_Ptr
:= Sloc
(N2
);
762 if S1
= No_Location
or else S2
= No_Location
then
765 elsif S1
= Standard_Location
then
766 return S2
= Standard_Location
;
768 elsif S2
= Standard_Location
then
772 return Get_Code_Unit
(N1
) = Get_Code_Unit
(N2
);
773 end In_Same_Code_Unit
;
775 ---------------------------
776 -- In_Same_Extended_Unit --
777 ---------------------------
779 function In_Same_Extended_Unit
780 (N1
, N2
: Node_Or_Entity_Id
) return Boolean
783 return Check_Same_Extended_Unit
(Sloc
(N1
), Sloc
(N2
)) /= No
;
784 end In_Same_Extended_Unit
;
786 function In_Same_Extended_Unit
(S1
, S2
: Source_Ptr
) return Boolean is
788 return Check_Same_Extended_Unit
(S1
, S2
) /= No
;
789 end In_Same_Extended_Unit
;
791 -------------------------
792 -- In_Same_Source_Unit --
793 -------------------------
795 function In_Same_Source_Unit
(N1
, N2
: Node_Or_Entity_Id
) return Boolean is
796 S1
: constant Source_Ptr
:= Sloc
(N1
);
797 S2
: constant Source_Ptr
:= Sloc
(N2
);
800 if S1
= No_Location
or else S2
= No_Location
then
803 elsif S1
= Standard_Location
then
804 return S2
= Standard_Location
;
806 elsif S2
= Standard_Location
then
810 return Get_Source_Unit
(N1
) = Get_Source_Unit
(N2
);
811 end In_Same_Source_Unit
;
813 -----------------------------
814 -- Increment_Serial_Number --
815 -----------------------------
817 function Increment_Serial_Number
return Nat
is
818 TSN
: Int
renames Units
.Table
(Current_Sem_Unit
).Serial_Number
;
822 end Increment_Serial_Number
;
828 procedure Initialize
is
830 Linker_Option_Lines
.Init
;
833 Compilation_Switches
.Init
;
840 function Is_Loaded
(Uname
: Unit_Name_Type
) return Boolean is
842 for Unum
in Units
.First
.. Units
.Last
loop
843 if Uname
= Unit_Name
(Unum
) then
855 function Last_Unit
return Unit_Number_Type
is
864 procedure List
(File_Names_Only
: Boolean := False) is separate;
872 Linker_Option_Lines
.Locked
:= True;
873 Load_Stack
.Locked
:= True;
874 Units
.Locked
:= True;
875 Linker_Option_Lines
.Release
;
884 function Num_Units
return Nat
is
886 return Int
(Units
.Last
) - Int
(Main_Unit
) + 1;
893 procedure Remove_Unit
(U
: Unit_Number_Type
) is
895 if U
= Units
.Last
then
896 Units
.Decrement_Last
;
900 ----------------------------------
901 -- Replace_Linker_Option_String --
902 ----------------------------------
904 procedure Replace_Linker_Option_String
905 (S
: String_Id
; Match_String
: String)
908 if Match_String
'Length > 0 then
909 for J
in 1 .. Linker_Option_Lines
.Last
loop
910 String_To_Name_Buffer
(Linker_Option_Lines
.Table
(J
).Option
);
912 if Match_String
= Name_Buffer
(1 .. Match_String
'Length) then
913 Linker_Option_Lines
.Table
(J
).Option
:= S
;
919 Store_Linker_Option_String
(S
);
920 end Replace_Linker_Option_String
;
926 procedure Sort
(Tbl
: in out Unit_Ref_Table
) is separate;
928 ------------------------------
929 -- Store_Compilation_Switch --
930 ------------------------------
932 procedure Store_Compilation_Switch
(Switch
: String) is
934 if Switch_Storing_Enabled
then
935 Compilation_Switches
.Increment_Last
;
936 Compilation_Switches
.Table
(Compilation_Switches
.Last
) :=
939 -- Fix up --RTS flag which has been transformed by the gcc driver
942 if Switch'Last >= Switch'First + 4
943 and then Switch (Switch'First .. Switch'First + 4) = "-fRTS"
945 Compilation_Switches.Table
946 (Compilation_Switches.Last) (Switch'First + 1) := '-';
949 end Store_Compilation_Switch;
951 --------------------------------
952 -- Store_Linker_Option_String --
953 --------------------------------
955 procedure Store_Linker_Option_String (S : String_Id) is
957 Linker_Option_Lines.Increment_Last;
958 Linker_Option_Lines.Table (Linker_Option_Lines.Last) :=
959 (Option => S, Unit => Current_Sem_Unit);
960 end Store_Linker_Option_String;
962 -------------------------------
963 -- Synchronize_Serial_Number --
964 -------------------------------
966 procedure Synchronize_Serial_Number is
967 TSN : Int renames Units.Table (Current_Sem_Unit).Serial_Number;
970 end Synchronize_Serial_Number;
976 procedure Tree_Read is
983 -- Read Compilation_Switches table. First release the memory occupied
984 -- by the previously loaded switches.
986 for J in Compilation_Switches.First .. Compilation_Switches.Last loop
987 Free (Compilation_Switches.Table (J));
991 Compilation_Switches.Set_Last (N);
995 Compilation_Switches.Table (J) := S;
1003 procedure Tree_Write is
1007 -- Write Compilation_Switches table
1009 Tree_Write_Int (Compilation_Switches.Last);
1011 for J in 1 .. Compilation_Switches.Last loop
1012 Tree_Write_Str (Compilation_Switches.Table (J));
1022 Linker_Option_Lines.Locked := False;
1023 Load_Stack.Locked := False;
1024 Units.Locked := False;
1031 function Version_Get (U : Unit_Number_Type) return Word_Hex_String is
1033 return Get_Hex_String (Units.Table (U).Version);
1036 ------------------------
1037 -- Version_Referenced --
1038 ------------------------
1040 procedure Version_Referenced (S : String_Id) is
1042 Version_Ref.Append (S);
1043 end Version_Referenced;