Add hppa-openbsd target
[official-gcc.git] / gcc / ada / lib.adb
blobd093ed9b7a59aa486731f6898ed248ebc113be6f
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- L I B --
6 -- --
7 -- B o d y --
8 -- --
9 -- --
10 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
29 -- --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
32 -- --
33 ------------------------------------------------------------------------------
35 pragma Style_Checks (All_Checks);
36 -- Subprogram ordering not enforced in this unit
37 -- (because of some logical groupings).
39 with Atree; use Atree;
40 with Einfo; use Einfo;
41 with Fname; use Fname;
42 with Namet; use Namet;
43 with Namet; use Namet;
44 with Output; use Output;
45 with Sinfo; use Sinfo;
46 with Sinput; use Sinput;
47 with Stand; use Stand;
48 with Stringt; use Stringt;
49 with Tree_IO; use Tree_IO;
50 with Uname; use Uname;
52 package body Lib is
54 -----------------------
55 -- Local Subprograms --
56 -----------------------
58 type SEU_Result is (
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 --------------------------------------------
69 -- Access Functions for Unit Table Fields --
70 --------------------------------------------
72 function Cunit (U : Unit_Number_Type) return Node_Id is
73 begin
74 return Units.Table (U).Cunit;
75 end Cunit;
77 function Cunit_Entity (U : Unit_Number_Type) return Entity_Id is
78 begin
79 return Units.Table (U).Cunit_Entity;
80 end Cunit_Entity;
82 function Dependency_Num (U : Unit_Number_Type) return Nat is
83 begin
84 return Units.Table (U).Dependency_Num;
85 end Dependency_Num;
87 function Dependent_Unit (U : Unit_Number_Type) return Boolean is
88 begin
89 return Units.Table (U).Dependent_Unit;
90 end Dependent_Unit;
92 function Dynamic_Elab (U : Unit_Number_Type) return Boolean is
93 begin
94 return Units.Table (U).Dynamic_Elab;
95 end Dynamic_Elab;
97 function Error_Location (U : Unit_Number_Type) return Source_Ptr is
98 begin
99 return Units.Table (U).Error_Location;
100 end Error_Location;
102 function Expected_Unit (U : Unit_Number_Type) return Unit_Name_Type is
103 begin
104 return Units.Table (U).Expected_Unit;
105 end Expected_Unit;
107 function Fatal_Error (U : Unit_Number_Type) return Boolean is
108 begin
109 return Units.Table (U).Fatal_Error;
110 end Fatal_Error;
112 function Generate_Code (U : Unit_Number_Type) return Boolean is
113 begin
114 return Units.Table (U).Generate_Code;
115 end Generate_Code;
117 function Has_RACW (U : Unit_Number_Type) return Boolean is
118 begin
119 return Units.Table (U).Has_RACW;
120 end Has_RACW;
122 function Ident_String (U : Unit_Number_Type) return Node_Id is
123 begin
124 return Units.Table (U).Ident_String;
125 end Ident_String;
127 function Loading (U : Unit_Number_Type) return Boolean is
128 begin
129 return Units.Table (U).Loading;
130 end Loading;
132 function Main_Priority (U : Unit_Number_Type) return Int is
133 begin
134 return Units.Table (U).Main_Priority;
135 end Main_Priority;
137 function Source_Index (U : Unit_Number_Type) return Source_File_Index is
138 begin
139 return Units.Table (U).Source_Index;
140 end Source_Index;
142 function Unit_File_Name (U : Unit_Number_Type) return File_Name_Type is
143 begin
144 return Units.Table (U).Unit_File_Name;
145 end Unit_File_Name;
147 function Unit_Name (U : Unit_Number_Type) return Unit_Name_Type is
148 begin
149 return Units.Table (U).Unit_Name;
150 end Unit_Name;
152 ------------------------------------------
153 -- Subprograms to Set Unit Table Fields --
154 ------------------------------------------
156 procedure Set_Cunit (U : Unit_Number_Type; N : Node_Id) is
157 begin
158 Units.Table (U).Cunit := N;
159 end Set_Cunit;
161 procedure Set_Cunit_Entity (U : Unit_Number_Type; E : Entity_Id) is
162 begin
163 Units.Table (U).Cunit_Entity := E;
164 Set_Is_Compilation_Unit (E);
165 end Set_Cunit_Entity;
167 procedure Set_Dynamic_Elab (U : Unit_Number_Type; B : Boolean := True) is
168 begin
169 Units.Table (U).Dynamic_Elab := B;
170 end Set_Dynamic_Elab;
172 procedure Set_Error_Location (U : Unit_Number_Type; W : Source_Ptr) is
173 begin
174 Units.Table (U).Error_Location := W;
175 end Set_Error_Location;
177 procedure Set_Fatal_Error (U : Unit_Number_Type; B : Boolean := True) is
178 begin
179 Units.Table (U).Fatal_Error := B;
180 end Set_Fatal_Error;
182 procedure Set_Generate_Code (U : Unit_Number_Type; B : Boolean := True) is
183 begin
184 Units.Table (U).Generate_Code := B;
185 end Set_Generate_Code;
187 procedure Set_Has_RACW (U : Unit_Number_Type; B : Boolean := True) is
188 begin
189 Units.Table (U).Has_RACW := B;
190 end Set_Has_RACW;
192 procedure Set_Ident_String (U : Unit_Number_Type; N : Node_Id) is
193 begin
194 Units.Table (U).Ident_String := N;
195 end Set_Ident_String;
197 procedure Set_Loading (U : Unit_Number_Type; B : Boolean := True) is
198 begin
199 Units.Table (U).Loading := B;
200 end Set_Loading;
202 procedure Set_Main_Priority (U : Unit_Number_Type; P : Int) is
203 begin
204 Units.Table (U).Main_Priority := P;
205 end Set_Main_Priority;
207 procedure Set_Unit_Name (U : Unit_Number_Type; N : Unit_Name_Type) is
208 begin
209 Units.Table (U).Unit_Name := N;
210 end Set_Unit_Name;
212 ------------------------------
213 -- Check_Same_Extended_Unit --
214 ------------------------------
216 function Check_Same_Extended_Unit (S1, S2 : Source_Ptr) return SEU_Result is
217 Sloc1 : Source_Ptr;
218 Sloc2 : Source_Ptr;
219 Sind1 : Source_File_Index;
220 Sind2 : Source_File_Index;
221 Inst1 : Source_Ptr;
222 Inst2 : Source_Ptr;
223 Unum1 : Unit_Number_Type;
224 Unum2 : Unit_Number_Type;
225 Unit1 : Node_Id;
226 Unit2 : Node_Id;
227 Depth1 : Nat;
228 Depth2 : Nat;
230 begin
231 if S1 = No_Location or else S2 = No_Location then
232 return No;
234 elsif S1 = Standard_Location then
235 if S2 = Standard_Location then
236 return Yes_Same;
237 else
238 return No;
239 end if;
241 elsif S2 = Standard_Location then
242 return No;
243 end if;
245 Sloc1 := S1;
246 Sloc2 := S2;
247 Unum1 := Get_Code_Unit (Sloc1);
248 Unum2 := Get_Code_Unit (Sloc2);
250 loop
251 Sind1 := Get_Source_File_Index (Sloc1);
252 Sind2 := Get_Source_File_Index (Sloc2);
254 if Sind1 = Sind2 then
255 if Sloc1 < Sloc2 then
256 return Yes_Before;
257 elsif Sloc1 > Sloc2 then
258 return Yes_After;
259 else
260 return Yes_Same;
261 end if;
262 end if;
264 -- OK, the two nodes are in separate source elements, but this is not
265 -- decisive, because of the issue of subunits and instantiations.
267 -- First we deal with subunits, since if the subunit is in an
268 -- instantiation, we know that the parent is in the corresponding
269 -- instantiation, since that is the only way we can have a subunit
270 -- that is part of an instantiation.
272 Unit1 := Unit (Cunit (Unum1));
273 Unit2 := Unit (Cunit (Unum2));
275 if Nkind (Unit1) = N_Subunit
276 and then Present (Corresponding_Stub (Unit1))
277 then
278 -- Both in subunits. They could have a common ancestor. If they
279 -- do, then the deeper one must have a longer unit name. Replace
280 -- the deeper one with its corresponding stub, in order to find
281 -- nearest common ancestor, if any.
283 if Nkind (Unit2) = N_Subunit
284 and then Present (Corresponding_Stub (Unit2))
285 then
286 if Length_Of_Name (Unit_Name (Unum1)) <
287 Length_Of_Name (Unit_Name (Unum2))
288 then
289 Sloc2 := Sloc (Corresponding_Stub (Unit2));
290 Unum2 := Get_Source_Unit (Sloc2);
291 goto Continue;
293 else
294 Sloc1 := Sloc (Corresponding_Stub (Unit1));
295 Unum1 := Get_Source_Unit (Sloc1);
296 goto Continue;
297 end if;
299 -- Nod1 in subunit, Nod2 not
301 else
302 Sloc1 := Sloc (Corresponding_Stub (Unit1));
303 Unum1 := Get_Source_Unit (Sloc1);
304 goto Continue;
305 end if;
307 -- Nod2 in subunit, Nod1 not
309 elsif Nkind (Unit2) = N_Subunit
310 and then Present (Corresponding_Stub (Unit2))
311 then
312 Sloc2 := Sloc (Corresponding_Stub (Unit2));
313 Unum2 := Get_Source_Unit (Sloc2);
314 goto Continue;
315 end if;
317 -- At this stage we know that neither is a subunit, so we deal
318 -- with instantiations, since we culd have a common ancestor
320 Inst1 := Instantiation (Sind1);
321 Inst2 := Instantiation (Sind2);
323 if Inst1 /= No_Location then
325 -- Both are instantiations
327 if Inst2 /= No_Location then
329 Depth1 := Instantiation_Depth (Sloc1);
330 Depth2 := Instantiation_Depth (Sloc2);
332 if Depth1 < Depth2 then
333 Sloc2 := Inst2;
334 Unum2 := Get_Source_Unit (Sloc2);
335 goto Continue;
337 elsif Depth1 > Depth2 then
338 Sloc1 := Inst1;
339 Unum1 := Get_Source_Unit (Sloc1);
340 goto Continue;
342 else
343 Sloc1 := Inst1;
344 Sloc2 := Inst2;
345 Unum1 := Get_Source_Unit (Sloc1);
346 Unum2 := Get_Source_Unit (Sloc2);
347 goto Continue;
348 end if;
350 -- Only first node is in instantiation
352 else
353 Sloc1 := Inst1;
354 Unum1 := Get_Source_Unit (Sloc1);
355 goto Continue;
356 end if;
358 -- Only second node is instantiation
360 elsif Inst2 /= No_Location then
361 Sloc2 := Inst2;
362 Unum2 := Get_Source_Unit (Sloc2);
363 goto Continue;
364 end if;
366 -- No instantiations involved, so we are not in the same unit
367 -- However, there is one case still to check, namely the case
368 -- where one location is in the spec, and the other in the
369 -- corresponding body (the spec location is earlier).
371 if Nkind (Unit1) = N_Subprogram_Body
372 or else
373 Nkind (Unit1) = N_Package_Body
374 then
375 if Library_Unit (Cunit (Unum1)) = Cunit (Unum2) then
376 return Yes_After;
377 end if;
379 elsif Nkind (Unit2) = N_Subprogram_Body
380 or else
381 Nkind (Unit2) = N_Package_Body
382 then
383 if Library_Unit (Cunit (Unum2)) = Cunit (Unum1) then
384 return Yes_Before;
385 end if;
386 end if;
388 -- If that special case does not occur, then we are certain that
389 -- the two locations are really in separate units.
391 return No;
393 <<Continue>>
394 null;
395 end loop;
397 end Check_Same_Extended_Unit;
399 -------------------------------
400 -- Compilation_Switches_Last --
401 -------------------------------
403 function Compilation_Switches_Last return Nat is
404 begin
405 return Compilation_Switches.Last;
406 end Compilation_Switches_Last;
408 ------------------------------
409 -- Earlier_In_Extended_Unit --
410 ------------------------------
412 function Earlier_In_Extended_Unit (S1, S2 : Source_Ptr) return Boolean is
413 begin
414 return Check_Same_Extended_Unit (S1, S2) = Yes_Before;
415 end Earlier_In_Extended_Unit;
417 ----------------------------
418 -- Entity_Is_In_Main_Unit --
419 ----------------------------
421 function Entity_Is_In_Main_Unit (E : Entity_Id) return Boolean is
422 S : Entity_Id;
424 begin
425 S := Scope (E);
427 while S /= Standard_Standard loop
428 if S = Main_Unit_Entity then
429 return True;
430 elsif Ekind (S) = E_Package and then Is_Child_Unit (S) then
431 return False;
432 else
433 S := Scope (S);
434 end if;
435 end loop;
437 return False;
438 end Entity_Is_In_Main_Unit;
440 ---------------------------------
441 -- Generic_Separately_Compiled --
442 ---------------------------------
444 function Generic_Separately_Compiled (E : Entity_Id) return Boolean is
445 begin
446 -- We do not generate object files for internal generics, because
447 -- the only thing they would contain is the elaboration boolean, and
448 -- we are careful to elaborate all predefined units first anyway, so
449 -- this boolean is not needed.
451 if Is_Internal_File_Name
452 (Fname => Unit_File_Name (Get_Source_Unit (E)),
453 Renamings_Included => True)
454 then
455 return False;
457 -- All other generic units do generate object files
459 else
460 return True;
461 end if;
462 end Generic_Separately_Compiled;
464 -------------------
465 -- Get_Code_Unit --
466 -------------------
468 function Get_Code_Unit (S : Source_Ptr) return Unit_Number_Type is
469 Source_File : Source_File_Index :=
470 Get_Source_File_Index (Top_Level_Location (S));
472 begin
473 for U in Units.First .. Units.Last loop
474 if Source_Index (U) = Source_File then
475 return U;
476 end if;
477 end loop;
479 -- If not in the table, must be the main source unit, and we just
480 -- have not got it put into the table yet.
482 return Main_Unit;
483 end Get_Code_Unit;
485 function Get_Code_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type is
486 begin
487 return Get_Code_Unit (Sloc (N));
488 end Get_Code_Unit;
490 ----------------------------
491 -- Get_Compilation_Switch --
492 ----------------------------
494 function Get_Compilation_Switch (N : Pos) return String_Ptr is
495 begin
496 if N <= Compilation_Switches.Last then
497 return Compilation_Switches.Table (N);
499 else
500 return null;
501 end if;
502 end Get_Compilation_Switch;
504 ----------------------------------
505 -- Get_Cunit_Entity_Unit_Number --
506 ----------------------------------
508 function Get_Cunit_Entity_Unit_Number
509 (E : Entity_Id)
510 return Unit_Number_Type
512 begin
513 for U in Units.First .. Units.Last loop
514 if Cunit_Entity (U) = E then
515 return U;
516 end if;
517 end loop;
519 -- If not in the table, must be the main source unit, and we just
520 -- have not got it put into the table yet.
522 return Main_Unit;
523 end Get_Cunit_Entity_Unit_Number;
525 ---------------------------
526 -- Get_Cunit_Unit_Number --
527 ---------------------------
529 function Get_Cunit_Unit_Number (N : Node_Id) return Unit_Number_Type is
530 begin
531 for U in Units.First .. Units.Last loop
532 if Cunit (U) = N then
533 return U;
534 end if;
535 end loop;
537 -- If not in the table, must be the main source unit, and we just
538 -- have not got it put into the table yet.
540 return Main_Unit;
541 end Get_Cunit_Unit_Number;
543 ---------------------
544 -- Get_Source_Unit --
545 ---------------------
547 function Get_Source_Unit (S : Source_Ptr) return Unit_Number_Type is
548 Source_File : Source_File_Index :=
549 Get_Source_File_Index (Top_Level_Location (S));
551 begin
552 Source_File := Get_Source_File_Index (S);
553 while Template (Source_File) /= No_Source_File loop
554 Source_File := Template (Source_File);
555 end loop;
557 for U in Units.First .. Units.Last loop
558 if Source_Index (U) = Source_File then
559 return U;
560 end if;
561 end loop;
563 -- If not in the table, must be the main source unit, and we just
564 -- have not got it put into the table yet.
566 return Main_Unit;
567 end Get_Source_Unit;
569 function Get_Source_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type is
570 begin
571 return Get_Source_Unit (Sloc (N));
572 end Get_Source_Unit;
574 --------------------------------
575 -- In_Extended_Main_Code_Unit --
576 --------------------------------
578 function In_Extended_Main_Code_Unit
579 (N : Node_Or_Entity_Id)
580 return Boolean
582 begin
583 if Sloc (N) = Standard_Location then
584 return True;
586 elsif Sloc (N) = No_Location then
587 return False;
589 -- Special case Itypes to test the Sloc of the associated node. The
590 -- reason we do this is for possible calls from gigi after -gnatD
591 -- processing is complete in sprint. This processing updates the
592 -- sloc fields of all nodes in the tree, but itypes are not in the
593 -- tree so their slocs do not get updated.
595 elsif Nkind (N) = N_Defining_Identifier
596 and then Is_Itype (N)
597 then
598 return In_Extended_Main_Code_Unit (Associated_Node_For_Itype (N));
600 elsif Get_Code_Unit (Sloc (N)) = Get_Code_Unit (Cunit (Main_Unit)) then
601 return True;
603 else -- node may be in spec of main unit
604 return
605 In_Same_Extended_Unit (Sloc (N), Sloc (Cunit (Main_Unit)));
606 end if;
607 end In_Extended_Main_Code_Unit;
609 ----------------------------------
610 -- In_Extended_Main_Source_Unit --
611 ----------------------------------
613 function In_Extended_Main_Source_Unit
614 (N : Node_Or_Entity_Id)
615 return Boolean
617 begin
618 if Sloc (N) = Standard_Location then
619 return True;
621 elsif Sloc (N) = No_Location then
622 return False;
624 -- Special case Itypes to test the Sloc of the associated node. The
625 -- reason we do this is for possible calls from gigi after -gnatD
626 -- processing is complete in sprint. This processing updates the
627 -- sloc fields of all nodes in the tree, but itypes are not in the
628 -- tree so their slocs do not get updated.
630 elsif Nkind (N) = N_Defining_Identifier
631 and then Is_Itype (N)
632 then
633 return In_Extended_Main_Source_Unit (Associated_Node_For_Itype (N));
635 else
636 return
637 In_Same_Extended_Unit
638 (Original_Location (Sloc (N)),
639 Original_Location (Sloc (Cunit (Main_Unit))));
640 end if;
641 end In_Extended_Main_Source_Unit;
643 -----------------------
644 -- In_Same_Code_Unit --
645 -----------------------
647 function In_Same_Code_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean is
648 S1 : constant Source_Ptr := Sloc (N1);
649 S2 : constant Source_Ptr := Sloc (N2);
651 begin
652 if S1 = No_Location or else S2 = No_Location then
653 return False;
655 elsif S1 = Standard_Location then
656 return S2 = Standard_Location;
658 elsif S2 = Standard_Location then
659 return False;
660 end if;
662 return Get_Code_Unit (N1) = Get_Code_Unit (N2);
663 end In_Same_Code_Unit;
665 ---------------------------
666 -- In_Same_Extended_Unit --
667 ---------------------------
669 function In_Same_Extended_Unit (S1, S2 : Source_Ptr) return Boolean is
670 begin
671 return Check_Same_Extended_Unit (S1, S2) /= No;
672 end In_Same_Extended_Unit;
674 -------------------------
675 -- In_Same_Source_Unit --
676 -------------------------
678 function In_Same_Source_Unit (N1, N2 : Node_Or_Entity_Id) return Boolean is
679 S1 : constant Source_Ptr := Sloc (N1);
680 S2 : constant Source_Ptr := Sloc (N2);
682 begin
683 if S1 = No_Location or else S2 = No_Location then
684 return False;
686 elsif S1 = Standard_Location then
687 return S2 = Standard_Location;
689 elsif S2 = Standard_Location then
690 return False;
691 end if;
693 return Get_Source_Unit (N1) = Get_Source_Unit (N2);
694 end In_Same_Source_Unit;
696 -----------------------------
697 -- Increment_Serial_Number --
698 -----------------------------
700 function Increment_Serial_Number return Nat is
701 TSN : Int renames Units.Table (Current_Sem_Unit).Serial_Number;
703 begin
704 TSN := TSN + 1;
705 return TSN;
706 end Increment_Serial_Number;
708 ----------------
709 -- Initialize --
710 ----------------
712 procedure Initialize is
713 begin
714 Linker_Option_Lines.Init;
715 Load_Stack.Init;
716 Units.Init;
717 Unit_Exception_Table_Present := False;
718 Compilation_Switches.Init;
719 end Initialize;
721 ---------------
722 -- Is_Loaded --
723 ---------------
725 function Is_Loaded (Uname : Unit_Name_Type) return Boolean is
726 begin
727 for Unum in Units.First .. Units.Last loop
728 if Uname = Unit_Name (Unum) then
729 return True;
730 end if;
731 end loop;
733 return False;
734 end Is_Loaded;
736 ---------------
737 -- Last_Unit --
738 ---------------
740 function Last_Unit return Unit_Number_Type is
741 begin
742 return Units.Last;
743 end Last_Unit;
745 ----------
746 -- List --
747 ----------
749 procedure List (File_Names_Only : Boolean := False) is separate;
751 ----------
752 -- Lock --
753 ----------
755 procedure Lock is
756 begin
757 Linker_Option_Lines.Locked := True;
758 Load_Stack.Locked := True;
759 Units.Locked := True;
760 Linker_Option_Lines.Release;
761 Load_Stack.Release;
762 Units.Release;
763 end Lock;
765 ---------------
766 -- Num_Units --
767 ---------------
769 function Num_Units return Nat is
770 begin
771 return Int (Units.Last) - Int (Main_Unit) + 1;
772 end Num_Units;
774 ----------------------------------
775 -- Replace_Linker_Option_String --
776 ----------------------------------
778 procedure Replace_Linker_Option_String
779 (S : String_Id; Match_String : String)
781 begin
782 if Match_String'Length > 0 then
783 for J in 1 .. Linker_Option_Lines.Last loop
784 String_To_Name_Buffer (Linker_Option_Lines.Table (J).Option);
786 if Match_String = Name_Buffer (1 .. Match_String'Length) then
787 Linker_Option_Lines.Table (J).Option := S;
788 return;
789 end if;
790 end loop;
791 end if;
793 Store_Linker_Option_String (S);
794 end Replace_Linker_Option_String;
796 ----------
797 -- Sort --
798 ----------
800 procedure Sort (Tbl : in out Unit_Ref_Table) is separate;
802 ------------------------------
803 -- Store_Compilation_Switch --
804 ------------------------------
806 procedure Store_Compilation_Switch (Switch : String) is
807 begin
808 Compilation_Switches.Increment_Last;
809 Compilation_Switches.Table (Compilation_Switches.Last) :=
810 new String'(Switch);
811 end Store_Compilation_Switch;
813 --------------------------------
814 -- Store_Linker_Option_String --
815 --------------------------------
817 procedure Store_Linker_Option_String (S : String_Id) is
818 begin
819 Linker_Option_Lines.Increment_Last;
820 Linker_Option_Lines.Table (Linker_Option_Lines.Last) :=
821 (Option => S, Unit => Current_Sem_Unit);
822 end Store_Linker_Option_String;
824 ---------------
825 -- Tree_Read --
826 ---------------
828 procedure Tree_Read is
829 N : Nat;
830 S : String_Ptr;
832 begin
833 Units.Tree_Read;
835 -- Read Compilation_Switches table
837 Tree_Read_Int (N);
838 Compilation_Switches.Set_Last (N);
840 for J in 1 .. N loop
841 Tree_Read_Str (S);
842 Compilation_Switches.Table (J) := S;
843 end loop;
844 end Tree_Read;
846 ----------------
847 -- Tree_Write --
848 ----------------
850 procedure Tree_Write is
851 begin
852 Units.Tree_Write;
854 -- Write Compilation_Switches table
856 Tree_Write_Int (Compilation_Switches.Last);
858 for J in 1 .. Compilation_Switches.Last loop
859 Tree_Write_Str (Compilation_Switches.Table (J));
860 end loop;
861 end Tree_Write;
863 -----------------
864 -- Version_Get --
865 -----------------
867 function Version_Get (U : Unit_Number_Type) return Word_Hex_String is
868 begin
869 return Get_Hex_String (Units.Table (U).Version);
870 end Version_Get;
872 ------------------------
873 -- Version_Referenced --
874 ------------------------
876 procedure Version_Referenced (S : String_Id) is
877 begin
878 Version_Ref.Append (S);
879 end Version_Referenced;
881 end Lib;