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
95 -- Nothing to do if we already compiled System
97 for Unum in Units.First .. Last_Unit loop
98 if Units.Table (Unum).Source_Index = System_Source_File_Index then
103 -- If no entry for system.ads in the units table, then add a entry
104 -- to the units table for system.ads, which will be referenced when
105 -- the ali file is generated. We need this because every unit depends
106 -- on system as a result of Targparm scanning the system.ads file to
107 -- determine the target dependent parameters for the compilation.
110 Name_Buffer (1 .. 6) := "system";
111 System_Uname := Name_To_Unit_Name (Name_Enter);
112 System_Fname := File_Name (System_Source_File_Index);
114 Units.Increment_Last;
115 Units.Table (Units.Last) := (
116 Unit_File_Name => System_Fname,
117 Unit_Name => System_Uname,
118 Expected_Unit => System_Uname,
119 Source_Index => System_Source_File_Index,
121 Cunit_Entity => Empty,
123 Dependent_Unit => True,
124 Dynamic_Elab => False,
125 Fatal_Error => False,
126 Generate_Code => False,
128 Ident_String => Empty,
133 Error_Location => No_Location);
135 -- Parse system.ads so that the checksum is set right
137 Initialize_Scanner (Units.Last, System_Source_File_Index);
138 Discard_List (Par (Configuration_Pragmas => False));
139 end Ensure_System_Dependency;
145 procedure Write_ALI (Object : Boolean) is
151 Last_Unit : constant Unit_Number_Type := Units.Last;
152 -- Record unit number of last unit. We capture this in case we
153 -- have to add a dummy entry to the unit table for package System.
155 With_Flags : array (Units.First .. Last_Unit) of Boolean;
156 -- Array of flags to show which units are with'ed
158 Elab_Flags : array (Units.First .. Last_Unit) of Boolean;
159 -- Array of flags to show which units have pragma Elaborate set
161 Elab_All_Flags : array (Units.First .. Last_Unit) of Boolean;
162 -- Array of flags to show which units have pragma Elaborate All set
164 Elab_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
165 -- Array of flags to show which units have Elaborate_All_Desirable set
167 Sdep_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 2));
168 -- Sorted table of source dependencies. One extra entry in case we
169 -- have to add a dummy entry for System.
172 -- Number of active entries in Sdep_Table
174 -----------------------
175 -- Local Subprograms --
176 -----------------------
178 procedure Collect_Withs (Cunit : Node_Id);
179 -- Collect with lines for entries in the context clause of the
180 -- given compilation unit, Cunit.
182 procedure Update_Tables_From_ALI_File;
183 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
184 -- function), update tables from the ALI information, including
185 -- specifically the Compilation_Switches table.
187 function Up_To_Date_ALI_File_Exists return Boolean;
188 -- If there exists an ALI file that is up to date, then this function
189 -- initializes the tables in the ALI spec to contain information on
190 -- this file (using Scan_ALI) and returns True. If no file exists,
191 -- or the file is not up to date, then False is returned.
193 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type);
194 -- Write out the library information for one unit for which code is
195 -- generated (includes unit line and with lines).
197 procedure Write_With_Lines;
198 -- Write out with lines collected by calls to Collect_Withs
204 procedure Collect_Withs (Cunit : Node_Id) is
206 Unum : Unit_Number_Type;
209 Item := First (Context_Items (Cunit));
210 while Present (Item) loop
212 -- limited_with_clauses do not create dependencies.
214 if Nkind (Item) = N_With_Clause
215 and then not (Limited_Present (Item))
217 Unum := Get_Cunit_Unit_Number (Library_Unit (Item));
218 With_Flags (Unum) := True;
220 if Elaborate_Present (Item) then
221 Elab_Flags (Unum) := True;
224 if Elaborate_All_Present (Item) then
225 Elab_All_Flags (Unum) := True;
228 if Elaborate_All_Desirable (Cunit_Entity (Unum)) then
229 Elab_Des_Flags (Unum) := True;
237 --------------------------------
238 -- Up_To_Date_ALI_File_Exists --
239 --------------------------------
241 function Up_To_Date_ALI_File_Exists return Boolean is
242 Name : File_Name_Type;
243 Text : Text_Buffer_Ptr;
245 Sind : Source_File_Index;
248 Opt.Check_Object_Consistency := True;
249 Read_Library_Info (Name, Text);
251 -- Return if we could not find an ALI file
257 -- Return if ALI file has bad format
261 if Scan_ALI (Name, Text, False, Err => True) = No_ALI_Id then
265 -- If we have an OK ALI file, check if it is up to date
266 -- Note that we assume that the ALI read has all the entries
267 -- we have in our table, plus some additional ones (that can
268 -- come from expansion).
270 Id := First_Sdep_Entry;
271 for J in 1 .. Num_Sdep loop
272 Sind := Units.Table (Sdep_Table (J)).Source_Index;
274 while Sdep.Table (Id).Sfile /= File_Name (Sind) loop
275 if Id = Sdep.Last then
282 if Sdep.Table (Id).Stamp /= Time_Stamp (Sind) then
288 end Up_To_Date_ALI_File_Exists;
290 ---------------------------------
291 -- Update_Tables_From_ALI_File --
292 ---------------------------------
294 procedure Update_Tables_From_ALI_File is
296 -- Build Compilation_Switches table
298 Compilation_Switches.Init;
300 for J in First_Arg_Entry .. Args.Last loop
301 Compilation_Switches.Increment_Last;
302 Compilation_Switches.Table (Compilation_Switches.Last) :=
305 end Update_Tables_From_ALI_File;
307 ----------------------------
308 -- Write_Unit_Information --
309 ----------------------------
311 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type) is
312 Unode : constant Node_Id := Cunit (Unit_Num);
313 Ukind : constant Node_Kind := Nkind (Unit (Unode));
314 Uent : constant Entity_Id := Cunit_Entity (Unit_Num);
318 Write_Info_Initiate ('U');
319 Write_Info_Char (' ');
320 Write_Info_Name (Unit_Name (Unit_Num));
322 Write_Info_Name (Unit_File_Name (Unit_Num));
325 Write_Info_Str (Version_Get (Unit_Num));
327 if (Is_Subprogram (Uent)
328 or else Ekind (Uent) = E_Package
329 or else Is_Generic_Unit (Uent))
330 and then Body_Needed_For_SAL (Uent)
332 Write_Info_Str (" BN");
335 if Dynamic_Elab (Unit_Num) then
336 Write_Info_Str (" DE");
339 -- We set the Elaborate_Body indication if either an explicit pragma
340 -- was present, or if this is an instantiation. RM 12.3(20) requires
341 -- that the body be immediately elaborated after the spec. We would
342 -- normally do that anyway, but the EB we generate here ensures that
343 -- this gets done even when we use the -p gnatbind switch.
345 if Has_Pragma_Elaborate_Body (Uent)
346 or else (Ukind = N_Package_Declaration
347 and then Is_Generic_Instance (Uent)
348 and then Present (Corresponding_Body (Unit (Unode))))
350 Write_Info_Str (" EB");
353 -- Now see if we should tell the binder that an elaboration entity
354 -- is present, which must be reset to true during elaboration. We
355 -- generate the indication if the following condition is met:
357 -- If this is a spec ...
359 if (Is_Subprogram (Uent)
361 Ekind (Uent) = E_Package
363 Is_Generic_Unit (Uent))
365 -- and an elaboration entity was declared ...
367 and then Present (Elaboration_Entity (Uent))
369 -- and either the elaboration flag is required ...
372 (Elaboration_Entity_Required (Uent)
374 -- or this unit has elaboration code ...
376 or else not Has_No_Elaboration_Code (Unode)
378 -- or this unit has a separate body and this
379 -- body has elaboration code.
382 (Ekind (Uent) = E_Package
383 and then Present (Body_Entity (Uent))
385 not Has_No_Elaboration_Code
388 (Body_Entity (Uent))))))
390 Write_Info_Str (" EE");
393 if Has_No_Elaboration_Code (Unode) then
394 Write_Info_Str (" NE");
397 if Is_Preelaborated (Uent) then
398 Write_Info_Str (" PR");
401 if Is_Pure (Uent) then
402 Write_Info_Str (" PU");
405 if Has_RACW (Unit_Num) then
406 Write_Info_Str (" RA");
409 if Is_Remote_Call_Interface (Uent) then
410 Write_Info_Str (" RC");
413 if Is_Remote_Types (Uent) then
414 Write_Info_Str (" RT");
417 if Is_Shared_Passive (Uent) then
418 Write_Info_Str (" SP");
421 if Ukind = N_Subprogram_Declaration
422 or else Ukind = N_Subprogram_Body
424 Write_Info_Str (" SU");
426 elsif Ukind = N_Package_Declaration
428 Ukind = N_Package_Body
430 -- If this is a wrapper package for a subprogram instantiation,
431 -- the user view is the subprogram. Note that in this case the
432 -- ali file contains both the spec and body of the instance.
434 if Is_Wrapper_Package (Uent) then
435 Write_Info_Str (" SU");
437 Write_Info_Str (" PK");
440 elsif Ukind = N_Generic_Package_Declaration then
441 Write_Info_Str (" PK");
445 if Ukind in N_Generic_Declaration
447 (Present (Library_Unit (Unode))
449 Nkind (Unit (Library_Unit (Unode))) in N_Generic_Declaration)
451 Write_Info_Str (" GE");
454 if not Is_Internal_File_Name (Unit_File_Name (Unit_Num), True) then
455 case Identifier_Casing (Source_Index (Unit_Num)) is
456 when All_Lower_Case => Write_Info_Str (" IL");
457 when All_Upper_Case => Write_Info_Str (" IU");
461 case Keyword_Casing (Source_Index (Unit_Num)) is
462 when Mixed_Case => Write_Info_Str (" KM");
463 when All_Upper_Case => Write_Info_Str (" KU");
468 if Initialize_Scalars then
469 Write_Info_Str (" IS");
474 -- Generate with lines, first those that are directly with'ed
476 for J in With_Flags'Range loop
477 With_Flags (J) := False;
478 Elab_Flags (J) := False;
479 Elab_All_Flags (J) := False;
480 Elab_Des_Flags (J) := False;
483 Collect_Withs (Unode);
485 -- For a body, we must also check for any subunits which belong to
486 -- it and which have context clauses of their own, since these
487 -- with'ed units are part of its own elaboration dependencies.
489 if Nkind (Unit (Unode)) in N_Unit_Body then
490 for S in Units.First .. Last_Unit loop
492 -- We are only interested in subunits.
493 -- For preproc. data and def. files, Cunit is Empty, so
494 -- we need to test that first.
496 if Cunit (S) /= Empty
497 and then Nkind (Unit (Cunit (S))) = N_Subunit
499 Pnode := Library_Unit (Cunit (S));
501 -- In gnatc mode, the errors in the subunits will not
502 -- have been recorded, but the analysis of the subunit
503 -- may have failed. There is no information to add to
504 -- ALI file in this case.
510 -- Find ultimate parent of the subunit
512 while Nkind (Unit (Pnode)) = N_Subunit loop
513 Pnode := Library_Unit (Pnode);
516 -- See if it belongs to current unit, and if so, include
519 if Pnode = Unode then
520 Collect_Withs (Cunit (S));
528 -- Output linker option lines
530 for J in 1 .. Linker_Option_Lines.Last loop
532 S : constant Linker_Option_Entry :=
533 Linker_Option_Lines.Table (J);
537 if S.Unit = Unit_Num then
538 Write_Info_Initiate ('L');
539 Write_Info_Str (" """);
541 for J in 1 .. String_Length (S.Option) loop
542 C := Get_Character (Get_String_Char (S.Option, J));
544 if C in Character'Val (16#20#) .. Character'Val (16#7E#)
555 Hex : constant array (0 .. 15) of Character :=
559 Write_Info_Char ('{');
560 Write_Info_Char (Hex (Character'Pos (C) / 16));
561 Write_Info_Char (Hex (Character'Pos (C) mod 16));
562 Write_Info_Char ('}');
567 Write_Info_Char ('"');
572 end Write_Unit_Information;
574 ----------------------
575 -- Write_With_Lines --
576 ----------------------
578 procedure Write_With_Lines is
579 With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
580 Num_Withs : Int := 0;
581 Unum : Unit_Number_Type;
584 Uname : Unit_Name_Type;
585 Fname : File_Name_Type;
586 Pname : constant Unit_Name_Type :=
587 Get_Parent_Spec_Name (Unit_Name (Main_Unit));
588 Body_Fname : File_Name_Type;
591 -- Loop to build the with table. A with on the main unit itself
592 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
593 -- the main unit is a subprogram with no spec, and a subunit of
594 -- it unecessarily withs the parent.
596 for J in Units.First + 1 .. Last_Unit loop
598 -- Add element to with table if it is with'ed or if it is the
599 -- parent spec of the main unit (case of main unit is a child
600 -- unit). The latter with is not needed for semantic purposes,
601 -- but is required by the binder for elaboration purposes.
602 -- For preproc. data and def. files, there is no Unit_Name,
603 -- check for that first.
605 if Unit_Name (J) /= No_Name
606 and then (With_Flags (J) or else Unit_Name (J) = Pname)
607 and then Units.Table (J).Dependent_Unit
609 Num_Withs := Num_Withs + 1;
610 With_Table (Num_Withs) := J;
614 -- Sort and output the table
616 Sort (With_Table (1 .. Num_Withs));
618 for J in 1 .. Num_Withs loop
619 Unum := With_Table (J);
620 Cunit := Units.Table (Unum).Cunit;
621 Cunite := Units.Table (Unum).Cunit_Entity;
622 Uname := Units.Table (Unum).Unit_Name;
623 Fname := Units.Table (Unum).Unit_File_Name;
625 Write_Info_Initiate ('W');
626 Write_Info_Char (' ');
627 Write_Info_Name (Uname);
629 -- Now we need to figure out the names of the files that contain
630 -- the with'ed unit. These will usually be the files for the body,
631 -- except in the case of a package that has no body.
633 if (Nkind (Unit (Cunit)) not in N_Generic_Declaration
635 Nkind (Unit (Cunit)) not in N_Generic_Renaming_Declaration)
636 or else Generic_Separately_Compiled (Cunite)
640 if Is_Spec_Name (Uname) then
642 Get_File_Name (Get_Body_Name (Uname), Subunit => False);
644 Body_Fname := Get_File_Name (Uname, Subunit => False);
647 -- A package is considered to have a body if it requires
648 -- a body or if a body is present in Ada 83 mode.
650 if Body_Required (Cunit)
652 and then Full_Source_Name (Body_Fname) /= No_File)
654 Write_Info_Name (Body_Fname);
656 Write_Info_Name (Lib_File_Name (Body_Fname));
658 Write_Info_Name (Fname);
660 Write_Info_Name (Lib_File_Name (Fname));
663 if Elab_Flags (Unum) then
664 Write_Info_Str (" E");
667 if Elab_All_Flags (Unum) then
668 Write_Info_Str (" EA");
671 if Elab_Des_Flags (Unum) then
672 Write_Info_Str (" ED");
678 end Write_With_Lines;
680 -- Start of processing for Writ_ALI
683 -- Build sorted source dependency table. We do this right away,
684 -- because it is referenced by Up_To_Date_ALI_File_Exists.
686 for Unum in Units.First .. Last_Unit loop
687 if Cunit_Entity (Unum) = Empty
688 or else not From_With_Type (Cunit_Entity (Unum))
690 Num_Sdep := Num_Sdep + 1;
691 Sdep_Table (Num_Sdep) := Unum;
695 -- Sort the table so that the D lines are in order
697 Lib.Sort (Sdep_Table (1 .. Num_Sdep));
699 -- If we are not generating code, and there is an up to date
700 -- ali file accessible, read it, and acquire the compilation
701 -- arguments from this file.
703 if Operating_Mode /= Generate_Code then
704 if Up_To_Date_ALI_File_Exists then
705 Update_Tables_From_ALI_File;
710 -- Otherwise acquire compilation arguments and prepare to write
711 -- out a new ali file.
713 Create_Output_Library_Info;
715 -- Output version line
717 Write_Info_Initiate ('V');
718 Write_Info_Str (" """);
719 Write_Info_Str (Library_Version);
720 Write_Info_Char ('"');
724 -- Output main program line if this is acceptable main program
726 Output_Main_Program_Line : declare
727 U : Node_Id := Unit (Units.Table (Main_Unit).Cunit);
730 procedure M_Parameters;
731 -- Output parameters for main program line
737 procedure M_Parameters is
739 if Main_Priority (Main_Unit) /= Default_Main_Priority then
740 Write_Info_Char (' ');
741 Write_Info_Nat (Main_Priority (Main_Unit));
744 if Opt.Time_Slice_Set then
745 Write_Info_Str (" T=");
746 Write_Info_Nat (Opt.Time_Slice_Value);
749 Write_Info_Str (" W=");
751 (WC_Encoding_Letters (Wide_Character_Encoding_Method));
756 -- Start of processing for Output_Main_Program_Line
759 if Nkind (U) = N_Subprogram_Body
760 or else (Nkind (U) = N_Package_Body
762 (Nkind (Original_Node (U)) = N_Function_Instantiation
764 Nkind (Original_Node (U)) =
765 N_Procedure_Instantiation))
767 -- If the unit is a subprogram instance, the entity for the
768 -- subprogram is the alias of the visible entity, which is the
769 -- related instance of the wrapper package. We retrieve the
770 -- subprogram declaration of the desired entity.
772 if Nkind (U) = N_Package_Body then
773 U := Parent (Parent (
774 Alias (Related_Instance (Defining_Unit_Name
775 (Specification (Unit (Library_Unit (Parent (U)))))))));
778 S := Specification (U);
780 if not Present (Parameter_Specifications (S)) then
781 if Nkind (S) = N_Procedure_Specification then
782 Write_Info_Initiate ('M');
783 Write_Info_Str (" P");
788 Nam : Node_Id := Defining_Unit_Name (S);
791 -- If it is a child unit, get its simple name.
793 if Nkind (Nam) = N_Defining_Program_Unit_Name then
794 Nam := Defining_Identifier (Nam);
797 if Is_Integer_Type (Etype (Nam)) then
798 Write_Info_Initiate ('M');
799 Write_Info_Str (" F");
806 end Output_Main_Program_Line;
808 -- Write command argmument ('A') lines
810 for A in 1 .. Compilation_Switches.Last loop
811 Write_Info_Initiate ('A');
812 Write_Info_Char (' ');
813 Write_Info_Str (Compilation_Switches.Table (A).all);
814 Write_Info_Terminate;
817 -- Output parameters ('P') line
819 Write_Info_Initiate ('P');
821 if Compilation_Errors then
822 Write_Info_Str (" CE");
825 if Opt.Float_Format /= ' ' then
826 Write_Info_Str (" F");
828 if Opt.Float_Format = 'I' then
829 Write_Info_Char ('I');
831 elsif Opt.Float_Format_Long = 'D' then
832 Write_Info_Char ('D');
835 Write_Info_Char ('G');
840 and then not Is_Predefined_File_Name (Unit_File_Name (Main_Unit))
842 if Locking_Policy /= ' ' then
843 Write_Info_Str (" L");
844 Write_Info_Char (Locking_Policy);
847 if Queuing_Policy /= ' ' then
848 Write_Info_Str (" Q");
849 Write_Info_Char (Queuing_Policy);
852 if Task_Dispatching_Policy /= ' ' then
853 Write_Info_Str (" T");
854 Write_Info_Char (Task_Dispatching_Policy);
855 Write_Info_Char (' ');
860 Write_Info_Str (" NO");
863 if No_Run_Time_Mode then
864 Write_Info_Str (" NR");
867 if Normalize_Scalars then
868 Write_Info_Str (" NS");
871 if Unreserve_All_Interrupts then
872 Write_Info_Str (" UA");
875 if Exception_Mechanism /= Front_End_Setjmp_Longjmp_Exceptions then
876 if Unit_Exception_Table_Present then
877 Write_Info_Str (" UX");
880 Write_Info_Str (" ZX");
885 -- Before outputting the restrictions line, update the setting of
886 -- the No_Elaboration_Code flag. Violations of this restriction
887 -- cannot be detected until after the backend has been called since
888 -- it is the backend that sets this flag. We have to check all units
889 -- for which we have generated code
891 for Unit in Units.First .. Last_Unit loop
892 if Units.Table (Unit).Generate_Code
893 or else Unit = Main_Unit
895 if not Has_No_Elaboration_Code (Cunit (Unit)) then
896 Violations (No_ELaboration_Code) := True;
901 -- Output restrictions line
903 Write_Info_Initiate ('R');
904 Write_Info_Char (' ');
906 for J in All_Restrictions loop
907 if Main_Restrictions (J) then
908 Write_Info_Char ('r');
909 elsif Violations (J) then
910 Write_Info_Char ('v');
912 Write_Info_Char ('n');
918 -- Output interrupt state lines
920 for J in Interrupt_States.First .. Interrupt_States.Last loop
921 Write_Info_Initiate ('I');
922 Write_Info_Char (' ');
923 Write_Info_Nat (Interrupt_States.Table (J).Interrupt_Number);
924 Write_Info_Char (' ');
925 Write_Info_Char (Interrupt_States.Table (J).Interrupt_State);
926 Write_Info_Char (' ');
928 (Nat (Get_Logical_Line_Number
929 (Interrupt_States.Table (J).Pragma_Loc)));
933 -- Loop through file table to output information for all units for which
934 -- we have generated code, as marked by the Generate_Code flag.
936 for Unit in Units.First .. Last_Unit loop
937 if Units.Table (Unit).Generate_Code
938 or else Unit = Main_Unit
940 Write_Info_EOL; -- blank line
941 Write_Unit_Information (Unit);
945 Write_Info_EOL; -- blank line
947 -- Output external version reference lines
949 for J in 1 .. Version_Ref.Last loop
950 Write_Info_Initiate ('E');
951 Write_Info_Char (' ');
953 for K in 1 .. String_Length (Version_Ref.Table (J)) loop
954 Write_Info_Char_Code (Get_String_Char (Version_Ref.Table (J), K));
960 -- Prepare to output the source dependency lines
963 Unum : Unit_Number_Type;
964 -- Number of unit being output
966 Sind : Source_File_Index;
967 -- Index of corresponding source file
970 for J in 1 .. Num_Sdep loop
971 Unum := Sdep_Table (J);
972 Units.Table (Unum).Dependency_Num := J;
973 Sind := Units.Table (Unum).Source_Index;
975 Write_Info_Initiate ('D');
976 Write_Info_Char (' ');
978 -- Normal case of a dependent unit entry with a source index
980 if Sind /= No_Source_File
981 and then Units.Table (Unum).Dependent_Unit
983 Write_Info_Name (File_Name (Sind));
985 Write_Info_Str (String (Time_Stamp (Sind)));
986 Write_Info_Char (' ');
987 Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
989 -- If subunit, add unit name, omitting the %b at the end
991 if Present (Cunit (Unum))
992 and then Nkind (Unit (Cunit (Unum))) = N_Subunit
994 Get_Decoded_Name_String (Unit_Name (Unum));
995 Write_Info_Char (' ');
996 Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
999 -- If Source_Reference pragma used output information
1001 if Num_SRef_Pragmas (Sind) > 0 then
1002 Write_Info_Char (' ');
1004 if Num_SRef_Pragmas (Sind) = 1 then
1005 Write_Info_Nat (Int (First_Mapped_Line (Sind)));
1010 Write_Info_Char (':');
1011 Write_Info_Name (Reference_Name (Sind));
1014 -- Case where there is no source index (happens for missing files)
1015 -- Also come here for non-dependent units.
1018 Write_Info_Name (Unit_File_Name (Unum));
1019 Write_Info_Tab (25);
1020 Write_Info_Str (String (Dummy_Time_Stamp));
1021 Write_Info_Char (' ');
1022 Write_Info_Str (Get_Hex_String (0));
1030 Write_Info_Terminate;
1031 Close_Output_Library_Info;