1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2023, 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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
27 with Atree
; use Atree
;
28 with Casing
; use Casing
;
29 with Debug
; use Debug
;
30 with Einfo
; use Einfo
;
31 with Einfo
.Entities
; use Einfo
.Entities
;
32 with Einfo
.Utils
; use Einfo
.Utils
;
33 with Elists
; use Elists
;
34 with Errout
; use Errout
;
35 with Fname
; use Fname
;
36 with Fname
.UF
; use Fname
.UF
;
37 with Lib
.Util
; use Lib
.Util
;
38 with Lib
.Xref
; use Lib
.Xref
;
39 with Nlists
; use Nlists
;
40 with Gnatvsn
; use Gnatvsn
;
41 with GNAT_CUDA
; use GNAT_CUDA
;
43 with Osint
; use Osint
;
44 with Osint
.C
; use Osint
.C
;
45 with Output
; use Output
;
47 with Par_SCO
; use Par_SCO
;
48 with Restrict
; use Restrict
;
49 with Rident
; use Rident
;
50 with Stand
; use Stand
;
52 with Sem_Eval
; use Sem_Eval
;
53 with Sem_Util
; use Sem_Util
;
54 with Sinfo
; use Sinfo
;
55 with Sinfo
.Nodes
; use Sinfo
.Nodes
;
56 with Sinfo
.Utils
; use Sinfo
.Utils
;
57 with Sinput
; use Sinput
;
58 with Snames
; use Snames
;
59 with Stringt
; use Stringt
;
60 with Tbuild
; use Tbuild
;
61 with Uname
; use Uname
;
63 with System
.Case_Util
; use System
.Case_Util
;
64 with System
.WCh_Con
; use System
.WCh_Con
;
66 package body Lib
.Writ
is
68 -----------------------
69 -- Local subprograms --
70 -----------------------
72 function Present
(N_Id
: Name_Id
) return Boolean;
73 pragma Inline
(Present
);
74 -- Determine whether a name with id N_Id exists
76 procedure Write_Invocation_Construct
(IC_Id
: Invocation_Construct_Id
);
77 pragma Inline
(Write_Invocation_Construct
);
78 -- Write invocation construct IC_Id to the ALI file
80 procedure Write_Invocation_Graph
;
81 pragma Inline
(Write_Invocation_Graph
);
82 -- Write out the invocation graph
84 procedure Write_Invocation_Graph_Attributes
;
85 pragma Inline
(Write_Invocation_Graph_Attributes
);
86 -- Write out the attributes of the invocation graph
88 procedure Write_Invocation_Relation
(IR_Id
: Invocation_Relation_Id
);
89 pragma Inline
(Write_Invocation_Relation
);
90 -- Write invocation relation IR_Id to the ALI file
92 procedure Write_Invocation_Signature
(IS_Id
: Invocation_Signature_Id
);
93 pragma Inline
(Write_Invocation_Signature
);
94 -- Write invocation signature IS_Id to the ALI file
96 procedure Write_Unit_Name
(N
: Node_Id
);
97 -- Used to write out the unit name for R (pragma Restriction) lines
98 -- for uses of Restriction (No_Dependence => unit-name).
100 ----------------------------------
101 -- Add_Preprocessing_Dependency --
102 ----------------------------------
104 procedure Add_Preprocessing_Dependency
(S
: Source_File_Index
) is
106 Units
.Increment_Last
;
107 Units
.Table
(Units
.Last
) :=
108 (Unit_File_Name
=> File_Name
(S
),
109 Unit_Name
=> No_Unit_Name
,
110 Expected_Unit
=> No_Unit_Name
,
113 Cunit_Entity
=> Empty
,
115 Dynamic_Elab
=> False,
117 Generate_Code
=> False,
120 Ident_String
=> Empty
,
121 Is_Predefined_Renaming
=> False,
122 Is_Internal_Unit
=> False,
123 Is_Predefined_Unit
=> False,
129 No_Elab_Code_All
=> False,
130 Primary_Stack_Count
=> 0,
131 Sec_Stack_Count
=> 0,
134 Error_Location
=> No_Location
,
136 end Add_Preprocessing_Dependency
;
138 ------------------------------
139 -- Ensure_System_Dependency --
140 ------------------------------
142 procedure Ensure_System_Dependency
is
143 System_Uname
: constant Unit_Name_Type
:=
144 Name_To_Unit_Name
(Name_System
);
145 -- Unit name for system spec if needed for dummy entry
147 System_Fname
: File_Name_Type
;
148 -- File name for system spec if needed for dummy entry
151 -- Nothing to do if we already compiled System
153 if Is_Loaded
(System_Uname
) then
157 -- If no entry for system.ads in the units table, then add a entry
158 -- to the units table for system.ads, which will be referenced when
159 -- the ali file is generated. We need this because every unit depends
160 -- on system as a result of Targparm scanning the system.ads file to
161 -- determine the target dependent parameters for the compilation.
163 System_Fname
:= File_Name
(System_Source_File_Index
);
165 Units
.Increment_Last
;
166 Units
.Table
(Units
.Last
) :=
167 (Unit_File_Name
=> System_Fname
,
168 Unit_Name
=> System_Uname
,
169 Expected_Unit
=> System_Uname
,
170 Source_Index
=> System_Source_File_Index
,
172 Cunit_Entity
=> Empty
,
174 Dynamic_Elab
=> False,
176 Generate_Code
=> False,
179 Ident_String
=> Empty
,
180 Is_Predefined_Renaming
=> False,
181 Is_Internal_Unit
=> True,
182 Is_Predefined_Unit
=> True,
188 No_Elab_Code_All
=> False,
189 Primary_Stack_Count
=> 0,
190 Sec_Stack_Count
=> 0,
193 Error_Location
=> No_Location
,
195 Init_Unit_Name
(Units
.Last
, System_Uname
);
197 -- Parse system.ads so that the checksum is set right. Style checks are
198 -- not applied. The Ekind is set to ensure that this reference is always
199 -- present in the ali file.
202 Save_Mindex
: constant Nat
:= Multiple_Unit_Index
;
203 Save_Style
: constant Boolean := Style_Check
;
205 Multiple_Unit_Index
:= 0;
206 Style_Check
:= False;
207 Initialize_Scanner
(Units
.Last
, System_Source_File_Index
);
208 Discard_List
(Par
(Configuration_Pragmas
=> False));
209 Mutate_Ekind
(Cunit_Entity
(Units
.Last
), E_Package
);
210 Set_Scope
(Cunit_Entity
(Units
.Last
), Standard_Standard
);
211 Style_Check
:= Save_Style
;
212 Multiple_Unit_Index
:= Save_Mindex
;
214 end Ensure_System_Dependency
;
220 function Present
(N_Id
: Name_Id
) return Boolean is
222 return N_Id
/= No_Name
;
229 procedure Write_ALI
(Object
: Boolean) is
235 Last_Unit
: constant Unit_Number_Type
:= Units
.Last
;
236 -- Record unit number of last unit. We capture this in case we
237 -- have to add a dummy entry to the unit table for package System.
239 With_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
240 -- Array of flags to show which units are with'ed
242 Elab_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
243 -- Array of flags to show which units have pragma Elaborate set
245 Elab_All_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
246 -- Array of flags to show which units have pragma Elaborate All set
248 Elab_Des_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
249 -- Array of flags to show which units have Elaborate_Desirable set
251 Elab_All_Des_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
252 -- Array of flags to show which units have Elaborate_All_Desirable set
254 type Yes_No
is (Unknown
, Yes
, No
);
255 Has_Implicit_With
: array (Units
.First
.. Last_Unit
) of Yes_No
;
256 -- Indicates if an implicit with has been given for the unit. Yes if
257 -- certainly present, No if certainly absent, Unknown if not known.
259 Sdep_Table
: Unit_Ref_Table
(1 .. Pos
(Last_Unit
- Units
.First
+ 2));
260 -- Sorted table of source dependencies. One extra entry in case we
261 -- have to add a dummy entry for System.
264 -- Number of active entries in Sdep_Table
266 -----------------------
267 -- Local Subprograms --
268 -----------------------
270 procedure Collect_Withs
(Cunit
: Node_Id
);
271 -- Collect with lines for entries in the context clause of the given
272 -- compilation unit, Cunit.
274 procedure Output_CUDA_Symbols
(Unit_Num
: Unit_Number_Type
);
275 -- Output CUDA symbols, so that the rest of the toolchain may know what
276 -- symbols need registering with the CUDA runtime.
278 procedure Write_Unit_Information
(Unit_Num
: Unit_Number_Type
);
279 -- Write out the library information for one unit for which code is
280 -- generated (includes unit line and with lines).
282 procedure Write_With_Lines
;
283 -- Write out with lines collected by calls to Collect_Withs
289 procedure Collect_Withs
(Cunit
: Node_Id
) is
290 function Is_Implicit_With_Clause
(Clause
: Node_Id
) return Boolean;
291 pragma Inline
(Is_Implicit_With_Clause
);
292 -- Determine whether a with clause denoted by Clause is implicit
294 -----------------------------
295 -- Is_Implicit_With_Clause --
296 -----------------------------
298 function Is_Implicit_With_Clause
(Clause
: Node_Id
) return Boolean is
300 -- With clauses created for ancestor units are marked as internal,
301 -- however, they emulate the semantics in Ada RM 10.1.2 (6/2),
306 -- is almost equivalent to
311 -- For ALI encoding purposes, they are considered to be explicit.
312 -- Note that the clauses cannot be marked as explicit because they
313 -- will be subjected to various checks related to with clauses and
314 -- possibly cause false positives.
316 if Parent_With
(Clause
) then
320 return Implicit_With
(Clause
);
322 end Is_Implicit_With_Clause
;
327 Unum
: Unit_Number_Type
;
329 -- Start of processing for Collect_Withs
332 Item
:= First
(Context_Items
(Cunit
));
333 while Present
(Item
) loop
335 -- Process with clause
337 -- Ada 2005 (AI-50217): limited with_clauses do not create
338 -- dependencies, but must be recorded as components of the
339 -- partition, in case there is no regular with_clause for
340 -- the unit anywhere else.
342 if Nkind
(Item
) = N_With_Clause
then
343 Unum
:= Get_Cunit_Unit_Number
(Library_Unit
(Item
));
344 With_Flags
(Unum
) := True;
346 if not Limited_Present
(Item
) then
347 if Elaborate_Present
(Item
) then
348 Elab_Flags
(Unum
) := True;
351 if Elaborate_All_Present
(Item
) then
352 Elab_All_Flags
(Unum
) := True;
355 if Elaborate_All_Desirable
(Item
) then
356 Elab_All_Des_Flags
(Unum
) := True;
359 if Elaborate_Desirable
(Item
) then
360 Elab_Des_Flags
(Unum
) := True;
364 Set_From_Limited_With
(Cunit_Entity
(Unum
));
367 if Is_Implicit_With_Clause
(Item
) then
369 -- A previous explicit with clause withs the unit. Retain
370 -- this classification, as it reflects the source relations
373 if Has_Implicit_With
(Unum
) = No
then
376 -- Otherwise this is either the first time any clause withs
377 -- the unit, or the unit is already implicitly withed.
380 Has_Implicit_With
(Unum
) := Yes
;
383 -- Otherwise the current with clause is explicit. Such clauses
384 -- take precedence over existing implicit clauses because they
385 -- reflect the source relations between unit.
388 Has_Implicit_With
(Unum
) := No
;
396 -------------------------
397 -- Output_CUDA_Symbols --
398 -------------------------
400 procedure Output_CUDA_Symbols
(Unit_Num
: Unit_Number_Type
) is
401 Unit_Id
: constant Node_Id
:= Unit
(Cunit
(Unit_Num
));
404 Kernel_Elm
: Elmt_Id
;
407 if not Enable_CUDA_Expansion
408 or else Nkind
(Unit_Id
) = N_Null_Statement
412 Spec_Id
:= (if Nkind
(Unit_Id
) = N_Package_Body
413 then Corresponding_Spec
(Unit_Id
)
414 else Defining_Unit_Name
(Specification
(Unit_Id
)));
415 Kernels
:= Get_CUDA_Kernels
(Spec_Id
);
420 Kernel_Elm
:= First_Elmt
(Kernels
);
421 while Present
(Kernel_Elm
) loop
422 Kernel
:= Node
(Kernel_Elm
);
424 Write_Info_Initiate
('K');
425 Write_Info_Char
(' ');
426 Write_Info_Name
(Chars
(Kernel
));
427 Write_Info_Terminate
;
428 Next_Elmt
(Kernel_Elm
);
431 end Output_CUDA_Symbols
;
433 ----------------------------
434 -- Write_Unit_Information --
435 ----------------------------
437 procedure Write_Unit_Information
(Unit_Num
: Unit_Number_Type
) is
438 Unode
: constant Node_Id
:= Cunit
(Unit_Num
);
439 Ukind
: constant Node_Kind
:= Nkind
(Unit
(Unode
));
440 Uent
: constant Entity_Id
:= Cunit_Entity
(Unit_Num
);
444 Write_Info_Initiate
('U');
445 Write_Info_Char
(' ');
446 Write_Info_Name
(Unit_Name
(Unit_Num
));
448 Write_Info_Name
(Unit_File_Name
(Unit_Num
));
451 Write_Info_Str
(Version_Get
(Unit_Num
));
453 -- Add BD parameter if Elaborate_Body pragma desirable
455 if Ekind
(Uent
) = E_Package
456 and then Elaborate_Body_Desirable
(Uent
)
458 Write_Info_Str
(" BD");
461 -- Add BN parameter if body needed for SAL
463 if (Is_Subprogram
(Uent
)
464 or else Ekind
(Uent
) = E_Package
465 or else Is_Generic_Unit
(Uent
))
466 and then Body_Needed_For_SAL
(Uent
)
468 Write_Info_Str
(" BN");
471 if Dynamic_Elab
(Unit_Num
) then
472 Write_Info_Str
(" DE");
475 -- Set the Elaborate_Body indication if either an explicit pragma
476 -- was present, or if this is an instantiation.
478 if Has_Pragma_Elaborate_Body
(Uent
)
479 or else (Ukind
= N_Package_Declaration
480 and then Is_Generic_Instance
(Uent
)
481 and then Present
(Corresponding_Body
(Unit
(Unode
))))
483 Write_Info_Str
(" EB");
486 -- Now see if we should tell the binder that an elaboration entity
487 -- is present, which must be set to true during elaboration.
488 -- We generate the indication if the following condition is met:
490 -- If this is a spec ...
492 if (Is_Subprogram
(Uent
)
493 or else Ekind
(Uent
) = E_Package
494 or else Is_Generic_Unit
(Uent
))
496 -- and an elaboration entity was declared ...
498 and then Present
(Elaboration_Entity
(Uent
))
500 -- and either the elaboration flag is required ...
502 and then (Elaboration_Entity_Required
(Uent
)
504 -- or this unit has elaboration code ...
506 or else not Has_No_Elaboration_Code
(Unode
)
508 -- or this unit has a separate body and this
509 -- body has elaboration code.
512 (Ekind
(Uent
) = E_Package
513 and then Present
(Body_Entity
(Uent
))
515 not Has_No_Elaboration_Code
516 (Parent
(Declaration_Node
(Body_Entity
(Uent
))))))
518 Write_Info_Str
(" EE");
521 if Has_No_Elaboration_Code
(Unode
) then
522 Write_Info_Str
(" NE");
525 Write_Info_Str
(" O");
526 Write_Info_Char
(OA_Setting
(Unit_Num
));
528 -- For a package instance with a body that is a library unit, the two
529 -- compilation units share Cunit_Entity so we cannot rely on Uent.
531 if Ukind
in N_Package_Declaration | N_Package_Body
then
533 E
: constant Entity_Id
:= Defining_Entity
(Unit
(Unode
));
536 if Ekind
(E
) in E_Package | E_Package_Body
537 and then Present
(Finalizer
(E
))
539 Write_Info_Str
(" PF");
544 if Is_Preelaborated
(Uent
) then
545 Write_Info_Str
(" PR");
548 if Is_Pure
(Uent
) then
549 Write_Info_Str
(" PU");
552 if Has_RACW
(Unit_Num
) then
553 Write_Info_Str
(" RA");
556 if Is_Remote_Call_Interface
(Uent
) then
557 Write_Info_Str
(" RC");
560 if Is_Remote_Types
(Uent
) then
561 Write_Info_Str
(" RT");
564 if Serious_Errors_Detected
/= 0 then
565 Write_Info_Str
(" SE");
568 if Is_Shared_Passive
(Uent
) then
569 Write_Info_Str
(" SP");
572 if Ukind
= N_Subprogram_Declaration
573 or else Ukind
= N_Subprogram_Body
575 Write_Info_Str
(" SU");
577 elsif Ukind
= N_Package_Declaration
579 Ukind
= N_Package_Body
581 -- If this is a wrapper package for a subprogram instantiation,
582 -- the user view is the subprogram. Note that in this case the
583 -- ali file contains both the spec and body of the instance.
585 if Is_Wrapper_Package
(Uent
) then
586 Write_Info_Str
(" SU");
588 Write_Info_Str
(" PK");
591 elsif Ukind
= N_Generic_Package_Declaration
then
592 Write_Info_Str
(" PK");
596 if Ukind
in N_Generic_Declaration
598 (Present
(Library_Unit
(Unode
))
600 Nkind
(Unit
(Library_Unit
(Unode
))) in N_Generic_Declaration
)
602 Write_Info_Str
(" GE");
605 if not Is_Internal_Unit
(Unit_Num
) then
606 case Identifier_Casing
(Source_Index
(Unit_Num
)) is
607 when All_Lower_Case
=> Write_Info_Str
(" IL");
608 when All_Upper_Case
=> Write_Info_Str
(" IU");
612 case Keyword_Casing
(Source_Index
(Unit_Num
)) is
613 when Mixed_Case
=> Write_Info_Str
(" KM");
614 when All_Upper_Case
=> Write_Info_Str
(" KU");
619 if Initialize_Scalars
or else Invalid_Value_Used
then
620 Write_Info_Str
(" IS");
625 -- Generate with lines, first those that are directly with'ed
627 for J
in With_Flags
'Range loop
628 With_Flags
(J
) := False;
629 Elab_Flags
(J
) := False;
630 Elab_All_Flags
(J
) := False;
631 Elab_Des_Flags
(J
) := False;
632 Elab_All_Des_Flags
(J
) := False;
633 Has_Implicit_With
(J
) := Unknown
;
636 Collect_Withs
(Unode
);
638 -- For a body, we must also check for any subunits which belong to
639 -- it and which have context clauses of their own, since these
640 -- with'ed units are part of its own elaboration dependencies.
642 if Nkind
(Unit
(Unode
)) in N_Unit_Body
then
643 for S
in Units
.First
.. Last_Unit
loop
645 -- We are only interested in subunits. For preproc. data and
646 -- def. files, Cunit is Empty, so we need to test that first.
648 if Cunit
(S
) /= Empty
649 and then Nkind
(Unit
(Cunit
(S
))) = N_Subunit
651 Pnode
:= Library_Unit
(Cunit
(S
));
653 -- In gnatc mode, the errors in the subunits will not have
654 -- been recorded, but the analysis of the subunit may have
655 -- failed. There is no information to add to ALI file in
662 -- Find ultimate parent of the subunit
664 while Nkind
(Unit
(Pnode
)) = N_Subunit
loop
665 Pnode
:= Library_Unit
(Pnode
);
668 -- See if it belongs to current unit, and if so, include
671 if Pnode
= Unode
then
672 Collect_Withs
(Cunit
(S
));
680 -- Generate task stack lines
682 if Primary_Stack_Count
(Unit_Num
) > 0
683 or else Sec_Stack_Count
(Unit_Num
) > 0
685 Write_Info_Initiate
('T');
686 Write_Info_Char
(' ');
687 Write_Info_Int
(Primary_Stack_Count
(Unit_Num
));
688 Write_Info_Char
(' ');
689 Write_Info_Int
(Sec_Stack_Count
(Unit_Num
));
693 -- Generate the linker option lines
695 for J
in 1 .. Linker_Option_Lines
.Last
loop
697 -- Pragma Linker_Options is not allowed in predefined generic
698 -- units. This is because they won't be read, due to the fact that
699 -- with lines for generic units lack the file name and lib name
700 -- parameters (see Lib_Writ spec for an explanation).
702 if Is_Generic_Unit
(Cunit_Entity
(Main_Unit
))
703 and then Is_Predefined_Unit
(Current_Sem_Unit
)
704 and then Linker_Option_Lines
.Table
(J
).Unit
= Unit_Num
708 ("linker options not allowed in predefined generic unit");
709 raise Unrecoverable_Error
;
712 -- Output one linker option line
715 S
: Linker_Option_Entry
renames Linker_Option_Lines
.Table
(J
);
717 if S
.Unit
= Unit_Num
then
718 Write_Info_Initiate
('L');
719 Write_Info_Char
(' ');
720 Write_Info_Slit
(S
.Option
);
728 for J
in 1 .. Notes
.Last
loop
730 N
: constant Node_Id
:= Notes
.Table
(J
);
731 L
: constant Source_Ptr
:= Sloc
(N
);
732 U
: constant Unit_Number_Type
:=
733 Unit
(Get_Source_File_Index
(L
));
736 Note_Unit
: Unit_Number_Type
;
737 -- The unit in whose U section this note must be emitted:
738 -- notes for subunits are emitted along with the main unit;
739 -- all other notes are emitted as part of the enclosing
743 if U
/= No_Unit
and then Nkind
(Unit
(Cunit
(U
))) = N_Subunit
745 Note_Unit
:= Main_Unit
;
750 -- No action needed for pragmas removed by the expander (for
751 -- example, pragmas of ignored ghost entities).
753 if Nkind
(N
) = N_Null_Statement
then
754 pragma Assert
(Nkind
(Original_Node
(N
)) = N_Pragma
);
757 elsif Note_Unit
= Unit_Num
then
758 Write_Info_Initiate
('N');
759 Write_Info_Char
(' ');
761 case Pragma_Name
(N
) is
762 when Name_Annotate | Name_GNAT_Annotate
=>
770 when Name_Subtitle
=>
777 Write_Info_Int
(Int
(Get_Logical_Line_Number
(L
)));
778 Write_Info_Char
(':');
779 Write_Info_Int
(Int
(Get_Column_Number
(L
)));
781 -- Indicate source file of annotation if different from
782 -- compilation unit source file (case of annotation coming
785 if Get_Source_File_Index
(L
) /= Source_Index
(Unit_Num
) then
786 Write_Info_Char
(':');
787 Write_Info_Name
(File_Name
(Get_Source_File_Index
(L
)));
794 A
:= First
(Pragma_Argument_Associations
(N
));
795 while Present
(A
) loop
796 Write_Info_Char
(' ');
798 if Chars
(A
) /= No_Name
then
799 Write_Info_Name
(Chars
(A
));
800 Write_Info_Char
(':');
804 Expr
: constant Node_Id
:= Expression
(A
);
807 if Nkind
(Expr
) = N_Identifier
then
808 Write_Info_Name
(Chars
(Expr
));
810 elsif Nkind
(Expr
) = N_Integer_Literal
811 and then Is_OK_Static_Expression
(Expr
)
813 Write_Info_Uint
(Intval
(Expr
));
815 elsif Nkind
(Expr
) = N_String_Literal
816 and then Is_OK_Static_Expression
(Expr
)
818 Write_Info_Slit
(Strval
(Expr
));
821 Write_Info_Str
("<expr>");
833 end Write_Unit_Information
;
835 ----------------------
836 -- Write_With_Lines --
837 ----------------------
839 procedure Write_With_Lines
is
840 Pname
: constant Unit_Name_Type
:=
841 Get_Parent_Spec_Name
(Unit_Name
(Main_Unit
));
842 Body_Fname
: File_Name_Type
;
845 Fname
: File_Name_Type
;
846 Num_Withs
: Int
:= 0;
847 Unum
: Unit_Number_Type
;
848 Uname
: Unit_Name_Type
;
849 With_Table
: Unit_Ref_Table
(1 .. Pos
(Last_Unit
- Units
.First
+ 1));
851 procedure Write_With_File_Names
852 (Nam
: in out File_Name_Type
;
854 -- Write source file name Nam and ALI file name for unit index Idx.
855 -- Possibly change Nam to lowercase (generating a new file name).
857 ---------------------------
858 -- Write_With_File_Names --
859 ---------------------------
861 procedure Write_With_File_Names
862 (Nam
: in out File_Name_Type
;
866 if not File_Names_Case_Sensitive
then
867 Get_Name_String
(Nam
);
868 To_Lower
(Name_Buffer
(1 .. Name_Len
));
872 Write_Info_Name
(Nam
);
874 Write_Info_Name
(Lib_File_Name
(Nam
, Idx
));
875 end Write_With_File_Names
;
877 -- Start of processing for Write_With_Lines
880 -- Loop to build the with table. A with on the main unit itself
881 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
882 -- the main unit is a subprogram with no spec, and a subunit of
883 -- it unnecessarily withs the parent.
885 for J
in Units
.First
+ 1 .. Last_Unit
loop
887 -- Add element to with table if it is with'ed or if it is the
888 -- parent spec of the main unit (case of main unit is a child
889 -- unit). The latter with is not needed for semantic purposes,
890 -- but is required by the binder for elaboration purposes. For
891 -- preprocessing data and definition files, there is no Unit_Name,
892 -- check for that first.
894 if Present
(Unit_Name
(J
))
895 and then (With_Flags
(J
) or else Unit_Name
(J
) = Pname
)
897 Num_Withs
:= Num_Withs
+ 1;
898 With_Table
(Num_Withs
) := J
;
902 -- Sort and output the table
904 Sort
(With_Table
(1 .. Num_Withs
));
906 for J
in 1 .. Num_Withs
loop
907 Unum
:= With_Table
(J
);
909 -- Do not generate a with line for an ignored Ghost unit because
910 -- the unit does not have an ALI file.
912 if Is_Ignored_Ghost_Entity
(Cunit_Entity
(Unum
)) then
916 Cunit
:= Units
.Table
(Unum
).Cunit
;
917 Uname
:= Units
.Table
(Unum
).Unit_Name
;
918 Fname
:= Units
.Table
(Unum
).Unit_File_Name
;
920 -- Limited with clauses must be processed first because they are
921 -- the most specific among the three kinds.
923 if Ekind
(Cunit_Entity
(Unum
)) = E_Package
924 and then From_Limited_With
(Cunit_Entity
(Unum
))
926 Write_Info_Initiate
('Y');
928 elsif Has_Implicit_With
(Unum
) = Yes
then
929 Write_Info_Initiate
('Z');
932 Write_Info_Initiate
('W');
935 Write_Info_Char
(' ');
936 Write_Info_Name
(Uname
);
938 -- Now we need to figure out the names of the files that contain
939 -- the with'ed unit. These will usually be the files for the body,
940 -- except in the case of a package that has no body. Note that we
941 -- have a specific exemption here for predefined library generics
942 -- (see comments for Generic_May_Lack_ALI). We do not generate
943 -- dependency upon the ALI file for such units. Older compilers
944 -- used to not support generating code (and ALI) for generics, and
945 -- we want to avoid having different processing (namely, different
946 -- lists of files to be compiled) for different stages of the
949 if not ((Nkind
(Unit
(Cunit
)) in N_Generic_Declaration
951 Nkind
(Unit
(Cunit
)) in N_Generic_Renaming_Declaration
)
952 and then Generic_May_Lack_ALI
(Unum
))
954 -- In SPARK mode, always generate the dependencies on ALI
955 -- files, which are required to compute frame conditions
958 or else GNATprove_Mode
962 if Is_Spec_Name
(Uname
) then
965 (Uname
=> Get_Body_Name
(Uname
),
969 Body_Index
:= Get_Unit_Index
(Get_Body_Name
(Uname
));
971 if Body_Fname
= No_File
then
972 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
973 Body_Index
:= Get_Unit_Index
(Uname
);
976 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
977 Body_Index
:= Get_Unit_Index
(Uname
);
980 -- A package is considered to have a body if it requires
981 -- a body or if a body is present in Ada 83 mode.
983 if Body_Required
(Cunit
)
984 or else (Ada_Version
= Ada_83
985 and then Full_Source_Name
(Body_Fname
) /= No_File
)
987 Write_With_File_Names
(Body_Fname
, Body_Index
);
989 Write_With_File_Names
(Fname
, Munit_Index
(Unum
));
992 if Ekind
(Cunit_Entity
(Unum
)) = E_Package
993 and then From_Limited_With
(Cunit_Entity
(Unum
))
997 if Elab_Flags
(Unum
) then
998 Write_Info_Str
(" E");
1001 if Elab_All_Flags
(Unum
) then
1002 Write_Info_Str
(" EA");
1005 if Elab_Des_Flags
(Unum
) then
1006 Write_Info_Str
(" ED");
1009 if Elab_All_Des_Flags
(Unum
) then
1010 Write_Info_Str
(" AD");
1021 -- Finally generate the special lines for cases of Restriction_Set
1022 -- with No_Dependence and no restriction present.
1025 Unam
: Unit_Name_Type
;
1028 for J
in Restriction_Set_Dependences
.First
..
1029 Restriction_Set_Dependences
.Last
1031 Unam
:= Restriction_Set_Dependences
.Table
(J
);
1033 -- Don't need an entry if already in the unit table
1035 for U
in 0 .. Last_Unit
loop
1036 if Unit_Name
(U
) = Unam
then
1037 goto Next_Restriction_Set
;
1041 -- Otherwise generate the entry
1043 Write_Info_Initiate
('W');
1044 Write_Info_Char
(' ');
1045 Write_Info_Name
(Unam
);
1048 <<Next_Restriction_Set
>>
1052 end Write_With_Lines
;
1054 -- Start of processing for Write_ALI
1057 -- We never write an ALI file if the original operating mode was
1058 -- syntax-only (-gnats switch used in compiler invocation line).
1060 if Original_Operating_Mode
= Check_Syntax
then
1064 -- Generation of ALI files may be disabled, e.g. for formal verification
1067 if Disable_ALI_File
then
1071 -- Build sorted source dependency table
1073 for Unum
in Units
.First
.. Last_Unit
loop
1074 if Cunit_Entity
(Unum
) = Empty
1075 or else not From_Limited_With
(Cunit_Entity
(Unum
))
1077 -- Units that are not analyzed need not appear in the dependency
1078 -- list. These units are either units appearing in limited_with
1079 -- clauses of other units, or units loaded for inlining that end
1080 -- up not inlined by a later decision of the inlining code, to
1081 -- prevent circularities. We want to exclude these files from the
1082 -- list of dependencies, so that the dependency number of other
1083 -- is correctly set, as that number is used by cross-reference
1084 -- tools to relate entity information to the unit in which they
1087 if Present
(Cunit_Entity
(Unum
))
1088 and then Ekind
(Cunit_Entity
(Unum
)) = E_Void
1089 and then Nkind
(Unit
(Cunit
(Unum
))) /= N_Subunit
1090 and then Serious_Errors_Detected
= 0
1095 Num_Sdep
:= Num_Sdep
+ 1;
1096 Sdep_Table
(Num_Sdep
) := Unum
;
1101 -- Sort the table so that the D lines are in order
1103 Lib
.Sort
(Sdep_Table
(1 .. Num_Sdep
));
1105 -- Acquire compilation arguments and prepare to write out a new ali
1108 Create_Output_Library_Info
;
1110 -- Output version line
1112 Write_Info_Initiate
('V');
1113 Write_Info_Str
(" """);
1114 Write_Info_Str
(Verbose_Library_Version
);
1115 Write_Info_Char
('"');
1119 -- Output main program line if this is acceptable main program
1121 Output_Main_Program_Line
: declare
1122 U
: Node_Id
:= Unit
(Units
.Table
(Main_Unit
).Cunit
);
1125 procedure M_Parameters
;
1126 -- Output parameters for main program line
1132 procedure M_Parameters
is
1134 if Main_Priority
(Main_Unit
) /= Default_Main_Priority
then
1135 Write_Info_Char
(' ');
1136 Write_Info_Nat
(Main_Priority
(Main_Unit
));
1139 if Opt
.Time_Slice_Set
then
1140 Write_Info_Str
(" T=");
1141 Write_Info_Nat
(Opt
.Time_Slice_Value
);
1144 if Main_CPU
(Main_Unit
) /= Default_Main_CPU
then
1145 Write_Info_Str
(" C=");
1146 Write_Info_Nat
(Main_CPU
(Main_Unit
));
1149 Write_Info_Str
(" W=");
1151 (WC_Encoding_Letters
(Wide_Character_Encoding_Method
));
1156 -- Start of processing for Output_Main_Program_Line
1159 if Nkind
(U
) = N_Subprogram_Body
1161 (Nkind
(U
) = N_Package_Body
1163 Nkind
(Original_Node
(U
)) in N_Subprogram_Instantiation
)
1165 -- If the unit is a subprogram instance, the entity for the
1166 -- subprogram is the alias of the visible entity, which is the
1167 -- related instance of the wrapper package. We retrieve the
1168 -- subprogram declaration of the desired entity.
1170 if Nkind
(U
) = N_Package_Body
then
1171 U
:= Parent
(Parent
(
1172 Alias
(Related_Instance
(Defining_Unit_Name
1173 (Specification
(Unit
(Library_Unit
(Parent
(U
)))))))));
1176 S
:= Specification
(U
);
1178 -- A generic subprogram is never a main program
1180 if Nkind
(U
) = N_Subprogram_Body
1181 and then Present
(Corresponding_Spec
(U
))
1182 and then Is_Generic_Subprogram
(Corresponding_Spec
(U
))
1186 elsif No
(Parameter_Specifications
(S
)) then
1187 if Nkind
(S
) = N_Procedure_Specification
then
1188 Write_Info_Initiate
('M');
1189 Write_Info_Str
(" P");
1194 Nam
: Node_Id
:= Defining_Unit_Name
(S
);
1197 -- If it is a child unit, get its simple name
1199 if Nkind
(Nam
) = N_Defining_Program_Unit_Name
then
1200 Nam
:= Defining_Identifier
(Nam
);
1203 if Is_Integer_Type
(Etype
(Nam
)) then
1204 Write_Info_Initiate
('M');
1205 Write_Info_Str
(" F");
1212 end Output_Main_Program_Line
;
1214 -- Write command argument ('A') lines
1216 for A
in 1 .. Compilation_Switches
.Last
loop
1217 Write_Info_Initiate
('A');
1218 Write_Info_Char
(' ');
1219 Write_Info_Str
(Compilation_Switches
.Table
(A
).all);
1220 Write_Info_Terminate
;
1223 -- Output CUDA Kernel lines
1225 for Unit
in Units
.First
.. Last_Unit
loop
1226 if Present
(Cunit
(Unit
)) then
1227 Output_CUDA_Symbols
(Unit
);
1231 -- Output parameters ('P') line
1233 Write_Info_Initiate
('P');
1235 if Compilation_Errors
then
1236 Write_Info_Str
(" CE");
1239 if Opt
.Detect_Blocking
then
1240 Write_Info_Str
(" DB");
1243 if Tasking_Used
and then not Is_Predefined_Unit
(Main_Unit
) then
1244 if Locking_Policy
/= ' ' then
1245 Write_Info_Str
(" L");
1246 Write_Info_Char
(Locking_Policy
);
1249 if Queuing_Policy
/= ' ' then
1250 Write_Info_Str
(" Q");
1251 Write_Info_Char
(Queuing_Policy
);
1254 if Task_Dispatching_Policy
/= ' ' then
1255 Write_Info_Str
(" T");
1256 Write_Info_Char
(Task_Dispatching_Policy
);
1257 Write_Info_Char
(' ');
1261 if GNATprove_Mode
then
1262 Write_Info_Str
(" GP");
1265 if Partition_Elaboration_Policy
/= ' ' then
1266 Write_Info_Str
(" E");
1267 Write_Info_Char
(Partition_Elaboration_Policy
);
1270 if No_Component_Reordering_Config
then
1271 Write_Info_Str
(" NC");
1275 Write_Info_Str
(" NO");
1278 if No_Run_Time_Mode
then
1279 Write_Info_Str
(" NR");
1282 if Normalize_Scalars
then
1283 Write_Info_Str
(" NS");
1286 if Default_SSO_Config
/= ' ' then
1287 Write_Info_Str
(" O");
1288 Write_Info_Char
(Default_SSO_Config
);
1291 if Sec_Stack_Used
then
1292 Write_Info_Str
(" SS");
1295 if Unreserve_All_Interrupts
then
1296 Write_Info_Str
(" UA");
1299 if ZCX_Exceptions
then
1300 Write_Info_Str
(" ZX");
1305 -- Before outputting the restrictions line, update the setting of
1306 -- the No_Elaboration_Code flag. Violations of this restriction
1307 -- cannot be detected until after the backend has been called since
1308 -- it is the backend that sets this flag. We have to check all units
1309 -- for which we have generated code
1311 for Unit
in Units
.First
.. Last_Unit
loop
1312 if Units
.Table
(Unit
).Generate_Code
then
1313 if not Has_No_Elaboration_Code
(Cunit
(Unit
)) then
1314 Main_Restrictions
.Violated
(No_Elaboration_Code
) := True;
1320 -- Positional case (only if debug flag -gnatd.R is set)
1322 if Debug_Flag_Dot_RR
then
1324 -- Output first restrictions line
1326 Write_Info_Initiate
('R');
1327 Write_Info_Char
(' ');
1329 -- First the information for the boolean restrictions
1331 for R
in All_Boolean_Restrictions
loop
1332 if Main_Restrictions
.Set
(R
)
1333 and then not Restriction_Warnings
(R
)
1335 Write_Info_Char
('r');
1336 elsif Main_Restrictions
.Violated
(R
) then
1337 Write_Info_Char
('v');
1339 Write_Info_Char
('n');
1343 -- And now the information for the parameter restrictions
1345 for RP
in All_Parameter_Restrictions
loop
1346 if Main_Restrictions
.Set
(RP
)
1347 and then not Restriction_Warnings
(RP
)
1349 Write_Info_Char
('r');
1350 Write_Info_Nat
(Nat
(Main_Restrictions
.Value
(RP
)));
1352 Write_Info_Char
('n');
1355 if not Main_Restrictions
.Violated
(RP
)
1356 or else RP
not in Checked_Parameter_Restrictions
1358 Write_Info_Char
('n');
1360 Write_Info_Char
('v');
1361 Write_Info_Nat
(Nat
(Main_Restrictions
.Count
(RP
)));
1363 if Main_Restrictions
.Unknown
(RP
) then
1364 Write_Info_Char
('+');
1371 -- Named case (if debug flag -gnatd.R is not set)
1378 -- Write RN header line with preceding blank line
1381 Write_Info_Initiate
('R');
1382 Write_Info_Char
('N');
1385 -- First the lines for the boolean restrictions
1387 for R
in All_Boolean_Restrictions
loop
1388 if Main_Restrictions
.Set
(R
)
1389 and then not Restriction_Warnings
(R
)
1392 elsif Main_Restrictions
.Violated
(R
) then
1398 Write_Info_Initiate
('R');
1399 Write_Info_Char
(C
);
1400 Write_Info_Char
(' ');
1401 Write_Info_Str
(All_Boolean_Restrictions
'Image (R
));
1409 -- And now the lines for the parameter restrictions
1411 for RP
in All_Parameter_Restrictions
loop
1412 if Main_Restrictions
.Set
(RP
)
1413 and then not Restriction_Warnings
(RP
)
1415 Write_Info_Initiate
('R');
1416 Write_Info_Str
("R ");
1417 Write_Info_Str
(All_Parameter_Restrictions
'Image (RP
));
1418 Write_Info_Char
('=');
1419 Write_Info_Nat
(Nat
(Main_Restrictions
.Value
(RP
)));
1423 if not Main_Restrictions
.Violated
(RP
)
1424 or else RP
not in Checked_Parameter_Restrictions
1428 Write_Info_Initiate
('R');
1429 Write_Info_Str
("V ");
1430 Write_Info_Str
(All_Parameter_Restrictions
'Image (RP
));
1431 Write_Info_Char
('=');
1432 Write_Info_Nat
(Nat
(Main_Restrictions
.Count
(RP
)));
1434 if Main_Restrictions
.Unknown
(RP
) then
1435 Write_Info_Char
('+');
1443 -- Output R lines for No_Dependence entries
1445 for J
in No_Dependences
.First
.. No_Dependences
.Last
loop
1446 if In_Extended_Main_Source_Unit
(No_Dependences
.Table
(J
).Unit
)
1447 and then not No_Dependences
.Table
(J
).Warn
1449 Write_Info_Initiate
('R');
1450 Write_Info_Char
(' ');
1451 Write_Unit_Name
(No_Dependences
.Table
(J
).Unit
);
1456 -- Output interrupt state lines
1458 for J
in Interrupt_States
.First
.. Interrupt_States
.Last
loop
1459 Write_Info_Initiate
('I');
1460 Write_Info_Char
(' ');
1461 Write_Info_Nat
(Interrupt_States
.Table
(J
).Interrupt_Number
);
1462 Write_Info_Char
(' ');
1463 Write_Info_Char
(Interrupt_States
.Table
(J
).Interrupt_State
);
1464 Write_Info_Char
(' ');
1466 (Nat
(Get_Logical_Line_Number
1467 (Interrupt_States
.Table
(J
).Pragma_Loc
)));
1471 -- Output priority specific dispatching lines
1473 for J
in Specific_Dispatching
.First
.. Specific_Dispatching
.Last
loop
1474 Write_Info_Initiate
('S');
1475 Write_Info_Char
(' ');
1476 Write_Info_Char
(Specific_Dispatching
.Table
(J
).Dispatching_Policy
);
1477 Write_Info_Char
(' ');
1478 Write_Info_Nat
(Specific_Dispatching
.Table
(J
).First_Priority
);
1479 Write_Info_Char
(' ');
1480 Write_Info_Nat
(Specific_Dispatching
.Table
(J
).Last_Priority
);
1481 Write_Info_Char
(' ');
1483 (Nat
(Get_Logical_Line_Number
1484 (Specific_Dispatching
.Table
(J
).Pragma_Loc
)));
1488 -- Loop through file table to output information for all units for which
1489 -- we have generated code, as marked by the Generate_Code flag.
1491 for Unit
in Units
.First
.. Last_Unit
loop
1492 if Units
.Table
(Unit
).Generate_Code
1493 or else Unit
= Main_Unit
1495 Write_Info_EOL
; -- blank line
1496 Write_Unit_Information
(Unit
);
1500 Write_Info_EOL
; -- blank line
1502 -- Output external version reference lines
1504 for J
in 1 .. Version_Ref
.Last
loop
1505 Write_Info_Initiate
('E');
1506 Write_Info_Char
(' ');
1508 for K
in 1 .. String_Length
(Version_Ref
.Table
(J
)) loop
1509 Write_Info_Char_Code
(Get_String_Char
(Version_Ref
.Table
(J
), K
));
1515 -- Prepare to output the source dependency lines
1518 Unum
: Unit_Number_Type
;
1519 -- Number of unit being output
1521 Sind
: Source_File_Index
;
1522 -- Index of corresponding source file
1524 Fname
: File_Name_Type
;
1527 for J
in 1 .. Num_Sdep
loop
1528 Unum
:= Sdep_Table
(J
);
1529 Units
.Table
(Unum
).Dependency_Num
:= J
;
1530 Sind
:= Source_Index
(Unum
);
1532 Write_Info_Initiate
('D');
1533 Write_Info_Char
(' ');
1535 -- Normal case of a unit entry with a source index
1537 if Sind
> No_Source_File
then
1539 if Config_Files_Store_Basename
then
1540 Fname
:= Strip_Directory
(File_Name
(Sind
));
1542 Fname
:= File_Name
(Sind
);
1545 -- Ensure that on platforms where the file names are not
1546 -- case sensitive, the recorded file name is in lower case.
1548 if not File_Names_Case_Sensitive
then
1549 Get_Name_String
(Fname
);
1550 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1554 Write_Info_Name_May_Be_Quoted
(Fname
);
1555 Write_Info_Tab
(25);
1556 Write_Info_Str
(String (Time_Stamp
(Sind
)));
1557 Write_Info_Char
(' ');
1558 Write_Info_Str
(Get_Hex_String
(Source_Checksum
(Sind
)));
1560 -- If the dependency comes from a limited_with clause, record
1561 -- limited_checksum. This is disabled until full checksum
1562 -- changes are checked.
1564 -- if Present (Cunit_Entity (Unum))
1565 -- and then From_Limited_With (Cunit_Entity (Unum))
1567 -- Write_Info_Char (' ');
1568 -- Write_Info_Char ('Y');
1569 -- Write_Info_Str (Get_Hex_String (Limited_Chk_Sum (Sind)));
1572 -- If subunit, add unit name, omitting the %b at the end
1574 if Present
(Cunit
(Unum
)) then
1575 Get_Decoded_Name_String
(Unit_Name
(Unum
));
1576 Write_Info_Char
(' ');
1578 if Nkind
(Unit
(Cunit
(Unum
))) = N_Subunit
then
1579 Write_Info_Str
(Name_Buffer
(1 .. Name_Len
- 2));
1581 Write_Info_Str
(Name_Buffer
(1 .. Name_Len
));
1585 -- If Source_Reference pragma used, output information
1587 if Num_SRef_Pragmas
(Sind
) > 0 then
1588 Write_Info_Char
(' ');
1590 if Num_SRef_Pragmas
(Sind
) = 1 then
1591 Write_Info_Nat
(Int
(First_Mapped_Line
(Sind
)));
1596 Write_Info_Char
(':');
1597 Write_Info_Name
(Reference_Name
(Sind
));
1600 -- Case where there is no source index (happens for missing
1601 -- files). In this case we write a dummy time stamp.
1604 Write_Info_Name
(Unit_File_Name
(Unum
));
1605 Write_Info_Tab
(25);
1606 Write_Info_Str
(String (Dummy_Time_Stamp
));
1607 Write_Info_Char
(' ');
1608 Write_Info_Str
(Get_Hex_String
(0));
1615 -- Output the invocation graph
1617 Write_Invocation_Graph
;
1619 -- Output cross-references
1621 if Opt
.Xref_Active
then
1625 -- Output SCO information if present
1627 if Generate_SCO
then
1628 SCO_Record_Filtered
;
1632 -- Output final blank line and we are done. This final blank line is
1633 -- probably junk, but we don't feel like making an incompatible change.
1635 Write_Info_Terminate
;
1636 Close_Output_Library_Info
;
1639 --------------------------------
1640 -- Write_Invocation_Construct --
1641 --------------------------------
1643 procedure Write_Invocation_Construct
(IC_Id
: Invocation_Construct_Id
) is
1647 Write_Info_Initiate
('G');
1648 Write_Info_Char
(' ');
1653 (Invocation_Graph_Line_Kind_To_Code
(Invocation_Construct_Line
));
1654 Write_Info_Char
(' ');
1658 Write_Info_Char
(Invocation_Construct_Kind_To_Code
(Kind
(IC_Id
)));
1659 Write_Info_Char
(' ');
1661 -- construct-spec-placement
1664 (Declaration_Placement_Kind_To_Code
(Spec_Placement
(IC_Id
)));
1665 Write_Info_Char
(' ');
1667 -- construct-body-placement
1670 (Declaration_Placement_Kind_To_Code
(Body_Placement
(IC_Id
)));
1671 Write_Info_Char
(' ');
1673 -- construct-signature
1675 Write_Invocation_Signature
(Signature
(IC_Id
));
1677 end Write_Invocation_Construct
;
1679 ---------------------------------------
1680 -- Write_Invocation_Graph_Attributes --
1681 ---------------------------------------
1683 procedure Write_Invocation_Graph_Attributes
is
1687 Write_Info_Initiate
('G');
1688 Write_Info_Char
(' ');
1693 (Invocation_Graph_Line_Kind_To_Code
1694 (Invocation_Graph_Attributes_Line
));
1695 Write_Info_Char
(' ');
1700 (Invocation_Graph_Encoding_Kind_To_Code
(Invocation_Graph_Encoding
));
1702 end Write_Invocation_Graph_Attributes
;
1704 ----------------------------
1705 -- Write_Invocation_Graph --
1706 ----------------------------
1708 procedure Write_Invocation_Graph
is
1710 Write_Invocation_Graph_Attributes
;
1712 -- First write out all invocation constructs declared within the current
1713 -- unit. This ensures that when this invocation is read, the invocation
1714 -- constructs are materialized before they are referenced by invocation
1717 For_Each_Invocation_Construct
(Write_Invocation_Construct
'Access);
1719 -- Write out all invocation relations that originate from invocation
1720 -- constructs delared in the current unit.
1722 For_Each_Invocation_Relation
(Write_Invocation_Relation
'Access);
1723 end Write_Invocation_Graph
;
1725 -------------------------------
1726 -- Write_Invocation_Relation --
1727 -------------------------------
1729 procedure Write_Invocation_Relation
(IR_Id
: Invocation_Relation_Id
) is
1733 Write_Info_Initiate
('G');
1734 Write_Info_Char
(' ');
1739 (Invocation_Graph_Line_Kind_To_Code
(Invocation_Relation_Line
));
1740 Write_Info_Char
(' ');
1744 Write_Info_Char
(Invocation_Kind_To_Code
(Kind
(IR_Id
)));
1745 Write_Info_Char
(' ');
1747 -- (extra-name | "none")
1749 if Present
(Extra
(IR_Id
)) then
1750 Write_Info_Name
(Extra
(IR_Id
));
1752 Write_Info_Str
("none");
1755 Write_Info_Char
(' ');
1757 -- invoker-signature
1759 Write_Invocation_Signature
(Invoker
(IR_Id
));
1760 Write_Info_Char
(' ');
1764 Write_Invocation_Signature
(Target
(IR_Id
));
1767 end Write_Invocation_Relation
;
1769 --------------------------------
1770 -- Write_Invocation_Signature --
1771 --------------------------------
1773 procedure Write_Invocation_Signature
(IS_Id
: Invocation_Signature_Id
) is
1777 Write_Info_Char
('[');
1781 Write_Info_Name
(Name
(IS_Id
));
1782 Write_Info_Char
(' ');
1786 Write_Info_Name
(IS_Scope
(IS_Id
));
1787 Write_Info_Char
(' ');
1791 Write_Info_Nat
(Line
(IS_Id
));
1792 Write_Info_Char
(' ');
1796 Write_Info_Nat
(Column
(IS_Id
));
1797 Write_Info_Char
(' ');
1799 -- (locations | "none")
1801 if Present
(Locations
(IS_Id
)) then
1802 Write_Info_Name
(Locations
(IS_Id
));
1804 Write_Info_Str
("none");
1809 Write_Info_Char
(']');
1810 end Write_Invocation_Signature
;
1812 ---------------------
1813 -- Write_Unit_Name --
1814 ---------------------
1816 procedure Write_Unit_Name
(N
: Node_Id
) is
1818 if Nkind
(N
) = N_Identifier
then
1819 Write_Info_Name
(Chars
(N
));
1822 pragma Assert
(Nkind
(N
) = N_Selected_Component
);
1823 Write_Unit_Name
(Prefix
(N
));
1824 Write_Info_Char
('.');
1825 Write_Unit_Name
(Selector_Name
(N
));
1827 end Write_Unit_Name
;