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 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
28 with Atree; use Atree;
29 with Casing; use Casing;
30 with Einfo; use Einfo;
31 with Errout; use Errout;
32 with Fname; use Fname;
33 with Fname.UF; use Fname.UF;
34 with Lib.Util; use Lib.Util;
35 with Lib.Xref; use Lib.Xref;
36 with Nlists; use Nlists;
37 with Gnatvsn; use Gnatvsn;
39 with Osint; use Osint;
40 with Osint.C; use Osint.C;
42 with Restrict; use Restrict;
43 with Rident; use Rident;
45 with Sinfo; use Sinfo;
46 with Sinput; use Sinput;
47 with Snames; use Snames;
48 with Stringt; use Stringt;
49 with Tbuild; use Tbuild;
50 with Uname; use Uname;
52 with System.Case_Util; use System.Case_Util;
53 with System.WCh_Con; use System.WCh_Con;
55 package body Lib.Writ is
57 -----------------------
58 -- Local Subprograms --
59 -----------------------
61 procedure Write_Unit_Name (N : Node_Id);
62 -- Used to write out the unit name for R (pragma Restriction) lines
63 -- for uses of Restriction (No_Dependence => unit-name).
65 ----------------------------------
66 -- Add_Preprocessing_Dependency --
67 ----------------------------------
69 procedure Add_Preprocessing_Dependency (S : Source_File_Index) is
72 Units.Table (Units.Last) :=
73 (Unit_File_Name => File_Name (S),
74 Unit_Name => No_Unit_Name,
75 Expected_Unit => No_Unit_Name,
78 Cunit_Entity => Empty,
80 Dynamic_Elab => False,
82 Generate_Code => False,
84 Ident_String => Empty,
90 Error_Location => No_Location);
91 end Add_Preprocessing_Dependency;
93 ------------------------------
94 -- Ensure_System_Dependency --
95 ------------------------------
97 procedure Ensure_System_Dependency is
98 System_Uname : Unit_Name_Type;
99 -- Unit name for system spec if needed for dummy entry
101 System_Fname : File_Name_Type;
102 -- File name for system spec if needed for dummy entry
105 -- Nothing to do if we already compiled System
107 for Unum in Units.First .. Last_Unit loop
108 if Units.Table (Unum).Source_Index = System_Source_File_Index then
113 -- If no entry for system.ads in the units table, then add a entry
114 -- to the units table for system.ads, which will be referenced when
115 -- the ali file is generated. We need this because every unit depends
116 -- on system as a result of Targparm scanning the system.ads file to
117 -- determine the target dependent parameters for the compilation.
120 Name_Buffer (1 .. 6) := "system";
121 System_Uname := Name_To_Unit_Name (Name_Enter);
122 System_Fname := File_Name (System_Source_File_Index);
124 Units.Increment_Last;
125 Units.Table (Units.Last) := (
126 Unit_File_Name => System_Fname,
127 Unit_Name => System_Uname,
128 Expected_Unit => System_Uname,
129 Source_Index => System_Source_File_Index,
131 Cunit_Entity => Empty,
133 Dynamic_Elab => False,
134 Fatal_Error => False,
135 Generate_Code => False,
137 Ident_String => Empty,
143 Error_Location => No_Location);
145 -- Parse system.ads so that the checksum is set right
146 -- Style checks are not applied.
149 Save_Mindex : constant Nat := Multiple_Unit_Index;
150 Save_Style : constant Boolean := Style_Check;
152 Multiple_Unit_Index := 0;
153 Style_Check := False;
154 Initialize_Scanner (Units.Last, System_Source_File_Index);
155 Discard_List (Par (Configuration_Pragmas => False));
156 Style_Check := Save_Style;
157 Multiple_Unit_Index := Save_Mindex;
159 end Ensure_System_Dependency;
165 procedure Write_ALI (Object : Boolean) is
171 Last_Unit : constant Unit_Number_Type := Units.Last;
172 -- Record unit number of last unit. We capture this in case we
173 -- have to add a dummy entry to the unit table for package System.
175 With_Flags : array (Units.First .. Last_Unit) of Boolean;
176 -- Array of flags to show which units are with'ed
178 Elab_Flags : array (Units.First .. Last_Unit) of Boolean;
179 -- Array of flags to show which units have pragma Elaborate set
181 Elab_All_Flags : array (Units.First .. Last_Unit) of Boolean;
182 -- Array of flags to show which units have pragma Elaborate All set
184 Elab_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
185 -- Array of flags to show which units have Elaborate_Desirable set
187 Elab_All_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
188 -- Array of flags to show which units have Elaborate_All_Desirable set
190 Sdep_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 2));
191 -- Sorted table of source dependencies. One extra entry in case we
192 -- have to add a dummy entry for System.
195 -- Number of active entries in Sdep_Table
197 -----------------------
198 -- Local Subprograms --
199 -----------------------
201 procedure Collect_Withs (Cunit : Node_Id);
202 -- Collect with lines for entries in the context clause of the
203 -- given compilation unit, Cunit.
205 procedure Update_Tables_From_ALI_File;
206 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
207 -- function), update tables from the ALI information, including
208 -- specifically the Compilation_Switches table.
210 function Up_To_Date_ALI_File_Exists return Boolean;
211 -- If there exists an ALI file that is up to date, then this function
212 -- initializes the tables in the ALI spec to contain information on
213 -- this file (using Scan_ALI) and returns True. If no file exists,
214 -- or the file is not up to date, then False is returned.
216 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type);
217 -- Write out the library information for one unit for which code is
218 -- generated (includes unit line and with lines).
220 procedure Write_With_Lines;
221 -- Write out with lines collected by calls to Collect_Withs
227 procedure Collect_Withs (Cunit : Node_Id) is
229 Unum : Unit_Number_Type;
232 Item := First (Context_Items (Cunit));
233 while Present (Item) loop
235 -- Process with clause
237 -- Ada 2005 (AI-50217): limited with_clauses do not create
240 if Nkind (Item) = N_With_Clause
241 and then not (Limited_Present (Item))
243 Unum := Get_Cunit_Unit_Number (Library_Unit (Item));
244 With_Flags (Unum) := True;
246 if Elaborate_Present (Item) then
247 Elab_Flags (Unum) := True;
250 if Elaborate_All_Present (Item) then
251 Elab_All_Flags (Unum) := True;
254 if Elaborate_All_Desirable (Item) then
255 Elab_All_Des_Flags (Unum) := True;
258 if Elaborate_Desirable (Item) then
259 Elab_Des_Flags (Unum) := True;
267 --------------------------------
268 -- Up_To_Date_ALI_File_Exists --
269 --------------------------------
271 function Up_To_Date_ALI_File_Exists return Boolean is
272 Name : File_Name_Type;
273 Text : Text_Buffer_Ptr;
275 Sind : Source_File_Index;
278 Opt.Check_Object_Consistency := True;
279 Read_Library_Info (Name, Text);
281 -- Return if we could not find an ALI file
287 -- Return if ALI file has bad format
291 if Scan_ALI (Name, Text, False, Err => True) = No_ALI_Id then
295 -- If we have an OK ALI file, check if it is up to date
296 -- Note that we assume that the ALI read has all the entries
297 -- we have in our table, plus some additional ones (that can
298 -- come from expansion).
300 Id := First_Sdep_Entry;
301 for J in 1 .. Num_Sdep loop
302 Sind := Units.Table (Sdep_Table (J)).Source_Index;
304 while Sdep.Table (Id).Sfile /= File_Name (Sind) loop
305 if Id = Sdep.Last then
312 if Sdep.Table (Id).Stamp /= Time_Stamp (Sind) then
318 end Up_To_Date_ALI_File_Exists;
320 ---------------------------------
321 -- Update_Tables_From_ALI_File --
322 ---------------------------------
324 procedure Update_Tables_From_ALI_File is
326 -- Build Compilation_Switches table
328 Compilation_Switches.Init;
330 for J in First_Arg_Entry .. Args.Last loop
331 Compilation_Switches.Increment_Last;
332 Compilation_Switches.Table (Compilation_Switches.Last) :=
335 end Update_Tables_From_ALI_File;
337 ----------------------------
338 -- Write_Unit_Information --
339 ----------------------------
341 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type) is
342 Unode : constant Node_Id := Cunit (Unit_Num);
343 Ukind : constant Node_Kind := Nkind (Unit (Unode));
344 Uent : constant Entity_Id := Cunit_Entity (Unit_Num);
348 Write_Info_Initiate ('U');
349 Write_Info_Char (' ');
350 Write_Info_Name (Unit_Name (Unit_Num));
352 Write_Info_Name (Unit_File_Name (Unit_Num));
355 Write_Info_Str (Version_Get (Unit_Num));
357 -- Add BD parameter if Elaborate_Body pragma desirable
359 if Ekind (Uent) = E_Package
360 and then Elaborate_Body_Desirable (Uent)
362 Write_Info_Str (" BD");
365 -- Add BN parameter if body needed for SAL
367 if (Is_Subprogram (Uent)
368 or else Ekind (Uent) = E_Package
369 or else Is_Generic_Unit (Uent))
370 and then Body_Needed_For_SAL (Uent)
372 Write_Info_Str (" BN");
375 if Dynamic_Elab (Unit_Num) then
376 Write_Info_Str (" DE");
379 -- We set the Elaborate_Body indication if either an explicit pragma
380 -- was present, or if this is an instantiation. RM 12.3(20) requires
381 -- that the body be immediately elaborated after the spec. We would
382 -- normally do that anyway, but the EB we generate here ensures that
383 -- this gets done even when we use the -p gnatbind switch.
385 if Has_Pragma_Elaborate_Body (Uent)
386 or else (Ukind = N_Package_Declaration
387 and then Is_Generic_Instance (Uent)
388 and then Present (Corresponding_Body (Unit (Unode))))
390 Write_Info_Str (" EB");
393 -- Now see if we should tell the binder that an elaboration entity
394 -- is present, which must be reset to true during elaboration. We
395 -- generate the indication if the following condition is met:
397 -- If this is a spec ...
399 if (Is_Subprogram (Uent)
401 Ekind (Uent) = E_Package
403 Is_Generic_Unit (Uent))
405 -- and an elaboration entity was declared ...
407 and then Present (Elaboration_Entity (Uent))
409 -- and either the elaboration flag is required ...
412 (Elaboration_Entity_Required (Uent)
414 -- or this unit has elaboration code ...
416 or else not Has_No_Elaboration_Code (Unode)
418 -- or this unit has a separate body and this
419 -- body has elaboration code.
422 (Ekind (Uent) = E_Package
423 and then Present (Body_Entity (Uent))
425 not Has_No_Elaboration_Code
428 (Body_Entity (Uent))))))
430 if Convention (Uent) = Convention_CIL then
432 -- Special case for generic CIL packages which never have
435 Write_Info_Str (" NE");
438 Write_Info_Str (" EE");
442 if Has_No_Elaboration_Code (Unode) then
443 Write_Info_Str (" NE");
446 if Is_Preelaborated (Uent) then
447 Write_Info_Str (" PR");
450 if Is_Pure (Uent) then
451 Write_Info_Str (" PU");
454 if Has_RACW (Unit_Num) then
455 Write_Info_Str (" RA");
458 if Is_Remote_Call_Interface (Uent) then
459 Write_Info_Str (" RC");
462 if Is_Remote_Types (Uent) then
463 Write_Info_Str (" RT");
466 if Is_Shared_Passive (Uent) then
467 Write_Info_Str (" SP");
470 if Ukind = N_Subprogram_Declaration
471 or else Ukind = N_Subprogram_Body
473 Write_Info_Str (" SU");
475 elsif Ukind = N_Package_Declaration
477 Ukind = N_Package_Body
479 -- If this is a wrapper package for a subprogram instantiation,
480 -- the user view is the subprogram. Note that in this case the
481 -- ali file contains both the spec and body of the instance.
483 if Is_Wrapper_Package (Uent) then
484 Write_Info_Str (" SU");
486 Write_Info_Str (" PK");
489 elsif Ukind = N_Generic_Package_Declaration then
490 Write_Info_Str (" PK");
494 if Ukind in N_Generic_Declaration
496 (Present (Library_Unit (Unode))
498 Nkind (Unit (Library_Unit (Unode))) in N_Generic_Declaration)
500 Write_Info_Str (" GE");
503 if not Is_Internal_File_Name (Unit_File_Name (Unit_Num), True) then
504 case Identifier_Casing (Source_Index (Unit_Num)) is
505 when All_Lower_Case => Write_Info_Str (" IL");
506 when All_Upper_Case => Write_Info_Str (" IU");
510 case Keyword_Casing (Source_Index (Unit_Num)) is
511 when Mixed_Case => Write_Info_Str (" KM");
512 when All_Upper_Case => Write_Info_Str (" KU");
517 if Initialize_Scalars then
518 Write_Info_Str (" IS");
523 -- Generate with lines, first those that are directly with'ed
525 for J in With_Flags'Range loop
526 With_Flags (J) := False;
527 Elab_Flags (J) := False;
528 Elab_All_Flags (J) := False;
529 Elab_Des_Flags (J) := False;
530 Elab_All_Des_Flags (J) := False;
533 Collect_Withs (Unode);
535 -- For a body, we must also check for any subunits which belong to
536 -- it and which have context clauses of their own, since these
537 -- with'ed units are part of its own elaboration dependencies.
539 if Nkind (Unit (Unode)) in N_Unit_Body then
540 for S in Units.First .. Last_Unit loop
542 -- We are only interested in subunits.
543 -- For preproc. data and def. files, Cunit is Empty, so
544 -- we need to test that first.
546 if Cunit (S) /= Empty
547 and then Nkind (Unit (Cunit (S))) = N_Subunit
549 Pnode := Library_Unit (Cunit (S));
551 -- In gnatc mode, the errors in the subunits will not
552 -- have been recorded, but the analysis of the subunit
553 -- may have failed. There is no information to add to
554 -- ALI file in this case.
560 -- Find ultimate parent of the subunit
562 while Nkind (Unit (Pnode)) = N_Subunit loop
563 Pnode := Library_Unit (Pnode);
566 -- See if it belongs to current unit, and if so, include
569 if Pnode = Unode then
570 Collect_Withs (Cunit (S));
578 -- Output linker option lines
580 for J in 1 .. Linker_Option_Lines.Last loop
582 S : constant Linker_Option_Entry :=
583 Linker_Option_Lines.Table (J);
587 if S.Unit = Unit_Num then
588 Write_Info_Initiate ('L');
589 Write_Info_Str (" """);
591 for J in 1 .. String_Length (S.Option) loop
592 C := Get_Character (Get_String_Char (S.Option, J));
594 if C in Character'Val (16#20#) .. Character'Val (16#7E#)
605 Hex : constant array (0 .. 15) of Character :=
609 Write_Info_Char ('{');
610 Write_Info_Char (Hex (Character'Pos (C) / 16));
611 Write_Info_Char (Hex (Character'Pos (C) mod 16));
612 Write_Info_Char ('}');
617 Write_Info_Char ('"');
622 end Write_Unit_Information;
624 ----------------------
625 -- Write_With_Lines --
626 ----------------------
628 procedure Write_With_Lines is
629 With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
630 Num_Withs : Int := 0;
631 Unum : Unit_Number_Type;
634 Uname : Unit_Name_Type;
635 Fname : File_Name_Type;
636 Pname : constant Unit_Name_Type :=
637 Get_Parent_Spec_Name (Unit_Name (Main_Unit));
638 Body_Fname : File_Name_Type;
641 procedure Write_With_File_Names
642 (Nam : in out File_Name_Type;
644 -- Write source file name Nam and ALI file name for unit index Idx.
645 -- Possibly change Nam to lowercase (generating a new file name).
647 --------------------------
648 -- Write_With_File_Name --
649 --------------------------
651 procedure Write_With_File_Names
652 (Nam : in out File_Name_Type;
656 if not File_Names_Case_Sensitive then
657 Get_Name_String (Nam);
658 To_Lower (Name_Buffer (1 .. Name_Len));
662 Write_Info_Name (Nam);
664 Write_Info_Name (Lib_File_Name (Nam, Idx));
665 end Write_With_File_Names;
667 -- Start of processing for Write_With_Lines
670 -- Loop to build the with table. A with on the main unit itself
671 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
672 -- the main unit is a subprogram with no spec, and a subunit of
673 -- it unecessarily withs the parent.
675 for J in Units.First + 1 .. Last_Unit loop
677 -- Add element to with table if it is with'ed or if it is the
678 -- parent spec of the main unit (case of main unit is a child
679 -- unit). The latter with is not needed for semantic purposes,
680 -- but is required by the binder for elaboration purposes.
681 -- For preproc. data and def. files, there is no Unit_Name,
682 -- check for that first.
684 if Unit_Name (J) /= No_Unit_Name
685 and then (With_Flags (J) or else Unit_Name (J) = Pname)
687 Num_Withs := Num_Withs + 1;
688 With_Table (Num_Withs) := J;
692 -- Sort and output the table
694 Sort (With_Table (1 .. Num_Withs));
696 for J in 1 .. Num_Withs loop
697 Unum := With_Table (J);
698 Cunit := Units.Table (Unum).Cunit;
699 Cunite := Units.Table (Unum).Cunit_Entity;
700 Uname := Units.Table (Unum).Unit_Name;
701 Fname := Units.Table (Unum).Unit_File_Name;
703 Write_Info_Initiate ('W');
704 Write_Info_Char (' ');
705 Write_Info_Name (Uname);
707 -- Now we need to figure out the names of the files that contain
708 -- the with'ed unit. These will usually be the files for the body,
709 -- except in the case of a package that has no body.
711 if (Nkind (Unit (Cunit)) not in N_Generic_Declaration
713 Nkind (Unit (Cunit)) not in N_Generic_Renaming_Declaration)
714 or else Generic_Separately_Compiled (Cunite)
718 if Is_Spec_Name (Uname) then
721 (Get_Body_Name (Uname),
722 Subunit => False, May_Fail => True);
726 (Get_Body_Name (Uname));
728 if Body_Fname = No_File then
729 Body_Fname := Get_File_Name (Uname, Subunit => False);
730 Body_Index := Get_Unit_Index (Uname);
734 Body_Fname := Get_File_Name (Uname, Subunit => False);
735 Body_Index := Get_Unit_Index (Uname);
738 -- A package is considered to have a body if it requires
739 -- a body or if a body is present in Ada 83 mode.
741 if Body_Required (Cunit)
742 or else (Ada_Version = Ada_83
743 and then Full_Source_Name (Body_Fname) /= No_File)
745 Write_With_File_Names (Body_Fname, Body_Index);
747 Write_With_File_Names (Fname, Munit_Index (Unum));
750 if Elab_Flags (Unum) then
751 Write_Info_Str (" E");
754 if Elab_All_Flags (Unum) then
755 Write_Info_Str (" EA");
758 if Elab_Des_Flags (Unum) then
759 Write_Info_Str (" ED");
762 if Elab_All_Des_Flags (Unum) then
763 Write_Info_Str (" AD");
769 end Write_With_Lines;
771 -- Start of processing for Write_ALI
774 -- We never write an ALI file if the original operating mode was
775 -- syntax-only (-gnats switch used in compiler invocation line)
777 if Original_Operating_Mode = Check_Syntax then
781 -- Build sorted source dependency table. We do this right away,
782 -- because it is referenced by Up_To_Date_ALI_File_Exists.
784 for Unum in Units.First .. Last_Unit loop
785 if Cunit_Entity (Unum) = Empty
786 or else not From_With_Type (Cunit_Entity (Unum))
788 Num_Sdep := Num_Sdep + 1;
789 Sdep_Table (Num_Sdep) := Unum;
793 -- Sort the table so that the D lines are in order
795 Lib.Sort (Sdep_Table (1 .. Num_Sdep));
797 -- If we are not generating code, and there is an up to date
798 -- ali file accessible, read it, and acquire the compilation
799 -- arguments from this file.
801 if Operating_Mode /= Generate_Code then
802 if Up_To_Date_ALI_File_Exists then
803 Update_Tables_From_ALI_File;
808 -- Otherwise acquire compilation arguments and prepare to write
809 -- out a new ali file.
811 Create_Output_Library_Info;
813 -- Output version line
815 Write_Info_Initiate ('V');
816 Write_Info_Str (" """);
817 Write_Info_Str (Verbose_Library_Version);
818 Write_Info_Char ('"');
822 -- Output main program line if this is acceptable main program
824 Output_Main_Program_Line : declare
825 U : Node_Id := Unit (Units.Table (Main_Unit).Cunit);
828 procedure M_Parameters;
829 -- Output parameters for main program line
835 procedure M_Parameters is
837 if Main_Priority (Main_Unit) /= Default_Main_Priority then
838 Write_Info_Char (' ');
839 Write_Info_Nat (Main_Priority (Main_Unit));
842 if Opt.Time_Slice_Set then
843 Write_Info_Str (" T=");
844 Write_Info_Nat (Opt.Time_Slice_Value);
847 Write_Info_Str (" W=");
849 (WC_Encoding_Letters (Wide_Character_Encoding_Method));
854 -- Start of processing for Output_Main_Program_Line
857 if Nkind (U) = N_Subprogram_Body
859 (Nkind (U) = N_Package_Body
861 Nkind (Original_Node (U)) in N_Subprogram_Instantiation)
863 -- If the unit is a subprogram instance, the entity for the
864 -- subprogram is the alias of the visible entity, which is the
865 -- related instance of the wrapper package. We retrieve the
866 -- subprogram declaration of the desired entity.
868 if Nkind (U) = N_Package_Body then
869 U := Parent (Parent (
870 Alias (Related_Instance (Defining_Unit_Name
871 (Specification (Unit (Library_Unit (Parent (U)))))))));
874 S := Specification (U);
876 if No (Parameter_Specifications (S)) then
877 if Nkind (S) = N_Procedure_Specification then
878 Write_Info_Initiate ('M');
879 Write_Info_Str (" P");
884 Nam : Node_Id := Defining_Unit_Name (S);
887 -- If it is a child unit, get its simple name
889 if Nkind (Nam) = N_Defining_Program_Unit_Name then
890 Nam := Defining_Identifier (Nam);
893 if Is_Integer_Type (Etype (Nam)) then
894 Write_Info_Initiate ('M');
895 Write_Info_Str (" F");
902 end Output_Main_Program_Line;
904 -- Write command argmument ('A') lines
906 for A in 1 .. Compilation_Switches.Last loop
907 Write_Info_Initiate ('A');
908 Write_Info_Char (' ');
909 Write_Info_Str (Compilation_Switches.Table (A).all);
910 Write_Info_Terminate;
913 -- Output parameters ('P') line
915 Write_Info_Initiate ('P');
917 if Compilation_Errors then
918 Write_Info_Str (" CE");
921 if Opt.Detect_Blocking then
922 Write_Info_Str (" DB");
925 if Opt.Float_Format /= ' ' then
926 Write_Info_Str (" F");
928 if Opt.Float_Format = 'I' then
929 Write_Info_Char ('I');
931 elsif Opt.Float_Format_Long = 'D' then
932 Write_Info_Char ('D');
935 Write_Info_Char ('G');
940 and then not Is_Predefined_File_Name (Unit_File_Name (Main_Unit))
942 if Locking_Policy /= ' ' then
943 Write_Info_Str (" L");
944 Write_Info_Char (Locking_Policy);
947 if Queuing_Policy /= ' ' then
948 Write_Info_Str (" Q");
949 Write_Info_Char (Queuing_Policy);
952 if Task_Dispatching_Policy /= ' ' then
953 Write_Info_Str (" T");
954 Write_Info_Char (Task_Dispatching_Policy);
955 Write_Info_Char (' ');
960 Write_Info_Str (" NO");
963 if No_Run_Time_Mode then
964 Write_Info_Str (" NR");
967 if Normalize_Scalars then
968 Write_Info_Str (" NS");
971 if Sec_Stack_Used then
972 Write_Info_Str (" SS");
975 if Unreserve_All_Interrupts then
976 Write_Info_Str (" UA");
979 if Exception_Mechanism = Back_End_Exceptions then
980 Write_Info_Str (" ZX");
985 -- Before outputting the restrictions line, update the setting of
986 -- the No_Elaboration_Code flag. Violations of this restriction
987 -- cannot be detected until after the backend has been called since
988 -- it is the backend that sets this flag. We have to check all units
989 -- for which we have generated code
991 for Unit in Units.First .. Last_Unit loop
992 if Units.Table (Unit).Generate_Code
993 or else Unit = Main_Unit
995 if not Has_No_Elaboration_Code (Cunit (Unit)) then
996 Main_Restrictions.Violated (No_Elaboration_Code) := True;
1001 -- Output first restrictions line
1003 Write_Info_Initiate ('R');
1004 Write_Info_Char (' ');
1006 -- First the information for the boolean restrictions
1008 for R in All_Boolean_Restrictions loop
1009 if Main_Restrictions.Set (R)
1010 and then not Restriction_Warnings (R)
1012 Write_Info_Char ('r');
1013 elsif Main_Restrictions.Violated (R) then
1014 Write_Info_Char ('v');
1016 Write_Info_Char ('n');
1020 -- And now the information for the parameter restrictions
1022 for RP in All_Parameter_Restrictions loop
1023 if Main_Restrictions.Set (RP)
1024 and then not Restriction_Warnings (RP)
1026 Write_Info_Char ('r');
1027 Write_Info_Nat (Nat (Main_Restrictions.Value (RP)));
1029 Write_Info_Char ('n');
1032 if not Main_Restrictions.Violated (RP)
1033 or else RP not in Checked_Parameter_Restrictions
1035 Write_Info_Char ('n');
1037 Write_Info_Char ('v');
1038 Write_Info_Nat (Nat (Main_Restrictions.Count (RP)));
1040 if Main_Restrictions.Unknown (RP) then
1041 Write_Info_Char ('+');
1048 -- Output R lines for No_Dependence entries
1050 for J in No_Dependence.First .. No_Dependence.Last loop
1051 if In_Extended_Main_Source_Unit (No_Dependence.Table (J).Unit)
1052 and then not No_Dependence.Table (J).Warn
1054 Write_Info_Initiate ('R');
1055 Write_Info_Char (' ');
1056 Write_Unit_Name (No_Dependence.Table (J).Unit);
1061 -- Output interrupt state lines
1063 for J in Interrupt_States.First .. Interrupt_States.Last loop
1064 Write_Info_Initiate ('I');
1065 Write_Info_Char (' ');
1066 Write_Info_Nat (Interrupt_States.Table (J).Interrupt_Number);
1067 Write_Info_Char (' ');
1068 Write_Info_Char (Interrupt_States.Table (J).Interrupt_State);
1069 Write_Info_Char (' ');
1071 (Nat (Get_Logical_Line_Number
1072 (Interrupt_States.Table (J).Pragma_Loc)));
1076 -- Output priority specific dispatching lines
1078 for J in Specific_Dispatching.First .. Specific_Dispatching.Last loop
1079 Write_Info_Initiate ('S');
1080 Write_Info_Char (' ');
1081 Write_Info_Char (Specific_Dispatching.Table (J).Dispatching_Policy);
1082 Write_Info_Char (' ');
1083 Write_Info_Nat (Specific_Dispatching.Table (J).First_Priority);
1084 Write_Info_Char (' ');
1085 Write_Info_Nat (Specific_Dispatching.Table (J).Last_Priority);
1086 Write_Info_Char (' ');
1088 (Nat (Get_Logical_Line_Number
1089 (Specific_Dispatching.Table (J).Pragma_Loc)));
1093 -- Loop through file table to output information for all units for which
1094 -- we have generated code, as marked by the Generate_Code flag.
1096 for Unit in Units.First .. Last_Unit loop
1097 if Units.Table (Unit).Generate_Code
1098 or else Unit = Main_Unit
1100 Write_Info_EOL; -- blank line
1101 Write_Unit_Information (Unit);
1105 Write_Info_EOL; -- blank line
1107 -- Output external version reference lines
1109 for J in 1 .. Version_Ref.Last loop
1110 Write_Info_Initiate ('E');
1111 Write_Info_Char (' ');
1113 for K in 1 .. String_Length (Version_Ref.Table (J)) loop
1114 Write_Info_Char_Code (Get_String_Char (Version_Ref.Table (J), K));
1120 -- Prepare to output the source dependency lines
1123 Unum : Unit_Number_Type;
1124 -- Number of unit being output
1126 Sind : Source_File_Index;
1127 -- Index of corresponding source file
1129 Fname : File_Name_Type;
1132 for J in 1 .. Num_Sdep loop
1133 Unum := Sdep_Table (J);
1134 Units.Table (Unum).Dependency_Num := J;
1135 Sind := Units.Table (Unum).Source_Index;
1137 Write_Info_Initiate ('D');
1138 Write_Info_Char (' ');
1140 -- Normal case of a unit entry with a source index
1142 if Sind /= No_Source_File then
1143 Fname := File_Name (Sind);
1145 -- Ensure that on platforms where the file names are not
1146 -- case sensitive, the recorded file name is in lower case.
1148 if not File_Names_Case_Sensitive then
1149 Get_Name_String (Fname);
1150 To_Lower (Name_Buffer (1 .. Name_Len));
1154 Write_Info_Name (Fname);
1155 Write_Info_Tab (25);
1156 Write_Info_Str (String (Time_Stamp (Sind)));
1157 Write_Info_Char (' ');
1158 Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
1160 -- If subunit, add unit name, omitting the %b at the end
1162 if Present (Cunit (Unum))
1163 and then Nkind (Unit (Cunit (Unum))) = N_Subunit
1165 Get_Decoded_Name_String (Unit_Name (Unum));
1166 Write_Info_Char (' ');
1167 Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
1170 -- If Source_Reference pragma used output information
1172 if Num_SRef_Pragmas (Sind) > 0 then
1173 Write_Info_Char (' ');
1175 if Num_SRef_Pragmas (Sind) = 1 then
1176 Write_Info_Nat (Int (First_Mapped_Line (Sind)));
1181 Write_Info_Char (':');
1182 Write_Info_Name (Reference_Name (Sind));
1185 -- Case where there is no source index (happens for missing
1186 -- files). In this case we write a dummy time stamp.
1189 Write_Info_Name (Unit_File_Name (Unum));
1190 Write_Info_Tab (25);
1191 Write_Info_Str (String (Dummy_Time_Stamp));
1192 Write_Info_Char (' ');
1193 Write_Info_Str (Get_Hex_String (0));
1201 Write_Info_Terminate;
1202 Close_Output_Library_Info;
1205 ---------------------
1206 -- Write_Unit_Name --
1207 ---------------------
1209 procedure Write_Unit_Name (N : Node_Id) is
1211 if Nkind (N) = N_Identifier then
1212 Write_Info_Name (Chars (N));
1215 pragma Assert (Nkind (N) = N_Selected_Component);
1216 Write_Unit_Name (Prefix (N));
1217 Write_Info_Char ('.');
1218 Write_Unit_Name (Selector_Name (N));
1220 end Write_Unit_Name;