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 ------------------------------------------------------------------------------
26 with Aspects
; use Aspects
;
27 with Atree
; use Atree
;
28 with Casing
; use Casing
;
29 with Csets
; use Csets
;
30 with Debug
; use Debug
;
31 with Einfo
; use Einfo
;
32 with Einfo
.Entities
; use Einfo
.Entities
;
33 with Einfo
.Utils
; use Einfo
.Utils
;
35 with Namet
; use Namet
;
36 with Nlists
; use Nlists
;
38 with Output
; use Output
;
39 with Rtsfind
; use Rtsfind
;
40 with Sem_Eval
; use Sem_Eval
;
41 with Sem_Util
; use Sem_Util
;
42 with Sinfo
; use Sinfo
;
43 with Sinfo
.Nodes
; use Sinfo
.Nodes
;
44 with Sinfo
.Utils
; use Sinfo
.Utils
;
45 with Sinput
; use Sinput
;
46 with Sinput
.D
; use Sinput
.D
;
47 with Snames
; use Snames
;
48 with Stand
; use Stand
;
49 with Stringt
; use Stringt
;
50 with Uintp
; use Uintp
;
51 with Uname
; use Uname
;
52 with Urealp
; use Urealp
;
54 package body Sprint
is
55 Current_Source_File
: Source_File_Index
;
56 -- Index of source file whose generated code is being dumped
58 Dump_Node
: Node_Id
:= Empty
;
59 -- This is set to the current node, used for printing line numbers. In
60 -- Debug_Generated_Code mode, Dump_Node is set to the current node
61 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
62 -- value. The call clears it back to Empty.
64 First_Debug_Sloc
: Source_Ptr
;
65 -- Sloc of first byte of the current output file if we are generating a
68 Debug_Sloc
: Source_Ptr
;
69 -- Sloc of first byte of line currently being written if we are
70 -- generating a source debug file.
72 Dump_Original_Only
: Boolean;
73 -- Set True if the -gnatdo (dump original tree) flag is set
75 Dump_Generated_Only
: Boolean;
76 -- Set True if the -gnatdG (dump generated tree) debug flag is set
77 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
79 Dump_Freeze_Null
: Boolean;
80 -- Set True if empty freeze nodes and non-source null statements output.
81 -- Note that freeze nodes containing freeze actions are always output,
82 -- as are freeze nodes for itypes, which in general have the effect of
83 -- causing elaboration of the itype.
85 Freeze_Indent
: Int
:= 0;
86 -- Keep track of freeze indent level (controls output of blank lines before
87 -- procedures within expression freeze actions). Relevant only if we are
88 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
89 -- output these blank lines in any case.
92 -- Number of columns for current line output indentation
94 Indent_Annull_Flag
: Boolean := False;
95 -- Set True if subsequent Write_Indent call to be ignored, gets reset
96 -- by this call, so it is only active to suppress a single indent call.
98 Last_Line_Printed
: Physical_Line_Number
;
99 -- This keeps track of the physical line number of the last source line
100 -- that has been output. The value is only valid in Dump_Source_Text mode.
102 -------------------------------
103 -- Operator Precedence Table --
104 -------------------------------
106 -- This table is used to decide whether a subexpression needs to be
107 -- parenthesized. The rule is that if an operand of an operator (which
108 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
109 -- with a lower precedence than the operator (or equal precedence if
110 -- appearing as the right operand), then parentheses are required.
112 Op_Prec
: constant array (N_Subexpr
) of Short_Short_Integer :=
145 procedure Sprint_Left_Opnd
(N
: Node_Id
);
146 -- Print left operand of operator, parenthesizing if necessary
148 procedure Sprint_Right_Opnd
(N
: Node_Id
);
149 -- Print right operand of operator, parenthesizing if necessary
151 -----------------------
152 -- Local Subprograms --
153 -----------------------
155 procedure Col_Check
(N
: Nat
);
156 -- Check that at least N characters remain on current line, and if not,
157 -- then start an extra line with two characters extra indentation for
158 -- continuing text on the next line.
160 procedure Extra_Blank_Line
;
161 -- In some situations we write extra blank lines to separate the generated
162 -- code to make it more readable. However, these extra blank lines are not
163 -- generated in Dump_Source_Text mode, since there the source text lines
164 -- output with preceding blank lines are quite sufficient as separators.
165 -- This procedure writes a blank line if Dump_Source_Text is False.
167 procedure Indent_Annull
;
168 -- Causes following call to Write_Indent to be ignored. This is used when
169 -- a higher level node wants to stop a lower level node from starting a
170 -- new line, when it would otherwise be inclined to do so (e.g. the case
171 -- of an accept statement called from an accept alternative with a guard)
173 procedure Indent_Begin
;
174 -- Increase indentation level
176 procedure Indent_End
;
177 -- Decrease indentation level
179 procedure Print_Debug_Line
(S
: String);
180 -- Used to print output lines in Debug_Generated_Code mode (this is used
181 -- as the argument for a call to Set_Special_Output in package Output).
183 procedure Set_Debug_Sloc
;
184 -- If Dump_Node is non-empty, this routine sets the appropriate value
185 -- in its Sloc field, from the current location in the debug source file
186 -- that is currently being written.
188 procedure Sprint_And_List
(List
: List_Id
);
189 -- Print the given list with items separated by vertical "and"
191 procedure Sprint_Aspect_Specifications
193 Semicolon
: Boolean);
194 -- Node is a declaration node that has aspect specifications (Has_Aspects
195 -- flag set True). It outputs the aspect specifications. For the case
196 -- of Semicolon = True, it is called after outputting the terminating
197 -- semicolon for the related node. The effect is to remove the semicolon
198 -- and print the aspect specifications followed by a terminating semicolon.
199 -- For the case of Semicolon False, no semicolon is removed or output, and
200 -- all the aspects are printed on a single line.
202 procedure Sprint_At_End_Proc
(Node
: Node_Id
);
203 -- Print At_End_Proc attribute if present
205 procedure Sprint_Bar_List
(List
: List_Id
);
206 -- Print the given list with items separated by vertical bars
208 procedure Sprint_End_Label
211 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
212 -- If there is no end label, use the defining identifier of the enclosing
213 -- construct. If the end label is present, treat it as a reference to the
214 -- defining entity of the construct: this guarantees that it carries the
215 -- proper sloc information for debugging purposes.
217 procedure Sprint_Node_Actual
(Node
: Node_Id
);
218 -- This routine prints its node argument. It is a lower level routine than
219 -- Sprint_Node, in that it does not bother about rewritten trees.
221 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
222 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
223 -- sets the Sloc of the current debug node to be a copy of the Sloc
224 -- of the sprinted node Node. Note that this is done after printing
225 -- Node, so that the Sloc is the proper updated value for the debug file.
227 procedure Update_Itype
(Node
: Node_Id
);
228 -- Update the Sloc of an itype that is not attached to the tree, when
229 -- debugging expanded code. This routine is called from nodes whose
230 -- type can be an Itype, such as defining_identifiers that may be of
231 -- an anonymous access type, or ranges in slices.
233 procedure Write_Char_Sloc
(C
: Character);
234 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
235 -- called to ensure that the current node has a proper Sloc set.
237 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
238 -- Write Condition and Reason codes of Raise_xxx_Error node
240 procedure Write_Corresponding_Source
(S
: String);
241 -- If S is a string with a single keyword (possibly followed by a space),
242 -- and if the next non-comment non-blank source line matches this keyword,
243 -- then output all source lines up to this matching line.
245 procedure Write_Discr_Specs
(N
: Node_Id
);
246 -- Output discriminant specification for node, which is any of the type
247 -- declarations that can have discriminants.
249 procedure Write_Ekind
(E
: Entity_Id
);
250 -- Write the String corresponding to the Ekind without "E_"
252 procedure Write_Id
(N
: Node_Id
);
253 -- N is a node with a Chars field. This procedure writes the name that
254 -- will be used in the generated code associated with the name. For a
255 -- node with no associated entity, this is simply the Chars field. For
256 -- the case where there is an entity associated with the node, we print
257 -- the name associated with the entity (since it may have been encoded).
258 -- One other special case is that an entity has an active external name
259 -- (i.e. an external name present with no address clause), then this
260 -- external name is output. This procedure also deals with outputting
261 -- declarations of referenced itypes, if not output earlier.
263 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
264 -- Handle node where the grammar has a list of defining identifiers, but
265 -- the tree has a separate declaration for each identifier. Handles the
266 -- printing of the defining identifier, and returns True if the type and
267 -- initialization information is to be printed, False if it is to be
268 -- skipped (the latter case happens when printing defining identifiers
269 -- other than the first in the original tree output case).
271 procedure Write_Implicit_Def
(E
: Entity_Id
);
272 pragma Warnings
(Off
, Write_Implicit_Def
);
273 -- Write the definition of the implicit type E according to its Ekind
274 -- For now a debugging procedure, but might be used in the future.
276 procedure Write_Indent
;
277 -- Start a new line and write indentation spacing
279 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
280 -- Like Write_Identifiers except that each new printed declaration
281 -- is at the start of a new line.
283 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
284 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
285 -- mode, the Sloc of the current debug node is set to point to the
286 -- first output identifier.
288 procedure Write_Indent_Str
(S
: String);
289 -- Start a new line and write indent spacing followed by given string
291 procedure Write_Indent_Str_Sloc
(S
: String);
292 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
293 -- the Sloc of the current node is set to the first non-blank character
296 procedure Write_Itype
(Typ
: Entity_Id
);
297 -- If Typ is an Itype that has not been written yet, write it. If Typ is
298 -- any other kind of entity or tree node, the call is ignored.
300 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
301 -- Write name (using Write_Name) with initial column check, and possible
302 -- initial Write_Indent (to get new line) if current line is too full.
304 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
305 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
306 -- mode, sets Sloc of current debug node to first character of name.
308 procedure Write_Operator
(N
: Node_Id
; S
: String);
309 -- Like Write_Str_Sloc, used for operators, encloses the string in
310 -- characters {} if the Do_Overflow flag is set on the node N.
312 procedure Write_Param_Specs
(N
: Node_Id
);
313 -- Output parameter specifications for node N (which is a subprogram, or
314 -- entry or entry family or access-subprogram-definition, all of which
315 -- have a Parameter_Specifications field).
317 procedure Write_Rewrite_Str
(S
: String);
318 -- Writes out a string (typically containing <<< or >>>}) for a node
319 -- created by rewriting the tree. Suppressed if we are outputting the
320 -- generated code only, since in this case we don't specially mark nodes
321 -- created by rewriting).
323 procedure Write_Source_Line
(L
: Physical_Line_Number
);
324 -- If writing of interspersed source lines is enabled, then write the given
325 -- line from the source file, preceded by Eol, then an extra blank line if
326 -- the line has at least one blank, is not a comment and is not line one,
327 -- then "--" and the line number followed by period followed by text of the
328 -- source line (without terminating Eol). If interspersed source line
329 -- output not enabled, then the call has no effect.
331 procedure Write_Source_Lines
(L
: Physical_Line_Number
);
332 -- If writing of interspersed source lines is enabled, then writes source
333 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
334 -- interspersed source line output not enabled, then call has no effect.
336 procedure Write_Str_Sloc
(S
: String);
337 -- Like Write_Str, but sets debug Sloc of current debug node to first
338 -- non-blank character if a current debug node is active.
340 procedure Write_Str_With_Col_Check
(S
: String);
341 -- Write string (using Write_Str) with initial column check, and possible
342 -- initial Write_Indent (to get new line) if current line is too full.
344 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
345 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
346 -- node to first non-blank character if a current debug node is active.
348 procedure Write_Subprogram_Name
(N
: Node_Id
);
349 -- N is the Name field of a function call or procedure statement call.
350 -- The effect of the call is to output the name, preceded by a $ if the
351 -- call is identified as an implicit call to a run time routine.
353 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
);
354 -- Write Uint (using UI_Write) with initial column check, and possible
355 -- initial Write_Indent (to get new line) if current line is too full.
356 -- The format parameter determines the output format (see UI_Write).
358 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
359 -- Write Uint (using UI_Write) with initial column check, and possible
360 -- initial Write_Indent (to get new line) if current line is too full.
361 -- The format parameter determines the output format (see UI_Write).
362 -- In addition, in Debug_Generated_Code mode, sets the current node
363 -- Sloc to the first character of the output value.
365 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
366 -- Write Ureal (using same output format as UR_Write) with column checks
367 -- and a possible initial Write_Indent (to get new line) if current line
368 -- is too full. In addition, in Debug_Generated_Code mode, sets the
369 -- current node Sloc to the first character of the output value.
375 procedure Col_Check
(N
: Nat
) is
377 if N
+ Column
> Sprint_Line_Limit
then
378 Write_Indent_Str
(" ");
382 ----------------------
383 -- Extra_Blank_Line --
384 ----------------------
386 procedure Extra_Blank_Line
is
388 if not Dump_Source_Text
then
391 end Extra_Blank_Line
;
397 procedure Indent_Annull
is
399 Indent_Annull_Flag
:= True;
406 procedure Indent_Begin
is
408 Indent
:= Indent
+ 3;
415 procedure Indent_End
is
417 Indent
:= Indent
- 3;
424 procedure pg
(Arg
: Union_Id
) is
426 Dump_Generated_Only
:= True;
427 Dump_Original_Only
:= False;
428 Dump_Freeze_Null
:= True;
429 Current_Source_File
:= No_Source_File
;
433 if Arg
in List_Range
then
434 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
436 elsif Arg
in Node_Range
then
437 Sprint_Node
(Node_Id
(Arg
));
451 procedure po
(Arg
: Union_Id
) is
453 Dump_Generated_Only
:= False;
454 Dump_Original_Only
:= True;
455 Dump_Freeze_Null
:= False;
456 Current_Source_File
:= No_Source_File
;
460 if Arg
in List_Range
then
461 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
463 elsif Arg
in Node_Range
then
464 Sprint_Node
(Node_Id
(Arg
));
474 ----------------------
475 -- Print_Debug_Line --
476 ----------------------
478 procedure Print_Debug_Line
(S
: String) is
480 Write_Debug_Line
(S
, Debug_Sloc
);
481 end Print_Debug_Line
;
487 procedure ps
(Arg
: Union_Id
) is
489 Dump_Generated_Only
:= False;
490 Dump_Original_Only
:= False;
491 Dump_Freeze_Null
:= False;
492 Current_Source_File
:= No_Source_File
;
496 if Arg
in List_Range
then
497 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
499 elsif Arg
in Node_Range
then
500 Sprint_Node
(Node_Id
(Arg
));
514 procedure Set_Debug_Sloc
is
516 if Debug_Generated_Code
and then Present
(Dump_Node
) then
518 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
521 -- Do not change the location of nodes defined in package Standard
522 -- and nodes of pragmas scanned by Targparm.
524 if Loc
<= Standard_Location
then
527 -- Update the location of a node which is part of the current .dg
528 -- output. This situation occurs in comma separated parameter
529 -- declarations since each parameter references the same parameter
530 -- type node (ie. obj1, obj2 : <param-type>).
532 -- Note: This case is needed here since we cannot use the routine
533 -- In_Extended_Main_Code_Unit with nodes whose location is a .dg
536 elsif Loc
>= First_Debug_Sloc
then
537 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
539 -- Do not change the location of nodes which are not part of the
542 elsif not In_Extended_Main_Code_Unit
(Loc
) then
546 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
550 -- We do not know the actual end location in the generated code and
551 -- it could be much closer than in the source code, so play safe.
553 if Nkind
(Dump_Node
) in N_Case_Statement | N_If_Statement
then
554 Set_End_Location
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
565 procedure Source_Dump
is
568 -- Put underline under string we just printed
574 procedure Underline
is
575 Col
: constant Int
:= Column
;
580 while Col
> Column
loop
587 -- Start of processing for Source_Dump
590 Dump_Generated_Only
:= Debug_Flag_G
or
591 Print_Generated_Code
or
592 Debug_Generated_Code
;
593 Dump_Original_Only
:= Debug_Flag_O
;
594 Dump_Freeze_Null
:= Debug_Flag_S
or Dump_Generated_Only
;
596 -- Note that we turn off the tree dump flags immediately, before
597 -- starting the dump. This avoids generating two copies of the dump
598 -- if an abort occurs after printing the dump, and more importantly,
599 -- avoids an infinite loop if an abort occurs during the dump.
602 Current_Source_File
:= No_Source_File
;
603 Debug_Flag_Z
:= False;
606 Write_Str
("Source recreated from tree of Standard (spec)");
608 Sprint_Node
(Standard_Package_Node
);
613 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
614 Debug_Flag_G
:= False;
615 Debug_Flag_O
:= False;
616 Debug_Flag_S
:= False;
617 First_Debug_Sloc
:= No_Location
;
619 -- Dump requested units
621 for U
in Main_Unit
.. Last_Unit
loop
622 Current_Source_File
:= Source_Index
(U
);
624 -- Dump all units if -gnatdf set, otherwise dump only the source
625 -- files that are in the extended main source. Note that, if we
626 -- are generating debug files, generating that of the main unit
627 -- has an effect on the outcome of In_Extended_Main_Source_Unit
628 -- because slocs are rewritten, so we also test for equality of
629 -- Cunit_Entity to work around this effect.
632 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
633 or else Cunit_Entity
(U
) = Cunit_Entity
(Main_Unit
)
635 -- If we are generating debug files, setup to write them
637 if Debug_Generated_Code
then
638 Set_Special_Output
(Print_Debug_Line
'Access);
639 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
640 First_Debug_Sloc
:= Debug_Sloc
;
641 Write_Source_Line
(1);
642 Last_Line_Printed
:= 1;
644 -- If this unit has the same entity as the main unit, for
645 -- example is the spec of a stand-alone instantiation of
646 -- a package and the main unit is the body, its debug file
647 -- will also be the same. Therefore, we need to print again
648 -- the main unit to have both units in the debug file.
651 and then Cunit_Entity
(U
) = Cunit_Entity
(Main_Unit
)
653 Sprint_Node
(Cunit
(Main_Unit
));
657 Sprint_Node
(Cunit
(U
));
658 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
661 Cancel_Special_Output
;
663 -- Normal output to standard output file
666 Write_Str
("Source recreated from tree for ");
667 Write_Unit_Name
(Unit_Name
(U
));
669 Write_Source_Line
(1);
670 Last_Line_Printed
:= 1;
671 Sprint_Node
(Cunit
(U
));
672 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
680 -- See above for the rationale, but we cannot do it earlier for them
682 Print_Generated_Code
:= False;
683 Debug_Generated_Code
:= False;
686 ---------------------
687 -- Sprint_And_List --
688 ---------------------
690 procedure Sprint_And_List
(List
: List_Id
) is
693 if Is_Non_Empty_List
(List
) then
694 Node
:= First
(List
);
698 exit when Node
= Empty
;
704 ----------------------------------
705 -- Sprint_Aspect_Specifications --
706 ----------------------------------
708 procedure Sprint_Aspect_Specifications
712 AS
: constant List_Id
:= Aspect_Specifications
(Node
);
717 Write_Erase_Char
(';');
718 Indent
:= Indent
+ 2;
721 Indent
:= Indent
+ 5;
724 Write_Str
(" with ");
729 Sprint_Node
(Identifier
(A
));
731 if Class_Present
(A
) then
732 Write_Str
("'Class");
735 if Present
(Expression
(A
)) then
737 Sprint_Node
(Expression
(A
));
751 Indent
:= Indent
- 7;
754 end Sprint_Aspect_Specifications
;
756 ------------------------
757 -- Sprint_At_End_Proc --
758 ------------------------
760 procedure Sprint_At_End_Proc
(Node
: Node_Id
) is
762 if Present
(At_End_Proc
(Node
)) then
763 Write_Indent_Str
("at end");
766 Sprint_Node
(At_End_Proc
(Node
));
770 end Sprint_At_End_Proc
;
772 ---------------------
773 -- Sprint_Bar_List --
774 ---------------------
776 procedure Sprint_Bar_List
(List
: List_Id
) is
779 if Is_Non_Empty_List
(List
) then
780 Node
:= First
(List
);
784 exit when Node
= Empty
;
790 ----------------------
791 -- Sprint_End_Label --
792 ----------------------
794 procedure Sprint_End_Label
800 and then Present
(End_Label
(Node
))
801 and then Is_Entity_Name
(End_Label
(Node
))
803 Set_Entity
(End_Label
(Node
), Default
);
805 -- For a function whose name is an operator, use the qualified name
806 -- created for the defining entity.
808 if Nkind
(End_Label
(Node
)) = N_Operator_Symbol
then
809 Set_Chars
(End_Label
(Node
), Chars
(Default
));
812 Sprint_Node
(End_Label
(Node
));
814 Sprint_Node
(Default
);
816 end Sprint_End_Label
;
818 -----------------------
819 -- Sprint_Comma_List --
820 -----------------------
822 procedure Sprint_Comma_List
(List
: List_Id
) is
826 if Is_Non_Empty_List
(List
) then
827 Node
:= First
(List
);
831 exit when Node
= Empty
;
833 if not Is_Rewrite_Insertion
(Node
)
834 or else not Dump_Original_Only
840 end Sprint_Comma_List
;
842 --------------------------
843 -- Sprint_Indented_List --
844 --------------------------
846 procedure Sprint_Indented_List
(List
: List_Id
) is
849 Sprint_Node_List
(List
);
851 end Sprint_Indented_List
;
853 ---------------------
854 -- Sprint_Left_Opnd --
855 ---------------------
857 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
858 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
861 if Paren_Count
(Opnd
) /= 0
862 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
871 end Sprint_Left_Opnd
;
877 procedure Sprint_Node
(Node
: Node_Id
) is
879 if Is_Rewrite_Insertion
(Node
) then
880 if not Dump_Original_Only
then
882 -- For special cases of nodes that always output <<< >>>
883 -- do not duplicate the output at this point.
885 if Nkind
(Node
) = N_Freeze_Entity
886 or else Nkind
(Node
) = N_Freeze_Generic_Entity
887 or else Nkind
(Node
) = N_Implicit_Label_Declaration
889 Sprint_Node_Actual
(Node
);
891 -- Normal case where <<< >>> may be required
894 Write_Rewrite_Str
("<<<");
895 Sprint_Node_Actual
(Node
);
896 Write_Rewrite_Str
(">>>");
900 elsif Is_Rewrite_Substitution
(Node
) then
902 -- Case of dump generated only
904 if Dump_Generated_Only
then
905 Sprint_Node_Actual
(Node
);
907 -- Case of dump original only
909 elsif Dump_Original_Only
then
910 Sprint_Node_Actual
(Original_Node
(Node
));
912 -- Case of both being dumped
915 Sprint_Node_Actual
(Original_Node
(Node
));
916 Write_Rewrite_Str
("<<<");
917 Sprint_Node_Actual
(Node
);
918 Write_Rewrite_Str
(">>>");
922 Sprint_Node_Actual
(Node
);
926 ------------------------
927 -- Sprint_Node_Actual --
928 ------------------------
930 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
931 Save_Dump_Node
: constant Node_Id
:= Dump_Node
;
938 for J
in 1 .. Paren_Count
(Node
) loop
939 Write_Str_With_Col_Check
("(");
942 -- Setup current dump node
946 if Nkind
(Node
) in N_Subexpr
947 and then Do_Range_Check
(Node
)
949 Write_Str_With_Col_Check
("{");
952 -- Select print circuit based on node kind
955 when N_Abort_Statement
=>
956 Write_Indent_Str_Sloc
("abort ");
957 Sprint_Comma_List
(Names
(Node
));
960 when N_Abortable_Part
=>
962 Write_Str_Sloc
("abort ");
963 Sprint_Indented_List
(Statements
(Node
));
965 when N_Abstract_Subprogram_Declaration
=>
967 Sprint_Node
(Specification
(Node
));
968 Write_Str_With_Col_Check
(" is ");
969 Write_Str_Sloc
("abstract;");
971 when N_Accept_Alternative
=>
972 Sprint_Node_List
(Pragmas_Before
(Node
));
974 if Present
(Condition
(Node
)) then
975 Write_Indent_Str
("when ");
976 Sprint_Node
(Condition
(Node
));
981 Sprint_Node_Sloc
(Accept_Statement
(Node
));
982 Sprint_Node_List
(Statements
(Node
));
984 when N_Accept_Statement
=>
985 Write_Indent_Str_Sloc
("accept ");
986 Write_Id
(Entry_Direct_Name
(Node
));
988 if Present
(Entry_Index
(Node
)) then
989 Write_Str_With_Col_Check
(" (");
990 Sprint_Node
(Entry_Index
(Node
));
994 Write_Param_Specs
(Node
);
996 if Present
(Handled_Statement_Sequence
(Node
)) then
997 Write_Str_With_Col_Check
(" do");
998 Sprint_Node
(Handled_Statement_Sequence
(Node
));
999 Write_Indent_Str
("end ");
1000 Write_Id
(Entry_Direct_Name
(Node
));
1005 when N_Access_Definition
=>
1007 -- Ada 2005 (AI-254)
1009 if Present
(Access_To_Subprogram_Definition
(Node
)) then
1010 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
1012 -- Ada 2005 (AI-231)
1014 if Null_Exclusion_Present
(Node
) then
1015 Write_Str
("not null ");
1018 Write_Str_With_Col_Check_Sloc
("access ");
1020 if All_Present
(Node
) then
1022 elsif Constant_Present
(Node
) then
1023 Write_Str
("constant ");
1026 Sprint_Node
(Subtype_Mark
(Node
));
1029 when N_Access_Function_Definition
=>
1031 -- Ada 2005 (AI-231)
1033 if Null_Exclusion_Present
(Node
) then
1034 Write_Str
("not null ");
1037 Write_Str_With_Col_Check_Sloc
("access ");
1039 if Protected_Present
(Node
) then
1040 Write_Str_With_Col_Check
("protected ");
1043 Write_Str_With_Col_Check
("function");
1044 Write_Param_Specs
(Node
);
1045 Write_Str_With_Col_Check
(" return ");
1046 Sprint_Node
(Result_Definition
(Node
));
1048 when N_Access_Procedure_Definition
=>
1050 -- Ada 2005 (AI-231)
1052 if Null_Exclusion_Present
(Node
) then
1053 Write_Str
("not null ");
1056 Write_Str_With_Col_Check_Sloc
("access ");
1058 if Protected_Present
(Node
) then
1059 Write_Str_With_Col_Check
("protected ");
1062 Write_Str_With_Col_Check
("procedure");
1063 Write_Param_Specs
(Node
);
1065 when N_Access_To_Object_Definition
=>
1066 Write_Str_With_Col_Check_Sloc
("access ");
1068 if All_Present
(Node
) then
1069 Write_Str_With_Col_Check
("all ");
1070 elsif Constant_Present
(Node
) then
1071 Write_Str_With_Col_Check
("constant ");
1074 -- Ada 2005 (AI-231)
1076 if Null_Exclusion_Present
(Node
) then
1077 Write_Str
("not null ");
1080 Sprint_Node
(Subtype_Indication
(Node
));
1083 if Null_Record_Present
(Node
) then
1084 Write_Str_With_Col_Check_Sloc
("(null record)");
1087 Write_Str_With_Col_Check_Sloc
("(");
1089 if Present
(Expressions
(Node
)) then
1090 Sprint_Comma_List
(Expressions
(Node
));
1092 if not Is_Empty_List
(Component_Associations
(Node
)) then
1097 if not Is_Empty_List
(Component_Associations
(Node
)) then
1104 Nd
:= First
(Component_Associations
(Node
));
1112 if not Is_Rewrite_Insertion
(Nd
)
1113 or else not Dump_Original_Only
1127 Write_Str_With_Col_Check_Sloc
("new ");
1129 -- Ada 2005 (AI-231)
1131 if Null_Exclusion_Present
(Node
) then
1132 Write_Str
("not null ");
1135 Sprint_Node
(Expression
(Node
));
1137 if Present
(Storage_Pool
(Node
)) then
1138 Write_Str_With_Col_Check
("[storage_pool = ");
1139 Sprint_Node
(Storage_Pool
(Node
));
1143 if Present
(Procedure_To_Call
(Node
)) then
1144 Write_Str_With_Col_Check
("[procedure_to_call = ");
1145 Sprint_Node
(Procedure_To_Call
(Node
));
1150 Sprint_Left_Opnd
(Node
);
1151 Write_Str_Sloc
(" and then ");
1152 Sprint_Right_Opnd
(Node
);
1154 -- Note: the following code for N_Aspect_Specification is not
1155 -- normally used, since we deal with aspects as part of a
1156 -- declaration, but it is here in case we deliberately try
1157 -- to print an N_Aspect_Specification node (e.g. from GDB).
1159 when N_Aspect_Specification
=>
1160 Sprint_Node
(Identifier
(Node
));
1162 Sprint_Node
(Expression
(Node
));
1164 when N_Assignment_Statement
=>
1166 Sprint_Node
(Name
(Node
));
1167 Write_Str_Sloc
(" := ");
1168 Sprint_Node
(Expression
(Node
));
1171 when N_Asynchronous_Select
=>
1172 Write_Indent_Str_Sloc
("select");
1174 Sprint_Node
(Triggering_Alternative
(Node
));
1177 -- Note: let the printing of Abortable_Part handle outputting
1178 -- the ABORT keyword, so that the Sloc can be set correctly.
1180 Write_Indent_Str
("then ");
1181 Sprint_Node
(Abortable_Part
(Node
));
1182 Write_Indent_Str
("end select;");
1185 Write_Indent_Str_Sloc
("for ");
1186 Write_Id
(Identifier
(Node
));
1187 Write_Str_With_Col_Check
(" use at ");
1188 Sprint_Node
(Expression
(Node
));
1191 when N_Attribute_Definition_Clause
=>
1192 Write_Indent_Str_Sloc
("for ");
1193 Sprint_Node
(Name
(Node
));
1195 Write_Name_With_Col_Check
(Chars
(Node
));
1196 Write_Str_With_Col_Check
(" use ");
1197 Sprint_Node
(Expression
(Node
));
1200 when N_Attribute_Reference
=>
1201 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1205 Sprint_Node
(Prefix
(Node
));
1206 Write_Char_Sloc
(''');
1207 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
1208 Sprint_Paren_Comma_List
(Expressions
(Node
));
1210 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1214 when N_Block_Statement
=>
1217 if Present
(Identifier
(Node
))
1218 and then (not Has_Created_Identifier
(Node
)
1219 or else not Dump_Original_Only
)
1221 Write_Rewrite_Str
("<<<");
1222 Write_Id
(Identifier
(Node
));
1224 Write_Rewrite_Str
(">>>");
1227 if Present
(Declarations
(Node
)) then
1228 Write_Str_With_Col_Check_Sloc
("declare");
1229 Sprint_Indented_List
(Declarations
(Node
));
1233 Write_Str_With_Col_Check_Sloc
("begin");
1234 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1235 Write_Indent_Str
("end");
1237 if Present
(Identifier
(Node
))
1238 and then (not Has_Created_Identifier
(Node
)
1239 or else not Dump_Original_Only
)
1241 Write_Rewrite_Str
("<<<");
1243 Write_Id
(Identifier
(Node
));
1244 Write_Rewrite_Str
(">>>");
1248 Sprint_At_End_Proc
(Node
);
1250 when N_Call_Marker
=>
1253 -- Enable the following code for debugging purposes only
1255 -- Write_Indent_Str ("#");
1256 -- Write_Id (Target (Node));
1257 -- Write_Char ('#');
1259 when N_Case_Expression
=>
1261 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
1265 -- The syntax for case_expression does not include parentheses,
1266 -- but sometimes parentheses are required, so unconditionally
1267 -- generate them here unless already present.
1269 if not Has_Parens
then
1273 Write_Str_With_Col_Check_Sloc
("case ");
1274 Sprint_Node
(Expression
(Node
));
1275 Write_Str_With_Col_Check
(" is");
1277 Alt
:= First
(Alternatives
(Node
));
1285 if not Has_Parens
then
1290 when N_Case_Expression_Alternative
=>
1291 Write_Str_With_Col_Check
(" when ");
1292 Sprint_Bar_List
(Discrete_Choices
(Node
));
1294 Sprint_Node
(Expression
(Node
));
1296 when N_Case_Statement
=>
1297 Write_Indent_Str_Sloc
("case ");
1298 Sprint_Node
(Expression
(Node
));
1300 Sprint_Indented_List
(Alternatives
(Node
));
1301 Write_Indent_Str
("end case;");
1303 when N_Case_Statement_Alternative
=>
1304 Write_Indent_Str_Sloc
("when ");
1305 Sprint_Bar_List
(Discrete_Choices
(Node
));
1307 Sprint_Indented_List
(Statements
(Node
));
1309 when N_Character_Literal
=>
1310 if Column
> Sprint_Line_Limit
- 2 then
1311 Write_Indent_Str
(" ");
1314 Write_Char_Sloc
(''');
1315 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
1318 when N_Code_Statement
=>
1321 Sprint_Node
(Expression
(Node
));
1324 when N_Compilation_Unit
=>
1325 Sprint_Node_List
(Context_Items
(Node
));
1326 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
1328 if Private_Present
(Node
) then
1329 Write_Indent_Str
("private ");
1333 Sprint_Node_Sloc
(Unit
(Node
));
1335 if Present
(Actions
(Aux_Decls_Node
(Node
)))
1337 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
1342 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
1343 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
1345 when N_Compilation_Unit_Aux
=>
1346 null; -- nothing to do, never used, see above
1348 when N_Component_Association
=>
1350 Sprint_Bar_List
(Choices
(Node
));
1353 -- Ada 2005 (AI-287): Print the box if present
1355 if Box_Present
(Node
) then
1356 Write_Str_With_Col_Check
("<>");
1358 Sprint_Node
(Expression
(Node
));
1361 when N_Iterated_Component_Association
=>
1363 Write_Str
(" for ");
1364 if Present
(Iterator_Specification
(Node
)) then
1365 Sprint_Node
(Iterator_Specification
(Node
));
1367 Write_Id
(Defining_Identifier
(Node
));
1369 Sprint_Bar_List
(Discrete_Choices
(Node
));
1372 Sprint_Node
(Expression
(Node
));
1374 when N_Iterated_Element_Association
=>
1376 if Present
(Iterator_Specification
(Node
)) then
1377 Sprint_Node
(Iterator_Specification
(Node
));
1379 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1382 if Present
(Key_Expression
(Node
)) then
1383 Write_Str
(" use ");
1384 Sprint_Node
(Key_Expression
(Node
));
1388 Sprint_Node
(Expression
(Node
));
1390 when N_Component_Clause
=>
1392 Sprint_Node
(Component_Name
(Node
));
1393 Write_Str_Sloc
(" at ");
1394 Sprint_Node
(Position
(Node
));
1396 Write_Str_With_Col_Check
("range ");
1397 Sprint_Node
(First_Bit
(Node
));
1399 Sprint_Node
(Last_Bit
(Node
));
1402 when N_Component_Definition
=>
1405 -- Ada 2005 (AI-230): Access definition components
1407 if Present
(Access_Definition
(Node
)) then
1408 Sprint_Node
(Access_Definition
(Node
));
1410 elsif Present
(Subtype_Indication
(Node
)) then
1411 if Aliased_Present
(Node
) then
1412 Write_Str_With_Col_Check
("aliased ");
1415 -- Ada 2005 (AI-231)
1417 if Null_Exclusion_Present
(Node
) then
1418 Write_Str
(" not null ");
1421 Sprint_Node
(Subtype_Indication
(Node
));
1424 Write_Str
(" ??? ");
1427 when N_Component_Declaration
=>
1428 if Write_Indent_Identifiers_Sloc
(Node
) then
1430 Sprint_Node
(Component_Definition
(Node
));
1432 if Present
(Expression
(Node
)) then
1434 Sprint_Node
(Expression
(Node
));
1440 when N_Component_List
=>
1441 if Null_Present
(Node
) then
1443 Write_Indent_Str_Sloc
("null");
1449 Sprint_Indented_List
(Component_Items
(Node
));
1450 Sprint_Node
(Variant_Part
(Node
));
1453 when N_Compound_Statement
=>
1454 Write_Indent_Str
("do");
1456 Sprint_Node_List
(Actions
(Node
));
1458 Write_Indent_Str
("end;");
1460 when N_Conditional_Entry_Call
=>
1461 Write_Indent_Str_Sloc
("select");
1463 Sprint_Node
(Entry_Call_Alternative
(Node
));
1465 Write_Indent_Str
("else");
1466 Sprint_Indented_List
(Else_Statements
(Node
));
1467 Write_Indent_Str
("end select;");
1469 when N_Constrained_Array_Definition
=>
1470 Write_Str_With_Col_Check_Sloc
("array ");
1471 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1474 Sprint_Node
(Component_Definition
(Node
));
1476 -- A contract node should not appear in the tree. It is a semantic
1477 -- node attached to entry and [generic] subprogram entities. But we
1478 -- still provide meaningful output, in case called from the debugger.
1486 Write_Str
("N_Contract node");
1489 Write_Indent_Str
("Pre_Post_Conditions");
1492 P
:= Pre_Post_Conditions
(Node
);
1493 while Present
(P
) loop
1495 P
:= Next_Pragma
(P
);
1501 Write_Indent_Str
("Contract_Test_Cases");
1504 P
:= Contract_Test_Cases
(Node
);
1505 while Present
(P
) loop
1507 P
:= Next_Pragma
(P
);
1513 Write_Indent_Str
("Classifications");
1516 P
:= Classifications
(Node
);
1517 while Present
(P
) loop
1519 P
:= Next_Pragma
(P
);
1527 when N_Decimal_Fixed_Point_Definition
=>
1528 Write_Str_With_Col_Check_Sloc
("delta ");
1529 Sprint_Node
(Delta_Expression
(Node
));
1530 Write_Str_With_Col_Check
(" digits ");
1531 Sprint_Node
(Digits_Expression
(Node
));
1532 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1534 when N_Defining_Character_Literal
=>
1535 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1537 when N_Defining_Identifier
=>
1541 when N_Defining_Operator_Symbol
=>
1542 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1544 when N_Defining_Program_Unit_Name
=>
1546 Sprint_Node
(Name
(Node
));
1548 Write_Id
(Defining_Identifier
(Node
));
1550 when N_Delay_Alternative
=>
1551 Sprint_Node_List
(Pragmas_Before
(Node
));
1553 if Present
(Condition
(Node
)) then
1555 Write_Str_With_Col_Check
("when ");
1556 Sprint_Node
(Condition
(Node
));
1561 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1562 Sprint_Node_List
(Statements
(Node
));
1564 when N_Delay_Relative_Statement
=>
1565 Write_Indent_Str_Sloc
("delay ");
1566 Sprint_Node
(Expression
(Node
));
1569 when N_Delay_Until_Statement
=>
1570 Write_Indent_Str_Sloc
("delay until ");
1571 Sprint_Node
(Expression
(Node
));
1574 when N_Delta_Constraint
=>
1575 Write_Str_With_Col_Check_Sloc
("delta ");
1576 Sprint_Node
(Delta_Expression
(Node
));
1577 Sprint_Opt_Node
(Range_Constraint
(Node
));
1579 when N_Derived_Type_Definition
=>
1580 if Abstract_Present
(Node
) then
1581 Write_Str_With_Col_Check
("abstract ");
1584 Write_Str_With_Col_Check
("new ");
1586 -- Ada 2005 (AI-231)
1588 if Null_Exclusion_Present
(Node
) then
1589 Write_Str_With_Col_Check
("not null ");
1592 Sprint_Node
(Subtype_Indication
(Node
));
1594 if Present
(Interface_List
(Node
)) then
1595 Write_Str_With_Col_Check
(" and ");
1596 Sprint_And_List
(Interface_List
(Node
));
1597 Write_Str_With_Col_Check
(" with ");
1600 if Present
(Record_Extension_Part
(Node
)) then
1601 if No
(Interface_List
(Node
)) then
1602 Write_Str_With_Col_Check
(" with ");
1605 Sprint_Node
(Record_Extension_Part
(Node
));
1608 when N_Designator
=>
1609 Sprint_Node
(Name
(Node
));
1610 Write_Char_Sloc
('.');
1611 Write_Id
(Identifier
(Node
));
1613 when N_Digits_Constraint
=>
1614 Write_Str_With_Col_Check_Sloc
("digits ");
1615 Sprint_Node
(Digits_Expression
(Node
));
1616 Sprint_Opt_Node
(Range_Constraint
(Node
));
1618 when N_Discriminant_Association
=>
1621 if Present
(Selector_Names
(Node
)) then
1622 Sprint_Bar_List
(Selector_Names
(Node
));
1627 Sprint_Node
(Expression
(Node
));
1629 when N_Discriminant_Specification
=>
1632 if Write_Identifiers
(Node
) then
1635 if Null_Exclusion_Present
(Node
) then
1636 Write_Str
("not null ");
1639 Sprint_Node
(Discriminant_Type
(Node
));
1641 if Present
(Expression
(Node
)) then
1643 Sprint_Node
(Expression
(Node
));
1649 when N_Elsif_Part
=>
1650 Write_Indent_Str_Sloc
("elsif ");
1651 Sprint_Node
(Condition
(Node
));
1652 Write_Str_With_Col_Check
(" then");
1653 Sprint_Indented_List
(Then_Statements
(Node
));
1658 when N_Entry_Body
=>
1659 Write_Indent_Str_Sloc
("entry ");
1660 Write_Id
(Defining_Identifier
(Node
));
1661 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1662 Write_Str_With_Col_Check
(" is");
1663 Sprint_Indented_List
(Declarations
(Node
));
1664 Write_Indent_Str
("begin");
1665 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1666 Write_Indent_Str
("end ");
1667 Write_Id
(Defining_Identifier
(Node
));
1669 Sprint_At_End_Proc
(Node
);
1671 when N_Entry_Body_Formal_Part
=>
1672 if Present
(Entry_Index_Specification
(Node
)) then
1673 Write_Str_With_Col_Check_Sloc
(" (");
1674 Sprint_Node
(Entry_Index_Specification
(Node
));
1678 Write_Param_Specs
(Node
);
1679 Write_Str_With_Col_Check_Sloc
(" when ");
1680 Sprint_Node
(Condition
(Node
));
1682 when N_Entry_Call_Alternative
=>
1683 Sprint_Node_List
(Pragmas_Before
(Node
));
1684 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1685 Sprint_Node_List
(Statements
(Node
));
1687 when N_Entry_Call_Statement
=>
1689 Sprint_Node_Sloc
(Name
(Node
));
1690 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1693 when N_Entry_Declaration
=>
1694 Write_Indent_Str_Sloc
("entry ");
1695 Write_Id
(Defining_Identifier
(Node
));
1697 if Present
(Discrete_Subtype_Definition
(Node
)) then
1698 Write_Str_With_Col_Check
(" (");
1699 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1703 Write_Param_Specs
(Node
);
1706 when N_Entry_Index_Specification
=>
1707 Write_Str_With_Col_Check_Sloc
("for ");
1708 Write_Id
(Defining_Identifier
(Node
));
1709 Write_Str_With_Col_Check
(" in ");
1710 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1712 when N_Enumeration_Representation_Clause
=>
1713 Write_Indent_Str_Sloc
("for ");
1714 Write_Id
(Identifier
(Node
));
1715 Write_Str_With_Col_Check
(" use ");
1716 Sprint_Node
(Array_Aggregate
(Node
));
1719 when N_Enumeration_Type_Definition
=>
1722 -- Skip attempt to print Literals field if it's not there and
1723 -- we are in package Standard (case of Character, which is
1724 -- handled specially (without an explicit literals list).
1726 if Sloc
(Node
) > Standard_Location
1727 or else Present
(Literals
(Node
))
1729 Sprint_Paren_Comma_List
(Literals
(Node
));
1733 Write_Str_With_Col_Check_Sloc
("<error>");
1735 when N_Exception_Declaration
=>
1736 if Write_Indent_Identifiers
(Node
) then
1737 Write_Str_With_Col_Check
(" : ");
1739 if Is_Statically_Allocated
(Defining_Identifier
(Node
)) then
1740 Write_Str_With_Col_Check
("static ");
1743 Write_Str_Sloc
("exception");
1745 if Present
(Expression
(Node
)) then
1747 Sprint_Node
(Expression
(Node
));
1753 when N_Exception_Handler
=>
1754 Write_Indent_Str_Sloc
("when ");
1756 if Present
(Choice_Parameter
(Node
)) then
1757 Sprint_Node
(Choice_Parameter
(Node
));
1761 Sprint_Bar_List
(Exception_Choices
(Node
));
1763 Sprint_Indented_List
(Statements
(Node
));
1765 when N_Exception_Renaming_Declaration
=>
1768 Sprint_Node
(Defining_Identifier
(Node
));
1769 Write_Str_With_Col_Check
(" : exception renames ");
1770 Sprint_Node
(Name
(Node
));
1773 when N_Exit_Statement
=>
1774 Write_Indent_Str_Sloc
("exit");
1775 Sprint_Opt_Node
(Name
(Node
));
1777 if Present
(Condition
(Node
)) then
1778 Write_Str_With_Col_Check
(" when ");
1779 Sprint_Node
(Condition
(Node
));
1784 when N_Expanded_Name
=>
1785 Sprint_Node
(Prefix
(Node
));
1786 Write_Char_Sloc
('.');
1787 Sprint_Node
(Selector_Name
(Node
));
1789 when N_Explicit_Dereference
=>
1790 Sprint_Node
(Prefix
(Node
));
1791 Write_Char_Sloc
('.');
1792 Write_Str_Sloc
("all");
1794 when N_Expression_With_Actions
=>
1796 Write_Indent_Str_Sloc
("do ");
1798 Sprint_Node_List
(Actions
(Node
));
1801 Write_Str_With_Col_Check_Sloc
("in ");
1802 Sprint_Node
(Expression
(Node
));
1803 Write_Str_With_Col_Check
(" end");
1807 when N_Expression_Function
=>
1809 Sprint_Node_Sloc
(Specification
(Node
));
1813 Sprint_Node
(Expression
(Node
));
1817 when N_Extended_Return_Statement
=>
1818 Write_Indent_Str_Sloc
("return ");
1819 Sprint_Node_List
(Return_Object_Declarations
(Node
));
1821 if Present
(Handled_Statement_Sequence
(Node
)) then
1822 Write_Str_With_Col_Check
(" do");
1823 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1824 Write_Indent_Str
("end return");
1827 if Present
(Storage_Pool
(Node
)) then
1828 Write_Str_With_Col_Check
("[storage_pool = ");
1829 Sprint_Node
(Storage_Pool
(Node
));
1833 if Present
(Procedure_To_Call
(Node
)) then
1834 Write_Str_With_Col_Check
("[procedure_to_call = ");
1835 Sprint_Node
(Procedure_To_Call
(Node
));
1841 when N_Delta_Aggregate
=>
1842 Write_Str_With_Col_Check_Sloc
("(");
1843 Sprint_Node
(Expression
(Node
));
1844 Write_Str_With_Col_Check
(" with delta ");
1845 Sprint_Comma_List
(Component_Associations
(Node
));
1848 when N_Extension_Aggregate
=>
1849 Write_Str_With_Col_Check_Sloc
("(");
1850 Sprint_Node
(Ancestor_Part
(Node
));
1851 Write_Str_With_Col_Check
(" with ");
1853 if Null_Record_Present
(Node
) then
1854 Write_Str_With_Col_Check
("null record");
1856 if Present
(Expressions
(Node
)) then
1857 Sprint_Comma_List
(Expressions
(Node
));
1859 if Present
(Component_Associations
(Node
)) then
1864 if Present
(Component_Associations
(Node
)) then
1865 Sprint_Comma_List
(Component_Associations
(Node
));
1871 when N_Floating_Point_Definition
=>
1872 Write_Str_With_Col_Check_Sloc
("digits ");
1873 Sprint_Node
(Digits_Expression
(Node
));
1874 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1876 when N_Formal_Decimal_Fixed_Point_Definition
=>
1877 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1879 when N_Formal_Derived_Type_Definition
=>
1880 Write_Str_With_Col_Check_Sloc
("new ");
1881 Sprint_Node
(Subtype_Mark
(Node
));
1883 if Present
(Interface_List
(Node
)) then
1884 Write_Str_With_Col_Check
(" and ");
1885 Sprint_And_List
(Interface_List
(Node
));
1888 if Private_Present
(Node
) then
1889 Write_Str_With_Col_Check
(" with private");
1892 when N_Formal_Abstract_Subprogram_Declaration
=>
1893 Write_Indent_Str_Sloc
("with ");
1894 Sprint_Node
(Specification
(Node
));
1896 Write_Str_With_Col_Check
(" is abstract");
1898 if Box_Present
(Node
) then
1899 Write_Str_With_Col_Check
(" <>");
1900 elsif Present
(Default_Name
(Node
)) then
1901 Write_Str_With_Col_Check
(" ");
1902 Sprint_Node
(Default_Name
(Node
));
1907 when N_Formal_Concrete_Subprogram_Declaration
=>
1908 Write_Indent_Str_Sloc
("with ");
1909 Sprint_Node
(Specification
(Node
));
1911 if Box_Present
(Node
) then
1912 Write_Str_With_Col_Check
(" is <>");
1913 elsif Present
(Default_Name
(Node
)) then
1914 Write_Str_With_Col_Check
(" is ");
1915 Sprint_Node
(Default_Name
(Node
));
1920 when N_Formal_Discrete_Type_Definition
=>
1921 Write_Str_With_Col_Check_Sloc
("<>");
1923 when N_Formal_Floating_Point_Definition
=>
1924 Write_Str_With_Col_Check_Sloc
("digits <>");
1926 when N_Formal_Modular_Type_Definition
=>
1927 Write_Str_With_Col_Check_Sloc
("mod <>");
1929 when N_Formal_Object_Declaration
=>
1932 if Write_Indent_Identifiers
(Node
) then
1935 if In_Present
(Node
) then
1936 Write_Str_With_Col_Check
("in ");
1939 if Out_Present
(Node
) then
1940 Write_Str_With_Col_Check
("out ");
1943 if Present
(Subtype_Mark
(Node
)) then
1945 -- Ada 2005 (AI-423): Formal object with null exclusion
1947 if Null_Exclusion_Present
(Node
) then
1948 Write_Str
("not null ");
1951 Sprint_Node
(Subtype_Mark
(Node
));
1953 -- Ada 2005 (AI-423): Formal object with access definition
1956 pragma Assert
(Present
(Access_Definition
(Node
)));
1958 Sprint_Node
(Access_Definition
(Node
));
1961 if Present
(Default_Expression
(Node
)) then
1963 Sprint_Node
(Default_Expression
(Node
));
1969 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1970 Write_Str_With_Col_Check_Sloc
("delta <>");
1972 when N_Formal_Package_Declaration
=>
1973 Write_Indent_Str_Sloc
("with package ");
1974 Write_Id
(Defining_Identifier
(Node
));
1975 Write_Str_With_Col_Check
(" is new ");
1976 Sprint_Node
(Name
(Node
));
1977 Write_Str_With_Col_Check
(" (<>);");
1979 when N_Formal_Private_Type_Definition
=>
1980 if Abstract_Present
(Node
) then
1981 Write_Str_With_Col_Check
("abstract ");
1984 if Tagged_Present
(Node
) then
1985 Write_Str_With_Col_Check
("tagged ");
1988 if Limited_Present
(Node
) then
1989 Write_Str_With_Col_Check
("limited ");
1992 Write_Str_With_Col_Check_Sloc
("private");
1994 when N_Formal_Incomplete_Type_Definition
=>
1995 if Tagged_Present
(Node
) then
1996 Write_Str_With_Col_Check
("is tagged ");
1999 when N_Formal_Signed_Integer_Type_Definition
=>
2000 Write_Str_With_Col_Check_Sloc
("range <>");
2002 when N_Formal_Type_Declaration
=>
2003 Write_Indent_Str_Sloc
("type ");
2004 Write_Id
(Defining_Identifier
(Node
));
2006 if Present
(Discriminant_Specifications
(Node
)) then
2007 Write_Discr_Specs
(Node
);
2008 elsif Unknown_Discriminants_Present
(Node
) then
2009 Write_Str_With_Col_Check
("(<>)");
2012 if Nkind
(Formal_Type_Definition
(Node
)) /=
2013 N_Formal_Incomplete_Type_Definition
2015 Write_Str_With_Col_Check
(" is ");
2018 Sprint_Node
(Formal_Type_Definition
(Node
));
2021 when N_Free_Statement
=>
2022 Write_Indent_Str_Sloc
("free ");
2023 Sprint_Node
(Expression
(Node
));
2025 if Present
(Storage_Pool
(Node
)) then
2026 Write_Str_With_Col_Check
("[storage_pool = ");
2027 Sprint_Node
(Storage_Pool
(Node
));
2031 if Present
(Procedure_To_Call
(Node
)) then
2032 Write_Str_With_Col_Check
("[procedure_to_call = ");
2033 Sprint_Node
(Procedure_To_Call
(Node
));
2039 when N_Freeze_Entity
=>
2040 if Dump_Original_Only
then
2043 -- A freeze node is output if it has some effect (i.e. non-empty
2044 -- actions, or freeze node for an itype, which causes elaboration
2045 -- of the itype), and is also always output if Dump_Freeze_Null
2048 elsif Present
(Actions
(Node
))
2049 or else Is_Itype
(Entity
(Node
))
2050 or else Dump_Freeze_Null
2053 Write_Rewrite_Str
("<<<");
2054 Write_Str_With_Col_Check_Sloc
("freeze ");
2055 Write_Id
(Entity
(Node
));
2058 if No
(Actions
(Node
)) then
2062 -- Output freeze actions. We increment Freeze_Indent during
2063 -- this output to avoid generating extra blank lines before
2064 -- any procedures included in the freeze actions.
2066 Freeze_Indent
:= Freeze_Indent
+ 1;
2067 Sprint_Indented_List
(Actions
(Node
));
2068 Freeze_Indent
:= Freeze_Indent
- 1;
2069 Write_Indent_Str
("]");
2072 Write_Rewrite_Str
(">>>");
2075 when N_Freeze_Generic_Entity
=>
2076 if Dump_Original_Only
then
2081 Write_Str_With_Col_Check_Sloc
("freeze_generic ");
2082 Write_Id
(Entity
(Node
));
2085 when N_Full_Type_Declaration
=>
2086 Write_Indent_Str_Sloc
("type ");
2087 Sprint_Node
(Defining_Identifier
(Node
));
2088 Write_Discr_Specs
(Node
);
2089 Write_Str_With_Col_Check
(" is ");
2090 Sprint_Node
(Type_Definition
(Node
));
2093 when N_Function_Call
=>
2095 Write_Subprogram_Name
(Name
(Node
));
2096 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2098 when N_Function_Instantiation
=>
2099 Write_Indent_Str_Sloc
("function ");
2100 Sprint_Node
(Defining_Unit_Name
(Node
));
2101 Write_Str_With_Col_Check
(" is new ");
2102 Sprint_Node
(Name
(Node
));
2103 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2106 when N_Function_Specification
=>
2107 Write_Str_With_Col_Check_Sloc
("function ");
2108 Sprint_Node
(Defining_Unit_Name
(Node
));
2109 Write_Param_Specs
(Node
);
2110 Write_Str_With_Col_Check
(" return ");
2112 -- Ada 2005 (AI-231)
2114 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
2115 and then Null_Exclusion_Present
(Node
)
2117 Write_Str
(" not null ");
2120 Sprint_Node
(Result_Definition
(Node
));
2122 when N_Generic_Association
=>
2125 if Present
(Selector_Name
(Node
)) then
2126 Sprint_Node
(Selector_Name
(Node
));
2130 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
2132 when N_Generic_Function_Renaming_Declaration
=>
2133 Write_Indent_Str_Sloc
("generic function ");
2134 Sprint_Node
(Defining_Unit_Name
(Node
));
2135 Write_Str_With_Col_Check
(" renames ");
2136 Sprint_Node
(Name
(Node
));
2139 when N_Generic_Declaration
=>
2141 Write_Indent_Str_Sloc
("generic ");
2142 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
2144 Sprint_Node
(Specification
(Node
));
2147 when N_Generic_Package_Renaming_Declaration
=>
2148 Write_Indent_Str_Sloc
("generic package ");
2149 Sprint_Node
(Defining_Unit_Name
(Node
));
2150 Write_Str_With_Col_Check
(" renames ");
2151 Sprint_Node
(Name
(Node
));
2154 when N_Generic_Procedure_Renaming_Declaration
=>
2155 Write_Indent_Str_Sloc
("generic procedure ");
2156 Sprint_Node
(Defining_Unit_Name
(Node
));
2157 Write_Str_With_Col_Check
(" renames ");
2158 Sprint_Node
(Name
(Node
));
2161 when N_Goto_Statement
=>
2162 Write_Indent_Str_Sloc
("goto ");
2163 Sprint_Node
(Name
(Node
));
2166 if Nkind
(Next
(Node
)) = N_Label
then
2170 when N_Goto_When_Statement
=>
2171 Write_Indent_Str_Sloc
("goto ");
2172 Sprint_Node
(Name
(Node
));
2173 Write_Str
(" when ");
2174 Sprint_Node
(Condition
(Node
));
2177 when N_Handled_Sequence_Of_Statements
=>
2179 Sprint_Indented_List
(Statements
(Node
));
2181 if Present
(Exception_Handlers
(Node
)) then
2182 Write_Indent_Str
("exception");
2184 Sprint_Node_List
(Exception_Handlers
(Node
));
2188 Sprint_At_End_Proc
(Node
);
2190 when N_Identifier
=>
2194 when N_If_Expression
=>
2196 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
2197 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
2198 Then_Expr
: constant Node_Id
:= Next
(Condition
);
2201 -- The syntax for if_expression does not include parentheses,
2202 -- but sometimes parentheses are required, so unconditionally
2203 -- generate them here unless already present.
2205 if not Has_Parens
then
2209 Write_Str_With_Col_Check_Sloc
("if ");
2210 Sprint_Node
(Condition
);
2211 Write_Str_With_Col_Check
(" then ");
2213 -- Defense against junk here
2215 if Present
(Then_Expr
) then
2216 Sprint_Node
(Then_Expr
);
2218 if Present
(Next
(Then_Expr
)) then
2219 Write_Str_With_Col_Check
(" else ");
2220 Sprint_Node
(Next
(Then_Expr
));
2224 if not Has_Parens
then
2229 when N_If_Statement
=>
2230 Write_Indent_Str_Sloc
("if ");
2231 Sprint_Node
(Condition
(Node
));
2232 Write_Str_With_Col_Check
(" then");
2233 Sprint_Indented_List
(Then_Statements
(Node
));
2234 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
2236 if Present
(Else_Statements
(Node
)) then
2237 Write_Indent_Str
("else");
2238 Sprint_Indented_List
(Else_Statements
(Node
));
2241 Write_Indent_Str
("end if;");
2243 when N_Implicit_Label_Declaration
=>
2244 if not Dump_Original_Only
then
2246 Write_Rewrite_Str
("<<<");
2248 Write_Id
(Defining_Identifier
(Node
));
2250 Write_Str_With_Col_Check
("label");
2251 Write_Rewrite_Str
(">>>");
2255 Sprint_Left_Opnd
(Node
);
2256 Write_Str_Sloc
(" in ");
2258 if Present
(Right_Opnd
(Node
)) then
2259 Sprint_Right_Opnd
(Node
);
2261 Sprint_Bar_List
(Alternatives
(Node
));
2264 when N_Incomplete_Type_Declaration
=>
2265 Write_Indent_Str_Sloc
("type ");
2266 Write_Id
(Defining_Identifier
(Node
));
2268 if Present
(Discriminant_Specifications
(Node
)) then
2269 Write_Discr_Specs
(Node
);
2270 elsif Unknown_Discriminants_Present
(Node
) then
2271 Write_Str_With_Col_Check
("(<>)");
2276 when N_Index_Or_Discriminant_Constraint
=>
2278 Sprint_Paren_Comma_List
(Constraints
(Node
));
2280 when N_Indexed_Component
=>
2281 Sprint_Node_Sloc
(Prefix
(Node
));
2282 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
2284 when N_Integer_Literal
=>
2285 if Print_In_Hex
(Node
) then
2286 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
2288 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
2291 when N_Iteration_Scheme
=>
2292 if Present
(Condition
(Node
)) then
2293 Write_Str_With_Col_Check_Sloc
("while ");
2294 Sprint_Node
(Condition
(Node
));
2296 Write_Str_With_Col_Check_Sloc
("for ");
2298 if Present
(Iterator_Specification
(Node
)) then
2299 Sprint_Node
(Iterator_Specification
(Node
));
2301 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2307 when N_Iterator_Specification
=>
2309 Write_Id
(Defining_Identifier
(Node
));
2311 if Present
(Subtype_Indication
(Node
)) then
2312 Write_Str_With_Col_Check
(" : ");
2313 Sprint_Node
(Subtype_Indication
(Node
));
2316 if Of_Present
(Node
) then
2317 Write_Str_With_Col_Check
(" of ");
2319 Write_Str_With_Col_Check
(" in ");
2322 if Reverse_Present
(Node
) then
2323 Write_Str_With_Col_Check
("reverse ");
2326 Sprint_Node
(Name
(Node
));
2328 if Present
(Iterator_Filter
(Node
)) then
2329 Write_Str
(" when ");
2330 Sprint_Node
(Iterator_Filter
(Node
));
2333 when N_Itype_Reference
=>
2334 Write_Indent_Str_Sloc
("reference ");
2335 Write_Id
(Itype
(Node
));
2338 Write_Indent_Str_Sloc
("<<");
2339 Write_Id
(Identifier
(Node
));
2342 when N_Loop_Parameter_Specification
=>
2344 Write_Id
(Defining_Identifier
(Node
));
2345 Write_Str_With_Col_Check
(" in ");
2347 if Reverse_Present
(Node
) then
2348 Write_Str_With_Col_Check
("reverse ");
2351 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
2353 when N_Loop_Statement
=>
2356 if Present
(Identifier
(Node
))
2357 and then (not Has_Created_Identifier
(Node
)
2358 or else not Dump_Original_Only
)
2360 Write_Rewrite_Str
("<<<");
2361 Write_Id
(Identifier
(Node
));
2363 Write_Rewrite_Str
(">>>");
2364 Sprint_Node
(Iteration_Scheme
(Node
));
2365 Write_Str_With_Col_Check_Sloc
("loop");
2366 Sprint_Indented_List
(Statements
(Node
));
2367 Write_Indent_Str
("end loop ");
2368 Write_Rewrite_Str
("<<<");
2369 Write_Id
(Identifier
(Node
));
2370 Write_Rewrite_Str
(">>>");
2374 Sprint_Node
(Iteration_Scheme
(Node
));
2375 Write_Str_With_Col_Check_Sloc
("loop");
2376 Sprint_Indented_List
(Statements
(Node
));
2377 Write_Indent_Str
("end loop;");
2380 when N_Mod_Clause
=>
2381 Sprint_Node_List
(Pragmas_Before
(Node
));
2382 Write_Str_With_Col_Check_Sloc
("at mod ");
2383 Sprint_Node
(Expression
(Node
));
2385 when N_Modular_Type_Definition
=>
2386 Write_Str_With_Col_Check_Sloc
("mod ");
2387 Sprint_Node
(Expression
(Node
));
2390 Sprint_Left_Opnd
(Node
);
2391 Write_Str_Sloc
(" not in ");
2393 if Present
(Right_Opnd
(Node
)) then
2394 Sprint_Right_Opnd
(Node
);
2396 Sprint_Bar_List
(Alternatives
(Node
));
2400 Write_Str_With_Col_Check_Sloc
("null");
2402 when N_Null_Statement
=>
2403 if Comes_From_Source
(Node
)
2404 or else Dump_Freeze_Null
2405 or else not Is_List_Member
(Node
)
2406 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
2408 Write_Indent_Str_Sloc
("null;");
2411 when N_Number_Declaration
=>
2414 if Write_Indent_Identifiers
(Node
) then
2415 Write_Str_With_Col_Check
(" : constant ");
2417 Sprint_Node
(Expression
(Node
));
2421 when N_Object_Declaration
=>
2424 if Write_Indent_Identifiers
(Node
) then
2426 Def_Id
: constant Entity_Id
:= Defining_Identifier
(Node
);
2429 Write_Str_With_Col_Check
(" : ");
2431 if Is_Statically_Allocated
(Def_Id
) then
2432 Write_Str_With_Col_Check
("static ");
2435 if Aliased_Present
(Node
) then
2436 Write_Str_With_Col_Check
("aliased ");
2439 if Constant_Present
(Node
) then
2440 Write_Str_With_Col_Check
("constant ");
2443 -- Ada 2005 (AI-231)
2445 if Null_Exclusion_Present
(Node
) then
2446 Write_Str_With_Col_Check
("not null ");
2449 -- Print type. We used to print the Object_Definition from
2450 -- the node, but it is much more useful to print the Etype
2451 -- of the defining identifier for the case where the nominal
2452 -- type is an unconstrained array type. For example, this
2453 -- will be a clear reference to the Itype with the bounds
2454 -- in the case of a type like String. The object after
2455 -- all is constrained, even if its nominal subtype is
2459 Odef
: constant Node_Id
:= Object_Definition
(Node
);
2462 if Nkind
(Odef
) = N_Identifier
2463 and then Present
(Etype
(Odef
))
2464 and then Is_Array_Type
(Etype
(Odef
))
2465 and then not Is_Constrained
(Etype
(Odef
))
2466 and then Present
(Etype
(Def_Id
))
2468 Sprint_Node
(Etype
(Def_Id
));
2470 -- In other cases, the nominal type is fine to print
2477 if Present
(Expression
(Node
))
2478 and then Expression
(Node
) /= Error
2479 and then not No_Initialization
(Node
)
2482 Sprint_Node
(Expression
(Node
));
2487 -- Handle implicit importation and implicit exportation of
2488 -- object declarations:
2489 -- $pragma import (Convention_Id, Def_Id, "...");
2490 -- $pragma export (Convention_Id, Def_Id, "...");
2492 if Is_Internal
(Def_Id
)
2493 and then Present
(Interface_Name
(Def_Id
))
2495 Write_Indent_Str_Sloc
("$pragma ");
2497 if Is_Imported
(Def_Id
) then
2498 Write_Str
("import (");
2500 else pragma Assert
(Is_Exported
(Def_Id
));
2501 Write_Str
("export (");
2505 Prefix
: constant String := "Convention_";
2506 S
: constant String := Convention
(Def_Id
)'Img;
2509 Name_Len
:= S
'Last - Prefix
'Last;
2510 Name_Buffer
(1 .. Name_Len
) :=
2511 S
(Prefix
'Last + 1 .. S
'Last);
2512 Set_Casing
(All_Lower_Case
);
2513 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2519 Write_String_Table_Entry
2520 (Strval
(Interface_Name
(Def_Id
)));
2526 when N_Object_Renaming_Declaration
=>
2529 Sprint_Node
(Defining_Identifier
(Node
));
2531 -- Ada 2005 (AI-230): Access renamings
2533 if Present
(Access_Definition
(Node
)) then
2535 Sprint_Node
(Access_Definition
(Node
));
2537 elsif Present
(Subtype_Mark
(Node
)) then
2540 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2542 if Null_Exclusion_Present
(Node
) then
2543 Write_Str
("not null ");
2546 Sprint_Node
(Subtype_Mark
(Node
));
2548 -- AI12-0275: Object_Renaming_Declaration without explicit subtype
2550 elsif Ada_Version
>= Ada_2022
then
2554 Write_Str
(" : ??? ");
2557 Write_Str_With_Col_Check
(" renames ");
2558 Sprint_Node
(Name
(Node
));
2562 Write_Operator
(Node
, "abs ");
2563 Sprint_Right_Opnd
(Node
);
2566 Sprint_Left_Opnd
(Node
);
2567 Write_Operator
(Node
, " + ");
2568 Sprint_Right_Opnd
(Node
);
2571 Sprint_Left_Opnd
(Node
);
2572 Write_Operator
(Node
, " and ");
2573 Sprint_Right_Opnd
(Node
);
2576 Sprint_Left_Opnd
(Node
);
2577 Write_Operator
(Node
, " & ");
2578 Sprint_Right_Opnd
(Node
);
2581 Sprint_Left_Opnd
(Node
);
2583 if Rounded_Result
(Node
) then
2586 Write_Operator
(Node
, "/ ");
2587 Sprint_Right_Opnd
(Node
);
2590 Sprint_Left_Opnd
(Node
);
2591 Write_Operator
(Node
, " = ");
2592 Sprint_Right_Opnd
(Node
);
2595 Sprint_Left_Opnd
(Node
);
2596 Write_Operator
(Node
, " ** ");
2597 Sprint_Right_Opnd
(Node
);
2600 Sprint_Left_Opnd
(Node
);
2601 Write_Operator
(Node
, " >= ");
2602 Sprint_Right_Opnd
(Node
);
2605 Sprint_Left_Opnd
(Node
);
2606 Write_Operator
(Node
, " > ");
2607 Sprint_Right_Opnd
(Node
);
2610 Sprint_Left_Opnd
(Node
);
2611 Write_Operator
(Node
, " <= ");
2612 Sprint_Right_Opnd
(Node
);
2615 Sprint_Left_Opnd
(Node
);
2616 Write_Operator
(Node
, " < ");
2617 Sprint_Right_Opnd
(Node
);
2620 Write_Operator
(Node
, "-");
2621 Sprint_Right_Opnd
(Node
);
2624 Sprint_Left_Opnd
(Node
);
2625 Write_Operator
(Node
, " mod ");
2626 Sprint_Right_Opnd
(Node
);
2628 when N_Op_Multiply
=>
2629 Sprint_Left_Opnd
(Node
);
2631 if Rounded_Result
(Node
) then
2634 Write_Operator
(Node
, "* ");
2635 Sprint_Right_Opnd
(Node
);
2638 Sprint_Left_Opnd
(Node
);
2639 Write_Operator
(Node
, " /= ");
2640 Sprint_Right_Opnd
(Node
);
2643 Write_Operator
(Node
, "not ");
2644 Sprint_Right_Opnd
(Node
);
2647 Sprint_Left_Opnd
(Node
);
2648 Write_Operator
(Node
, " or ");
2649 Sprint_Right_Opnd
(Node
);
2652 Write_Operator
(Node
, "+");
2653 Sprint_Right_Opnd
(Node
);
2656 Sprint_Left_Opnd
(Node
);
2657 Write_Operator
(Node
, " rem ");
2658 Sprint_Right_Opnd
(Node
);
2664 Write_Str_With_Col_Check
("(");
2665 Sprint_Node
(Left_Opnd
(Node
));
2667 Sprint_Node
(Right_Opnd
(Node
));
2670 when N_Op_Subtract
=>
2671 Sprint_Left_Opnd
(Node
);
2672 Write_Operator
(Node
, " - ");
2673 Sprint_Right_Opnd
(Node
);
2676 Sprint_Left_Opnd
(Node
);
2677 Write_Operator
(Node
, " xor ");
2678 Sprint_Right_Opnd
(Node
);
2680 when N_Operator_Symbol
=>
2681 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
2683 when N_Ordinary_Fixed_Point_Definition
=>
2684 Write_Str_With_Col_Check_Sloc
("delta ");
2685 Sprint_Node
(Delta_Expression
(Node
));
2686 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
2689 Sprint_Left_Opnd
(Node
);
2690 Write_Str_Sloc
(" or else ");
2691 Sprint_Right_Opnd
(Node
);
2693 when N_Others_Choice
=>
2694 if All_Others
(Node
) then
2695 Write_Str_With_Col_Check
("all ");
2698 Write_Str_With_Col_Check_Sloc
("others");
2700 when N_Package_Body
=>
2702 Write_Indent_Str_Sloc
("package body ");
2703 Sprint_Node
(Defining_Unit_Name
(Node
));
2705 Sprint_Indented_List
(Declarations
(Node
));
2707 if Present
(Handled_Statement_Sequence
(Node
)) then
2708 Write_Indent_Str
("begin");
2709 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2712 Write_Indent_Str
("end ");
2714 (Handled_Statement_Sequence
(Node
), Defining_Unit_Name
(Node
));
2716 Sprint_At_End_Proc
(Node
);
2718 when N_Package_Body_Stub
=>
2719 Write_Indent_Str_Sloc
("package body ");
2720 Sprint_Node
(Defining_Identifier
(Node
));
2721 Write_Str_With_Col_Check
(" is separate;");
2723 when N_Package_Declaration
=>
2726 Sprint_Node_Sloc
(Specification
(Node
));
2729 -- If this is an instantiation, get the aspects from the original
2730 -- instantiation node.
2732 if Is_Generic_Instance
(Defining_Entity
(Node
))
2733 and then Has_Aspects
2734 (Package_Instantiation
(Defining_Entity
(Node
)))
2736 Sprint_Aspect_Specifications
2737 (Package_Instantiation
(Defining_Entity
(Node
)),
2741 when N_Package_Instantiation
=>
2743 Write_Indent_Str_Sloc
("package ");
2744 Sprint_Node
(Defining_Unit_Name
(Node
));
2745 Write_Str
(" is new ");
2746 Sprint_Node
(Name
(Node
));
2747 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2750 when N_Package_Renaming_Declaration
=>
2751 Write_Indent_Str_Sloc
("package ");
2752 Sprint_Node
(Defining_Unit_Name
(Node
));
2753 Write_Str_With_Col_Check
(" renames ");
2754 Sprint_Node
(Name
(Node
));
2757 when N_Package_Specification
=>
2758 Write_Str_With_Col_Check_Sloc
("package ");
2759 Sprint_Node
(Defining_Unit_Name
(Node
));
2761 if Nkind
(Parent
(Node
)) = N_Generic_Package_Declaration
2762 and then Has_Aspects
(Parent
(Node
))
2764 Sprint_Aspect_Specifications
2765 (Parent
(Node
), Semicolon
=> False);
2767 -- An instantiation is rewritten as a package declaration, but
2768 -- the aspects belong to the instantiation node.
2770 elsif Nkind
(Parent
(Node
)) = N_Package_Declaration
then
2772 Pack
: constant Entity_Id
:= Defining_Entity
(Node
);
2775 if not Is_Generic_Instance
(Pack
) then
2776 if Has_Aspects
(Parent
(Node
)) then
2777 Sprint_Aspect_Specifications
2778 (Parent
(Node
), Semicolon
=> False);
2785 Sprint_Indented_List
(Visible_Declarations
(Node
));
2787 if Present
(Private_Declarations
(Node
)) then
2788 Write_Indent_Str
("private");
2789 Sprint_Indented_List
(Private_Declarations
(Node
));
2792 Write_Indent_Str
("end ");
2793 Sprint_Node
(Defining_Unit_Name
(Node
));
2795 when N_Parameter_Association
=>
2796 Sprint_Node_Sloc
(Selector_Name
(Node
));
2798 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2800 when N_Parameter_Specification
=>
2803 if Write_Identifiers
(Node
) then
2806 if In_Present
(Node
) then
2807 Write_Str_With_Col_Check
("in ");
2810 if Out_Present
(Node
) then
2811 Write_Str_With_Col_Check
("out ");
2814 -- Ada 2005 (AI-231): Parameter specification may carry null
2815 -- exclusion. Do not print it now if this is an access formal,
2816 -- it is emitted when the access definition is displayed.
2818 if Null_Exclusion_Present
(Node
)
2819 and then Nkind
(Parameter_Type
(Node
)) /= N_Access_Definition
2821 Write_Str
("not null ");
2824 if Aliased_Present
(Node
) then
2825 Write_Str
("aliased ");
2828 Sprint_Node
(Parameter_Type
(Node
));
2830 if Present
(Expression
(Node
)) then
2832 Sprint_Node
(Expression
(Node
));
2838 when N_Pop_Constraint_Error_Label
=>
2839 Write_Indent_Str
("%pop_constraint_error_label");
2841 when N_Pop_Program_Error_Label
=>
2842 Write_Indent_Str
("%pop_program_error_label");
2844 when N_Pop_Storage_Error_Label
=>
2845 Write_Indent_Str
("%pop_storage_error_label");
2847 when N_Private_Extension_Declaration
=>
2848 Write_Indent_Str_Sloc
("type ");
2849 Write_Id
(Defining_Identifier
(Node
));
2851 if Present
(Discriminant_Specifications
(Node
)) then
2852 Write_Discr_Specs
(Node
);
2853 elsif Unknown_Discriminants_Present
(Node
) then
2854 Write_Str_With_Col_Check
("(<>)");
2857 Write_Str_With_Col_Check
(" is new ");
2858 Sprint_Node
(Subtype_Indication
(Node
));
2860 if Present
(Interface_List
(Node
)) then
2861 Write_Str_With_Col_Check
(" and ");
2862 Sprint_And_List
(Interface_List
(Node
));
2865 Write_Str_With_Col_Check
(" with private;");
2867 when N_Private_Type_Declaration
=>
2868 Write_Indent_Str_Sloc
("type ");
2869 Write_Id
(Defining_Identifier
(Node
));
2871 if Present
(Discriminant_Specifications
(Node
)) then
2872 Write_Discr_Specs
(Node
);
2873 elsif Unknown_Discriminants_Present
(Node
) then
2874 Write_Str_With_Col_Check
("(<>)");
2879 if Tagged_Present
(Node
) then
2880 Write_Str_With_Col_Check
("tagged ");
2883 if Limited_Present
(Node
) then
2884 Write_Str_With_Col_Check
("limited ");
2887 Write_Str_With_Col_Check
("private;");
2889 when N_Push_Constraint_Error_Label
=>
2890 Write_Indent_Str
("%push_constraint_error_label (");
2892 if Present
(Exception_Label
(Node
)) then
2893 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2898 when N_Push_Program_Error_Label
=>
2899 Write_Indent_Str
("%push_program_error_label (");
2901 if Present
(Exception_Label
(Node
)) then
2902 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2907 when N_Push_Storage_Error_Label
=>
2908 Write_Indent_Str
("%push_storage_error_label (");
2910 if Present
(Exception_Label
(Node
)) then
2911 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2917 Write_Indent_Str_Sloc
("pragma ");
2918 Write_Name_With_Col_Check
(Pragma_Name_Unmapped
(Node
));
2920 if Present
(Pragma_Argument_Associations
(Node
)) then
2921 Sprint_Opt_Paren_Comma_List
2922 (Pragma_Argument_Associations
(Node
));
2927 when N_Pragma_Argument_Association
=>
2930 if Chars
(Node
) /= No_Name
then
2931 Write_Name_With_Col_Check
(Chars
(Node
));
2935 Sprint_Node
(Expression
(Node
));
2937 when N_Procedure_Call_Statement
=>
2940 Write_Subprogram_Name
(Name
(Node
));
2941 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2944 when N_Procedure_Instantiation
=>
2945 Write_Indent_Str_Sloc
("procedure ");
2946 Sprint_Node
(Defining_Unit_Name
(Node
));
2947 Write_Str_With_Col_Check
(" is new ");
2948 Sprint_Node
(Name
(Node
));
2949 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2952 when N_Procedure_Specification
=>
2953 Write_Str_With_Col_Check_Sloc
("procedure ");
2954 Sprint_Node
(Defining_Unit_Name
(Node
));
2955 Write_Param_Specs
(Node
);
2957 when N_Protected_Body
=>
2958 Write_Indent_Str_Sloc
("protected body ");
2959 Write_Id
(Defining_Identifier
(Node
));
2961 Sprint_Indented_List
(Declarations
(Node
));
2962 Write_Indent_Str
("end ");
2963 Write_Id
(Defining_Identifier
(Node
));
2966 when N_Protected_Body_Stub
=>
2967 Write_Indent_Str_Sloc
("protected body ");
2968 Write_Id
(Defining_Identifier
(Node
));
2969 Write_Str_With_Col_Check
(" is separate;");
2971 when N_Protected_Definition
=>
2973 Sprint_Indented_List
(Visible_Declarations
(Node
));
2975 if Present
(Private_Declarations
(Node
)) then
2976 Write_Indent_Str
("private");
2977 Sprint_Indented_List
(Private_Declarations
(Node
));
2980 Write_Indent_Str
("end ");
2982 when N_Protected_Type_Declaration
=>
2983 Write_Indent_Str_Sloc
("protected type ");
2984 Sprint_Node
(Defining_Identifier
(Node
));
2985 Write_Discr_Specs
(Node
);
2987 if Present
(Interface_List
(Node
)) then
2988 Write_Str
(" is new ");
2989 Sprint_And_List
(Interface_List
(Node
));
2990 Write_Str
(" with ");
2995 Sprint_Node
(Protected_Definition
(Node
));
2996 Write_Id
(Defining_Identifier
(Node
));
2999 when N_Qualified_Expression
=>
3000 Sprint_Node
(Subtype_Mark
(Node
));
3001 Write_Char_Sloc
(''');
3003 -- Print expression, make sure we have at least one level of
3004 -- parentheses around the expression. For cases of qualified
3005 -- expressions in the source, this is always the case, but
3006 -- for generated qualifications, there may be no explicit
3007 -- parentheses present.
3009 if Paren_Count
(Expression
(Node
)) /= 0 then
3010 Sprint_Node
(Expression
(Node
));
3014 Sprint_Node
(Expression
(Node
));
3016 -- Odd case, for the qualified expressions used in machine
3017 -- code the argument may be a procedure call, resulting in
3018 -- a junk semicolon before the right parent, get rid of it.
3020 Write_Erase_Char
(';');
3022 -- Now we can add the terminating right paren
3027 when N_Quantified_Expression
=>
3030 if All_Present
(Node
) then
3031 Write_Str
(" all ");
3033 Write_Str
(" some ");
3036 if Present
(Iterator_Specification
(Node
)) then
3037 Sprint_Node
(Iterator_Specification
(Node
));
3039 Sprint_Node
(Loop_Parameter_Specification
(Node
));
3043 Sprint_Node
(Condition
(Node
));
3045 when N_Raise_Expression
=>
3047 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
3050 -- The syntax for raise_expression does not include parentheses
3051 -- but sometimes parentheses are required, so unconditionally
3052 -- generate them here unless already present.
3054 if not Has_Parens
then
3058 Write_Str_With_Col_Check_Sloc
("raise ");
3059 Sprint_Node
(Name
(Node
));
3061 if Present
(Expression
(Node
)) then
3062 Write_Str_With_Col_Check
(" with ");
3063 Sprint_Node
(Expression
(Node
));
3066 if not Has_Parens
then
3071 when N_Raise_Constraint_Error
=>
3073 -- This node can be used either as a subexpression or as a
3074 -- statement form. The following test is a reasonably reliable
3075 -- way to distinguish the two cases.
3077 if Is_List_Member
(Node
)
3078 and then Nkind
(Parent
(Node
)) not in N_Subexpr
3083 Write_Str_With_Col_Check_Sloc
("[constraint_error");
3084 Write_Condition_And_Reason
(Node
);
3086 when N_Raise_Program_Error
=>
3088 -- This node can be used either as a subexpression or as a
3089 -- statement form. The following test is a reasonably reliable
3090 -- way to distinguish the two cases.
3092 if Is_List_Member
(Node
)
3093 and then Nkind
(Parent
(Node
)) not in N_Subexpr
3098 Write_Str_With_Col_Check_Sloc
("[program_error");
3099 Write_Condition_And_Reason
(Node
);
3101 when N_Raise_Storage_Error
=>
3103 -- This node can be used either as a subexpression or as a
3104 -- statement form. The following test is a reasonably reliable
3105 -- way to distinguish the two cases.
3107 if Is_List_Member
(Node
)
3108 and then Nkind
(Parent
(Node
)) not in N_Subexpr
3113 Write_Str_With_Col_Check_Sloc
("[storage_error");
3114 Write_Condition_And_Reason
(Node
);
3116 when N_Raise_Statement
=>
3117 Write_Indent_Str_Sloc
("raise ");
3118 Sprint_Node
(Name
(Node
));
3120 if Present
(Expression
(Node
)) then
3121 Write_Str_With_Col_Check_Sloc
(" with ");
3122 Sprint_Node
(Expression
(Node
));
3127 when N_Raise_When_Statement
=>
3128 Write_Indent_Str_Sloc
("raise ");
3129 Sprint_Node
(Name
(Node
));
3130 Write_Str
(" when ");
3131 Sprint_Node
(Condition
(Node
));
3133 if Present
(Expression
(Node
)) then
3134 Write_Str_With_Col_Check_Sloc
(" with ");
3135 Sprint_Node
(Expression
(Node
));
3141 Sprint_Node
(Low_Bound
(Node
));
3142 Write_Str_Sloc
(" .. ");
3143 if Present
(Etype
(Node
))
3144 and then Is_Fixed_Lower_Bound_Index_Subtype
(Etype
(Node
))
3148 Sprint_Node
(High_Bound
(Node
));
3150 Update_Itype
(Node
);
3152 when N_Range_Constraint
=>
3153 Write_Str_With_Col_Check_Sloc
("range ");
3154 Sprint_Node
(Range_Expression
(Node
));
3156 when N_Real_Literal
=>
3157 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
3159 when N_Real_Range_Specification
3160 | N_Signed_Integer_Type_Definition
3162 Write_Str_With_Col_Check_Sloc
("range ");
3163 Sprint_Node
(Low_Bound
(Node
));
3165 Sprint_Node
(High_Bound
(Node
));
3167 when N_Record_Definition
=>
3168 if Abstract_Present
(Node
) then
3169 Write_Str_With_Col_Check
("abstract ");
3172 if Tagged_Present
(Node
) then
3173 Write_Str_With_Col_Check
("tagged ");
3176 if Limited_Present
(Node
) then
3177 Write_Str_With_Col_Check
("limited ");
3180 if Null_Present
(Node
) then
3181 Write_Str_With_Col_Check_Sloc
("null record");
3184 Write_Str_With_Col_Check_Sloc
("record");
3185 Sprint_Node
(Component_List
(Node
));
3186 Write_Indent_Str
("end record");
3189 when N_Record_Representation_Clause
=>
3190 Write_Indent_Str_Sloc
("for ");
3191 Sprint_Node
(Identifier
(Node
));
3192 Write_Str_With_Col_Check
(" use record ");
3194 if Present
(Mod_Clause
(Node
)) then
3195 Sprint_Node
(Mod_Clause
(Node
));
3198 Sprint_Indented_List
(Component_Clauses
(Node
));
3199 Write_Indent_Str
("end record;");
3202 Sprint_Node
(Prefix
(Node
));
3203 Write_Str_With_Col_Check_Sloc
("'reference");
3205 when N_Requeue_Statement
=>
3206 Write_Indent_Str_Sloc
("requeue ");
3207 Sprint_Node
(Name
(Node
));
3209 if Abort_Present
(Node
) then
3210 Write_Str_With_Col_Check
(" with abort");
3215 when N_Return_When_Statement
=>
3216 Write_Indent_Str_Sloc
("return ");
3217 Sprint_Node
(Expression
(Node
));
3218 Write_Str
(" when ");
3219 Sprint_Node
(Condition
(Node
));
3222 when N_SCIL_Dispatch_Table_Tag_Init
=>
3223 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Tag_Init]");
3225 when N_SCIL_Dispatching_Call
=>
3226 Write_Indent_Str
("[N_SCIL_Dispatching_Node]");
3228 when N_SCIL_Membership_Test
=>
3229 Write_Indent_Str
("[N_SCIL_Membership_Test]");
3231 when N_Simple_Return_Statement
=>
3232 if Present
(Expression
(Node
)) then
3233 Write_Indent_Str_Sloc
("return ");
3234 Sprint_Node
(Expression
(Node
));
3236 Write_Indent_Str_Sloc
("return");
3239 if Present
(Storage_Pool
(Node
)) then
3240 Write_Str_With_Col_Check
("[storage_pool = ");
3241 Sprint_Node
(Storage_Pool
(Node
));
3245 if Present
(Procedure_To_Call
(Node
)) then
3246 Write_Str_With_Col_Check
("[procedure_to_call = ");
3247 Sprint_Node
(Procedure_To_Call
(Node
));
3253 when N_Selective_Accept
=>
3254 Write_Indent_Str_Sloc
("select");
3259 Alt_Node
:= First
(Select_Alternatives
(Node
));
3262 Sprint_Node
(Alt_Node
);
3265 exit when No
(Alt_Node
);
3266 Write_Indent_Str
("or");
3270 if Present
(Else_Statements
(Node
)) then
3271 Write_Indent_Str
("else");
3272 Sprint_Indented_List
(Else_Statements
(Node
));
3275 Write_Indent_Str
("end select;");
3277 when N_Single_Protected_Declaration
=>
3278 Write_Indent_Str_Sloc
("protected ");
3279 Write_Id
(Defining_Identifier
(Node
));
3281 Sprint_Node
(Protected_Definition
(Node
));
3282 Write_Id
(Defining_Identifier
(Node
));
3285 when N_Single_Task_Declaration
=>
3286 Write_Indent_Str_Sloc
("task ");
3287 Sprint_Node
(Defining_Identifier
(Node
));
3289 if Present
(Task_Definition
(Node
)) then
3291 Sprint_Node
(Task_Definition
(Node
));
3296 when N_Selected_Component
=>
3297 Sprint_Node
(Prefix
(Node
));
3298 Write_Char_Sloc
('.');
3299 Sprint_Node
(Selector_Name
(Node
));
3303 Sprint_Node
(Prefix
(Node
));
3304 Write_Str_With_Col_Check
(" (");
3305 Sprint_Node
(Discrete_Range
(Node
));
3308 when N_String_Literal
=>
3309 if String_Length
(Strval
(Node
)) + Column
> Sprint_Line_Limit
then
3310 Write_Indent_Str
(" ");
3314 Write_String_Table_Entry
(Strval
(Node
));
3316 when N_Interpolated_String_Literal
=>
3320 Str_Elem
: Node_Id
:= First
(Expressions
(Node
));
3321 Is_First
: Boolean := True;
3324 while Present
(Str_Elem
) loop
3325 if not Is_First
then
3329 if Nkind
(Str_Elem
) = N_String_Literal
then
3330 Sprint_Node
(Str_Elem
);
3335 Sprint_Node
(Str_Elem
);
3348 when N_Subprogram_Body
=>
3350 -- Output extra blank line unless we are in freeze actions
3352 if Freeze_Indent
= 0 then
3358 if Present
(Corresponding_Spec
(Node
)) then
3359 Sprint_Node_Sloc
(Parent
(Corresponding_Spec
(Node
)));
3361 Sprint_Node_Sloc
(Specification
(Node
));
3366 Sprint_Indented_List
(Declarations
(Node
));
3367 Write_Indent_Str
("begin");
3368 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3370 Write_Indent_Str
("end ");
3373 (Handled_Statement_Sequence
(Node
),
3374 Defining_Unit_Name
(Specification
(Node
)));
3376 Sprint_At_End_Proc
(Node
);
3378 if Is_List_Member
(Node
)
3379 and then Present
(Next
(Node
))
3380 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
3385 when N_Subprogram_Body_Stub
=>
3387 Sprint_Node_Sloc
(Specification
(Node
));
3388 Write_Str_With_Col_Check
(" is separate;");
3390 when N_Subprogram_Declaration
=>
3392 Sprint_Node_Sloc
(Specification
(Node
));
3394 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
3395 and then Null_Present
(Specification
(Node
))
3397 Write_Str_With_Col_Check
(" is null");
3402 when N_Subprogram_Renaming_Declaration
=>
3404 Sprint_Node
(Specification
(Node
));
3405 Write_Str_With_Col_Check_Sloc
(" renames ");
3406 Sprint_Node
(Name
(Node
));
3409 when N_Subtype_Declaration
=>
3410 Write_Indent_Str_Sloc
("subtype ");
3411 Sprint_Node
(Defining_Identifier
(Node
));
3414 -- Ada 2005 (AI-231)
3416 if Null_Exclusion_Present
(Node
) then
3417 Write_Str
("not null ");
3420 Sprint_Node
(Subtype_Indication
(Node
));
3423 when N_Subtype_Indication
=>
3424 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
3426 Sprint_Node
(Constraint
(Node
));
3429 Write_Indent_Str_Sloc
("separate (");
3430 Sprint_Node
(Name
(Node
));
3433 Sprint_Node
(Proper_Body
(Node
));
3435 when N_Target_Name
=>
3439 Write_Indent_Str_Sloc
("task body ");
3440 Write_Id
(Defining_Identifier
(Node
));
3442 Sprint_Indented_List
(Declarations
(Node
));
3443 Write_Indent_Str
("begin");
3444 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3445 Write_Indent_Str
("end ");
3447 (Handled_Statement_Sequence
(Node
), Defining_Identifier
(Node
));
3449 Sprint_At_End_Proc
(Node
);
3451 when N_Task_Body_Stub
=>
3452 Write_Indent_Str_Sloc
("task body ");
3453 Write_Id
(Defining_Identifier
(Node
));
3454 Write_Str_With_Col_Check
(" is separate;");
3456 when N_Task_Definition
=>
3458 Sprint_Indented_List
(Visible_Declarations
(Node
));
3460 if Present
(Private_Declarations
(Node
)) then
3461 Write_Indent_Str
("private");
3462 Sprint_Indented_List
(Private_Declarations
(Node
));
3465 Write_Indent_Str
("end ");
3466 Sprint_End_Label
(Node
, Defining_Identifier
(Parent
(Node
)));
3468 when N_Task_Type_Declaration
=>
3469 Write_Indent_Str_Sloc
("task type ");
3470 Sprint_Node
(Defining_Identifier
(Node
));
3471 Write_Discr_Specs
(Node
);
3473 if Present
(Interface_List
(Node
)) then
3474 Write_Str
(" is new ");
3475 Sprint_And_List
(Interface_List
(Node
));
3478 if Present
(Task_Definition
(Node
)) then
3479 if No
(Interface_List
(Node
)) then
3482 Write_Str
(" with ");
3485 Sprint_Node
(Task_Definition
(Node
));
3490 when N_Terminate_Alternative
=>
3491 Sprint_Node_List
(Pragmas_Before
(Node
));
3494 if Present
(Condition
(Node
)) then
3495 Write_Str_With_Col_Check
("when ");
3496 Sprint_Node
(Condition
(Node
));
3500 Write_Str_With_Col_Check_Sloc
("terminate;");
3501 Sprint_Node_List
(Pragmas_After
(Node
));
3503 when N_Timed_Entry_Call
=>
3504 Write_Indent_Str_Sloc
("select");
3506 Sprint_Node
(Entry_Call_Alternative
(Node
));
3508 Write_Indent_Str
("or");
3510 Sprint_Node
(Delay_Alternative
(Node
));
3512 Write_Indent_Str
("end select;");
3514 when N_Triggering_Alternative
=>
3515 Sprint_Node_List
(Pragmas_Before
(Node
));
3516 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
3517 Sprint_Node_List
(Statements
(Node
));
3519 when N_Type_Conversion
=>
3521 Sprint_Node
(Subtype_Mark
(Node
));
3524 if Conversion_OK
(Node
) then
3528 if Float_Truncate
(Node
) then
3532 if Rounded_Result
(Node
) then
3537 Sprint_Node
(Expression
(Node
));
3540 when N_Unchecked_Expression
=>
3543 Sprint_Node_Sloc
(Expression
(Node
));
3546 when N_Unchecked_Type_Conversion
=>
3547 Sprint_Node
(Subtype_Mark
(Node
));
3549 Write_Str_With_Col_Check
("(");
3550 Sprint_Node_Sloc
(Expression
(Node
));
3553 when N_Unconstrained_Array_Definition
=>
3554 Write_Str_With_Col_Check_Sloc
("array (");
3559 Node1
:= First
(Subtype_Marks
(Node
));
3561 Sprint_Node
(Node1
);
3562 Write_Str_With_Col_Check
(" range <>");
3564 exit when Node1
= Empty
;
3569 Write_Str
(") of ");
3570 Sprint_Node
(Component_Definition
(Node
));
3572 when N_Unused_At_Start | N_Unused_At_End
=>
3573 Write_Indent_Str
("***** Error, unused node encountered *****");
3576 when N_Use_Package_Clause
=>
3577 Write_Indent_Str_Sloc
("use ");
3578 Sprint_Node_Sloc
(Name
(Node
));
3581 when N_Use_Type_Clause
=>
3582 Write_Indent_Str_Sloc
("use type ");
3583 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
3586 when N_Validate_Unchecked_Conversion
=>
3587 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
3588 Sprint_Node
(Source_Type
(Node
));
3590 Sprint_Node
(Target_Type
(Node
));
3593 when N_Variable_Reference_Marker
=>
3596 -- Enable the following code for debugging purposes only
3598 -- if Is_Read (Node) and then Is_Write (Node) then
3599 -- Write_Indent_Str ("rw#");
3601 -- elsif Is_Read (Node) then
3602 -- Write_Indent_Str ("r#");
3605 -- pragma Assert (Is_Write (Node));
3606 -- Write_Indent_Str ("w#");
3609 -- Write_Id (Target (Node));
3610 -- Write_Char ('#');
3613 Write_Indent_Str_Sloc
("when ");
3614 Sprint_Bar_List
(Discrete_Choices
(Node
));
3616 Sprint_Node
(Component_List
(Node
));
3618 when N_Variant_Part
=>
3620 Write_Indent_Str_Sloc
("case ");
3621 Sprint_Node
(Name
(Node
));
3623 Sprint_Indented_List
(Variants
(Node
));
3624 Write_Indent_Str
("end case");
3627 when N_With_Clause
=>
3629 -- Special test, if we are dumping the original tree only,
3630 -- then we want to eliminate the bogus with clauses that
3631 -- correspond to the non-existent children of Text_IO.
3633 if Dump_Original_Only
3634 and then Is_Text_IO_Special_Unit
(Name
(Node
))
3638 -- Normal case, output the with clause
3641 if First_Name
(Node
) or else not Dump_Original_Only
then
3643 -- Ada 2005 (AI-50217): Print limited with_clauses
3645 if Private_Present
(Node
) and Limited_Present
(Node
) then
3646 Write_Indent_Str
("limited private with ");
3648 elsif Private_Present
(Node
) then
3649 Write_Indent_Str
("private with ");
3651 elsif Limited_Present
(Node
) then
3652 Write_Indent_Str
("limited with ");
3655 Write_Indent_Str
("with ");
3662 Sprint_Node_Sloc
(Name
(Node
));
3664 if Last_Name
(Node
) or else not Dump_Original_Only
then
3670 -- Print aspects, except for special case of package declaration,
3671 -- where the aspects are printed inside the package specification.
3673 if Has_Aspects
(Node
)
3674 and then Nkind
(Node
) not in
3675 N_Generic_Package_Declaration | N_Package_Declaration
3676 and then not Is_Empty_List
(Aspect_Specifications
(Node
))
3678 Sprint_Aspect_Specifications
(Node
, Semicolon
=> True);
3681 if Nkind
(Node
) in N_Subexpr
and then Do_Range_Check
(Node
) then
3685 for J
in 1 .. Paren_Count
(Node
) loop
3689 Dump_Node
:= Save_Dump_Node
;
3690 end Sprint_Node_Actual
;
3692 ----------------------
3693 -- Sprint_Node_List --
3694 ----------------------
3696 procedure Sprint_Node_List
(List
: List_Id
; New_Lines
: Boolean := False) is
3700 if Is_Non_Empty_List
(List
) then
3701 Node
:= First
(List
);
3706 exit when Node
= Empty
;
3710 if New_Lines
and then Column
/= 1 then
3713 end Sprint_Node_List
;
3715 ----------------------
3716 -- Sprint_Node_Sloc --
3717 ----------------------
3719 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
3723 if Debug_Generated_Code
and then Present
(Dump_Node
) then
3724 Set_Sloc
(Dump_Node
, Sloc
(Node
));
3727 end Sprint_Node_Sloc
;
3729 ---------------------
3730 -- Sprint_Opt_Node --
3731 ---------------------
3733 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
3735 if Present
(Node
) then
3739 end Sprint_Opt_Node
;
3741 --------------------------
3742 -- Sprint_Opt_Node_List --
3743 --------------------------
3745 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
3747 if Present
(List
) then
3748 Sprint_Node_List
(List
);
3750 end Sprint_Opt_Node_List
;
3752 ---------------------------------
3753 -- Sprint_Opt_Paren_Comma_List --
3754 ---------------------------------
3756 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
3758 if Is_Non_Empty_List
(List
) then
3760 Sprint_Paren_Comma_List
(List
);
3762 end Sprint_Opt_Paren_Comma_List
;
3764 -----------------------------
3765 -- Sprint_Paren_Comma_List --
3766 -----------------------------
3768 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
3770 Node_Exists
: Boolean := False;
3774 if Is_Non_Empty_List
(List
) then
3776 if Dump_Original_Only
then
3778 while Present
(N
) loop
3779 if not Is_Rewrite_Insertion
(N
) then
3780 Node_Exists
:= True;
3787 if not Node_Exists
then
3792 Write_Str_With_Col_Check
("(");
3793 Sprint_Comma_List
(List
);
3796 end Sprint_Paren_Comma_List
;
3798 ----------------------
3799 -- Sprint_Right_Opnd --
3800 ----------------------
3802 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
3803 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
3806 if Paren_Count
(Opnd
) /= 0
3807 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
3816 end Sprint_Right_Opnd
;
3822 procedure Update_Itype
(Node
: Node_Id
) is
3824 if Present
(Etype
(Node
))
3825 and then Is_Itype
(Etype
(Node
))
3826 and then Debug_Generated_Code
3828 Set_Sloc
(Etype
(Node
), Sloc
(Node
));
3832 ---------------------
3833 -- Write_Char_Sloc --
3834 ---------------------
3836 procedure Write_Char_Sloc
(C
: Character) is
3838 if Debug_Generated_Code
and then C
/= ' ' then
3843 end Write_Char_Sloc
;
3845 --------------------------------
3846 -- Write_Condition_And_Reason --
3847 --------------------------------
3849 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
3850 Cond
: constant Node_Id
:= Condition
(Node
);
3851 Image
: constant String := RT_Exception_Code
'Image
3852 (RT_Exception_Code
'Val
3853 (UI_To_Int
(Reason
(Node
))));
3856 if Present
(Cond
) then
3858 -- If condition is a single entity, or NOT with a single entity,
3859 -- output all on one line, since it will likely fit just fine.
3861 if Is_Entity_Name
(Cond
)
3862 or else (Nkind
(Cond
) = N_Op_Not
3863 and then Is_Entity_Name
(Right_Opnd
(Cond
)))
3865 Write_Str_With_Col_Check
(" when ");
3869 -- Otherwise for more complex condition, multiple lines
3872 Write_Str_With_Col_Check
(" when");
3873 Indent
:= Indent
+ 2;
3877 Indent
:= Indent
- 2;
3880 -- If no condition, just need a space (all on one line)
3890 for J
in 4 .. Image
'Last loop
3891 if Image
(J
) = '_' then
3894 Write_Char
(Fold_Lower
(Image
(J
)));
3899 end Write_Condition_And_Reason
;
3901 --------------------------------
3902 -- Write_Corresponding_Source --
3903 --------------------------------
3905 procedure Write_Corresponding_Source
(S
: String) is
3907 Src
: Source_Buffer_Ptr
;
3910 -- Ignore if there is no current source file, or we're not in dump
3911 -- source text mode, or if in freeze actions.
3913 if Current_Source_File
> No_Source_File
3914 and then Dump_Source_Text
3915 and then Freeze_Indent
= 0
3918 -- Ignore null string
3924 -- Ignore space or semicolon at end of given string
3926 if S
(S
'Last) = ' ' or else S
(S
'Last) = ';' then
3927 Write_Corresponding_Source
(S
(S
'First .. S
'Last - 1));
3931 -- Loop to look at next lines not yet printed in source file
3934 Last_Line_Printed
+ 1 .. Last_Source_Line
(Current_Source_File
)
3936 Src
:= Source_Text
(Current_Source_File
);
3937 Loc
:= Line_Start
(L
, Current_Source_File
);
3939 -- If comment, keep looking
3941 if Src
(Loc
.. Loc
+ 1) = "--" then
3944 -- Search to first non-blank
3947 while Src
(Loc
) not in Line_Terminator
loop
3951 if Src
(Loc
) /= ' ' and then Src
(Loc
) /= ASCII
.HT
then
3953 -- Loop through characters in string to see if we match
3955 for J
in S
'Range loop
3957 -- If mismatch, then not the case we are looking for
3959 if Src
(Loc
) /= S
(J
) then
3966 -- If we fall through, string matched, if white space or
3967 -- semicolon after the matched string, this is the case
3968 -- we are looking for.
3970 if Src
(Loc
) in Line_Terminator
3971 or else Src
(Loc
) = ' '
3972 or else Src
(Loc
) = ASCII
.HT
3973 or else Src
(Loc
) = ';'
3975 -- So output source lines up to and including this one
3977 Write_Source_Lines
(L
);
3986 -- Line was all blanks, or a comment line, keep looking
3990 end Write_Corresponding_Source
;
3992 -----------------------
3993 -- Write_Discr_Specs --
3994 -----------------------
3996 procedure Write_Discr_Specs
(N
: Node_Id
) is
4001 Specs
:= Discriminant_Specifications
(N
);
4003 if Present
(Specs
) then
4004 Write_Str_With_Col_Check
(" (");
4005 Spec
:= First
(Specs
);
4010 exit when Spec
= Empty
;
4012 -- Add semicolon, unless we are printing original tree and the
4013 -- next specification is part of a list (but not the first
4014 -- element of that list)
4016 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4023 end Write_Discr_Specs
;
4029 procedure Write_Ekind
(E
: Entity_Id
) is
4030 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
4033 Name_Len
:= S
'Length;
4034 Name_Buffer
(1 .. Name_Len
) := S
;
4035 Set_Casing
(Mixed_Case
);
4036 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4043 procedure Write_Id
(N
: Node_Id
) is
4045 -- Deal with outputting Itype
4047 -- Note: if we are printing the full tree with -gnatds, then we may
4048 -- end up picking up the Associated_Node link from a generic template
4049 -- here which overlaps the Entity field, but as documented, Write_Itype
4050 -- is defended against junk calls.
4052 if Nkind
(N
) in N_Entity
then
4054 elsif Nkind
(N
) in N_Has_Entity
then
4055 Write_Itype
(Entity
(N
));
4058 -- Case of a defining identifier
4060 if Nkind
(N
) = N_Defining_Identifier
then
4062 -- If defining identifier has an interface name (and no
4063 -- address clause), then we output the interface name.
4065 if (Is_Imported
(N
) or else Is_Exported
(N
))
4066 and then Present
(Interface_Name
(N
))
4067 and then No
(Address_Clause
(N
))
4069 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
4070 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4072 -- If no interface name (or inactive because there was
4073 -- an address clause), then just output the Chars name.
4076 Write_Name_With_Col_Check
(Chars
(N
));
4079 -- Case of selector of an expanded name where the expanded name
4080 -- has an associated entity, output this entity. Check that the
4081 -- entity or associated node is of the right kind, see above.
4083 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
4084 and then Selector_Name
(Parent
(N
)) = N
4085 and then Present
(Entity_Or_Associated_Node
(Parent
(N
)))
4086 and then Nkind
(Entity
(Parent
(N
))) in N_Entity
4088 Write_Id
(Entity
(Parent
(N
)));
4090 -- For any other node with an associated entity, output it
4092 elsif Nkind
(N
) in N_Has_Entity
4093 and then Present
(Entity_Or_Associated_Node
(N
))
4094 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
4096 Write_Id
(Entity
(N
));
4098 -- All other cases, we just print the Chars field
4101 Write_Name_With_Col_Check
(Chars
(N
));
4105 -----------------------
4106 -- Write_Identifiers --
4107 -----------------------
4109 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
4111 Sprint_Node
(Defining_Identifier
(Node
));
4112 Update_Itype
(Defining_Identifier
(Node
));
4114 -- The remainder of the declaration must be printed unless we are
4115 -- printing the original tree and this is not the last identifier
4118 not Dump_Original_Only
or else not More_Ids
(Node
);
4120 end Write_Identifiers
;
4122 ------------------------
4123 -- Write_Implicit_Def --
4124 ------------------------
4126 procedure Write_Implicit_Def
(E
: Entity_Id
) is
4131 when E_Array_Subtype
=>
4132 Write_Str_With_Col_Check
("subtype ");
4134 Write_Str_With_Col_Check
(" is ");
4135 Write_Id
(Base_Type
(E
));
4136 Write_Str_With_Col_Check
(" (");
4138 Ind
:= First_Index
(E
);
4139 while Present
(Ind
) loop
4143 if Present
(Ind
) then
4150 when E_Enumeration_Subtype
4151 | E_Signed_Integer_Subtype
4153 Write_Str_With_Col_Check
("subtype ");
4156 Write_Id
(Etype
(E
));
4157 Write_Str_With_Col_Check
(" range ");
4158 Sprint_Node
(Scalar_Range
(E
));
4162 Write_Str_With_Col_Check
("type ");
4164 Write_Str_With_Col_Check
(" is <");
4168 end Write_Implicit_Def
;
4174 procedure Write_Indent
is
4175 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
4178 if Indent_Annull_Flag
then
4179 Indent_Annull_Flag
:= False;
4181 -- Deal with Dump_Source_Text output. Note that we ignore implicit
4182 -- label declarations, since they typically have the sloc of the
4183 -- corresponding label, which really messes up the -gnatL output.
4186 and then Loc
> No_Location
4187 and then Nkind
(Dump_Node
) /= N_Implicit_Label_Declaration
4189 if Get_Source_File_Index
(Loc
) = Current_Source_File
then
4191 (Get_Physical_Line_Number
(Sloc
(Dump_Node
)));
4197 for J
in 1 .. Indent
loop
4203 ------------------------------
4204 -- Write_Indent_Identifiers --
4205 ------------------------------
4207 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
4209 -- We need to start a new line for every node, except in the case
4210 -- where we are printing the original tree and this is not the first
4211 -- defining identifier in the list.
4213 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
4216 -- If printing original tree and this is not the first defining
4217 -- identifier in the list, then the previous call to this procedure
4218 -- printed only the name, and we add a comma to separate the names.
4224 Sprint_Node
(Defining_Identifier
(Node
));
4226 -- The remainder of the declaration must be printed unless we are
4227 -- printing the original tree and this is not the last identifier
4230 not Dump_Original_Only
or else not More_Ids
(Node
);
4231 end Write_Indent_Identifiers
;
4233 -----------------------------------
4234 -- Write_Indent_Identifiers_Sloc --
4235 -----------------------------------
4237 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
4239 -- We need to start a new line for every node, except in the case
4240 -- where we are printing the original tree and this is not the first
4241 -- defining identifier in the list.
4243 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
4246 -- If printing original tree and this is not the first defining
4247 -- identifier in the list, then the previous call to this procedure
4248 -- printed only the name, and we add a comma to separate the names.
4255 Sprint_Node
(Defining_Identifier
(Node
));
4257 -- The remainder of the declaration must be printed unless we are
4258 -- printing the original tree and this is not the last identifier
4260 return not Dump_Original_Only
or else not More_Ids
(Node
);
4261 end Write_Indent_Identifiers_Sloc
;
4263 ----------------------
4264 -- Write_Indent_Str --
4265 ----------------------
4267 procedure Write_Indent_Str
(S
: String) is
4269 Write_Corresponding_Source
(S
);
4272 end Write_Indent_Str
;
4274 ---------------------------
4275 -- Write_Indent_Str_Sloc --
4276 ---------------------------
4278 procedure Write_Indent_Str_Sloc
(S
: String) is
4280 Write_Corresponding_Source
(S
);
4283 end Write_Indent_Str_Sloc
;
4289 procedure Write_Itype
(Typ
: Entity_Id
) is
4291 procedure Write_Header
(T
: Boolean := True);
4292 -- Write type if T is True, subtype if T is false
4298 procedure Write_Header
(T
: Boolean := True) is
4301 Write_Str
("[type ");
4303 Write_Str
("[subtype ");
4306 Write_Name_With_Col_Check
(Chars
(Typ
));
4310 -- Start of processing for Write_Itype
4313 if Nkind
(Typ
) in N_Entity
4314 and then Is_Itype
(Typ
)
4315 and then not Itype_Printed
(Typ
)
4317 -- Itype to be printed
4320 B
: constant Entity_Id
:= Etype
(Typ
);
4321 P
: constant Node_Id
:= Parent
(Typ
);
4322 S
: constant Saved_Output_Buffer
:= Save_Output_Buffer
;
4323 -- Save current output buffer
4325 Old_Sloc
: Source_Ptr
;
4326 -- Save sloc of related node, so it is not modified when
4327 -- printing with -gnatD.
4332 -- Write indentation at start of line
4334 for J
in 1 .. Indent
loop
4338 -- If we have a constructed declaration for the itype, print it
4341 and then Nkind
(P
) in N_Declaration
4342 and then Defining_Entity
(P
) = Typ
4344 -- We must set Itype_Printed true before the recursive call to
4345 -- print the node, otherwise we get an infinite recursion.
4347 Set_Itype_Printed
(Typ
, True);
4349 -- Write the declaration enclosed in [], avoiding new line
4350 -- at start of declaration, and semicolon at end.
4352 -- Note: The itype may be imported from another unit, in which
4353 -- case we do not want to modify the Sloc of the declaration.
4354 -- Otherwise the itype may appear to be in the current unit,
4355 -- and the back-end will reject a reference out of scope.
4358 Indent_Annull_Flag
:= True;
4359 Old_Sloc
:= Sloc
(P
);
4361 Set_Sloc
(P
, Old_Sloc
);
4362 Write_Erase_Char
(';');
4364 -- If no constructed declaration, then we have to concoct the
4365 -- source corresponding to the type entity that we have at hand.
4370 -- Access types and subtypes
4373 Write_Header
(Ekind
(Typ
) = E_Access_Type
);
4375 if Can_Never_Be_Null
(Typ
) then
4376 Write_Str
("not null ");
4379 Write_Str
("access ");
4381 if Is_Access_Constant
(Typ
) then
4382 Write_Str
("constant ");
4385 Write_Id
(Directly_Designated_Type
(Typ
));
4389 when E_Array_Type
=>
4391 Write_Str
("array (");
4393 X
:= First_Index
(Typ
);
4397 if not Is_Constrained
(Typ
) then
4398 Write_Str
(" range <>");
4406 Write_Str
(") of ");
4407 X
:= Component_Type
(Typ
);
4409 -- Preserve sloc of component type, which is defined
4410 -- elsewhere than the itype (see comment above).
4412 Old_Sloc
:= Sloc
(X
);
4414 Set_Sloc
(X
, Old_Sloc
);
4418 -- Preserve Sloc of index subtypes, as above
4420 when E_Array_Subtype
=>
4421 Write_Header
(False);
4422 Write_Id
(Etype
(Typ
));
4425 X
:= First_Index
(Typ
);
4427 Old_Sloc
:= Sloc
(X
);
4429 Set_Sloc
(X
, Old_Sloc
);
4437 -- Signed integer types, and modular integer subtypes,
4438 -- and also enumeration subtypes.
4440 when E_Enumeration_Subtype
4441 | E_Modular_Integer_Subtype
4442 | E_Signed_Integer_Subtype
4443 | E_Signed_Integer_Type
4445 Write_Header
(Ekind
(Typ
) = E_Signed_Integer_Type
);
4447 if Ekind
(Typ
) = E_Signed_Integer_Type
then
4453 -- Print bounds if different from base type
4456 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4457 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4462 -- B can either be a scalar type, in which case the
4463 -- declaration of Typ may constrain it with different
4464 -- bounds, or a private type, in which case we know
4465 -- that the declaration of Typ cannot have a scalar
4468 if Is_Scalar_Type
(B
) then
4469 BL
:= Type_Low_Bound
(B
);
4470 BH
:= Type_High_Bound
(B
);
4478 and then Nkind
(L
) = N_Integer_Literal
4479 and then Nkind
(H
) = N_Integer_Literal
4480 and then Nkind
(BL
) = N_Integer_Literal
4481 and then Nkind
(BH
) = N_Integer_Literal
4482 and then UI_Eq
(Intval
(L
), Intval
(BL
))
4483 and then UI_Eq
(Intval
(H
), Intval
(BH
)))
4488 Write_Str
(" range ");
4495 -- Modular integer types
4497 when E_Modular_Integer_Type
=>
4501 if No
(Modulus
(Typ
)) then
4502 Write_Uint_With_Col_Check
(Uint_0
, Auto
);
4504 Write_Uint_With_Col_Check
(Modulus
(Typ
), Auto
);
4507 -- Floating-point types and subtypes
4509 when E_Floating_Point_Subtype
4510 | E_Floating_Point_Type
4512 Write_Header
(Ekind
(Typ
) = E_Floating_Point_Type
);
4514 if Ekind
(Typ
) = E_Floating_Point_Type
then
4520 if Digits_Value
(Typ
) /= Digits_Value
(B
) then
4521 Write_Str
(" digits ");
4522 Write_Uint_With_Col_Check
4523 (Digits_Value
(Typ
), Decimal
);
4526 -- Print bounds if not different from base type
4529 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4530 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4531 BL
: constant Node_Id
:= Type_Low_Bound
(B
);
4532 BH
: constant Node_Id
:= Type_High_Bound
(B
);
4536 and then Nkind
(L
) = N_Real_Literal
4537 and then Nkind
(H
) = N_Real_Literal
4538 and then Nkind
(BL
) = N_Real_Literal
4539 and then Nkind
(BH
) = N_Real_Literal
4540 and then UR_Eq
(Realval
(L
), Realval
(BL
))
4541 and then UR_Eq
(Realval
(H
), Realval
(BH
))
4546 Write_Str
(" range ");
4553 -- Ordinary fixed-point types and subtypes
4555 when E_Ordinary_Fixed_Point_Subtype
4556 | E_Ordinary_Fixed_Point_Type
4558 Write_Header
(Ekind
(Typ
) = E_Ordinary_Fixed_Point_Type
);
4560 Write_Str
("delta ");
4561 Write_Ureal_With_Col_Check_Sloc
(Delta_Value
(Typ
));
4562 Write_Str
(" range ");
4563 Sprint_Node
(Type_Low_Bound
(Typ
));
4565 Sprint_Node
(Type_High_Bound
(Typ
));
4567 -- Decimal fixed-point types and subtypes
4569 when E_Decimal_Fixed_Point_Subtype
4570 | E_Decimal_Fixed_Point_Type
4572 Write_Header
(Ekind
(Typ
) = E_Decimal_Fixed_Point_Type
);
4574 Write_Str
("delta ");
4575 Write_Ureal_With_Col_Check_Sloc
(Delta_Value
(Typ
));
4576 Write_Str
(" digits ");
4577 Write_Uint_With_Col_Check
(Digits_Value
(Typ
), Decimal
);
4581 when E_Record_Subtype
4582 | E_Record_Subtype_With_Private
4584 Write_Header
(False);
4585 Write_Str
("record");
4591 C
:= First_Entity
(Typ
);
4592 while Present
(C
) loop
4596 Write_Id
(Etype
(C
));
4602 Write_Indent_Str
(" end record");
4606 when E_Class_Wide_Subtype
4609 Write_Header
(Ekind
(Typ
) = E_Class_Wide_Type
);
4610 Write_Name_With_Col_Check
(Chars
(Etype
(Typ
)));
4611 Write_Str
("'Class");
4615 when E_Subprogram_Type
=>
4618 if Etype
(Typ
) = Standard_Void_Type
then
4619 Write_Str
("procedure");
4621 Write_Str
("function");
4624 if Present
(First_Entity
(Typ
)) then
4631 Param
:= First_Entity
(Typ
);
4636 if Ekind
(Param
) = E_In_Out_Parameter
then
4637 Write_Str
("in out ");
4638 elsif Ekind
(Param
) = E_Out_Parameter
then
4642 Write_Id
(Etype
(Param
));
4643 Next_Entity
(Param
);
4644 exit when No
(Param
);
4648 if Present
(Extra_Formals
(Typ
)) then
4649 Param
:= Extra_Formals
(Typ
);
4651 while Present
(Param
) loop
4655 Write_Id
(Etype
(Param
));
4657 Param
:= Extra_Formal
(Param
);
4664 elsif Present
(Extra_Formals
(Typ
)) then
4671 Param
:= Extra_Formals
(Typ
);
4673 while Present
(Param
) loop
4676 Write_Id
(Etype
(Param
));
4678 if Present
(Extra_Formal
(Param
)) then
4682 Param
:= Extra_Formal
(Param
);
4689 if Etype
(Typ
) /= Standard_Void_Type
then
4690 Write_Str
(" return ");
4691 Write_Id
(Etype
(Typ
));
4694 when E_String_Literal_Subtype
=>
4696 L
: constant Uint
:=
4697 Expr_Value
(String_Literal_Low_Bound
(Typ
));
4698 Len
: constant Uint
:=
4699 String_Literal_Length
(Typ
);
4701 Write_Header
(False);
4702 Write_Str
("String (");
4703 Write_Int
(UI_To_Int
(L
));
4705 Write_Int
(UI_To_Int
(L
+ Len
) - 1);
4709 -- For all other Itypes, print a triple ? (fill in later
4713 Write_Header
(True);
4718 -- Add terminating bracket and restore output buffer
4722 Restore_Output_Buffer
(S
);
4725 Set_Itype_Printed
(Typ
);
4729 -------------------------------
4730 -- Write_Name_With_Col_Check --
4731 -------------------------------
4733 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
4739 -- Avoid crashing on invalid Name_Ids
4741 if not Is_Valid_Name
(N
) then
4742 Write_Str
("<invalid name ");
4743 Write_Int
(Int
(N
));
4748 Get_Name_String
(N
);
4750 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4751 -- upper case letter, nnn is one or more digits and b is a lower case
4752 -- letter by C...b, so that listings do not depend on serial numbers.
4754 if Debug_Flag_II
then
4756 while J
< Name_Len
- 1 loop
4757 if Name_Buffer
(J
) in 'A' .. 'Z'
4758 and then Name_Buffer
(J
+ 1) in '0' .. '9'
4761 while K
< Name_Len
loop
4762 exit when Name_Buffer
(K
) not in '0' .. '9';
4766 if Name_Buffer
(K
) in 'a' .. 'z' then
4767 L
:= Name_Len
- K
+ 1;
4769 Name_Buffer
(J
+ 4 .. J
+ L
+ 3) :=
4770 Name_Buffer
(K
.. Name_Len
);
4771 Name_Buffer
(J
+ 1 .. J
+ 3) := "...";
4772 Name_Len
:= J
+ L
+ 3;
4785 -- Fall through for normal case
4787 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4788 end Write_Name_With_Col_Check
;
4790 ------------------------------------
4791 -- Write_Name_With_Col_Check_Sloc --
4792 ------------------------------------
4794 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
4796 -- Avoid crashing on invalid Name_Ids
4798 if not Is_Valid_Name
(N
) then
4799 Write_Str
("<invalid name ");
4800 Write_Int
(Int
(N
));
4805 Get_Name_String
(N
);
4806 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
4807 end Write_Name_With_Col_Check_Sloc
;
4809 --------------------
4810 -- Write_Operator --
4811 --------------------
4813 procedure Write_Operator
(N
: Node_Id
; S
: String) is
4814 F
: Natural := S
'First;
4815 T
: Natural := S
'Last;
4818 -- If no overflow check, just write string out, and we are done
4820 if not Do_Overflow_Check
(N
) then
4823 -- If overflow check, we want to surround the operator with curly
4824 -- brackets, but not include spaces within the brackets.
4837 Write_Str_Sloc
(S
(F
.. T
));
4840 if S
(S
'Last) = ' ' then
4846 -----------------------
4847 -- Write_Param_Specs --
4848 -----------------------
4850 procedure Write_Param_Specs
(N
: Node_Id
) is
4851 Specs
: constant List_Id
:= Parameter_Specifications
(N
);
4852 Specs_Present
: constant Boolean := Is_Non_Empty_List
(Specs
);
4859 Output
: Boolean := False;
4860 -- Set true if we output at least one parameter
4863 -- Write out explicit specs from Parameter_Specifications list
4865 if Specs_Present
then
4866 Write_Str_With_Col_Check
(" (");
4869 Spec
:= First
(Specs
);
4872 Formal
:= Defining_Identifier
(Spec
);
4874 exit when Spec
= Empty
;
4876 -- Add semicolon, unless we are printing original tree and the
4877 -- next specification is part of a list (but not the first element
4880 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4886 -- See if we have extra formals
4888 if Nkind
(N
) in N_Function_Specification | N_Procedure_Specification
then
4889 Ent
:= Defining_Entity
(N
);
4891 -- Loop to write extra formals (if any)
4893 if Present
(Ent
) and then Is_Subprogram
(Ent
) then
4894 Extras
:= Extra_Formals
(Ent
);
4896 if Present
(Extras
) then
4897 if not Specs_Present
then
4898 Write_Str_With_Col_Check
(" (");
4903 while Present
(Formal
) loop
4904 if Specs_Present
or else Formal
/= Extras
then
4908 Write_Name_With_Col_Check
(Chars
(Formal
));
4910 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
4911 Formal
:= Extra_Formal
(Formal
);
4920 end Write_Param_Specs
;
4922 -----------------------
4923 -- Write_Rewrite_Str --
4924 -----------------------
4926 procedure Write_Rewrite_Str
(S
: String) is
4928 if not Dump_Generated_Only
then
4929 if S
'Length = 3 and then S
= ">>>" then
4932 Write_Str_With_Col_Check
(S
);
4935 end Write_Rewrite_Str
;
4937 -----------------------
4938 -- Write_Source_Line --
4939 -----------------------
4941 procedure Write_Source_Line
(L
: Physical_Line_Number
) is
4943 Src
: Source_Buffer_Ptr
;
4947 if Dump_Source_Text
then
4948 Src
:= Source_Text
(Current_Source_File
);
4949 Loc
:= Line_Start
(L
, Current_Source_File
);
4952 -- See if line is a comment line, if not, and if not line one,
4953 -- precede with blank line.
4956 while Src
(Scn
) = ' ' or else Src
(Scn
) = ASCII
.HT
loop
4960 if (Src
(Scn
) in Line_Terminator
4961 or else Src
(Scn
.. Scn
+ 1) /= "--")
4967 -- Now write the source text of the line
4970 Write_Int
(Int
(L
));
4973 -- We need to check for EOF here, in case the last line of the source
4974 -- file does not have a Line_Terminator.
4976 while Src
(Loc
) not in Line_Terminator | EOF
loop
4977 Write_Char
(Src
(Loc
));
4981 end Write_Source_Line
;
4983 ------------------------
4984 -- Write_Source_Lines --
4985 ------------------------
4987 procedure Write_Source_Lines
(L
: Physical_Line_Number
) is
4989 while Last_Line_Printed
< L
loop
4990 Last_Line_Printed
:= Last_Line_Printed
+ 1;
4991 Write_Source_Line
(Last_Line_Printed
);
4993 end Write_Source_Lines
;
4995 --------------------
4996 -- Write_Str_Sloc --
4997 --------------------
4999 procedure Write_Str_Sloc
(S
: String) is
5001 for J
in S
'Range loop
5002 Write_Char_Sloc
(S
(J
));
5006 ------------------------------
5007 -- Write_Str_With_Col_Check --
5008 ------------------------------
5010 procedure Write_Str_With_Col_Check
(S
: String) is
5012 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
5013 Write_Indent_Str
(" ");
5015 if S
(S
'First) = ' ' then
5016 Write_Str
(S
(S
'First + 1 .. S
'Last));
5024 end Write_Str_With_Col_Check
;
5026 -----------------------------------
5027 -- Write_Str_With_Col_Check_Sloc --
5028 -----------------------------------
5030 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
5032 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
5033 Write_Indent_Str
(" ");
5035 if S
(S
'First) = ' ' then
5036 Write_Str_Sloc
(S
(S
'First + 1 .. S
'Last));
5044 end Write_Str_With_Col_Check_Sloc
;
5046 ---------------------------
5047 -- Write_Subprogram_Name --
5048 ---------------------------
5050 procedure Write_Subprogram_Name
(N
: Node_Id
) is
5052 if not Comes_From_Source
(N
)
5053 and then Is_Entity_Name
(N
)
5056 Ent
: constant Entity_Id
:= Entity
(N
);
5058 if not In_Extended_Main_Source_Unit
(Ent
)
5059 and then In_Predefined_Unit
(Ent
)
5061 -- Run-time routine name, output name with a preceding dollar
5062 -- making sure that we do not get a line split between them.
5064 Col_Check
(Length_Of_Name
(Chars
(Ent
)) + 1);
5066 Write_Name
(Chars
(Ent
));
5072 -- Normal case, not a run-time routine name
5075 end Write_Subprogram_Name
;
5077 -------------------------------
5078 -- Write_Uint_With_Col_Check --
5079 -------------------------------
5081 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
) is
5083 Col_Check
(UI_Decimal_Digits_Hi
(U
));
5084 UI_Write
(U
, Format
);
5085 end Write_Uint_With_Col_Check
;
5087 ------------------------------------
5088 -- Write_Uint_With_Col_Check_Sloc --
5089 ------------------------------------
5091 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
5093 Col_Check
(UI_Decimal_Digits_Hi
(U
));
5095 UI_Write
(U
, Format
);
5096 end Write_Uint_With_Col_Check_Sloc
;
5098 -------------------------------------
5099 -- Write_Ureal_With_Col_Check_Sloc --
5100 -------------------------------------
5102 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
5103 D
: constant Uint
:= Denominator
(U
);
5104 N
: constant Uint
:= Numerator
(U
);
5106 Col_Check
(UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
5108 UR_Write
(U
, Brackets
=> True);
5109 end Write_Ureal_With_Col_Check_Sloc
;