1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2003 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;
45 with Sinfo; use Sinfo;
46 with Sinput; use Sinput;
47 with Stringt; use Stringt;
48 with Tbuild; use Tbuild;
49 with Uname; use Uname;
51 with System.WCh_Con; use System.WCh_Con;
53 package body Lib.Writ is
55 ----------------------------------
56 -- Add_Preprocessing_Dependency --
57 ----------------------------------
59 procedure Add_Preprocessing_Dependency (S : Source_File_Index) is
62 Units.Table (Units.Last) :=
63 (Unit_File_Name => File_Name (S),
65 Expected_Unit => No_Name,
68 Cunit_Entity => Empty,
70 Dependent_Unit => True,
71 Dynamic_Elab => False,
73 Generate_Code => False,
75 Ident_String => Empty,
80 Error_Location => No_Location);
81 end Add_Preprocessing_Dependency;
83 ------------------------------
84 -- Ensure_System_Dependency --
85 ------------------------------
87 procedure Ensure_System_Dependency is
88 System_Uname : Unit_Name_Type;
89 -- Unit name for system spec if needed for dummy entry
91 System_Fname : File_Name_Type;
92 -- File name for system spec if needed for dummy entry
94 Save_Style : constant Boolean := Style_Check;
97 -- Nothing to do if we already compiled System
99 for Unum in Units.First .. Last_Unit loop
100 if Units.Table (Unum).Source_Index = System_Source_File_Index then
105 -- If no entry for system.ads in the units table, then add a entry
106 -- to the units table for system.ads, which will be referenced when
107 -- the ali file is generated. We need this because every unit depends
108 -- on system as a result of Targparm scanning the system.ads file to
109 -- determine the target dependent parameters for the compilation.
112 Name_Buffer (1 .. 6) := "system";
113 System_Uname := Name_To_Unit_Name (Name_Enter);
114 System_Fname := File_Name (System_Source_File_Index);
116 Units.Increment_Last;
117 Units.Table (Units.Last) := (
118 Unit_File_Name => System_Fname,
119 Unit_Name => System_Uname,
120 Expected_Unit => System_Uname,
121 Source_Index => System_Source_File_Index,
123 Cunit_Entity => Empty,
125 Dependent_Unit => True,
126 Dynamic_Elab => False,
127 Fatal_Error => False,
128 Generate_Code => False,
130 Ident_String => Empty,
135 Error_Location => No_Location);
137 -- Parse system.ads so that the checksum is set right
138 -- Style checks are not applied.
140 Style_Check := False;
141 Initialize_Scanner (Units.Last, System_Source_File_Index);
142 Discard_List (Par (Configuration_Pragmas => False));
143 Style_Check := Save_Style;
144 end Ensure_System_Dependency;
150 procedure Write_ALI (Object : Boolean) is
156 Last_Unit : constant Unit_Number_Type := Units.Last;
157 -- Record unit number of last unit. We capture this in case we
158 -- have to add a dummy entry to the unit table for package System.
160 With_Flags : array (Units.First .. Last_Unit) of Boolean;
161 -- Array of flags to show which units are with'ed
163 Elab_Flags : array (Units.First .. Last_Unit) of Boolean;
164 -- Array of flags to show which units have pragma Elaborate set
166 Elab_All_Flags : array (Units.First .. Last_Unit) of Boolean;
167 -- Array of flags to show which units have pragma Elaborate All set
169 Elab_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
170 -- Array of flags to show which units have Elaborate_All_Desirable set
172 Sdep_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 2));
173 -- Sorted table of source dependencies. One extra entry in case we
174 -- have to add a dummy entry for System.
177 -- Number of active entries in Sdep_Table
179 -----------------------
180 -- Local Subprograms --
181 -----------------------
183 procedure Collect_Withs (Cunit : Node_Id);
184 -- Collect with lines for entries in the context clause of the
185 -- given compilation unit, Cunit.
187 procedure Update_Tables_From_ALI_File;
188 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
189 -- function), update tables from the ALI information, including
190 -- specifically the Compilation_Switches table.
192 function Up_To_Date_ALI_File_Exists return Boolean;
193 -- If there exists an ALI file that is up to date, then this function
194 -- initializes the tables in the ALI spec to contain information on
195 -- this file (using Scan_ALI) and returns True. If no file exists,
196 -- or the file is not up to date, then False is returned.
198 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type);
199 -- Write out the library information for one unit for which code is
200 -- generated (includes unit line and with lines).
202 procedure Write_With_Lines;
203 -- Write out with lines collected by calls to Collect_Withs
209 procedure Collect_Withs (Cunit : Node_Id) is
211 Unum : Unit_Number_Type;
214 Item := First (Context_Items (Cunit));
215 while Present (Item) loop
217 -- Ada0Y (AI-50217): limited with_clauses do not create
220 if Nkind (Item) = N_With_Clause
221 and then not (Limited_Present (Item))
223 Unum := Get_Cunit_Unit_Number (Library_Unit (Item));
224 With_Flags (Unum) := True;
226 if Elaborate_Present (Item) then
227 Elab_Flags (Unum) := True;
230 if Elaborate_All_Present (Item) then
231 Elab_All_Flags (Unum) := True;
234 if Elaborate_All_Desirable (Cunit_Entity (Unum)) then
235 Elab_Des_Flags (Unum) := True;
243 --------------------------------
244 -- Up_To_Date_ALI_File_Exists --
245 --------------------------------
247 function Up_To_Date_ALI_File_Exists return Boolean is
248 Name : File_Name_Type;
249 Text : Text_Buffer_Ptr;
251 Sind : Source_File_Index;
254 Opt.Check_Object_Consistency := True;
255 Read_Library_Info (Name, Text);
257 -- Return if we could not find an ALI file
263 -- Return if ALI file has bad format
267 if Scan_ALI (Name, Text, False, Err => True) = No_ALI_Id then
271 -- If we have an OK ALI file, check if it is up to date
272 -- Note that we assume that the ALI read has all the entries
273 -- we have in our table, plus some additional ones (that can
274 -- come from expansion).
276 Id := First_Sdep_Entry;
277 for J in 1 .. Num_Sdep loop
278 Sind := Units.Table (Sdep_Table (J)).Source_Index;
280 while Sdep.Table (Id).Sfile /= File_Name (Sind) loop
281 if Id = Sdep.Last then
288 if Sdep.Table (Id).Stamp /= Time_Stamp (Sind) then
294 end Up_To_Date_ALI_File_Exists;
296 ---------------------------------
297 -- Update_Tables_From_ALI_File --
298 ---------------------------------
300 procedure Update_Tables_From_ALI_File is
302 -- Build Compilation_Switches table
304 Compilation_Switches.Init;
306 for J in First_Arg_Entry .. Args.Last loop
307 Compilation_Switches.Increment_Last;
308 Compilation_Switches.Table (Compilation_Switches.Last) :=
311 end Update_Tables_From_ALI_File;
313 ----------------------------
314 -- Write_Unit_Information --
315 ----------------------------
317 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type) is
318 Unode : constant Node_Id := Cunit (Unit_Num);
319 Ukind : constant Node_Kind := Nkind (Unit (Unode));
320 Uent : constant Entity_Id := Cunit_Entity (Unit_Num);
324 Write_Info_Initiate ('U');
325 Write_Info_Char (' ');
326 Write_Info_Name (Unit_Name (Unit_Num));
328 Write_Info_Name (Unit_File_Name (Unit_Num));
331 Write_Info_Str (Version_Get (Unit_Num));
333 if (Is_Subprogram (Uent)
334 or else Ekind (Uent) = E_Package
335 or else Is_Generic_Unit (Uent))
336 and then Body_Needed_For_SAL (Uent)
338 Write_Info_Str (" BN");
341 if Dynamic_Elab (Unit_Num) then
342 Write_Info_Str (" DE");
345 -- We set the Elaborate_Body indication if either an explicit pragma
346 -- was present, or if this is an instantiation. RM 12.3(20) requires
347 -- that the body be immediately elaborated after the spec. We would
348 -- normally do that anyway, but the EB we generate here ensures that
349 -- this gets done even when we use the -p gnatbind switch.
351 if Has_Pragma_Elaborate_Body (Uent)
352 or else (Ukind = N_Package_Declaration
353 and then Is_Generic_Instance (Uent)
354 and then Present (Corresponding_Body (Unit (Unode))))
356 Write_Info_Str (" EB");
359 -- Now see if we should tell the binder that an elaboration entity
360 -- is present, which must be reset to true during elaboration. We
361 -- generate the indication if the following condition is met:
363 -- If this is a spec ...
365 if (Is_Subprogram (Uent)
367 Ekind (Uent) = E_Package
369 Is_Generic_Unit (Uent))
371 -- and an elaboration entity was declared ...
373 and then Present (Elaboration_Entity (Uent))
375 -- and either the elaboration flag is required ...
378 (Elaboration_Entity_Required (Uent)
380 -- or this unit has elaboration code ...
382 or else not Has_No_Elaboration_Code (Unode)
384 -- or this unit has a separate body and this
385 -- body has elaboration code.
388 (Ekind (Uent) = E_Package
389 and then Present (Body_Entity (Uent))
391 not Has_No_Elaboration_Code
394 (Body_Entity (Uent))))))
396 Write_Info_Str (" EE");
399 if Has_No_Elaboration_Code (Unode) then
400 Write_Info_Str (" NE");
403 if Is_Preelaborated (Uent) then
404 Write_Info_Str (" PR");
407 if Is_Pure (Uent) then
408 Write_Info_Str (" PU");
411 if Has_RACW (Unit_Num) then
412 Write_Info_Str (" RA");
415 if Is_Remote_Call_Interface (Uent) then
416 Write_Info_Str (" RC");
419 if Is_Remote_Types (Uent) then
420 Write_Info_Str (" RT");
423 if Is_Shared_Passive (Uent) then
424 Write_Info_Str (" SP");
427 if Ukind = N_Subprogram_Declaration
428 or else Ukind = N_Subprogram_Body
430 Write_Info_Str (" SU");
432 elsif Ukind = N_Package_Declaration
434 Ukind = N_Package_Body
436 -- If this is a wrapper package for a subprogram instantiation,
437 -- the user view is the subprogram. Note that in this case the
438 -- ali file contains both the spec and body of the instance.
440 if Is_Wrapper_Package (Uent) then
441 Write_Info_Str (" SU");
443 Write_Info_Str (" PK");
446 elsif Ukind = N_Generic_Package_Declaration then
447 Write_Info_Str (" PK");
451 if Ukind in N_Generic_Declaration
453 (Present (Library_Unit (Unode))
455 Nkind (Unit (Library_Unit (Unode))) in N_Generic_Declaration)
457 Write_Info_Str (" GE");
460 if not Is_Internal_File_Name (Unit_File_Name (Unit_Num), True) then
461 case Identifier_Casing (Source_Index (Unit_Num)) is
462 when All_Lower_Case => Write_Info_Str (" IL");
463 when All_Upper_Case => Write_Info_Str (" IU");
467 case Keyword_Casing (Source_Index (Unit_Num)) is
468 when Mixed_Case => Write_Info_Str (" KM");
469 when All_Upper_Case => Write_Info_Str (" KU");
474 if Initialize_Scalars then
475 Write_Info_Str (" IS");
480 -- Generate with lines, first those that are directly with'ed
482 for J in With_Flags'Range loop
483 With_Flags (J) := False;
484 Elab_Flags (J) := False;
485 Elab_All_Flags (J) := False;
486 Elab_Des_Flags (J) := False;
489 Collect_Withs (Unode);
491 -- For a body, we must also check for any subunits which belong to
492 -- it and which have context clauses of their own, since these
493 -- with'ed units are part of its own elaboration dependencies.
495 if Nkind (Unit (Unode)) in N_Unit_Body then
496 for S in Units.First .. Last_Unit loop
498 -- We are only interested in subunits.
499 -- For preproc. data and def. files, Cunit is Empty, so
500 -- we need to test that first.
502 if Cunit (S) /= Empty
503 and then Nkind (Unit (Cunit (S))) = N_Subunit
505 Pnode := Library_Unit (Cunit (S));
507 -- In gnatc mode, the errors in the subunits will not
508 -- have been recorded, but the analysis of the subunit
509 -- may have failed. There is no information to add to
510 -- ALI file in this case.
516 -- Find ultimate parent of the subunit
518 while Nkind (Unit (Pnode)) = N_Subunit loop
519 Pnode := Library_Unit (Pnode);
522 -- See if it belongs to current unit, and if so, include
525 if Pnode = Unode then
526 Collect_Withs (Cunit (S));
534 -- Output linker option lines
536 for J in 1 .. Linker_Option_Lines.Last loop
538 S : constant Linker_Option_Entry :=
539 Linker_Option_Lines.Table (J);
543 if S.Unit = Unit_Num then
544 Write_Info_Initiate ('L');
545 Write_Info_Str (" """);
547 for J in 1 .. String_Length (S.Option) loop
548 C := Get_Character (Get_String_Char (S.Option, J));
550 if C in Character'Val (16#20#) .. Character'Val (16#7E#)
561 Hex : constant array (0 .. 15) of Character :=
565 Write_Info_Char ('{');
566 Write_Info_Char (Hex (Character'Pos (C) / 16));
567 Write_Info_Char (Hex (Character'Pos (C) mod 16));
568 Write_Info_Char ('}');
573 Write_Info_Char ('"');
578 end Write_Unit_Information;
580 ----------------------
581 -- Write_With_Lines --
582 ----------------------
584 procedure Write_With_Lines is
585 With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
586 Num_Withs : Int := 0;
587 Unum : Unit_Number_Type;
590 Uname : Unit_Name_Type;
591 Fname : File_Name_Type;
592 Pname : constant Unit_Name_Type :=
593 Get_Parent_Spec_Name (Unit_Name (Main_Unit));
594 Body_Fname : File_Name_Type;
597 -- Loop to build the with table. A with on the main unit itself
598 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
599 -- the main unit is a subprogram with no spec, and a subunit of
600 -- it unecessarily withs the parent.
602 for J in Units.First + 1 .. Last_Unit loop
604 -- Add element to with table if it is with'ed or if it is the
605 -- parent spec of the main unit (case of main unit is a child
606 -- unit). The latter with is not needed for semantic purposes,
607 -- but is required by the binder for elaboration purposes.
608 -- For preproc. data and def. files, there is no Unit_Name,
609 -- check for that first.
611 if Unit_Name (J) /= No_Name
612 and then (With_Flags (J) or else Unit_Name (J) = Pname)
613 and then Units.Table (J).Dependent_Unit
615 Num_Withs := Num_Withs + 1;
616 With_Table (Num_Withs) := J;
620 -- Sort and output the table
622 Sort (With_Table (1 .. Num_Withs));
624 for J in 1 .. Num_Withs loop
625 Unum := With_Table (J);
626 Cunit := Units.Table (Unum).Cunit;
627 Cunite := Units.Table (Unum).Cunit_Entity;
628 Uname := Units.Table (Unum).Unit_Name;
629 Fname := Units.Table (Unum).Unit_File_Name;
631 Write_Info_Initiate ('W');
632 Write_Info_Char (' ');
633 Write_Info_Name (Uname);
635 -- Now we need to figure out the names of the files that contain
636 -- the with'ed unit. These will usually be the files for the body,
637 -- except in the case of a package that has no body.
639 if (Nkind (Unit (Cunit)) not in N_Generic_Declaration
641 Nkind (Unit (Cunit)) not in N_Generic_Renaming_Declaration)
642 or else Generic_Separately_Compiled (Cunite)
646 if Is_Spec_Name (Uname) then
648 Get_File_Name (Get_Body_Name (Uname), Subunit => False);
650 Body_Fname := Get_File_Name (Uname, Subunit => False);
653 -- A package is considered to have a body if it requires
654 -- a body or if a body is present in Ada 83 mode.
656 if Body_Required (Cunit)
658 and then Full_Source_Name (Body_Fname) /= No_File)
660 Write_Info_Name (Body_Fname);
662 Write_Info_Name (Lib_File_Name (Body_Fname));
664 Write_Info_Name (Fname);
666 Write_Info_Name (Lib_File_Name (Fname));
669 if Elab_Flags (Unum) then
670 Write_Info_Str (" E");
673 if Elab_All_Flags (Unum) then
674 Write_Info_Str (" EA");
677 if Elab_Des_Flags (Unum) then
678 Write_Info_Str (" ED");
684 end Write_With_Lines;
686 -- Start of processing for Writ_ALI
689 -- We never write an ALI file if the original operating mode was
690 -- syntax-only (-gnats switch used in compiler invocation line)
692 if Original_Operating_Mode = Check_Syntax then
696 -- Build sorted source dependency table. We do this right away,
697 -- because it is referenced by Up_To_Date_ALI_File_Exists.
699 for Unum in Units.First .. Last_Unit loop
700 if Cunit_Entity (Unum) = Empty
701 or else not From_With_Type (Cunit_Entity (Unum))
703 Num_Sdep := Num_Sdep + 1;
704 Sdep_Table (Num_Sdep) := Unum;
708 -- Sort the table so that the D lines are in order
710 Lib.Sort (Sdep_Table (1 .. Num_Sdep));
712 -- If we are not generating code, and there is an up to date
713 -- ali file accessible, read it, and acquire the compilation
714 -- arguments from this file.
716 if Operating_Mode /= Generate_Code then
717 if Up_To_Date_ALI_File_Exists then
718 Update_Tables_From_ALI_File;
723 -- Otherwise acquire compilation arguments and prepare to write
724 -- out a new ali file.
726 Create_Output_Library_Info;
728 -- Output version line
730 Write_Info_Initiate ('V');
731 Write_Info_Str (" """);
732 Write_Info_Str (Verbose_Library_Version);
733 Write_Info_Char ('"');
737 -- Output main program line if this is acceptable main program
739 Output_Main_Program_Line : declare
740 U : Node_Id := Unit (Units.Table (Main_Unit).Cunit);
743 procedure M_Parameters;
744 -- Output parameters for main program line
750 procedure M_Parameters is
752 if Main_Priority (Main_Unit) /= Default_Main_Priority then
753 Write_Info_Char (' ');
754 Write_Info_Nat (Main_Priority (Main_Unit));
757 if Opt.Time_Slice_Set then
758 Write_Info_Str (" T=");
759 Write_Info_Nat (Opt.Time_Slice_Value);
762 Write_Info_Str (" W=");
764 (WC_Encoding_Letters (Wide_Character_Encoding_Method));
769 -- Start of processing for Output_Main_Program_Line
772 if Nkind (U) = N_Subprogram_Body
773 or else (Nkind (U) = N_Package_Body
775 (Nkind (Original_Node (U)) = N_Function_Instantiation
777 Nkind (Original_Node (U)) =
778 N_Procedure_Instantiation))
780 -- If the unit is a subprogram instance, the entity for the
781 -- subprogram is the alias of the visible entity, which is the
782 -- related instance of the wrapper package. We retrieve the
783 -- subprogram declaration of the desired entity.
785 if Nkind (U) = N_Package_Body then
786 U := Parent (Parent (
787 Alias (Related_Instance (Defining_Unit_Name
788 (Specification (Unit (Library_Unit (Parent (U)))))))));
791 S := Specification (U);
793 if not Present (Parameter_Specifications (S)) then
794 if Nkind (S) = N_Procedure_Specification then
795 Write_Info_Initiate ('M');
796 Write_Info_Str (" P");
801 Nam : Node_Id := Defining_Unit_Name (S);
804 -- If it is a child unit, get its simple name.
806 if Nkind (Nam) = N_Defining_Program_Unit_Name then
807 Nam := Defining_Identifier (Nam);
810 if Is_Integer_Type (Etype (Nam)) then
811 Write_Info_Initiate ('M');
812 Write_Info_Str (" F");
819 end Output_Main_Program_Line;
821 -- Write command argmument ('A') lines
823 for A in 1 .. Compilation_Switches.Last loop
824 Write_Info_Initiate ('A');
825 Write_Info_Char (' ');
826 Write_Info_Str (Compilation_Switches.Table (A).all);
827 Write_Info_Terminate;
830 -- Output parameters ('P') line
832 Write_Info_Initiate ('P');
834 if Compilation_Errors then
835 Write_Info_Str (" CE");
838 if Opt.Float_Format /= ' ' then
839 Write_Info_Str (" F");
841 if Opt.Float_Format = 'I' then
842 Write_Info_Char ('I');
844 elsif Opt.Float_Format_Long = 'D' then
845 Write_Info_Char ('D');
848 Write_Info_Char ('G');
853 and then not Is_Predefined_File_Name (Unit_File_Name (Main_Unit))
855 if Locking_Policy /= ' ' then
856 Write_Info_Str (" L");
857 Write_Info_Char (Locking_Policy);
860 if Queuing_Policy /= ' ' then
861 Write_Info_Str (" Q");
862 Write_Info_Char (Queuing_Policy);
865 if Task_Dispatching_Policy /= ' ' then
866 Write_Info_Str (" T");
867 Write_Info_Char (Task_Dispatching_Policy);
868 Write_Info_Char (' ');
873 Write_Info_Str (" NO");
876 if No_Run_Time_Mode then
877 Write_Info_Str (" NR");
880 if Normalize_Scalars then
881 Write_Info_Str (" NS");
884 if Unreserve_All_Interrupts then
885 Write_Info_Str (" UA");
888 if Exception_Mechanism /= Front_End_Setjmp_Longjmp_Exceptions then
889 if Unit_Exception_Table_Present then
890 Write_Info_Str (" UX");
893 Write_Info_Str (" ZX");
898 -- Before outputting the restrictions line, update the setting of
899 -- the No_Elaboration_Code flag. Violations of this restriction
900 -- cannot be detected until after the backend has been called since
901 -- it is the backend that sets this flag. We have to check all units
902 -- for which we have generated code
904 for Unit in Units.First .. Last_Unit loop
905 if Units.Table (Unit).Generate_Code
906 or else Unit = Main_Unit
908 if not Has_No_Elaboration_Code (Cunit (Unit)) then
909 Violations (No_ELaboration_Code) := True;
914 -- Output restrictions line
916 Write_Info_Initiate ('R');
917 Write_Info_Char (' ');
919 for J in All_Restrictions loop
920 if Main_Restrictions (J) then
921 Write_Info_Char ('r');
922 elsif Violations (J) then
923 Write_Info_Char ('v');
925 Write_Info_Char ('n');
931 -- Output interrupt state lines
933 for J in Interrupt_States.First .. Interrupt_States.Last loop
934 Write_Info_Initiate ('I');
935 Write_Info_Char (' ');
936 Write_Info_Nat (Interrupt_States.Table (J).Interrupt_Number);
937 Write_Info_Char (' ');
938 Write_Info_Char (Interrupt_States.Table (J).Interrupt_State);
939 Write_Info_Char (' ');
941 (Nat (Get_Logical_Line_Number
942 (Interrupt_States.Table (J).Pragma_Loc)));
946 -- Loop through file table to output information for all units for which
947 -- we have generated code, as marked by the Generate_Code flag.
949 for Unit in Units.First .. Last_Unit loop
950 if Units.Table (Unit).Generate_Code
951 or else Unit = Main_Unit
953 Write_Info_EOL; -- blank line
954 Write_Unit_Information (Unit);
958 Write_Info_EOL; -- blank line
960 -- Output external version reference lines
962 for J in 1 .. Version_Ref.Last loop
963 Write_Info_Initiate ('E');
964 Write_Info_Char (' ');
966 for K in 1 .. String_Length (Version_Ref.Table (J)) loop
967 Write_Info_Char_Code (Get_String_Char (Version_Ref.Table (J), K));
973 -- Prepare to output the source dependency lines
976 Unum : Unit_Number_Type;
977 -- Number of unit being output
979 Sind : Source_File_Index;
980 -- Index of corresponding source file
983 for J in 1 .. Num_Sdep loop
984 Unum := Sdep_Table (J);
985 Units.Table (Unum).Dependency_Num := J;
986 Sind := Units.Table (Unum).Source_Index;
988 Write_Info_Initiate ('D');
989 Write_Info_Char (' ');
991 -- Normal case of a dependent unit entry with a source index
993 if Sind /= No_Source_File
994 and then Units.Table (Unum).Dependent_Unit
996 Write_Info_Name (File_Name (Sind));
998 Write_Info_Str (String (Time_Stamp (Sind)));
999 Write_Info_Char (' ');
1000 Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
1002 -- If subunit, add unit name, omitting the %b at the end
1004 if Present (Cunit (Unum))
1005 and then Nkind (Unit (Cunit (Unum))) = N_Subunit
1007 Get_Decoded_Name_String (Unit_Name (Unum));
1008 Write_Info_Char (' ');
1009 Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
1012 -- If Source_Reference pragma used output information
1014 if Num_SRef_Pragmas (Sind) > 0 then
1015 Write_Info_Char (' ');
1017 if Num_SRef_Pragmas (Sind) = 1 then
1018 Write_Info_Nat (Int (First_Mapped_Line (Sind)));
1023 Write_Info_Char (':');
1024 Write_Info_Name (Reference_Name (Sind));
1027 -- Case where there is no source index (happens for missing files)
1028 -- Also come here for non-dependent units.
1031 Write_Info_Name (Unit_File_Name (Unum));
1032 Write_Info_Tab (25);
1033 Write_Info_Str (String (Dummy_Time_Stamp));
1034 Write_Info_Char (' ');
1035 Write_Info_Str (Get_Hex_String (0));
1043 Write_Info_Terminate;
1044 Close_Output_Library_Info;