1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2020, 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
;
33 with Namet
; use Namet
;
34 with Nlists
; use Nlists
;
36 with Output
; use Output
;
37 with Rtsfind
; use Rtsfind
;
38 with Sem_Eval
; use Sem_Eval
;
39 with Sem_Util
; use Sem_Util
;
40 with Sinfo
; use Sinfo
;
41 with Sinput
; use Sinput
;
42 with Sinput
.D
; use Sinput
.D
;
43 with Snames
; use Snames
;
44 with Stand
; use Stand
;
45 with Stringt
; use Stringt
;
46 with Uintp
; use Uintp
;
47 with Uname
; use Uname
;
48 with Urealp
; use Urealp
;
50 package body Sprint
is
51 Current_Source_File
: Source_File_Index
;
52 -- Index of source file whose generated code is being dumped
54 Dump_Node
: Node_Id
:= Empty
;
55 -- This is set to the current node, used for printing line numbers. In
56 -- Debug_Generated_Code mode, Dump_Node is set to the current node
57 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
58 -- value. The call clears it back to Empty.
60 First_Debug_Sloc
: Source_Ptr
;
61 -- Sloc of first byte of the current output file if we are generating a
64 Debug_Sloc
: Source_Ptr
;
65 -- Sloc of first byte of line currently being written if we are
66 -- generating a source debug file.
68 Dump_Original_Only
: Boolean;
69 -- Set True if the -gnatdo (dump original tree) flag is set
71 Dump_Generated_Only
: Boolean;
72 -- Set True if the -gnatdG (dump generated tree) debug flag is set
73 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
75 Dump_Freeze_Null
: Boolean;
76 -- Set True if empty freeze nodes and non-source null statements output.
77 -- Note that freeze nodes containing freeze actions are always output,
78 -- as are freeze nodes for itypes, which in general have the effect of
79 -- causing elaboration of the itype.
81 Freeze_Indent
: Int
:= 0;
82 -- Keep track of freeze indent level (controls output of blank lines before
83 -- procedures within expression freeze actions). Relevant only if we are
84 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
85 -- output these blank lines in any case.
88 -- Number of columns for current line output indentation
90 Indent_Annull_Flag
: Boolean := False;
91 -- Set True if subsequent Write_Indent call to be ignored, gets reset
92 -- by this call, so it is only active to suppress a single indent call.
94 Last_Line_Printed
: Physical_Line_Number
;
95 -- This keeps track of the physical line number of the last source line
96 -- that has been output. The value is only valid in Dump_Source_Text mode.
98 -------------------------------
99 -- Operator Precedence Table --
100 -------------------------------
102 -- This table is used to decide whether a subexpression needs to be
103 -- parenthesized. The rule is that if an operand of an operator (which
104 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
105 -- with a lower precedence than the operator (or equal precedence if
106 -- appearing as the right operand), then parentheses are required.
108 Op_Prec
: constant array (N_Subexpr
) of Short_Short_Integer :=
141 procedure Sprint_Left_Opnd
(N
: Node_Id
);
142 -- Print left operand of operator, parenthesizing if necessary
144 procedure Sprint_Right_Opnd
(N
: Node_Id
);
145 -- Print right operand of operator, parenthesizing if necessary
147 -----------------------
148 -- Local Subprograms --
149 -----------------------
151 procedure Col_Check
(N
: Nat
);
152 -- Check that at least N characters remain on current line, and if not,
153 -- then start an extra line with two characters extra indentation for
154 -- continuing text on the next line.
156 procedure Extra_Blank_Line
;
157 -- In some situations we write extra blank lines to separate the generated
158 -- code to make it more readable. However, these extra blank lines are not
159 -- generated in Dump_Source_Text mode, since there the source text lines
160 -- output with preceding blank lines are quite sufficient as separators.
161 -- This procedure writes a blank line if Dump_Source_Text is False.
163 procedure Indent_Annull
;
164 -- Causes following call to Write_Indent to be ignored. This is used when
165 -- a higher level node wants to stop a lower level node from starting a
166 -- new line, when it would otherwise be inclined to do so (e.g. the case
167 -- of an accept statement called from an accept alternative with a guard)
169 procedure Indent_Begin
;
170 -- Increase indentation level
172 procedure Indent_End
;
173 -- Decrease indentation level
175 procedure Print_Debug_Line
(S
: String);
176 -- Used to print output lines in Debug_Generated_Code mode (this is used
177 -- as the argument for a call to Set_Special_Output in package Output).
179 procedure Set_Debug_Sloc
;
180 -- If Dump_Node is non-empty, this routine sets the appropriate value
181 -- in its Sloc field, from the current location in the debug source file
182 -- that is currently being written.
184 procedure Sprint_And_List
(List
: List_Id
);
185 -- Print the given list with items separated by vertical "and"
187 procedure Sprint_Aspect_Specifications
189 Semicolon
: Boolean);
190 -- Node is a declaration node that has aspect specifications (Has_Aspects
191 -- flag set True). It outputs the aspect specifications. For the case
192 -- of Semicolon = True, it is called after outputting the terminating
193 -- semicolon for the related node. The effect is to remove the semicolon
194 -- and print the aspect specifications followed by a terminating semicolon.
195 -- For the case of Semicolon False, no semicolon is removed or output, and
196 -- all the aspects are printed on a single line.
198 procedure Sprint_Bar_List
(List
: List_Id
);
199 -- Print the given list with items separated by vertical bars
201 procedure Sprint_End_Label
204 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
205 -- If there is no end label, use the defining identifier of the enclosing
206 -- construct. If the end label is present, treat it as a reference to the
207 -- defining entity of the construct: this guarantees that it carries the
208 -- proper sloc information for debugging purposes.
210 procedure Sprint_Node_Actual
(Node
: Node_Id
);
211 -- This routine prints its node argument. It is a lower level routine than
212 -- Sprint_Node, in that it does not bother about rewritten trees.
214 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
215 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
216 -- sets the Sloc of the current debug node to be a copy of the Sloc
217 -- of the sprinted node Node. Note that this is done after printing
218 -- Node, so that the Sloc is the proper updated value for the debug file.
220 procedure Update_Itype
(Node
: Node_Id
);
221 -- Update the Sloc of an itype that is not attached to the tree, when
222 -- debugging expanded code. This routine is called from nodes whose
223 -- type can be an Itype, such as defining_identifiers that may be of
224 -- an anonymous access type, or ranges in slices.
226 procedure Write_Char_Sloc
(C
: Character);
227 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
228 -- called to ensure that the current node has a proper Sloc set.
230 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
231 -- Write Condition and Reason codes of Raise_xxx_Error node
233 procedure Write_Corresponding_Source
(S
: String);
234 -- If S is a string with a single keyword (possibly followed by a space),
235 -- and if the next non-comment non-blank source line matches this keyword,
236 -- then output all source lines up to this matching line.
238 procedure Write_Discr_Specs
(N
: Node_Id
);
239 -- Output discriminant specification for node, which is any of the type
240 -- declarations that can have discriminants.
242 procedure Write_Ekind
(E
: Entity_Id
);
243 -- Write the String corresponding to the Ekind without "E_"
245 procedure Write_Id
(N
: Node_Id
);
246 -- N is a node with a Chars field. This procedure writes the name that
247 -- will be used in the generated code associated with the name. For a
248 -- node with no associated entity, this is simply the Chars field. For
249 -- the case where there is an entity associated with the node, we print
250 -- the name associated with the entity (since it may have been encoded).
251 -- One other special case is that an entity has an active external name
252 -- (i.e. an external name present with no address clause), then this
253 -- external name is output. This procedure also deals with outputting
254 -- declarations of referenced itypes, if not output earlier.
256 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
257 -- Handle node where the grammar has a list of defining identifiers, but
258 -- the tree has a separate declaration for each identifier. Handles the
259 -- printing of the defining identifier, and returns True if the type and
260 -- initialization information is to be printed, False if it is to be
261 -- skipped (the latter case happens when printing defining identifiers
262 -- other than the first in the original tree output case).
264 procedure Write_Implicit_Def
(E
: Entity_Id
);
265 pragma Warnings
(Off
, Write_Implicit_Def
);
266 -- Write the definition of the implicit type E according to its Ekind
267 -- For now a debugging procedure, but might be used in the future.
269 procedure Write_Indent
;
270 -- Start a new line and write indentation spacing
272 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
273 -- Like Write_Identifiers except that each new printed declaration
274 -- is at the start of a new line.
276 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
277 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
278 -- mode, the Sloc of the current debug node is set to point to the
279 -- first output identifier.
281 procedure Write_Indent_Str
(S
: String);
282 -- Start a new line and write indent spacing followed by given string
284 procedure Write_Indent_Str_Sloc
(S
: String);
285 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
286 -- the Sloc of the current node is set to the first non-blank character
289 procedure Write_Itype
(Typ
: Entity_Id
);
290 -- If Typ is an Itype that has not been written yet, write it. If Typ is
291 -- any other kind of entity or tree node, the call is ignored.
293 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
294 -- Write name (using Write_Name) with initial column check, and possible
295 -- initial Write_Indent (to get new line) if current line is too full.
297 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
298 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
299 -- mode, sets Sloc of current debug node to first character of name.
301 procedure Write_Operator
(N
: Node_Id
; S
: String);
302 -- Like Write_Str_Sloc, used for operators, encloses the string in
303 -- characters {} if the Do_Overflow flag is set on the node N.
305 procedure Write_Param_Specs
(N
: Node_Id
);
306 -- Output parameter specifications for node N (which is a subprogram, or
307 -- entry or entry family or access-subprogram-definition, all of which
308 -- have a Parameter_Specificatioons field).
310 procedure Write_Rewrite_Str
(S
: String);
311 -- Writes out a string (typically containing <<< or >>>}) for a node
312 -- created by rewriting the tree. Suppressed if we are outputting the
313 -- generated code only, since in this case we don't specially mark nodes
314 -- created by rewriting).
316 procedure Write_Source_Line
(L
: Physical_Line_Number
);
317 -- If writing of interspersed source lines is enabled, then write the given
318 -- line from the source file, preceded by Eol, then an extra blank line if
319 -- the line has at least one blank, is not a comment and is not line one,
320 -- then "--" and the line number followed by period followed by text of the
321 -- source line (without terminating Eol). If interspersed source line
322 -- output not enabled, then the call has no effect.
324 procedure Write_Source_Lines
(L
: Physical_Line_Number
);
325 -- If writing of interspersed source lines is enabled, then writes source
326 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
327 -- interspersed source line output not enabled, then call has no effect.
329 procedure Write_Str_Sloc
(S
: String);
330 -- Like Write_Str, but sets debug Sloc of current debug node to first
331 -- non-blank character if a current debug node is active.
333 procedure Write_Str_With_Col_Check
(S
: String);
334 -- Write string (using Write_Str) with initial column check, and possible
335 -- initial Write_Indent (to get new line) if current line is too full.
337 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
338 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
339 -- node to first non-blank character if a current debug node is active.
341 procedure Write_Subprogram_Name
(N
: Node_Id
);
342 -- N is the Name field of a function call or procedure statement call.
343 -- The effect of the call is to output the name, preceded by a $ if the
344 -- call is identified as an implicit call to a run time routine.
346 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
);
347 -- Write Uint (using UI_Write) with initial column check, and possible
348 -- initial Write_Indent (to get new line) if current line is too full.
349 -- The format parameter determines the output format (see UI_Write).
351 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
352 -- Write Uint (using UI_Write) with initial column check, and possible
353 -- initial Write_Indent (to get new line) if current line is too full.
354 -- The format parameter determines the output format (see UI_Write).
355 -- In addition, in Debug_Generated_Code mode, sets the current node
356 -- Sloc to the first character of the output value.
358 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
359 -- Write Ureal (using same output format as UR_Write) with column checks
360 -- and a possible initial Write_Indent (to get new line) if current line
361 -- is too full. In addition, in Debug_Generated_Code mode, sets the
362 -- current node Sloc to the first character of the output value.
368 procedure Col_Check
(N
: Nat
) is
370 if N
+ Column
> Sprint_Line_Limit
then
371 Write_Indent_Str
(" ");
375 ----------------------
376 -- Extra_Blank_Line --
377 ----------------------
379 procedure Extra_Blank_Line
is
381 if not Dump_Source_Text
then
384 end Extra_Blank_Line
;
390 procedure Indent_Annull
is
392 Indent_Annull_Flag
:= True;
399 procedure Indent_Begin
is
401 Indent
:= Indent
+ 3;
408 procedure Indent_End
is
410 Indent
:= Indent
- 3;
417 procedure pg
(Arg
: Union_Id
) is
419 Dump_Generated_Only
:= True;
420 Dump_Original_Only
:= False;
421 Dump_Freeze_Null
:= True;
422 Current_Source_File
:= No_Source_File
;
426 if Arg
in List_Range
then
427 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
429 elsif Arg
in Node_Range
then
430 Sprint_Node
(Node_Id
(Arg
));
444 procedure po
(Arg
: Union_Id
) is
446 Dump_Generated_Only
:= False;
447 Dump_Original_Only
:= True;
448 Dump_Freeze_Null
:= False;
449 Current_Source_File
:= No_Source_File
;
453 if Arg
in List_Range
then
454 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
456 elsif Arg
in Node_Range
then
457 Sprint_Node
(Node_Id
(Arg
));
467 ----------------------
468 -- Print_Debug_Line --
469 ----------------------
471 procedure Print_Debug_Line
(S
: String) is
473 Write_Debug_Line
(S
, Debug_Sloc
);
474 end Print_Debug_Line
;
480 procedure ps
(Arg
: Union_Id
) is
482 Dump_Generated_Only
:= False;
483 Dump_Original_Only
:= False;
484 Dump_Freeze_Null
:= False;
485 Current_Source_File
:= No_Source_File
;
489 if Arg
in List_Range
then
490 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
492 elsif Arg
in Node_Range
then
493 Sprint_Node
(Node_Id
(Arg
));
507 procedure Set_Debug_Sloc
is
509 if Debug_Generated_Code
and then Present
(Dump_Node
) then
511 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
514 -- Do not change the location of nodes defined in package Standard
515 -- and nodes of pragmas scanned by Targparm.
517 if Loc
<= Standard_Location
then
520 -- Update the location of a node which is part of the current .dg
521 -- output. This situation occurs in comma separated parameter
522 -- declarations since each parameter references the same parameter
523 -- type node (ie. obj1, obj2 : <param-type>).
525 -- Note: This case is needed here since we cannot use the routine
526 -- In_Extended_Main_Code_Unit with nodes whose location is a .dg
529 elsif Loc
>= First_Debug_Sloc
then
530 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
532 -- Do not change the location of nodes which are not part of the
535 elsif not In_Extended_Main_Code_Unit
(Loc
) then
539 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
543 -- We do not know the actual end location in the generated code and
544 -- it could be much closer than in the source code, so play safe.
546 if Nkind
(Dump_Node
) in N_Case_Statement | N_If_Statement
then
547 Set_End_Location
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
558 procedure Source_Dump
is
561 -- Put underline under string we just printed
567 procedure Underline
is
568 Col
: constant Int
:= Column
;
573 while Col
> Column
loop
580 -- Start of processing for Source_Dump
583 Dump_Generated_Only
:= Debug_Flag_G
or
584 Print_Generated_Code
or
585 Debug_Generated_Code
;
586 Dump_Original_Only
:= Debug_Flag_O
;
587 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
589 -- Note that we turn off the tree dump flags immediately, before
590 -- starting the dump. This avoids generating two copies of the dump
591 -- if an abort occurs after printing the dump, and more importantly,
592 -- avoids an infinite loop if an abort occurs during the dump.
595 Current_Source_File
:= No_Source_File
;
596 Debug_Flag_Z
:= False;
599 Write_Str
("Source recreated from tree of Standard (spec)");
601 Sprint_Node
(Standard_Package_Node
);
606 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
607 Debug_Flag_G
:= False;
608 Debug_Flag_O
:= False;
609 Debug_Flag_S
:= False;
610 First_Debug_Sloc
:= No_Location
;
612 -- Dump requested units
614 for U
in Main_Unit
.. Last_Unit
loop
615 Current_Source_File
:= Source_Index
(U
);
617 -- Dump all units if -gnatdf set, otherwise dump only the source
618 -- files that are in the extended main source. Note that, if we
619 -- are generating debug files, generating that of the main unit
620 -- has an effect on the outcome of In_Extended_Main_Source_Unit
621 -- because slocs are rewritten, so we also test for equality of
622 -- Cunit_Entity to work around this effect.
625 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
626 or else Cunit_Entity
(U
) = Cunit_Entity
(Main_Unit
)
628 -- If we are generating debug files, setup to write them
630 if Debug_Generated_Code
then
631 Set_Special_Output
(Print_Debug_Line
'Access);
632 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
633 First_Debug_Sloc
:= Debug_Sloc
;
634 Write_Source_Line
(1);
635 Last_Line_Printed
:= 1;
637 -- If this unit has the same entity as the main unit, for
638 -- example is the spec of a stand-alone instantiation of
639 -- a package and the main unit is the body, its debug file
640 -- will also be the same. Therefore, we need to print again
641 -- the main unit to have both units in the debug file.
644 and then Cunit_Entity
(U
) = Cunit_Entity
(Main_Unit
)
646 Sprint_Node
(Cunit
(Main_Unit
));
650 Sprint_Node
(Cunit
(U
));
651 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
654 Cancel_Special_Output
;
656 -- Normal output to standard output file
659 Write_Str
("Source recreated from tree for ");
660 Write_Unit_Name
(Unit_Name
(U
));
662 Write_Source_Line
(1);
663 Last_Line_Printed
:= 1;
664 Sprint_Node
(Cunit
(U
));
665 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
674 ---------------------
675 -- Sprint_And_List --
676 ---------------------
678 procedure Sprint_And_List
(List
: List_Id
) is
681 if Is_Non_Empty_List
(List
) then
682 Node
:= First
(List
);
686 exit when Node
= Empty
;
692 ----------------------------------
693 -- Sprint_Aspect_Specifications --
694 ----------------------------------
696 procedure Sprint_Aspect_Specifications
700 AS
: constant List_Id
:= Aspect_Specifications
(Node
);
705 Write_Erase_Char
(';');
706 Indent
:= Indent
+ 2;
709 Indent
:= Indent
+ 5;
712 Write_Str
(" with ");
717 Sprint_Node
(Identifier
(A
));
719 if Class_Present
(A
) then
720 Write_Str
("'Class");
723 if Present
(Expression
(A
)) then
725 Sprint_Node
(Expression
(A
));
739 Indent
:= Indent
- 7;
742 end Sprint_Aspect_Specifications
;
744 ---------------------
745 -- Sprint_Bar_List --
746 ---------------------
748 procedure Sprint_Bar_List
(List
: List_Id
) is
751 if Is_Non_Empty_List
(List
) then
752 Node
:= First
(List
);
756 exit when Node
= Empty
;
762 ----------------------
763 -- Sprint_End_Label --
764 ----------------------
766 procedure Sprint_End_Label
772 and then Present
(End_Label
(Node
))
773 and then Is_Entity_Name
(End_Label
(Node
))
775 Set_Entity
(End_Label
(Node
), Default
);
777 -- For a function whose name is an operator, use the qualified name
778 -- created for the defining entity.
780 if Nkind
(End_Label
(Node
)) = N_Operator_Symbol
then
781 Set_Chars
(End_Label
(Node
), Chars
(Default
));
784 Sprint_Node
(End_Label
(Node
));
786 Sprint_Node
(Default
);
788 end Sprint_End_Label
;
790 -----------------------
791 -- Sprint_Comma_List --
792 -----------------------
794 procedure Sprint_Comma_List
(List
: List_Id
) is
798 if Is_Non_Empty_List
(List
) then
799 Node
:= First
(List
);
803 exit when Node
= Empty
;
805 if not Is_Rewrite_Insertion
(Node
)
806 or else not Dump_Original_Only
812 end Sprint_Comma_List
;
814 --------------------------
815 -- Sprint_Indented_List --
816 --------------------------
818 procedure Sprint_Indented_List
(List
: List_Id
) is
821 Sprint_Node_List
(List
);
823 end Sprint_Indented_List
;
825 ---------------------
826 -- Sprint_Left_Opnd --
827 ---------------------
829 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
830 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
833 if Paren_Count
(Opnd
) /= 0
834 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
843 end Sprint_Left_Opnd
;
849 procedure Sprint_Node
(Node
: Node_Id
) is
851 if Is_Rewrite_Insertion
(Node
) then
852 if not Dump_Original_Only
then
854 -- For special cases of nodes that always output <<< >>>
855 -- do not duplicate the output at this point.
857 if Nkind
(Node
) = N_Freeze_Entity
858 or else Nkind
(Node
) = N_Freeze_Generic_Entity
859 or else Nkind
(Node
) = N_Implicit_Label_Declaration
861 Sprint_Node_Actual
(Node
);
863 -- Normal case where <<< >>> may be required
866 Write_Rewrite_Str
("<<<");
867 Sprint_Node_Actual
(Node
);
868 Write_Rewrite_Str
(">>>");
872 elsif Is_Rewrite_Substitution
(Node
) then
874 -- Case of dump generated only
876 if Dump_Generated_Only
then
877 Sprint_Node_Actual
(Node
);
879 -- Case of dump original only
881 elsif Dump_Original_Only
then
882 Sprint_Node_Actual
(Original_Node
(Node
));
884 -- Case of both being dumped
887 Sprint_Node_Actual
(Original_Node
(Node
));
888 Write_Rewrite_Str
("<<<");
889 Sprint_Node_Actual
(Node
);
890 Write_Rewrite_Str
(">>>");
894 Sprint_Node_Actual
(Node
);
898 ------------------------
899 -- Sprint_Node_Actual --
900 ------------------------
902 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
903 Save_Dump_Node
: constant Node_Id
:= Dump_Node
;
910 for J
in 1 .. Paren_Count
(Node
) loop
911 Write_Str_With_Col_Check
("(");
914 -- Setup current dump node
918 if Nkind
(Node
) in N_Subexpr
919 and then Do_Range_Check
(Node
)
921 Write_Str_With_Col_Check
("{");
924 -- Select print circuit based on node kind
927 when N_Abort_Statement
=>
928 Write_Indent_Str_Sloc
("abort ");
929 Sprint_Comma_List
(Names
(Node
));
932 when N_Abortable_Part
=>
934 Write_Str_Sloc
("abort ");
935 Sprint_Indented_List
(Statements
(Node
));
937 when N_Abstract_Subprogram_Declaration
=>
939 Sprint_Node
(Specification
(Node
));
940 Write_Str_With_Col_Check
(" is ");
941 Write_Str_Sloc
("abstract;");
943 when N_Accept_Alternative
=>
944 Sprint_Node_List
(Pragmas_Before
(Node
));
946 if Present
(Condition
(Node
)) then
947 Write_Indent_Str
("when ");
948 Sprint_Node
(Condition
(Node
));
953 Sprint_Node_Sloc
(Accept_Statement
(Node
));
954 Sprint_Node_List
(Statements
(Node
));
956 when N_Accept_Statement
=>
957 Write_Indent_Str_Sloc
("accept ");
958 Write_Id
(Entry_Direct_Name
(Node
));
960 if Present
(Entry_Index
(Node
)) then
961 Write_Str_With_Col_Check
(" (");
962 Sprint_Node
(Entry_Index
(Node
));
966 Write_Param_Specs
(Node
);
968 if Present
(Handled_Statement_Sequence
(Node
)) then
969 Write_Str_With_Col_Check
(" do");
970 Sprint_Node
(Handled_Statement_Sequence
(Node
));
971 Write_Indent_Str
("end ");
972 Write_Id
(Entry_Direct_Name
(Node
));
977 when N_Access_Definition
=>
981 if Present
(Access_To_Subprogram_Definition
(Node
)) then
982 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
986 if Null_Exclusion_Present
(Node
) then
987 Write_Str
("not null ");
990 Write_Str_With_Col_Check_Sloc
("access ");
992 if All_Present
(Node
) then
994 elsif Constant_Present
(Node
) then
995 Write_Str
("constant ");
998 Sprint_Node
(Subtype_Mark
(Node
));
1001 when N_Access_Function_Definition
=>
1003 -- Ada 2005 (AI-231)
1005 if Null_Exclusion_Present
(Node
) then
1006 Write_Str
("not null ");
1009 Write_Str_With_Col_Check_Sloc
("access ");
1011 if Protected_Present
(Node
) then
1012 Write_Str_With_Col_Check
("protected ");
1015 Write_Str_With_Col_Check
("function");
1016 Write_Param_Specs
(Node
);
1017 Write_Str_With_Col_Check
(" return ");
1018 Sprint_Node
(Result_Definition
(Node
));
1020 when N_Access_Procedure_Definition
=>
1022 -- Ada 2005 (AI-231)
1024 if Null_Exclusion_Present
(Node
) then
1025 Write_Str
("not null ");
1028 Write_Str_With_Col_Check_Sloc
("access ");
1030 if Protected_Present
(Node
) then
1031 Write_Str_With_Col_Check
("protected ");
1034 Write_Str_With_Col_Check
("procedure");
1035 Write_Param_Specs
(Node
);
1037 when N_Access_To_Object_Definition
=>
1038 Write_Str_With_Col_Check_Sloc
("access ");
1040 if All_Present
(Node
) then
1041 Write_Str_With_Col_Check
("all ");
1042 elsif Constant_Present
(Node
) then
1043 Write_Str_With_Col_Check
("constant ");
1046 -- Ada 2005 (AI-231)
1048 if Null_Exclusion_Present
(Node
) then
1049 Write_Str
("not null ");
1052 Sprint_Node
(Subtype_Indication
(Node
));
1055 if Null_Record_Present
(Node
) then
1056 Write_Str_With_Col_Check_Sloc
("(null record)");
1059 Write_Str_With_Col_Check_Sloc
("(");
1061 if Present
(Expressions
(Node
)) then
1062 Sprint_Comma_List
(Expressions
(Node
));
1064 if Present
(Component_Associations
(Node
))
1065 and then not Is_Empty_List
(Component_Associations
(Node
))
1071 if Present
(Component_Associations
(Node
))
1072 and then not Is_Empty_List
(Component_Associations
(Node
))
1080 Nd
:= First
(Component_Associations
(Node
));
1088 if not Is_Rewrite_Insertion
(Nd
)
1089 or else not Dump_Original_Only
1103 Write_Str_With_Col_Check_Sloc
("new ");
1105 -- Ada 2005 (AI-231)
1107 if Null_Exclusion_Present
(Node
) then
1108 Write_Str
("not null ");
1111 Sprint_Node
(Expression
(Node
));
1113 if Present
(Storage_Pool
(Node
)) then
1114 Write_Str_With_Col_Check
("[storage_pool = ");
1115 Sprint_Node
(Storage_Pool
(Node
));
1120 Sprint_Left_Opnd
(Node
);
1121 Write_Str_Sloc
(" and then ");
1122 Sprint_Right_Opnd
(Node
);
1124 -- Note: the following code for N_Aspect_Specification is not
1125 -- normally used, since we deal with aspects as part of a
1126 -- declaration, but it is here in case we deliberately try
1127 -- to print an N_Aspect_Speficiation node (e.g. from GDB).
1129 when N_Aspect_Specification
=>
1130 Sprint_Node
(Identifier
(Node
));
1132 Sprint_Node
(Expression
(Node
));
1134 when N_Assignment_Statement
=>
1136 Sprint_Node
(Name
(Node
));
1137 Write_Str_Sloc
(" := ");
1138 Sprint_Node
(Expression
(Node
));
1141 when N_Asynchronous_Select
=>
1142 Write_Indent_Str_Sloc
("select");
1144 Sprint_Node
(Triggering_Alternative
(Node
));
1147 -- Note: let the printing of Abortable_Part handle outputting
1148 -- the ABORT keyword, so that the Sloc can be set correctly.
1150 Write_Indent_Str
("then ");
1151 Sprint_Node
(Abortable_Part
(Node
));
1152 Write_Indent_Str
("end select;");
1155 Write_Indent_Str_Sloc
("for ");
1156 Write_Id
(Identifier
(Node
));
1157 Write_Str_With_Col_Check
(" use at ");
1158 Sprint_Node
(Expression
(Node
));
1161 when N_Attribute_Definition_Clause
=>
1162 Write_Indent_Str_Sloc
("for ");
1163 Sprint_Node
(Name
(Node
));
1165 Write_Name_With_Col_Check
(Chars
(Node
));
1166 Write_Str_With_Col_Check
(" use ");
1167 Sprint_Node
(Expression
(Node
));
1170 when N_Attribute_Reference
=>
1171 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1175 Sprint_Node
(Prefix
(Node
));
1176 Write_Char_Sloc
(''');
1177 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
1178 Sprint_Paren_Comma_List
(Expressions
(Node
));
1180 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1184 when N_Block_Statement
=>
1187 if Present
(Identifier
(Node
))
1188 and then (not Has_Created_Identifier
(Node
)
1189 or else not Dump_Original_Only
)
1191 Write_Rewrite_Str
("<<<");
1192 Write_Id
(Identifier
(Node
));
1194 Write_Rewrite_Str
(">>>");
1197 if Present
(Declarations
(Node
)) then
1198 Write_Str_With_Col_Check_Sloc
("declare");
1199 Sprint_Indented_List
(Declarations
(Node
));
1203 Write_Str_With_Col_Check_Sloc
("begin");
1204 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1205 Write_Indent_Str
("end");
1207 if Present
(Identifier
(Node
))
1208 and then (not Has_Created_Identifier
(Node
)
1209 or else not Dump_Original_Only
)
1211 Write_Rewrite_Str
("<<<");
1213 Write_Id
(Identifier
(Node
));
1214 Write_Rewrite_Str
(">>>");
1219 when N_Call_Marker
=>
1222 -- Enable the following code for debugging purposes only
1224 -- Write_Indent_Str ("#");
1225 -- Write_Id (Target (Node));
1226 -- Write_Char ('#');
1228 when N_Case_Expression
=>
1230 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
1234 -- The syntax for case_expression does not include parentheses,
1235 -- but sometimes parentheses are required, so unconditionally
1236 -- generate them here unless already present.
1238 if not Has_Parens
then
1242 Write_Str_With_Col_Check_Sloc
("case ");
1243 Sprint_Node
(Expression
(Node
));
1244 Write_Str_With_Col_Check
(" is");
1246 Alt
:= First
(Alternatives
(Node
));
1254 if not Has_Parens
then
1259 when N_Case_Expression_Alternative
=>
1260 Write_Str_With_Col_Check
(" when ");
1261 Sprint_Bar_List
(Discrete_Choices
(Node
));
1263 Sprint_Node
(Expression
(Node
));
1265 when N_Case_Statement
=>
1266 Write_Indent_Str_Sloc
("case ");
1267 Sprint_Node
(Expression
(Node
));
1269 Sprint_Indented_List
(Alternatives
(Node
));
1270 Write_Indent_Str
("end case;");
1272 when N_Case_Statement_Alternative
=>
1273 Write_Indent_Str_Sloc
("when ");
1274 Sprint_Bar_List
(Discrete_Choices
(Node
));
1276 Sprint_Indented_List
(Statements
(Node
));
1278 when N_Character_Literal
=>
1279 if Column
> Sprint_Line_Limit
- 2 then
1280 Write_Indent_Str
(" ");
1283 Write_Char_Sloc
(''');
1284 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
1287 when N_Code_Statement
=>
1290 Sprint_Node
(Expression
(Node
));
1293 when N_Compilation_Unit
=>
1294 Sprint_Node_List
(Context_Items
(Node
));
1295 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
1297 if Private_Present
(Node
) then
1298 Write_Indent_Str
("private ");
1302 Sprint_Node_Sloc
(Unit
(Node
));
1304 if Present
(Actions
(Aux_Decls_Node
(Node
)))
1306 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
1311 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
1312 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
1314 when N_Compilation_Unit_Aux
=>
1315 null; -- nothing to do, never used, see above
1317 when N_Component_Association
=>
1319 Sprint_Bar_List
(Choices
(Node
));
1322 -- Ada 2005 (AI-287): Print the box if present
1324 if Box_Present
(Node
) then
1325 Write_Str_With_Col_Check
("<>");
1327 Sprint_Node
(Expression
(Node
));
1330 when N_Iterated_Component_Association
=>
1332 Write_Str
(" for ");
1333 Write_Id
(Defining_Identifier
(Node
));
1335 Sprint_Bar_List
(Discrete_Choices
(Node
));
1337 Sprint_Node
(Expression
(Node
));
1339 when N_Iterated_Element_Association
=>
1341 if Present
(Iterator_Specification
(Node
)) then
1342 Sprint_Node
(Iterator_Specification
(Node
));
1344 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1347 if Present
(Key_Expression
(Node
)) then
1348 Write_Str
(" use ");
1349 Sprint_Node
(Key_Expression
(Node
));
1353 Sprint_Node
(Expression
(Node
));
1355 when N_Component_Clause
=>
1357 Sprint_Node
(Component_Name
(Node
));
1358 Write_Str_Sloc
(" at ");
1359 Sprint_Node
(Position
(Node
));
1361 Write_Str_With_Col_Check
("range ");
1362 Sprint_Node
(First_Bit
(Node
));
1364 Sprint_Node
(Last_Bit
(Node
));
1367 when N_Component_Definition
=>
1370 -- Ada 2005 (AI-230): Access definition components
1372 if Present
(Access_Definition
(Node
)) then
1373 Sprint_Node
(Access_Definition
(Node
));
1375 elsif Present
(Subtype_Indication
(Node
)) then
1376 if Aliased_Present
(Node
) then
1377 Write_Str_With_Col_Check
("aliased ");
1380 -- Ada 2005 (AI-231)
1382 if Null_Exclusion_Present
(Node
) then
1383 Write_Str
(" not null ");
1386 Sprint_Node
(Subtype_Indication
(Node
));
1389 Write_Str
(" ??? ");
1392 when N_Component_Declaration
=>
1393 if Write_Indent_Identifiers_Sloc
(Node
) then
1395 Sprint_Node
(Component_Definition
(Node
));
1397 if Present
(Expression
(Node
)) then
1399 Sprint_Node
(Expression
(Node
));
1405 when N_Component_List
=>
1406 if Null_Present
(Node
) then
1408 Write_Indent_Str_Sloc
("null");
1414 Sprint_Indented_List
(Component_Items
(Node
));
1415 Sprint_Node
(Variant_Part
(Node
));
1418 when N_Compound_Statement
=>
1419 Write_Indent_Str
("do");
1421 Sprint_Node_List
(Actions
(Node
));
1423 Write_Indent_Str
("end;");
1425 when N_Conditional_Entry_Call
=>
1426 Write_Indent_Str_Sloc
("select");
1428 Sprint_Node
(Entry_Call_Alternative
(Node
));
1430 Write_Indent_Str
("else");
1431 Sprint_Indented_List
(Else_Statements
(Node
));
1432 Write_Indent_Str
("end select;");
1434 when N_Constrained_Array_Definition
=>
1435 Write_Str_With_Col_Check_Sloc
("array ");
1436 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1439 Sprint_Node
(Component_Definition
(Node
));
1441 -- A contract node should not appear in the tree. It is a semantic
1442 -- node attached to entry and [generic] subprogram entities. But we
1443 -- still provide meaningful output, in case called from the debugger.
1451 Write_Str
("N_Contract node");
1454 Write_Indent_Str
("Pre_Post_Conditions");
1457 P
:= Pre_Post_Conditions
(Node
);
1458 while Present
(P
) loop
1460 P
:= Next_Pragma
(P
);
1466 Write_Indent_Str
("Contract_Test_Cases");
1469 P
:= Contract_Test_Cases
(Node
);
1470 while Present
(P
) loop
1472 P
:= Next_Pragma
(P
);
1478 Write_Indent_Str
("Classifications");
1481 P
:= Classifications
(Node
);
1482 while Present
(P
) loop
1484 P
:= Next_Pragma
(P
);
1492 when N_Decimal_Fixed_Point_Definition
=>
1493 Write_Str_With_Col_Check_Sloc
("delta ");
1494 Sprint_Node
(Delta_Expression
(Node
));
1495 Write_Str_With_Col_Check
(" digits ");
1496 Sprint_Node
(Digits_Expression
(Node
));
1497 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1499 when N_Defining_Character_Literal
=>
1500 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1502 when N_Defining_Identifier
=>
1506 when N_Defining_Operator_Symbol
=>
1507 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1509 when N_Defining_Program_Unit_Name
=>
1511 Sprint_Node
(Name
(Node
));
1513 Write_Id
(Defining_Identifier
(Node
));
1515 when N_Delay_Alternative
=>
1516 Sprint_Node_List
(Pragmas_Before
(Node
));
1518 if Present
(Condition
(Node
)) then
1520 Write_Str_With_Col_Check
("when ");
1521 Sprint_Node
(Condition
(Node
));
1526 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1527 Sprint_Node_List
(Statements
(Node
));
1529 when N_Delay_Relative_Statement
=>
1530 Write_Indent_Str_Sloc
("delay ");
1531 Sprint_Node
(Expression
(Node
));
1534 when N_Delay_Until_Statement
=>
1535 Write_Indent_Str_Sloc
("delay until ");
1536 Sprint_Node
(Expression
(Node
));
1539 when N_Delta_Constraint
=>
1540 Write_Str_With_Col_Check_Sloc
("delta ");
1541 Sprint_Node
(Delta_Expression
(Node
));
1542 Sprint_Opt_Node
(Range_Constraint
(Node
));
1544 when N_Derived_Type_Definition
=>
1545 if Abstract_Present
(Node
) then
1546 Write_Str_With_Col_Check
("abstract ");
1549 Write_Str_With_Col_Check
("new ");
1551 -- Ada 2005 (AI-231)
1553 if Null_Exclusion_Present
(Node
) then
1554 Write_Str_With_Col_Check
("not null ");
1557 Sprint_Node
(Subtype_Indication
(Node
));
1559 if Present
(Interface_List
(Node
)) then
1560 Write_Str_With_Col_Check
(" and ");
1561 Sprint_And_List
(Interface_List
(Node
));
1562 Write_Str_With_Col_Check
(" with ");
1565 if Present
(Record_Extension_Part
(Node
)) then
1566 if No
(Interface_List
(Node
)) then
1567 Write_Str_With_Col_Check
(" with ");
1570 Sprint_Node
(Record_Extension_Part
(Node
));
1573 when N_Designator
=>
1574 Sprint_Node
(Name
(Node
));
1575 Write_Char_Sloc
('.');
1576 Write_Id
(Identifier
(Node
));
1578 when N_Digits_Constraint
=>
1579 Write_Str_With_Col_Check_Sloc
("digits ");
1580 Sprint_Node
(Digits_Expression
(Node
));
1581 Sprint_Opt_Node
(Range_Constraint
(Node
));
1583 when N_Discriminant_Association
=>
1586 if Present
(Selector_Names
(Node
)) then
1587 Sprint_Bar_List
(Selector_Names
(Node
));
1592 Sprint_Node
(Expression
(Node
));
1594 when N_Discriminant_Specification
=>
1597 if Write_Identifiers
(Node
) then
1600 if Null_Exclusion_Present
(Node
) then
1601 Write_Str
("not null ");
1604 Sprint_Node
(Discriminant_Type
(Node
));
1606 if Present
(Expression
(Node
)) then
1608 Sprint_Node
(Expression
(Node
));
1614 when N_Elsif_Part
=>
1615 Write_Indent_Str_Sloc
("elsif ");
1616 Sprint_Node
(Condition
(Node
));
1617 Write_Str_With_Col_Check
(" then");
1618 Sprint_Indented_List
(Then_Statements
(Node
));
1623 when N_Entry_Body
=>
1624 Write_Indent_Str_Sloc
("entry ");
1625 Write_Id
(Defining_Identifier
(Node
));
1626 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1627 Write_Str_With_Col_Check
(" is");
1628 Sprint_Indented_List
(Declarations
(Node
));
1629 Write_Indent_Str
("begin");
1630 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1631 Write_Indent_Str
("end ");
1632 Write_Id
(Defining_Identifier
(Node
));
1635 when N_Entry_Body_Formal_Part
=>
1636 if Present
(Entry_Index_Specification
(Node
)) then
1637 Write_Str_With_Col_Check_Sloc
(" (");
1638 Sprint_Node
(Entry_Index_Specification
(Node
));
1642 Write_Param_Specs
(Node
);
1643 Write_Str_With_Col_Check_Sloc
(" when ");
1644 Sprint_Node
(Condition
(Node
));
1646 when N_Entry_Call_Alternative
=>
1647 Sprint_Node_List
(Pragmas_Before
(Node
));
1648 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1649 Sprint_Node_List
(Statements
(Node
));
1651 when N_Entry_Call_Statement
=>
1653 Sprint_Node_Sloc
(Name
(Node
));
1654 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1657 when N_Entry_Declaration
=>
1658 Write_Indent_Str_Sloc
("entry ");
1659 Write_Id
(Defining_Identifier
(Node
));
1661 if Present
(Discrete_Subtype_Definition
(Node
)) then
1662 Write_Str_With_Col_Check
(" (");
1663 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1667 Write_Param_Specs
(Node
);
1670 when N_Entry_Index_Specification
=>
1671 Write_Str_With_Col_Check_Sloc
("for ");
1672 Write_Id
(Defining_Identifier
(Node
));
1673 Write_Str_With_Col_Check
(" in ");
1674 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1676 when N_Enumeration_Representation_Clause
=>
1677 Write_Indent_Str_Sloc
("for ");
1678 Write_Id
(Identifier
(Node
));
1679 Write_Str_With_Col_Check
(" use ");
1680 Sprint_Node
(Array_Aggregate
(Node
));
1683 when N_Enumeration_Type_Definition
=>
1686 -- Skip attempt to print Literals field if it's not there and
1687 -- we are in package Standard (case of Character, which is
1688 -- handled specially (without an explicit literals list).
1690 if Sloc
(Node
) > Standard_Location
1691 or else Present
(Literals
(Node
))
1693 Sprint_Paren_Comma_List
(Literals
(Node
));
1697 Write_Str_With_Col_Check_Sloc
("<error>");
1699 when N_Exception_Declaration
=>
1700 if Write_Indent_Identifiers
(Node
) then
1701 Write_Str_With_Col_Check
(" : ");
1703 if Is_Statically_Allocated
(Defining_Identifier
(Node
)) then
1704 Write_Str_With_Col_Check
("static ");
1707 Write_Str_Sloc
("exception");
1709 if Present
(Expression
(Node
)) then
1711 Sprint_Node
(Expression
(Node
));
1717 when N_Exception_Handler
=>
1718 Write_Indent_Str_Sloc
("when ");
1720 if Present
(Choice_Parameter
(Node
)) then
1721 Sprint_Node
(Choice_Parameter
(Node
));
1725 Sprint_Bar_List
(Exception_Choices
(Node
));
1727 Sprint_Indented_List
(Statements
(Node
));
1729 when N_Exception_Renaming_Declaration
=>
1732 Sprint_Node
(Defining_Identifier
(Node
));
1733 Write_Str_With_Col_Check
(" : exception renames ");
1734 Sprint_Node
(Name
(Node
));
1737 when N_Exit_Statement
=>
1738 Write_Indent_Str_Sloc
("exit");
1739 Sprint_Opt_Node
(Name
(Node
));
1741 if Present
(Condition
(Node
)) then
1742 Write_Str_With_Col_Check
(" when ");
1743 Sprint_Node
(Condition
(Node
));
1748 when N_Expanded_Name
=>
1749 Sprint_Node
(Prefix
(Node
));
1750 Write_Char_Sloc
('.');
1751 Sprint_Node
(Selector_Name
(Node
));
1753 when N_Explicit_Dereference
=>
1754 Sprint_Node
(Prefix
(Node
));
1755 Write_Char_Sloc
('.');
1756 Write_Str_Sloc
("all");
1758 when N_Expression_With_Actions
=>
1760 Write_Indent_Str_Sloc
("do ");
1762 Sprint_Node_List
(Actions
(Node
));
1765 Write_Str_With_Col_Check_Sloc
("in ");
1766 Sprint_Node
(Expression
(Node
));
1767 Write_Str_With_Col_Check
(" end");
1771 when N_Expression_Function
=>
1773 Sprint_Node_Sloc
(Specification
(Node
));
1777 Sprint_Node
(Expression
(Node
));
1781 when N_Extended_Return_Statement
=>
1782 Write_Indent_Str_Sloc
("return ");
1783 Sprint_Node_List
(Return_Object_Declarations
(Node
));
1785 if Present
(Handled_Statement_Sequence
(Node
)) then
1786 Write_Str_With_Col_Check
(" do");
1787 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1788 Write_Indent_Str
("end return;");
1790 Write_Indent_Str
(";");
1793 when N_Delta_Aggregate
=>
1794 Write_Str_With_Col_Check_Sloc
("(");
1795 Sprint_Node
(Expression
(Node
));
1796 Write_Str_With_Col_Check
(" with delta ");
1797 Sprint_Comma_List
(Component_Associations
(Node
));
1800 when N_Extension_Aggregate
=>
1801 Write_Str_With_Col_Check_Sloc
("(");
1802 Sprint_Node
(Ancestor_Part
(Node
));
1803 Write_Str_With_Col_Check
(" with ");
1805 if Null_Record_Present
(Node
) then
1806 Write_Str_With_Col_Check
("null record");
1808 if Present
(Expressions
(Node
)) then
1809 Sprint_Comma_List
(Expressions
(Node
));
1811 if Present
(Component_Associations
(Node
)) then
1816 if Present
(Component_Associations
(Node
)) then
1817 Sprint_Comma_List
(Component_Associations
(Node
));
1823 when N_Floating_Point_Definition
=>
1824 Write_Str_With_Col_Check_Sloc
("digits ");
1825 Sprint_Node
(Digits_Expression
(Node
));
1826 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1828 when N_Formal_Decimal_Fixed_Point_Definition
=>
1829 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1831 when N_Formal_Derived_Type_Definition
=>
1832 Write_Str_With_Col_Check_Sloc
("new ");
1833 Sprint_Node
(Subtype_Mark
(Node
));
1835 if Present
(Interface_List
(Node
)) then
1836 Write_Str_With_Col_Check
(" and ");
1837 Sprint_And_List
(Interface_List
(Node
));
1840 if Private_Present
(Node
) then
1841 Write_Str_With_Col_Check
(" with private");
1844 when N_Formal_Abstract_Subprogram_Declaration
=>
1845 Write_Indent_Str_Sloc
("with ");
1846 Sprint_Node
(Specification
(Node
));
1848 Write_Str_With_Col_Check
(" is abstract");
1850 if Box_Present
(Node
) then
1851 Write_Str_With_Col_Check
(" <>");
1852 elsif Present
(Default_Name
(Node
)) then
1853 Write_Str_With_Col_Check
(" ");
1854 Sprint_Node
(Default_Name
(Node
));
1859 when N_Formal_Concrete_Subprogram_Declaration
=>
1860 Write_Indent_Str_Sloc
("with ");
1861 Sprint_Node
(Specification
(Node
));
1863 if Box_Present
(Node
) then
1864 Write_Str_With_Col_Check
(" is <>");
1865 elsif Present
(Default_Name
(Node
)) then
1866 Write_Str_With_Col_Check
(" is ");
1867 Sprint_Node
(Default_Name
(Node
));
1872 when N_Formal_Discrete_Type_Definition
=>
1873 Write_Str_With_Col_Check_Sloc
("<>");
1875 when N_Formal_Floating_Point_Definition
=>
1876 Write_Str_With_Col_Check_Sloc
("digits <>");
1878 when N_Formal_Modular_Type_Definition
=>
1879 Write_Str_With_Col_Check_Sloc
("mod <>");
1881 when N_Formal_Object_Declaration
=>
1884 if Write_Indent_Identifiers
(Node
) then
1887 if In_Present
(Node
) then
1888 Write_Str_With_Col_Check
("in ");
1891 if Out_Present
(Node
) then
1892 Write_Str_With_Col_Check
("out ");
1895 if Present
(Subtype_Mark
(Node
)) then
1897 -- Ada 2005 (AI-423): Formal object with null exclusion
1899 if Null_Exclusion_Present
(Node
) then
1900 Write_Str
("not null ");
1903 Sprint_Node
(Subtype_Mark
(Node
));
1905 -- Ada 2005 (AI-423): Formal object with access definition
1908 pragma Assert
(Present
(Access_Definition
(Node
)));
1910 Sprint_Node
(Access_Definition
(Node
));
1913 if Present
(Default_Expression
(Node
)) then
1915 Sprint_Node
(Default_Expression
(Node
));
1921 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1922 Write_Str_With_Col_Check_Sloc
("delta <>");
1924 when N_Formal_Package_Declaration
=>
1925 Write_Indent_Str_Sloc
("with package ");
1926 Write_Id
(Defining_Identifier
(Node
));
1927 Write_Str_With_Col_Check
(" is new ");
1928 Sprint_Node
(Name
(Node
));
1929 Write_Str_With_Col_Check
(" (<>);");
1931 when N_Formal_Private_Type_Definition
=>
1932 if Abstract_Present
(Node
) then
1933 Write_Str_With_Col_Check
("abstract ");
1936 if Tagged_Present
(Node
) then
1937 Write_Str_With_Col_Check
("tagged ");
1940 if Limited_Present
(Node
) then
1941 Write_Str_With_Col_Check
("limited ");
1944 Write_Str_With_Col_Check_Sloc
("private");
1946 when N_Formal_Incomplete_Type_Definition
=>
1947 if Tagged_Present
(Node
) then
1948 Write_Str_With_Col_Check
("is tagged ");
1951 when N_Formal_Signed_Integer_Type_Definition
=>
1952 Write_Str_With_Col_Check_Sloc
("range <>");
1954 when N_Formal_Type_Declaration
=>
1955 Write_Indent_Str_Sloc
("type ");
1956 Write_Id
(Defining_Identifier
(Node
));
1958 if Present
(Discriminant_Specifications
(Node
)) then
1959 Write_Discr_Specs
(Node
);
1960 elsif Unknown_Discriminants_Present
(Node
) then
1961 Write_Str_With_Col_Check
("(<>)");
1964 if Nkind
(Formal_Type_Definition
(Node
)) /=
1965 N_Formal_Incomplete_Type_Definition
1967 Write_Str_With_Col_Check
(" is ");
1970 Sprint_Node
(Formal_Type_Definition
(Node
));
1973 when N_Free_Statement
=>
1974 Write_Indent_Str_Sloc
("free ");
1975 Sprint_Node
(Expression
(Node
));
1978 when N_Freeze_Entity
=>
1979 if Dump_Original_Only
then
1982 -- A freeze node is output if it has some effect (i.e. non-empty
1983 -- actions, or freeze node for an itype, which causes elaboration
1984 -- of the itype), and is also always output if Dump_Freeze_Null
1987 elsif Present
(Actions
(Node
))
1988 or else Is_Itype
(Entity
(Node
))
1989 or else Dump_Freeze_Null
1992 Write_Rewrite_Str
("<<<");
1993 Write_Str_With_Col_Check_Sloc
("freeze ");
1994 Write_Id
(Entity
(Node
));
1997 if No
(Actions
(Node
)) then
2001 -- Output freeze actions. We increment Freeze_Indent during
2002 -- this output to avoid generating extra blank lines before
2003 -- any procedures included in the freeze actions.
2005 Freeze_Indent
:= Freeze_Indent
+ 1;
2006 Sprint_Indented_List
(Actions
(Node
));
2007 Freeze_Indent
:= Freeze_Indent
- 1;
2008 Write_Indent_Str
("]");
2011 Write_Rewrite_Str
(">>>");
2014 when N_Freeze_Generic_Entity
=>
2015 if Dump_Original_Only
then
2020 Write_Str_With_Col_Check_Sloc
("freeze_generic ");
2021 Write_Id
(Entity
(Node
));
2024 when N_Full_Type_Declaration
=>
2025 Write_Indent_Str_Sloc
("type ");
2026 Sprint_Node
(Defining_Identifier
(Node
));
2027 Write_Discr_Specs
(Node
);
2028 Write_Str_With_Col_Check
(" is ");
2029 Sprint_Node
(Type_Definition
(Node
));
2032 when N_Function_Call
=>
2034 Write_Subprogram_Name
(Name
(Node
));
2035 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2037 when N_Function_Instantiation
=>
2038 Write_Indent_Str_Sloc
("function ");
2039 Sprint_Node
(Defining_Unit_Name
(Node
));
2040 Write_Str_With_Col_Check
(" is new ");
2041 Sprint_Node
(Name
(Node
));
2042 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2045 when N_Function_Specification
=>
2046 Write_Str_With_Col_Check_Sloc
("function ");
2047 Sprint_Node
(Defining_Unit_Name
(Node
));
2048 Write_Param_Specs
(Node
);
2049 Write_Str_With_Col_Check
(" return ");
2051 -- Ada 2005 (AI-231)
2053 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
2054 and then Null_Exclusion_Present
(Node
)
2056 Write_Str
(" not null ");
2059 Sprint_Node
(Result_Definition
(Node
));
2061 when N_Generic_Association
=>
2064 if Present
(Selector_Name
(Node
)) then
2065 Sprint_Node
(Selector_Name
(Node
));
2069 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
2071 when N_Generic_Function_Renaming_Declaration
=>
2072 Write_Indent_Str_Sloc
("generic function ");
2073 Sprint_Node
(Defining_Unit_Name
(Node
));
2074 Write_Str_With_Col_Check
(" renames ");
2075 Sprint_Node
(Name
(Node
));
2078 when N_Generic_Package_Declaration
=>
2080 Write_Indent_Str_Sloc
("generic ");
2081 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
2083 Sprint_Node
(Specification
(Node
));
2086 when N_Generic_Package_Renaming_Declaration
=>
2087 Write_Indent_Str_Sloc
("generic package ");
2088 Sprint_Node
(Defining_Unit_Name
(Node
));
2089 Write_Str_With_Col_Check
(" renames ");
2090 Sprint_Node
(Name
(Node
));
2093 when N_Generic_Procedure_Renaming_Declaration
=>
2094 Write_Indent_Str_Sloc
("generic procedure ");
2095 Sprint_Node
(Defining_Unit_Name
(Node
));
2096 Write_Str_With_Col_Check
(" renames ");
2097 Sprint_Node
(Name
(Node
));
2100 when N_Generic_Subprogram_Declaration
=>
2102 Write_Indent_Str_Sloc
("generic ");
2103 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
2105 Sprint_Node
(Specification
(Node
));
2108 when N_Goto_Statement
=>
2109 Write_Indent_Str_Sloc
("goto ");
2110 Sprint_Node
(Name
(Node
));
2113 if Nkind
(Next
(Node
)) = N_Label
then
2117 when N_Handled_Sequence_Of_Statements
=>
2119 Sprint_Indented_List
(Statements
(Node
));
2121 if Present
(Exception_Handlers
(Node
)) then
2122 Write_Indent_Str
("exception");
2124 Sprint_Node_List
(Exception_Handlers
(Node
));
2128 if Present
(At_End_Proc
(Node
)) then
2129 Write_Indent_Str
("at end");
2132 Sprint_Node
(At_End_Proc
(Node
));
2137 when N_Identifier
=>
2141 when N_If_Expression
=>
2143 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
2144 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
2145 Then_Expr
: constant Node_Id
:= Next
(Condition
);
2148 -- The syntax for if_expression does not include parentheses,
2149 -- but sometimes parentheses are required, so unconditionally
2150 -- generate them here unless already present.
2152 if not Has_Parens
then
2156 Write_Str_With_Col_Check_Sloc
("if ");
2157 Sprint_Node
(Condition
);
2158 Write_Str_With_Col_Check
(" then ");
2160 -- Defense against junk here
2162 if Present
(Then_Expr
) then
2163 Sprint_Node
(Then_Expr
);
2165 if Present
(Next
(Then_Expr
)) then
2166 Write_Str_With_Col_Check
(" else ");
2167 Sprint_Node
(Next
(Then_Expr
));
2171 if not Has_Parens
then
2176 when N_If_Statement
=>
2177 Write_Indent_Str_Sloc
("if ");
2178 Sprint_Node
(Condition
(Node
));
2179 Write_Str_With_Col_Check
(" then");
2180 Sprint_Indented_List
(Then_Statements
(Node
));
2181 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
2183 if Present
(Else_Statements
(Node
)) then
2184 Write_Indent_Str
("else");
2185 Sprint_Indented_List
(Else_Statements
(Node
));
2188 Write_Indent_Str
("end if;");
2190 when N_Implicit_Label_Declaration
=>
2191 if not Dump_Original_Only
then
2193 Write_Rewrite_Str
("<<<");
2195 Write_Id
(Defining_Identifier
(Node
));
2197 Write_Str_With_Col_Check
("label");
2198 Write_Rewrite_Str
(">>>");
2202 Sprint_Left_Opnd
(Node
);
2203 Write_Str_Sloc
(" in ");
2205 if Present
(Right_Opnd
(Node
)) then
2206 Sprint_Right_Opnd
(Node
);
2208 Sprint_Bar_List
(Alternatives
(Node
));
2211 when N_Incomplete_Type_Declaration
=>
2212 Write_Indent_Str_Sloc
("type ");
2213 Write_Id
(Defining_Identifier
(Node
));
2215 if Present
(Discriminant_Specifications
(Node
)) then
2216 Write_Discr_Specs
(Node
);
2217 elsif Unknown_Discriminants_Present
(Node
) then
2218 Write_Str_With_Col_Check
("(<>)");
2223 when N_Index_Or_Discriminant_Constraint
=>
2225 Sprint_Paren_Comma_List
(Constraints
(Node
));
2227 when N_Indexed_Component
=>
2228 Sprint_Node_Sloc
(Prefix
(Node
));
2229 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
2231 when N_Integer_Literal
=>
2232 if Print_In_Hex
(Node
) then
2233 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
2235 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
2238 when N_Iteration_Scheme
=>
2239 if Present
(Condition
(Node
)) then
2240 Write_Str_With_Col_Check_Sloc
("while ");
2241 Sprint_Node
(Condition
(Node
));
2243 Write_Str_With_Col_Check_Sloc
("for ");
2245 if Present
(Iterator_Specification
(Node
)) then
2246 Sprint_Node
(Iterator_Specification
(Node
));
2248 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2254 when N_Iterator_Specification
=>
2256 Write_Id
(Defining_Identifier
(Node
));
2258 if Present
(Subtype_Indication
(Node
)) then
2259 Write_Str_With_Col_Check
(" : ");
2260 Sprint_Node
(Subtype_Indication
(Node
));
2263 if Of_Present
(Node
) then
2264 Write_Str_With_Col_Check
(" of ");
2266 Write_Str_With_Col_Check
(" in ");
2269 if Reverse_Present
(Node
) then
2270 Write_Str_With_Col_Check
("reverse ");
2273 Sprint_Node
(Name
(Node
));
2275 when N_Itype_Reference
=>
2276 Write_Indent_Str_Sloc
("reference ");
2277 Write_Id
(Itype
(Node
));
2280 Write_Indent_Str_Sloc
("<<");
2281 Write_Id
(Identifier
(Node
));
2284 when N_Loop_Parameter_Specification
=>
2286 Write_Id
(Defining_Identifier
(Node
));
2287 Write_Str_With_Col_Check
(" in ");
2289 if Reverse_Present
(Node
) then
2290 Write_Str_With_Col_Check
("reverse ");
2293 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
2295 when N_Loop_Statement
=>
2298 if Present
(Identifier
(Node
))
2299 and then (not Has_Created_Identifier
(Node
)
2300 or else not Dump_Original_Only
)
2302 Write_Rewrite_Str
("<<<");
2303 Write_Id
(Identifier
(Node
));
2305 Write_Rewrite_Str
(">>>");
2306 Sprint_Node
(Iteration_Scheme
(Node
));
2307 Write_Str_With_Col_Check_Sloc
("loop");
2308 Sprint_Indented_List
(Statements
(Node
));
2309 Write_Indent_Str
("end loop ");
2310 Write_Rewrite_Str
("<<<");
2311 Write_Id
(Identifier
(Node
));
2312 Write_Rewrite_Str
(">>>");
2316 Sprint_Node
(Iteration_Scheme
(Node
));
2317 Write_Str_With_Col_Check_Sloc
("loop");
2318 Sprint_Indented_List
(Statements
(Node
));
2319 Write_Indent_Str
("end loop;");
2322 when N_Mod_Clause
=>
2323 Sprint_Node_List
(Pragmas_Before
(Node
));
2324 Write_Str_With_Col_Check_Sloc
("at mod ");
2325 Sprint_Node
(Expression
(Node
));
2327 when N_Modular_Type_Definition
=>
2328 Write_Str_With_Col_Check_Sloc
("mod ");
2329 Sprint_Node
(Expression
(Node
));
2332 Sprint_Left_Opnd
(Node
);
2333 Write_Str_Sloc
(" not in ");
2335 if Present
(Right_Opnd
(Node
)) then
2336 Sprint_Right_Opnd
(Node
);
2338 Sprint_Bar_List
(Alternatives
(Node
));
2342 Write_Str_With_Col_Check_Sloc
("null");
2344 when N_Null_Statement
=>
2345 if Comes_From_Source
(Node
)
2346 or else Dump_Freeze_Null
2347 or else not Is_List_Member
(Node
)
2348 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
2350 Write_Indent_Str_Sloc
("null;");
2353 when N_Number_Declaration
=>
2356 if Write_Indent_Identifiers
(Node
) then
2357 Write_Str_With_Col_Check
(" : constant ");
2359 Sprint_Node
(Expression
(Node
));
2363 when N_Object_Declaration
=>
2366 if Write_Indent_Identifiers
(Node
) then
2368 Def_Id
: constant Entity_Id
:= Defining_Identifier
(Node
);
2371 Write_Str_With_Col_Check
(" : ");
2373 if Is_Statically_Allocated
(Def_Id
) then
2374 Write_Str_With_Col_Check
("static ");
2377 if Aliased_Present
(Node
) then
2378 Write_Str_With_Col_Check
("aliased ");
2381 if Constant_Present
(Node
) then
2382 Write_Str_With_Col_Check
("constant ");
2385 -- Ada 2005 (AI-231)
2387 if Null_Exclusion_Present
(Node
) then
2388 Write_Str_With_Col_Check
("not null ");
2391 -- Print type. We used to print the Object_Definition from
2392 -- the node, but it is much more useful to print the Etype
2393 -- of the defining identifier for the case where the nominal
2394 -- type is an unconstrained array type. For example, this
2395 -- will be a clear reference to the Itype with the bounds
2396 -- in the case of a type like String. The object after
2397 -- all is constrained, even if its nominal subtype is
2401 Odef
: constant Node_Id
:= Object_Definition
(Node
);
2404 if Nkind
(Odef
) = N_Identifier
2405 and then Present
(Etype
(Odef
))
2406 and then Is_Array_Type
(Etype
(Odef
))
2407 and then not Is_Constrained
(Etype
(Odef
))
2408 and then Present
(Etype
(Def_Id
))
2410 Sprint_Node
(Etype
(Def_Id
));
2412 -- In other cases, the nominal type is fine to print
2419 if Present
(Expression
(Node
))
2420 and then Expression
(Node
) /= Error
2421 and then not No_Initialization
(Node
)
2424 Sprint_Node
(Expression
(Node
));
2429 -- Handle implicit importation and implicit exportation of
2430 -- object declarations:
2431 -- $pragma import (Convention_Id, Def_Id, "...");
2432 -- $pragma export (Convention_Id, Def_Id, "...");
2434 if Is_Internal
(Def_Id
)
2435 and then Present
(Interface_Name
(Def_Id
))
2437 Write_Indent_Str_Sloc
("$pragma ");
2439 if Is_Imported
(Def_Id
) then
2440 Write_Str
("import (");
2442 else pragma Assert
(Is_Exported
(Def_Id
));
2443 Write_Str
("export (");
2447 Prefix
: constant String := "Convention_";
2448 S
: constant String := Convention
(Def_Id
)'Img;
2451 Name_Len
:= S
'Last - Prefix
'Last;
2452 Name_Buffer
(1 .. Name_Len
) :=
2453 S
(Prefix
'Last + 1 .. S
'Last);
2454 Set_Casing
(All_Lower_Case
);
2455 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2461 Write_String_Table_Entry
2462 (Strval
(Interface_Name
(Def_Id
)));
2468 when N_Object_Renaming_Declaration
=>
2471 Sprint_Node
(Defining_Identifier
(Node
));
2473 -- Ada 2005 (AI-230): Access renamings
2475 if Present
(Access_Definition
(Node
)) then
2477 Sprint_Node
(Access_Definition
(Node
));
2479 elsif Present
(Subtype_Mark
(Node
)) then
2482 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2484 if Null_Exclusion_Present
(Node
) then
2485 Write_Str
("not null ");
2488 Sprint_Node
(Subtype_Mark
(Node
));
2490 -- AI12-0275: Object_Renaming_Declaration without explicit subtype
2492 elsif Ada_Version
>= Ada_2020
then
2496 Write_Str
(" : ??? ");
2499 Write_Str_With_Col_Check
(" renames ");
2500 Sprint_Node
(Name
(Node
));
2504 Write_Operator
(Node
, "abs ");
2505 Sprint_Right_Opnd
(Node
);
2508 Sprint_Left_Opnd
(Node
);
2509 Write_Operator
(Node
, " + ");
2510 Sprint_Right_Opnd
(Node
);
2513 Sprint_Left_Opnd
(Node
);
2514 Write_Operator
(Node
, " and ");
2515 Sprint_Right_Opnd
(Node
);
2518 Sprint_Left_Opnd
(Node
);
2519 Write_Operator
(Node
, " & ");
2520 Sprint_Right_Opnd
(Node
);
2523 Sprint_Left_Opnd
(Node
);
2525 if Rounded_Result
(Node
) then
2528 Write_Operator
(Node
, "/ ");
2529 Sprint_Right_Opnd
(Node
);
2532 Sprint_Left_Opnd
(Node
);
2533 Write_Operator
(Node
, " = ");
2534 Sprint_Right_Opnd
(Node
);
2537 Sprint_Left_Opnd
(Node
);
2538 Write_Operator
(Node
, " ** ");
2539 Sprint_Right_Opnd
(Node
);
2542 Sprint_Left_Opnd
(Node
);
2543 Write_Operator
(Node
, " >= ");
2544 Sprint_Right_Opnd
(Node
);
2547 Sprint_Left_Opnd
(Node
);
2548 Write_Operator
(Node
, " > ");
2549 Sprint_Right_Opnd
(Node
);
2552 Sprint_Left_Opnd
(Node
);
2553 Write_Operator
(Node
, " <= ");
2554 Sprint_Right_Opnd
(Node
);
2557 Sprint_Left_Opnd
(Node
);
2558 Write_Operator
(Node
, " < ");
2559 Sprint_Right_Opnd
(Node
);
2562 Write_Operator
(Node
, "-");
2563 Sprint_Right_Opnd
(Node
);
2566 Sprint_Left_Opnd
(Node
);
2567 Write_Operator
(Node
, " mod ");
2568 Sprint_Right_Opnd
(Node
);
2570 when N_Op_Multiply
=>
2571 Sprint_Left_Opnd
(Node
);
2573 if Rounded_Result
(Node
) then
2576 Write_Operator
(Node
, "* ");
2577 Sprint_Right_Opnd
(Node
);
2580 Sprint_Left_Opnd
(Node
);
2581 Write_Operator
(Node
, " /= ");
2582 Sprint_Right_Opnd
(Node
);
2585 Write_Operator
(Node
, "not ");
2586 Sprint_Right_Opnd
(Node
);
2589 Sprint_Left_Opnd
(Node
);
2590 Write_Operator
(Node
, " or ");
2591 Sprint_Right_Opnd
(Node
);
2594 Write_Operator
(Node
, "+");
2595 Sprint_Right_Opnd
(Node
);
2598 Sprint_Left_Opnd
(Node
);
2599 Write_Operator
(Node
, " rem ");
2600 Sprint_Right_Opnd
(Node
);
2606 Write_Str_With_Col_Check
("(");
2607 Sprint_Node
(Left_Opnd
(Node
));
2609 Sprint_Node
(Right_Opnd
(Node
));
2612 when N_Op_Subtract
=>
2613 Sprint_Left_Opnd
(Node
);
2614 Write_Operator
(Node
, " - ");
2615 Sprint_Right_Opnd
(Node
);
2618 Sprint_Left_Opnd
(Node
);
2619 Write_Operator
(Node
, " xor ");
2620 Sprint_Right_Opnd
(Node
);
2622 when N_Operator_Symbol
=>
2623 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
2625 when N_Ordinary_Fixed_Point_Definition
=>
2626 Write_Str_With_Col_Check_Sloc
("delta ");
2627 Sprint_Node
(Delta_Expression
(Node
));
2628 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
2631 Sprint_Left_Opnd
(Node
);
2632 Write_Str_Sloc
(" or else ");
2633 Sprint_Right_Opnd
(Node
);
2635 when N_Others_Choice
=>
2636 if All_Others
(Node
) then
2637 Write_Str_With_Col_Check
("all ");
2640 Write_Str_With_Col_Check_Sloc
("others");
2642 when N_Package_Body
=>
2644 Write_Indent_Str_Sloc
("package body ");
2645 Sprint_Node
(Defining_Unit_Name
(Node
));
2647 Sprint_Indented_List
(Declarations
(Node
));
2649 if Present
(Handled_Statement_Sequence
(Node
)) then
2650 Write_Indent_Str
("begin");
2651 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2654 Write_Indent_Str
("end ");
2656 (Handled_Statement_Sequence
(Node
), Defining_Unit_Name
(Node
));
2659 when N_Package_Body_Stub
=>
2660 Write_Indent_Str_Sloc
("package body ");
2661 Sprint_Node
(Defining_Identifier
(Node
));
2662 Write_Str_With_Col_Check
(" is separate;");
2664 when N_Package_Declaration
=>
2667 Sprint_Node_Sloc
(Specification
(Node
));
2670 -- If this is an instantiation, get the aspects from the original
2671 -- instantiation node.
2673 if Is_Generic_Instance
(Defining_Entity
(Node
))
2674 and then Has_Aspects
2675 (Package_Instantiation
(Defining_Entity
(Node
)))
2677 Sprint_Aspect_Specifications
2678 (Package_Instantiation
(Defining_Entity
(Node
)),
2682 when N_Package_Instantiation
=>
2684 Write_Indent_Str_Sloc
("package ");
2685 Sprint_Node
(Defining_Unit_Name
(Node
));
2686 Write_Str
(" is new ");
2687 Sprint_Node
(Name
(Node
));
2688 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2691 when N_Package_Renaming_Declaration
=>
2692 Write_Indent_Str_Sloc
("package ");
2693 Sprint_Node
(Defining_Unit_Name
(Node
));
2694 Write_Str_With_Col_Check
(" renames ");
2695 Sprint_Node
(Name
(Node
));
2698 when N_Package_Specification
=>
2699 Write_Str_With_Col_Check_Sloc
("package ");
2700 Sprint_Node
(Defining_Unit_Name
(Node
));
2702 if Nkind
(Parent
(Node
)) = N_Generic_Package_Declaration
2703 and then Has_Aspects
(Parent
(Node
))
2705 Sprint_Aspect_Specifications
2706 (Parent
(Node
), Semicolon
=> False);
2708 -- An instantiation is rewritten as a package declaration, but
2709 -- the aspects belong to the instantiation node.
2711 elsif Nkind
(Parent
(Node
)) = N_Package_Declaration
then
2713 Pack
: constant Entity_Id
:= Defining_Entity
(Node
);
2716 if not Is_Generic_Instance
(Pack
) then
2717 if Has_Aspects
(Parent
(Node
)) then
2718 Sprint_Aspect_Specifications
2719 (Parent
(Node
), Semicolon
=> False);
2726 Sprint_Indented_List
(Visible_Declarations
(Node
));
2728 if Present
(Private_Declarations
(Node
)) then
2729 Write_Indent_Str
("private");
2730 Sprint_Indented_List
(Private_Declarations
(Node
));
2733 Write_Indent_Str
("end ");
2734 Sprint_Node
(Defining_Unit_Name
(Node
));
2736 when N_Parameter_Association
=>
2737 Sprint_Node_Sloc
(Selector_Name
(Node
));
2739 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2741 when N_Parameter_Specification
=>
2744 if Write_Identifiers
(Node
) then
2747 if In_Present
(Node
) then
2748 Write_Str_With_Col_Check
("in ");
2751 if Out_Present
(Node
) then
2752 Write_Str_With_Col_Check
("out ");
2755 -- Ada 2005 (AI-231): Parameter specification may carry null
2756 -- exclusion. Do not print it now if this is an access formal,
2757 -- it is emitted when the access definition is displayed.
2759 if Null_Exclusion_Present
(Node
)
2760 and then Nkind
(Parameter_Type
(Node
)) /= N_Access_Definition
2762 Write_Str
("not null ");
2765 if Aliased_Present
(Node
) then
2766 Write_Str
("aliased ");
2769 Sprint_Node
(Parameter_Type
(Node
));
2771 if Present
(Expression
(Node
)) then
2773 Sprint_Node
(Expression
(Node
));
2779 when N_Pop_Constraint_Error_Label
=>
2780 Write_Indent_Str
("%pop_constraint_error_label");
2782 when N_Pop_Program_Error_Label
=>
2783 Write_Indent_Str
("%pop_program_error_label");
2785 when N_Pop_Storage_Error_Label
=>
2786 Write_Indent_Str
("%pop_storage_error_label");
2788 when N_Private_Extension_Declaration
=>
2789 Write_Indent_Str_Sloc
("type ");
2790 Write_Id
(Defining_Identifier
(Node
));
2792 if Present
(Discriminant_Specifications
(Node
)) then
2793 Write_Discr_Specs
(Node
);
2794 elsif Unknown_Discriminants_Present
(Node
) then
2795 Write_Str_With_Col_Check
("(<>)");
2798 Write_Str_With_Col_Check
(" is new ");
2799 Sprint_Node
(Subtype_Indication
(Node
));
2801 if Present
(Interface_List
(Node
)) then
2802 Write_Str_With_Col_Check
(" and ");
2803 Sprint_And_List
(Interface_List
(Node
));
2806 Write_Str_With_Col_Check
(" with private;");
2808 when N_Private_Type_Declaration
=>
2809 Write_Indent_Str_Sloc
("type ");
2810 Write_Id
(Defining_Identifier
(Node
));
2812 if Present
(Discriminant_Specifications
(Node
)) then
2813 Write_Discr_Specs
(Node
);
2814 elsif Unknown_Discriminants_Present
(Node
) then
2815 Write_Str_With_Col_Check
("(<>)");
2820 if Tagged_Present
(Node
) then
2821 Write_Str_With_Col_Check
("tagged ");
2824 if Limited_Present
(Node
) then
2825 Write_Str_With_Col_Check
("limited ");
2828 Write_Str_With_Col_Check
("private;");
2830 when N_Push_Constraint_Error_Label
=>
2831 Write_Indent_Str
("%push_constraint_error_label (");
2833 if Present
(Exception_Label
(Node
)) then
2834 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2839 when N_Push_Program_Error_Label
=>
2840 Write_Indent_Str
("%push_program_error_label (");
2842 if Present
(Exception_Label
(Node
)) then
2843 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2848 when N_Push_Storage_Error_Label
=>
2849 Write_Indent_Str
("%push_storage_error_label (");
2851 if Present
(Exception_Label
(Node
)) then
2852 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2858 Write_Indent_Str_Sloc
("pragma ");
2859 Write_Name_With_Col_Check
(Pragma_Name_Unmapped
(Node
));
2861 if Present
(Pragma_Argument_Associations
(Node
)) then
2862 Sprint_Opt_Paren_Comma_List
2863 (Pragma_Argument_Associations
(Node
));
2868 when N_Pragma_Argument_Association
=>
2871 if Chars
(Node
) /= No_Name
then
2872 Write_Name_With_Col_Check
(Chars
(Node
));
2876 Sprint_Node
(Expression
(Node
));
2878 when N_Procedure_Call_Statement
=>
2881 Write_Subprogram_Name
(Name
(Node
));
2882 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2885 when N_Procedure_Instantiation
=>
2886 Write_Indent_Str_Sloc
("procedure ");
2887 Sprint_Node
(Defining_Unit_Name
(Node
));
2888 Write_Str_With_Col_Check
(" is new ");
2889 Sprint_Node
(Name
(Node
));
2890 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2893 when N_Procedure_Specification
=>
2894 Write_Str_With_Col_Check_Sloc
("procedure ");
2895 Sprint_Node
(Defining_Unit_Name
(Node
));
2896 Write_Param_Specs
(Node
);
2898 when N_Protected_Body
=>
2899 Write_Indent_Str_Sloc
("protected body ");
2900 Write_Id
(Defining_Identifier
(Node
));
2902 Sprint_Indented_List
(Declarations
(Node
));
2903 Write_Indent_Str
("end ");
2904 Write_Id
(Defining_Identifier
(Node
));
2907 when N_Protected_Body_Stub
=>
2908 Write_Indent_Str_Sloc
("protected body ");
2909 Write_Id
(Defining_Identifier
(Node
));
2910 Write_Str_With_Col_Check
(" is separate;");
2912 when N_Protected_Definition
=>
2914 Sprint_Indented_List
(Visible_Declarations
(Node
));
2916 if Present
(Private_Declarations
(Node
)) then
2917 Write_Indent_Str
("private");
2918 Sprint_Indented_List
(Private_Declarations
(Node
));
2921 Write_Indent_Str
("end ");
2923 when N_Protected_Type_Declaration
=>
2924 Write_Indent_Str_Sloc
("protected type ");
2925 Sprint_Node
(Defining_Identifier
(Node
));
2926 Write_Discr_Specs
(Node
);
2928 if Present
(Interface_List
(Node
)) then
2929 Write_Str
(" is new ");
2930 Sprint_And_List
(Interface_List
(Node
));
2931 Write_Str
(" with ");
2936 Sprint_Node
(Protected_Definition
(Node
));
2937 Write_Id
(Defining_Identifier
(Node
));
2940 when N_Qualified_Expression
=>
2941 Sprint_Node
(Subtype_Mark
(Node
));
2942 Write_Char_Sloc
(''');
2944 -- Print expression, make sure we have at least one level of
2945 -- parentheses around the expression. For cases of qualified
2946 -- expressions in the source, this is always the case, but
2947 -- for generated qualifications, there may be no explicit
2948 -- parentheses present.
2950 if Paren_Count
(Expression
(Node
)) /= 0 then
2951 Sprint_Node
(Expression
(Node
));
2955 Sprint_Node
(Expression
(Node
));
2957 -- Odd case, for the qualified expressions used in machine
2958 -- code the argument may be a procedure call, resulting in
2959 -- a junk semicolon before the right parent, get rid of it.
2961 Write_Erase_Char
(';');
2963 -- Now we can add the terminating right paren
2968 when N_Quantified_Expression
=>
2971 if All_Present
(Node
) then
2972 Write_Str
(" all ");
2974 Write_Str
(" some ");
2977 if Present
(Iterator_Specification
(Node
)) then
2978 Sprint_Node
(Iterator_Specification
(Node
));
2980 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2984 Sprint_Node
(Condition
(Node
));
2986 when N_Raise_Expression
=>
2988 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
2991 -- The syntax for raise_expression does not include parentheses
2992 -- but sometimes parentheses are required, so unconditionally
2993 -- generate them here unless already present.
2995 if not Has_Parens
then
2999 Write_Str_With_Col_Check_Sloc
("raise ");
3000 Sprint_Node
(Name
(Node
));
3002 if Present
(Expression
(Node
)) then
3003 Write_Str_With_Col_Check
(" with ");
3004 Sprint_Node
(Expression
(Node
));
3007 if not Has_Parens
then
3012 when N_Raise_Constraint_Error
=>
3014 -- This node can be used either as a subexpression or as a
3015 -- statement form. The following test is a reasonably reliable
3016 -- way to distinguish the two cases.
3018 if Is_List_Member
(Node
)
3019 and then Nkind
(Parent
(Node
)) not in N_Subexpr
3024 Write_Str_With_Col_Check_Sloc
("[constraint_error");
3025 Write_Condition_And_Reason
(Node
);
3027 when N_Raise_Program_Error
=>
3029 -- This node can be used either as a subexpression or as a
3030 -- statement form. The following test is a reasonably reliable
3031 -- way to distinguish the two cases.
3033 if Is_List_Member
(Node
)
3034 and then Nkind
(Parent
(Node
)) not in N_Subexpr
3039 Write_Str_With_Col_Check_Sloc
("[program_error");
3040 Write_Condition_And_Reason
(Node
);
3042 when N_Raise_Storage_Error
=>
3044 -- This node can be used either as a subexpression or as a
3045 -- statement form. The following test is a reasonably reliable
3046 -- way to distinguish the two cases.
3048 if Is_List_Member
(Node
)
3049 and then Nkind
(Parent
(Node
)) not in N_Subexpr
3054 Write_Str_With_Col_Check_Sloc
("[storage_error");
3055 Write_Condition_And_Reason
(Node
);
3057 when N_Raise_Statement
=>
3058 Write_Indent_Str_Sloc
("raise ");
3059 Sprint_Node
(Name
(Node
));
3061 if Present
(Expression
(Node
)) then
3062 Write_Str_With_Col_Check_Sloc
(" with ");
3063 Sprint_Node
(Expression
(Node
));
3069 Sprint_Node
(Low_Bound
(Node
));
3070 Write_Str_Sloc
(" .. ");
3071 Sprint_Node
(High_Bound
(Node
));
3072 Update_Itype
(Node
);
3074 when N_Range_Constraint
=>
3075 Write_Str_With_Col_Check_Sloc
("range ");
3076 Sprint_Node
(Range_Expression
(Node
));
3078 when N_Real_Literal
=>
3079 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
3081 when N_Real_Range_Specification
=>
3082 Write_Str_With_Col_Check_Sloc
("range ");
3083 Sprint_Node
(Low_Bound
(Node
));
3085 Sprint_Node
(High_Bound
(Node
));
3087 when N_Record_Definition
=>
3088 if Abstract_Present
(Node
) then
3089 Write_Str_With_Col_Check
("abstract ");
3092 if Tagged_Present
(Node
) then
3093 Write_Str_With_Col_Check
("tagged ");
3096 if Limited_Present
(Node
) then
3097 Write_Str_With_Col_Check
("limited ");
3100 if Null_Present
(Node
) then
3101 Write_Str_With_Col_Check_Sloc
("null record");
3104 Write_Str_With_Col_Check_Sloc
("record");
3105 Sprint_Node
(Component_List
(Node
));
3106 Write_Indent_Str
("end record");
3109 when N_Record_Representation_Clause
=>
3110 Write_Indent_Str_Sloc
("for ");
3111 Sprint_Node
(Identifier
(Node
));
3112 Write_Str_With_Col_Check
(" use record ");
3114 if Present
(Mod_Clause
(Node
)) then
3115 Sprint_Node
(Mod_Clause
(Node
));
3118 Sprint_Indented_List
(Component_Clauses
(Node
));
3119 Write_Indent_Str
("end record;");
3122 Sprint_Node
(Prefix
(Node
));
3123 Write_Str_With_Col_Check_Sloc
("'reference");
3125 when N_Requeue_Statement
=>
3126 Write_Indent_Str_Sloc
("requeue ");
3127 Sprint_Node
(Name
(Node
));
3129 if Abort_Present
(Node
) then
3130 Write_Str_With_Col_Check
(" with abort");
3135 -- Don't we want to print more detail???
3137 -- Doc of this extended syntax belongs in sinfo.ads and/or
3140 when N_SCIL_Dispatch_Table_Tag_Init
=>
3141 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Tag_Init]");
3143 when N_SCIL_Dispatching_Call
=>
3144 Write_Indent_Str
("[N_SCIL_Dispatching_Node]");
3146 when N_SCIL_Membership_Test
=>
3147 Write_Indent_Str
("[N_SCIL_Membership_Test]");
3149 when N_Simple_Return_Statement
=>
3150 if Present
(Expression
(Node
)) then
3151 Write_Indent_Str_Sloc
("return ");
3152 Sprint_Node
(Expression
(Node
));
3155 Write_Indent_Str_Sloc
("return;");
3158 when N_Selective_Accept
=>
3159 Write_Indent_Str_Sloc
("select");
3164 Alt_Node
:= First
(Select_Alternatives
(Node
));
3167 Sprint_Node
(Alt_Node
);
3170 exit when No
(Alt_Node
);
3171 Write_Indent_Str
("or");
3175 if Present
(Else_Statements
(Node
)) then
3176 Write_Indent_Str
("else");
3177 Sprint_Indented_List
(Else_Statements
(Node
));
3180 Write_Indent_Str
("end select;");
3182 when N_Signed_Integer_Type_Definition
=>
3183 Write_Str_With_Col_Check_Sloc
("range ");
3184 Sprint_Node
(Low_Bound
(Node
));
3186 Sprint_Node
(High_Bound
(Node
));
3188 when N_Single_Protected_Declaration
=>
3189 Write_Indent_Str_Sloc
("protected ");
3190 Write_Id
(Defining_Identifier
(Node
));
3192 Sprint_Node
(Protected_Definition
(Node
));
3193 Write_Id
(Defining_Identifier
(Node
));
3196 when N_Single_Task_Declaration
=>
3197 Write_Indent_Str_Sloc
("task ");
3198 Sprint_Node
(Defining_Identifier
(Node
));
3200 if Present
(Task_Definition
(Node
)) then
3202 Sprint_Node
(Task_Definition
(Node
));
3207 when N_Selected_Component
=>
3208 Sprint_Node
(Prefix
(Node
));
3209 Write_Char_Sloc
('.');
3210 Sprint_Node
(Selector_Name
(Node
));
3214 Sprint_Node
(Prefix
(Node
));
3215 Write_Str_With_Col_Check
(" (");
3216 Sprint_Node
(Discrete_Range
(Node
));
3219 when N_String_Literal
=>
3220 if String_Length
(Strval
(Node
)) + Column
> Sprint_Line_Limit
then
3221 Write_Indent_Str
(" ");
3225 Write_String_Table_Entry
(Strval
(Node
));
3227 when N_Subprogram_Body
=>
3229 -- Output extra blank line unless we are in freeze actions
3231 if Freeze_Indent
= 0 then
3237 if Present
(Corresponding_Spec
(Node
)) then
3238 Sprint_Node_Sloc
(Parent
(Corresponding_Spec
(Node
)));
3240 Sprint_Node_Sloc
(Specification
(Node
));
3245 Sprint_Indented_List
(Declarations
(Node
));
3246 Write_Indent_Str
("begin");
3247 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3249 Write_Indent_Str
("end ");
3252 (Handled_Statement_Sequence
(Node
),
3253 Defining_Unit_Name
(Specification
(Node
)));
3256 if Is_List_Member
(Node
)
3257 and then Present
(Next
(Node
))
3258 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
3263 when N_Subprogram_Body_Stub
=>
3265 Sprint_Node_Sloc
(Specification
(Node
));
3266 Write_Str_With_Col_Check
(" is separate;");
3268 when N_Subprogram_Declaration
=>
3270 Sprint_Node_Sloc
(Specification
(Node
));
3272 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
3273 and then Null_Present
(Specification
(Node
))
3275 Write_Str_With_Col_Check
(" is null");
3280 when N_Subprogram_Renaming_Declaration
=>
3282 Sprint_Node
(Specification
(Node
));
3283 Write_Str_With_Col_Check_Sloc
(" renames ");
3284 Sprint_Node
(Name
(Node
));
3287 when N_Subtype_Declaration
=>
3288 Write_Indent_Str_Sloc
("subtype ");
3289 Sprint_Node
(Defining_Identifier
(Node
));
3292 -- Ada 2005 (AI-231)
3294 if Null_Exclusion_Present
(Node
) then
3295 Write_Str
("not null ");
3298 Sprint_Node
(Subtype_Indication
(Node
));
3301 when N_Subtype_Indication
=>
3302 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
3304 Sprint_Node
(Constraint
(Node
));
3307 Write_Indent_Str_Sloc
("separate (");
3308 Sprint_Node
(Name
(Node
));
3311 Sprint_Node
(Proper_Body
(Node
));
3313 when N_Target_Name
=>
3317 Write_Indent_Str_Sloc
("task body ");
3318 Write_Id
(Defining_Identifier
(Node
));
3320 Sprint_Indented_List
(Declarations
(Node
));
3321 Write_Indent_Str
("begin");
3322 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3323 Write_Indent_Str
("end ");
3325 (Handled_Statement_Sequence
(Node
), Defining_Identifier
(Node
));
3328 when N_Task_Body_Stub
=>
3329 Write_Indent_Str_Sloc
("task body ");
3330 Write_Id
(Defining_Identifier
(Node
));
3331 Write_Str_With_Col_Check
(" is separate;");
3333 when N_Task_Definition
=>
3335 Sprint_Indented_List
(Visible_Declarations
(Node
));
3337 if Present
(Private_Declarations
(Node
)) then
3338 Write_Indent_Str
("private");
3339 Sprint_Indented_List
(Private_Declarations
(Node
));
3342 Write_Indent_Str
("end ");
3343 Sprint_End_Label
(Node
, Defining_Identifier
(Parent
(Node
)));
3345 when N_Task_Type_Declaration
=>
3346 Write_Indent_Str_Sloc
("task type ");
3347 Sprint_Node
(Defining_Identifier
(Node
));
3348 Write_Discr_Specs
(Node
);
3350 if Present
(Interface_List
(Node
)) then
3351 Write_Str
(" is new ");
3352 Sprint_And_List
(Interface_List
(Node
));
3355 if Present
(Task_Definition
(Node
)) then
3356 if No
(Interface_List
(Node
)) then
3359 Write_Str
(" with ");
3362 Sprint_Node
(Task_Definition
(Node
));
3367 when N_Terminate_Alternative
=>
3368 Sprint_Node_List
(Pragmas_Before
(Node
));
3371 if Present
(Condition
(Node
)) then
3372 Write_Str_With_Col_Check
("when ");
3373 Sprint_Node
(Condition
(Node
));
3377 Write_Str_With_Col_Check_Sloc
("terminate;");
3378 Sprint_Node_List
(Pragmas_After
(Node
));
3380 when N_Timed_Entry_Call
=>
3381 Write_Indent_Str_Sloc
("select");
3383 Sprint_Node
(Entry_Call_Alternative
(Node
));
3385 Write_Indent_Str
("or");
3387 Sprint_Node
(Delay_Alternative
(Node
));
3389 Write_Indent_Str
("end select;");
3391 when N_Triggering_Alternative
=>
3392 Sprint_Node_List
(Pragmas_Before
(Node
));
3393 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
3394 Sprint_Node_List
(Statements
(Node
));
3396 when N_Type_Conversion
=>
3398 Sprint_Node
(Subtype_Mark
(Node
));
3401 if Conversion_OK
(Node
) then
3405 if Float_Truncate
(Node
) then
3409 if Rounded_Result
(Node
) then
3414 Sprint_Node
(Expression
(Node
));
3417 when N_Unchecked_Expression
=>
3420 Sprint_Node_Sloc
(Expression
(Node
));
3423 when N_Unchecked_Type_Conversion
=>
3424 Sprint_Node
(Subtype_Mark
(Node
));
3426 Write_Str_With_Col_Check
("(");
3427 Sprint_Node_Sloc
(Expression
(Node
));
3430 when N_Unconstrained_Array_Definition
=>
3431 Write_Str_With_Col_Check_Sloc
("array (");
3436 Node1
:= First
(Subtype_Marks
(Node
));
3438 Sprint_Node
(Node1
);
3439 Write_Str_With_Col_Check
(" range <>");
3441 exit when Node1
= Empty
;
3446 Write_Str
(") of ");
3447 Sprint_Node
(Component_Definition
(Node
));
3449 when N_Unused_At_Start | N_Unused_At_End
=>
3450 Write_Indent_Str
("***** Error, unused node encountered *****");
3453 when N_Use_Package_Clause
=>
3454 Write_Indent_Str_Sloc
("use ");
3455 Sprint_Node_Sloc
(Name
(Node
));
3458 when N_Use_Type_Clause
=>
3459 Write_Indent_Str_Sloc
("use type ");
3460 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
3463 when N_Validate_Unchecked_Conversion
=>
3464 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
3465 Sprint_Node
(Source_Type
(Node
));
3467 Sprint_Node
(Target_Type
(Node
));
3470 when N_Variable_Reference_Marker
=>
3473 -- Enable the following code for debugging purposes only
3475 -- if Is_Read (Node) and then Is_Write (Node) then
3476 -- Write_Indent_Str ("rw#");
3478 -- elsif Is_Read (Node) then
3479 -- Write_Indent_Str ("r#");
3482 -- pragma Assert (Is_Write (Node));
3483 -- Write_Indent_Str ("w#");
3486 -- Write_Id (Target (Node));
3487 -- Write_Char ('#');
3490 Write_Indent_Str_Sloc
("when ");
3491 Sprint_Bar_List
(Discrete_Choices
(Node
));
3493 Sprint_Node
(Component_List
(Node
));
3495 when N_Variant_Part
=>
3497 Write_Indent_Str_Sloc
("case ");
3498 Sprint_Node
(Name
(Node
));
3500 Sprint_Indented_List
(Variants
(Node
));
3501 Write_Indent_Str
("end case");
3504 when N_With_Clause
=>
3506 -- Special test, if we are dumping the original tree only,
3507 -- then we want to eliminate the bogus with clauses that
3508 -- correspond to the non-existent children of Text_IO.
3510 if Dump_Original_Only
3511 and then Is_Text_IO_Special_Unit
(Name
(Node
))
3515 -- Normal case, output the with clause
3518 if First_Name
(Node
) or else not Dump_Original_Only
then
3520 -- Ada 2005 (AI-50217): Print limited with_clauses
3522 if Private_Present
(Node
) and Limited_Present
(Node
) then
3523 Write_Indent_Str
("limited private with ");
3525 elsif Private_Present
(Node
) then
3526 Write_Indent_Str
("private with ");
3528 elsif Limited_Present
(Node
) then
3529 Write_Indent_Str
("limited with ");
3532 Write_Indent_Str
("with ");
3539 Sprint_Node_Sloc
(Name
(Node
));
3541 if Last_Name
(Node
) or else not Dump_Original_Only
then
3547 -- Print aspects, except for special case of package declaration,
3548 -- where the aspects are printed inside the package specification.
3550 if Has_Aspects
(Node
)
3551 and then Nkind
(Node
) not in
3552 N_Generic_Package_Declaration | N_Package_Declaration
3553 and then not Is_Empty_List
(Aspect_Specifications
(Node
))
3555 Sprint_Aspect_Specifications
(Node
, Semicolon
=> True);
3558 if Nkind
(Node
) in N_Subexpr
and then Do_Range_Check
(Node
) then
3562 for J
in 1 .. Paren_Count
(Node
) loop
3566 Dump_Node
:= Save_Dump_Node
;
3567 end Sprint_Node_Actual
;
3569 ----------------------
3570 -- Sprint_Node_List --
3571 ----------------------
3573 procedure Sprint_Node_List
(List
: List_Id
; New_Lines
: Boolean := False) is
3577 if Is_Non_Empty_List
(List
) then
3578 Node
:= First
(List
);
3583 exit when Node
= Empty
;
3587 if New_Lines
and then Column
/= 1 then
3590 end Sprint_Node_List
;
3592 ----------------------
3593 -- Sprint_Node_Sloc --
3594 ----------------------
3596 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
3600 if Debug_Generated_Code
and then Present
(Dump_Node
) then
3601 Set_Sloc
(Dump_Node
, Sloc
(Node
));
3604 end Sprint_Node_Sloc
;
3606 ---------------------
3607 -- Sprint_Opt_Node --
3608 ---------------------
3610 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
3612 if Present
(Node
) then
3616 end Sprint_Opt_Node
;
3618 --------------------------
3619 -- Sprint_Opt_Node_List --
3620 --------------------------
3622 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
3624 if Present
(List
) then
3625 Sprint_Node_List
(List
);
3627 end Sprint_Opt_Node_List
;
3629 ---------------------------------
3630 -- Sprint_Opt_Paren_Comma_List --
3631 ---------------------------------
3633 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
3635 if Is_Non_Empty_List
(List
) then
3637 Sprint_Paren_Comma_List
(List
);
3639 end Sprint_Opt_Paren_Comma_List
;
3641 -----------------------------
3642 -- Sprint_Paren_Comma_List --
3643 -----------------------------
3645 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
3647 Node_Exists
: Boolean := False;
3651 if Is_Non_Empty_List
(List
) then
3653 if Dump_Original_Only
then
3655 while Present
(N
) loop
3656 if not Is_Rewrite_Insertion
(N
) then
3657 Node_Exists
:= True;
3664 if not Node_Exists
then
3669 Write_Str_With_Col_Check
("(");
3670 Sprint_Comma_List
(List
);
3673 end Sprint_Paren_Comma_List
;
3675 ----------------------
3676 -- Sprint_Right_Opnd --
3677 ----------------------
3679 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
3680 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
3683 if Paren_Count
(Opnd
) /= 0
3684 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
3693 end Sprint_Right_Opnd
;
3699 procedure Update_Itype
(Node
: Node_Id
) is
3701 if Present
(Etype
(Node
))
3702 and then Is_Itype
(Etype
(Node
))
3703 and then Debug_Generated_Code
3705 Set_Sloc
(Etype
(Node
), Sloc
(Node
));
3709 ---------------------
3710 -- Write_Char_Sloc --
3711 ---------------------
3713 procedure Write_Char_Sloc
(C
: Character) is
3715 if Debug_Generated_Code
and then C
/= ' ' then
3720 end Write_Char_Sloc
;
3722 --------------------------------
3723 -- Write_Condition_And_Reason --
3724 --------------------------------
3726 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
3727 Cond
: constant Node_Id
:= Condition
(Node
);
3728 Image
: constant String := RT_Exception_Code
'Image
3729 (RT_Exception_Code
'Val
3730 (UI_To_Int
(Reason
(Node
))));
3733 if Present
(Cond
) then
3735 -- If condition is a single entity, or NOT with a single entity,
3736 -- output all on one line, since it will likely fit just fine.
3738 if Is_Entity_Name
(Cond
)
3739 or else (Nkind
(Cond
) = N_Op_Not
3740 and then Is_Entity_Name
(Right_Opnd
(Cond
)))
3742 Write_Str_With_Col_Check
(" when ");
3746 -- Otherwise for more complex condition, multiple lines
3749 Write_Str_With_Col_Check
(" when");
3750 Indent
:= Indent
+ 2;
3754 Indent
:= Indent
- 2;
3757 -- If no condition, just need a space (all on one line)
3767 for J
in 4 .. Image
'Last loop
3768 if Image
(J
) = '_' then
3771 Write_Char
(Fold_Lower
(Image
(J
)));
3776 end Write_Condition_And_Reason
;
3778 --------------------------------
3779 -- Write_Corresponding_Source --
3780 --------------------------------
3782 procedure Write_Corresponding_Source
(S
: String) is
3784 Src
: Source_Buffer_Ptr
;
3787 -- Ignore if there is no current source file, or we're not in dump
3788 -- source text mode, or if in freeze actions.
3790 if Current_Source_File
> No_Source_File
3791 and then Dump_Source_Text
3792 and then Freeze_Indent
= 0
3795 -- Ignore null string
3801 -- Ignore space or semicolon at end of given string
3803 if S
(S
'Last) = ' ' or else S
(S
'Last) = ';' then
3804 Write_Corresponding_Source
(S
(S
'First .. S
'Last - 1));
3808 -- Loop to look at next lines not yet printed in source file
3811 Last_Line_Printed
+ 1 .. Last_Source_Line
(Current_Source_File
)
3813 Src
:= Source_Text
(Current_Source_File
);
3814 Loc
:= Line_Start
(L
, Current_Source_File
);
3816 -- If comment, keep looking
3818 if Src
(Loc
.. Loc
+ 1) = "--" then
3821 -- Search to first non-blank
3824 while Src
(Loc
) not in Line_Terminator
loop
3828 if Src
(Loc
) /= ' ' and then Src
(Loc
) /= ASCII
.HT
then
3830 -- Loop through characters in string to see if we match
3832 for J
in S
'Range loop
3834 -- If mismatch, then not the case we are looking for
3836 if Src
(Loc
) /= S
(J
) then
3843 -- If we fall through, string matched, if white space or
3844 -- semicolon after the matched string, this is the case
3845 -- we are looking for.
3847 if Src
(Loc
) in Line_Terminator
3848 or else Src
(Loc
) = ' '
3849 or else Src
(Loc
) = ASCII
.HT
3850 or else Src
(Loc
) = ';'
3852 -- So output source lines up to and including this one
3854 Write_Source_Lines
(L
);
3863 -- Line was all blanks, or a comment line, keep looking
3867 end Write_Corresponding_Source
;
3869 -----------------------
3870 -- Write_Discr_Specs --
3871 -----------------------
3873 procedure Write_Discr_Specs
(N
: Node_Id
) is
3878 Specs
:= Discriminant_Specifications
(N
);
3880 if Present
(Specs
) then
3881 Write_Str_With_Col_Check
(" (");
3882 Spec
:= First
(Specs
);
3887 exit when Spec
= Empty
;
3889 -- Add semicolon, unless we are printing original tree and the
3890 -- next specification is part of a list (but not the first
3891 -- element of that list)
3893 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3900 end Write_Discr_Specs
;
3906 procedure Write_Ekind
(E
: Entity_Id
) is
3907 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
3910 Name_Len
:= S
'Length;
3911 Name_Buffer
(1 .. Name_Len
) := S
;
3912 Set_Casing
(Mixed_Case
);
3913 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3920 procedure Write_Id
(N
: Node_Id
) is
3922 -- Deal with outputting Itype
3924 -- Note: if we are printing the full tree with -gnatds, then we may
3925 -- end up picking up the Associated_Node link from a generic template
3926 -- here which overlaps the Entity field, but as documented, Write_Itype
3927 -- is defended against junk calls.
3929 if Nkind
(N
) in N_Entity
then
3931 elsif Nkind
(N
) in N_Has_Entity
then
3932 Write_Itype
(Entity
(N
));
3935 -- Case of a defining identifier
3937 if Nkind
(N
) = N_Defining_Identifier
then
3939 -- If defining identifier has an interface name (and no
3940 -- address clause), then we output the interface name.
3942 if (Is_Imported
(N
) or else Is_Exported
(N
))
3943 and then Present
(Interface_Name
(N
))
3944 and then No
(Address_Clause
(N
))
3946 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
3947 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3949 -- If no interface name (or inactive because there was
3950 -- an address clause), then just output the Chars name.
3953 Write_Name_With_Col_Check
(Chars
(N
));
3956 -- Case of selector of an expanded name where the expanded name
3957 -- has an associated entity, output this entity. Check that the
3958 -- entity or associated node is of the right kind, see above.
3960 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
3961 and then Selector_Name
(Parent
(N
)) = N
3962 and then Present
(Entity_Or_Associated_Node
(Parent
(N
)))
3963 and then Nkind
(Entity
(Parent
(N
))) in N_Entity
3965 Write_Id
(Entity
(Parent
(N
)));
3967 -- For any other node with an associated entity, output it
3969 elsif Nkind
(N
) in N_Has_Entity
3970 and then Present
(Entity_Or_Associated_Node
(N
))
3971 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
3973 Write_Id
(Entity
(N
));
3975 -- All other cases, we just print the Chars field
3978 Write_Name_With_Col_Check
(Chars
(N
));
3982 -----------------------
3983 -- Write_Identifiers --
3984 -----------------------
3986 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
3988 Sprint_Node
(Defining_Identifier
(Node
));
3989 Update_Itype
(Defining_Identifier
(Node
));
3991 -- The remainder of the declaration must be printed unless we are
3992 -- printing the original tree and this is not the last identifier
3995 not Dump_Original_Only
or else not More_Ids
(Node
);
3997 end Write_Identifiers
;
3999 ------------------------
4000 -- Write_Implicit_Def --
4001 ------------------------
4003 procedure Write_Implicit_Def
(E
: Entity_Id
) is
4008 when E_Array_Subtype
=>
4009 Write_Str_With_Col_Check
("subtype ");
4011 Write_Str_With_Col_Check
(" is ");
4012 Write_Id
(Base_Type
(E
));
4013 Write_Str_With_Col_Check
(" (");
4015 Ind
:= First_Index
(E
);
4016 while Present
(Ind
) loop
4020 if Present
(Ind
) then
4027 when E_Enumeration_Subtype
4028 | E_Signed_Integer_Subtype
4030 Write_Str_With_Col_Check
("subtype ");
4033 Write_Id
(Etype
(E
));
4034 Write_Str_With_Col_Check
(" range ");
4035 Sprint_Node
(Scalar_Range
(E
));
4039 Write_Str_With_Col_Check
("type ");
4041 Write_Str_With_Col_Check
(" is <");
4045 end Write_Implicit_Def
;
4051 procedure Write_Indent
is
4052 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
4055 if Indent_Annull_Flag
then
4056 Indent_Annull_Flag
:= False;
4058 -- Deal with Dump_Source_Text output. Note that we ignore implicit
4059 -- label declarations, since they typically have the sloc of the
4060 -- corresponding label, which really messes up the -gnatL output.
4063 and then Loc
> No_Location
4064 and then Nkind
(Dump_Node
) /= N_Implicit_Label_Declaration
4066 if Get_Source_File_Index
(Loc
) = Current_Source_File
then
4068 (Get_Physical_Line_Number
(Sloc
(Dump_Node
)));
4074 for J
in 1 .. Indent
loop
4080 ------------------------------
4081 -- Write_Indent_Identifiers --
4082 ------------------------------
4084 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
4086 -- We need to start a new line for every node, except in the case
4087 -- where we are printing the original tree and this is not the first
4088 -- defining identifier in the list.
4090 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
4093 -- If printing original tree and this is not the first defining
4094 -- identifier in the list, then the previous call to this procedure
4095 -- printed only the name, and we add a comma to separate the names.
4101 Sprint_Node
(Defining_Identifier
(Node
));
4103 -- The remainder of the declaration must be printed unless we are
4104 -- printing the original tree and this is not the last identifier
4107 not Dump_Original_Only
or else not More_Ids
(Node
);
4108 end Write_Indent_Identifiers
;
4110 -----------------------------------
4111 -- Write_Indent_Identifiers_Sloc --
4112 -----------------------------------
4114 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
4116 -- We need to start a new line for every node, except in the case
4117 -- where we are printing the original tree and this is not the first
4118 -- defining identifier in the list.
4120 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
4123 -- If printing original tree and this is not the first defining
4124 -- identifier in the list, then the previous call to this procedure
4125 -- printed only the name, and we add a comma to separate the names.
4132 Sprint_Node
(Defining_Identifier
(Node
));
4134 -- The remainder of the declaration must be printed unless we are
4135 -- printing the original tree and this is not the last identifier
4137 return not Dump_Original_Only
or else not More_Ids
(Node
);
4138 end Write_Indent_Identifiers_Sloc
;
4140 ----------------------
4141 -- Write_Indent_Str --
4142 ----------------------
4144 procedure Write_Indent_Str
(S
: String) is
4146 Write_Corresponding_Source
(S
);
4149 end Write_Indent_Str
;
4151 ---------------------------
4152 -- Write_Indent_Str_Sloc --
4153 ---------------------------
4155 procedure Write_Indent_Str_Sloc
(S
: String) is
4157 Write_Corresponding_Source
(S
);
4160 end Write_Indent_Str_Sloc
;
4166 procedure Write_Itype
(Typ
: Entity_Id
) is
4168 procedure Write_Header
(T
: Boolean := True);
4169 -- Write type if T is True, subtype if T is false
4175 procedure Write_Header
(T
: Boolean := True) is
4178 Write_Str
("[type ");
4180 Write_Str
("[subtype ");
4183 Write_Name_With_Col_Check
(Chars
(Typ
));
4187 -- Start of processing for Write_Itype
4190 if Nkind
(Typ
) in N_Entity
4191 and then Is_Itype
(Typ
)
4192 and then not Itype_Printed
(Typ
)
4194 -- Itype to be printed
4197 B
: constant Node_Id
:= Etype
(Typ
);
4198 P
: constant Node_Id
:= Parent
(Typ
);
4199 S
: constant Saved_Output_Buffer
:= Save_Output_Buffer
;
4200 -- Save current output buffer
4202 Old_Sloc
: Source_Ptr
;
4203 -- Save sloc of related node, so it is not modified when
4204 -- printing with -gnatD.
4209 -- Write indentation at start of line
4211 for J
in 1 .. Indent
loop
4215 -- If we have a constructed declaration for the itype, print it
4218 and then Nkind
(P
) in N_Declaration
4219 and then Defining_Entity
(P
) = Typ
4221 -- We must set Itype_Printed true before the recursive call to
4222 -- print the node, otherwise we get an infinite recursion.
4224 Set_Itype_Printed
(Typ
, True);
4226 -- Write the declaration enclosed in [], avoiding new line
4227 -- at start of declaration, and semicolon at end.
4229 -- Note: The itype may be imported from another unit, in which
4230 -- case we do not want to modify the Sloc of the declaration.
4231 -- Otherwise the itype may appear to be in the current unit,
4232 -- and the back-end will reject a reference out of scope.
4235 Indent_Annull_Flag
:= True;
4236 Old_Sloc
:= Sloc
(P
);
4238 Set_Sloc
(P
, Old_Sloc
);
4239 Write_Erase_Char
(';');
4241 -- If no constructed declaration, then we have to concoct the
4242 -- source corresponding to the type entity that we have at hand.
4247 -- Access types and subtypes
4250 Write_Header
(Ekind
(Typ
) = E_Access_Type
);
4252 if Can_Never_Be_Null
(Typ
) then
4253 Write_Str
("not null ");
4256 Write_Str
("access ");
4258 if Is_Access_Constant
(Typ
) then
4259 Write_Str
("constant ");
4262 Write_Id
(Directly_Designated_Type
(Typ
));
4266 when E_Array_Type
=>
4268 Write_Str
("array (");
4270 X
:= First_Index
(Typ
);
4274 if not Is_Constrained
(Typ
) then
4275 Write_Str
(" range <>");
4283 Write_Str
(") of ");
4284 X
:= Component_Type
(Typ
);
4286 -- Preserve sloc of component type, which is defined
4287 -- elsewhere than the itype (see comment above).
4289 Old_Sloc
:= Sloc
(X
);
4291 Set_Sloc
(X
, Old_Sloc
);
4295 -- Preserve Sloc of index subtypes, as above
4297 when E_Array_Subtype
=>
4298 Write_Header
(False);
4299 Write_Id
(Etype
(Typ
));
4302 X
:= First_Index
(Typ
);
4304 Old_Sloc
:= Sloc
(X
);
4306 Set_Sloc
(X
, Old_Sloc
);
4314 -- Signed integer types, and modular integer subtypes,
4315 -- and also enumeration subtypes.
4317 when E_Enumeration_Subtype
4318 | E_Modular_Integer_Subtype
4319 | E_Signed_Integer_Subtype
4320 | E_Signed_Integer_Type
4322 Write_Header
(Ekind
(Typ
) = E_Signed_Integer_Type
);
4324 if Ekind
(Typ
) = E_Signed_Integer_Type
then
4330 -- Print bounds if different from base type
4333 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4334 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4339 -- B can either be a scalar type, in which case the
4340 -- declaration of Typ may constrain it with different
4341 -- bounds, or a private type, in which case we know
4342 -- that the declaration of Typ cannot have a scalar
4345 if Is_Scalar_Type
(B
) then
4346 BL
:= Type_Low_Bound
(B
);
4347 BH
:= Type_High_Bound
(B
);
4355 and then Nkind
(L
) = N_Integer_Literal
4356 and then Nkind
(H
) = N_Integer_Literal
4357 and then Nkind
(BL
) = N_Integer_Literal
4358 and then Nkind
(BH
) = N_Integer_Literal
4359 and then UI_Eq
(Intval
(L
), Intval
(BL
))
4360 and then UI_Eq
(Intval
(H
), Intval
(BH
)))
4365 Write_Str
(" range ");
4372 -- Modular integer types
4374 when E_Modular_Integer_Type
=>
4377 Write_Uint_With_Col_Check
(Modulus
(Typ
), Auto
);
4379 -- Floating-point types and subtypes
4381 when E_Floating_Point_Subtype
4382 | E_Floating_Point_Type
4384 Write_Header
(Ekind
(Typ
) = E_Floating_Point_Type
);
4386 if Ekind
(Typ
) = E_Floating_Point_Type
then
4392 if Digits_Value
(Typ
) /= Digits_Value
(B
) then
4393 Write_Str
(" digits ");
4394 Write_Uint_With_Col_Check
4395 (Digits_Value
(Typ
), Decimal
);
4398 -- Print bounds if not different from base type
4401 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4402 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4403 BL
: constant Node_Id
:= Type_Low_Bound
(B
);
4404 BH
: constant Node_Id
:= Type_High_Bound
(B
);
4408 and then Nkind
(L
) = N_Real_Literal
4409 and then Nkind
(H
) = N_Real_Literal
4410 and then Nkind
(BL
) = N_Real_Literal
4411 and then Nkind
(BH
) = N_Real_Literal
4412 and then UR_Eq
(Realval
(L
), Realval
(BL
))
4413 and then UR_Eq
(Realval
(H
), Realval
(BH
))
4418 Write_Str
(" range ");
4425 -- Ordinary fixed-point types and subtypes
4427 when E_Ordinary_Fixed_Point_Subtype
4428 | E_Ordinary_Fixed_Point_Type
4430 Write_Header
(Ekind
(Typ
) = E_Ordinary_Fixed_Point_Type
);
4432 Write_Str
("delta ");
4433 Write_Ureal_With_Col_Check_Sloc
(Delta_Value
(Typ
));
4434 Write_Str
(" range ");
4435 Sprint_Node
(Type_Low_Bound
(Typ
));
4437 Sprint_Node
(Type_High_Bound
(Typ
));
4439 -- Decimal fixed-point types and subtypes
4441 when E_Decimal_Fixed_Point_Subtype
4442 | E_Decimal_Fixed_Point_Type
4444 Write_Header
(Ekind
(Typ
) = E_Decimal_Fixed_Point_Type
);
4446 Write_Str
("delta ");
4447 Write_Ureal_With_Col_Check_Sloc
(Delta_Value
(Typ
));
4448 Write_Str
(" digits ");
4449 Write_Uint_With_Col_Check
(Digits_Value
(Typ
), Decimal
);
4453 when E_Record_Subtype
4454 | E_Record_Subtype_With_Private
4456 Write_Header
(False);
4457 Write_Str
("record");
4463 C
:= First_Entity
(Typ
);
4464 while Present
(C
) loop
4468 Write_Id
(Etype
(C
));
4474 Write_Indent_Str
(" end record");
4478 when E_Class_Wide_Subtype
4481 Write_Header
(Ekind
(Typ
) = E_Class_Wide_Type
);
4482 Write_Name_With_Col_Check
(Chars
(Etype
(Typ
)));
4483 Write_Str
("'Class");
4487 when E_Subprogram_Type
=>
4490 if Etype
(Typ
) = Standard_Void_Type
then
4491 Write_Str
("procedure");
4493 Write_Str
("function");
4496 if Present
(First_Entity
(Typ
)) then
4503 Param
:= First_Entity
(Typ
);
4508 if Ekind
(Param
) = E_In_Out_Parameter
then
4509 Write_Str
("in out ");
4510 elsif Ekind
(Param
) = E_Out_Parameter
then
4514 Write_Id
(Etype
(Param
));
4515 Next_Entity
(Param
);
4516 exit when No
(Param
);
4520 if Present
(Extra_Formals
(Typ
)) then
4521 Param
:= Extra_Formals
(Typ
);
4523 while Present
(Param
) loop
4527 Write_Id
(Etype
(Param
));
4529 Param
:= Extra_Formal
(Param
);
4536 elsif Present
(Extra_Formals
(Typ
)) then
4543 Param
:= Extra_Formals
(Typ
);
4545 while Present
(Param
) loop
4548 Write_Id
(Etype
(Param
));
4550 if Present
(Extra_Formal
(Param
)) then
4554 Param
:= Extra_Formal
(Param
);
4561 if Etype
(Typ
) /= Standard_Void_Type
then
4562 Write_Str
(" return ");
4563 Write_Id
(Etype
(Typ
));
4566 when E_String_Literal_Subtype
=>
4568 L
: constant Uint
:=
4569 Expr_Value
(String_Literal_Low_Bound
(Typ
));
4570 Len
: constant Uint
:=
4571 String_Literal_Length
(Typ
);
4573 Write_Header
(False);
4574 Write_Str
("String (");
4575 Write_Int
(UI_To_Int
(L
));
4577 Write_Int
(UI_To_Int
(L
+ Len
) - 1);
4581 -- For all other Itypes, print ??? (fill in later)
4584 Write_Header
(True);
4589 -- Add terminating bracket and restore output buffer
4593 Restore_Output_Buffer
(S
);
4596 Set_Itype_Printed
(Typ
);
4600 -------------------------------
4601 -- Write_Name_With_Col_Check --
4602 -------------------------------
4604 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
4610 -- Avoid crashing on invalid Name_Ids
4612 if not Is_Valid_Name
(N
) then
4613 Write_Str
("<invalid name ");
4614 Write_Int
(Int
(N
));
4619 Get_Name_String
(N
);
4621 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4622 -- upper case letter, nnn is one or more digits and b is a lower case
4623 -- letter by C...b, so that listings do not depend on serial numbers.
4625 if Debug_Flag_II
then
4627 while J
< Name_Len
- 1 loop
4628 if Name_Buffer
(J
) in 'A' .. 'Z'
4629 and then Name_Buffer
(J
+ 1) in '0' .. '9'
4632 while K
< Name_Len
loop
4633 exit when Name_Buffer
(K
) not in '0' .. '9';
4637 if Name_Buffer
(K
) in 'a' .. 'z' then
4638 L
:= Name_Len
- K
+ 1;
4640 Name_Buffer
(J
+ 4 .. J
+ L
+ 3) :=
4641 Name_Buffer
(K
.. Name_Len
);
4642 Name_Buffer
(J
+ 1 .. J
+ 3) := "...";
4643 Name_Len
:= J
+ L
+ 3;
4656 -- Fall through for normal case
4658 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4659 end Write_Name_With_Col_Check
;
4661 ------------------------------------
4662 -- Write_Name_With_Col_Check_Sloc --
4663 ------------------------------------
4665 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
4667 -- Avoid crashing on invalid Name_Ids
4669 if not Is_Valid_Name
(N
) then
4670 Write_Str
("<invalid name ");
4671 Write_Int
(Int
(N
));
4676 Get_Name_String
(N
);
4677 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
4678 end Write_Name_With_Col_Check_Sloc
;
4680 --------------------
4681 -- Write_Operator --
4682 --------------------
4684 procedure Write_Operator
(N
: Node_Id
; S
: String) is
4685 F
: Natural := S
'First;
4686 T
: Natural := S
'Last;
4689 -- If no overflow check, just write string out, and we are done
4691 if not Do_Overflow_Check
(N
) then
4694 -- If overflow check, we want to surround the operator with curly
4695 -- brackets, but not include spaces within the brackets.
4708 Write_Str_Sloc
(S
(F
.. T
));
4711 if S
(S
'Last) = ' ' then
4717 -----------------------
4718 -- Write_Param_Specs --
4719 -----------------------
4721 procedure Write_Param_Specs
(N
: Node_Id
) is
4722 Specs
: constant List_Id
:= Parameter_Specifications
(N
);
4723 Specs_Present
: constant Boolean := Is_Non_Empty_List
(Specs
);
4730 Output
: Boolean := False;
4731 -- Set true if we output at least one parameter
4734 -- Write out explicit specs from Parameter_Speficiations list
4736 if Specs_Present
then
4737 Write_Str_With_Col_Check
(" (");
4740 Spec
:= First
(Specs
);
4743 Formal
:= Defining_Identifier
(Spec
);
4745 exit when Spec
= Empty
;
4747 -- Add semicolon, unless we are printing original tree and the
4748 -- next specification is part of a list (but not the first element
4751 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4757 -- See if we have extra formals
4759 if Nkind
(N
) in N_Function_Specification | N_Procedure_Specification
then
4760 Ent
:= Defining_Entity
(N
);
4762 -- Loop to write extra formals (if any)
4764 if Present
(Ent
) and then Is_Subprogram
(Ent
) then
4765 Extras
:= Extra_Formals
(Ent
);
4767 if Present
(Extras
) then
4768 if not Specs_Present
then
4769 Write_Str_With_Col_Check
(" (");
4774 while Present
(Formal
) loop
4775 if Specs_Present
or else Formal
/= Extras
then
4779 Write_Name_With_Col_Check
(Chars
(Formal
));
4781 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
4782 Formal
:= Extra_Formal
(Formal
);
4791 end Write_Param_Specs
;
4793 -----------------------
4794 -- Write_Rewrite_Str --
4795 -----------------------
4797 procedure Write_Rewrite_Str
(S
: String) is
4799 if not Dump_Generated_Only
then
4800 if S
'Length = 3 and then S
= ">>>" then
4803 Write_Str_With_Col_Check
(S
);
4806 end Write_Rewrite_Str
;
4808 -----------------------
4809 -- Write_Source_Line --
4810 -----------------------
4812 procedure Write_Source_Line
(L
: Physical_Line_Number
) is
4814 Src
: Source_Buffer_Ptr
;
4818 if Dump_Source_Text
then
4819 Src
:= Source_Text
(Current_Source_File
);
4820 Loc
:= Line_Start
(L
, Current_Source_File
);
4823 -- See if line is a comment line, if not, and if not line one,
4824 -- precede with blank line.
4827 while Src
(Scn
) = ' ' or else Src
(Scn
) = ASCII
.HT
loop
4831 if (Src
(Scn
) in Line_Terminator
4832 or else Src
(Scn
.. Scn
+ 1) /= "--")
4838 -- Now write the source text of the line
4841 Write_Int
(Int
(L
));
4844 while Src
(Loc
) not in Line_Terminator
loop
4845 Write_Char
(Src
(Loc
));
4849 end Write_Source_Line
;
4851 ------------------------
4852 -- Write_Source_Lines --
4853 ------------------------
4855 procedure Write_Source_Lines
(L
: Physical_Line_Number
) is
4857 while Last_Line_Printed
< L
loop
4858 Last_Line_Printed
:= Last_Line_Printed
+ 1;
4859 Write_Source_Line
(Last_Line_Printed
);
4861 end Write_Source_Lines
;
4863 --------------------
4864 -- Write_Str_Sloc --
4865 --------------------
4867 procedure Write_Str_Sloc
(S
: String) is
4869 for J
in S
'Range loop
4870 Write_Char_Sloc
(S
(J
));
4874 ------------------------------
4875 -- Write_Str_With_Col_Check --
4876 ------------------------------
4878 procedure Write_Str_With_Col_Check
(S
: String) is
4880 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4881 Write_Indent_Str
(" ");
4883 if S
(S
'First) = ' ' then
4884 Write_Str
(S
(S
'First + 1 .. S
'Last));
4892 end Write_Str_With_Col_Check
;
4894 -----------------------------------
4895 -- Write_Str_With_Col_Check_Sloc --
4896 -----------------------------------
4898 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
4900 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4901 Write_Indent_Str
(" ");
4903 if S
(S
'First) = ' ' then
4904 Write_Str_Sloc
(S
(S
'First + 1 .. S
'Last));
4912 end Write_Str_With_Col_Check_Sloc
;
4914 ---------------------------
4915 -- Write_Subprogram_Name --
4916 ---------------------------
4918 procedure Write_Subprogram_Name
(N
: Node_Id
) is
4920 if not Comes_From_Source
(N
)
4921 and then Is_Entity_Name
(N
)
4924 Ent
: constant Entity_Id
:= Entity
(N
);
4926 if not In_Extended_Main_Source_Unit
(Ent
)
4927 and then In_Predefined_Unit
(Ent
)
4929 -- Run-time routine name, output name with a preceding dollar
4930 -- making sure that we do not get a line split between them.
4932 Col_Check
(Length_Of_Name
(Chars
(Ent
)) + 1);
4934 Write_Name
(Chars
(Ent
));
4940 -- Normal case, not a run-time routine name
4943 end Write_Subprogram_Name
;
4945 -------------------------------
4946 -- Write_Uint_With_Col_Check --
4947 -------------------------------
4949 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
) is
4951 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4952 UI_Write
(U
, Format
);
4953 end Write_Uint_With_Col_Check
;
4955 ------------------------------------
4956 -- Write_Uint_With_Col_Check_Sloc --
4957 ------------------------------------
4959 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
4961 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4963 UI_Write
(U
, Format
);
4964 end Write_Uint_With_Col_Check_Sloc
;
4966 -------------------------------------
4967 -- Write_Ureal_With_Col_Check_Sloc --
4968 -------------------------------------
4970 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
4971 D
: constant Uint
:= Denominator
(U
);
4972 N
: constant Uint
:= Numerator
(U
);
4974 Col_Check
(UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
4976 UR_Write
(U
, Brackets
=> True);
4977 end Write_Ureal_With_Col_Check_Sloc
;