1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
28 with Atree
; use Atree
;
29 with Casing
; use Casing
;
30 with Einfo
; use Einfo
;
31 with Errout
; use Errout
;
32 with Fname
; use Fname
;
33 with Fname
.UF
; use Fname
.UF
;
34 with Lib
.Util
; use Lib
.Util
;
35 with Lib
.Xref
; use Lib
.Xref
;
36 with 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
.Case_Util
; use System
.Case_Util
;
53 with System
.WCh_Con
; use System
.WCh_Con
;
55 package body Lib
.Writ
is
57 -----------------------
58 -- Local Subprograms --
59 -----------------------
61 procedure Write_Unit_Name
(N
: Node_Id
);
62 -- Used to write out the unit name for R (pragma Restriction) lines
63 -- for uses of Restriction (No_Dependence => unit-name).
65 ----------------------------------
66 -- Add_Preprocessing_Dependency --
67 ----------------------------------
69 procedure Add_Preprocessing_Dependency
(S
: Source_File_Index
) is
72 Units
.Table
(Units
.Last
) :=
73 (Unit_File_Name
=> File_Name
(S
),
75 Expected_Unit
=> No_Name
,
78 Cunit_Entity
=> Empty
,
80 Dynamic_Elab
=> False,
82 Generate_Code
=> False,
84 Ident_String
=> Empty
,
90 Error_Location
=> No_Location
);
91 end Add_Preprocessing_Dependency
;
93 ------------------------------
94 -- Ensure_System_Dependency --
95 ------------------------------
97 procedure Ensure_System_Dependency
is
98 System_Uname
: Unit_Name_Type
;
99 -- Unit name for system spec if needed for dummy entry
101 System_Fname
: File_Name_Type
;
102 -- File name for system spec if needed for dummy entry
105 -- Nothing to do if we already compiled System
107 for Unum
in Units
.First
.. Last_Unit
loop
108 if Units
.Table
(Unum
).Source_Index
= System_Source_File_Index
then
113 -- If no entry for system.ads in the units table, then add a entry
114 -- to the units table for system.ads, which will be referenced when
115 -- the ali file is generated. We need this because every unit depends
116 -- on system as a result of Targparm scanning the system.ads file to
117 -- determine the target dependent parameters for the compilation.
120 Name_Buffer
(1 .. 6) := "system";
121 System_Uname
:= Name_To_Unit_Name
(Name_Enter
);
122 System_Fname
:= File_Name
(System_Source_File_Index
);
124 Units
.Increment_Last
;
125 Units
.Table
(Units
.Last
) := (
126 Unit_File_Name
=> System_Fname
,
127 Unit_Name
=> System_Uname
,
128 Expected_Unit
=> System_Uname
,
129 Source_Index
=> System_Source_File_Index
,
131 Cunit_Entity
=> Empty
,
133 Dynamic_Elab
=> False,
134 Fatal_Error
=> False,
135 Generate_Code
=> False,
137 Ident_String
=> Empty
,
143 Error_Location
=> No_Location
);
145 -- Parse system.ads so that the checksum is set right
146 -- Style checks are not applied.
149 Save_Mindex
: constant Nat
:= Multiple_Unit_Index
;
150 Save_Style
: constant Boolean := Style_Check
;
152 Multiple_Unit_Index
:= 0;
153 Style_Check
:= False;
154 Initialize_Scanner
(Units
.Last
, System_Source_File_Index
);
155 Discard_List
(Par
(Configuration_Pragmas
=> False));
156 Style_Check
:= Save_Style
;
157 Multiple_Unit_Index
:= Save_Mindex
;
159 end Ensure_System_Dependency
;
165 procedure Write_ALI
(Object
: Boolean) is
171 Last_Unit
: constant Unit_Number_Type
:= Units
.Last
;
172 -- Record unit number of last unit. We capture this in case we
173 -- have to add a dummy entry to the unit table for package System.
175 With_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
176 -- Array of flags to show which units are with'ed
178 Elab_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
179 -- Array of flags to show which units have pragma Elaborate set
181 Elab_All_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
182 -- Array of flags to show which units have pragma Elaborate All set
184 Elab_Des_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
185 -- Array of flags to show which units have Elaborate_Desirable set
187 Elab_All_Des_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
188 -- Array of flags to show which units have Elaborate_All_Desirable set
190 Sdep_Table
: Unit_Ref_Table
(1 .. Pos
(Last_Unit
- Units
.First
+ 2));
191 -- Sorted table of source dependencies. One extra entry in case we
192 -- have to add a dummy entry for System.
195 -- Number of active entries in Sdep_Table
197 -----------------------
198 -- Local Subprograms --
199 -----------------------
201 procedure Collect_Withs
(Cunit
: Node_Id
);
202 -- Collect with lines for entries in the context clause of the
203 -- given compilation unit, Cunit.
205 procedure Update_Tables_From_ALI_File
;
206 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
207 -- function), update tables from the ALI information, including
208 -- specifically the Compilation_Switches table.
210 function Up_To_Date_ALI_File_Exists
return Boolean;
211 -- If there exists an ALI file that is up to date, then this function
212 -- initializes the tables in the ALI spec to contain information on
213 -- this file (using Scan_ALI) and returns True. If no file exists,
214 -- or the file is not up to date, then False is returned.
216 procedure Write_Unit_Information
(Unit_Num
: Unit_Number_Type
);
217 -- Write out the library information for one unit for which code is
218 -- generated (includes unit line and with lines).
220 procedure Write_With_Lines
;
221 -- Write out with lines collected by calls to Collect_Withs
227 procedure Collect_Withs
(Cunit
: Node_Id
) is
229 Unum
: Unit_Number_Type
;
232 Item
:= First
(Context_Items
(Cunit
));
233 while Present
(Item
) loop
235 -- Process with clause
237 -- Ada 2005 (AI-50217): limited with_clauses do not create
240 if Nkind
(Item
) = N_With_Clause
241 and then not (Limited_Present
(Item
))
243 Unum
:= Get_Cunit_Unit_Number
(Library_Unit
(Item
));
244 With_Flags
(Unum
) := True;
246 if Elaborate_Present
(Item
) then
247 Elab_Flags
(Unum
) := True;
250 if Elaborate_All_Present
(Item
) then
251 Elab_All_Flags
(Unum
) := True;
254 if Elaborate_All_Desirable
(Item
) then
255 Elab_All_Des_Flags
(Unum
) := True;
258 if Elaborate_Desirable
(Item
) then
259 Elab_Des_Flags
(Unum
) := True;
267 --------------------------------
268 -- Up_To_Date_ALI_File_Exists --
269 --------------------------------
271 function Up_To_Date_ALI_File_Exists
return Boolean is
272 Name
: File_Name_Type
;
273 Text
: Text_Buffer_Ptr
;
275 Sind
: Source_File_Index
;
278 Opt
.Check_Object_Consistency
:= True;
279 Read_Library_Info
(Name
, Text
);
281 -- Return if we could not find an ALI file
287 -- Return if ALI file has bad format
291 if Scan_ALI
(Name
, Text
, False, Err
=> True) = No_ALI_Id
then
295 -- If we have an OK ALI file, check if it is up to date
296 -- Note that we assume that the ALI read has all the entries
297 -- we have in our table, plus some additional ones (that can
298 -- come from expansion).
300 Id
:= First_Sdep_Entry
;
301 for J
in 1 .. Num_Sdep
loop
302 Sind
:= Units
.Table
(Sdep_Table
(J
)).Source_Index
;
304 while Sdep
.Table
(Id
).Sfile
/= File_Name
(Sind
) loop
305 if Id
= Sdep
.Last
then
312 if Sdep
.Table
(Id
).Stamp
/= Time_Stamp
(Sind
) then
318 end Up_To_Date_ALI_File_Exists
;
320 ---------------------------------
321 -- Update_Tables_From_ALI_File --
322 ---------------------------------
324 procedure Update_Tables_From_ALI_File
is
326 -- Build Compilation_Switches table
328 Compilation_Switches
.Init
;
330 for J
in First_Arg_Entry
.. Args
.Last
loop
331 Compilation_Switches
.Increment_Last
;
332 Compilation_Switches
.Table
(Compilation_Switches
.Last
) :=
335 end Update_Tables_From_ALI_File
;
337 ----------------------------
338 -- Write_Unit_Information --
339 ----------------------------
341 procedure Write_Unit_Information
(Unit_Num
: Unit_Number_Type
) is
342 Unode
: constant Node_Id
:= Cunit
(Unit_Num
);
343 Ukind
: constant Node_Kind
:= Nkind
(Unit
(Unode
));
344 Uent
: constant Entity_Id
:= Cunit_Entity
(Unit_Num
);
348 Write_Info_Initiate
('U');
349 Write_Info_Char
(' ');
350 Write_Info_Name
(Unit_Name
(Unit_Num
));
352 Write_Info_Name
(Unit_File_Name
(Unit_Num
));
355 Write_Info_Str
(Version_Get
(Unit_Num
));
357 -- Add BD parameter if Elaborate_Body pragma desirable
359 if Ekind
(Uent
) = E_Package
360 and then Elaborate_Body_Desirable
(Uent
)
362 Write_Info_Str
(" BD");
365 -- Add BN parameter if body needed for SAL
367 if (Is_Subprogram
(Uent
)
368 or else Ekind
(Uent
) = E_Package
369 or else Is_Generic_Unit
(Uent
))
370 and then Body_Needed_For_SAL
(Uent
)
372 Write_Info_Str
(" BN");
375 if Dynamic_Elab
(Unit_Num
) then
376 Write_Info_Str
(" DE");
379 -- We set the Elaborate_Body indication if either an explicit pragma
380 -- was present, or if this is an instantiation. RM 12.3(20) requires
381 -- that the body be immediately elaborated after the spec. We would
382 -- normally do that anyway, but the EB we generate here ensures that
383 -- this gets done even when we use the -p gnatbind switch.
385 if Has_Pragma_Elaborate_Body
(Uent
)
386 or else (Ukind
= N_Package_Declaration
387 and then Is_Generic_Instance
(Uent
)
388 and then Present
(Corresponding_Body
(Unit
(Unode
))))
390 Write_Info_Str
(" EB");
393 -- Now see if we should tell the binder that an elaboration entity
394 -- is present, which must be reset to true during elaboration. We
395 -- generate the indication if the following condition is met:
397 -- If this is a spec ...
399 if (Is_Subprogram
(Uent
)
401 Ekind
(Uent
) = E_Package
403 Is_Generic_Unit
(Uent
))
405 -- and an elaboration entity was declared ...
407 and then Present
(Elaboration_Entity
(Uent
))
409 -- and either the elaboration flag is required ...
412 (Elaboration_Entity_Required
(Uent
)
414 -- or this unit has elaboration code ...
416 or else not Has_No_Elaboration_Code
(Unode
)
418 -- or this unit has a separate body and this
419 -- body has elaboration code.
422 (Ekind
(Uent
) = E_Package
423 and then Present
(Body_Entity
(Uent
))
425 not Has_No_Elaboration_Code
428 (Body_Entity
(Uent
))))))
430 Write_Info_Str
(" EE");
433 if Has_No_Elaboration_Code
(Unode
) then
434 Write_Info_Str
(" NE");
437 if Is_Preelaborated
(Uent
) then
438 Write_Info_Str
(" PR");
441 if Is_Pure
(Uent
) then
442 Write_Info_Str
(" PU");
445 if Has_RACW
(Unit_Num
) then
446 Write_Info_Str
(" RA");
449 if Is_Remote_Call_Interface
(Uent
) then
450 Write_Info_Str
(" RC");
453 if Is_Remote_Types
(Uent
) then
454 Write_Info_Str
(" RT");
457 if Is_Shared_Passive
(Uent
) then
458 Write_Info_Str
(" SP");
461 if Ukind
= N_Subprogram_Declaration
462 or else Ukind
= N_Subprogram_Body
464 Write_Info_Str
(" SU");
466 elsif Ukind
= N_Package_Declaration
468 Ukind
= N_Package_Body
470 -- If this is a wrapper package for a subprogram instantiation,
471 -- the user view is the subprogram. Note that in this case the
472 -- ali file contains both the spec and body of the instance.
474 if Is_Wrapper_Package
(Uent
) then
475 Write_Info_Str
(" SU");
477 Write_Info_Str
(" PK");
480 elsif Ukind
= N_Generic_Package_Declaration
then
481 Write_Info_Str
(" PK");
485 if Ukind
in N_Generic_Declaration
487 (Present
(Library_Unit
(Unode
))
489 Nkind
(Unit
(Library_Unit
(Unode
))) in N_Generic_Declaration
)
491 Write_Info_Str
(" GE");
494 if not Is_Internal_File_Name
(Unit_File_Name
(Unit_Num
), True) then
495 case Identifier_Casing
(Source_Index
(Unit_Num
)) is
496 when All_Lower_Case
=> Write_Info_Str
(" IL");
497 when All_Upper_Case
=> Write_Info_Str
(" IU");
501 case Keyword_Casing
(Source_Index
(Unit_Num
)) is
502 when Mixed_Case
=> Write_Info_Str
(" KM");
503 when All_Upper_Case
=> Write_Info_Str
(" KU");
508 if Initialize_Scalars
then
509 Write_Info_Str
(" IS");
514 -- Generate with lines, first those that are directly with'ed
516 for J
in With_Flags
'Range loop
517 With_Flags
(J
) := False;
518 Elab_Flags
(J
) := False;
519 Elab_All_Flags
(J
) := False;
520 Elab_Des_Flags
(J
) := False;
521 Elab_All_Des_Flags
(J
) := False;
524 Collect_Withs
(Unode
);
526 -- For a body, we must also check for any subunits which belong to
527 -- it and which have context clauses of their own, since these
528 -- with'ed units are part of its own elaboration dependencies.
530 if Nkind
(Unit
(Unode
)) in N_Unit_Body
then
531 for S
in Units
.First
.. Last_Unit
loop
533 -- We are only interested in subunits.
534 -- For preproc. data and def. files, Cunit is Empty, so
535 -- we need to test that first.
537 if Cunit
(S
) /= Empty
538 and then Nkind
(Unit
(Cunit
(S
))) = N_Subunit
540 Pnode
:= Library_Unit
(Cunit
(S
));
542 -- In gnatc mode, the errors in the subunits will not
543 -- have been recorded, but the analysis of the subunit
544 -- may have failed. There is no information to add to
545 -- ALI file in this case.
551 -- Find ultimate parent of the subunit
553 while Nkind
(Unit
(Pnode
)) = N_Subunit
loop
554 Pnode
:= Library_Unit
(Pnode
);
557 -- See if it belongs to current unit, and if so, include
560 if Pnode
= Unode
then
561 Collect_Withs
(Cunit
(S
));
569 -- Output linker option lines
571 for J
in 1 .. Linker_Option_Lines
.Last
loop
573 S
: constant Linker_Option_Entry
:=
574 Linker_Option_Lines
.Table
(J
);
578 if S
.Unit
= Unit_Num
then
579 Write_Info_Initiate
('L');
580 Write_Info_Str
(" """);
582 for J
in 1 .. String_Length
(S
.Option
) loop
583 C
:= Get_Character
(Get_String_Char
(S
.Option
, J
));
585 if C
in Character'Val (16#
20#
) .. Character'Val (16#
7E#
)
596 Hex
: constant array (0 .. 15) of Character :=
600 Write_Info_Char
('{');
601 Write_Info_Char
(Hex
(Character'Pos (C
) / 16));
602 Write_Info_Char
(Hex
(Character'Pos (C
) mod 16));
603 Write_Info_Char
('}');
608 Write_Info_Char
('"');
613 end Write_Unit_Information
;
615 ----------------------
616 -- Write_With_Lines --
617 ----------------------
619 procedure Write_With_Lines
is
620 With_Table
: Unit_Ref_Table
(1 .. Pos
(Last_Unit
- Units
.First
+ 1));
621 Num_Withs
: Int
:= 0;
622 Unum
: Unit_Number_Type
;
625 Uname
: Unit_Name_Type
;
626 Fname
: File_Name_Type
;
627 Pname
: constant Unit_Name_Type
:=
628 Get_Parent_Spec_Name
(Unit_Name
(Main_Unit
));
629 Body_Fname
: File_Name_Type
;
633 -- Loop to build the with table. A with on the main unit itself
634 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
635 -- the main unit is a subprogram with no spec, and a subunit of
636 -- it unecessarily withs the parent.
638 for J
in Units
.First
+ 1 .. Last_Unit
loop
640 -- Add element to with table if it is with'ed or if it is the
641 -- parent spec of the main unit (case of main unit is a child
642 -- unit). The latter with is not needed for semantic purposes,
643 -- but is required by the binder for elaboration purposes.
644 -- For preproc. data and def. files, there is no Unit_Name,
645 -- check for that first.
647 if Unit_Name
(J
) /= No_Name
648 and then (With_Flags
(J
) or else Unit_Name
(J
) = Pname
)
650 Num_Withs
:= Num_Withs
+ 1;
651 With_Table
(Num_Withs
) := J
;
655 -- Sort and output the table
657 Sort
(With_Table
(1 .. Num_Withs
));
659 for J
in 1 .. Num_Withs
loop
660 Unum
:= With_Table
(J
);
661 Cunit
:= Units
.Table
(Unum
).Cunit
;
662 Cunite
:= Units
.Table
(Unum
).Cunit_Entity
;
663 Uname
:= Units
.Table
(Unum
).Unit_Name
;
664 Fname
:= Units
.Table
(Unum
).Unit_File_Name
;
666 Write_Info_Initiate
('W');
667 Write_Info_Char
(' ');
668 Write_Info_Name
(Uname
);
670 -- Now we need to figure out the names of the files that contain
671 -- the with'ed unit. These will usually be the files for the body,
672 -- except in the case of a package that has no body.
674 if (Nkind
(Unit
(Cunit
)) not in N_Generic_Declaration
676 Nkind
(Unit
(Cunit
)) not in N_Generic_Renaming_Declaration
)
677 or else Generic_Separately_Compiled
(Cunite
)
681 if Is_Spec_Name
(Uname
) then
684 (Get_Body_Name
(Uname
),
685 Subunit
=> False, May_Fail
=> True);
689 (Get_Body_Name
(Uname
));
691 if Body_Fname
= No_File
then
692 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
693 Body_Index
:= Get_Unit_Index
(Uname
);
697 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
698 Body_Index
:= Get_Unit_Index
(Uname
);
701 -- A package is considered to have a body if it requires
702 -- a body or if a body is present in Ada 83 mode.
704 if Body_Required
(Cunit
)
705 or else (Ada_Version
= Ada_83
706 and then Full_Source_Name
(Body_Fname
) /= No_File
)
708 -- Ensure that on platforms where the file names are not
709 -- case sensitive, the recorded file name is in lower case.
711 if not File_Names_Case_Sensitive
then
712 Get_Name_String
(Body_Fname
);
713 To_Lower
(Name_Buffer
(1 .. Name_Len
));
714 Body_Fname
:= Name_Find
;
717 Write_Info_Name
(Body_Fname
);
720 (Lib_File_Name
(Body_Fname
, Body_Index
));
722 -- Ensure that on platforms where the file names are not
723 -- case sensitive, the recorded file name is in lower case.
725 if not File_Names_Case_Sensitive
then
726 Get_Name_String
(Fname
);
727 To_Lower
(Name_Buffer
(1 .. Name_Len
));
731 Write_Info_Name
(Fname
);
734 (Lib_File_Name
(Fname
, Munit_Index
(Unum
)));
737 if Elab_Flags
(Unum
) then
738 Write_Info_Str
(" E");
741 if Elab_All_Flags
(Unum
) then
742 Write_Info_Str
(" EA");
745 if Elab_Des_Flags
(Unum
) then
746 Write_Info_Str
(" ED");
749 if Elab_All_Des_Flags
(Unum
) then
750 Write_Info_Str
(" AD");
756 end Write_With_Lines
;
758 -- Start of processing for Write_ALI
761 -- We never write an ALI file if the original operating mode was
762 -- syntax-only (-gnats switch used in compiler invocation line)
764 if Original_Operating_Mode
= Check_Syntax
then
768 -- Build sorted source dependency table. We do this right away,
769 -- because it is referenced by Up_To_Date_ALI_File_Exists.
771 for Unum
in Units
.First
.. Last_Unit
loop
772 if Cunit_Entity
(Unum
) = Empty
773 or else not From_With_Type
(Cunit_Entity
(Unum
))
775 Num_Sdep
:= Num_Sdep
+ 1;
776 Sdep_Table
(Num_Sdep
) := Unum
;
780 -- Sort the table so that the D lines are in order
782 Lib
.Sort
(Sdep_Table
(1 .. Num_Sdep
));
784 -- If we are not generating code, and there is an up to date
785 -- ali file accessible, read it, and acquire the compilation
786 -- arguments from this file.
788 if Operating_Mode
/= Generate_Code
then
789 if Up_To_Date_ALI_File_Exists
then
790 Update_Tables_From_ALI_File
;
795 -- Otherwise acquire compilation arguments and prepare to write
796 -- out a new ali file.
798 Create_Output_Library_Info
;
800 -- Output version line
802 Write_Info_Initiate
('V');
803 Write_Info_Str
(" """);
804 Write_Info_Str
(Verbose_Library_Version
);
805 Write_Info_Char
('"');
809 -- Output main program line if this is acceptable main program
811 Output_Main_Program_Line
: declare
812 U
: Node_Id
:= Unit
(Units
.Table
(Main_Unit
).Cunit
);
815 procedure M_Parameters
;
816 -- Output parameters for main program line
822 procedure M_Parameters
is
824 if Main_Priority
(Main_Unit
) /= Default_Main_Priority
then
825 Write_Info_Char
(' ');
826 Write_Info_Nat
(Main_Priority
(Main_Unit
));
829 if Opt
.Time_Slice_Set
then
830 Write_Info_Str
(" T=");
831 Write_Info_Nat
(Opt
.Time_Slice_Value
);
834 Write_Info_Str
(" W=");
836 (WC_Encoding_Letters
(Wide_Character_Encoding_Method
));
841 -- Start of processing for Output_Main_Program_Line
844 if Nkind
(U
) = N_Subprogram_Body
846 (Nkind
(U
) = N_Package_Body
848 Nkind
(Original_Node
(U
)) in N_Subprogram_Instantiation
)
850 -- If the unit is a subprogram instance, the entity for the
851 -- subprogram is the alias of the visible entity, which is the
852 -- related instance of the wrapper package. We retrieve the
853 -- subprogram declaration of the desired entity.
855 if Nkind
(U
) = N_Package_Body
then
856 U
:= Parent
(Parent
(
857 Alias
(Related_Instance
(Defining_Unit_Name
858 (Specification
(Unit
(Library_Unit
(Parent
(U
)))))))));
861 S
:= Specification
(U
);
863 if No
(Parameter_Specifications
(S
)) then
864 if Nkind
(S
) = N_Procedure_Specification
then
865 Write_Info_Initiate
('M');
866 Write_Info_Str
(" P");
871 Nam
: Node_Id
:= Defining_Unit_Name
(S
);
874 -- If it is a child unit, get its simple name
876 if Nkind
(Nam
) = N_Defining_Program_Unit_Name
then
877 Nam
:= Defining_Identifier
(Nam
);
880 if Is_Integer_Type
(Etype
(Nam
)) then
881 Write_Info_Initiate
('M');
882 Write_Info_Str
(" F");
889 end Output_Main_Program_Line
;
891 -- Write command argmument ('A') lines
893 for A
in 1 .. Compilation_Switches
.Last
loop
894 Write_Info_Initiate
('A');
895 Write_Info_Char
(' ');
896 Write_Info_Str
(Compilation_Switches
.Table
(A
).all);
897 Write_Info_Terminate
;
900 -- Output parameters ('P') line
902 Write_Info_Initiate
('P');
904 if Compilation_Errors
then
905 Write_Info_Str
(" CE");
908 if Opt
.Detect_Blocking
then
909 Write_Info_Str
(" DB");
912 if Opt
.Float_Format
/= ' ' then
913 Write_Info_Str
(" F");
915 if Opt
.Float_Format
= 'I' then
916 Write_Info_Char
('I');
918 elsif Opt
.Float_Format_Long
= 'D' then
919 Write_Info_Char
('D');
922 Write_Info_Char
('G');
927 and then not Is_Predefined_File_Name
(Unit_File_Name
(Main_Unit
))
929 if Locking_Policy
/= ' ' then
930 Write_Info_Str
(" L");
931 Write_Info_Char
(Locking_Policy
);
934 if Queuing_Policy
/= ' ' then
935 Write_Info_Str
(" Q");
936 Write_Info_Char
(Queuing_Policy
);
939 if Task_Dispatching_Policy
/= ' ' then
940 Write_Info_Str
(" T");
941 Write_Info_Char
(Task_Dispatching_Policy
);
942 Write_Info_Char
(' ');
947 Write_Info_Str
(" NO");
950 if No_Run_Time_Mode
then
951 Write_Info_Str
(" NR");
954 if Normalize_Scalars
then
955 Write_Info_Str
(" NS");
958 if Sec_Stack_Used
then
959 Write_Info_Str
(" SS");
962 if Unreserve_All_Interrupts
then
963 Write_Info_Str
(" UA");
966 if Exception_Mechanism
= Back_End_Exceptions
then
967 Write_Info_Str
(" ZX");
972 -- Before outputting the restrictions line, update the setting of
973 -- the No_Elaboration_Code flag. Violations of this restriction
974 -- cannot be detected until after the backend has been called since
975 -- it is the backend that sets this flag. We have to check all units
976 -- for which we have generated code
978 for Unit
in Units
.First
.. Last_Unit
loop
979 if Units
.Table
(Unit
).Generate_Code
980 or else Unit
= Main_Unit
982 if not Has_No_Elaboration_Code
(Cunit
(Unit
)) then
983 Main_Restrictions
.Violated
(No_Elaboration_Code
) := True;
988 -- Output first restrictions line
990 Write_Info_Initiate
('R');
991 Write_Info_Char
(' ');
993 -- First the information for the boolean restrictions
995 for R
in All_Boolean_Restrictions
loop
996 if Main_Restrictions
.Set
(R
)
997 and then not Restriction_Warnings
(R
)
999 Write_Info_Char
('r');
1000 elsif Main_Restrictions
.Violated
(R
) then
1001 Write_Info_Char
('v');
1003 Write_Info_Char
('n');
1007 -- And now the information for the parameter restrictions
1009 for RP
in All_Parameter_Restrictions
loop
1010 if Main_Restrictions
.Set
(RP
)
1011 and then not Restriction_Warnings
(RP
)
1013 Write_Info_Char
('r');
1014 Write_Info_Nat
(Nat
(Main_Restrictions
.Value
(RP
)));
1016 Write_Info_Char
('n');
1019 if not Main_Restrictions
.Violated
(RP
)
1020 or else RP
not in Checked_Parameter_Restrictions
1022 Write_Info_Char
('n');
1024 Write_Info_Char
('v');
1025 Write_Info_Nat
(Nat
(Main_Restrictions
.Count
(RP
)));
1027 if Main_Restrictions
.Unknown
(RP
) then
1028 Write_Info_Char
('+');
1035 -- Output R lines for No_Dependence entries
1037 for J
in No_Dependence
.First
.. No_Dependence
.Last
loop
1038 if In_Extended_Main_Source_Unit
(No_Dependence
.Table
(J
).Unit
)
1039 and then not No_Dependence
.Table
(J
).Warn
1041 Write_Info_Initiate
('R');
1042 Write_Info_Char
(' ');
1043 Write_Unit_Name
(No_Dependence
.Table
(J
).Unit
);
1048 -- Output interrupt state lines
1050 for J
in Interrupt_States
.First
.. Interrupt_States
.Last
loop
1051 Write_Info_Initiate
('I');
1052 Write_Info_Char
(' ');
1053 Write_Info_Nat
(Interrupt_States
.Table
(J
).Interrupt_Number
);
1054 Write_Info_Char
(' ');
1055 Write_Info_Char
(Interrupt_States
.Table
(J
).Interrupt_State
);
1056 Write_Info_Char
(' ');
1058 (Nat
(Get_Logical_Line_Number
1059 (Interrupt_States
.Table
(J
).Pragma_Loc
)));
1063 -- Output priority specific dispatching lines
1065 for J
in Specific_Dispatching
.First
.. Specific_Dispatching
.Last
loop
1066 Write_Info_Initiate
('S');
1067 Write_Info_Char
(' ');
1068 Write_Info_Char
(Specific_Dispatching
.Table
(J
).Dispatching_Policy
);
1069 Write_Info_Char
(' ');
1070 Write_Info_Nat
(Specific_Dispatching
.Table
(J
).First_Priority
);
1071 Write_Info_Char
(' ');
1072 Write_Info_Nat
(Specific_Dispatching
.Table
(J
).Last_Priority
);
1073 Write_Info_Char
(' ');
1075 (Nat
(Get_Logical_Line_Number
1076 (Specific_Dispatching
.Table
(J
).Pragma_Loc
)));
1080 -- Loop through file table to output information for all units for which
1081 -- we have generated code, as marked by the Generate_Code flag.
1083 for Unit
in Units
.First
.. Last_Unit
loop
1084 if Units
.Table
(Unit
).Generate_Code
1085 or else Unit
= Main_Unit
1087 Write_Info_EOL
; -- blank line
1088 Write_Unit_Information
(Unit
);
1092 Write_Info_EOL
; -- blank line
1094 -- Output external version reference lines
1096 for J
in 1 .. Version_Ref
.Last
loop
1097 Write_Info_Initiate
('E');
1098 Write_Info_Char
(' ');
1100 for K
in 1 .. String_Length
(Version_Ref
.Table
(J
)) loop
1101 Write_Info_Char_Code
(Get_String_Char
(Version_Ref
.Table
(J
), K
));
1107 -- Prepare to output the source dependency lines
1110 Unum
: Unit_Number_Type
;
1111 -- Number of unit being output
1113 Sind
: Source_File_Index
;
1114 -- Index of corresponding source file
1116 Fname
: File_Name_Type
;
1119 for J
in 1 .. Num_Sdep
loop
1120 Unum
:= Sdep_Table
(J
);
1121 Units
.Table
(Unum
).Dependency_Num
:= J
;
1122 Sind
:= Units
.Table
(Unum
).Source_Index
;
1124 Write_Info_Initiate
('D');
1125 Write_Info_Char
(' ');
1127 -- Normal case of a unit entry with a source index
1129 if Sind
/= No_Source_File
then
1130 Fname
:= File_Name
(Sind
);
1132 -- Ensure that on platforms where the file names are not
1133 -- case sensitive, the recorded file name is in lower case.
1135 if not File_Names_Case_Sensitive
then
1136 Get_Name_String
(Fname
);
1137 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1141 Write_Info_Name
(Fname
);
1142 Write_Info_Tab
(25);
1143 Write_Info_Str
(String (Time_Stamp
(Sind
)));
1144 Write_Info_Char
(' ');
1145 Write_Info_Str
(Get_Hex_String
(Source_Checksum
(Sind
)));
1147 -- If subunit, add unit name, omitting the %b at the end
1149 if Present
(Cunit
(Unum
))
1150 and then Nkind
(Unit
(Cunit
(Unum
))) = N_Subunit
1152 Get_Decoded_Name_String
(Unit_Name
(Unum
));
1153 Write_Info_Char
(' ');
1154 Write_Info_Str
(Name_Buffer
(1 .. Name_Len
- 2));
1157 -- If Source_Reference pragma used output information
1159 if Num_SRef_Pragmas
(Sind
) > 0 then
1160 Write_Info_Char
(' ');
1162 if Num_SRef_Pragmas
(Sind
) = 1 then
1163 Write_Info_Nat
(Int
(First_Mapped_Line
(Sind
)));
1168 Write_Info_Char
(':');
1169 Write_Info_Name
(Reference_Name
(Sind
));
1172 -- Case where there is no source index (happens for missing
1173 -- files). In this case we write a dummy time stamp.
1176 Write_Info_Name
(Unit_File_Name
(Unum
));
1177 Write_Info_Tab
(25);
1178 Write_Info_Str
(String (Dummy_Time_Stamp
));
1179 Write_Info_Char
(' ');
1180 Write_Info_Str
(Get_Hex_String
(0));
1188 Write_Info_Terminate
;
1189 Close_Output_Library_Info
;
1192 ---------------------
1193 -- Write_Unit_Name --
1194 ---------------------
1196 procedure Write_Unit_Name
(N
: Node_Id
) is
1198 if Nkind
(N
) = N_Identifier
then
1199 Write_Info_Name
(Chars
(N
));
1202 pragma Assert
(Nkind
(N
) = N_Selected_Component
);
1203 Write_Unit_Name
(Prefix
(N
));
1204 Write_Info_Char
('.');
1205 Write_Unit_Name
(Selector_Name
(N
));
1207 end Write_Unit_Name
;