1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2024, 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 RM 10.1.2 (6/2), where
305 -- is almost equivalent to
310 -- For ALI encoding purposes, they are considered to be explicit.
311 -- Note that the clauses cannot be marked as explicit because they
312 -- will be subjected to various checks related to with clauses and
313 -- possibly cause false positives.
315 if Parent_With
(Clause
) then
319 return Implicit_With
(Clause
);
321 end Is_Implicit_With_Clause
;
326 Unum
: Unit_Number_Type
;
328 -- Start of processing for Collect_Withs
331 Item
:= First
(Context_Items
(Cunit
));
332 while Present
(Item
) loop
334 -- Process with clause
336 -- Ada 2005 (AI-50217): limited with_clauses do not create
337 -- dependencies, but must be recorded as components of the
338 -- partition, in case there is no regular with_clause for
339 -- the unit anywhere else.
341 if Nkind
(Item
) = N_With_Clause
then
342 Unum
:= Get_Cunit_Unit_Number
(Library_Unit
(Item
));
343 With_Flags
(Unum
) := True;
345 if not Limited_Present
(Item
) then
346 if Elaborate_Present
(Item
) then
347 Elab_Flags
(Unum
) := True;
350 if Elaborate_All_Present
(Item
) then
351 Elab_All_Flags
(Unum
) := True;
354 if Elaborate_All_Desirable
(Item
) then
355 Elab_All_Des_Flags
(Unum
) := True;
358 if Elaborate_Desirable
(Item
) then
359 Elab_Des_Flags
(Unum
) := True;
363 Set_From_Limited_With
(Cunit_Entity
(Unum
));
366 if Is_Implicit_With_Clause
(Item
) then
368 -- A previous explicit with clause withs the unit. Retain
369 -- this classification, as it reflects the source relations
372 if Has_Implicit_With
(Unum
) = No
then
375 -- Otherwise this is either the first time any clause withs
376 -- the unit, or the unit is already implicitly withed.
379 Has_Implicit_With
(Unum
) := Yes
;
382 -- Otherwise the current with clause is explicit. Such clauses
383 -- take precedence over existing implicit clauses because they
384 -- reflect the source relations between unit.
387 Has_Implicit_With
(Unum
) := No
;
395 -------------------------
396 -- Output_CUDA_Symbols --
397 -------------------------
399 procedure Output_CUDA_Symbols
(Unit_Num
: Unit_Number_Type
) is
400 Unit_Id
: constant Node_Id
:= Unit
(Cunit
(Unit_Num
));
403 Kernel_Elm
: Elmt_Id
;
406 if not Enable_CUDA_Expansion
407 or else Nkind
(Unit_Id
) = N_Null_Statement
411 Spec_Id
:= (if Nkind
(Unit_Id
) = N_Package_Body
412 then Corresponding_Spec
(Unit_Id
)
413 else Defining_Unit_Name
(Specification
(Unit_Id
)));
414 Kernels
:= Get_CUDA_Kernels
(Spec_Id
);
419 Kernel_Elm
:= First_Elmt
(Kernels
);
420 while Present
(Kernel_Elm
) loop
421 Kernel
:= Node
(Kernel_Elm
);
423 Write_Info_Initiate
('K');
424 Write_Info_Char
(' ');
425 Write_Info_Name
(Chars
(Kernel
));
426 Write_Info_Terminate
;
427 Next_Elmt
(Kernel_Elm
);
430 end Output_CUDA_Symbols
;
432 ----------------------------
433 -- Write_Unit_Information --
434 ----------------------------
436 procedure Write_Unit_Information
(Unit_Num
: Unit_Number_Type
) is
437 Unode
: constant Node_Id
:= Cunit
(Unit_Num
);
438 Ukind
: constant Node_Kind
:= Nkind
(Unit
(Unode
));
439 Uent
: constant Entity_Id
:= Cunit_Entity
(Unit_Num
);
443 Write_Info_Initiate
('U');
444 Write_Info_Char
(' ');
445 Write_Info_Name
(Unit_Name
(Unit_Num
));
447 Write_Info_Name
(Unit_File_Name
(Unit_Num
));
450 Write_Info_Str
(Version_Get
(Unit_Num
));
452 -- Add BD parameter if Elaborate_Body pragma desirable
454 if Ekind
(Uent
) = E_Package
455 and then Elaborate_Body_Desirable
(Uent
)
457 Write_Info_Str
(" BD");
460 -- Add BN parameter if body needed for SAL
462 if (Is_Subprogram
(Uent
)
463 or else Ekind
(Uent
) = E_Package
464 or else Is_Generic_Unit
(Uent
))
465 and then Body_Needed_For_SAL
(Uent
)
467 Write_Info_Str
(" BN");
470 if Dynamic_Elab
(Unit_Num
) then
471 Write_Info_Str
(" DE");
474 -- Set the Elaborate_Body indication if either an explicit pragma
475 -- was present, or if this is an instantiation.
477 if Has_Pragma_Elaborate_Body
(Uent
)
478 or else (Ukind
= N_Package_Declaration
479 and then Is_Generic_Instance
(Uent
)
480 and then Present
(Corresponding_Body
(Unit
(Unode
))))
482 Write_Info_Str
(" EB");
485 -- Now see if we should tell the binder that an elaboration entity
486 -- is present, which must be set to true during elaboration.
487 -- We generate the indication if the following condition is met:
489 -- If this is a spec ...
491 if (Is_Subprogram
(Uent
)
492 or else Ekind
(Uent
) = E_Package
493 or else Is_Generic_Unit
(Uent
))
495 -- and an elaboration entity was declared ...
497 and then Present
(Elaboration_Entity
(Uent
))
499 -- and either the elaboration flag is required ...
501 and then (Elaboration_Entity_Required
(Uent
)
503 -- or this unit has elaboration code ...
505 or else not Has_No_Elaboration_Code
(Unode
)
507 -- or this unit has a separate body and this
508 -- body has elaboration code.
511 (Ekind
(Uent
) = E_Package
512 and then Present
(Body_Entity
(Uent
))
514 not Has_No_Elaboration_Code
515 (Parent
(Declaration_Node
(Body_Entity
(Uent
))))))
517 Write_Info_Str
(" EE");
520 if Has_No_Elaboration_Code
(Unode
) then
521 Write_Info_Str
(" NE");
524 Write_Info_Str
(" O");
525 Write_Info_Char
(OA_Setting
(Unit_Num
));
527 -- For a package instance with a body that is a library unit, the two
528 -- compilation units share Cunit_Entity so we cannot rely on Uent.
530 if Ukind
in N_Package_Declaration | N_Package_Body
then
532 E
: constant Entity_Id
:= Defining_Entity
(Unit
(Unode
));
535 if Ekind
(E
) in E_Package | E_Package_Body
536 and then Present
(Finalizer
(E
))
538 Write_Info_Str
(" PF");
543 if Is_Preelaborated
(Uent
) then
544 Write_Info_Str
(" PR");
547 if Is_Pure
(Uent
) then
548 Write_Info_Str
(" PU");
551 if Has_RACW
(Unit_Num
) then
552 Write_Info_Str
(" RA");
555 if Is_Remote_Call_Interface
(Uent
) then
556 Write_Info_Str
(" RC");
559 if Is_Remote_Types
(Uent
) then
560 Write_Info_Str
(" RT");
563 if Serious_Errors_Detected
/= 0 then
564 Write_Info_Str
(" SE");
567 if Is_Shared_Passive
(Uent
) then
568 Write_Info_Str
(" SP");
571 if Ukind
= N_Subprogram_Declaration
572 or else Ukind
= N_Subprogram_Body
574 Write_Info_Str
(" SU");
576 elsif Ukind
= N_Package_Declaration
578 Ukind
= N_Package_Body
580 -- If this is a wrapper package for a subprogram instantiation,
581 -- the user view is the subprogram. Note that in this case the
582 -- ali file contains both the spec and body of the instance.
584 if Is_Wrapper_Package
(Uent
) then
585 Write_Info_Str
(" SU");
587 Write_Info_Str
(" PK");
590 elsif Ukind
= N_Generic_Package_Declaration
then
591 Write_Info_Str
(" PK");
595 if Ukind
in N_Generic_Declaration
597 (Present
(Library_Unit
(Unode
))
599 Nkind
(Unit
(Library_Unit
(Unode
))) in N_Generic_Declaration
)
601 Write_Info_Str
(" GE");
604 if not Is_Internal_Unit
(Unit_Num
) then
605 case Identifier_Casing
(Source_Index
(Unit_Num
)) is
606 when All_Lower_Case
=> Write_Info_Str
(" IL");
607 when All_Upper_Case
=> Write_Info_Str
(" IU");
611 case Keyword_Casing
(Source_Index
(Unit_Num
)) is
612 when Mixed_Case
=> Write_Info_Str
(" KM");
613 when All_Upper_Case
=> Write_Info_Str
(" KU");
618 if Initialize_Scalars
or else Invalid_Value_Used
then
619 Write_Info_Str
(" IS");
624 -- Generate with lines, first those that are directly with'ed
626 for J
in With_Flags
'Range loop
627 With_Flags
(J
) := False;
628 Elab_Flags
(J
) := False;
629 Elab_All_Flags
(J
) := False;
630 Elab_Des_Flags
(J
) := False;
631 Elab_All_Des_Flags
(J
) := False;
632 Has_Implicit_With
(J
) := Unknown
;
635 Collect_Withs
(Unode
);
637 -- For a body, we must also check for any subunits which belong to
638 -- it and which have context clauses of their own, since these
639 -- with'ed units are part of its own elaboration dependencies.
641 if Nkind
(Unit
(Unode
)) in N_Unit_Body
then
642 for S
in Units
.First
.. Last_Unit
loop
644 -- We are only interested in subunits. For preproc. data and
645 -- def. files, Cunit is Empty, so we need to test that first.
647 if Cunit
(S
) /= Empty
648 and then Nkind
(Unit
(Cunit
(S
))) = N_Subunit
650 Pnode
:= Library_Unit
(Cunit
(S
));
652 -- In gnatc mode, the errors in the subunits will not have
653 -- been recorded, but the analysis of the subunit may have
654 -- failed. There is no information to add to ALI file in
661 -- Find ultimate parent of the subunit
663 while Nkind
(Unit
(Pnode
)) = N_Subunit
loop
664 Pnode
:= Library_Unit
(Pnode
);
667 -- See if it belongs to current unit, and if so, include
670 if Pnode
= Unode
then
671 Collect_Withs
(Cunit
(S
));
679 -- Generate task stack lines
681 if Primary_Stack_Count
(Unit_Num
) > 0
682 or else Sec_Stack_Count
(Unit_Num
) > 0
684 Write_Info_Initiate
('T');
685 Write_Info_Char
(' ');
686 Write_Info_Int
(Primary_Stack_Count
(Unit_Num
));
687 Write_Info_Char
(' ');
688 Write_Info_Int
(Sec_Stack_Count
(Unit_Num
));
692 -- Generate the linker option lines
694 for J
in 1 .. Linker_Option_Lines
.Last
loop
696 -- Pragma Linker_Options is not allowed in predefined generic
697 -- units. This is because they won't be read, due to the fact that
698 -- with lines for generic units lack the file name and lib name
699 -- parameters (see Lib_Writ spec for an explanation).
701 if Is_Generic_Unit
(Cunit_Entity
(Main_Unit
))
702 and then Is_Predefined_Unit
(Current_Sem_Unit
)
703 and then Linker_Option_Lines
.Table
(J
).Unit
= Unit_Num
707 ("linker options not allowed in predefined generic unit");
708 raise Unrecoverable_Error
;
711 -- Output one linker option line
714 S
: Linker_Option_Entry
renames Linker_Option_Lines
.Table
(J
);
716 if S
.Unit
= Unit_Num
then
717 Write_Info_Initiate
('L');
718 Write_Info_Char
(' ');
719 Write_Info_Slit
(S
.Option
);
727 for J
in 1 .. Notes
.Last
loop
729 N
: constant Node_Id
:= Notes
.Table
(J
);
730 L
: constant Source_Ptr
:= Sloc
(N
);
731 U
: constant Unit_Number_Type
:=
732 Unit
(Get_Source_File_Index
(L
));
735 Note_Unit
: Unit_Number_Type
;
736 -- The unit in whose U section this note must be emitted:
737 -- notes for subunits are emitted along with the main unit;
738 -- all other notes are emitted as part of the enclosing
742 if U
/= No_Unit
and then Nkind
(Unit
(Cunit
(U
))) = N_Subunit
744 Note_Unit
:= Main_Unit
;
749 -- No action needed for pragmas removed by the expander (for
750 -- example, pragmas of ignored ghost entities).
752 if Nkind
(N
) = N_Null_Statement
then
753 pragma Assert
(Nkind
(Original_Node
(N
)) = N_Pragma
);
756 elsif Note_Unit
= Unit_Num
then
757 Write_Info_Initiate
('N');
758 Write_Info_Char
(' ');
760 case Pragma_Name
(N
) is
761 when Name_Annotate | Name_GNAT_Annotate
=>
769 when Name_Subtitle
=>
776 Write_Info_Int
(Int
(Get_Logical_Line_Number
(L
)));
777 Write_Info_Char
(':');
778 Write_Info_Int
(Int
(Get_Column_Number
(L
)));
780 -- Indicate source file of annotation if different from
781 -- compilation unit source file (case of annotation coming
784 if Get_Source_File_Index
(L
) /= Source_Index
(Unit_Num
) then
785 Write_Info_Char
(':');
786 Write_Info_Name
(File_Name
(Get_Source_File_Index
(L
)));
793 A
:= First
(Pragma_Argument_Associations
(N
));
794 while Present
(A
) loop
795 Write_Info_Char
(' ');
797 if Chars
(A
) /= No_Name
then
798 Write_Info_Name
(Chars
(A
));
799 Write_Info_Char
(':');
803 Expr
: constant Node_Id
:= Expression
(A
);
806 if Nkind
(Expr
) = N_Identifier
then
807 Write_Info_Name
(Chars
(Expr
));
809 elsif Nkind
(Expr
) = N_Integer_Literal
810 and then Is_OK_Static_Expression
(Expr
)
812 Write_Info_Uint
(Intval
(Expr
));
814 elsif Nkind
(Expr
) = N_String_Literal
815 and then Is_OK_Static_Expression
(Expr
)
817 Write_Info_Slit
(Strval
(Expr
));
820 Write_Info_Str
("<expr>");
832 end Write_Unit_Information
;
834 ----------------------
835 -- Write_With_Lines --
836 ----------------------
838 procedure Write_With_Lines
is
839 Pname
: constant Unit_Name_Type
:=
840 Get_Parent_Spec_Name
(Unit_Name
(Main_Unit
));
841 Body_Fname
: File_Name_Type
;
844 Fname
: File_Name_Type
;
845 Num_Withs
: Int
:= 0;
846 Unum
: Unit_Number_Type
;
847 Uname
: Unit_Name_Type
;
848 With_Table
: Unit_Ref_Table
(1 .. Pos
(Last_Unit
- Units
.First
+ 1));
850 procedure Write_With_File_Names
851 (Nam
: in out File_Name_Type
;
853 -- Write source file name Nam and ALI file name for unit index Idx.
854 -- Possibly change Nam to lowercase (generating a new file name).
856 ---------------------------
857 -- Write_With_File_Names --
858 ---------------------------
860 procedure Write_With_File_Names
861 (Nam
: in out File_Name_Type
;
865 if not File_Names_Case_Sensitive
then
866 Get_Name_String
(Nam
);
867 To_Lower
(Name_Buffer
(1 .. Name_Len
));
871 Write_Info_Name
(Nam
);
873 Write_Info_Name
(Lib_File_Name
(Nam
, Idx
));
874 end Write_With_File_Names
;
876 -- Start of processing for Write_With_Lines
879 -- Loop to build the with table. A with on the main unit itself
880 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
881 -- the main unit is a subprogram with no spec, and a subunit of
882 -- it unnecessarily withs the parent.
884 for J
in Units
.First
+ 1 .. Last_Unit
loop
886 -- Add element to with table if it is with'ed or if it is the
887 -- parent spec of the main unit (case of main unit is a child
888 -- unit). The latter with is not needed for semantic purposes,
889 -- but is required by the binder for elaboration purposes. For
890 -- preprocessing data and definition files, there is no Unit_Name,
891 -- check for that first.
893 if Present
(Unit_Name
(J
))
894 and then (With_Flags
(J
) or else Unit_Name
(J
) = Pname
)
896 Num_Withs
:= Num_Withs
+ 1;
897 With_Table
(Num_Withs
) := J
;
901 -- Sort and output the table
903 Sort
(With_Table
(1 .. Num_Withs
));
905 for J
in 1 .. Num_Withs
loop
906 Unum
:= With_Table
(J
);
908 -- Do not generate a with line for an ignored Ghost unit because
909 -- the unit does not have an ALI file.
911 if Is_Ignored_Ghost_Entity
(Cunit_Entity
(Unum
)) then
915 Cunit
:= Units
.Table
(Unum
).Cunit
;
916 Uname
:= Units
.Table
(Unum
).Unit_Name
;
917 Fname
:= Units
.Table
(Unum
).Unit_File_Name
;
919 -- Limited with clauses must be processed first because they are
920 -- the most specific among the three kinds.
922 if Ekind
(Cunit_Entity
(Unum
)) = E_Package
923 and then From_Limited_With
(Cunit_Entity
(Unum
))
925 Write_Info_Initiate
('Y');
927 elsif Has_Implicit_With
(Unum
) = Yes
then
928 Write_Info_Initiate
('Z');
931 Write_Info_Initiate
('W');
934 Write_Info_Char
(' ');
935 Write_Info_Name
(Uname
);
937 -- Now we need to figure out the names of the files that contain
938 -- the with'ed unit. These will usually be the files for the body,
939 -- except in the case of a package that has no body. Note that we
940 -- have a specific exemption here for predefined library generics
941 -- (see comments for Generic_May_Lack_ALI). We do not generate
942 -- dependency upon the ALI file for such units. Older compilers
943 -- used to not support generating code (and ALI) for generics, and
944 -- we want to avoid having different processing (namely, different
945 -- lists of files to be compiled) for different stages of the
948 if not ((Nkind
(Unit
(Cunit
)) in N_Generic_Declaration
950 Nkind
(Unit
(Cunit
)) in N_Generic_Renaming_Declaration
)
951 and then Generic_May_Lack_ALI
(Unum
))
953 -- In SPARK mode, always generate the dependencies on ALI
954 -- files, which are required to compute frame conditions
957 or else GNATprove_Mode
961 if Is_Spec_Name
(Uname
) then
964 (Uname
=> Get_Body_Name
(Uname
),
968 Body_Index
:= Get_Unit_Index
(Get_Body_Name
(Uname
));
970 if Body_Fname
= No_File
then
971 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
972 Body_Index
:= Get_Unit_Index
(Uname
);
975 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
976 Body_Index
:= Get_Unit_Index
(Uname
);
979 -- A package is considered to have a body if it requires
980 -- a body or if a body is present in Ada 83 mode.
982 if Body_Required
(Cunit
)
983 or else (Ada_Version
= Ada_83
984 and then Full_Source_Name
(Body_Fname
) /= No_File
)
986 Write_With_File_Names
(Body_Fname
, Body_Index
);
988 Write_With_File_Names
(Fname
, Munit_Index
(Unum
));
991 if Ekind
(Cunit_Entity
(Unum
)) = E_Package
992 and then From_Limited_With
(Cunit_Entity
(Unum
))
996 if Elab_Flags
(Unum
) then
997 Write_Info_Str
(" E");
1000 if Elab_All_Flags
(Unum
) then
1001 Write_Info_Str
(" EA");
1004 if Elab_Des_Flags
(Unum
) then
1005 Write_Info_Str
(" ED");
1008 if Elab_All_Des_Flags
(Unum
) then
1009 Write_Info_Str
(" AD");
1020 -- Finally generate the special lines for cases of Restriction_Set
1021 -- with No_Dependence and no restriction present.
1024 Unam
: Unit_Name_Type
;
1027 for J
in Restriction_Set_Dependences
.First
..
1028 Restriction_Set_Dependences
.Last
1030 Unam
:= Restriction_Set_Dependences
.Table
(J
);
1032 -- Don't need an entry if already in the unit table
1034 for U
in 0 .. Last_Unit
loop
1035 if Unit_Name
(U
) = Unam
then
1036 goto Next_Restriction_Set
;
1040 -- Otherwise generate the entry
1042 Write_Info_Initiate
('W');
1043 Write_Info_Char
(' ');
1044 Write_Info_Name
(Unam
);
1047 <<Next_Restriction_Set
>>
1051 end Write_With_Lines
;
1053 -- Start of processing for Write_ALI
1056 -- We never write an ALI file if the original operating mode was
1057 -- syntax-only (-gnats switch used in compiler invocation line).
1059 if Original_Operating_Mode
= Check_Syntax
then
1063 -- Generation of ALI files may be disabled, e.g. for formal verification
1066 if Disable_ALI_File
then
1070 -- Build sorted source dependency table
1072 for Unum
in Units
.First
.. Last_Unit
loop
1073 if Cunit_Entity
(Unum
) = Empty
1074 or else not From_Limited_With
(Cunit_Entity
(Unum
))
1076 -- Units that are not analyzed need not appear in the dependency
1077 -- list. These units are either units appearing in limited_with
1078 -- clauses of other units, or units loaded for inlining that end
1079 -- up not inlined by a later decision of the inlining code, to
1080 -- prevent circularities. We want to exclude these files from the
1081 -- list of dependencies, so that the dependency number of other
1082 -- is correctly set, as that number is used by cross-reference
1083 -- tools to relate entity information to the unit in which they
1086 if Present
(Cunit_Entity
(Unum
))
1087 and then Ekind
(Cunit_Entity
(Unum
)) = E_Void
1088 and then Nkind
(Unit
(Cunit
(Unum
))) /= N_Subunit
1089 and then Serious_Errors_Detected
= 0
1094 Num_Sdep
:= Num_Sdep
+ 1;
1095 Sdep_Table
(Num_Sdep
) := Unum
;
1100 -- Sort the table so that the D lines are in order
1102 Lib
.Sort
(Sdep_Table
(1 .. Num_Sdep
));
1104 -- Acquire compilation arguments and prepare to write out a new ali
1107 Create_Output_Library_Info
;
1109 -- Output version line
1111 Write_Info_Initiate
('V');
1112 Write_Info_Str
(" """);
1113 Write_Info_Str
(Verbose_Library_Version
);
1114 Write_Info_Char
('"');
1118 -- Output main program line if this is acceptable main program
1120 Output_Main_Program_Line
: declare
1121 U
: Node_Id
:= Unit
(Units
.Table
(Main_Unit
).Cunit
);
1124 procedure M_Parameters
;
1125 -- Output parameters for main program line
1131 procedure M_Parameters
is
1133 if Main_Priority
(Main_Unit
) /= Default_Main_Priority
then
1134 Write_Info_Char
(' ');
1135 Write_Info_Nat
(Main_Priority
(Main_Unit
));
1138 if Opt
.Time_Slice_Set
then
1139 Write_Info_Str
(" T=");
1140 Write_Info_Nat
(Opt
.Time_Slice_Value
);
1143 if Main_CPU
(Main_Unit
) /= Default_Main_CPU
then
1144 Write_Info_Str
(" C=");
1145 Write_Info_Nat
(Main_CPU
(Main_Unit
));
1148 Write_Info_Str
(" W=");
1150 (WC_Encoding_Letters
(Wide_Character_Encoding_Method
));
1155 -- Start of processing for Output_Main_Program_Line
1158 if Nkind
(U
) = N_Subprogram_Body
1160 (Nkind
(U
) = N_Package_Body
1162 Nkind
(Original_Node
(U
)) in N_Subprogram_Instantiation
)
1164 -- If the unit is a subprogram instance, the entity for the
1165 -- subprogram is the alias of the visible entity, which is the
1166 -- related instance of the wrapper package. We retrieve the
1167 -- subprogram declaration of the desired entity.
1169 if Nkind
(U
) = N_Package_Body
then
1170 U
:= Parent
(Parent
(
1171 Alias
(Related_Instance
(Defining_Unit_Name
1172 (Specification
(Unit
(Library_Unit
(Parent
(U
)))))))));
1175 S
:= Specification
(U
);
1177 -- A generic subprogram is never a main program
1179 if Nkind
(U
) = N_Subprogram_Body
1180 and then Present
(Corresponding_Spec
(U
))
1181 and then Is_Generic_Subprogram
(Corresponding_Spec
(U
))
1185 elsif No
(Parameter_Specifications
(S
)) then
1186 if Nkind
(S
) = N_Procedure_Specification
then
1187 Write_Info_Initiate
('M');
1188 Write_Info_Str
(" P");
1193 Nam
: Node_Id
:= Defining_Unit_Name
(S
);
1196 -- If it is a child unit, get its simple name
1198 if Nkind
(Nam
) = N_Defining_Program_Unit_Name
then
1199 Nam
:= Defining_Identifier
(Nam
);
1202 if Is_Integer_Type
(Etype
(Nam
)) then
1203 Write_Info_Initiate
('M');
1204 Write_Info_Str
(" F");
1211 end Output_Main_Program_Line
;
1213 -- Write command argument ('A') lines
1215 for A
in 1 .. Compilation_Switches
.Last
loop
1216 Write_Info_Initiate
('A');
1217 Write_Info_Char
(' ');
1218 Write_Info_Str
(Compilation_Switches
.Table
(A
).all);
1219 Write_Info_Terminate
;
1222 -- Output CUDA Kernel lines
1224 for Unit
in Units
.First
.. Last_Unit
loop
1225 if Present
(Cunit
(Unit
)) then
1226 Output_CUDA_Symbols
(Unit
);
1230 -- Output parameters ('P') line
1232 Write_Info_Initiate
('P');
1234 if Compilation_Errors
then
1235 Write_Info_Str
(" CE");
1238 if Opt
.Detect_Blocking
then
1239 Write_Info_Str
(" DB");
1242 if Tasking_Used
and then not Is_Predefined_Unit
(Main_Unit
) then
1243 if Locking_Policy
/= ' ' then
1244 Write_Info_Str
(" L");
1245 Write_Info_Char
(Locking_Policy
);
1248 if Queuing_Policy
/= ' ' then
1249 Write_Info_Str
(" Q");
1250 Write_Info_Char
(Queuing_Policy
);
1253 if Task_Dispatching_Policy
/= ' ' then
1254 Write_Info_Str
(" T");
1255 Write_Info_Char
(Task_Dispatching_Policy
);
1256 Write_Info_Char
(' ');
1260 if GNATprove_Mode
then
1261 Write_Info_Str
(" GP");
1264 if Partition_Elaboration_Policy
/= ' ' then
1265 Write_Info_Str
(" E");
1266 Write_Info_Char
(Partition_Elaboration_Policy
);
1269 if Opt
.Interrupts_System_By_Default
then
1270 Write_Info_Str
(" ID");
1273 if No_Component_Reordering_Config
then
1274 Write_Info_Str
(" NC");
1278 Write_Info_Str
(" NO");
1281 if No_Run_Time_Mode
then
1282 Write_Info_Str
(" NR");
1285 if Normalize_Scalars
then
1286 Write_Info_Str
(" NS");
1289 if Default_SSO_Config
/= ' ' then
1290 Write_Info_Str
(" O");
1291 Write_Info_Char
(Default_SSO_Config
);
1294 if Sec_Stack_Used
then
1295 Write_Info_Str
(" SS");
1298 if Unreserve_All_Interrupts
then
1299 Write_Info_Str
(" UA");
1302 if ZCX_Exceptions
then
1303 Write_Info_Str
(" ZX");
1308 -- Before outputting the restrictions line, update the setting of
1309 -- the No_Elaboration_Code flag. Violations of this restriction
1310 -- cannot be detected until after the backend has been called since
1311 -- it is the backend that sets this flag. We have to check all units
1312 -- for which we have generated code
1314 for Unit
in Units
.First
.. Last_Unit
loop
1315 if Units
.Table
(Unit
).Generate_Code
then
1316 if not Has_No_Elaboration_Code
(Cunit
(Unit
)) then
1317 Main_Restrictions
.Violated
(No_Elaboration_Code
) := True;
1323 -- Positional case (only if debug flag -gnatd.R is set)
1325 if Debug_Flag_Dot_RR
then
1327 -- Output first restrictions line
1329 Write_Info_Initiate
('R');
1330 Write_Info_Char
(' ');
1332 -- First the information for the boolean restrictions
1334 for R
in All_Boolean_Restrictions
loop
1335 if Main_Restrictions
.Set
(R
)
1336 and then not Restriction_Warnings
(R
)
1338 Write_Info_Char
('r');
1339 elsif Main_Restrictions
.Violated
(R
) then
1340 Write_Info_Char
('v');
1342 Write_Info_Char
('n');
1346 -- And now the information for the parameter restrictions
1348 for RP
in All_Parameter_Restrictions
loop
1349 if Main_Restrictions
.Set
(RP
)
1350 and then not Restriction_Warnings
(RP
)
1352 Write_Info_Char
('r');
1353 Write_Info_Nat
(Nat
(Main_Restrictions
.Value
(RP
)));
1355 Write_Info_Char
('n');
1358 if not Main_Restrictions
.Violated
(RP
)
1359 or else RP
not in Checked_Parameter_Restrictions
1361 Write_Info_Char
('n');
1363 Write_Info_Char
('v');
1364 Write_Info_Nat
(Nat
(Main_Restrictions
.Count
(RP
)));
1366 if Main_Restrictions
.Unknown
(RP
) then
1367 Write_Info_Char
('+');
1374 -- Named case (if debug flag -gnatd.R is not set)
1381 -- Write RN header line with preceding blank line
1384 Write_Info_Initiate
('R');
1385 Write_Info_Char
('N');
1388 -- First the lines for the boolean restrictions
1390 for R
in All_Boolean_Restrictions
loop
1391 if Main_Restrictions
.Set
(R
)
1392 and then not Restriction_Warnings
(R
)
1395 elsif Main_Restrictions
.Violated
(R
) then
1401 Write_Info_Initiate
('R');
1402 Write_Info_Char
(C
);
1403 Write_Info_Char
(' ');
1404 Write_Info_Str
(All_Boolean_Restrictions
'Image (R
));
1412 -- And now the lines for the parameter restrictions
1414 for RP
in All_Parameter_Restrictions
loop
1415 if Main_Restrictions
.Set
(RP
)
1416 and then not Restriction_Warnings
(RP
)
1418 Write_Info_Initiate
('R');
1419 Write_Info_Str
("R ");
1420 Write_Info_Str
(All_Parameter_Restrictions
'Image (RP
));
1421 Write_Info_Char
('=');
1422 Write_Info_Nat
(Nat
(Main_Restrictions
.Value
(RP
)));
1426 if not Main_Restrictions
.Violated
(RP
)
1427 or else RP
not in Checked_Parameter_Restrictions
1431 Write_Info_Initiate
('R');
1432 Write_Info_Str
("V ");
1433 Write_Info_Str
(All_Parameter_Restrictions
'Image (RP
));
1434 Write_Info_Char
('=');
1435 Write_Info_Nat
(Nat
(Main_Restrictions
.Count
(RP
)));
1437 if Main_Restrictions
.Unknown
(RP
) then
1438 Write_Info_Char
('+');
1446 -- Output R lines for No_Dependence entries
1448 for J
in No_Dependences
.First
.. No_Dependences
.Last
loop
1449 if In_Extended_Main_Source_Unit
(No_Dependences
.Table
(J
).Unit
)
1450 and then not No_Dependences
.Table
(J
).Warn
1452 Write_Info_Initiate
('R');
1453 Write_Info_Char
(' ');
1454 Write_Unit_Name
(No_Dependences
.Table
(J
).Unit
);
1459 -- Output interrupt state lines
1461 for J
in Interrupt_States
.First
.. Interrupt_States
.Last
loop
1462 Write_Info_Initiate
('I');
1463 Write_Info_Char
(' ');
1464 Write_Info_Nat
(Interrupt_States
.Table
(J
).Interrupt_Number
);
1465 Write_Info_Char
(' ');
1466 Write_Info_Char
(Interrupt_States
.Table
(J
).Interrupt_State
);
1467 Write_Info_Char
(' ');
1469 (Nat
(Get_Logical_Line_Number
1470 (Interrupt_States
.Table
(J
).Pragma_Loc
)));
1474 -- Output priority specific dispatching lines
1476 for J
in Specific_Dispatching
.First
.. Specific_Dispatching
.Last
loop
1477 Write_Info_Initiate
('S');
1478 Write_Info_Char
(' ');
1479 Write_Info_Char
(Specific_Dispatching
.Table
(J
).Dispatching_Policy
);
1480 Write_Info_Char
(' ');
1481 Write_Info_Nat
(Specific_Dispatching
.Table
(J
).First_Priority
);
1482 Write_Info_Char
(' ');
1483 Write_Info_Nat
(Specific_Dispatching
.Table
(J
).Last_Priority
);
1484 Write_Info_Char
(' ');
1486 (Nat
(Get_Logical_Line_Number
1487 (Specific_Dispatching
.Table
(J
).Pragma_Loc
)));
1491 -- Loop through file table to output information for all units for which
1492 -- we have generated code, as marked by the Generate_Code flag.
1494 for Unit
in Units
.First
.. Last_Unit
loop
1495 if Units
.Table
(Unit
).Generate_Code
1496 or else Unit
= Main_Unit
1498 Write_Info_EOL
; -- blank line
1499 Write_Unit_Information
(Unit
);
1503 Write_Info_EOL
; -- blank line
1505 -- Output external version reference lines
1507 for J
in 1 .. Version_Ref
.Last
loop
1508 Write_Info_Initiate
('E');
1509 Write_Info_Char
(' ');
1511 for K
in 1 .. String_Length
(Version_Ref
.Table
(J
)) loop
1512 Write_Info_Char_Code
(Get_String_Char
(Version_Ref
.Table
(J
), K
));
1518 -- Prepare to output the source dependency lines
1521 Unum
: Unit_Number_Type
;
1522 -- Number of unit being output
1524 Sind
: Source_File_Index
;
1525 -- Index of corresponding source file
1527 Fname
: File_Name_Type
;
1530 for J
in 1 .. Num_Sdep
loop
1531 Unum
:= Sdep_Table
(J
);
1532 Units
.Table
(Unum
).Dependency_Num
:= J
;
1533 Sind
:= Source_Index
(Unum
);
1535 Write_Info_Initiate
('D');
1536 Write_Info_Char
(' ');
1538 -- Normal case of a unit entry with a source index
1540 if Sind
> No_Source_File
then
1542 if Config_Files_Store_Basename
then
1543 Fname
:= Strip_Directory
(File_Name
(Sind
));
1545 Fname
:= File_Name
(Sind
);
1548 -- Ensure that on platforms where the file names are not
1549 -- case sensitive, the recorded file name is in lower case.
1551 if not File_Names_Case_Sensitive
then
1552 Get_Name_String
(Fname
);
1553 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1557 Write_Info_Name_May_Be_Quoted
(Fname
);
1558 Write_Info_Tab
(25);
1559 Write_Info_Str
(String (Time_Stamp
(Sind
)));
1560 Write_Info_Char
(' ');
1561 Write_Info_Str
(Get_Hex_String
(Source_Checksum
(Sind
)));
1563 -- If the dependency comes from a limited_with clause, record
1564 -- limited_checksum. This is disabled until full checksum
1565 -- changes are checked.
1567 -- if Present (Cunit_Entity (Unum))
1568 -- and then From_Limited_With (Cunit_Entity (Unum))
1570 -- Write_Info_Char (' ');
1571 -- Write_Info_Char ('Y');
1572 -- Write_Info_Str (Get_Hex_String (Limited_Chk_Sum (Sind)));
1575 -- If subunit, add unit name, omitting the %b at the end
1577 if Present
(Cunit
(Unum
)) then
1578 Get_Decoded_Name_String
(Unit_Name
(Unum
));
1579 Write_Info_Char
(' ');
1581 if Nkind
(Unit
(Cunit
(Unum
))) = N_Subunit
then
1582 Write_Info_Str
(Name_Buffer
(1 .. Name_Len
- 2));
1584 Write_Info_Str
(Name_Buffer
(1 .. Name_Len
));
1588 -- If Source_Reference pragma used, output information
1590 if Num_SRef_Pragmas
(Sind
) > 0 then
1591 Write_Info_Char
(' ');
1593 if Num_SRef_Pragmas
(Sind
) = 1 then
1594 Write_Info_Nat
(Int
(First_Mapped_Line
(Sind
)));
1599 Write_Info_Char
(':');
1600 Write_Info_Name
(Reference_Name
(Sind
));
1603 -- Case where there is no source index (happens for missing
1604 -- files). In this case we write a dummy time stamp.
1607 Write_Info_Name
(Unit_File_Name
(Unum
));
1608 Write_Info_Tab
(25);
1609 Write_Info_Str
(String (Dummy_Time_Stamp
));
1610 Write_Info_Char
(' ');
1611 Write_Info_Str
(Get_Hex_String
(0));
1618 -- Output the invocation graph
1620 Write_Invocation_Graph
;
1622 -- Output cross-references
1624 if Opt
.Xref_Active
then
1628 -- Output SCO information if present
1630 if Generate_SCO
then
1631 SCO_Record_Filtered
;
1635 -- Output final blank line and we are done. This final blank line is
1636 -- probably junk, but we don't feel like making an incompatible change.
1638 Write_Info_Terminate
;
1639 Close_Output_Library_Info
;
1642 --------------------------------
1643 -- Write_Invocation_Construct --
1644 --------------------------------
1646 procedure Write_Invocation_Construct
(IC_Id
: Invocation_Construct_Id
) is
1650 Write_Info_Initiate
('G');
1651 Write_Info_Char
(' ');
1656 (Invocation_Graph_Line_Kind_To_Code
(Invocation_Construct_Line
));
1657 Write_Info_Char
(' ');
1661 Write_Info_Char
(Invocation_Construct_Kind_To_Code
(Kind
(IC_Id
)));
1662 Write_Info_Char
(' ');
1664 -- construct-spec-placement
1667 (Declaration_Placement_Kind_To_Code
(Spec_Placement
(IC_Id
)));
1668 Write_Info_Char
(' ');
1670 -- construct-body-placement
1673 (Declaration_Placement_Kind_To_Code
(Body_Placement
(IC_Id
)));
1674 Write_Info_Char
(' ');
1676 -- construct-signature
1678 Write_Invocation_Signature
(Signature
(IC_Id
));
1680 end Write_Invocation_Construct
;
1682 ---------------------------------------
1683 -- Write_Invocation_Graph_Attributes --
1684 ---------------------------------------
1686 procedure Write_Invocation_Graph_Attributes
is
1690 Write_Info_Initiate
('G');
1691 Write_Info_Char
(' ');
1696 (Invocation_Graph_Line_Kind_To_Code
1697 (Invocation_Graph_Attributes_Line
));
1698 Write_Info_Char
(' ');
1703 (Invocation_Graph_Encoding_Kind_To_Code
(Invocation_Graph_Encoding
));
1705 end Write_Invocation_Graph_Attributes
;
1707 ----------------------------
1708 -- Write_Invocation_Graph --
1709 ----------------------------
1711 procedure Write_Invocation_Graph
is
1713 Write_Invocation_Graph_Attributes
;
1715 -- First write out all invocation constructs declared within the current
1716 -- unit. This ensures that when this invocation is read, the invocation
1717 -- constructs are materialized before they are referenced by invocation
1720 For_Each_Invocation_Construct
(Write_Invocation_Construct
'Access);
1722 -- Write out all invocation relations that originate from invocation
1723 -- constructs delared in the current unit.
1725 For_Each_Invocation_Relation
(Write_Invocation_Relation
'Access);
1726 end Write_Invocation_Graph
;
1728 -------------------------------
1729 -- Write_Invocation_Relation --
1730 -------------------------------
1732 procedure Write_Invocation_Relation
(IR_Id
: Invocation_Relation_Id
) is
1736 Write_Info_Initiate
('G');
1737 Write_Info_Char
(' ');
1742 (Invocation_Graph_Line_Kind_To_Code
(Invocation_Relation_Line
));
1743 Write_Info_Char
(' ');
1747 Write_Info_Char
(Invocation_Kind_To_Code
(Kind
(IR_Id
)));
1748 Write_Info_Char
(' ');
1750 -- (extra-name | "none")
1752 if Present
(Extra
(IR_Id
)) then
1753 Write_Info_Name
(Extra
(IR_Id
));
1755 Write_Info_Str
("none");
1758 Write_Info_Char
(' ');
1760 -- invoker-signature
1762 Write_Invocation_Signature
(Invoker
(IR_Id
));
1763 Write_Info_Char
(' ');
1767 Write_Invocation_Signature
(Target
(IR_Id
));
1770 end Write_Invocation_Relation
;
1772 --------------------------------
1773 -- Write_Invocation_Signature --
1774 --------------------------------
1776 procedure Write_Invocation_Signature
(IS_Id
: Invocation_Signature_Id
) is
1780 Write_Info_Char
('[');
1784 Write_Info_Name
(Name
(IS_Id
));
1785 Write_Info_Char
(' ');
1789 Write_Info_Name
(IS_Scope
(IS_Id
));
1790 Write_Info_Char
(' ');
1794 Write_Info_Nat
(Line
(IS_Id
));
1795 Write_Info_Char
(' ');
1799 Write_Info_Nat
(Column
(IS_Id
));
1800 Write_Info_Char
(' ');
1802 -- (locations | "none")
1804 if Present
(Locations
(IS_Id
)) then
1805 Write_Info_Name
(Locations
(IS_Id
));
1807 Write_Info_Str
("none");
1812 Write_Info_Char
(']');
1813 end Write_Invocation_Signature
;
1815 ---------------------
1816 -- Write_Unit_Name --
1817 ---------------------
1819 procedure Write_Unit_Name
(N
: Node_Id
) is
1821 if Nkind
(N
) = N_Identifier
then
1822 Write_Info_Name
(Chars
(N
));
1825 pragma Assert
(Nkind
(N
) = N_Selected_Component
);
1826 Write_Unit_Name
(Prefix
(N
));
1827 Write_Info_Char
('.');
1828 Write_Unit_Name
(Selector_Name
(N
));
1830 end Write_Unit_Name
;