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 Dependent_Unit
=> True,
72 Dynamic_Elab
=> False,
74 Generate_Code
=> False,
76 Ident_String
=> Empty
,
82 Error_Location
=> No_Location
);
83 end Add_Preprocessing_Dependency
;
85 ------------------------------
86 -- Ensure_System_Dependency --
87 ------------------------------
89 procedure Ensure_System_Dependency
is
90 System_Uname
: Unit_Name_Type
;
91 -- Unit name for system spec if needed for dummy entry
93 System_Fname
: File_Name_Type
;
94 -- File name for system spec if needed for dummy entry
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
,
136 Error_Location
=> No_Location
);
138 -- Parse system.ads so that the checksum is set right
139 -- Style checks are not applied.
142 Save_Mindex
: constant Nat
:= Multiple_Unit_Index
;
143 Save_Style
: constant Boolean := Style_Check
;
145 Multiple_Unit_Index
:= 0;
146 Style_Check
:= False;
147 Initialize_Scanner
(Units
.Last
, System_Source_File_Index
);
148 Discard_List
(Par
(Configuration_Pragmas
=> False));
149 Style_Check
:= Save_Style
;
150 Multiple_Unit_Index
:= Save_Mindex
;
152 end Ensure_System_Dependency
;
158 procedure Write_ALI
(Object
: Boolean) is
164 Last_Unit
: constant Unit_Number_Type
:= Units
.Last
;
165 -- Record unit number of last unit. We capture this in case we
166 -- have to add a dummy entry to the unit table for package System.
168 With_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
169 -- Array of flags to show which units are with'ed
171 Elab_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
172 -- Array of flags to show which units have pragma Elaborate set
174 Elab_All_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
175 -- Array of flags to show which units have pragma Elaborate All set
177 Elab_Des_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
178 -- Array of flags to show which units have Elaborate_All_Desirable set
180 Sdep_Table
: Unit_Ref_Table
(1 .. Pos
(Last_Unit
- Units
.First
+ 2));
181 -- Sorted table of source dependencies. One extra entry in case we
182 -- have to add a dummy entry for System.
185 -- Number of active entries in Sdep_Table
187 -----------------------
188 -- Local Subprograms --
189 -----------------------
191 procedure Collect_Withs
(Cunit
: Node_Id
);
192 -- Collect with lines for entries in the context clause of the
193 -- given compilation unit, Cunit.
195 procedure Update_Tables_From_ALI_File
;
196 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
197 -- function), update tables from the ALI information, including
198 -- specifically the Compilation_Switches table.
200 function Up_To_Date_ALI_File_Exists
return Boolean;
201 -- If there exists an ALI file that is up to date, then this function
202 -- initializes the tables in the ALI spec to contain information on
203 -- this file (using Scan_ALI) and returns True. If no file exists,
204 -- or the file is not up to date, then False is returned.
206 procedure Write_Unit_Information
(Unit_Num
: Unit_Number_Type
);
207 -- Write out the library information for one unit for which code is
208 -- generated (includes unit line and with lines).
210 procedure Write_With_Lines
;
211 -- Write out with lines collected by calls to Collect_Withs
217 procedure Collect_Withs
(Cunit
: Node_Id
) is
219 Unum
: Unit_Number_Type
;
222 Item
:= First
(Context_Items
(Cunit
));
223 while Present
(Item
) loop
225 -- Ada0Y (AI-50217): limited with_clauses do not create
228 if Nkind
(Item
) = N_With_Clause
229 and then not (Limited_Present
(Item
))
231 Unum
:= Get_Cunit_Unit_Number
(Library_Unit
(Item
));
232 With_Flags
(Unum
) := True;
234 if Elaborate_Present
(Item
) then
235 Elab_Flags
(Unum
) := True;
238 if Elaborate_All_Present
(Item
) then
239 Elab_All_Flags
(Unum
) := True;
242 if Elaborate_All_Desirable
(Cunit_Entity
(Unum
)) then
243 Elab_Des_Flags
(Unum
) := True;
251 --------------------------------
252 -- Up_To_Date_ALI_File_Exists --
253 --------------------------------
255 function Up_To_Date_ALI_File_Exists
return Boolean is
256 Name
: File_Name_Type
;
257 Text
: Text_Buffer_Ptr
;
259 Sind
: Source_File_Index
;
262 Opt
.Check_Object_Consistency
:= True;
263 Read_Library_Info
(Name
, Text
);
265 -- Return if we could not find an ALI file
271 -- Return if ALI file has bad format
275 if Scan_ALI
(Name
, Text
, False, Err
=> True) = No_ALI_Id
then
279 -- If we have an OK ALI file, check if it is up to date
280 -- Note that we assume that the ALI read has all the entries
281 -- we have in our table, plus some additional ones (that can
282 -- come from expansion).
284 Id
:= First_Sdep_Entry
;
285 for J
in 1 .. Num_Sdep
loop
286 Sind
:= Units
.Table
(Sdep_Table
(J
)).Source_Index
;
288 while Sdep
.Table
(Id
).Sfile
/= File_Name
(Sind
) loop
289 if Id
= Sdep
.Last
then
296 if Sdep
.Table
(Id
).Stamp
/= Time_Stamp
(Sind
) then
302 end Up_To_Date_ALI_File_Exists
;
304 ---------------------------------
305 -- Update_Tables_From_ALI_File --
306 ---------------------------------
308 procedure Update_Tables_From_ALI_File
is
310 -- Build Compilation_Switches table
312 Compilation_Switches
.Init
;
314 for J
in First_Arg_Entry
.. Args
.Last
loop
315 Compilation_Switches
.Increment_Last
;
316 Compilation_Switches
.Table
(Compilation_Switches
.Last
) :=
319 end Update_Tables_From_ALI_File
;
321 ----------------------------
322 -- Write_Unit_Information --
323 ----------------------------
325 procedure Write_Unit_Information
(Unit_Num
: Unit_Number_Type
) is
326 Unode
: constant Node_Id
:= Cunit
(Unit_Num
);
327 Ukind
: constant Node_Kind
:= Nkind
(Unit
(Unode
));
328 Uent
: constant Entity_Id
:= Cunit_Entity
(Unit_Num
);
332 Write_Info_Initiate
('U');
333 Write_Info_Char
(' ');
334 Write_Info_Name
(Unit_Name
(Unit_Num
));
336 Write_Info_Name
(Unit_File_Name
(Unit_Num
));
339 Write_Info_Str
(Version_Get
(Unit_Num
));
341 if (Is_Subprogram
(Uent
)
342 or else Ekind
(Uent
) = E_Package
343 or else Is_Generic_Unit
(Uent
))
344 and then Body_Needed_For_SAL
(Uent
)
346 Write_Info_Str
(" BN");
349 if Dynamic_Elab
(Unit_Num
) then
350 Write_Info_Str
(" DE");
353 -- We set the Elaborate_Body indication if either an explicit pragma
354 -- was present, or if this is an instantiation. RM 12.3(20) requires
355 -- that the body be immediately elaborated after the spec. We would
356 -- normally do that anyway, but the EB we generate here ensures that
357 -- this gets done even when we use the -p gnatbind switch.
359 if Has_Pragma_Elaborate_Body
(Uent
)
360 or else (Ukind
= N_Package_Declaration
361 and then Is_Generic_Instance
(Uent
)
362 and then Present
(Corresponding_Body
(Unit
(Unode
))))
364 Write_Info_Str
(" EB");
367 -- Now see if we should tell the binder that an elaboration entity
368 -- is present, which must be reset to true during elaboration. We
369 -- generate the indication if the following condition is met:
371 -- If this is a spec ...
373 if (Is_Subprogram
(Uent
)
375 Ekind
(Uent
) = E_Package
377 Is_Generic_Unit
(Uent
))
379 -- and an elaboration entity was declared ...
381 and then Present
(Elaboration_Entity
(Uent
))
383 -- and either the elaboration flag is required ...
386 (Elaboration_Entity_Required
(Uent
)
388 -- or this unit has elaboration code ...
390 or else not Has_No_Elaboration_Code
(Unode
)
392 -- or this unit has a separate body and this
393 -- body has elaboration code.
396 (Ekind
(Uent
) = E_Package
397 and then Present
(Body_Entity
(Uent
))
399 not Has_No_Elaboration_Code
402 (Body_Entity
(Uent
))))))
404 Write_Info_Str
(" EE");
407 if Has_No_Elaboration_Code
(Unode
) then
408 Write_Info_Str
(" NE");
411 if Is_Preelaborated
(Uent
) then
412 Write_Info_Str
(" PR");
415 if Is_Pure
(Uent
) then
416 Write_Info_Str
(" PU");
419 if Has_RACW
(Unit_Num
) then
420 Write_Info_Str
(" RA");
423 if Is_Remote_Call_Interface
(Uent
) then
424 Write_Info_Str
(" RC");
427 if Is_Remote_Types
(Uent
) then
428 Write_Info_Str
(" RT");
431 if Is_Shared_Passive
(Uent
) then
432 Write_Info_Str
(" SP");
435 if Ukind
= N_Subprogram_Declaration
436 or else Ukind
= N_Subprogram_Body
438 Write_Info_Str
(" SU");
440 elsif Ukind
= N_Package_Declaration
442 Ukind
= N_Package_Body
444 -- If this is a wrapper package for a subprogram instantiation,
445 -- the user view is the subprogram. Note that in this case the
446 -- ali file contains both the spec and body of the instance.
448 if Is_Wrapper_Package
(Uent
) then
449 Write_Info_Str
(" SU");
451 Write_Info_Str
(" PK");
454 elsif Ukind
= N_Generic_Package_Declaration
then
455 Write_Info_Str
(" PK");
459 if Ukind
in N_Generic_Declaration
461 (Present
(Library_Unit
(Unode
))
463 Nkind
(Unit
(Library_Unit
(Unode
))) in N_Generic_Declaration
)
465 Write_Info_Str
(" GE");
468 if not Is_Internal_File_Name
(Unit_File_Name
(Unit_Num
), True) then
469 case Identifier_Casing
(Source_Index
(Unit_Num
)) is
470 when All_Lower_Case
=> Write_Info_Str
(" IL");
471 when All_Upper_Case
=> Write_Info_Str
(" IU");
475 case Keyword_Casing
(Source_Index
(Unit_Num
)) is
476 when Mixed_Case
=> Write_Info_Str
(" KM");
477 when All_Upper_Case
=> Write_Info_Str
(" KU");
482 if Initialize_Scalars
then
483 Write_Info_Str
(" IS");
488 -- Generate with lines, first those that are directly with'ed
490 for J
in With_Flags
'Range loop
491 With_Flags
(J
) := False;
492 Elab_Flags
(J
) := False;
493 Elab_All_Flags
(J
) := False;
494 Elab_Des_Flags
(J
) := False;
497 Collect_Withs
(Unode
);
499 -- For a body, we must also check for any subunits which belong to
500 -- it and which have context clauses of their own, since these
501 -- with'ed units are part of its own elaboration dependencies.
503 if Nkind
(Unit
(Unode
)) in N_Unit_Body
then
504 for S
in Units
.First
.. Last_Unit
loop
506 -- We are only interested in subunits.
507 -- For preproc. data and def. files, Cunit is Empty, so
508 -- we need to test that first.
510 if Cunit
(S
) /= Empty
511 and then Nkind
(Unit
(Cunit
(S
))) = N_Subunit
513 Pnode
:= Library_Unit
(Cunit
(S
));
515 -- In gnatc mode, the errors in the subunits will not
516 -- have been recorded, but the analysis of the subunit
517 -- may have failed. There is no information to add to
518 -- ALI file in this case.
524 -- Find ultimate parent of the subunit
526 while Nkind
(Unit
(Pnode
)) = N_Subunit
loop
527 Pnode
:= Library_Unit
(Pnode
);
530 -- See if it belongs to current unit, and if so, include
533 if Pnode
= Unode
then
534 Collect_Withs
(Cunit
(S
));
542 -- Output linker option lines
544 for J
in 1 .. Linker_Option_Lines
.Last
loop
546 S
: constant Linker_Option_Entry
:=
547 Linker_Option_Lines
.Table
(J
);
551 if S
.Unit
= Unit_Num
then
552 Write_Info_Initiate
('L');
553 Write_Info_Str
(" """);
555 for J
in 1 .. String_Length
(S
.Option
) loop
556 C
:= Get_Character
(Get_String_Char
(S
.Option
, J
));
558 if C
in Character'Val (16#
20#
) .. Character'Val (16#
7E#
)
569 Hex
: constant array (0 .. 15) of Character :=
573 Write_Info_Char
('{');
574 Write_Info_Char
(Hex
(Character'Pos (C
) / 16));
575 Write_Info_Char
(Hex
(Character'Pos (C
) mod 16));
576 Write_Info_Char
('}');
581 Write_Info_Char
('"');
586 end Write_Unit_Information
;
588 ----------------------
589 -- Write_With_Lines --
590 ----------------------
592 procedure Write_With_Lines
is
593 With_Table
: Unit_Ref_Table
(1 .. Pos
(Last_Unit
- Units
.First
+ 1));
594 Num_Withs
: Int
:= 0;
595 Unum
: Unit_Number_Type
;
598 Uname
: Unit_Name_Type
;
599 Fname
: File_Name_Type
;
600 Pname
: constant Unit_Name_Type
:=
601 Get_Parent_Spec_Name
(Unit_Name
(Main_Unit
));
602 Body_Fname
: File_Name_Type
;
605 -- Loop to build the with table. A with on the main unit itself
606 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
607 -- the main unit is a subprogram with no spec, and a subunit of
608 -- it unecessarily withs the parent.
610 for J
in Units
.First
+ 1 .. Last_Unit
loop
612 -- Add element to with table if it is with'ed or if it is the
613 -- parent spec of the main unit (case of main unit is a child
614 -- unit). The latter with is not needed for semantic purposes,
615 -- but is required by the binder for elaboration purposes.
616 -- For preproc. data and def. files, there is no Unit_Name,
617 -- check for that first.
619 if Unit_Name
(J
) /= No_Name
620 and then (With_Flags
(J
) or else Unit_Name
(J
) = Pname
)
621 and then Units
.Table
(J
).Dependent_Unit
623 Num_Withs
:= Num_Withs
+ 1;
624 With_Table
(Num_Withs
) := J
;
628 -- Sort and output the table
630 Sort
(With_Table
(1 .. Num_Withs
));
632 for J
in 1 .. Num_Withs
loop
633 Unum
:= With_Table
(J
);
634 Cunit
:= Units
.Table
(Unum
).Cunit
;
635 Cunite
:= Units
.Table
(Unum
).Cunit_Entity
;
636 Uname
:= Units
.Table
(Unum
).Unit_Name
;
637 Fname
:= Units
.Table
(Unum
).Unit_File_Name
;
639 Write_Info_Initiate
('W');
640 Write_Info_Char
(' ');
641 Write_Info_Name
(Uname
);
643 -- Now we need to figure out the names of the files that contain
644 -- the with'ed unit. These will usually be the files for the body,
645 -- except in the case of a package that has no body.
647 if (Nkind
(Unit
(Cunit
)) not in N_Generic_Declaration
649 Nkind
(Unit
(Cunit
)) not in N_Generic_Renaming_Declaration
)
650 or else Generic_Separately_Compiled
(Cunite
)
654 if Is_Spec_Name
(Uname
) then
657 (Get_Body_Name
(Uname
),
658 Subunit
=> False, May_Fail
=> True);
660 if Body_Fname
= No_File
then
661 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
665 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
668 -- A package is considered to have a body if it requires
669 -- a body or if a body is present in Ada 83 mode.
671 if Body_Required
(Cunit
)
673 and then Full_Source_Name
(Body_Fname
) /= No_File
)
675 Write_Info_Name
(Body_Fname
);
678 (Lib_File_Name
(Body_Fname
, Munit_Index
(Unum
)));
680 Write_Info_Name
(Fname
);
683 (Lib_File_Name
(Fname
, Munit_Index
(Unum
)));
686 if Elab_Flags
(Unum
) then
687 Write_Info_Str
(" E");
690 if Elab_All_Flags
(Unum
) then
691 Write_Info_Str
(" EA");
694 if Elab_Des_Flags
(Unum
) then
695 Write_Info_Str
(" ED");
701 end Write_With_Lines
;
703 -- Start of processing for Write_ALI
706 -- We never write an ALI file if the original operating mode was
707 -- syntax-only (-gnats switch used in compiler invocation line)
709 if Original_Operating_Mode
= Check_Syntax
then
713 -- Build sorted source dependency table. We do this right away,
714 -- because it is referenced by Up_To_Date_ALI_File_Exists.
716 for Unum
in Units
.First
.. Last_Unit
loop
717 if Cunit_Entity
(Unum
) = Empty
718 or else not From_With_Type
(Cunit_Entity
(Unum
))
720 Num_Sdep
:= Num_Sdep
+ 1;
721 Sdep_Table
(Num_Sdep
) := Unum
;
725 -- Sort the table so that the D lines are in order
727 Lib
.Sort
(Sdep_Table
(1 .. Num_Sdep
));
729 -- If we are not generating code, and there is an up to date
730 -- ali file accessible, read it, and acquire the compilation
731 -- arguments from this file.
733 if Operating_Mode
/= Generate_Code
then
734 if Up_To_Date_ALI_File_Exists
then
735 Update_Tables_From_ALI_File
;
740 -- Otherwise acquire compilation arguments and prepare to write
741 -- out a new ali file.
743 Create_Output_Library_Info
;
745 -- Output version line
747 Write_Info_Initiate
('V');
748 Write_Info_Str
(" """);
749 Write_Info_Str
(Verbose_Library_Version
);
750 Write_Info_Char
('"');
754 -- Output main program line if this is acceptable main program
756 Output_Main_Program_Line
: declare
757 U
: Node_Id
:= Unit
(Units
.Table
(Main_Unit
).Cunit
);
760 procedure M_Parameters
;
761 -- Output parameters for main program line
767 procedure M_Parameters
is
769 if Main_Priority
(Main_Unit
) /= Default_Main_Priority
then
770 Write_Info_Char
(' ');
771 Write_Info_Nat
(Main_Priority
(Main_Unit
));
774 if Opt
.Time_Slice_Set
then
775 Write_Info_Str
(" T=");
776 Write_Info_Nat
(Opt
.Time_Slice_Value
);
779 Write_Info_Str
(" W=");
781 (WC_Encoding_Letters
(Wide_Character_Encoding_Method
));
786 -- Start of processing for Output_Main_Program_Line
789 if Nkind
(U
) = N_Subprogram_Body
790 or else (Nkind
(U
) = N_Package_Body
792 (Nkind
(Original_Node
(U
)) = N_Function_Instantiation
794 Nkind
(Original_Node
(U
)) =
795 N_Procedure_Instantiation
))
797 -- If the unit is a subprogram instance, the entity for the
798 -- subprogram is the alias of the visible entity, which is the
799 -- related instance of the wrapper package. We retrieve the
800 -- subprogram declaration of the desired entity.
802 if Nkind
(U
) = N_Package_Body
then
803 U
:= Parent
(Parent
(
804 Alias
(Related_Instance
(Defining_Unit_Name
805 (Specification
(Unit
(Library_Unit
(Parent
(U
)))))))));
808 S
:= Specification
(U
);
810 if not Present
(Parameter_Specifications
(S
)) then
811 if Nkind
(S
) = N_Procedure_Specification
then
812 Write_Info_Initiate
('M');
813 Write_Info_Str
(" P");
818 Nam
: Node_Id
:= Defining_Unit_Name
(S
);
821 -- If it is a child unit, get its simple name.
823 if Nkind
(Nam
) = N_Defining_Program_Unit_Name
then
824 Nam
:= Defining_Identifier
(Nam
);
827 if Is_Integer_Type
(Etype
(Nam
)) then
828 Write_Info_Initiate
('M');
829 Write_Info_Str
(" F");
836 end Output_Main_Program_Line
;
838 -- Write command argmument ('A') lines
840 for A
in 1 .. Compilation_Switches
.Last
loop
841 Write_Info_Initiate
('A');
842 Write_Info_Char
(' ');
843 Write_Info_Str
(Compilation_Switches
.Table
(A
).all);
844 Write_Info_Terminate
;
847 -- Output parameters ('P') line
849 Write_Info_Initiate
('P');
851 if Compilation_Errors
then
852 Write_Info_Str
(" CE");
855 if Opt
.Float_Format
/= ' ' then
856 Write_Info_Str
(" F");
858 if Opt
.Float_Format
= 'I' then
859 Write_Info_Char
('I');
861 elsif Opt
.Float_Format_Long
= 'D' then
862 Write_Info_Char
('D');
865 Write_Info_Char
('G');
870 and then not Is_Predefined_File_Name
(Unit_File_Name
(Main_Unit
))
872 if Locking_Policy
/= ' ' then
873 Write_Info_Str
(" L");
874 Write_Info_Char
(Locking_Policy
);
877 if Queuing_Policy
/= ' ' then
878 Write_Info_Str
(" Q");
879 Write_Info_Char
(Queuing_Policy
);
882 if Task_Dispatching_Policy
/= ' ' then
883 Write_Info_Str
(" T");
884 Write_Info_Char
(Task_Dispatching_Policy
);
885 Write_Info_Char
(' ');
890 Write_Info_Str
(" NO");
893 if No_Run_Time_Mode
then
894 Write_Info_Str
(" NR");
897 if Normalize_Scalars
then
898 Write_Info_Str
(" NS");
901 if Sec_Stack_Used
then
902 Write_Info_Str
(" SS");
905 if Unreserve_All_Interrupts
then
906 Write_Info_Str
(" UA");
909 if Exception_Mechanism
/= Front_End_Setjmp_Longjmp_Exceptions
then
910 if Unit_Exception_Table_Present
then
911 Write_Info_Str
(" UX");
914 Write_Info_Str
(" ZX");
919 -- Before outputting the restrictions line, update the setting of
920 -- the No_Elaboration_Code flag. Violations of this restriction
921 -- cannot be detected until after the backend has been called since
922 -- it is the backend that sets this flag. We have to check all units
923 -- for which we have generated code
925 for Unit
in Units
.First
.. Last_Unit
loop
926 if Units
.Table
(Unit
).Generate_Code
927 or else Unit
= Main_Unit
929 if not Has_No_Elaboration_Code
(Cunit
(Unit
)) then
930 Main_Restrictions
.Violated
(No_Elaboration_Code
) := True;
935 -- Output restrictions line
937 Write_Info_Initiate
('R');
938 Write_Info_Char
(' ');
940 -- First the information for the boolean restrictions
942 for R
in All_Boolean_Restrictions
loop
943 if Main_Restrictions
.Set
(R
) then
944 Write_Info_Char
('r');
945 elsif Main_Restrictions
.Violated
(R
) then
946 Write_Info_Char
('v');
948 Write_Info_Char
('n');
952 -- And now the information for the parameter restrictions
954 for RP
in All_Parameter_Restrictions
loop
955 if Main_Restrictions
.Set
(RP
) then
956 Write_Info_Char
('r');
957 Write_Info_Nat
(Nat
(Main_Restrictions
.Value
(RP
)));
959 Write_Info_Char
('n');
962 if not Main_Restrictions
.Violated
(RP
)
963 or else RP
not in Checked_Parameter_Restrictions
965 Write_Info_Char
('n');
967 Write_Info_Char
('v');
968 Write_Info_Nat
(Nat
(Main_Restrictions
.Count
(RP
)));
970 if Main_Restrictions
.Unknown
(RP
) then
971 Write_Info_Char
('+');
978 -- Output interrupt state lines
980 for J
in Interrupt_States
.First
.. Interrupt_States
.Last
loop
981 Write_Info_Initiate
('I');
982 Write_Info_Char
(' ');
983 Write_Info_Nat
(Interrupt_States
.Table
(J
).Interrupt_Number
);
984 Write_Info_Char
(' ');
985 Write_Info_Char
(Interrupt_States
.Table
(J
).Interrupt_State
);
986 Write_Info_Char
(' ');
988 (Nat
(Get_Logical_Line_Number
989 (Interrupt_States
.Table
(J
).Pragma_Loc
)));
993 -- Loop through file table to output information for all units for which
994 -- we have generated code, as marked by the Generate_Code flag.
996 for Unit
in Units
.First
.. Last_Unit
loop
997 if Units
.Table
(Unit
).Generate_Code
998 or else Unit
= Main_Unit
1000 Write_Info_EOL
; -- blank line
1001 Write_Unit_Information
(Unit
);
1005 Write_Info_EOL
; -- blank line
1007 -- Output external version reference lines
1009 for J
in 1 .. Version_Ref
.Last
loop
1010 Write_Info_Initiate
('E');
1011 Write_Info_Char
(' ');
1013 for K
in 1 .. String_Length
(Version_Ref
.Table
(J
)) loop
1014 Write_Info_Char_Code
(Get_String_Char
(Version_Ref
.Table
(J
), K
));
1020 -- Prepare to output the source dependency lines
1023 Unum
: Unit_Number_Type
;
1024 -- Number of unit being output
1026 Sind
: Source_File_Index
;
1027 -- Index of corresponding source file
1030 for J
in 1 .. Num_Sdep
loop
1031 Unum
:= Sdep_Table
(J
);
1032 Units
.Table
(Unum
).Dependency_Num
:= J
;
1033 Sind
:= Units
.Table
(Unum
).Source_Index
;
1035 Write_Info_Initiate
('D');
1036 Write_Info_Char
(' ');
1038 -- Normal case of a dependent unit entry with a source index
1040 if Sind
/= No_Source_File
1041 and then Units
.Table
(Unum
).Dependent_Unit
1043 Write_Info_Name
(File_Name
(Sind
));
1044 Write_Info_Tab
(25);
1045 Write_Info_Str
(String (Time_Stamp
(Sind
)));
1046 Write_Info_Char
(' ');
1047 Write_Info_Str
(Get_Hex_String
(Source_Checksum
(Sind
)));
1049 -- If subunit, add unit name, omitting the %b at the end
1051 if Present
(Cunit
(Unum
))
1052 and then Nkind
(Unit
(Cunit
(Unum
))) = N_Subunit
1054 Get_Decoded_Name_String
(Unit_Name
(Unum
));
1055 Write_Info_Char
(' ');
1056 Write_Info_Str
(Name_Buffer
(1 .. Name_Len
- 2));
1059 -- If Source_Reference pragma used output information
1061 if Num_SRef_Pragmas
(Sind
) > 0 then
1062 Write_Info_Char
(' ');
1064 if Num_SRef_Pragmas
(Sind
) = 1 then
1065 Write_Info_Nat
(Int
(First_Mapped_Line
(Sind
)));
1070 Write_Info_Char
(':');
1071 Write_Info_Name
(Reference_Name
(Sind
));
1074 -- Case where there is no source index (happens for missing files)
1075 -- Also come here for non-dependent units.
1078 Write_Info_Name
(Unit_File_Name
(Unum
));
1079 Write_Info_Tab
(25);
1080 Write_Info_Str
(String (Dummy_Time_Stamp
));
1081 Write_Info_Char
(' ');
1082 Write_Info_Str
(Get_Hex_String
(0));
1090 Write_Info_Terminate
;
1091 Close_Output_Library_Info
;