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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
27 with Atree; use Atree;
28 with Casing; use Casing;
29 with Einfo; use Einfo;
30 with Errout; use Errout;
31 with Fname; use Fname;
32 with Fname.UF; use Fname.UF;
33 with Lib.Util; use Lib.Util;
34 with Lib.Xref; use Lib.Xref;
35 with Nlists; use Nlists;
36 with Gnatvsn; use Gnatvsn;
38 with Osint; use Osint;
39 with Osint.C; use Osint.C;
41 with Restrict; use Restrict;
42 with Rident; use Rident;
44 with Sinfo; use Sinfo;
45 with Sinput; use Sinput;
46 with Snames; use Snames;
47 with Stringt; use Stringt;
48 with Tbuild; use Tbuild;
49 with Uname; use Uname;
51 with System.Case_Util; use System.Case_Util;
52 with System.WCh_Con; use System.WCh_Con;
54 package body Lib.Writ is
56 -----------------------
57 -- Local Subprograms --
58 -----------------------
60 procedure Write_Unit_Name (N : Node_Id);
61 -- Used to write out the unit name for R (pragma Restriction) lines
62 -- for uses of Restriction (No_Dependence => unit-name).
64 ----------------------------------
65 -- Add_Preprocessing_Dependency --
66 ----------------------------------
68 procedure Add_Preprocessing_Dependency (S : Source_File_Index) is
71 Units.Table (Units.Last) :=
72 (Unit_File_Name => File_Name (S),
73 Unit_Name => No_Unit_Name,
74 Expected_Unit => No_Unit_Name,
77 Cunit_Entity => Empty,
79 Dynamic_Elab => False,
81 Generate_Code => False,
83 Ident_String => Empty,
89 Error_Location => No_Location);
90 end Add_Preprocessing_Dependency;
92 ------------------------------
93 -- Ensure_System_Dependency --
94 ------------------------------
96 procedure Ensure_System_Dependency is
97 System_Uname : Unit_Name_Type;
98 -- Unit name for system spec if needed for dummy entry
100 System_Fname : File_Name_Type;
101 -- File name for system spec if needed for dummy entry
104 -- Nothing to do if we already compiled System
106 for Unum in Units.First .. Last_Unit loop
107 if Units.Table (Unum).Source_Index = System_Source_File_Index then
112 -- If no entry for system.ads in the units table, then add a entry
113 -- to the units table for system.ads, which will be referenced when
114 -- the ali file is generated. We need this because every unit depends
115 -- on system as a result of Targparm scanning the system.ads file to
116 -- determine the target dependent parameters for the compilation.
119 Name_Buffer (1 .. 6) := "system";
120 System_Uname := Name_To_Unit_Name (Name_Enter);
121 System_Fname := File_Name (System_Source_File_Index);
123 Units.Increment_Last;
124 Units.Table (Units.Last) := (
125 Unit_File_Name => System_Fname,
126 Unit_Name => System_Uname,
127 Expected_Unit => System_Uname,
128 Source_Index => System_Source_File_Index,
130 Cunit_Entity => Empty,
132 Dynamic_Elab => False,
133 Fatal_Error => False,
134 Generate_Code => False,
136 Ident_String => Empty,
142 Error_Location => No_Location);
144 -- Parse system.ads so that the checksum is set right
145 -- Style checks are not applied.
148 Save_Mindex : constant Nat := Multiple_Unit_Index;
149 Save_Style : constant Boolean := Style_Check;
151 Multiple_Unit_Index := 0;
152 Style_Check := False;
153 Initialize_Scanner (Units.Last, System_Source_File_Index);
154 Discard_List (Par (Configuration_Pragmas => False));
155 Style_Check := Save_Style;
156 Multiple_Unit_Index := Save_Mindex;
158 end Ensure_System_Dependency;
164 procedure Write_ALI (Object : Boolean) is
170 Last_Unit : constant Unit_Number_Type := Units.Last;
171 -- Record unit number of last unit. We capture this in case we
172 -- have to add a dummy entry to the unit table for package System.
174 With_Flags : array (Units.First .. Last_Unit) of Boolean;
175 -- Array of flags to show which units are with'ed
177 Elab_Flags : array (Units.First .. Last_Unit) of Boolean;
178 -- Array of flags to show which units have pragma Elaborate set
180 Elab_All_Flags : array (Units.First .. Last_Unit) of Boolean;
181 -- Array of flags to show which units have pragma Elaborate All set
183 Elab_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
184 -- Array of flags to show which units have Elaborate_Desirable set
186 Elab_All_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
187 -- Array of flags to show which units have Elaborate_All_Desirable set
189 Sdep_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 2));
190 -- Sorted table of source dependencies. One extra entry in case we
191 -- have to add a dummy entry for System.
194 -- Number of active entries in Sdep_Table
196 -----------------------
197 -- Local Subprograms --
198 -----------------------
200 procedure Collect_Withs (Cunit : Node_Id);
201 -- Collect with lines for entries in the context clause of the
202 -- given compilation unit, Cunit.
204 procedure Update_Tables_From_ALI_File;
205 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
206 -- function), update tables from the ALI information, including
207 -- specifically the Compilation_Switches table.
209 function Up_To_Date_ALI_File_Exists return Boolean;
210 -- If there exists an ALI file that is up to date, then this function
211 -- initializes the tables in the ALI spec to contain information on
212 -- this file (using Scan_ALI) and returns True. If no file exists,
213 -- or the file is not up to date, then False is returned.
215 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type);
216 -- Write out the library information for one unit for which code is
217 -- generated (includes unit line and with lines).
219 procedure Write_With_Lines;
220 -- Write out with lines collected by calls to Collect_Withs
226 procedure Collect_Withs (Cunit : Node_Id) is
228 Unum : Unit_Number_Type;
231 Item := First (Context_Items (Cunit));
232 while Present (Item) loop
234 -- Process with clause
236 -- Ada 2005 (AI-50217): limited with_clauses do not create
239 if Nkind (Item) = N_With_Clause
240 and then not (Limited_Present (Item))
242 Unum := Get_Cunit_Unit_Number (Library_Unit (Item));
243 With_Flags (Unum) := True;
245 if Elaborate_Present (Item) then
246 Elab_Flags (Unum) := True;
249 if Elaborate_All_Present (Item) then
250 Elab_All_Flags (Unum) := True;
253 if Elaborate_All_Desirable (Item) then
254 Elab_All_Des_Flags (Unum) := True;
257 if Elaborate_Desirable (Item) then
258 Elab_Des_Flags (Unum) := True;
266 --------------------------------
267 -- Up_To_Date_ALI_File_Exists --
268 --------------------------------
270 function Up_To_Date_ALI_File_Exists return Boolean is
271 Name : File_Name_Type;
272 Text : Text_Buffer_Ptr;
274 Sind : Source_File_Index;
277 Opt.Check_Object_Consistency := True;
278 Read_Library_Info (Name, Text);
280 -- Return if we could not find an ALI file
286 -- Return if ALI file has bad format
290 if Scan_ALI (Name, Text, False, Err => True) = No_ALI_Id then
294 -- If we have an OK ALI file, check if it is up to date
295 -- Note that we assume that the ALI read has all the entries
296 -- we have in our table, plus some additional ones (that can
297 -- come from expansion).
299 Id := First_Sdep_Entry;
300 for J in 1 .. Num_Sdep loop
301 Sind := Units.Table (Sdep_Table (J)).Source_Index;
303 while Sdep.Table (Id).Sfile /= File_Name (Sind) loop
304 if Id = Sdep.Last then
311 if Sdep.Table (Id).Stamp /= Time_Stamp (Sind) then
317 end Up_To_Date_ALI_File_Exists;
319 ---------------------------------
320 -- Update_Tables_From_ALI_File --
321 ---------------------------------
323 procedure Update_Tables_From_ALI_File is
325 -- Build Compilation_Switches table
327 Compilation_Switches.Init;
329 for J in First_Arg_Entry .. Args.Last loop
330 Compilation_Switches.Increment_Last;
331 Compilation_Switches.Table (Compilation_Switches.Last) :=
334 end Update_Tables_From_ALI_File;
336 ----------------------------
337 -- Write_Unit_Information --
338 ----------------------------
340 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type) is
341 Unode : constant Node_Id := Cunit (Unit_Num);
342 Ukind : constant Node_Kind := Nkind (Unit (Unode));
343 Uent : constant Entity_Id := Cunit_Entity (Unit_Num);
347 Write_Info_Initiate ('U');
348 Write_Info_Char (' ');
349 Write_Info_Name (Unit_Name (Unit_Num));
351 Write_Info_Name (Unit_File_Name (Unit_Num));
354 Write_Info_Str (Version_Get (Unit_Num));
356 -- Add BD parameter if Elaborate_Body pragma desirable
358 if Ekind (Uent) = E_Package
359 and then Elaborate_Body_Desirable (Uent)
361 Write_Info_Str (" BD");
364 -- Add BN parameter if body needed for SAL
366 if (Is_Subprogram (Uent)
367 or else Ekind (Uent) = E_Package
368 or else Is_Generic_Unit (Uent))
369 and then Body_Needed_For_SAL (Uent)
371 Write_Info_Str (" BN");
374 if Dynamic_Elab (Unit_Num) then
375 Write_Info_Str (" DE");
378 -- Set the Elaborate_Body indication if either an explicit pragma
379 -- was present, or if this is an instantiation.
381 if Has_Pragma_Elaborate_Body (Uent)
382 or else (Ukind = N_Package_Declaration
383 and then Is_Generic_Instance (Uent)
384 and then Present (Corresponding_Body (Unit (Unode))))
386 Write_Info_Str (" EB");
389 -- Now see if we should tell the binder that an elaboration entity
390 -- is present, which must be set to true during elaboration.
391 -- We generate the indication if the following condition is met:
393 -- If this is a spec ...
395 if (Is_Subprogram (Uent)
397 Ekind (Uent) = E_Package
399 Is_Generic_Unit (Uent))
401 -- and an elaboration entity was declared ...
403 and then Present (Elaboration_Entity (Uent))
405 -- and either the elaboration flag is required ...
408 (Elaboration_Entity_Required (Uent)
410 -- or this unit has elaboration code ...
412 or else not Has_No_Elaboration_Code (Unode)
414 -- or this unit has a separate body and this
415 -- body has elaboration code.
418 (Ekind (Uent) = E_Package
419 and then Present (Body_Entity (Uent))
421 not Has_No_Elaboration_Code
424 (Body_Entity (Uent))))))
426 if Convention (Uent) = Convention_CIL then
428 -- Special case for generic CIL packages which never have
431 Write_Info_Str (" NE");
434 Write_Info_Str (" EE");
438 if Has_No_Elaboration_Code (Unode) then
439 Write_Info_Str (" NE");
442 if Is_Preelaborated (Uent) then
443 Write_Info_Str (" PR");
446 if Is_Pure (Uent) then
447 Write_Info_Str (" PU");
450 if Has_RACW (Unit_Num) then
451 Write_Info_Str (" RA");
454 if Is_Remote_Call_Interface (Uent) then
455 Write_Info_Str (" RC");
458 if Is_Remote_Types (Uent) then
459 Write_Info_Str (" RT");
462 if Is_Shared_Passive (Uent) then
463 Write_Info_Str (" SP");
466 if Ukind = N_Subprogram_Declaration
467 or else Ukind = N_Subprogram_Body
469 Write_Info_Str (" SU");
471 elsif Ukind = N_Package_Declaration
473 Ukind = N_Package_Body
475 -- If this is a wrapper package for a subprogram instantiation,
476 -- the user view is the subprogram. Note that in this case the
477 -- ali file contains both the spec and body of the instance.
479 if Is_Wrapper_Package (Uent) then
480 Write_Info_Str (" SU");
482 Write_Info_Str (" PK");
485 elsif Ukind = N_Generic_Package_Declaration then
486 Write_Info_Str (" PK");
490 if Ukind in N_Generic_Declaration
492 (Present (Library_Unit (Unode))
494 Nkind (Unit (Library_Unit (Unode))) in N_Generic_Declaration)
496 Write_Info_Str (" GE");
499 if not Is_Internal_File_Name (Unit_File_Name (Unit_Num), True) then
500 case Identifier_Casing (Source_Index (Unit_Num)) is
501 when All_Lower_Case => Write_Info_Str (" IL");
502 when All_Upper_Case => Write_Info_Str (" IU");
506 case Keyword_Casing (Source_Index (Unit_Num)) is
507 when Mixed_Case => Write_Info_Str (" KM");
508 when All_Upper_Case => Write_Info_Str (" KU");
513 if Initialize_Scalars then
514 Write_Info_Str (" IS");
519 -- Generate with lines, first those that are directly with'ed
521 for J in With_Flags'Range loop
522 With_Flags (J) := False;
523 Elab_Flags (J) := False;
524 Elab_All_Flags (J) := False;
525 Elab_Des_Flags (J) := False;
526 Elab_All_Des_Flags (J) := False;
529 Collect_Withs (Unode);
531 -- For a body, we must also check for any subunits which belong to
532 -- it and which have context clauses of their own, since these
533 -- with'ed units are part of its own elaboration dependencies.
535 if Nkind (Unit (Unode)) in N_Unit_Body then
536 for S in Units.First .. Last_Unit loop
538 -- We are only interested in subunits.
539 -- For preproc. data and def. files, Cunit is Empty, so
540 -- we need to test that first.
542 if Cunit (S) /= Empty
543 and then Nkind (Unit (Cunit (S))) = N_Subunit
545 Pnode := Library_Unit (Cunit (S));
547 -- In gnatc mode, the errors in the subunits will not
548 -- have been recorded, but the analysis of the subunit
549 -- may have failed. There is no information to add to
550 -- ALI file in this case.
556 -- Find ultimate parent of the subunit
558 while Nkind (Unit (Pnode)) = N_Subunit loop
559 Pnode := Library_Unit (Pnode);
562 -- See if it belongs to current unit, and if so, include
565 if Pnode = Unode then
566 Collect_Withs (Cunit (S));
574 -- Output linker option lines
576 for J in 1 .. Linker_Option_Lines.Last loop
578 S : constant Linker_Option_Entry :=
579 Linker_Option_Lines.Table (J);
583 if S.Unit = Unit_Num then
584 Write_Info_Initiate ('L');
585 Write_Info_Str (" """);
587 for J in 1 .. String_Length (S.Option) loop
588 C := Get_Character (Get_String_Char (S.Option, J));
590 if C in Character'Val (16#20#) .. Character'Val (16#7E#)
601 Hex : constant array (0 .. 15) of Character :=
605 Write_Info_Char ('{');
606 Write_Info_Char (Hex (Character'Pos (C) / 16));
607 Write_Info_Char (Hex (Character'Pos (C) mod 16));
608 Write_Info_Char ('}');
613 Write_Info_Char ('"');
618 end Write_Unit_Information;
620 ----------------------
621 -- Write_With_Lines --
622 ----------------------
624 procedure Write_With_Lines is
625 With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
626 Num_Withs : Int := 0;
627 Unum : Unit_Number_Type;
629 Uname : Unit_Name_Type;
630 Fname : File_Name_Type;
631 Pname : constant Unit_Name_Type :=
632 Get_Parent_Spec_Name (Unit_Name (Main_Unit));
633 Body_Fname : File_Name_Type;
636 procedure Write_With_File_Names
637 (Nam : in out File_Name_Type;
639 -- Write source file name Nam and ALI file name for unit index Idx.
640 -- Possibly change Nam to lowercase (generating a new file name).
642 --------------------------
643 -- Write_With_File_Name --
644 --------------------------
646 procedure Write_With_File_Names
647 (Nam : in out File_Name_Type;
651 if not File_Names_Case_Sensitive then
652 Get_Name_String (Nam);
653 To_Lower (Name_Buffer (1 .. Name_Len));
657 Write_Info_Name (Nam);
659 Write_Info_Name (Lib_File_Name (Nam, Idx));
660 end Write_With_File_Names;
662 -- Start of processing for Write_With_Lines
665 -- Loop to build the with table. A with on the main unit itself
666 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
667 -- the main unit is a subprogram with no spec, and a subunit of
668 -- it unecessarily withs the parent.
670 for J in Units.First + 1 .. Last_Unit loop
672 -- Add element to with table if it is with'ed or if it is the
673 -- parent spec of the main unit (case of main unit is a child
674 -- unit). The latter with is not needed for semantic purposes,
675 -- but is required by the binder for elaboration purposes.
676 -- For preproc. data and def. files, there is no Unit_Name,
677 -- check for that first.
679 if Unit_Name (J) /= No_Unit_Name
680 and then (With_Flags (J) or else Unit_Name (J) = Pname)
682 Num_Withs := Num_Withs + 1;
683 With_Table (Num_Withs) := J;
687 -- Sort and output the table
689 Sort (With_Table (1 .. Num_Withs));
691 for J in 1 .. Num_Withs loop
692 Unum := With_Table (J);
693 Cunit := Units.Table (Unum).Cunit;
694 Uname := Units.Table (Unum).Unit_Name;
695 Fname := Units.Table (Unum).Unit_File_Name;
697 Write_Info_Initiate ('W');
698 Write_Info_Char (' ');
699 Write_Info_Name (Uname);
701 -- Now we need to figure out the names of the files that contain
702 -- the with'ed unit. These will usually be the files for the body,
703 -- except in the case of a package that has no body. Note that we
704 -- have a specific exemption here for predefined library generics
705 -- (see comments for Generic_May_Lack_ALI). We do not generate
706 -- dependency upon the ALI file for such units. Older compilers
707 -- used to not support generating code (and ALI) for generics, and
708 -- we want to avoid having different processing (namely, different
709 -- lists of files to be compiled) for different stages of the
712 if not ((Nkind (Unit (Cunit)) in N_Generic_Declaration
714 Nkind (Unit (Cunit)) in N_Generic_Renaming_Declaration)
715 and then Generic_May_Lack_ALI (Fname))
719 if Is_Spec_Name (Uname) then
722 (Get_Body_Name (Uname),
723 Subunit => False, May_Fail => True);
727 (Get_Body_Name (Uname));
729 if Body_Fname = No_File then
730 Body_Fname := Get_File_Name (Uname, Subunit => False);
731 Body_Index := Get_Unit_Index (Uname);
735 Body_Fname := Get_File_Name (Uname, Subunit => False);
736 Body_Index := Get_Unit_Index (Uname);
739 -- A package is considered to have a body if it requires
740 -- a body or if a body is present in Ada 83 mode.
742 if Body_Required (Cunit)
743 or else (Ada_Version = Ada_83
744 and then Full_Source_Name (Body_Fname) /= No_File)
746 Write_With_File_Names (Body_Fname, Body_Index);
748 Write_With_File_Names (Fname, Munit_Index (Unum));
751 if Elab_Flags (Unum) then
752 Write_Info_Str (" E");
755 if Elab_All_Flags (Unum) then
756 Write_Info_Str (" EA");
759 if Elab_Des_Flags (Unum) then
760 Write_Info_Str (" ED");
763 if Elab_All_Des_Flags (Unum) then
764 Write_Info_Str (" AD");
770 end Write_With_Lines;
772 -- Start of processing for Write_ALI
775 -- We never write an ALI file if the original operating mode was
776 -- syntax-only (-gnats switch used in compiler invocation line)
778 if Original_Operating_Mode = Check_Syntax then
782 -- Build sorted source dependency table. We do this right away,
783 -- because it is referenced by Up_To_Date_ALI_File_Exists.
785 for Unum in Units.First .. Last_Unit loop
786 if Cunit_Entity (Unum) = Empty
787 or else not From_With_Type (Cunit_Entity (Unum))
789 Num_Sdep := Num_Sdep + 1;
790 Sdep_Table (Num_Sdep) := Unum;
794 -- Sort the table so that the D lines are in order
796 Lib.Sort (Sdep_Table (1 .. Num_Sdep));
798 -- If we are not generating code, and there is an up to date
799 -- ali file accessible, read it, and acquire the compilation
800 -- arguments from this file.
802 if Operating_Mode /= Generate_Code then
803 if Up_To_Date_ALI_File_Exists then
804 Update_Tables_From_ALI_File;
809 -- Otherwise acquire compilation arguments and prepare to write
810 -- out a new ali file.
812 Create_Output_Library_Info;
814 -- Output version line
816 Write_Info_Initiate ('V');
817 Write_Info_Str (" """);
818 Write_Info_Str (Verbose_Library_Version);
819 Write_Info_Char ('"');
823 -- Output main program line if this is acceptable main program
825 Output_Main_Program_Line : declare
826 U : Node_Id := Unit (Units.Table (Main_Unit).Cunit);
829 procedure M_Parameters;
830 -- Output parameters for main program line
836 procedure M_Parameters is
838 if Main_Priority (Main_Unit) /= Default_Main_Priority then
839 Write_Info_Char (' ');
840 Write_Info_Nat (Main_Priority (Main_Unit));
843 if Opt.Time_Slice_Set then
844 Write_Info_Str (" T=");
845 Write_Info_Nat (Opt.Time_Slice_Value);
848 Write_Info_Str (" W=");
850 (WC_Encoding_Letters (Wide_Character_Encoding_Method));
855 -- Start of processing for Output_Main_Program_Line
858 if Nkind (U) = N_Subprogram_Body
860 (Nkind (U) = N_Package_Body
862 Nkind (Original_Node (U)) in N_Subprogram_Instantiation)
864 -- If the unit is a subprogram instance, the entity for the
865 -- subprogram is the alias of the visible entity, which is the
866 -- related instance of the wrapper package. We retrieve the
867 -- subprogram declaration of the desired entity.
869 if Nkind (U) = N_Package_Body then
870 U := Parent (Parent (
871 Alias (Related_Instance (Defining_Unit_Name
872 (Specification (Unit (Library_Unit (Parent (U)))))))));
875 S := Specification (U);
877 if No (Parameter_Specifications (S)) then
878 if Nkind (S) = N_Procedure_Specification then
879 Write_Info_Initiate ('M');
880 Write_Info_Str (" P");
885 Nam : Node_Id := Defining_Unit_Name (S);
888 -- If it is a child unit, get its simple name
890 if Nkind (Nam) = N_Defining_Program_Unit_Name then
891 Nam := Defining_Identifier (Nam);
894 if Is_Integer_Type (Etype (Nam)) then
895 Write_Info_Initiate ('M');
896 Write_Info_Str (" F");
903 end Output_Main_Program_Line;
905 -- Write command argmument ('A') lines
907 for A in 1 .. Compilation_Switches.Last loop
908 Write_Info_Initiate ('A');
909 Write_Info_Char (' ');
910 Write_Info_Str (Compilation_Switches.Table (A).all);
911 Write_Info_Terminate;
914 -- Output parameters ('P') line
916 Write_Info_Initiate ('P');
918 if Compilation_Errors then
919 Write_Info_Str (" CE");
922 if Opt.Detect_Blocking then
923 Write_Info_Str (" DB");
926 if Opt.Float_Format /= ' ' then
927 Write_Info_Str (" F");
929 if Opt.Float_Format = 'I' then
930 Write_Info_Char ('I');
932 elsif Opt.Float_Format_Long = 'D' then
933 Write_Info_Char ('D');
936 Write_Info_Char ('G');
941 and then not Is_Predefined_File_Name (Unit_File_Name (Main_Unit))
943 if Locking_Policy /= ' ' then
944 Write_Info_Str (" L");
945 Write_Info_Char (Locking_Policy);
948 if Queuing_Policy /= ' ' then
949 Write_Info_Str (" Q");
950 Write_Info_Char (Queuing_Policy);
953 if Task_Dispatching_Policy /= ' ' then
954 Write_Info_Str (" T");
955 Write_Info_Char (Task_Dispatching_Policy);
956 Write_Info_Char (' ');
961 Write_Info_Str (" NO");
964 if No_Run_Time_Mode then
965 Write_Info_Str (" NR");
968 if Normalize_Scalars then
969 Write_Info_Str (" NS");
972 if Sec_Stack_Used then
973 Write_Info_Str (" SS");
976 if Unreserve_All_Interrupts then
977 Write_Info_Str (" UA");
980 if Exception_Mechanism = Back_End_Exceptions then
981 Write_Info_Str (" ZX");
986 -- Before outputting the restrictions line, update the setting of
987 -- the No_Elaboration_Code flag. Violations of this restriction
988 -- cannot be detected until after the backend has been called since
989 -- it is the backend that sets this flag. We have to check all units
990 -- for which we have generated code
992 for Unit in Units.First .. Last_Unit loop
993 if Units.Table (Unit).Generate_Code
994 or else Unit = Main_Unit
996 if not Has_No_Elaboration_Code (Cunit (Unit)) then
997 Main_Restrictions.Violated (No_Elaboration_Code) := True;
1002 -- Output first restrictions line
1004 Write_Info_Initiate ('R');
1005 Write_Info_Char (' ');
1007 -- First the information for the boolean restrictions
1009 for R in All_Boolean_Restrictions loop
1010 if Main_Restrictions.Set (R)
1011 and then not Restriction_Warnings (R)
1013 Write_Info_Char ('r');
1014 elsif Main_Restrictions.Violated (R) then
1015 Write_Info_Char ('v');
1017 Write_Info_Char ('n');
1021 -- And now the information for the parameter restrictions
1023 for RP in All_Parameter_Restrictions loop
1024 if Main_Restrictions.Set (RP)
1025 and then not Restriction_Warnings (RP)
1027 Write_Info_Char ('r');
1028 Write_Info_Nat (Nat (Main_Restrictions.Value (RP)));
1030 Write_Info_Char ('n');
1033 if not Main_Restrictions.Violated (RP)
1034 or else RP not in Checked_Parameter_Restrictions
1036 Write_Info_Char ('n');
1038 Write_Info_Char ('v');
1039 Write_Info_Nat (Nat (Main_Restrictions.Count (RP)));
1041 if Main_Restrictions.Unknown (RP) then
1042 Write_Info_Char ('+');
1049 -- Output R lines for No_Dependence entries
1051 for J in No_Dependence.First .. No_Dependence.Last loop
1052 if In_Extended_Main_Source_Unit (No_Dependence.Table (J).Unit)
1053 and then not No_Dependence.Table (J).Warn
1055 Write_Info_Initiate ('R');
1056 Write_Info_Char (' ');
1057 Write_Unit_Name (No_Dependence.Table (J).Unit);
1062 -- Output interrupt state lines
1064 for J in Interrupt_States.First .. Interrupt_States.Last loop
1065 Write_Info_Initiate ('I');
1066 Write_Info_Char (' ');
1067 Write_Info_Nat (Interrupt_States.Table (J).Interrupt_Number);
1068 Write_Info_Char (' ');
1069 Write_Info_Char (Interrupt_States.Table (J).Interrupt_State);
1070 Write_Info_Char (' ');
1072 (Nat (Get_Logical_Line_Number
1073 (Interrupt_States.Table (J).Pragma_Loc)));
1077 -- Output priority specific dispatching lines
1079 for J in Specific_Dispatching.First .. Specific_Dispatching.Last loop
1080 Write_Info_Initiate ('S');
1081 Write_Info_Char (' ');
1082 Write_Info_Char (Specific_Dispatching.Table (J).Dispatching_Policy);
1083 Write_Info_Char (' ');
1084 Write_Info_Nat (Specific_Dispatching.Table (J).First_Priority);
1085 Write_Info_Char (' ');
1086 Write_Info_Nat (Specific_Dispatching.Table (J).Last_Priority);
1087 Write_Info_Char (' ');
1089 (Nat (Get_Logical_Line_Number
1090 (Specific_Dispatching.Table (J).Pragma_Loc)));
1094 -- Loop through file table to output information for all units for which
1095 -- we have generated code, as marked by the Generate_Code flag.
1097 for Unit in Units.First .. Last_Unit loop
1098 if Units.Table (Unit).Generate_Code
1099 or else Unit = Main_Unit
1101 Write_Info_EOL; -- blank line
1102 Write_Unit_Information (Unit);
1106 Write_Info_EOL; -- blank line
1108 -- Output external version reference lines
1110 for J in 1 .. Version_Ref.Last loop
1111 Write_Info_Initiate ('E');
1112 Write_Info_Char (' ');
1114 for K in 1 .. String_Length (Version_Ref.Table (J)) loop
1115 Write_Info_Char_Code (Get_String_Char (Version_Ref.Table (J), K));
1121 -- Prepare to output the source dependency lines
1124 Unum : Unit_Number_Type;
1125 -- Number of unit being output
1127 Sind : Source_File_Index;
1128 -- Index of corresponding source file
1130 Fname : File_Name_Type;
1133 for J in 1 .. Num_Sdep loop
1134 Unum := Sdep_Table (J);
1135 Units.Table (Unum).Dependency_Num := J;
1136 Sind := Units.Table (Unum).Source_Index;
1138 Write_Info_Initiate ('D');
1139 Write_Info_Char (' ');
1141 -- Normal case of a unit entry with a source index
1143 if Sind /= No_Source_File then
1144 Fname := File_Name (Sind);
1146 -- Ensure that on platforms where the file names are not
1147 -- case sensitive, the recorded file name is in lower case.
1149 if not File_Names_Case_Sensitive then
1150 Get_Name_String (Fname);
1151 To_Lower (Name_Buffer (1 .. Name_Len));
1155 Write_Info_Name (Fname);
1156 Write_Info_Tab (25);
1157 Write_Info_Str (String (Time_Stamp (Sind)));
1158 Write_Info_Char (' ');
1159 Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
1161 -- If subunit, add unit name, omitting the %b at the end
1163 if Present (Cunit (Unum))
1164 and then Nkind (Unit (Cunit (Unum))) = N_Subunit
1166 Get_Decoded_Name_String (Unit_Name (Unum));
1167 Write_Info_Char (' ');
1168 Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
1171 -- If Source_Reference pragma used output information
1173 if Num_SRef_Pragmas (Sind) > 0 then
1174 Write_Info_Char (' ');
1176 if Num_SRef_Pragmas (Sind) = 1 then
1177 Write_Info_Nat (Int (First_Mapped_Line (Sind)));
1182 Write_Info_Char (':');
1183 Write_Info_Name (Reference_Name (Sind));
1186 -- Case where there is no source index (happens for missing
1187 -- files). In this case we write a dummy time stamp.
1190 Write_Info_Name (Unit_File_Name (Unum));
1191 Write_Info_Tab (25);
1192 Write_Info_Str (String (Dummy_Time_Stamp));
1193 Write_Info_Char (' ');
1194 Write_Info_Str (Get_Hex_String (0));
1202 Write_Info_Terminate;
1203 Close_Output_Library_Info;
1206 ---------------------
1207 -- Write_Unit_Name --
1208 ---------------------
1210 procedure Write_Unit_Name (N : Node_Id) is
1212 if Nkind (N) = N_Identifier then
1213 Write_Info_Name (Chars (N));
1216 pragma Assert (Nkind (N) = N_Selected_Component);
1217 Write_Unit_Name (Prefix (N));
1218 Write_Info_Char ('.');
1219 Write_Unit_Name (Selector_Name (N));
1221 end Write_Unit_Name;