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 Sinfo
; use Sinfo
;
54 with Sinfo
.Nodes
; use Sinfo
.Nodes
;
55 with Sinfo
.Utils
; use Sinfo
.Utils
;
56 with Sinput
; use Sinput
;
57 with Snames
; use Snames
;
58 with Stringt
; use Stringt
;
59 with Tbuild
; use Tbuild
;
60 with Uname
; use Uname
;
62 with System
.Case_Util
; use System
.Case_Util
;
63 with System
.WCh_Con
; use System
.WCh_Con
;
65 package body Lib
.Writ
is
67 -----------------------
68 -- Local subprograms --
69 -----------------------
71 function Present
(N_Id
: Name_Id
) return Boolean;
72 pragma Inline
(Present
);
73 -- Determine whether a name with id N_Id exists
75 procedure Write_Invocation_Construct
(IC_Id
: Invocation_Construct_Id
);
76 pragma Inline
(Write_Invocation_Construct
);
77 -- Write invocation construct IC_Id to the ALI file
79 procedure Write_Invocation_Graph
;
80 pragma Inline
(Write_Invocation_Graph
);
81 -- Write out the invocation graph
83 procedure Write_Invocation_Graph_Attributes
;
84 pragma Inline
(Write_Invocation_Graph_Attributes
);
85 -- Write out the attributes of the invocation graph
87 procedure Write_Invocation_Relation
(IR_Id
: Invocation_Relation_Id
);
88 pragma Inline
(Write_Invocation_Relation
);
89 -- Write invocation relation IR_Id to the ALI file
91 procedure Write_Invocation_Signature
(IS_Id
: Invocation_Signature_Id
);
92 pragma Inline
(Write_Invocation_Signature
);
93 -- Write invocation signature IS_Id to the ALI file
95 procedure Write_Unit_Name
(N
: Node_Id
);
96 -- Used to write out the unit name for R (pragma Restriction) lines
97 -- for uses of Restriction (No_Dependence => unit-name).
99 ----------------------------------
100 -- Add_Preprocessing_Dependency --
101 ----------------------------------
103 procedure Add_Preprocessing_Dependency
(S
: Source_File_Index
) is
105 Units
.Increment_Last
;
106 Units
.Table
(Units
.Last
) :=
107 (Unit_File_Name
=> File_Name
(S
),
108 Unit_Name
=> No_Unit_Name
,
109 Expected_Unit
=> No_Unit_Name
,
112 Cunit_Entity
=> Empty
,
114 Dynamic_Elab
=> False,
116 Generate_Code
=> False,
119 Ident_String
=> Empty
,
120 Is_Predefined_Renaming
=> False,
121 Is_Internal_Unit
=> False,
122 Is_Predefined_Unit
=> False,
128 No_Elab_Code_All
=> False,
129 Primary_Stack_Count
=> 0,
130 Sec_Stack_Count
=> 0,
133 Error_Location
=> No_Location
,
135 end Add_Preprocessing_Dependency
;
137 ------------------------------
138 -- Ensure_System_Dependency --
139 ------------------------------
141 procedure Ensure_System_Dependency
is
142 System_Uname
: constant Unit_Name_Type
:=
143 Name_To_Unit_Name
(Name_System
);
144 -- Unit name for system spec if needed for dummy entry
146 System_Fname
: File_Name_Type
;
147 -- File name for system spec if needed for dummy entry
150 -- Nothing to do if we already compiled System
152 if Is_Loaded
(System_Uname
) then
156 -- If no entry for system.ads in the units table, then add a entry
157 -- to the units table for system.ads, which will be referenced when
158 -- the ali file is generated. We need this because every unit depends
159 -- on system as a result of Targparm scanning the system.ads file to
160 -- determine the target dependent parameters for the compilation.
162 System_Fname
:= File_Name
(System_Source_File_Index
);
164 Units
.Increment_Last
;
165 Units
.Table
(Units
.Last
) :=
166 (Unit_File_Name
=> System_Fname
,
167 Unit_Name
=> System_Uname
,
168 Expected_Unit
=> System_Uname
,
169 Source_Index
=> System_Source_File_Index
,
171 Cunit_Entity
=> Empty
,
173 Dynamic_Elab
=> False,
175 Generate_Code
=> False,
178 Ident_String
=> Empty
,
179 Is_Predefined_Renaming
=> False,
180 Is_Internal_Unit
=> True,
181 Is_Predefined_Unit
=> True,
187 No_Elab_Code_All
=> False,
188 Primary_Stack_Count
=> 0,
189 Sec_Stack_Count
=> 0,
192 Error_Location
=> No_Location
,
194 Init_Unit_Name
(Units
.Last
, System_Uname
);
196 -- Parse system.ads so that the checksum is set right. Style checks are
197 -- not applied. The Ekind is set to ensure that this reference is always
198 -- present in the ali file.
201 Save_Mindex
: constant Nat
:= Multiple_Unit_Index
;
202 Save_Style
: constant Boolean := Style_Check
;
204 Multiple_Unit_Index
:= 0;
205 Style_Check
:= False;
206 Initialize_Scanner
(Units
.Last
, System_Source_File_Index
);
207 Discard_List
(Par
(Configuration_Pragmas
=> False));
208 Mutate_Ekind
(Cunit_Entity
(Units
.Last
), E_Package
);
209 Set_Scope
(Cunit_Entity
(Units
.Last
), Standard_Standard
);
210 Style_Check
:= Save_Style
;
211 Multiple_Unit_Index
:= Save_Mindex
;
213 end Ensure_System_Dependency
;
219 function Present
(N_Id
: Name_Id
) return Boolean is
221 return N_Id
/= No_Name
;
228 procedure Write_ALI
(Object
: Boolean) is
234 Last_Unit
: constant Unit_Number_Type
:= Units
.Last
;
235 -- Record unit number of last unit. We capture this in case we
236 -- have to add a dummy entry to the unit table for package System.
238 With_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
239 -- Array of flags to show which units are with'ed
241 Elab_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
242 -- Array of flags to show which units have pragma Elaborate set
244 Elab_All_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
245 -- Array of flags to show which units have pragma Elaborate All set
247 Elab_Des_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
248 -- Array of flags to show which units have Elaborate_Desirable set
250 Elab_All_Des_Flags
: array (Units
.First
.. Last_Unit
) of Boolean;
251 -- Array of flags to show which units have Elaborate_All_Desirable set
253 type Yes_No
is (Unknown
, Yes
, No
);
254 Has_Implicit_With
: array (Units
.First
.. Last_Unit
) of Yes_No
;
255 -- Indicates if an implicit with has been given for the unit. Yes if
256 -- certainly present, No if certainly absent, Unknown if not known.
258 Sdep_Table
: Unit_Ref_Table
(1 .. Pos
(Last_Unit
- Units
.First
+ 2));
259 -- Sorted table of source dependencies. One extra entry in case we
260 -- have to add a dummy entry for System.
263 -- Number of active entries in Sdep_Table
265 -----------------------
266 -- Local Subprograms --
267 -----------------------
269 procedure Collect_Withs
(Cunit
: Node_Id
);
270 -- Collect with lines for entries in the context clause of the given
271 -- compilation unit, Cunit.
273 procedure Output_CUDA_Symbols
(Unit_Num
: Unit_Number_Type
);
274 -- Output CUDA symbols, so that the rest of the toolchain may know what
275 -- symbols need registering with the CUDA runtime.
277 procedure Write_Unit_Information
(Unit_Num
: Unit_Number_Type
);
278 -- Write out the library information for one unit for which code is
279 -- generated (includes unit line and with lines).
281 procedure Write_With_Lines
;
282 -- Write out with lines collected by calls to Collect_Withs
288 procedure Collect_Withs
(Cunit
: Node_Id
) is
289 function Is_Implicit_With_Clause
(Clause
: Node_Id
) return Boolean;
290 pragma Inline
(Is_Implicit_With_Clause
);
291 -- Determine whether a with clause denoted by Clause is implicit
293 -----------------------------
294 -- Is_Implicit_With_Clause --
295 -----------------------------
297 function Is_Implicit_With_Clause
(Clause
: Node_Id
) return Boolean is
299 -- With clauses created for ancestor units are marked as internal,
300 -- however, they emulate the semantics in Ada RM 10.1.2 (6/2),
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 if Ekind
(Uent
) in E_Package | E_Package_Body
528 and then Present
(Finalizer
(Uent
))
530 Write_Info_Str
(" PF");
533 if Is_Preelaborated
(Uent
) then
534 Write_Info_Str
(" PR");
537 if Is_Pure
(Uent
) then
538 Write_Info_Str
(" PU");
541 if Has_RACW
(Unit_Num
) then
542 Write_Info_Str
(" RA");
545 if Is_Remote_Call_Interface
(Uent
) then
546 Write_Info_Str
(" RC");
549 if Is_Remote_Types
(Uent
) then
550 Write_Info_Str
(" RT");
553 if Serious_Errors_Detected
/= 0 then
554 Write_Info_Str
(" SE");
557 if Is_Shared_Passive
(Uent
) then
558 Write_Info_Str
(" SP");
561 if Ukind
= N_Subprogram_Declaration
562 or else Ukind
= N_Subprogram_Body
564 Write_Info_Str
(" SU");
566 elsif Ukind
= N_Package_Declaration
568 Ukind
= N_Package_Body
570 -- If this is a wrapper package for a subprogram instantiation,
571 -- the user view is the subprogram. Note that in this case the
572 -- ali file contains both the spec and body of the instance.
574 if Is_Wrapper_Package
(Uent
) then
575 Write_Info_Str
(" SU");
577 Write_Info_Str
(" PK");
580 elsif Ukind
= N_Generic_Package_Declaration
then
581 Write_Info_Str
(" PK");
585 if Ukind
in N_Generic_Declaration
587 (Present
(Library_Unit
(Unode
))
589 Nkind
(Unit
(Library_Unit
(Unode
))) in N_Generic_Declaration
)
591 Write_Info_Str
(" GE");
594 if not Is_Internal_Unit
(Unit_Num
) then
595 case Identifier_Casing
(Source_Index
(Unit_Num
)) is
596 when All_Lower_Case
=> Write_Info_Str
(" IL");
597 when All_Upper_Case
=> Write_Info_Str
(" IU");
601 case Keyword_Casing
(Source_Index
(Unit_Num
)) is
602 when Mixed_Case
=> Write_Info_Str
(" KM");
603 when All_Upper_Case
=> Write_Info_Str
(" KU");
608 if Initialize_Scalars
or else Invalid_Value_Used
then
609 Write_Info_Str
(" IS");
614 -- Generate with lines, first those that are directly with'ed
616 for J
in With_Flags
'Range loop
617 With_Flags
(J
) := False;
618 Elab_Flags
(J
) := False;
619 Elab_All_Flags
(J
) := False;
620 Elab_Des_Flags
(J
) := False;
621 Elab_All_Des_Flags
(J
) := False;
622 Has_Implicit_With
(J
) := Unknown
;
625 Collect_Withs
(Unode
);
627 -- For a body, we must also check for any subunits which belong to
628 -- it and which have context clauses of their own, since these
629 -- with'ed units are part of its own elaboration dependencies.
631 if Nkind
(Unit
(Unode
)) in N_Unit_Body
then
632 for S
in Units
.First
.. Last_Unit
loop
634 -- We are only interested in subunits. For preproc. data and
635 -- def. files, Cunit is Empty, so we need to test that first.
637 if Cunit
(S
) /= Empty
638 and then Nkind
(Unit
(Cunit
(S
))) = N_Subunit
640 Pnode
:= Library_Unit
(Cunit
(S
));
642 -- In gnatc mode, the errors in the subunits will not have
643 -- been recorded, but the analysis of the subunit may have
644 -- failed. There is no information to add to ALI file in
651 -- Find ultimate parent of the subunit
653 while Nkind
(Unit
(Pnode
)) = N_Subunit
loop
654 Pnode
:= Library_Unit
(Pnode
);
657 -- See if it belongs to current unit, and if so, include
660 if Pnode
= Unode
then
661 Collect_Withs
(Cunit
(S
));
669 -- Generate task stack lines
671 if Primary_Stack_Count
(Unit_Num
) > 0
672 or else Sec_Stack_Count
(Unit_Num
) > 0
674 Write_Info_Initiate
('T');
675 Write_Info_Char
(' ');
676 Write_Info_Int
(Primary_Stack_Count
(Unit_Num
));
677 Write_Info_Char
(' ');
678 Write_Info_Int
(Sec_Stack_Count
(Unit_Num
));
682 -- Generate the linker option lines
684 for J
in 1 .. Linker_Option_Lines
.Last
loop
686 -- Pragma Linker_Options is not allowed in predefined generic
687 -- units. This is because they won't be read, due to the fact that
688 -- with lines for generic units lack the file name and lib name
689 -- parameters (see Lib_Writ spec for an explanation).
691 if Is_Generic_Unit
(Cunit_Entity
(Main_Unit
))
692 and then Is_Predefined_Unit
(Current_Sem_Unit
)
693 and then Linker_Option_Lines
.Table
(J
).Unit
= Unit_Num
697 ("linker options not allowed in predefined generic unit");
698 raise Unrecoverable_Error
;
701 -- Output one linker option line
704 S
: Linker_Option_Entry
renames Linker_Option_Lines
.Table
(J
);
706 if S
.Unit
= Unit_Num
then
707 Write_Info_Initiate
('L');
708 Write_Info_Char
(' ');
709 Write_Info_Slit
(S
.Option
);
717 for J
in 1 .. Notes
.Last
loop
719 N
: constant Node_Id
:= Notes
.Table
(J
);
720 L
: constant Source_Ptr
:= Sloc
(N
);
721 U
: constant Unit_Number_Type
:=
722 Unit
(Get_Source_File_Index
(L
));
725 Note_Unit
: Unit_Number_Type
;
726 -- The unit in whose U section this note must be emitted:
727 -- notes for subunits are emitted along with the main unit;
728 -- all other notes are emitted as part of the enclosing
732 if U
/= No_Unit
and then Nkind
(Unit
(Cunit
(U
))) = N_Subunit
734 Note_Unit
:= Main_Unit
;
739 -- No action needed for pragmas removed by the expander (for
740 -- example, pragmas of ignored ghost entities).
742 if Nkind
(N
) = N_Null_Statement
then
743 pragma Assert
(Nkind
(Original_Node
(N
)) = N_Pragma
);
746 elsif Note_Unit
= Unit_Num
then
747 Write_Info_Initiate
('N');
748 Write_Info_Char
(' ');
750 case Pragma_Name
(N
) is
751 when Name_Annotate | Name_GNAT_Annotate
=>
759 when Name_Subtitle
=>
766 Write_Info_Int
(Int
(Get_Logical_Line_Number
(L
)));
767 Write_Info_Char
(':');
768 Write_Info_Int
(Int
(Get_Column_Number
(L
)));
770 -- Indicate source file of annotation if different from
771 -- compilation unit source file (case of annotation coming
774 if Get_Source_File_Index
(L
) /= Source_Index
(Unit_Num
) then
775 Write_Info_Char
(':');
776 Write_Info_Name
(File_Name
(Get_Source_File_Index
(L
)));
783 A
:= First
(Pragma_Argument_Associations
(N
));
784 while Present
(A
) loop
785 Write_Info_Char
(' ');
787 if Chars
(A
) /= No_Name
then
788 Write_Info_Name
(Chars
(A
));
789 Write_Info_Char
(':');
793 Expr
: constant Node_Id
:= Expression
(A
);
796 if Nkind
(Expr
) = N_Identifier
then
797 Write_Info_Name
(Chars
(Expr
));
799 elsif Nkind
(Expr
) = N_Integer_Literal
800 and then Is_OK_Static_Expression
(Expr
)
802 Write_Info_Uint
(Intval
(Expr
));
804 elsif Nkind
(Expr
) = N_String_Literal
805 and then Is_OK_Static_Expression
(Expr
)
807 Write_Info_Slit
(Strval
(Expr
));
810 Write_Info_Str
("<expr>");
822 end Write_Unit_Information
;
824 ----------------------
825 -- Write_With_Lines --
826 ----------------------
828 procedure Write_With_Lines
is
829 Pname
: constant Unit_Name_Type
:=
830 Get_Parent_Spec_Name
(Unit_Name
(Main_Unit
));
831 Body_Fname
: File_Name_Type
;
834 Fname
: File_Name_Type
;
835 Num_Withs
: Int
:= 0;
836 Unum
: Unit_Number_Type
;
837 Uname
: Unit_Name_Type
;
838 With_Table
: Unit_Ref_Table
(1 .. Pos
(Last_Unit
- Units
.First
+ 1));
840 procedure Write_With_File_Names
841 (Nam
: in out File_Name_Type
;
843 -- Write source file name Nam and ALI file name for unit index Idx.
844 -- Possibly change Nam to lowercase (generating a new file name).
846 ---------------------------
847 -- Write_With_File_Names --
848 ---------------------------
850 procedure Write_With_File_Names
851 (Nam
: in out File_Name_Type
;
855 if not File_Names_Case_Sensitive
then
856 Get_Name_String
(Nam
);
857 To_Lower
(Name_Buffer
(1 .. Name_Len
));
861 Write_Info_Name
(Nam
);
863 Write_Info_Name
(Lib_File_Name
(Nam
, Idx
));
864 end Write_With_File_Names
;
866 -- Start of processing for Write_With_Lines
869 -- Loop to build the with table. A with on the main unit itself
870 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
871 -- the main unit is a subprogram with no spec, and a subunit of
872 -- it unnecessarily withs the parent.
874 for J
in Units
.First
+ 1 .. Last_Unit
loop
876 -- Add element to with table if it is with'ed or if it is the
877 -- parent spec of the main unit (case of main unit is a child
878 -- unit). The latter with is not needed for semantic purposes,
879 -- but is required by the binder for elaboration purposes. For
880 -- preprocessing data and definition files, there is no Unit_Name,
881 -- check for that first.
883 if Present
(Unit_Name
(J
))
884 and then (With_Flags
(J
) or else Unit_Name
(J
) = Pname
)
886 Num_Withs
:= Num_Withs
+ 1;
887 With_Table
(Num_Withs
) := J
;
891 -- Sort and output the table
893 Sort
(With_Table
(1 .. Num_Withs
));
895 for J
in 1 .. Num_Withs
loop
896 Unum
:= With_Table
(J
);
898 -- Do not generate a with line for an ignored Ghost unit because
899 -- the unit does not have an ALI file.
901 if Is_Ignored_Ghost_Entity
(Cunit_Entity
(Unum
)) then
905 Cunit
:= Units
.Table
(Unum
).Cunit
;
906 Uname
:= Units
.Table
(Unum
).Unit_Name
;
907 Fname
:= Units
.Table
(Unum
).Unit_File_Name
;
909 -- Limited with clauses must be processed first because they are
910 -- the most specific among the three kinds.
912 if Ekind
(Cunit_Entity
(Unum
)) = E_Package
913 and then From_Limited_With
(Cunit_Entity
(Unum
))
915 Write_Info_Initiate
('Y');
917 elsif Has_Implicit_With
(Unum
) = Yes
then
918 Write_Info_Initiate
('Z');
921 Write_Info_Initiate
('W');
924 Write_Info_Char
(' ');
925 Write_Info_Name
(Uname
);
927 -- Now we need to figure out the names of the files that contain
928 -- the with'ed unit. These will usually be the files for the body,
929 -- except in the case of a package that has no body. Note that we
930 -- have a specific exemption here for predefined library generics
931 -- (see comments for Generic_May_Lack_ALI). We do not generate
932 -- dependency upon the ALI file for such units. Older compilers
933 -- used to not support generating code (and ALI) for generics, and
934 -- we want to avoid having different processing (namely, different
935 -- lists of files to be compiled) for different stages of the
938 if not ((Nkind
(Unit
(Cunit
)) in N_Generic_Declaration
940 Nkind
(Unit
(Cunit
)) in N_Generic_Renaming_Declaration
)
941 and then Generic_May_Lack_ALI
(Unum
))
943 -- In SPARK mode, always generate the dependencies on ALI
944 -- files, which are required to compute frame conditions
947 or else GNATprove_Mode
951 if Is_Spec_Name
(Uname
) then
954 (Uname
=> Get_Body_Name
(Uname
),
958 Body_Index
:= Get_Unit_Index
(Get_Body_Name
(Uname
));
960 if Body_Fname
= No_File
then
961 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
962 Body_Index
:= Get_Unit_Index
(Uname
);
965 Body_Fname
:= Get_File_Name
(Uname
, Subunit
=> False);
966 Body_Index
:= Get_Unit_Index
(Uname
);
969 -- A package is considered to have a body if it requires
970 -- a body or if a body is present in Ada 83 mode.
972 if Body_Required
(Cunit
)
973 or else (Ada_Version
= Ada_83
974 and then Full_Source_Name
(Body_Fname
) /= No_File
)
976 Write_With_File_Names
(Body_Fname
, Body_Index
);
978 Write_With_File_Names
(Fname
, Munit_Index
(Unum
));
981 if Ekind
(Cunit_Entity
(Unum
)) = E_Package
982 and then From_Limited_With
(Cunit_Entity
(Unum
))
986 if Elab_Flags
(Unum
) then
987 Write_Info_Str
(" E");
990 if Elab_All_Flags
(Unum
) then
991 Write_Info_Str
(" EA");
994 if Elab_Des_Flags
(Unum
) then
995 Write_Info_Str
(" ED");
998 if Elab_All_Des_Flags
(Unum
) then
999 Write_Info_Str
(" AD");
1010 -- Finally generate the special lines for cases of Restriction_Set
1011 -- with No_Dependence and no restriction present.
1014 Unam
: Unit_Name_Type
;
1017 for J
in Restriction_Set_Dependences
.First
..
1018 Restriction_Set_Dependences
.Last
1020 Unam
:= Restriction_Set_Dependences
.Table
(J
);
1022 -- Don't need an entry if already in the unit table
1024 for U
in 0 .. Last_Unit
loop
1025 if Unit_Name
(U
) = Unam
then
1026 goto Next_Restriction_Set
;
1030 -- Otherwise generate the entry
1032 Write_Info_Initiate
('W');
1033 Write_Info_Char
(' ');
1034 Write_Info_Name
(Unam
);
1037 <<Next_Restriction_Set
>>
1041 end Write_With_Lines
;
1043 -- Start of processing for Write_ALI
1046 -- We never write an ALI file if the original operating mode was
1047 -- syntax-only (-gnats switch used in compiler invocation line).
1049 if Original_Operating_Mode
= Check_Syntax
then
1053 -- Generation of ALI files may be disabled, e.g. for formal verification
1056 if Disable_ALI_File
then
1060 -- Build sorted source dependency table
1062 for Unum
in Units
.First
.. Last_Unit
loop
1063 if Cunit_Entity
(Unum
) = Empty
1064 or else not From_Limited_With
(Cunit_Entity
(Unum
))
1066 -- Units that are not analyzed need not appear in the dependency
1067 -- list. These units are either units appearing in limited_with
1068 -- clauses of other units, or units loaded for inlining that end
1069 -- up not inlined by a later decision of the inlining code, to
1070 -- prevent circularities. We want to exclude these files from the
1071 -- list of dependencies, so that the dependency number of other
1072 -- is correctly set, as that number is used by cross-reference
1073 -- tools to relate entity information to the unit in which they
1076 if Present
(Cunit_Entity
(Unum
))
1077 and then Ekind
(Cunit_Entity
(Unum
)) = E_Void
1078 and then Nkind
(Unit
(Cunit
(Unum
))) /= N_Subunit
1079 and then Serious_Errors_Detected
= 0
1084 Num_Sdep
:= Num_Sdep
+ 1;
1085 Sdep_Table
(Num_Sdep
) := Unum
;
1090 -- Sort the table so that the D lines are in order
1092 Lib
.Sort
(Sdep_Table
(1 .. Num_Sdep
));
1094 -- Acquire compilation arguments and prepare to write out a new ali
1097 Create_Output_Library_Info
;
1099 -- Output version line
1101 Write_Info_Initiate
('V');
1102 Write_Info_Str
(" """);
1103 Write_Info_Str
(Verbose_Library_Version
);
1104 Write_Info_Char
('"');
1108 -- Output main program line if this is acceptable main program
1110 Output_Main_Program_Line
: declare
1111 U
: Node_Id
:= Unit
(Units
.Table
(Main_Unit
).Cunit
);
1114 procedure M_Parameters
;
1115 -- Output parameters for main program line
1121 procedure M_Parameters
is
1123 if Main_Priority
(Main_Unit
) /= Default_Main_Priority
then
1124 Write_Info_Char
(' ');
1125 Write_Info_Nat
(Main_Priority
(Main_Unit
));
1128 if Opt
.Time_Slice_Set
then
1129 Write_Info_Str
(" T=");
1130 Write_Info_Nat
(Opt
.Time_Slice_Value
);
1133 if Main_CPU
(Main_Unit
) /= Default_Main_CPU
then
1134 Write_Info_Str
(" C=");
1135 Write_Info_Nat
(Main_CPU
(Main_Unit
));
1138 Write_Info_Str
(" W=");
1140 (WC_Encoding_Letters
(Wide_Character_Encoding_Method
));
1145 -- Start of processing for Output_Main_Program_Line
1148 if Nkind
(U
) = N_Subprogram_Body
1150 (Nkind
(U
) = N_Package_Body
1152 Nkind
(Original_Node
(U
)) in N_Subprogram_Instantiation
)
1154 -- If the unit is a subprogram instance, the entity for the
1155 -- subprogram is the alias of the visible entity, which is the
1156 -- related instance of the wrapper package. We retrieve the
1157 -- subprogram declaration of the desired entity.
1159 if Nkind
(U
) = N_Package_Body
then
1160 U
:= Parent
(Parent
(
1161 Alias
(Related_Instance
(Defining_Unit_Name
1162 (Specification
(Unit
(Library_Unit
(Parent
(U
)))))))));
1165 S
:= Specification
(U
);
1167 -- A generic subprogram is never a main program
1169 if Nkind
(U
) = N_Subprogram_Body
1170 and then Present
(Corresponding_Spec
(U
))
1171 and then Is_Generic_Subprogram
(Corresponding_Spec
(U
))
1175 elsif No
(Parameter_Specifications
(S
)) then
1176 if Nkind
(S
) = N_Procedure_Specification
then
1177 Write_Info_Initiate
('M');
1178 Write_Info_Str
(" P");
1183 Nam
: Node_Id
:= Defining_Unit_Name
(S
);
1186 -- If it is a child unit, get its simple name
1188 if Nkind
(Nam
) = N_Defining_Program_Unit_Name
then
1189 Nam
:= Defining_Identifier
(Nam
);
1192 if Is_Integer_Type
(Etype
(Nam
)) then
1193 Write_Info_Initiate
('M');
1194 Write_Info_Str
(" F");
1201 end Output_Main_Program_Line
;
1203 -- Write command argument ('A') lines
1205 for A
in 1 .. Compilation_Switches
.Last
loop
1206 Write_Info_Initiate
('A');
1207 Write_Info_Char
(' ');
1208 Write_Info_Str
(Compilation_Switches
.Table
(A
).all);
1209 Write_Info_Terminate
;
1212 -- Output CUDA Kernel lines
1214 for Unit
in Units
.First
.. Last_Unit
loop
1215 if Present
(Cunit
(Unit
)) then
1216 Output_CUDA_Symbols
(Unit
);
1220 -- Output parameters ('P') line
1222 Write_Info_Initiate
('P');
1224 if Compilation_Errors
then
1225 Write_Info_Str
(" CE");
1228 if Opt
.Detect_Blocking
then
1229 Write_Info_Str
(" DB");
1232 if Tasking_Used
and then not Is_Predefined_Unit
(Main_Unit
) then
1233 if Locking_Policy
/= ' ' then
1234 Write_Info_Str
(" L");
1235 Write_Info_Char
(Locking_Policy
);
1238 if Queuing_Policy
/= ' ' then
1239 Write_Info_Str
(" Q");
1240 Write_Info_Char
(Queuing_Policy
);
1243 if Task_Dispatching_Policy
/= ' ' then
1244 Write_Info_Str
(" T");
1245 Write_Info_Char
(Task_Dispatching_Policy
);
1246 Write_Info_Char
(' ');
1250 if GNATprove_Mode
then
1251 Write_Info_Str
(" GP");
1254 if Partition_Elaboration_Policy
/= ' ' then
1255 Write_Info_Str
(" E");
1256 Write_Info_Char
(Partition_Elaboration_Policy
);
1259 if No_Component_Reordering_Config
then
1260 Write_Info_Str
(" NC");
1264 Write_Info_Str
(" NO");
1267 if No_Run_Time_Mode
then
1268 Write_Info_Str
(" NR");
1271 if Normalize_Scalars
then
1272 Write_Info_Str
(" NS");
1275 if Default_SSO_Config
/= ' ' then
1276 Write_Info_Str
(" O");
1277 Write_Info_Char
(Default_SSO_Config
);
1280 if Sec_Stack_Used
then
1281 Write_Info_Str
(" SS");
1284 if Unreserve_All_Interrupts
then
1285 Write_Info_Str
(" UA");
1288 if ZCX_Exceptions
then
1289 Write_Info_Str
(" ZX");
1294 -- Before outputting the restrictions line, update the setting of
1295 -- the No_Elaboration_Code flag. Violations of this restriction
1296 -- cannot be detected until after the backend has been called since
1297 -- it is the backend that sets this flag. We have to check all units
1298 -- for which we have generated code
1300 for Unit
in Units
.First
.. Last_Unit
loop
1301 if Units
.Table
(Unit
).Generate_Code
then
1302 if not Has_No_Elaboration_Code
(Cunit
(Unit
)) then
1303 Main_Restrictions
.Violated
(No_Elaboration_Code
) := True;
1309 -- Positional case (only if debug flag -gnatd.R is set)
1311 if Debug_Flag_Dot_RR
then
1313 -- Output first restrictions line
1315 Write_Info_Initiate
('R');
1316 Write_Info_Char
(' ');
1318 -- First the information for the boolean restrictions
1320 for R
in All_Boolean_Restrictions
loop
1321 if Main_Restrictions
.Set
(R
)
1322 and then not Restriction_Warnings
(R
)
1324 Write_Info_Char
('r');
1325 elsif Main_Restrictions
.Violated
(R
) then
1326 Write_Info_Char
('v');
1328 Write_Info_Char
('n');
1332 -- And now the information for the parameter restrictions
1334 for RP
in All_Parameter_Restrictions
loop
1335 if Main_Restrictions
.Set
(RP
)
1336 and then not Restriction_Warnings
(RP
)
1338 Write_Info_Char
('r');
1339 Write_Info_Nat
(Nat
(Main_Restrictions
.Value
(RP
)));
1341 Write_Info_Char
('n');
1344 if not Main_Restrictions
.Violated
(RP
)
1345 or else RP
not in Checked_Parameter_Restrictions
1347 Write_Info_Char
('n');
1349 Write_Info_Char
('v');
1350 Write_Info_Nat
(Nat
(Main_Restrictions
.Count
(RP
)));
1352 if Main_Restrictions
.Unknown
(RP
) then
1353 Write_Info_Char
('+');
1360 -- Named case (if debug flag -gnatd.R is not set)
1367 -- Write RN header line with preceding blank line
1370 Write_Info_Initiate
('R');
1371 Write_Info_Char
('N');
1374 -- First the lines for the boolean restrictions
1376 for R
in All_Boolean_Restrictions
loop
1377 if Main_Restrictions
.Set
(R
)
1378 and then not Restriction_Warnings
(R
)
1381 elsif Main_Restrictions
.Violated
(R
) then
1387 Write_Info_Initiate
('R');
1388 Write_Info_Char
(C
);
1389 Write_Info_Char
(' ');
1390 Write_Info_Str
(All_Boolean_Restrictions
'Image (R
));
1398 -- And now the lines for the parameter restrictions
1400 for RP
in All_Parameter_Restrictions
loop
1401 if Main_Restrictions
.Set
(RP
)
1402 and then not Restriction_Warnings
(RP
)
1404 Write_Info_Initiate
('R');
1405 Write_Info_Str
("R ");
1406 Write_Info_Str
(All_Parameter_Restrictions
'Image (RP
));
1407 Write_Info_Char
('=');
1408 Write_Info_Nat
(Nat
(Main_Restrictions
.Value
(RP
)));
1412 if not Main_Restrictions
.Violated
(RP
)
1413 or else RP
not in Checked_Parameter_Restrictions
1417 Write_Info_Initiate
('R');
1418 Write_Info_Str
("V ");
1419 Write_Info_Str
(All_Parameter_Restrictions
'Image (RP
));
1420 Write_Info_Char
('=');
1421 Write_Info_Nat
(Nat
(Main_Restrictions
.Count
(RP
)));
1423 if Main_Restrictions
.Unknown
(RP
) then
1424 Write_Info_Char
('+');
1432 -- Output R lines for No_Dependence entries
1434 for J
in No_Dependences
.First
.. No_Dependences
.Last
loop
1435 if In_Extended_Main_Source_Unit
(No_Dependences
.Table
(J
).Unit
)
1436 and then not No_Dependences
.Table
(J
).Warn
1438 Write_Info_Initiate
('R');
1439 Write_Info_Char
(' ');
1440 Write_Unit_Name
(No_Dependences
.Table
(J
).Unit
);
1445 -- Output interrupt state lines
1447 for J
in Interrupt_States
.First
.. Interrupt_States
.Last
loop
1448 Write_Info_Initiate
('I');
1449 Write_Info_Char
(' ');
1450 Write_Info_Nat
(Interrupt_States
.Table
(J
).Interrupt_Number
);
1451 Write_Info_Char
(' ');
1452 Write_Info_Char
(Interrupt_States
.Table
(J
).Interrupt_State
);
1453 Write_Info_Char
(' ');
1455 (Nat
(Get_Logical_Line_Number
1456 (Interrupt_States
.Table
(J
).Pragma_Loc
)));
1460 -- Output priority specific dispatching lines
1462 for J
in Specific_Dispatching
.First
.. Specific_Dispatching
.Last
loop
1463 Write_Info_Initiate
('S');
1464 Write_Info_Char
(' ');
1465 Write_Info_Char
(Specific_Dispatching
.Table
(J
).Dispatching_Policy
);
1466 Write_Info_Char
(' ');
1467 Write_Info_Nat
(Specific_Dispatching
.Table
(J
).First_Priority
);
1468 Write_Info_Char
(' ');
1469 Write_Info_Nat
(Specific_Dispatching
.Table
(J
).Last_Priority
);
1470 Write_Info_Char
(' ');
1472 (Nat
(Get_Logical_Line_Number
1473 (Specific_Dispatching
.Table
(J
).Pragma_Loc
)));
1477 -- Loop through file table to output information for all units for which
1478 -- we have generated code, as marked by the Generate_Code flag.
1480 for Unit
in Units
.First
.. Last_Unit
loop
1481 if Units
.Table
(Unit
).Generate_Code
1482 or else Unit
= Main_Unit
1484 Write_Info_EOL
; -- blank line
1485 Write_Unit_Information
(Unit
);
1489 Write_Info_EOL
; -- blank line
1491 -- Output external version reference lines
1493 for J
in 1 .. Version_Ref
.Last
loop
1494 Write_Info_Initiate
('E');
1495 Write_Info_Char
(' ');
1497 for K
in 1 .. String_Length
(Version_Ref
.Table
(J
)) loop
1498 Write_Info_Char_Code
(Get_String_Char
(Version_Ref
.Table
(J
), K
));
1504 -- Prepare to output the source dependency lines
1507 Unum
: Unit_Number_Type
;
1508 -- Number of unit being output
1510 Sind
: Source_File_Index
;
1511 -- Index of corresponding source file
1513 Fname
: File_Name_Type
;
1516 for J
in 1 .. Num_Sdep
loop
1517 Unum
:= Sdep_Table
(J
);
1518 Units
.Table
(Unum
).Dependency_Num
:= J
;
1519 Sind
:= Source_Index
(Unum
);
1521 Write_Info_Initiate
('D');
1522 Write_Info_Char
(' ');
1524 -- Normal case of a unit entry with a source index
1526 if Sind
> No_Source_File
then
1528 if Config_Files_Store_Basename
then
1529 Fname
:= Strip_Directory
(File_Name
(Sind
));
1531 Fname
:= File_Name
(Sind
);
1534 -- Ensure that on platforms where the file names are not
1535 -- case sensitive, the recorded file name is in lower case.
1537 if not File_Names_Case_Sensitive
then
1538 Get_Name_String
(Fname
);
1539 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1543 Write_Info_Name_May_Be_Quoted
(Fname
);
1544 Write_Info_Tab
(25);
1545 Write_Info_Str
(String (Time_Stamp
(Sind
)));
1546 Write_Info_Char
(' ');
1547 Write_Info_Str
(Get_Hex_String
(Source_Checksum
(Sind
)));
1549 -- If the dependency comes from a limited_with clause, record
1550 -- limited_checksum. This is disabled until full checksum
1551 -- changes are checked.
1553 -- if Present (Cunit_Entity (Unum))
1554 -- and then From_Limited_With (Cunit_Entity (Unum))
1556 -- Write_Info_Char (' ');
1557 -- Write_Info_Char ('Y');
1558 -- Write_Info_Str (Get_Hex_String (Limited_Chk_Sum (Sind)));
1561 -- If subunit, add unit name, omitting the %b at the end
1563 if Present
(Cunit
(Unum
)) then
1564 Get_Decoded_Name_String
(Unit_Name
(Unum
));
1565 Write_Info_Char
(' ');
1567 if Nkind
(Unit
(Cunit
(Unum
))) = N_Subunit
then
1568 Write_Info_Str
(Name_Buffer
(1 .. Name_Len
- 2));
1570 Write_Info_Str
(Name_Buffer
(1 .. Name_Len
));
1574 -- If Source_Reference pragma used, output information
1576 if Num_SRef_Pragmas
(Sind
) > 0 then
1577 Write_Info_Char
(' ');
1579 if Num_SRef_Pragmas
(Sind
) = 1 then
1580 Write_Info_Nat
(Int
(First_Mapped_Line
(Sind
)));
1585 Write_Info_Char
(':');
1586 Write_Info_Name
(Reference_Name
(Sind
));
1589 -- Case where there is no source index (happens for missing
1590 -- files). In this case we write a dummy time stamp.
1593 Write_Info_Name
(Unit_File_Name
(Unum
));
1594 Write_Info_Tab
(25);
1595 Write_Info_Str
(String (Dummy_Time_Stamp
));
1596 Write_Info_Char
(' ');
1597 Write_Info_Str
(Get_Hex_String
(0));
1604 -- Output the invocation graph
1606 Write_Invocation_Graph
;
1608 -- Output cross-references
1610 if Opt
.Xref_Active
then
1614 -- Output SCO information if present
1616 if Generate_SCO
then
1617 SCO_Record_Filtered
;
1621 -- Output final blank line and we are done. This final blank line is
1622 -- probably junk, but we don't feel like making an incompatible change.
1624 Write_Info_Terminate
;
1625 Close_Output_Library_Info
;
1628 --------------------------------
1629 -- Write_Invocation_Construct --
1630 --------------------------------
1632 procedure Write_Invocation_Construct
(IC_Id
: Invocation_Construct_Id
) is
1636 Write_Info_Initiate
('G');
1637 Write_Info_Char
(' ');
1642 (Invocation_Graph_Line_Kind_To_Code
(Invocation_Construct_Line
));
1643 Write_Info_Char
(' ');
1647 Write_Info_Char
(Invocation_Construct_Kind_To_Code
(Kind
(IC_Id
)));
1648 Write_Info_Char
(' ');
1650 -- construct-spec-placement
1653 (Declaration_Placement_Kind_To_Code
(Spec_Placement
(IC_Id
)));
1654 Write_Info_Char
(' ');
1656 -- construct-body-placement
1659 (Declaration_Placement_Kind_To_Code
(Body_Placement
(IC_Id
)));
1660 Write_Info_Char
(' ');
1662 -- construct-signature
1664 Write_Invocation_Signature
(Signature
(IC_Id
));
1666 end Write_Invocation_Construct
;
1668 ---------------------------------------
1669 -- Write_Invocation_Graph_Attributes --
1670 ---------------------------------------
1672 procedure Write_Invocation_Graph_Attributes
is
1676 Write_Info_Initiate
('G');
1677 Write_Info_Char
(' ');
1682 (Invocation_Graph_Line_Kind_To_Code
1683 (Invocation_Graph_Attributes_Line
));
1684 Write_Info_Char
(' ');
1689 (Invocation_Graph_Encoding_Kind_To_Code
(Invocation_Graph_Encoding
));
1691 end Write_Invocation_Graph_Attributes
;
1693 ----------------------------
1694 -- Write_Invocation_Graph --
1695 ----------------------------
1697 procedure Write_Invocation_Graph
is
1699 Write_Invocation_Graph_Attributes
;
1701 -- First write out all invocation constructs declared within the current
1702 -- unit. This ensures that when this invocation is read, the invocation
1703 -- constructs are materialized before they are referenced by invocation
1706 For_Each_Invocation_Construct
(Write_Invocation_Construct
'Access);
1708 -- Write out all invocation relations that originate from invocation
1709 -- constructs delared in the current unit.
1711 For_Each_Invocation_Relation
(Write_Invocation_Relation
'Access);
1712 end Write_Invocation_Graph
;
1714 -------------------------------
1715 -- Write_Invocation_Relation --
1716 -------------------------------
1718 procedure Write_Invocation_Relation
(IR_Id
: Invocation_Relation_Id
) is
1722 Write_Info_Initiate
('G');
1723 Write_Info_Char
(' ');
1728 (Invocation_Graph_Line_Kind_To_Code
(Invocation_Relation_Line
));
1729 Write_Info_Char
(' ');
1733 Write_Info_Char
(Invocation_Kind_To_Code
(Kind
(IR_Id
)));
1734 Write_Info_Char
(' ');
1736 -- (extra-name | "none")
1738 if Present
(Extra
(IR_Id
)) then
1739 Write_Info_Name
(Extra
(IR_Id
));
1741 Write_Info_Str
("none");
1744 Write_Info_Char
(' ');
1746 -- invoker-signature
1748 Write_Invocation_Signature
(Invoker
(IR_Id
));
1749 Write_Info_Char
(' ');
1753 Write_Invocation_Signature
(Target
(IR_Id
));
1756 end Write_Invocation_Relation
;
1758 --------------------------------
1759 -- Write_Invocation_Signature --
1760 --------------------------------
1762 procedure Write_Invocation_Signature
(IS_Id
: Invocation_Signature_Id
) is
1766 Write_Info_Char
('[');
1770 Write_Info_Name
(Name
(IS_Id
));
1771 Write_Info_Char
(' ');
1775 Write_Info_Name
(IS_Scope
(IS_Id
));
1776 Write_Info_Char
(' ');
1780 Write_Info_Nat
(Line
(IS_Id
));
1781 Write_Info_Char
(' ');
1785 Write_Info_Nat
(Column
(IS_Id
));
1786 Write_Info_Char
(' ');
1788 -- (locations | "none")
1790 if Present
(Locations
(IS_Id
)) then
1791 Write_Info_Name
(Locations
(IS_Id
));
1793 Write_Info_Str
("none");
1798 Write_Info_Char
(']');
1799 end Write_Invocation_Signature
;
1801 ---------------------
1802 -- Write_Unit_Name --
1803 ---------------------
1805 procedure Write_Unit_Name
(N
: Node_Id
) is
1807 if Nkind
(N
) = N_Identifier
then
1808 Write_Info_Name
(Chars
(N
));
1811 pragma Assert
(Nkind
(N
) = N_Selected_Component
);
1812 Write_Unit_Name
(Prefix
(N
));
1813 Write_Info_Char
('.');
1814 Write_Unit_Name
(Selector_Name
(N
));
1816 end Write_Unit_Name
;