1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 Namet; use Namet;
37 with Nlists; use Nlists;
38 with Gnatvsn; use Gnatvsn;
40 with Osint; use Osint;
41 with Osint.C; use Osint.C;
43 with Restrict; use Restrict;
44 with Rident; use Rident;
46 with Sinfo; use Sinfo;
47 with Sinput; use Sinput;
48 with Stringt; use Stringt;
49 with Tbuild; use Tbuild;
50 with Uname; use Uname;
52 with System.WCh_Con; use System.WCh_Con;
54 package body Lib.Writ is
56 ----------------------------------
57 -- Add_Preprocessing_Dependency --
58 ----------------------------------
60 procedure Add_Preprocessing_Dependency (S : Source_File_Index) is
63 Units.Table (Units.Last) :=
64 (Unit_File_Name => File_Name (S),
66 Expected_Unit => No_Name,
69 Cunit_Entity => Empty,
71 Dynamic_Elab => False,
73 Generate_Code => False,
75 Ident_String => Empty,
81 Error_Location => No_Location);
82 end Add_Preprocessing_Dependency;
84 ------------------------------
85 -- Ensure_System_Dependency --
86 ------------------------------
88 procedure Ensure_System_Dependency is
89 System_Uname : Unit_Name_Type;
90 -- Unit name for system spec if needed for dummy entry
92 System_Fname : File_Name_Type;
93 -- File name for system spec if needed for dummy entry
96 -- Nothing to do if we already compiled System
98 for Unum in Units.First .. Last_Unit loop
99 if Units.Table (Unum).Source_Index = System_Source_File_Index then
104 -- If no entry for system.ads in the units table, then add a entry
105 -- to the units table for system.ads, which will be referenced when
106 -- the ali file is generated. We need this because every unit depends
107 -- on system as a result of Targparm scanning the system.ads file to
108 -- determine the target dependent parameters for the compilation.
111 Name_Buffer (1 .. 6) := "system";
112 System_Uname := Name_To_Unit_Name (Name_Enter);
113 System_Fname := File_Name (System_Source_File_Index);
115 Units.Increment_Last;
116 Units.Table (Units.Last) := (
117 Unit_File_Name => System_Fname,
118 Unit_Name => System_Uname,
119 Expected_Unit => System_Uname,
120 Source_Index => System_Source_File_Index,
122 Cunit_Entity => Empty,
124 Dynamic_Elab => False,
125 Fatal_Error => False,
126 Generate_Code => False,
128 Ident_String => Empty,
134 Error_Location => No_Location);
136 -- Parse system.ads so that the checksum is set right
137 -- Style checks are not applied.
140 Save_Mindex : constant Nat := Multiple_Unit_Index;
141 Save_Style : constant Boolean := Style_Check;
143 Multiple_Unit_Index := 0;
144 Style_Check := False;
145 Initialize_Scanner (Units.Last, System_Source_File_Index);
146 Discard_List (Par (Configuration_Pragmas => False));
147 Style_Check := Save_Style;
148 Multiple_Unit_Index := Save_Mindex;
150 end Ensure_System_Dependency;
156 procedure Write_ALI (Object : Boolean) is
162 Last_Unit : constant Unit_Number_Type := Units.Last;
163 -- Record unit number of last unit. We capture this in case we
164 -- have to add a dummy entry to the unit table for package System.
166 With_Flags : array (Units.First .. Last_Unit) of Boolean;
167 -- Array of flags to show which units are with'ed
169 Elab_Flags : array (Units.First .. Last_Unit) of Boolean;
170 -- Array of flags to show which units have pragma Elaborate set
172 Elab_All_Flags : array (Units.First .. Last_Unit) of Boolean;
173 -- Array of flags to show which units have pragma Elaborate All set
175 Elab_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
176 -- Array of flags to show which units have Elaborate_All_Desirable set
178 Sdep_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 2));
179 -- Sorted table of source dependencies. One extra entry in case we
180 -- have to add a dummy entry for System.
183 -- Number of active entries in Sdep_Table
185 -----------------------
186 -- Local Subprograms --
187 -----------------------
189 procedure Collect_Withs (Cunit : Node_Id);
190 -- Collect with lines for entries in the context clause of the
191 -- given compilation unit, Cunit.
193 procedure Update_Tables_From_ALI_File;
194 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
195 -- function), update tables from the ALI information, including
196 -- specifically the Compilation_Switches table.
198 function Up_To_Date_ALI_File_Exists return Boolean;
199 -- If there exists an ALI file that is up to date, then this function
200 -- initializes the tables in the ALI spec to contain information on
201 -- this file (using Scan_ALI) and returns True. If no file exists,
202 -- or the file is not up to date, then False is returned.
204 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type);
205 -- Write out the library information for one unit for which code is
206 -- generated (includes unit line and with lines).
208 procedure Write_With_Lines;
209 -- Write out with lines collected by calls to Collect_Withs
215 procedure Collect_Withs (Cunit : Node_Id) is
217 Unum : Unit_Number_Type;
220 Item := First (Context_Items (Cunit));
221 while Present (Item) loop
223 -- Ada 2005 (AI-50217): limited with_clauses do not create
226 if Nkind (Item) = N_With_Clause
227 and then not (Limited_Present (Item))
229 Unum := Get_Cunit_Unit_Number (Library_Unit (Item));
230 With_Flags (Unum) := True;
232 if Elaborate_Present (Item) then
233 Elab_Flags (Unum) := True;
236 if Elaborate_All_Present (Item) then
237 Elab_All_Flags (Unum) := True;
240 if Elaborate_All_Desirable (Cunit_Entity (Unum)) then
241 Elab_Des_Flags (Unum) := True;
249 --------------------------------
250 -- Up_To_Date_ALI_File_Exists --
251 --------------------------------
253 function Up_To_Date_ALI_File_Exists return Boolean is
254 Name : File_Name_Type;
255 Text : Text_Buffer_Ptr;
257 Sind : Source_File_Index;
260 Opt.Check_Object_Consistency := True;
261 Read_Library_Info (Name, Text);
263 -- Return if we could not find an ALI file
269 -- Return if ALI file has bad format
273 if Scan_ALI (Name, Text, False, Err => True) = No_ALI_Id then
277 -- If we have an OK ALI file, check if it is up to date
278 -- Note that we assume that the ALI read has all the entries
279 -- we have in our table, plus some additional ones (that can
280 -- come from expansion).
282 Id := First_Sdep_Entry;
283 for J in 1 .. Num_Sdep loop
284 Sind := Units.Table (Sdep_Table (J)).Source_Index;
286 while Sdep.Table (Id).Sfile /= File_Name (Sind) loop
287 if Id = Sdep.Last then
294 if Sdep.Table (Id).Stamp /= Time_Stamp (Sind) then
300 end Up_To_Date_ALI_File_Exists;
302 ---------------------------------
303 -- Update_Tables_From_ALI_File --
304 ---------------------------------
306 procedure Update_Tables_From_ALI_File is
308 -- Build Compilation_Switches table
310 Compilation_Switches.Init;
312 for J in First_Arg_Entry .. Args.Last loop
313 Compilation_Switches.Increment_Last;
314 Compilation_Switches.Table (Compilation_Switches.Last) :=
317 end Update_Tables_From_ALI_File;
319 ----------------------------
320 -- Write_Unit_Information --
321 ----------------------------
323 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type) is
324 Unode : constant Node_Id := Cunit (Unit_Num);
325 Ukind : constant Node_Kind := Nkind (Unit (Unode));
326 Uent : constant Entity_Id := Cunit_Entity (Unit_Num);
330 Write_Info_Initiate ('U');
331 Write_Info_Char (' ');
332 Write_Info_Name (Unit_Name (Unit_Num));
334 Write_Info_Name (Unit_File_Name (Unit_Num));
337 Write_Info_Str (Version_Get (Unit_Num));
339 if (Is_Subprogram (Uent)
340 or else Ekind (Uent) = E_Package
341 or else Is_Generic_Unit (Uent))
342 and then Body_Needed_For_SAL (Uent)
344 Write_Info_Str (" BN");
347 if Dynamic_Elab (Unit_Num) then
348 Write_Info_Str (" DE");
351 -- We set the Elaborate_Body indication if either an explicit pragma
352 -- was present, or if this is an instantiation. RM 12.3(20) requires
353 -- that the body be immediately elaborated after the spec. We would
354 -- normally do that anyway, but the EB we generate here ensures that
355 -- this gets done even when we use the -p gnatbind switch.
357 if Has_Pragma_Elaborate_Body (Uent)
358 or else (Ukind = N_Package_Declaration
359 and then Is_Generic_Instance (Uent)
360 and then Present (Corresponding_Body (Unit (Unode))))
362 Write_Info_Str (" EB");
365 -- Now see if we should tell the binder that an elaboration entity
366 -- is present, which must be reset to true during elaboration. We
367 -- generate the indication if the following condition is met:
369 -- If this is a spec ...
371 if (Is_Subprogram (Uent)
373 Ekind (Uent) = E_Package
375 Is_Generic_Unit (Uent))
377 -- and an elaboration entity was declared ...
379 and then Present (Elaboration_Entity (Uent))
381 -- and either the elaboration flag is required ...
384 (Elaboration_Entity_Required (Uent)
386 -- or this unit has elaboration code ...
388 or else not Has_No_Elaboration_Code (Unode)
390 -- or this unit has a separate body and this
391 -- body has elaboration code.
394 (Ekind (Uent) = E_Package
395 and then Present (Body_Entity (Uent))
397 not Has_No_Elaboration_Code
400 (Body_Entity (Uent))))))
402 Write_Info_Str (" EE");
405 if Has_No_Elaboration_Code (Unode) then
406 Write_Info_Str (" NE");
409 if Is_Preelaborated (Uent) then
410 Write_Info_Str (" PR");
413 if Is_Pure (Uent) then
414 Write_Info_Str (" PU");
417 if Has_RACW (Unit_Num) then
418 Write_Info_Str (" RA");
421 if Is_Remote_Call_Interface (Uent) then
422 Write_Info_Str (" RC");
425 if Is_Remote_Types (Uent) then
426 Write_Info_Str (" RT");
429 if Is_Shared_Passive (Uent) then
430 Write_Info_Str (" SP");
433 if Ukind = N_Subprogram_Declaration
434 or else Ukind = N_Subprogram_Body
436 Write_Info_Str (" SU");
438 elsif Ukind = N_Package_Declaration
440 Ukind = N_Package_Body
442 -- If this is a wrapper package for a subprogram instantiation,
443 -- the user view is the subprogram. Note that in this case the
444 -- ali file contains both the spec and body of the instance.
446 if Is_Wrapper_Package (Uent) then
447 Write_Info_Str (" SU");
449 Write_Info_Str (" PK");
452 elsif Ukind = N_Generic_Package_Declaration then
453 Write_Info_Str (" PK");
457 if Ukind in N_Generic_Declaration
459 (Present (Library_Unit (Unode))
461 Nkind (Unit (Library_Unit (Unode))) in N_Generic_Declaration)
463 Write_Info_Str (" GE");
466 if not Is_Internal_File_Name (Unit_File_Name (Unit_Num), True) then
467 case Identifier_Casing (Source_Index (Unit_Num)) is
468 when All_Lower_Case => Write_Info_Str (" IL");
469 when All_Upper_Case => Write_Info_Str (" IU");
473 case Keyword_Casing (Source_Index (Unit_Num)) is
474 when Mixed_Case => Write_Info_Str (" KM");
475 when All_Upper_Case => Write_Info_Str (" KU");
480 if Initialize_Scalars then
481 Write_Info_Str (" IS");
486 -- Generate with lines, first those that are directly with'ed
488 for J in With_Flags'Range loop
489 With_Flags (J) := False;
490 Elab_Flags (J) := False;
491 Elab_All_Flags (J) := False;
492 Elab_Des_Flags (J) := False;
495 Collect_Withs (Unode);
497 -- For a body, we must also check for any subunits which belong to
498 -- it and which have context clauses of their own, since these
499 -- with'ed units are part of its own elaboration dependencies.
501 if Nkind (Unit (Unode)) in N_Unit_Body then
502 for S in Units.First .. Last_Unit loop
504 -- We are only interested in subunits.
505 -- For preproc. data and def. files, Cunit is Empty, so
506 -- we need to test that first.
508 if Cunit (S) /= Empty
509 and then Nkind (Unit (Cunit (S))) = N_Subunit
511 Pnode := Library_Unit (Cunit (S));
513 -- In gnatc mode, the errors in the subunits will not
514 -- have been recorded, but the analysis of the subunit
515 -- may have failed. There is no information to add to
516 -- ALI file in this case.
522 -- Find ultimate parent of the subunit
524 while Nkind (Unit (Pnode)) = N_Subunit loop
525 Pnode := Library_Unit (Pnode);
528 -- See if it belongs to current unit, and if so, include
531 if Pnode = Unode then
532 Collect_Withs (Cunit (S));
540 -- Output linker option lines
542 for J in 1 .. Linker_Option_Lines.Last loop
544 S : constant Linker_Option_Entry :=
545 Linker_Option_Lines.Table (J);
549 if S.Unit = Unit_Num then
550 Write_Info_Initiate ('L');
551 Write_Info_Str (" """);
553 for J in 1 .. String_Length (S.Option) loop
554 C := Get_Character (Get_String_Char (S.Option, J));
556 if C in Character'Val (16#20#) .. Character'Val (16#7E#)
567 Hex : constant array (0 .. 15) of Character :=
571 Write_Info_Char ('{');
572 Write_Info_Char (Hex (Character'Pos (C) / 16));
573 Write_Info_Char (Hex (Character'Pos (C) mod 16));
574 Write_Info_Char ('}');
579 Write_Info_Char ('"');
584 end Write_Unit_Information;
586 ----------------------
587 -- Write_With_Lines --
588 ----------------------
590 procedure Write_With_Lines is
591 With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
592 Num_Withs : Int := 0;
593 Unum : Unit_Number_Type;
596 Uname : Unit_Name_Type;
597 Fname : File_Name_Type;
598 Pname : constant Unit_Name_Type :=
599 Get_Parent_Spec_Name (Unit_Name (Main_Unit));
600 Body_Fname : File_Name_Type;
604 -- Loop to build the with table. A with on the main unit itself
605 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
606 -- the main unit is a subprogram with no spec, and a subunit of
607 -- it unecessarily withs the parent.
609 for J in Units.First + 1 .. Last_Unit loop
611 -- Add element to with table if it is with'ed or if it is the
612 -- parent spec of the main unit (case of main unit is a child
613 -- unit). The latter with is not needed for semantic purposes,
614 -- but is required by the binder for elaboration purposes.
615 -- For preproc. data and def. files, there is no Unit_Name,
616 -- check for that first.
618 if Unit_Name (J) /= No_Name
619 and then (With_Flags (J) or else Unit_Name (J) = Pname)
621 Num_Withs := Num_Withs + 1;
622 With_Table (Num_Withs) := J;
626 -- Sort and output the table
628 Sort (With_Table (1 .. Num_Withs));
630 for J in 1 .. Num_Withs loop
631 Unum := With_Table (J);
632 Cunit := Units.Table (Unum).Cunit;
633 Cunite := Units.Table (Unum).Cunit_Entity;
634 Uname := Units.Table (Unum).Unit_Name;
635 Fname := Units.Table (Unum).Unit_File_Name;
637 Write_Info_Initiate ('W');
638 Write_Info_Char (' ');
639 Write_Info_Name (Uname);
641 -- Now we need to figure out the names of the files that contain
642 -- the with'ed unit. These will usually be the files for the body,
643 -- except in the case of a package that has no body.
645 if (Nkind (Unit (Cunit)) not in N_Generic_Declaration
647 Nkind (Unit (Cunit)) not in N_Generic_Renaming_Declaration)
648 or else Generic_Separately_Compiled (Cunite)
652 if Is_Spec_Name (Uname) then
655 (Get_Body_Name (Uname),
656 Subunit => False, May_Fail => True);
660 (Get_Body_Name (Uname));
662 if Body_Fname = No_File then
663 Body_Fname := Get_File_Name (Uname, Subunit => False);
664 Body_Index := Get_Unit_Index (Uname);
668 Body_Fname := Get_File_Name (Uname, Subunit => False);
669 Body_Index := Get_Unit_Index (Uname);
672 -- A package is considered to have a body if it requires
673 -- a body or if a body is present in Ada 83 mode.
675 if Body_Required (Cunit)
676 or else (Ada_Version = Ada_83
677 and then Full_Source_Name (Body_Fname) /= No_File)
679 Write_Info_Name (Body_Fname);
682 (Lib_File_Name (Body_Fname, Body_Index));
684 Write_Info_Name (Fname);
687 (Lib_File_Name (Fname, Munit_Index (Unum)));
690 if Elab_Flags (Unum) then
691 Write_Info_Str (" E");
694 if Elab_All_Flags (Unum) then
695 Write_Info_Str (" EA");
698 if Elab_Des_Flags (Unum) then
699 Write_Info_Str (" ED");
705 end Write_With_Lines;
707 -- Start of processing for Write_ALI
710 -- We never write an ALI file if the original operating mode was
711 -- syntax-only (-gnats switch used in compiler invocation line)
713 if Original_Operating_Mode = Check_Syntax then
717 -- Build sorted source dependency table. We do this right away,
718 -- because it is referenced by Up_To_Date_ALI_File_Exists.
720 for Unum in Units.First .. Last_Unit loop
721 if Cunit_Entity (Unum) = Empty
722 or else not From_With_Type (Cunit_Entity (Unum))
724 Num_Sdep := Num_Sdep + 1;
725 Sdep_Table (Num_Sdep) := Unum;
729 -- Sort the table so that the D lines are in order
731 Lib.Sort (Sdep_Table (1 .. Num_Sdep));
733 -- If we are not generating code, and there is an up to date
734 -- ali file accessible, read it, and acquire the compilation
735 -- arguments from this file.
737 if Operating_Mode /= Generate_Code then
738 if Up_To_Date_ALI_File_Exists then
739 Update_Tables_From_ALI_File;
744 -- Otherwise acquire compilation arguments and prepare to write
745 -- out a new ali file.
747 Create_Output_Library_Info;
749 -- Output version line
751 Write_Info_Initiate ('V');
752 Write_Info_Str (" """);
753 Write_Info_Str (Verbose_Library_Version);
754 Write_Info_Char ('"');
758 -- Output main program line if this is acceptable main program
760 Output_Main_Program_Line : declare
761 U : Node_Id := Unit (Units.Table (Main_Unit).Cunit);
764 procedure M_Parameters;
765 -- Output parameters for main program line
771 procedure M_Parameters is
773 if Main_Priority (Main_Unit) /= Default_Main_Priority then
774 Write_Info_Char (' ');
775 Write_Info_Nat (Main_Priority (Main_Unit));
778 if Opt.Time_Slice_Set then
779 Write_Info_Str (" T=");
780 Write_Info_Nat (Opt.Time_Slice_Value);
783 Write_Info_Str (" W=");
785 (WC_Encoding_Letters (Wide_Character_Encoding_Method));
790 -- Start of processing for Output_Main_Program_Line
793 if Nkind (U) = N_Subprogram_Body
794 or else (Nkind (U) = N_Package_Body
796 (Nkind (Original_Node (U)) = N_Function_Instantiation
798 Nkind (Original_Node (U)) =
799 N_Procedure_Instantiation))
801 -- If the unit is a subprogram instance, the entity for the
802 -- subprogram is the alias of the visible entity, which is the
803 -- related instance of the wrapper package. We retrieve the
804 -- subprogram declaration of the desired entity.
806 if Nkind (U) = N_Package_Body then
807 U := Parent (Parent (
808 Alias (Related_Instance (Defining_Unit_Name
809 (Specification (Unit (Library_Unit (Parent (U)))))))));
812 S := Specification (U);
814 if not Present (Parameter_Specifications (S)) then
815 if Nkind (S) = N_Procedure_Specification then
816 Write_Info_Initiate ('M');
817 Write_Info_Str (" P");
822 Nam : Node_Id := Defining_Unit_Name (S);
825 -- If it is a child unit, get its simple name.
827 if Nkind (Nam) = N_Defining_Program_Unit_Name then
828 Nam := Defining_Identifier (Nam);
831 if Is_Integer_Type (Etype (Nam)) then
832 Write_Info_Initiate ('M');
833 Write_Info_Str (" F");
840 end Output_Main_Program_Line;
842 -- Write command argmument ('A') lines
844 for A in 1 .. Compilation_Switches.Last loop
845 Write_Info_Initiate ('A');
846 Write_Info_Char (' ');
847 Write_Info_Str (Compilation_Switches.Table (A).all);
848 Write_Info_Terminate;
851 -- Output parameters ('P') line
853 Write_Info_Initiate ('P');
855 if Compilation_Errors then
856 Write_Info_Str (" CE");
859 if Opt.Detect_Blocking then
860 Write_Info_Str (" DB");
863 if Opt.Float_Format /= ' ' then
864 Write_Info_Str (" F");
866 if Opt.Float_Format = 'I' then
867 Write_Info_Char ('I');
869 elsif Opt.Float_Format_Long = 'D' then
870 Write_Info_Char ('D');
873 Write_Info_Char ('G');
878 and then not Is_Predefined_File_Name (Unit_File_Name (Main_Unit))
880 if Locking_Policy /= ' ' then
881 Write_Info_Str (" L");
882 Write_Info_Char (Locking_Policy);
885 if Queuing_Policy /= ' ' then
886 Write_Info_Str (" Q");
887 Write_Info_Char (Queuing_Policy);
890 if Task_Dispatching_Policy /= ' ' then
891 Write_Info_Str (" T");
892 Write_Info_Char (Task_Dispatching_Policy);
893 Write_Info_Char (' ');
898 Write_Info_Str (" NO");
901 if No_Run_Time_Mode then
902 Write_Info_Str (" NR");
905 if Normalize_Scalars then
906 Write_Info_Str (" NS");
909 if Sec_Stack_Used then
910 Write_Info_Str (" SS");
913 if Unreserve_All_Interrupts then
914 Write_Info_Str (" UA");
917 if Exception_Mechanism /= Front_End_Setjmp_Longjmp_Exceptions then
918 if Unit_Exception_Table_Present then
919 Write_Info_Str (" UX");
922 Write_Info_Str (" ZX");
927 -- Before outputting the restrictions line, update the setting of
928 -- the No_Elaboration_Code flag. Violations of this restriction
929 -- cannot be detected until after the backend has been called since
930 -- it is the backend that sets this flag. We have to check all units
931 -- for which we have generated code
933 for Unit in Units.First .. Last_Unit loop
934 if Units.Table (Unit).Generate_Code
935 or else Unit = Main_Unit
937 if not Has_No_Elaboration_Code (Cunit (Unit)) then
938 Main_Restrictions.Violated (No_Elaboration_Code) := True;
943 -- Output restrictions line
945 Write_Info_Initiate ('R');
946 Write_Info_Char (' ');
948 -- First the information for the boolean restrictions
950 for R in All_Boolean_Restrictions loop
951 if Main_Restrictions.Set (R)
952 and then not Restriction_Warnings (R)
954 Write_Info_Char ('r');
955 elsif Main_Restrictions.Violated (R) then
956 Write_Info_Char ('v');
958 Write_Info_Char ('n');
962 -- And now the information for the parameter restrictions
964 for RP in All_Parameter_Restrictions loop
965 if Main_Restrictions.Set (RP)
966 and then not Restriction_Warnings (RP)
968 Write_Info_Char ('r');
969 Write_Info_Nat (Nat (Main_Restrictions.Value (RP)));
971 Write_Info_Char ('n');
974 if not Main_Restrictions.Violated (RP)
975 or else RP not in Checked_Parameter_Restrictions
977 Write_Info_Char ('n');
979 Write_Info_Char ('v');
980 Write_Info_Nat (Nat (Main_Restrictions.Count (RP)));
982 if Main_Restrictions.Unknown (RP) then
983 Write_Info_Char ('+');
990 -- Output interrupt state lines
992 for J in Interrupt_States.First .. Interrupt_States.Last loop
993 Write_Info_Initiate ('I');
994 Write_Info_Char (' ');
995 Write_Info_Nat (Interrupt_States.Table (J).Interrupt_Number);
996 Write_Info_Char (' ');
997 Write_Info_Char (Interrupt_States.Table (J).Interrupt_State);
998 Write_Info_Char (' ');
1000 (Nat (Get_Logical_Line_Number
1001 (Interrupt_States.Table (J).Pragma_Loc)));
1005 -- Loop through file table to output information for all units for which
1006 -- we have generated code, as marked by the Generate_Code flag.
1008 for Unit in Units.First .. Last_Unit loop
1009 if Units.Table (Unit).Generate_Code
1010 or else Unit = Main_Unit
1012 Write_Info_EOL; -- blank line
1013 Write_Unit_Information (Unit);
1017 Write_Info_EOL; -- blank line
1019 -- Output external version reference lines
1021 for J in 1 .. Version_Ref.Last loop
1022 Write_Info_Initiate ('E');
1023 Write_Info_Char (' ');
1025 for K in 1 .. String_Length (Version_Ref.Table (J)) loop
1026 Write_Info_Char_Code (Get_String_Char (Version_Ref.Table (J), K));
1032 -- Prepare to output the source dependency lines
1035 Unum : Unit_Number_Type;
1036 -- Number of unit being output
1038 Sind : Source_File_Index;
1039 -- Index of corresponding source file
1042 for J in 1 .. Num_Sdep loop
1043 Unum := Sdep_Table (J);
1044 Units.Table (Unum).Dependency_Num := J;
1045 Sind := Units.Table (Unum).Source_Index;
1047 Write_Info_Initiate ('D');
1048 Write_Info_Char (' ');
1050 -- Normal case of a unit entry with a source index
1052 if Sind /= No_Source_File then
1053 Write_Info_Name (File_Name (Sind));
1054 Write_Info_Tab (25);
1055 Write_Info_Str (String (Time_Stamp (Sind)));
1056 Write_Info_Char (' ');
1057 Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
1059 -- If subunit, add unit name, omitting the %b at the end
1061 if Present (Cunit (Unum))
1062 and then Nkind (Unit (Cunit (Unum))) = N_Subunit
1064 Get_Decoded_Name_String (Unit_Name (Unum));
1065 Write_Info_Char (' ');
1066 Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
1069 -- If Source_Reference pragma used output information
1071 if Num_SRef_Pragmas (Sind) > 0 then
1072 Write_Info_Char (' ');
1074 if Num_SRef_Pragmas (Sind) = 1 then
1075 Write_Info_Nat (Int (First_Mapped_Line (Sind)));
1080 Write_Info_Char (':');
1081 Write_Info_Name (Reference_Name (Sind));
1084 -- Case where there is no source index (happens for missing
1085 -- files). In this case we write a dummy time stamp.
1088 Write_Info_Name (Unit_File_Name (Unum));
1089 Write_Info_Tab (25);
1090 Write_Info_Str (String (Dummy_Time_Stamp));
1091 Write_Info_Char (' ');
1092 Write_Info_Str (Get_Hex_String (0));
1100 Write_Info_Terminate;
1101 Close_Output_Library_Info;