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
1088 (if Is_Homogeneous_Aggregate
(Node
) then "[" else "(");
1090 if Present
(Expressions
(Node
)) then
1091 Sprint_Comma_List
(Expressions
(Node
));
1093 if not Is_Empty_List
(Component_Associations
(Node
)) then
1098 if not Is_Empty_List
(Component_Associations
(Node
)) then
1105 Nd
:= First
(Component_Associations
(Node
));
1113 if not Is_Rewrite_Insertion
(Nd
)
1114 or else not Dump_Original_Only
1125 (if Is_Homogeneous_Aggregate
(Node
) then ']' else ')');
1129 Write_Str_With_Col_Check_Sloc
("new ");
1131 -- Ada 2005 (AI-231)
1133 if Null_Exclusion_Present
(Node
) then
1134 Write_Str
("not null ");
1137 Sprint_Node
(Expression
(Node
));
1139 if Present
(Storage_Pool
(Node
)) then
1140 Write_Str_With_Col_Check
("[storage_pool = ");
1141 Sprint_Node
(Storage_Pool
(Node
));
1145 if Present
(Procedure_To_Call
(Node
)) then
1146 Write_Str_With_Col_Check
("[procedure_to_call = ");
1147 Sprint_Node
(Procedure_To_Call
(Node
));
1152 Sprint_Left_Opnd
(Node
);
1153 Write_Str_Sloc
(" and then ");
1154 Sprint_Right_Opnd
(Node
);
1156 -- Note: the following code for N_Aspect_Specification is not
1157 -- normally used, since we deal with aspects as part of a
1158 -- declaration, but it is here in case we deliberately try
1159 -- to print an N_Aspect_Specification node (e.g. from GDB).
1161 when N_Aspect_Specification
=>
1162 Sprint_Node
(Identifier
(Node
));
1164 Sprint_Node
(Expression
(Node
));
1166 when N_Assignment_Statement
=>
1168 Sprint_Node
(Name
(Node
));
1169 Write_Str_Sloc
(" := ");
1170 Sprint_Node
(Expression
(Node
));
1173 when N_Asynchronous_Select
=>
1174 Write_Indent_Str_Sloc
("select");
1176 Sprint_Node
(Triggering_Alternative
(Node
));
1179 -- Note: let the printing of Abortable_Part handle outputting
1180 -- the ABORT keyword, so that the Sloc can be set correctly.
1182 Write_Indent_Str
("then ");
1183 Sprint_Node
(Abortable_Part
(Node
));
1184 Write_Indent_Str
("end select;");
1187 Write_Indent_Str_Sloc
("for ");
1188 Write_Id
(Identifier
(Node
));
1189 Write_Str_With_Col_Check
(" use at ");
1190 Sprint_Node
(Expression
(Node
));
1193 when N_Attribute_Definition_Clause
=>
1194 Write_Indent_Str_Sloc
("for ");
1195 Sprint_Node
(Name
(Node
));
1197 Write_Name_With_Col_Check
(Chars
(Node
));
1198 Write_Str_With_Col_Check
(" use ");
1199 Sprint_Node
(Expression
(Node
));
1202 when N_Attribute_Reference
=>
1203 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1207 Sprint_Node
(Prefix
(Node
));
1208 Write_Char_Sloc
(''');
1209 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
1210 Sprint_Paren_Comma_List
(Expressions
(Node
));
1212 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1216 when N_Block_Statement
=>
1219 if Present
(Identifier
(Node
))
1220 and then (not Has_Created_Identifier
(Node
)
1221 or else not Dump_Original_Only
)
1223 Write_Rewrite_Str
("<<<");
1224 Write_Id
(Identifier
(Node
));
1226 Write_Rewrite_Str
(">>>");
1229 if Present
(Declarations
(Node
)) then
1230 Write_Str_With_Col_Check_Sloc
("declare");
1231 Sprint_Indented_List
(Declarations
(Node
));
1235 Write_Str_With_Col_Check_Sloc
("begin");
1236 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1237 Write_Indent_Str
("end");
1239 if Present
(Identifier
(Node
))
1240 and then (not Has_Created_Identifier
(Node
)
1241 or else not Dump_Original_Only
)
1243 Write_Rewrite_Str
("<<<");
1245 Write_Id
(Identifier
(Node
));
1246 Write_Rewrite_Str
(">>>");
1250 Sprint_At_End_Proc
(Node
);
1252 when N_Call_Marker
=>
1255 -- Enable the following code for debugging purposes only
1257 -- Write_Indent_Str ("#");
1258 -- Write_Id (Target (Node));
1259 -- Write_Char ('#');
1261 when N_Case_Expression
=>
1263 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
1267 -- The syntax for case_expression does not include parentheses,
1268 -- but sometimes parentheses are required, so unconditionally
1269 -- generate them here unless already present.
1271 if not Has_Parens
then
1275 Write_Str_With_Col_Check_Sloc
("case ");
1276 Sprint_Node
(Expression
(Node
));
1277 Write_Str_With_Col_Check
(" is");
1279 Alt
:= First
(Alternatives
(Node
));
1287 if not Has_Parens
then
1292 when N_Case_Expression_Alternative
=>
1293 Write_Str_With_Col_Check
(" when ");
1294 Sprint_Bar_List
(Discrete_Choices
(Node
));
1296 Sprint_Node
(Expression
(Node
));
1298 when N_Case_Statement
=>
1299 Write_Indent_Str_Sloc
("case ");
1300 Sprint_Node
(Expression
(Node
));
1302 Sprint_Indented_List
(Alternatives
(Node
));
1303 Write_Indent_Str
("end case;");
1305 when N_Case_Statement_Alternative
=>
1306 Write_Indent_Str_Sloc
("when ");
1307 Sprint_Bar_List
(Discrete_Choices
(Node
));
1309 Sprint_Indented_List
(Statements
(Node
));
1311 when N_Character_Literal
=>
1312 if Column
> Sprint_Line_Limit
- 2 then
1313 Write_Indent_Str
(" ");
1316 Write_Char_Sloc
(''');
1317 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
1320 when N_Code_Statement
=>
1323 Sprint_Node
(Expression
(Node
));
1326 when N_Compilation_Unit
=>
1327 Sprint_Node_List
(Context_Items
(Node
));
1328 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
1330 if Private_Present
(Node
) then
1331 Write_Indent_Str
("private ");
1335 Sprint_Node_Sloc
(Unit
(Node
));
1337 if Present
(Actions
(Aux_Decls_Node
(Node
)))
1339 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
1344 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
1345 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
1347 when N_Compilation_Unit_Aux
=>
1348 null; -- nothing to do, never used, see above
1350 when N_Component_Association
=>
1352 Sprint_Bar_List
(Choices
(Node
));
1355 -- Ada 2005 (AI-287): Print the box if present
1357 if Box_Present
(Node
) then
1358 Write_Str_With_Col_Check
("<>");
1360 Sprint_Node
(Expression
(Node
));
1363 when N_Iterated_Component_Association
=>
1365 Write_Str
(" for ");
1366 if Present
(Iterator_Specification
(Node
)) then
1367 Sprint_Node
(Iterator_Specification
(Node
));
1369 Write_Id
(Defining_Identifier
(Node
));
1371 Sprint_Bar_List
(Discrete_Choices
(Node
));
1374 Sprint_Node
(Expression
(Node
));
1376 when N_Iterated_Element_Association
=>
1378 if Present
(Iterator_Specification
(Node
)) then
1379 Sprint_Node
(Iterator_Specification
(Node
));
1381 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1384 if Present
(Key_Expression
(Node
)) then
1385 Write_Str
(" use ");
1386 Sprint_Node
(Key_Expression
(Node
));
1390 Sprint_Node
(Expression
(Node
));
1392 when N_Component_Clause
=>
1394 Sprint_Node
(Component_Name
(Node
));
1395 Write_Str_Sloc
(" at ");
1396 Sprint_Node
(Position
(Node
));
1398 Write_Str_With_Col_Check
("range ");
1399 Sprint_Node
(First_Bit
(Node
));
1401 Sprint_Node
(Last_Bit
(Node
));
1404 when N_Component_Definition
=>
1407 -- Ada 2005 (AI-230): Access definition components
1409 if Present
(Access_Definition
(Node
)) then
1410 Sprint_Node
(Access_Definition
(Node
));
1412 elsif Present
(Subtype_Indication
(Node
)) then
1413 if Aliased_Present
(Node
) then
1414 Write_Str_With_Col_Check
("aliased ");
1417 -- Ada 2005 (AI-231)
1419 if Null_Exclusion_Present
(Node
) then
1420 Write_Str
(" not null ");
1423 Sprint_Node
(Subtype_Indication
(Node
));
1426 Write_Str
(" ??? ");
1429 when N_Component_Declaration
=>
1430 if Write_Indent_Identifiers_Sloc
(Node
) then
1432 Sprint_Node
(Component_Definition
(Node
));
1434 if Present
(Expression
(Node
)) then
1436 Sprint_Node
(Expression
(Node
));
1442 when N_Component_List
=>
1443 if Null_Present
(Node
) then
1445 Write_Indent_Str_Sloc
("null");
1451 Sprint_Indented_List
(Component_Items
(Node
));
1452 Sprint_Node
(Variant_Part
(Node
));
1455 when N_Compound_Statement
=>
1456 Write_Indent_Str
("do");
1458 Sprint_Node_List
(Actions
(Node
));
1460 Write_Indent_Str
("end;");
1462 when N_Conditional_Entry_Call
=>
1463 Write_Indent_Str_Sloc
("select");
1465 Sprint_Node
(Entry_Call_Alternative
(Node
));
1467 Write_Indent_Str
("else");
1468 Sprint_Indented_List
(Else_Statements
(Node
));
1469 Write_Indent_Str
("end select;");
1471 when N_Constrained_Array_Definition
=>
1472 Write_Str_With_Col_Check_Sloc
("array ");
1473 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1476 Sprint_Node
(Component_Definition
(Node
));
1478 -- A contract node should not appear in the tree. It is a semantic
1479 -- node attached to entry and [generic] subprogram entities. But we
1480 -- still provide meaningful output, in case called from the debugger.
1488 Write_Str
("N_Contract node");
1491 Write_Indent_Str
("Pre_Post_Conditions");
1494 P
:= Pre_Post_Conditions
(Node
);
1495 while Present
(P
) loop
1497 P
:= Next_Pragma
(P
);
1503 Write_Indent_Str
("Contract_Test_Cases");
1506 P
:= Contract_Test_Cases
(Node
);
1507 while Present
(P
) loop
1509 P
:= Next_Pragma
(P
);
1515 Write_Indent_Str
("Classifications");
1518 P
:= Classifications
(Node
);
1519 while Present
(P
) loop
1521 P
:= Next_Pragma
(P
);
1529 when N_Decimal_Fixed_Point_Definition
=>
1530 Write_Str_With_Col_Check_Sloc
("delta ");
1531 Sprint_Node
(Delta_Expression
(Node
));
1532 Write_Str_With_Col_Check
(" digits ");
1533 Sprint_Node
(Digits_Expression
(Node
));
1534 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1536 when N_Defining_Character_Literal
=>
1537 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1539 when N_Defining_Identifier
=>
1543 when N_Defining_Operator_Symbol
=>
1544 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1546 when N_Defining_Program_Unit_Name
=>
1548 Sprint_Node
(Name
(Node
));
1550 Write_Id
(Defining_Identifier
(Node
));
1552 when N_Delay_Alternative
=>
1553 Sprint_Node_List
(Pragmas_Before
(Node
));
1555 if Present
(Condition
(Node
)) then
1557 Write_Str_With_Col_Check
("when ");
1558 Sprint_Node
(Condition
(Node
));
1563 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1564 Sprint_Node_List
(Statements
(Node
));
1566 when N_Delay_Relative_Statement
=>
1567 Write_Indent_Str_Sloc
("delay ");
1568 Sprint_Node
(Expression
(Node
));
1571 when N_Delay_Until_Statement
=>
1572 Write_Indent_Str_Sloc
("delay until ");
1573 Sprint_Node
(Expression
(Node
));
1576 when N_Delta_Constraint
=>
1577 Write_Str_With_Col_Check_Sloc
("delta ");
1578 Sprint_Node
(Delta_Expression
(Node
));
1579 Sprint_Opt_Node
(Range_Constraint
(Node
));
1581 when N_Derived_Type_Definition
=>
1582 if Abstract_Present
(Node
) then
1583 Write_Str_With_Col_Check
("abstract ");
1586 Write_Str_With_Col_Check
("new ");
1588 -- Ada 2005 (AI-231)
1590 if Null_Exclusion_Present
(Node
) then
1591 Write_Str_With_Col_Check
("not null ");
1594 Sprint_Node
(Subtype_Indication
(Node
));
1596 if Present
(Interface_List
(Node
)) then
1597 Write_Str_With_Col_Check
(" and ");
1598 Sprint_And_List
(Interface_List
(Node
));
1599 Write_Str_With_Col_Check
(" with ");
1602 if Present
(Record_Extension_Part
(Node
)) then
1603 if No
(Interface_List
(Node
)) then
1604 Write_Str_With_Col_Check
(" with ");
1607 Sprint_Node
(Record_Extension_Part
(Node
));
1610 when N_Designator
=>
1611 Sprint_Node
(Name
(Node
));
1612 Write_Char_Sloc
('.');
1613 Write_Id
(Identifier
(Node
));
1615 when N_Digits_Constraint
=>
1616 Write_Str_With_Col_Check_Sloc
("digits ");
1617 Sprint_Node
(Digits_Expression
(Node
));
1618 Sprint_Opt_Node
(Range_Constraint
(Node
));
1620 when N_Discriminant_Association
=>
1623 if Present
(Selector_Names
(Node
)) then
1624 Sprint_Bar_List
(Selector_Names
(Node
));
1629 Sprint_Node
(Expression
(Node
));
1631 when N_Discriminant_Specification
=>
1634 if Write_Identifiers
(Node
) then
1637 if Null_Exclusion_Present
(Node
) then
1638 Write_Str
("not null ");
1641 Sprint_Node
(Discriminant_Type
(Node
));
1643 if Present
(Expression
(Node
)) then
1645 Sprint_Node
(Expression
(Node
));
1651 when N_Elsif_Part
=>
1652 Write_Indent_Str_Sloc
("elsif ");
1653 Sprint_Node
(Condition
(Node
));
1654 Write_Str_With_Col_Check
(" then");
1655 Sprint_Indented_List
(Then_Statements
(Node
));
1660 when N_Entry_Body
=>
1661 Write_Indent_Str_Sloc
("entry ");
1662 Write_Id
(Defining_Identifier
(Node
));
1663 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1664 Write_Str_With_Col_Check
(" is");
1665 Sprint_Indented_List
(Declarations
(Node
));
1666 Write_Indent_Str
("begin");
1667 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1668 Write_Indent_Str
("end ");
1669 Write_Id
(Defining_Identifier
(Node
));
1671 Sprint_At_End_Proc
(Node
);
1673 when N_Entry_Body_Formal_Part
=>
1674 if Present
(Entry_Index_Specification
(Node
)) then
1675 Write_Str_With_Col_Check_Sloc
(" (");
1676 Sprint_Node
(Entry_Index_Specification
(Node
));
1680 Write_Param_Specs
(Node
);
1681 Write_Str_With_Col_Check_Sloc
(" when ");
1682 Sprint_Node
(Condition
(Node
));
1684 when N_Entry_Call_Alternative
=>
1685 Sprint_Node_List
(Pragmas_Before
(Node
));
1686 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1687 Sprint_Node_List
(Statements
(Node
));
1689 when N_Entry_Call_Statement
=>
1691 Sprint_Node_Sloc
(Name
(Node
));
1692 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1695 when N_Entry_Declaration
=>
1696 Write_Indent_Str_Sloc
("entry ");
1697 Write_Id
(Defining_Identifier
(Node
));
1699 if Present
(Discrete_Subtype_Definition
(Node
)) then
1700 Write_Str_With_Col_Check
(" (");
1701 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1705 Write_Param_Specs
(Node
);
1708 when N_Entry_Index_Specification
=>
1709 Write_Str_With_Col_Check_Sloc
("for ");
1710 Write_Id
(Defining_Identifier
(Node
));
1711 Write_Str_With_Col_Check
(" in ");
1712 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1714 when N_Enumeration_Representation_Clause
=>
1715 Write_Indent_Str_Sloc
("for ");
1716 Write_Id
(Identifier
(Node
));
1717 Write_Str_With_Col_Check
(" use ");
1718 Sprint_Node
(Array_Aggregate
(Node
));
1721 when N_Enumeration_Type_Definition
=>
1724 -- Skip attempt to print Literals field if it's not there and
1725 -- we are in package Standard (case of Character, which is
1726 -- handled specially (without an explicit literals list).
1728 if Sloc
(Node
) > Standard_Location
1729 or else Present
(Literals
(Node
))
1731 Sprint_Paren_Comma_List
(Literals
(Node
));
1735 Write_Str_With_Col_Check_Sloc
("<error>");
1737 when N_Exception_Declaration
=>
1738 if Write_Indent_Identifiers
(Node
) then
1739 Write_Str_With_Col_Check
(" : ");
1741 if Is_Statically_Allocated
(Defining_Identifier
(Node
)) then
1742 Write_Str_With_Col_Check
("static ");
1745 Write_Str_Sloc
("exception");
1747 if Present
(Expression
(Node
)) then
1749 Sprint_Node
(Expression
(Node
));
1755 when N_Exception_Handler
=>
1756 Write_Indent_Str_Sloc
("when ");
1758 if Present
(Choice_Parameter
(Node
)) then
1759 Sprint_Node
(Choice_Parameter
(Node
));
1763 Sprint_Bar_List
(Exception_Choices
(Node
));
1765 Sprint_Indented_List
(Statements
(Node
));
1767 when N_Exception_Renaming_Declaration
=>
1770 Sprint_Node
(Defining_Identifier
(Node
));
1771 Write_Str_With_Col_Check
(" : exception renames ");
1772 Sprint_Node
(Name
(Node
));
1775 when N_Exit_Statement
=>
1776 Write_Indent_Str_Sloc
("exit");
1777 Sprint_Opt_Node
(Name
(Node
));
1779 if Present
(Condition
(Node
)) then
1780 Write_Str_With_Col_Check
(" when ");
1781 Sprint_Node
(Condition
(Node
));
1786 when N_Expanded_Name
=>
1787 Sprint_Node
(Prefix
(Node
));
1788 Write_Char_Sloc
('.');
1789 Sprint_Node
(Selector_Name
(Node
));
1791 when N_Explicit_Dereference
=>
1792 Sprint_Node
(Prefix
(Node
));
1793 Write_Char_Sloc
('.');
1794 Write_Str_Sloc
("all");
1796 when N_Expression_With_Actions
=>
1798 Write_Indent_Str_Sloc
("do ");
1800 Sprint_Node_List
(Actions
(Node
));
1803 Write_Str_With_Col_Check_Sloc
("in ");
1804 Sprint_Node
(Expression
(Node
));
1805 Write_Str_With_Col_Check
(" end");
1809 when N_Expression_Function
=>
1811 Sprint_Node_Sloc
(Specification
(Node
));
1815 Sprint_Node
(Expression
(Node
));
1819 when N_Extended_Return_Statement
=>
1820 Write_Indent_Str_Sloc
("return ");
1821 Sprint_Node_List
(Return_Object_Declarations
(Node
));
1823 if Present
(Handled_Statement_Sequence
(Node
)) then
1824 Write_Str_With_Col_Check
(" do");
1825 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1826 Write_Indent_Str
("end return");
1829 if Present
(Storage_Pool
(Node
)) then
1830 Write_Str_With_Col_Check
("[storage_pool = ");
1831 Sprint_Node
(Storage_Pool
(Node
));
1835 if Present
(Procedure_To_Call
(Node
)) then
1836 Write_Str_With_Col_Check
("[procedure_to_call = ");
1837 Sprint_Node
(Procedure_To_Call
(Node
));
1843 when N_Delta_Aggregate
=>
1844 Write_Str_With_Col_Check_Sloc
("(");
1845 Sprint_Node
(Expression
(Node
));
1846 Write_Str_With_Col_Check
(" with delta ");
1847 Sprint_Comma_List
(Component_Associations
(Node
));
1850 when N_Extension_Aggregate
=>
1851 Write_Str_With_Col_Check_Sloc
("(");
1852 Sprint_Node
(Ancestor_Part
(Node
));
1853 Write_Str_With_Col_Check
(" with ");
1855 if Null_Record_Present
(Node
) then
1856 Write_Str_With_Col_Check
("null record");
1858 if Present
(Expressions
(Node
)) then
1859 Sprint_Comma_List
(Expressions
(Node
));
1861 if Present
(Component_Associations
(Node
)) then
1866 if Present
(Component_Associations
(Node
)) then
1867 Sprint_Comma_List
(Component_Associations
(Node
));
1873 when N_Floating_Point_Definition
=>
1874 Write_Str_With_Col_Check_Sloc
("digits ");
1875 Sprint_Node
(Digits_Expression
(Node
));
1876 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1878 when N_Formal_Decimal_Fixed_Point_Definition
=>
1879 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1881 when N_Formal_Derived_Type_Definition
=>
1882 Write_Str_With_Col_Check_Sloc
("new ");
1883 Sprint_Node
(Subtype_Mark
(Node
));
1885 if Present
(Interface_List
(Node
)) then
1886 Write_Str_With_Col_Check
(" and ");
1887 Sprint_And_List
(Interface_List
(Node
));
1890 if Private_Present
(Node
) then
1891 Write_Str_With_Col_Check
(" with private");
1894 when N_Formal_Abstract_Subprogram_Declaration
=>
1895 Write_Indent_Str_Sloc
("with ");
1896 Sprint_Node
(Specification
(Node
));
1898 Write_Str_With_Col_Check
(" is abstract");
1900 if Box_Present
(Node
) then
1901 Write_Str_With_Col_Check
(" <>");
1902 elsif Present
(Default_Name
(Node
)) then
1903 Write_Str_With_Col_Check
(" ");
1904 Sprint_Node
(Default_Name
(Node
));
1909 when N_Formal_Concrete_Subprogram_Declaration
=>
1910 Write_Indent_Str_Sloc
("with ");
1911 Sprint_Node
(Specification
(Node
));
1913 if Box_Present
(Node
) then
1914 Write_Str_With_Col_Check
(" is <>");
1915 elsif Present
(Default_Name
(Node
)) then
1916 Write_Str_With_Col_Check
(" is ");
1917 Sprint_Node
(Default_Name
(Node
));
1922 when N_Formal_Discrete_Type_Definition
=>
1923 Write_Str_With_Col_Check_Sloc
("<>");
1925 when N_Formal_Floating_Point_Definition
=>
1926 Write_Str_With_Col_Check_Sloc
("digits <>");
1928 when N_Formal_Modular_Type_Definition
=>
1929 Write_Str_With_Col_Check_Sloc
("mod <>");
1931 when N_Formal_Object_Declaration
=>
1934 if Write_Indent_Identifiers
(Node
) then
1937 if In_Present
(Node
) then
1938 Write_Str_With_Col_Check
("in ");
1941 if Out_Present
(Node
) then
1942 Write_Str_With_Col_Check
("out ");
1945 if Present
(Subtype_Mark
(Node
)) then
1947 -- Ada 2005 (AI-423): Formal object with null exclusion
1949 if Null_Exclusion_Present
(Node
) then
1950 Write_Str
("not null ");
1953 Sprint_Node
(Subtype_Mark
(Node
));
1955 -- Ada 2005 (AI-423): Formal object with access definition
1958 pragma Assert
(Present
(Access_Definition
(Node
)));
1960 Sprint_Node
(Access_Definition
(Node
));
1963 if Present
(Default_Expression
(Node
)) then
1965 Sprint_Node
(Default_Expression
(Node
));
1971 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1972 Write_Str_With_Col_Check_Sloc
("delta <>");
1974 when N_Formal_Package_Declaration
=>
1975 Write_Indent_Str_Sloc
("with package ");
1976 Write_Id
(Defining_Identifier
(Node
));
1977 Write_Str_With_Col_Check
(" is new ");
1978 Sprint_Node
(Name
(Node
));
1979 Write_Str_With_Col_Check
(" (<>);");
1981 when N_Formal_Private_Type_Definition
=>
1982 if Abstract_Present
(Node
) then
1983 Write_Str_With_Col_Check
("abstract ");
1986 if Tagged_Present
(Node
) then
1987 Write_Str_With_Col_Check
("tagged ");
1990 if Limited_Present
(Node
) then
1991 Write_Str_With_Col_Check
("limited ");
1994 Write_Str_With_Col_Check_Sloc
("private");
1996 when N_Formal_Incomplete_Type_Definition
=>
1997 if Tagged_Present
(Node
) then
1998 Write_Str_With_Col_Check
("is tagged ");
2001 when N_Formal_Signed_Integer_Type_Definition
=>
2002 Write_Str_With_Col_Check_Sloc
("range <>");
2004 when N_Formal_Type_Declaration
=>
2005 Write_Indent_Str_Sloc
("type ");
2006 Write_Id
(Defining_Identifier
(Node
));
2008 if Present
(Discriminant_Specifications
(Node
)) then
2009 Write_Discr_Specs
(Node
);
2010 elsif Unknown_Discriminants_Present
(Node
) then
2011 Write_Str_With_Col_Check
("(<>)");
2014 if Nkind
(Formal_Type_Definition
(Node
)) /=
2015 N_Formal_Incomplete_Type_Definition
2017 Write_Str_With_Col_Check
(" is ");
2020 Sprint_Node
(Formal_Type_Definition
(Node
));
2023 when N_Free_Statement
=>
2024 Write_Indent_Str_Sloc
("free ");
2025 Sprint_Node
(Expression
(Node
));
2027 if Present
(Storage_Pool
(Node
)) then
2028 Write_Str_With_Col_Check
("[storage_pool = ");
2029 Sprint_Node
(Storage_Pool
(Node
));
2033 if Present
(Procedure_To_Call
(Node
)) then
2034 Write_Str_With_Col_Check
("[procedure_to_call = ");
2035 Sprint_Node
(Procedure_To_Call
(Node
));
2041 when N_Freeze_Entity
=>
2042 if Dump_Original_Only
then
2045 -- A freeze node is output if it has some effect (i.e. non-empty
2046 -- actions, or freeze node for an itype, which causes elaboration
2047 -- of the itype), and is also always output if Dump_Freeze_Null
2050 elsif Present
(Actions
(Node
))
2051 or else Is_Itype
(Entity
(Node
))
2052 or else Dump_Freeze_Null
2055 Write_Rewrite_Str
("<<<");
2056 Write_Str_With_Col_Check_Sloc
("freeze ");
2057 Write_Id
(Entity
(Node
));
2060 if No
(Actions
(Node
)) then
2064 -- Output freeze actions. We increment Freeze_Indent during
2065 -- this output to avoid generating extra blank lines before
2066 -- any procedures included in the freeze actions.
2068 Freeze_Indent
:= Freeze_Indent
+ 1;
2069 Sprint_Indented_List
(Actions
(Node
));
2070 Freeze_Indent
:= Freeze_Indent
- 1;
2071 Write_Indent_Str
("]");
2074 Write_Rewrite_Str
(">>>");
2077 when N_Freeze_Generic_Entity
=>
2078 if Dump_Original_Only
then
2083 Write_Str_With_Col_Check_Sloc
("freeze_generic ");
2084 Write_Id
(Entity
(Node
));
2087 when N_Full_Type_Declaration
=>
2088 Write_Indent_Str_Sloc
("type ");
2089 Sprint_Node
(Defining_Identifier
(Node
));
2090 Write_Discr_Specs
(Node
);
2091 Write_Str_With_Col_Check
(" is ");
2092 Sprint_Node
(Type_Definition
(Node
));
2095 when N_Function_Call
=>
2097 Write_Subprogram_Name
(Name
(Node
));
2098 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2100 when N_Function_Instantiation
=>
2101 Write_Indent_Str_Sloc
("function ");
2102 Sprint_Node
(Defining_Unit_Name
(Node
));
2103 Write_Str_With_Col_Check
(" is new ");
2104 Sprint_Node
(Name
(Node
));
2105 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2108 when N_Function_Specification
=>
2109 Write_Str_With_Col_Check_Sloc
("function ");
2110 Sprint_Node
(Defining_Unit_Name
(Node
));
2111 Write_Param_Specs
(Node
);
2112 Write_Str_With_Col_Check
(" return ");
2114 -- Ada 2005 (AI-231)
2116 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
2117 and then Null_Exclusion_Present
(Node
)
2119 Write_Str
(" not null ");
2122 Sprint_Node
(Result_Definition
(Node
));
2124 when N_Generic_Association
=>
2127 if Present
(Selector_Name
(Node
)) then
2128 Sprint_Node
(Selector_Name
(Node
));
2132 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
2134 when N_Generic_Function_Renaming_Declaration
=>
2135 Write_Indent_Str_Sloc
("generic function ");
2136 Sprint_Node
(Defining_Unit_Name
(Node
));
2137 Write_Str_With_Col_Check
(" renames ");
2138 Sprint_Node
(Name
(Node
));
2141 when N_Generic_Declaration
=>
2143 Write_Indent_Str_Sloc
("generic ");
2144 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
2146 Sprint_Node
(Specification
(Node
));
2149 when N_Generic_Package_Renaming_Declaration
=>
2150 Write_Indent_Str_Sloc
("generic package ");
2151 Sprint_Node
(Defining_Unit_Name
(Node
));
2152 Write_Str_With_Col_Check
(" renames ");
2153 Sprint_Node
(Name
(Node
));
2156 when N_Generic_Procedure_Renaming_Declaration
=>
2157 Write_Indent_Str_Sloc
("generic procedure ");
2158 Sprint_Node
(Defining_Unit_Name
(Node
));
2159 Write_Str_With_Col_Check
(" renames ");
2160 Sprint_Node
(Name
(Node
));
2163 when N_Goto_Statement
=>
2164 Write_Indent_Str_Sloc
("goto ");
2165 Sprint_Node
(Name
(Node
));
2168 if Nkind
(Next
(Node
)) = N_Label
then
2172 when N_Goto_When_Statement
=>
2173 Write_Indent_Str_Sloc
("goto ");
2174 Sprint_Node
(Name
(Node
));
2175 Write_Str
(" when ");
2176 Sprint_Node
(Condition
(Node
));
2179 when N_Handled_Sequence_Of_Statements
=>
2181 Sprint_Indented_List
(Statements
(Node
));
2183 if Present
(Exception_Handlers
(Node
)) then
2184 Write_Indent_Str
("exception");
2186 Sprint_Node_List
(Exception_Handlers
(Node
));
2190 Sprint_At_End_Proc
(Node
);
2192 when N_Identifier
=>
2196 when N_If_Expression
=>
2198 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
2199 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
2200 Then_Expr
: constant Node_Id
:= Next
(Condition
);
2203 -- The syntax for if_expression does not include parentheses,
2204 -- but sometimes parentheses are required, so unconditionally
2205 -- generate them here unless already present.
2207 if not Has_Parens
then
2211 Write_Str_With_Col_Check_Sloc
("if ");
2212 Sprint_Node
(Condition
);
2213 Write_Str_With_Col_Check
(" then ");
2215 -- Defense against junk here
2217 if Present
(Then_Expr
) then
2218 Sprint_Node
(Then_Expr
);
2220 if Present
(Next
(Then_Expr
)) then
2221 Write_Str_With_Col_Check
(" else ");
2222 Sprint_Node
(Next
(Then_Expr
));
2226 if not Has_Parens
then
2231 when N_If_Statement
=>
2232 Write_Indent_Str_Sloc
("if ");
2233 Sprint_Node
(Condition
(Node
));
2234 Write_Str_With_Col_Check
(" then");
2235 Sprint_Indented_List
(Then_Statements
(Node
));
2236 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
2238 if Present
(Else_Statements
(Node
)) then
2239 Write_Indent_Str
("else");
2240 Sprint_Indented_List
(Else_Statements
(Node
));
2243 Write_Indent_Str
("end if;");
2245 when N_Implicit_Label_Declaration
=>
2246 if not Dump_Original_Only
then
2248 Write_Rewrite_Str
("<<<");
2250 Write_Id
(Defining_Identifier
(Node
));
2252 Write_Str_With_Col_Check
("label");
2253 Write_Rewrite_Str
(">>>");
2257 Sprint_Left_Opnd
(Node
);
2258 Write_Str_Sloc
(" in ");
2260 if Present
(Right_Opnd
(Node
)) then
2261 Sprint_Right_Opnd
(Node
);
2263 Sprint_Bar_List
(Alternatives
(Node
));
2266 when N_Incomplete_Type_Declaration
=>
2267 Write_Indent_Str_Sloc
("type ");
2268 Write_Id
(Defining_Identifier
(Node
));
2270 if Present
(Discriminant_Specifications
(Node
)) then
2271 Write_Discr_Specs
(Node
);
2272 elsif Unknown_Discriminants_Present
(Node
) then
2273 Write_Str_With_Col_Check
("(<>)");
2278 when N_Index_Or_Discriminant_Constraint
=>
2280 Sprint_Paren_Comma_List
(Constraints
(Node
));
2282 when N_Indexed_Component
=>
2283 Sprint_Node_Sloc
(Prefix
(Node
));
2284 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
2286 when N_Integer_Literal
=>
2287 if Print_In_Hex
(Node
) then
2288 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
2290 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
2293 when N_Iteration_Scheme
=>
2294 if Present
(Condition
(Node
)) then
2295 Write_Str_With_Col_Check_Sloc
("while ");
2296 Sprint_Node
(Condition
(Node
));
2298 Write_Str_With_Col_Check_Sloc
("for ");
2300 if Present
(Iterator_Specification
(Node
)) then
2301 Sprint_Node
(Iterator_Specification
(Node
));
2303 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2309 when N_Iterator_Specification
=>
2311 Write_Id
(Defining_Identifier
(Node
));
2313 if Present
(Subtype_Indication
(Node
)) then
2314 Write_Str_With_Col_Check
(" : ");
2315 Sprint_Node
(Subtype_Indication
(Node
));
2318 if Of_Present
(Node
) then
2319 Write_Str_With_Col_Check
(" of ");
2321 Write_Str_With_Col_Check
(" in ");
2324 if Reverse_Present
(Node
) then
2325 Write_Str_With_Col_Check
("reverse ");
2328 Sprint_Node
(Name
(Node
));
2330 if Present
(Iterator_Filter
(Node
)) then
2331 Write_Str
(" when ");
2332 Sprint_Node
(Iterator_Filter
(Node
));
2335 when N_Itype_Reference
=>
2336 Write_Indent_Str_Sloc
("reference ");
2337 Write_Id
(Itype
(Node
));
2340 Write_Indent_Str_Sloc
("<<");
2341 Write_Id
(Identifier
(Node
));
2344 when N_Loop_Parameter_Specification
=>
2346 Write_Id
(Defining_Identifier
(Node
));
2347 Write_Str_With_Col_Check
(" in ");
2349 if Reverse_Present
(Node
) then
2350 Write_Str_With_Col_Check
("reverse ");
2353 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
2355 when N_Loop_Statement
=>
2358 if Present
(Identifier
(Node
))
2359 and then (not Has_Created_Identifier
(Node
)
2360 or else not Dump_Original_Only
)
2362 Write_Rewrite_Str
("<<<");
2363 Write_Id
(Identifier
(Node
));
2365 Write_Rewrite_Str
(">>>");
2366 Sprint_Node
(Iteration_Scheme
(Node
));
2367 Write_Str_With_Col_Check_Sloc
("loop");
2368 Sprint_Indented_List
(Statements
(Node
));
2369 Write_Indent_Str
("end loop ");
2370 Write_Rewrite_Str
("<<<");
2371 Write_Id
(Identifier
(Node
));
2372 Write_Rewrite_Str
(">>>");
2376 Sprint_Node
(Iteration_Scheme
(Node
));
2377 Write_Str_With_Col_Check_Sloc
("loop");
2378 Sprint_Indented_List
(Statements
(Node
));
2379 Write_Indent_Str
("end loop;");
2382 when N_Mod_Clause
=>
2383 Sprint_Node_List
(Pragmas_Before
(Node
));
2384 Write_Str_With_Col_Check_Sloc
("at mod ");
2385 Sprint_Node
(Expression
(Node
));
2387 when N_Modular_Type_Definition
=>
2388 Write_Str_With_Col_Check_Sloc
("mod ");
2389 Sprint_Node
(Expression
(Node
));
2392 Sprint_Left_Opnd
(Node
);
2393 Write_Str_Sloc
(" not in ");
2395 if Present
(Right_Opnd
(Node
)) then
2396 Sprint_Right_Opnd
(Node
);
2398 Sprint_Bar_List
(Alternatives
(Node
));
2402 Write_Str_With_Col_Check_Sloc
("null");
2404 when N_Null_Statement
=>
2405 if Comes_From_Source
(Node
)
2406 or else Dump_Freeze_Null
2407 or else not Is_List_Member
(Node
)
2408 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
2410 Write_Indent_Str_Sloc
("null;");
2413 when N_Number_Declaration
=>
2416 if Write_Indent_Identifiers
(Node
) then
2417 Write_Str_With_Col_Check
(" : constant ");
2419 Sprint_Node
(Expression
(Node
));
2423 when N_Object_Declaration
=>
2426 if Write_Indent_Identifiers
(Node
) then
2428 Def_Id
: constant Entity_Id
:= Defining_Identifier
(Node
);
2431 Write_Str_With_Col_Check
(" : ");
2433 if Is_Statically_Allocated
(Def_Id
) then
2434 Write_Str_With_Col_Check
("static ");
2437 if Aliased_Present
(Node
) then
2438 Write_Str_With_Col_Check
("aliased ");
2441 if Constant_Present
(Node
) then
2442 Write_Str_With_Col_Check
("constant ");
2445 -- Ada 2005 (AI-231)
2447 if Null_Exclusion_Present
(Node
) then
2448 Write_Str_With_Col_Check
("not null ");
2451 -- Print type. We used to print the Object_Definition from
2452 -- the node, but it is much more useful to print the Etype
2453 -- of the defining identifier for the case where the nominal
2454 -- type is an unconstrained array type. For example, this
2455 -- will be a clear reference to the Itype with the bounds
2456 -- in the case of a type like String. The object after
2457 -- all is constrained, even if its nominal subtype is
2461 Odef
: constant Node_Id
:= Object_Definition
(Node
);
2464 if Nkind
(Odef
) = N_Identifier
2465 and then Present
(Etype
(Odef
))
2466 and then Is_Array_Type
(Etype
(Odef
))
2467 and then not Is_Constrained
(Etype
(Odef
))
2468 and then Present
(Etype
(Def_Id
))
2470 Sprint_Node
(Etype
(Def_Id
));
2472 -- In other cases, the nominal type is fine to print
2479 if Present
(Expression
(Node
))
2480 and then Expression
(Node
) /= Error
2481 and then not No_Initialization
(Node
)
2484 Sprint_Node
(Expression
(Node
));
2489 -- Handle implicit importation and implicit exportation of
2490 -- object declarations:
2491 -- $pragma import (Convention_Id, Def_Id, "...");
2492 -- $pragma export (Convention_Id, Def_Id, "...");
2494 if Is_Internal
(Def_Id
)
2495 and then Present
(Interface_Name
(Def_Id
))
2497 Write_Indent_Str_Sloc
("$pragma ");
2499 if Is_Imported
(Def_Id
) then
2500 Write_Str
("import (");
2502 else pragma Assert
(Is_Exported
(Def_Id
));
2503 Write_Str
("export (");
2507 Prefix
: constant String := "Convention_";
2508 S
: constant String := Convention
(Def_Id
)'Img;
2511 Name_Len
:= S
'Last - Prefix
'Last;
2512 Name_Buffer
(1 .. Name_Len
) :=
2513 S
(Prefix
'Last + 1 .. S
'Last);
2514 Set_Casing
(All_Lower_Case
);
2515 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2521 Write_String_Table_Entry
2522 (Strval
(Interface_Name
(Def_Id
)));
2528 when N_Object_Renaming_Declaration
=>
2531 Sprint_Node
(Defining_Identifier
(Node
));
2533 -- Ada 2005 (AI-230): Access renamings
2535 if Present
(Access_Definition
(Node
)) then
2537 Sprint_Node
(Access_Definition
(Node
));
2539 elsif Present
(Subtype_Mark
(Node
)) then
2542 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2544 if Null_Exclusion_Present
(Node
) then
2545 Write_Str
("not null ");
2548 Sprint_Node
(Subtype_Mark
(Node
));
2550 -- AI12-0275: Object_Renaming_Declaration without explicit subtype
2552 elsif Ada_Version
>= Ada_2022
then
2556 Write_Str
(" : ??? ");
2559 Write_Str_With_Col_Check
(" renames ");
2560 Sprint_Node
(Name
(Node
));
2564 Write_Operator
(Node
, "abs ");
2565 Sprint_Right_Opnd
(Node
);
2568 Sprint_Left_Opnd
(Node
);
2569 Write_Operator
(Node
, " + ");
2570 Sprint_Right_Opnd
(Node
);
2573 Sprint_Left_Opnd
(Node
);
2574 Write_Operator
(Node
, " and ");
2575 Sprint_Right_Opnd
(Node
);
2578 Sprint_Left_Opnd
(Node
);
2579 Write_Operator
(Node
, " & ");
2580 Sprint_Right_Opnd
(Node
);
2583 Sprint_Left_Opnd
(Node
);
2585 if Rounded_Result
(Node
) then
2588 Write_Operator
(Node
, "/ ");
2589 Sprint_Right_Opnd
(Node
);
2592 Sprint_Left_Opnd
(Node
);
2593 Write_Operator
(Node
, " = ");
2594 Sprint_Right_Opnd
(Node
);
2597 Sprint_Left_Opnd
(Node
);
2598 Write_Operator
(Node
, " ** ");
2599 Sprint_Right_Opnd
(Node
);
2602 Sprint_Left_Opnd
(Node
);
2603 Write_Operator
(Node
, " >= ");
2604 Sprint_Right_Opnd
(Node
);
2607 Sprint_Left_Opnd
(Node
);
2608 Write_Operator
(Node
, " > ");
2609 Sprint_Right_Opnd
(Node
);
2612 Sprint_Left_Opnd
(Node
);
2613 Write_Operator
(Node
, " <= ");
2614 Sprint_Right_Opnd
(Node
);
2617 Sprint_Left_Opnd
(Node
);
2618 Write_Operator
(Node
, " < ");
2619 Sprint_Right_Opnd
(Node
);
2622 Write_Operator
(Node
, "-");
2623 Sprint_Right_Opnd
(Node
);
2626 Sprint_Left_Opnd
(Node
);
2627 Write_Operator
(Node
, " mod ");
2628 Sprint_Right_Opnd
(Node
);
2630 when N_Op_Multiply
=>
2631 Sprint_Left_Opnd
(Node
);
2633 if Rounded_Result
(Node
) then
2636 Write_Operator
(Node
, "* ");
2637 Sprint_Right_Opnd
(Node
);
2640 Sprint_Left_Opnd
(Node
);
2641 Write_Operator
(Node
, " /= ");
2642 Sprint_Right_Opnd
(Node
);
2645 Write_Operator
(Node
, "not ");
2646 Sprint_Right_Opnd
(Node
);
2649 Sprint_Left_Opnd
(Node
);
2650 Write_Operator
(Node
, " or ");
2651 Sprint_Right_Opnd
(Node
);
2654 Write_Operator
(Node
, "+");
2655 Sprint_Right_Opnd
(Node
);
2658 Sprint_Left_Opnd
(Node
);
2659 Write_Operator
(Node
, " rem ");
2660 Sprint_Right_Opnd
(Node
);
2666 Write_Str_With_Col_Check
("(");
2667 Sprint_Node
(Left_Opnd
(Node
));
2669 Sprint_Node
(Right_Opnd
(Node
));
2672 when N_Op_Subtract
=>
2673 Sprint_Left_Opnd
(Node
);
2674 Write_Operator
(Node
, " - ");
2675 Sprint_Right_Opnd
(Node
);
2678 Sprint_Left_Opnd
(Node
);
2679 Write_Operator
(Node
, " xor ");
2680 Sprint_Right_Opnd
(Node
);
2682 when N_Operator_Symbol
=>
2683 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
2685 when N_Ordinary_Fixed_Point_Definition
=>
2686 Write_Str_With_Col_Check_Sloc
("delta ");
2687 Sprint_Node
(Delta_Expression
(Node
));
2688 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
2691 Sprint_Left_Opnd
(Node
);
2692 Write_Str_Sloc
(" or else ");
2693 Sprint_Right_Opnd
(Node
);
2695 when N_Others_Choice
=>
2696 if All_Others
(Node
) then
2697 Write_Str_With_Col_Check
("all ");
2700 Write_Str_With_Col_Check_Sloc
("others");
2702 when N_Package_Body
=>
2704 Write_Indent_Str_Sloc
("package body ");
2705 Sprint_Node
(Defining_Unit_Name
(Node
));
2707 Sprint_Indented_List
(Declarations
(Node
));
2709 if Present
(Handled_Statement_Sequence
(Node
)) then
2710 Write_Indent_Str
("begin");
2711 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2714 Write_Indent_Str
("end ");
2716 (Handled_Statement_Sequence
(Node
), Defining_Unit_Name
(Node
));
2718 Sprint_At_End_Proc
(Node
);
2720 when N_Package_Body_Stub
=>
2721 Write_Indent_Str_Sloc
("package body ");
2722 Sprint_Node
(Defining_Identifier
(Node
));
2723 Write_Str_With_Col_Check
(" is separate;");
2725 when N_Package_Declaration
=>
2728 Sprint_Node_Sloc
(Specification
(Node
));
2731 -- If this is an instantiation, get the aspects from the original
2732 -- instantiation node.
2734 if Is_Generic_Instance
(Defining_Entity
(Node
))
2735 and then Has_Aspects
2736 (Package_Instantiation
(Defining_Entity
(Node
)))
2738 Sprint_Aspect_Specifications
2739 (Package_Instantiation
(Defining_Entity
(Node
)),
2743 when N_Package_Instantiation
=>
2745 Write_Indent_Str_Sloc
("package ");
2746 Sprint_Node
(Defining_Unit_Name
(Node
));
2747 Write_Str
(" is new ");
2748 Sprint_Node
(Name
(Node
));
2749 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2752 when N_Package_Renaming_Declaration
=>
2753 Write_Indent_Str_Sloc
("package ");
2754 Sprint_Node
(Defining_Unit_Name
(Node
));
2755 Write_Str_With_Col_Check
(" renames ");
2756 Sprint_Node
(Name
(Node
));
2759 when N_Package_Specification
=>
2760 Write_Str_With_Col_Check_Sloc
("package ");
2761 Sprint_Node
(Defining_Unit_Name
(Node
));
2763 if Nkind
(Parent
(Node
)) = N_Generic_Package_Declaration
2764 and then Has_Aspects
(Parent
(Node
))
2766 Sprint_Aspect_Specifications
2767 (Parent
(Node
), Semicolon
=> False);
2769 -- An instantiation is rewritten as a package declaration, but
2770 -- the aspects belong to the instantiation node.
2772 elsif Nkind
(Parent
(Node
)) = N_Package_Declaration
then
2774 Pack
: constant Entity_Id
:= Defining_Entity
(Node
);
2777 if not Is_Generic_Instance
(Pack
) then
2778 if Has_Aspects
(Parent
(Node
)) then
2779 Sprint_Aspect_Specifications
2780 (Parent
(Node
), Semicolon
=> False);
2787 Sprint_Indented_List
(Visible_Declarations
(Node
));
2789 if Present
(Private_Declarations
(Node
)) then
2790 Write_Indent_Str
("private");
2791 Sprint_Indented_List
(Private_Declarations
(Node
));
2794 Write_Indent_Str
("end ");
2795 Sprint_Node
(Defining_Unit_Name
(Node
));
2797 when N_Parameter_Association
=>
2798 Sprint_Node_Sloc
(Selector_Name
(Node
));
2800 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2802 when N_Parameter_Specification
=>
2805 if Write_Identifiers
(Node
) then
2808 if In_Present
(Node
) then
2809 Write_Str_With_Col_Check
("in ");
2812 if Out_Present
(Node
) then
2813 Write_Str_With_Col_Check
("out ");
2816 -- Ada 2005 (AI-231): Parameter specification may carry null
2817 -- exclusion. Do not print it now if this is an access formal,
2818 -- it is emitted when the access definition is displayed.
2820 if Null_Exclusion_Present
(Node
)
2821 and then Nkind
(Parameter_Type
(Node
)) /= N_Access_Definition
2823 Write_Str
("not null ");
2826 if Aliased_Present
(Node
) then
2827 Write_Str
("aliased ");
2830 Sprint_Node
(Parameter_Type
(Node
));
2832 if Present
(Expression
(Node
)) then
2834 Sprint_Node
(Expression
(Node
));
2840 when N_Pop_Constraint_Error_Label
=>
2841 Write_Indent_Str
("%pop_constraint_error_label");
2843 when N_Pop_Program_Error_Label
=>
2844 Write_Indent_Str
("%pop_program_error_label");
2846 when N_Pop_Storage_Error_Label
=>
2847 Write_Indent_Str
("%pop_storage_error_label");
2849 when N_Private_Extension_Declaration
=>
2850 Write_Indent_Str_Sloc
("type ");
2851 Write_Id
(Defining_Identifier
(Node
));
2853 if Present
(Discriminant_Specifications
(Node
)) then
2854 Write_Discr_Specs
(Node
);
2855 elsif Unknown_Discriminants_Present
(Node
) then
2856 Write_Str_With_Col_Check
("(<>)");
2859 Write_Str_With_Col_Check
(" is new ");
2860 Sprint_Node
(Subtype_Indication
(Node
));
2862 if Present
(Interface_List
(Node
)) then
2863 Write_Str_With_Col_Check
(" and ");
2864 Sprint_And_List
(Interface_List
(Node
));
2867 Write_Str_With_Col_Check
(" with private;");
2869 when N_Private_Type_Declaration
=>
2870 Write_Indent_Str_Sloc
("type ");
2871 Write_Id
(Defining_Identifier
(Node
));
2873 if Present
(Discriminant_Specifications
(Node
)) then
2874 Write_Discr_Specs
(Node
);
2875 elsif Unknown_Discriminants_Present
(Node
) then
2876 Write_Str_With_Col_Check
("(<>)");
2881 if Tagged_Present
(Node
) then
2882 Write_Str_With_Col_Check
("tagged ");
2885 if Limited_Present
(Node
) then
2886 Write_Str_With_Col_Check
("limited ");
2889 Write_Str_With_Col_Check
("private;");
2891 when N_Push_Constraint_Error_Label
=>
2892 Write_Indent_Str
("%push_constraint_error_label (");
2894 if Present
(Exception_Label
(Node
)) then
2895 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2900 when N_Push_Program_Error_Label
=>
2901 Write_Indent_Str
("%push_program_error_label (");
2903 if Present
(Exception_Label
(Node
)) then
2904 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2909 when N_Push_Storage_Error_Label
=>
2910 Write_Indent_Str
("%push_storage_error_label (");
2912 if Present
(Exception_Label
(Node
)) then
2913 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2919 Write_Indent_Str_Sloc
("pragma ");
2920 Write_Name_With_Col_Check
(Pragma_Name_Unmapped
(Node
));
2922 if Present
(Pragma_Argument_Associations
(Node
)) then
2923 Sprint_Opt_Paren_Comma_List
2924 (Pragma_Argument_Associations
(Node
));
2929 when N_Pragma_Argument_Association
=>
2932 if Chars
(Node
) /= No_Name
then
2933 Write_Name_With_Col_Check
(Chars
(Node
));
2937 Sprint_Node
(Expression
(Node
));
2939 when N_Procedure_Call_Statement
=>
2942 Write_Subprogram_Name
(Name
(Node
));
2943 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2946 when N_Procedure_Instantiation
=>
2947 Write_Indent_Str_Sloc
("procedure ");
2948 Sprint_Node
(Defining_Unit_Name
(Node
));
2949 Write_Str_With_Col_Check
(" is new ");
2950 Sprint_Node
(Name
(Node
));
2951 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2954 when N_Procedure_Specification
=>
2955 Write_Str_With_Col_Check_Sloc
("procedure ");
2956 Sprint_Node
(Defining_Unit_Name
(Node
));
2957 Write_Param_Specs
(Node
);
2959 when N_Protected_Body
=>
2960 Write_Indent_Str_Sloc
("protected body ");
2961 Write_Id
(Defining_Identifier
(Node
));
2963 Sprint_Indented_List
(Declarations
(Node
));
2964 Write_Indent_Str
("end ");
2965 Write_Id
(Defining_Identifier
(Node
));
2968 when N_Protected_Body_Stub
=>
2969 Write_Indent_Str_Sloc
("protected body ");
2970 Write_Id
(Defining_Identifier
(Node
));
2971 Write_Str_With_Col_Check
(" is separate;");
2973 when N_Protected_Definition
=>
2975 Sprint_Indented_List
(Visible_Declarations
(Node
));
2977 if Present
(Private_Declarations
(Node
)) then
2978 Write_Indent_Str
("private");
2979 Sprint_Indented_List
(Private_Declarations
(Node
));
2982 Write_Indent_Str
("end ");
2984 when N_Protected_Type_Declaration
=>
2985 Write_Indent_Str_Sloc
("protected type ");
2986 Sprint_Node
(Defining_Identifier
(Node
));
2987 Write_Discr_Specs
(Node
);
2989 if Present
(Interface_List
(Node
)) then
2990 Write_Str
(" is new ");
2991 Sprint_And_List
(Interface_List
(Node
));
2992 Write_Str
(" with ");
2997 Sprint_Node
(Protected_Definition
(Node
));
2998 Write_Id
(Defining_Identifier
(Node
));
3001 when N_Qualified_Expression
=>
3002 Sprint_Node
(Subtype_Mark
(Node
));
3003 Write_Char_Sloc
(''');
3005 -- Print expression, make sure we have at least one level of
3006 -- parentheses around the expression. For cases of qualified
3007 -- expressions in the source, this is always the case, but
3008 -- for generated qualifications, there may be no explicit
3009 -- parentheses present.
3011 if Paren_Count
(Expression
(Node
)) /= 0 then
3012 Sprint_Node
(Expression
(Node
));
3016 Sprint_Node
(Expression
(Node
));
3018 -- Odd case, for the qualified expressions used in machine
3019 -- code the argument may be a procedure call, resulting in
3020 -- a junk semicolon before the right parent, get rid of it.
3022 Write_Erase_Char
(';');
3024 -- Now we can add the terminating right paren
3029 when N_Quantified_Expression
=>
3032 if All_Present
(Node
) then
3033 Write_Str
(" all ");
3035 Write_Str
(" some ");
3038 if Present
(Iterator_Specification
(Node
)) then
3039 Sprint_Node
(Iterator_Specification
(Node
));
3041 Sprint_Node
(Loop_Parameter_Specification
(Node
));
3045 Sprint_Node
(Condition
(Node
));
3047 when N_Raise_Expression
=>
3049 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
3052 -- The syntax for raise_expression does not include parentheses
3053 -- but sometimes parentheses are required, so unconditionally
3054 -- generate them here unless already present.
3056 if not Has_Parens
then
3060 Write_Str_With_Col_Check_Sloc
("raise ");
3061 Sprint_Node
(Name
(Node
));
3063 if Present
(Expression
(Node
)) then
3064 Write_Str_With_Col_Check
(" with ");
3065 Sprint_Node
(Expression
(Node
));
3068 if not Has_Parens
then
3073 when N_Raise_Constraint_Error
=>
3075 -- This node can be used either as a subexpression or as a
3076 -- statement form. The following test is a reasonably reliable
3077 -- way to distinguish the two cases.
3079 if Is_List_Member
(Node
)
3080 and then Nkind
(Parent
(Node
)) not in N_Subexpr
3085 Write_Str_With_Col_Check_Sloc
("[constraint_error");
3086 Write_Condition_And_Reason
(Node
);
3088 when N_Raise_Program_Error
=>
3090 -- This node can be used either as a subexpression or as a
3091 -- statement form. The following test is a reasonably reliable
3092 -- way to distinguish the two cases.
3094 if Is_List_Member
(Node
)
3095 and then Nkind
(Parent
(Node
)) not in N_Subexpr
3100 Write_Str_With_Col_Check_Sloc
("[program_error");
3101 Write_Condition_And_Reason
(Node
);
3103 when N_Raise_Storage_Error
=>
3105 -- This node can be used either as a subexpression or as a
3106 -- statement form. The following test is a reasonably reliable
3107 -- way to distinguish the two cases.
3109 if Is_List_Member
(Node
)
3110 and then Nkind
(Parent
(Node
)) not in N_Subexpr
3115 Write_Str_With_Col_Check_Sloc
("[storage_error");
3116 Write_Condition_And_Reason
(Node
);
3118 when N_Raise_Statement
=>
3119 Write_Indent_Str_Sloc
("raise ");
3120 Sprint_Node
(Name
(Node
));
3122 if Present
(Expression
(Node
)) then
3123 Write_Str_With_Col_Check_Sloc
(" with ");
3124 Sprint_Node
(Expression
(Node
));
3129 when N_Raise_When_Statement
=>
3130 Write_Indent_Str_Sloc
("raise ");
3131 Sprint_Node
(Name
(Node
));
3132 Write_Str
(" when ");
3133 Sprint_Node
(Condition
(Node
));
3135 if Present
(Expression
(Node
)) then
3136 Write_Str_With_Col_Check_Sloc
(" with ");
3137 Sprint_Node
(Expression
(Node
));
3143 Sprint_Node
(Low_Bound
(Node
));
3144 Write_Str_Sloc
(" .. ");
3145 if Present
(Etype
(Node
))
3146 and then Is_Fixed_Lower_Bound_Index_Subtype
(Etype
(Node
))
3150 Sprint_Node
(High_Bound
(Node
));
3152 Update_Itype
(Node
);
3154 when N_Range_Constraint
=>
3155 Write_Str_With_Col_Check_Sloc
("range ");
3156 Sprint_Node
(Range_Expression
(Node
));
3158 when N_Real_Literal
=>
3159 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
3161 when N_Real_Range_Specification
3162 | N_Signed_Integer_Type_Definition
3164 Write_Str_With_Col_Check_Sloc
("range ");
3165 Sprint_Node
(Low_Bound
(Node
));
3167 Sprint_Node
(High_Bound
(Node
));
3169 when N_Record_Definition
=>
3170 if Abstract_Present
(Node
) then
3171 Write_Str_With_Col_Check
("abstract ");
3174 if Tagged_Present
(Node
) then
3175 Write_Str_With_Col_Check
("tagged ");
3178 if Limited_Present
(Node
) then
3179 Write_Str_With_Col_Check
("limited ");
3182 if Null_Present
(Node
) then
3183 Write_Str_With_Col_Check_Sloc
("null record");
3186 Write_Str_With_Col_Check_Sloc
("record");
3187 Sprint_Node
(Component_List
(Node
));
3188 Write_Indent_Str
("end record");
3191 when N_Record_Representation_Clause
=>
3192 Write_Indent_Str_Sloc
("for ");
3193 Sprint_Node
(Identifier
(Node
));
3194 Write_Str_With_Col_Check
(" use record ");
3196 if Present
(Mod_Clause
(Node
)) then
3197 Sprint_Node
(Mod_Clause
(Node
));
3200 Sprint_Indented_List
(Component_Clauses
(Node
));
3201 Write_Indent_Str
("end record;");
3204 Sprint_Node
(Prefix
(Node
));
3205 Write_Str_With_Col_Check_Sloc
("'reference");
3207 when N_Requeue_Statement
=>
3208 Write_Indent_Str_Sloc
("requeue ");
3209 Sprint_Node
(Name
(Node
));
3211 if Abort_Present
(Node
) then
3212 Write_Str_With_Col_Check
(" with abort");
3217 when N_Return_When_Statement
=>
3218 Write_Indent_Str_Sloc
("return ");
3219 Sprint_Node
(Expression
(Node
));
3220 Write_Str
(" when ");
3221 Sprint_Node
(Condition
(Node
));
3224 when N_SCIL_Dispatch_Table_Tag_Init
=>
3225 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Tag_Init]");
3227 when N_SCIL_Dispatching_Call
=>
3228 Write_Indent_Str
("[N_SCIL_Dispatching_Node]");
3230 when N_SCIL_Membership_Test
=>
3231 Write_Indent_Str
("[N_SCIL_Membership_Test]");
3233 when N_Simple_Return_Statement
=>
3234 if Present
(Expression
(Node
)) then
3235 Write_Indent_Str_Sloc
("return ");
3236 Sprint_Node
(Expression
(Node
));
3238 Write_Indent_Str_Sloc
("return");
3241 if Present
(Storage_Pool
(Node
)) then
3242 Write_Str_With_Col_Check
("[storage_pool = ");
3243 Sprint_Node
(Storage_Pool
(Node
));
3247 if Present
(Procedure_To_Call
(Node
)) then
3248 Write_Str_With_Col_Check
("[procedure_to_call = ");
3249 Sprint_Node
(Procedure_To_Call
(Node
));
3255 when N_Selective_Accept
=>
3256 Write_Indent_Str_Sloc
("select");
3261 Alt_Node
:= First
(Select_Alternatives
(Node
));
3264 Sprint_Node
(Alt_Node
);
3267 exit when No
(Alt_Node
);
3268 Write_Indent_Str
("or");
3272 if Present
(Else_Statements
(Node
)) then
3273 Write_Indent_Str
("else");
3274 Sprint_Indented_List
(Else_Statements
(Node
));
3277 Write_Indent_Str
("end select;");
3279 when N_Single_Protected_Declaration
=>
3280 Write_Indent_Str_Sloc
("protected ");
3281 Write_Id
(Defining_Identifier
(Node
));
3283 Sprint_Node
(Protected_Definition
(Node
));
3284 Write_Id
(Defining_Identifier
(Node
));
3287 when N_Single_Task_Declaration
=>
3288 Write_Indent_Str_Sloc
("task ");
3289 Sprint_Node
(Defining_Identifier
(Node
));
3291 if Present
(Task_Definition
(Node
)) then
3293 Sprint_Node
(Task_Definition
(Node
));
3298 when N_Selected_Component
=>
3299 Sprint_Node
(Prefix
(Node
));
3300 Write_Char_Sloc
('.');
3301 Sprint_Node
(Selector_Name
(Node
));
3305 Sprint_Node
(Prefix
(Node
));
3306 Write_Str_With_Col_Check
(" (");
3307 Sprint_Node
(Discrete_Range
(Node
));
3310 when N_String_Literal
=>
3311 if String_Length
(Strval
(Node
)) + Column
> Sprint_Line_Limit
then
3312 Write_Indent_Str
(" ");
3316 Write_String_Table_Entry
(Strval
(Node
));
3318 when N_Interpolated_String_Literal
=>
3322 Str_Elem
: Node_Id
:= First
(Expressions
(Node
));
3323 Is_First
: Boolean := True;
3326 while Present
(Str_Elem
) loop
3327 if not Is_First
then
3331 if Nkind
(Str_Elem
) = N_String_Literal
then
3332 Sprint_Node
(Str_Elem
);
3337 Sprint_Node
(Str_Elem
);
3350 when N_Subprogram_Body
=>
3352 -- Output extra blank line unless we are in freeze actions
3354 if Freeze_Indent
= 0 then
3360 if Present
(Corresponding_Spec
(Node
)) then
3361 Sprint_Node_Sloc
(Parent
(Corresponding_Spec
(Node
)));
3363 Sprint_Node_Sloc
(Specification
(Node
));
3368 Sprint_Indented_List
(Declarations
(Node
));
3369 Write_Indent_Str
("begin");
3370 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3372 Write_Indent_Str
("end ");
3375 (Handled_Statement_Sequence
(Node
),
3376 Defining_Unit_Name
(Specification
(Node
)));
3378 Sprint_At_End_Proc
(Node
);
3380 if Is_List_Member
(Node
)
3381 and then Present
(Next
(Node
))
3382 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
3387 when N_Subprogram_Body_Stub
=>
3389 Sprint_Node_Sloc
(Specification
(Node
));
3390 Write_Str_With_Col_Check
(" is separate;");
3392 when N_Subprogram_Declaration
=>
3394 Sprint_Node_Sloc
(Specification
(Node
));
3396 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
3397 and then Null_Present
(Specification
(Node
))
3399 Write_Str_With_Col_Check
(" is null");
3404 when N_Subprogram_Renaming_Declaration
=>
3406 Sprint_Node
(Specification
(Node
));
3407 Write_Str_With_Col_Check_Sloc
(" renames ");
3408 Sprint_Node
(Name
(Node
));
3411 when N_Subtype_Declaration
=>
3412 Write_Indent_Str_Sloc
("subtype ");
3413 Sprint_Node
(Defining_Identifier
(Node
));
3416 -- Ada 2005 (AI-231)
3418 if Null_Exclusion_Present
(Node
) then
3419 Write_Str
("not null ");
3422 Sprint_Node
(Subtype_Indication
(Node
));
3425 when N_Subtype_Indication
=>
3426 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
3428 Sprint_Node
(Constraint
(Node
));
3431 Write_Indent_Str_Sloc
("separate (");
3432 Sprint_Node
(Name
(Node
));
3435 Sprint_Node
(Proper_Body
(Node
));
3437 when N_Target_Name
=>
3441 Write_Indent_Str_Sloc
("task body ");
3442 Write_Id
(Defining_Identifier
(Node
));
3444 Sprint_Indented_List
(Declarations
(Node
));
3445 Write_Indent_Str
("begin");
3446 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3447 Write_Indent_Str
("end ");
3449 (Handled_Statement_Sequence
(Node
), Defining_Identifier
(Node
));
3451 Sprint_At_End_Proc
(Node
);
3453 when N_Task_Body_Stub
=>
3454 Write_Indent_Str_Sloc
("task body ");
3455 Write_Id
(Defining_Identifier
(Node
));
3456 Write_Str_With_Col_Check
(" is separate;");
3458 when N_Task_Definition
=>
3460 Sprint_Indented_List
(Visible_Declarations
(Node
));
3462 if Present
(Private_Declarations
(Node
)) then
3463 Write_Indent_Str
("private");
3464 Sprint_Indented_List
(Private_Declarations
(Node
));
3467 Write_Indent_Str
("end ");
3468 Sprint_End_Label
(Node
, Defining_Identifier
(Parent
(Node
)));
3470 when N_Task_Type_Declaration
=>
3471 Write_Indent_Str_Sloc
("task type ");
3472 Sprint_Node
(Defining_Identifier
(Node
));
3473 Write_Discr_Specs
(Node
);
3475 if Present
(Interface_List
(Node
)) then
3476 Write_Str
(" is new ");
3477 Sprint_And_List
(Interface_List
(Node
));
3480 if Present
(Task_Definition
(Node
)) then
3481 if No
(Interface_List
(Node
)) then
3484 Write_Str
(" with ");
3487 Sprint_Node
(Task_Definition
(Node
));
3492 when N_Terminate_Alternative
=>
3493 Sprint_Node_List
(Pragmas_Before
(Node
));
3496 if Present
(Condition
(Node
)) then
3497 Write_Str_With_Col_Check
("when ");
3498 Sprint_Node
(Condition
(Node
));
3502 Write_Str_With_Col_Check_Sloc
("terminate;");
3503 Sprint_Node_List
(Pragmas_After
(Node
));
3505 when N_Timed_Entry_Call
=>
3506 Write_Indent_Str_Sloc
("select");
3508 Sprint_Node
(Entry_Call_Alternative
(Node
));
3510 Write_Indent_Str
("or");
3512 Sprint_Node
(Delay_Alternative
(Node
));
3514 Write_Indent_Str
("end select;");
3516 when N_Triggering_Alternative
=>
3517 Sprint_Node_List
(Pragmas_Before
(Node
));
3518 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
3519 Sprint_Node_List
(Statements
(Node
));
3521 when N_Type_Conversion
=>
3523 Sprint_Node
(Subtype_Mark
(Node
));
3526 if Conversion_OK
(Node
) then
3530 if Float_Truncate
(Node
) then
3534 if Rounded_Result
(Node
) then
3539 Sprint_Node
(Expression
(Node
));
3542 when N_Unchecked_Expression
=>
3545 Sprint_Node_Sloc
(Expression
(Node
));
3548 when N_Unchecked_Type_Conversion
=>
3549 Sprint_Node
(Subtype_Mark
(Node
));
3551 Write_Str_With_Col_Check
("(");
3552 Sprint_Node_Sloc
(Expression
(Node
));
3555 when N_Unconstrained_Array_Definition
=>
3556 Write_Str_With_Col_Check_Sloc
("array (");
3561 Node1
:= First
(Subtype_Marks
(Node
));
3563 Sprint_Node
(Node1
);
3564 Write_Str_With_Col_Check
(" range <>");
3566 exit when Node1
= Empty
;
3571 Write_Str
(") of ");
3572 Sprint_Node
(Component_Definition
(Node
));
3574 when N_Unused_At_Start | N_Unused_At_End
=>
3575 Write_Indent_Str
("***** Error, unused node encountered *****");
3578 when N_Use_Package_Clause
=>
3579 Write_Indent_Str_Sloc
("use ");
3580 Sprint_Node_Sloc
(Name
(Node
));
3583 when N_Use_Type_Clause
=>
3584 Write_Indent_Str_Sloc
("use type ");
3585 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
3588 when N_Validate_Unchecked_Conversion
=>
3589 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
3590 Sprint_Node
(Source_Type
(Node
));
3592 Sprint_Node
(Target_Type
(Node
));
3595 when N_Variable_Reference_Marker
=>
3598 -- Enable the following code for debugging purposes only
3600 -- if Is_Read (Node) and then Is_Write (Node) then
3601 -- Write_Indent_Str ("rw#");
3603 -- elsif Is_Read (Node) then
3604 -- Write_Indent_Str ("r#");
3607 -- pragma Assert (Is_Write (Node));
3608 -- Write_Indent_Str ("w#");
3611 -- Write_Id (Target (Node));
3612 -- Write_Char ('#');
3615 Write_Indent_Str_Sloc
("when ");
3616 Sprint_Bar_List
(Discrete_Choices
(Node
));
3618 Sprint_Node
(Component_List
(Node
));
3620 when N_Variant_Part
=>
3622 Write_Indent_Str_Sloc
("case ");
3623 Sprint_Node
(Name
(Node
));
3625 Sprint_Indented_List
(Variants
(Node
));
3626 Write_Indent_Str
("end case");
3629 when N_With_Clause
=>
3631 -- Special test, if we are dumping the original tree only,
3632 -- then we want to eliminate the bogus with clauses that
3633 -- correspond to the non-existent children of Text_IO.
3635 if Dump_Original_Only
3636 and then Is_Text_IO_Special_Unit
(Name
(Node
))
3640 -- Normal case, output the with clause
3643 if First_Name
(Node
) or else not Dump_Original_Only
then
3645 -- Ada 2005 (AI-50217): Print limited with_clauses
3647 if Private_Present
(Node
) and Limited_Present
(Node
) then
3648 Write_Indent_Str
("limited private with ");
3650 elsif Private_Present
(Node
) then
3651 Write_Indent_Str
("private with ");
3653 elsif Limited_Present
(Node
) then
3654 Write_Indent_Str
("limited with ");
3657 Write_Indent_Str
("with ");
3664 Sprint_Node_Sloc
(Name
(Node
));
3666 if Last_Name
(Node
) or else not Dump_Original_Only
then
3672 -- Print aspects, except for special case of package declaration,
3673 -- where the aspects are printed inside the package specification.
3675 if Has_Aspects
(Node
)
3676 and then Nkind
(Node
) not in
3677 N_Generic_Package_Declaration | N_Package_Declaration
3678 and then not Is_Empty_List
(Aspect_Specifications
(Node
))
3680 Sprint_Aspect_Specifications
(Node
, Semicolon
=> True);
3683 if Nkind
(Node
) in N_Subexpr
and then Do_Range_Check
(Node
) then
3687 for J
in 1 .. Paren_Count
(Node
) loop
3691 Dump_Node
:= Save_Dump_Node
;
3692 end Sprint_Node_Actual
;
3694 ----------------------
3695 -- Sprint_Node_List --
3696 ----------------------
3698 procedure Sprint_Node_List
(List
: List_Id
; New_Lines
: Boolean := False) is
3702 if Is_Non_Empty_List
(List
) then
3703 Node
:= First
(List
);
3708 exit when Node
= Empty
;
3712 if New_Lines
and then Column
/= 1 then
3715 end Sprint_Node_List
;
3717 ----------------------
3718 -- Sprint_Node_Sloc --
3719 ----------------------
3721 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
3725 if Debug_Generated_Code
and then Present
(Dump_Node
) then
3726 Set_Sloc
(Dump_Node
, Sloc
(Node
));
3729 end Sprint_Node_Sloc
;
3731 ---------------------
3732 -- Sprint_Opt_Node --
3733 ---------------------
3735 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
3737 if Present
(Node
) then
3741 end Sprint_Opt_Node
;
3743 --------------------------
3744 -- Sprint_Opt_Node_List --
3745 --------------------------
3747 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
3749 if Present
(List
) then
3750 Sprint_Node_List
(List
);
3752 end Sprint_Opt_Node_List
;
3754 ---------------------------------
3755 -- Sprint_Opt_Paren_Comma_List --
3756 ---------------------------------
3758 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
3760 if Is_Non_Empty_List
(List
) then
3762 Sprint_Paren_Comma_List
(List
);
3764 end Sprint_Opt_Paren_Comma_List
;
3766 -----------------------------
3767 -- Sprint_Paren_Comma_List --
3768 -----------------------------
3770 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
3772 Node_Exists
: Boolean := False;
3776 if Is_Non_Empty_List
(List
) then
3778 if Dump_Original_Only
then
3780 while Present
(N
) loop
3781 if not Is_Rewrite_Insertion
(N
) then
3782 Node_Exists
:= True;
3789 if not Node_Exists
then
3794 Write_Str_With_Col_Check
("(");
3795 Sprint_Comma_List
(List
);
3798 end Sprint_Paren_Comma_List
;
3800 ----------------------
3801 -- Sprint_Right_Opnd --
3802 ----------------------
3804 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
3805 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
3808 if Paren_Count
(Opnd
) /= 0
3809 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
3818 end Sprint_Right_Opnd
;
3824 procedure Update_Itype
(Node
: Node_Id
) is
3826 if Present
(Etype
(Node
))
3827 and then Is_Itype
(Etype
(Node
))
3828 and then Debug_Generated_Code
3830 Set_Sloc
(Etype
(Node
), Sloc
(Node
));
3834 ---------------------
3835 -- Write_Char_Sloc --
3836 ---------------------
3838 procedure Write_Char_Sloc
(C
: Character) is
3840 if Debug_Generated_Code
and then C
/= ' ' then
3845 end Write_Char_Sloc
;
3847 --------------------------------
3848 -- Write_Condition_And_Reason --
3849 --------------------------------
3851 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
3852 Cond
: constant Node_Id
:= Condition
(Node
);
3853 Image
: constant String := RT_Exception_Code
'Image
3854 (RT_Exception_Code
'Val
3855 (UI_To_Int
(Reason
(Node
))));
3858 if Present
(Cond
) then
3860 -- If condition is a single entity, or NOT with a single entity,
3861 -- output all on one line, since it will likely fit just fine.
3863 if Is_Entity_Name
(Cond
)
3864 or else (Nkind
(Cond
) = N_Op_Not
3865 and then Is_Entity_Name
(Right_Opnd
(Cond
)))
3867 Write_Str_With_Col_Check
(" when ");
3871 -- Otherwise for more complex condition, multiple lines
3874 Write_Str_With_Col_Check
(" when");
3875 Indent
:= Indent
+ 2;
3879 Indent
:= Indent
- 2;
3882 -- If no condition, just need a space (all on one line)
3892 for J
in 4 .. Image
'Last loop
3893 if Image
(J
) = '_' then
3896 Write_Char
(Fold_Lower
(Image
(J
)));
3901 end Write_Condition_And_Reason
;
3903 --------------------------------
3904 -- Write_Corresponding_Source --
3905 --------------------------------
3907 procedure Write_Corresponding_Source
(S
: String) is
3909 Src
: Source_Buffer_Ptr
;
3912 -- Ignore if there is no current source file, or we're not in dump
3913 -- source text mode, or if in freeze actions.
3915 if Current_Source_File
> No_Source_File
3916 and then Dump_Source_Text
3917 and then Freeze_Indent
= 0
3920 -- Ignore null string
3926 -- Ignore space or semicolon at end of given string
3928 if S
(S
'Last) = ' ' or else S
(S
'Last) = ';' then
3929 Write_Corresponding_Source
(S
(S
'First .. S
'Last - 1));
3933 -- Loop to look at next lines not yet printed in source file
3936 Last_Line_Printed
+ 1 .. Last_Source_Line
(Current_Source_File
)
3938 Src
:= Source_Text
(Current_Source_File
);
3939 Loc
:= Line_Start
(L
, Current_Source_File
);
3941 -- If comment, keep looking
3943 if Src
(Loc
.. Loc
+ 1) = "--" then
3946 -- Search to first non-blank
3949 while Src
(Loc
) not in Line_Terminator
loop
3953 if Src
(Loc
) /= ' ' and then Src
(Loc
) /= ASCII
.HT
then
3955 -- Loop through characters in string to see if we match
3957 for J
in S
'Range loop
3959 -- If mismatch, then not the case we are looking for
3961 if Src
(Loc
) /= S
(J
) then
3968 -- If we fall through, string matched, if white space or
3969 -- semicolon after the matched string, this is the case
3970 -- we are looking for.
3972 if Src
(Loc
) in Line_Terminator
3973 or else Src
(Loc
) = ' '
3974 or else Src
(Loc
) = ASCII
.HT
3975 or else Src
(Loc
) = ';'
3977 -- So output source lines up to and including this one
3979 Write_Source_Lines
(L
);
3988 -- Line was all blanks, or a comment line, keep looking
3992 end Write_Corresponding_Source
;
3994 -----------------------
3995 -- Write_Discr_Specs --
3996 -----------------------
3998 procedure Write_Discr_Specs
(N
: Node_Id
) is
4003 Specs
:= Discriminant_Specifications
(N
);
4005 if Present
(Specs
) then
4006 Write_Str_With_Col_Check
(" (");
4007 Spec
:= First
(Specs
);
4012 exit when Spec
= Empty
;
4014 -- Add semicolon, unless we are printing original tree and the
4015 -- next specification is part of a list (but not the first
4016 -- element of that list)
4018 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4025 end Write_Discr_Specs
;
4031 procedure Write_Ekind
(E
: Entity_Id
) is
4032 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
4035 Name_Len
:= S
'Length;
4036 Name_Buffer
(1 .. Name_Len
) := S
;
4037 Set_Casing
(Mixed_Case
);
4038 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4045 procedure Write_Id
(N
: Node_Id
) is
4047 -- Deal with outputting Itype
4049 -- Note: if we are printing the full tree with -gnatds, then we may
4050 -- end up picking up the Associated_Node link from a generic template
4051 -- here which overlaps the Entity field, but as documented, Write_Itype
4052 -- is defended against junk calls.
4054 if Nkind
(N
) in N_Entity
then
4056 elsif Nkind
(N
) in N_Has_Entity
then
4057 Write_Itype
(Entity
(N
));
4060 -- Case of a defining identifier
4062 if Nkind
(N
) = N_Defining_Identifier
then
4064 -- If defining identifier has an interface name (and no
4065 -- address clause), then we output the interface name.
4067 if (Is_Imported
(N
) or else Is_Exported
(N
))
4068 and then Present
(Interface_Name
(N
))
4069 and then No
(Address_Clause
(N
))
4071 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
4072 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4074 -- If no interface name (or inactive because there was
4075 -- an address clause), then just output the Chars name.
4078 Write_Name_With_Col_Check
(Chars
(N
));
4081 -- Case of selector of an expanded name where the expanded name
4082 -- has an associated entity, output this entity. Check that the
4083 -- entity or associated node is of the right kind, see above.
4085 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
4086 and then Selector_Name
(Parent
(N
)) = N
4087 and then Present
(Entity_Or_Associated_Node
(Parent
(N
)))
4088 and then Nkind
(Entity
(Parent
(N
))) in N_Entity
4090 Write_Id
(Entity
(Parent
(N
)));
4092 -- For any other node with an associated entity, output it
4094 elsif Nkind
(N
) in N_Has_Entity
4095 and then Present
(Entity_Or_Associated_Node
(N
))
4096 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
4098 Write_Id
(Entity
(N
));
4100 -- All other cases, we just print the Chars field
4103 Write_Name_With_Col_Check
(Chars
(N
));
4107 -----------------------
4108 -- Write_Identifiers --
4109 -----------------------
4111 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
4113 Sprint_Node
(Defining_Identifier
(Node
));
4114 Update_Itype
(Defining_Identifier
(Node
));
4116 -- The remainder of the declaration must be printed unless we are
4117 -- printing the original tree and this is not the last identifier
4120 not Dump_Original_Only
or else not More_Ids
(Node
);
4122 end Write_Identifiers
;
4124 ------------------------
4125 -- Write_Implicit_Def --
4126 ------------------------
4128 procedure Write_Implicit_Def
(E
: Entity_Id
) is
4133 when E_Array_Subtype
=>
4134 Write_Str_With_Col_Check
("subtype ");
4136 Write_Str_With_Col_Check
(" is ");
4137 Write_Id
(Base_Type
(E
));
4138 Write_Str_With_Col_Check
(" (");
4140 Ind
:= First_Index
(E
);
4141 while Present
(Ind
) loop
4145 if Present
(Ind
) then
4152 when E_Enumeration_Subtype
4153 | E_Signed_Integer_Subtype
4155 Write_Str_With_Col_Check
("subtype ");
4158 Write_Id
(Etype
(E
));
4159 Write_Str_With_Col_Check
(" range ");
4160 Sprint_Node
(Scalar_Range
(E
));
4164 Write_Str_With_Col_Check
("type ");
4166 Write_Str_With_Col_Check
(" is <");
4170 end Write_Implicit_Def
;
4176 procedure Write_Indent
is
4177 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
4180 if Indent_Annull_Flag
then
4181 Indent_Annull_Flag
:= False;
4183 -- Deal with Dump_Source_Text output. Note that we ignore implicit
4184 -- label declarations, since they typically have the sloc of the
4185 -- corresponding label, which really messes up the -gnatL output.
4188 and then Loc
> No_Location
4189 and then Nkind
(Dump_Node
) /= N_Implicit_Label_Declaration
4191 if Get_Source_File_Index
(Loc
) = Current_Source_File
then
4193 (Get_Physical_Line_Number
(Sloc
(Dump_Node
)));
4199 for J
in 1 .. Indent
loop
4205 ------------------------------
4206 -- Write_Indent_Identifiers --
4207 ------------------------------
4209 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
4211 -- We need to start a new line for every node, except in the case
4212 -- where we are printing the original tree and this is not the first
4213 -- defining identifier in the list.
4215 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
4218 -- If printing original tree and this is not the first defining
4219 -- identifier in the list, then the previous call to this procedure
4220 -- printed only the name, and we add a comma to separate the names.
4226 Sprint_Node
(Defining_Identifier
(Node
));
4228 -- The remainder of the declaration must be printed unless we are
4229 -- printing the original tree and this is not the last identifier
4232 not Dump_Original_Only
or else not More_Ids
(Node
);
4233 end Write_Indent_Identifiers
;
4235 -----------------------------------
4236 -- Write_Indent_Identifiers_Sloc --
4237 -----------------------------------
4239 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
4241 -- We need to start a new line for every node, except in the case
4242 -- where we are printing the original tree and this is not the first
4243 -- defining identifier in the list.
4245 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
4248 -- If printing original tree and this is not the first defining
4249 -- identifier in the list, then the previous call to this procedure
4250 -- printed only the name, and we add a comma to separate the names.
4257 Sprint_Node
(Defining_Identifier
(Node
));
4259 -- The remainder of the declaration must be printed unless we are
4260 -- printing the original tree and this is not the last identifier
4262 return not Dump_Original_Only
or else not More_Ids
(Node
);
4263 end Write_Indent_Identifiers_Sloc
;
4265 ----------------------
4266 -- Write_Indent_Str --
4267 ----------------------
4269 procedure Write_Indent_Str
(S
: String) is
4271 Write_Corresponding_Source
(S
);
4274 end Write_Indent_Str
;
4276 ---------------------------
4277 -- Write_Indent_Str_Sloc --
4278 ---------------------------
4280 procedure Write_Indent_Str_Sloc
(S
: String) is
4282 Write_Corresponding_Source
(S
);
4285 end Write_Indent_Str_Sloc
;
4291 procedure Write_Itype
(Typ
: Entity_Id
) is
4293 procedure Write_Header
(T
: Boolean := True);
4294 -- Write type if T is True, subtype if T is false
4300 procedure Write_Header
(T
: Boolean := True) is
4303 Write_Str
("[type ");
4305 Write_Str
("[subtype ");
4308 Write_Name_With_Col_Check
(Chars
(Typ
));
4312 -- Start of processing for Write_Itype
4315 if Nkind
(Typ
) in N_Entity
4316 and then Is_Itype
(Typ
)
4317 and then not Itype_Printed
(Typ
)
4319 -- Itype to be printed
4322 B
: constant Entity_Id
:= Etype
(Typ
);
4323 P
: constant Node_Id
:= Parent
(Typ
);
4324 S
: constant Saved_Output_Buffer
:= Save_Output_Buffer
;
4325 -- Save current output buffer
4327 Old_Sloc
: Source_Ptr
;
4328 -- Save sloc of related node, so it is not modified when
4329 -- printing with -gnatD.
4334 -- Write indentation at start of line
4336 for J
in 1 .. Indent
loop
4340 -- If we have a constructed declaration for the itype, print it
4343 and then Nkind
(P
) in N_Declaration
4344 and then Defining_Entity
(P
) = Typ
4346 -- We must set Itype_Printed true before the recursive call to
4347 -- print the node, otherwise we get an infinite recursion.
4349 Set_Itype_Printed
(Typ
, True);
4351 -- Write the declaration enclosed in [], avoiding new line
4352 -- at start of declaration, and semicolon at end.
4354 -- Note: The itype may be imported from another unit, in which
4355 -- case we do not want to modify the Sloc of the declaration.
4356 -- Otherwise the itype may appear to be in the current unit,
4357 -- and the back-end will reject a reference out of scope.
4360 Indent_Annull_Flag
:= True;
4361 Old_Sloc
:= Sloc
(P
);
4363 Set_Sloc
(P
, Old_Sloc
);
4364 Write_Erase_Char
(';');
4366 -- If no constructed declaration, then we have to concoct the
4367 -- source corresponding to the type entity that we have at hand.
4372 -- Access types and subtypes
4375 Write_Header
(Ekind
(Typ
) = E_Access_Type
);
4377 if Can_Never_Be_Null
(Typ
) then
4378 Write_Str
("not null ");
4381 Write_Str
("access ");
4383 if Is_Access_Constant
(Typ
) then
4384 Write_Str
("constant ");
4387 Write_Id
(Directly_Designated_Type
(Typ
));
4391 when E_Array_Type
=>
4393 Write_Str
("array (");
4395 X
:= First_Index
(Typ
);
4399 if not Is_Constrained
(Typ
) then
4400 Write_Str
(" range <>");
4408 Write_Str
(") of ");
4409 X
:= Component_Type
(Typ
);
4411 -- Preserve sloc of component type, which is defined
4412 -- elsewhere than the itype (see comment above).
4414 Old_Sloc
:= Sloc
(X
);
4416 Set_Sloc
(X
, Old_Sloc
);
4420 -- Preserve Sloc of index subtypes, as above
4422 when E_Array_Subtype
=>
4423 Write_Header
(False);
4424 Write_Id
(Etype
(Typ
));
4427 X
:= First_Index
(Typ
);
4429 Old_Sloc
:= Sloc
(X
);
4431 Set_Sloc
(X
, Old_Sloc
);
4439 -- Signed integer types, and modular integer subtypes,
4440 -- and also enumeration subtypes.
4442 when E_Enumeration_Subtype
4443 | E_Modular_Integer_Subtype
4444 | E_Signed_Integer_Subtype
4445 | E_Signed_Integer_Type
4447 Write_Header
(Ekind
(Typ
) = E_Signed_Integer_Type
);
4449 if Ekind
(Typ
) = E_Signed_Integer_Type
then
4455 -- Print bounds if different from base type
4458 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4459 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4464 -- B can either be a scalar type, in which case the
4465 -- declaration of Typ may constrain it with different
4466 -- bounds, or a private type, in which case we know
4467 -- that the declaration of Typ cannot have a scalar
4470 if Is_Scalar_Type
(B
) then
4471 BL
:= Type_Low_Bound
(B
);
4472 BH
:= Type_High_Bound
(B
);
4480 and then Nkind
(L
) = N_Integer_Literal
4481 and then Nkind
(H
) = N_Integer_Literal
4482 and then Nkind
(BL
) = N_Integer_Literal
4483 and then Nkind
(BH
) = N_Integer_Literal
4484 and then UI_Eq
(Intval
(L
), Intval
(BL
))
4485 and then UI_Eq
(Intval
(H
), Intval
(BH
)))
4490 Write_Str
(" range ");
4497 -- Modular integer types
4499 when E_Modular_Integer_Type
=>
4503 if No
(Modulus
(Typ
)) then
4504 Write_Uint_With_Col_Check
(Uint_0
, Auto
);
4506 Write_Uint_With_Col_Check
(Modulus
(Typ
), Auto
);
4509 -- Floating-point types and subtypes
4511 when E_Floating_Point_Subtype
4512 | E_Floating_Point_Type
4514 Write_Header
(Ekind
(Typ
) = E_Floating_Point_Type
);
4516 if Ekind
(Typ
) = E_Floating_Point_Type
then
4522 if Digits_Value
(Typ
) /= Digits_Value
(B
) then
4523 Write_Str
(" digits ");
4524 Write_Uint_With_Col_Check
4525 (Digits_Value
(Typ
), Decimal
);
4528 -- Print bounds if not different from base type
4531 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4532 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4533 BL
: constant Node_Id
:= Type_Low_Bound
(B
);
4534 BH
: constant Node_Id
:= Type_High_Bound
(B
);
4538 and then Nkind
(L
) = N_Real_Literal
4539 and then Nkind
(H
) = N_Real_Literal
4540 and then Nkind
(BL
) = N_Real_Literal
4541 and then Nkind
(BH
) = N_Real_Literal
4542 and then UR_Eq
(Realval
(L
), Realval
(BL
))
4543 and then UR_Eq
(Realval
(H
), Realval
(BH
))
4548 Write_Str
(" range ");
4555 -- Ordinary fixed-point types and subtypes
4557 when E_Ordinary_Fixed_Point_Subtype
4558 | E_Ordinary_Fixed_Point_Type
4560 Write_Header
(Ekind
(Typ
) = E_Ordinary_Fixed_Point_Type
);
4562 Write_Str
("delta ");
4563 Write_Ureal_With_Col_Check_Sloc
(Delta_Value
(Typ
));
4564 Write_Str
(" range ");
4565 Sprint_Node
(Type_Low_Bound
(Typ
));
4567 Sprint_Node
(Type_High_Bound
(Typ
));
4569 -- Decimal fixed-point types and subtypes
4571 when E_Decimal_Fixed_Point_Subtype
4572 | E_Decimal_Fixed_Point_Type
4574 Write_Header
(Ekind
(Typ
) = E_Decimal_Fixed_Point_Type
);
4576 Write_Str
("delta ");
4577 Write_Ureal_With_Col_Check_Sloc
(Delta_Value
(Typ
));
4578 Write_Str
(" digits ");
4579 Write_Uint_With_Col_Check
(Digits_Value
(Typ
), Decimal
);
4583 when E_Record_Subtype
4584 | E_Record_Subtype_With_Private
4586 Write_Header
(False);
4587 Write_Str
("record");
4593 C
:= First_Entity
(Typ
);
4594 while Present
(C
) loop
4598 Write_Id
(Etype
(C
));
4604 Write_Indent_Str
(" end record");
4608 when E_Class_Wide_Subtype
4611 Write_Header
(Ekind
(Typ
) = E_Class_Wide_Type
);
4612 Write_Name_With_Col_Check
(Chars
(Etype
(Typ
)));
4613 Write_Str
("'Class");
4617 when E_Subprogram_Type
=>
4620 if Etype
(Typ
) = Standard_Void_Type
then
4621 Write_Str
("procedure");
4623 Write_Str
("function");
4626 if Present
(First_Entity
(Typ
)) then
4633 Param
:= First_Entity
(Typ
);
4638 if Ekind
(Param
) = E_In_Out_Parameter
then
4639 Write_Str
("in out ");
4640 elsif Ekind
(Param
) = E_Out_Parameter
then
4644 Write_Id
(Etype
(Param
));
4645 Next_Entity
(Param
);
4646 exit when No
(Param
);
4650 if Present
(Extra_Formals
(Typ
)) then
4651 Param
:= Extra_Formals
(Typ
);
4653 while Present
(Param
) loop
4657 Write_Id
(Etype
(Param
));
4659 Param
:= Extra_Formal
(Param
);
4666 elsif Present
(Extra_Formals
(Typ
)) then
4673 Param
:= Extra_Formals
(Typ
);
4675 while Present
(Param
) loop
4678 Write_Id
(Etype
(Param
));
4680 if Present
(Extra_Formal
(Param
)) then
4684 Param
:= Extra_Formal
(Param
);
4691 if Etype
(Typ
) /= Standard_Void_Type
then
4692 Write_Str
(" return ");
4693 Write_Id
(Etype
(Typ
));
4696 when E_String_Literal_Subtype
=>
4698 L
: constant Uint
:=
4699 Expr_Value
(String_Literal_Low_Bound
(Typ
));
4700 Len
: constant Uint
:=
4701 String_Literal_Length
(Typ
);
4703 Write_Header
(False);
4704 Write_Str
("String (");
4705 Write_Int
(UI_To_Int
(L
));
4707 Write_Int
(UI_To_Int
(L
+ Len
) - 1);
4711 -- For all other Itypes, print a triple ? (fill in later
4715 Write_Header
(True);
4720 -- Add terminating bracket and restore output buffer
4724 Restore_Output_Buffer
(S
);
4727 Set_Itype_Printed
(Typ
);
4731 -------------------------------
4732 -- Write_Name_With_Col_Check --
4733 -------------------------------
4735 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
4741 -- Avoid crashing on invalid Name_Ids
4743 if not Is_Valid_Name
(N
) then
4744 Write_Str
("<invalid name ");
4745 Write_Int
(Int
(N
));
4750 Get_Name_String
(N
);
4752 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4753 -- upper case letter, nnn is one or more digits and b is a lower case
4754 -- letter by C...b, so that listings do not depend on serial numbers.
4756 if Debug_Flag_II
then
4758 while J
< Name_Len
- 1 loop
4759 if Name_Buffer
(J
) in 'A' .. 'Z'
4760 and then Name_Buffer
(J
+ 1) in '0' .. '9'
4763 while K
< Name_Len
loop
4764 exit when Name_Buffer
(K
) not in '0' .. '9';
4768 if Name_Buffer
(K
) in 'a' .. 'z' then
4769 L
:= Name_Len
- K
+ 1;
4771 Name_Buffer
(J
+ 4 .. J
+ L
+ 3) :=
4772 Name_Buffer
(K
.. Name_Len
);
4773 Name_Buffer
(J
+ 1 .. J
+ 3) := "...";
4774 Name_Len
:= J
+ L
+ 3;
4787 -- Fall through for normal case
4789 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4790 end Write_Name_With_Col_Check
;
4792 ------------------------------------
4793 -- Write_Name_With_Col_Check_Sloc --
4794 ------------------------------------
4796 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
4798 -- Avoid crashing on invalid Name_Ids
4800 if not Is_Valid_Name
(N
) then
4801 Write_Str
("<invalid name ");
4802 Write_Int
(Int
(N
));
4807 Get_Name_String
(N
);
4808 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
4809 end Write_Name_With_Col_Check_Sloc
;
4811 --------------------
4812 -- Write_Operator --
4813 --------------------
4815 procedure Write_Operator
(N
: Node_Id
; S
: String) is
4816 F
: Natural := S
'First;
4817 T
: Natural := S
'Last;
4820 -- If no overflow check, just write string out, and we are done
4822 if not Do_Overflow_Check
(N
) then
4825 -- If overflow check, we want to surround the operator with curly
4826 -- brackets, but not include spaces within the brackets.
4839 Write_Str_Sloc
(S
(F
.. T
));
4842 if S
(S
'Last) = ' ' then
4848 -----------------------
4849 -- Write_Param_Specs --
4850 -----------------------
4852 procedure Write_Param_Specs
(N
: Node_Id
) is
4853 Specs
: constant List_Id
:= Parameter_Specifications
(N
);
4854 Specs_Present
: constant Boolean := Is_Non_Empty_List
(Specs
);
4861 Output
: Boolean := False;
4862 -- Set true if we output at least one parameter
4865 -- Write out explicit specs from Parameter_Specifications list
4867 if Specs_Present
then
4868 Write_Str_With_Col_Check
(" (");
4871 Spec
:= First
(Specs
);
4874 Formal
:= Defining_Identifier
(Spec
);
4876 exit when Spec
= Empty
;
4878 -- Add semicolon, unless we are printing original tree and the
4879 -- next specification is part of a list (but not the first element
4882 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4888 -- See if we have extra formals
4890 if Nkind
(N
) in N_Function_Specification | N_Procedure_Specification
then
4891 Ent
:= Defining_Entity
(N
);
4893 -- Loop to write extra formals (if any)
4895 if Present
(Ent
) and then Is_Subprogram
(Ent
) then
4896 Extras
:= Extra_Formals
(Ent
);
4898 if Present
(Extras
) then
4899 if not Specs_Present
then
4900 Write_Str_With_Col_Check
(" (");
4905 while Present
(Formal
) loop
4906 if Specs_Present
or else Formal
/= Extras
then
4910 Write_Name_With_Col_Check
(Chars
(Formal
));
4912 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
4913 Formal
:= Extra_Formal
(Formal
);
4922 end Write_Param_Specs
;
4924 -----------------------
4925 -- Write_Rewrite_Str --
4926 -----------------------
4928 procedure Write_Rewrite_Str
(S
: String) is
4930 if not Dump_Generated_Only
then
4931 if S
'Length = 3 and then S
= ">>>" then
4934 Write_Str_With_Col_Check
(S
);
4937 end Write_Rewrite_Str
;
4939 -----------------------
4940 -- Write_Source_Line --
4941 -----------------------
4943 procedure Write_Source_Line
(L
: Physical_Line_Number
) is
4945 Src
: Source_Buffer_Ptr
;
4949 if Dump_Source_Text
then
4950 Src
:= Source_Text
(Current_Source_File
);
4951 Loc
:= Line_Start
(L
, Current_Source_File
);
4954 -- See if line is a comment line, if not, and if not line one,
4955 -- precede with blank line.
4958 while Src
(Scn
) = ' ' or else Src
(Scn
) = ASCII
.HT
loop
4962 if (Src
(Scn
) in Line_Terminator
4963 or else Src
(Scn
.. Scn
+ 1) /= "--")
4969 -- Now write the source text of the line
4972 Write_Int
(Int
(L
));
4975 -- We need to check for EOF here, in case the last line of the source
4976 -- file does not have a Line_Terminator.
4978 while Src
(Loc
) not in Line_Terminator | EOF
loop
4979 Write_Char
(Src
(Loc
));
4983 end Write_Source_Line
;
4985 ------------------------
4986 -- Write_Source_Lines --
4987 ------------------------
4989 procedure Write_Source_Lines
(L
: Physical_Line_Number
) is
4991 while Last_Line_Printed
< L
loop
4992 Last_Line_Printed
:= Last_Line_Printed
+ 1;
4993 Write_Source_Line
(Last_Line_Printed
);
4995 end Write_Source_Lines
;
4997 --------------------
4998 -- Write_Str_Sloc --
4999 --------------------
5001 procedure Write_Str_Sloc
(S
: String) is
5003 for J
in S
'Range loop
5004 Write_Char_Sloc
(S
(J
));
5008 ------------------------------
5009 -- Write_Str_With_Col_Check --
5010 ------------------------------
5012 procedure Write_Str_With_Col_Check
(S
: String) is
5014 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
5015 Write_Indent_Str
(" ");
5017 if S
(S
'First) = ' ' then
5018 Write_Str
(S
(S
'First + 1 .. S
'Last));
5026 end Write_Str_With_Col_Check
;
5028 -----------------------------------
5029 -- Write_Str_With_Col_Check_Sloc --
5030 -----------------------------------
5032 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
5034 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
5035 Write_Indent_Str
(" ");
5037 if S
(S
'First) = ' ' then
5038 Write_Str_Sloc
(S
(S
'First + 1 .. S
'Last));
5046 end Write_Str_With_Col_Check_Sloc
;
5048 ---------------------------
5049 -- Write_Subprogram_Name --
5050 ---------------------------
5052 procedure Write_Subprogram_Name
(N
: Node_Id
) is
5054 if not Comes_From_Source
(N
)
5055 and then Is_Entity_Name
(N
)
5058 Ent
: constant Entity_Id
:= Entity
(N
);
5060 if not In_Extended_Main_Source_Unit
(Ent
)
5061 and then In_Predefined_Unit
(Ent
)
5063 -- Run-time routine name, output name with a preceding dollar
5064 -- making sure that we do not get a line split between them.
5066 Col_Check
(Length_Of_Name
(Chars
(Ent
)) + 1);
5068 Write_Name
(Chars
(Ent
));
5074 -- Normal case, not a run-time routine name
5077 end Write_Subprogram_Name
;
5079 -------------------------------
5080 -- Write_Uint_With_Col_Check --
5081 -------------------------------
5083 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
) is
5085 Col_Check
(UI_Decimal_Digits_Hi
(U
));
5086 UI_Write
(U
, Format
);
5087 end Write_Uint_With_Col_Check
;
5089 ------------------------------------
5090 -- Write_Uint_With_Col_Check_Sloc --
5091 ------------------------------------
5093 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
5095 Col_Check
(UI_Decimal_Digits_Hi
(U
));
5097 UI_Write
(U
, Format
);
5098 end Write_Uint_With_Col_Check_Sloc
;
5100 -------------------------------------
5101 -- Write_Ureal_With_Col_Check_Sloc --
5102 -------------------------------------
5104 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
5105 D
: constant Uint
:= Denominator
(U
);
5106 N
: constant Uint
:= Numerator
(U
);
5108 Col_Check
(UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
5110 UR_Write
(U
, Brackets
=> True);
5111 end Write_Ureal_With_Col_Check_Sloc
;