1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Aspects
; use Aspects
;
27 with Atree
; use Atree
;
28 with Casing
; use Casing
;
29 with Csets
; use Csets
;
30 with Debug
; use Debug
;
31 with Einfo
; use Einfo
;
32 with Fname
; use Fname
;
34 with Namet
; use Namet
;
35 with Nlists
; use Nlists
;
37 with Output
; use Output
;
38 with Rtsfind
; use Rtsfind
;
39 with Sem_Eval
; use Sem_Eval
;
40 with Sem_Util
; use Sem_Util
;
41 with Sinfo
; use Sinfo
;
42 with Sinput
; use Sinput
;
43 with Sinput
.D
; use Sinput
.D
;
44 with Snames
; use Snames
;
45 with Stand
; use Stand
;
46 with Stringt
; use Stringt
;
47 with Uintp
; use Uintp
;
48 with Uname
; use Uname
;
49 with Urealp
; use Urealp
;
51 package body Sprint
is
52 Current_Source_File
: Source_File_Index
;
53 -- Index of source file whose generated code is being dumped
55 Dump_Node
: Node_Id
:= Empty
;
56 -- This is set to the current node, used for printing line numbers. In
57 -- Debug_Generated_Code mode, Dump_Node is set to the current node
58 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
59 -- value. The call clears it back to Empty.
61 First_Debug_Sloc
: Source_Ptr
;
62 -- Sloc of first byte of the current output file if we are generating a
65 Debug_Sloc
: Source_Ptr
;
66 -- Sloc of first byte of line currently being written if we are
67 -- generating a source debug file.
69 Dump_Original_Only
: Boolean;
70 -- Set True if the -gnatdo (dump original tree) flag is set
72 Dump_Generated_Only
: Boolean;
73 -- Set True if the -gnatdG (dump generated tree) debug flag is set
74 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
76 Dump_Freeze_Null
: Boolean;
77 -- Set True if empty freeze nodes and non-source null statements output.
78 -- Note that freeze nodes containing freeze actions are always output,
79 -- as are freeze nodes for itypes, which in general have the effect of
80 -- causing elaboration of the itype.
82 Freeze_Indent
: Int
:= 0;
83 -- Keep track of freeze indent level (controls output of blank lines before
84 -- procedures within expression freeze actions). Relevant only if we are
85 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
86 -- output these blank lines in any case.
89 -- Number of columns for current line output indentation
91 Indent_Annull_Flag
: Boolean := False;
92 -- Set True if subsequent Write_Indent call to be ignored, gets reset
93 -- by this call, so it is only active to suppress a single indent call.
95 Last_Line_Printed
: Physical_Line_Number
;
96 -- This keeps track of the physical line number of the last source line
97 -- that has been output. The value is only valid in Dump_Source_Text mode.
99 -------------------------------
100 -- Operator Precedence Table --
101 -------------------------------
103 -- This table is used to decide whether a subexpression needs to be
104 -- parenthesized. The rule is that if an operand of an operator (which
105 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
106 -- with a lower precedence than the operator (or equal precedence if
107 -- appearing as the right operand), then parentheses are required.
109 Op_Prec
: constant array (N_Subexpr
) of Short_Short_Integer :=
142 procedure Sprint_Left_Opnd
(N
: Node_Id
);
143 -- Print left operand of operator, parenthesizing if necessary
145 procedure Sprint_Right_Opnd
(N
: Node_Id
);
146 -- Print right operand of operator, parenthesizing if necessary
148 -----------------------
149 -- Local Subprograms --
150 -----------------------
152 procedure Col_Check
(N
: Nat
);
153 -- Check that at least N characters remain on current line, and if not,
154 -- then start an extra line with two characters extra indentation for
155 -- continuing text on the next line.
157 procedure Extra_Blank_Line
;
158 -- In some situations we write extra blank lines to separate the generated
159 -- code to make it more readable. However, these extra blank lines are not
160 -- generated in Dump_Source_Text mode, since there the source text lines
161 -- output with preceding blank lines are quite sufficient as separators.
162 -- This procedure writes a blank line if Dump_Source_Text is False.
164 procedure Indent_Annull
;
165 -- Causes following call to Write_Indent to be ignored. This is used when
166 -- a higher level node wants to stop a lower level node from starting a
167 -- new line, when it would otherwise be inclined to do so (e.g. the case
168 -- of an accept statement called from an accept alternative with a guard)
170 procedure Indent_Begin
;
171 -- Increase indentation level
173 procedure Indent_End
;
174 -- Decrease indentation level
176 procedure Print_Debug_Line
(S
: String);
177 -- Used to print output lines in Debug_Generated_Code mode (this is used
178 -- as the argument for a call to Set_Special_Output in package Output).
180 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
);
181 -- Given a divide, multiplication or division node, check the flags
182 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
183 -- appropriate special syntax characters (# and @).
185 procedure Set_Debug_Sloc
;
186 -- If Dump_Node is non-empty, this routine sets the appropriate value
187 -- in its Sloc field, from the current location in the debug source file
188 -- that is currently being written.
190 procedure Sprint_And_List
(List
: List_Id
);
191 -- Print the given list with items separated by vertical "and"
193 procedure Sprint_Aspect_Specifications
195 Semicolon
: Boolean);
196 -- Node is a declaration node that has aspect specifications (Has_Aspects
197 -- flag set True). It outputs the aspect specifications. For the case
198 -- of Semicolon = True, it is called after outputting the terminating
199 -- semicolon for the related node. The effect is to remove the semicolon
200 -- and print the aspect specifications followed by a terminating semicolon.
201 -- For the case of Semicolon False, no semicolon is removed or output, and
202 -- all the aspects are printed on a single line.
204 procedure Sprint_Bar_List
(List
: List_Id
);
205 -- Print the given list with items separated by vertical bars
207 procedure Sprint_End_Label
210 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
211 -- If there is no end label, use the defining identifier of the enclosing
212 -- construct. If the end label is present, treat it as a reference to the
213 -- defining entity of the construct: this guarantees that it carries the
214 -- proper sloc information for debugging purposes.
216 procedure Sprint_Node_Actual
(Node
: Node_Id
);
217 -- This routine prints its node argument. It is a lower level routine than
218 -- Sprint_Node, in that it does not bother about rewritten trees.
220 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
221 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
222 -- sets the Sloc of the current debug node to be a copy of the Sloc
223 -- of the sprinted node Node. Note that this is done after printing
224 -- Node, so that the Sloc is the proper updated value for the debug file.
226 procedure Update_Itype
(Node
: Node_Id
);
227 -- Update the Sloc of an itype that is not attached to the tree, when
228 -- debugging expanded code. This routine is called from nodes whose
229 -- type can be an Itype, such as defining_identifiers that may be of
230 -- an anonymous access type, or ranges in slices.
232 procedure Write_Char_Sloc
(C
: Character);
233 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
234 -- called to ensure that the current node has a proper Sloc set.
236 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
237 -- Write Condition and Reason codes of Raise_xxx_Error node
239 procedure Write_Corresponding_Source
(S
: String);
240 -- If S is a string with a single keyword (possibly followed by a space),
241 -- and if the next non-comment non-blank source line matches this keyword,
242 -- then output all source lines up to this matching line.
244 procedure Write_Discr_Specs
(N
: Node_Id
);
245 -- Output discriminant specification for node, which is any of the type
246 -- declarations that can have discriminants.
248 procedure Write_Ekind
(E
: Entity_Id
);
249 -- Write the String corresponding to the Ekind without "E_"
251 procedure Write_Id
(N
: Node_Id
);
252 -- N is a node with a Chars field. This procedure writes the name that
253 -- will be used in the generated code associated with the name. For a
254 -- node with no associated entity, this is simply the Chars field. For
255 -- the case where there is an entity associated with the node, we print
256 -- the name associated with the entity (since it may have been encoded).
257 -- One other special case is that an entity has an active external name
258 -- (i.e. an external name present with no address clause), then this
259 -- external name is output. This procedure also deals with outputting
260 -- declarations of referenced itypes, if not output earlier.
262 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
263 -- Handle node where the grammar has a list of defining identifiers, but
264 -- the tree has a separate declaration for each identifier. Handles the
265 -- printing of the defining identifier, and returns True if the type and
266 -- initialization information is to be printed, False if it is to be
267 -- skipped (the latter case happens when printing defining identifiers
268 -- other than the first in the original tree output case).
270 procedure Write_Implicit_Def
(E
: Entity_Id
);
271 pragma Warnings
(Off
, Write_Implicit_Def
);
272 -- Write the definition of the implicit type E according to its Ekind
273 -- For now a debugging procedure, but might be used in the future.
275 procedure Write_Indent
;
276 -- Start a new line and write indentation spacing
278 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
279 -- Like Write_Identifiers except that each new printed declaration
280 -- is at the start of a new line.
282 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
283 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
284 -- mode, the Sloc of the current debug node is set to point to the
285 -- first output identifier.
287 procedure Write_Indent_Str
(S
: String);
288 -- Start a new line and write indent spacing followed by given string
290 procedure Write_Indent_Str_Sloc
(S
: String);
291 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
292 -- the Sloc of the current node is set to the first non-blank character
295 procedure Write_Itype
(Typ
: Entity_Id
);
296 -- If Typ is an Itype that has not been written yet, write it. If Typ is
297 -- any other kind of entity or tree node, the call is ignored.
299 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
300 -- Write name (using Write_Name) with initial column check, and possible
301 -- initial Write_Indent (to get new line) if current line is too full.
303 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
304 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
305 -- mode, sets Sloc of current debug node to first character of name.
307 procedure Write_Operator
(N
: Node_Id
; S
: String);
308 -- Like Write_Str_Sloc, used for operators, encloses the string in
309 -- characters {} if the Do_Overflow flag is set on the node N.
311 procedure Write_Param_Specs
(N
: Node_Id
);
312 -- Output parameter specifications for node (which is either a function
313 -- or procedure specification with a Parameter_Specifications field)
315 procedure Write_Rewrite_Str
(S
: String);
316 -- Writes out a string (typically containing <<< or >>>}) for a node
317 -- created by rewriting the tree. Suppressed if we are outputting the
318 -- generated code only, since in this case we don't specially mark nodes
319 -- created by rewriting).
321 procedure Write_Source_Line
(L
: Physical_Line_Number
);
322 -- If writing of interspersed source lines is enabled, then write the given
323 -- line from the source file, preceded by Eol, then an extra blank line if
324 -- the line has at least one blank, is not a comment and is not line one,
325 -- then "--" and the line number followed by period followed by text of the
326 -- source line (without terminating Eol). If interspersed source line
327 -- output not enabled, then the call has no effect.
329 procedure Write_Source_Lines
(L
: Physical_Line_Number
);
330 -- If writing of interspersed source lines is enabled, then writes source
331 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
332 -- interspersed source line output not enabled, then call has no effect.
334 procedure Write_Str_Sloc
(S
: String);
335 -- Like Write_Str, but sets debug Sloc of current debug node to first
336 -- non-blank character if a current debug node is active.
338 procedure Write_Str_With_Col_Check
(S
: String);
339 -- Write string (using Write_Str) with initial column check, and possible
340 -- initial Write_Indent (to get new line) if current line is too full.
342 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
343 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
344 -- node to first non-blank character if a current debug node is active.
346 procedure Write_Subprogram_Name
(N
: Node_Id
);
347 -- N is the Name field of a function call or procedure statement call.
348 -- The effect of the call is to output the name, preceded by a $ if the
349 -- call is identified as an implicit call to a run time routine.
351 procedure Write_Uint_With_Col_Check
(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).
356 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
357 -- Write Uint (using UI_Write) with initial column check, and possible
358 -- initial Write_Indent (to get new line) if current line is too full.
359 -- The format parameter determines the output format (see UI_Write).
360 -- In addition, in Debug_Generated_Code mode, sets the current node
361 -- Sloc to the first character of the output value.
363 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
364 -- Write Ureal (using same output format as UR_Write) with column checks
365 -- and a possible initial Write_Indent (to get new line) if current line
366 -- is too full. In addition, in Debug_Generated_Code mode, sets the
367 -- current node Sloc to the first character of the output value.
373 procedure Col_Check
(N
: Nat
) is
375 if N
+ Column
> Sprint_Line_Limit
then
376 Write_Indent_Str
(" ");
380 ----------------------
381 -- Extra_Blank_Line --
382 ----------------------
384 procedure Extra_Blank_Line
is
386 if not Dump_Source_Text
then
389 end Extra_Blank_Line
;
395 procedure Indent_Annull
is
397 Indent_Annull_Flag
:= True;
404 procedure Indent_Begin
is
406 Indent
:= Indent
+ 3;
413 procedure Indent_End
is
415 Indent
:= Indent
- 3;
422 procedure pg
(Arg
: Union_Id
) is
424 Dump_Generated_Only
:= True;
425 Dump_Original_Only
:= False;
426 Dump_Freeze_Null
:= True;
427 Current_Source_File
:= No_Source_File
;
429 if Arg
in List_Range
then
430 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
432 elsif Arg
in Node_Range
then
433 Sprint_Node
(Node_Id
(Arg
));
446 procedure po
(Arg
: Union_Id
) is
448 Dump_Generated_Only
:= False;
449 Dump_Original_Only
:= True;
450 Current_Source_File
:= No_Source_File
;
452 if Arg
in List_Range
then
453 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
455 elsif Arg
in Node_Range
then
456 Sprint_Node
(Node_Id
(Arg
));
465 ----------------------
466 -- Print_Debug_Line --
467 ----------------------
469 procedure Print_Debug_Line
(S
: String) is
471 Write_Debug_Line
(S
, Debug_Sloc
);
472 end Print_Debug_Line
;
474 ---------------------------
475 -- Process_TFAI_RR_Flags --
476 ---------------------------
478 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
480 if Treat_Fixed_As_Integer
(Nod
) then
484 if Rounded_Result
(Nod
) then
487 end Process_TFAI_RR_Flags
;
493 procedure ps
(Arg
: Union_Id
) is
495 Dump_Generated_Only
:= False;
496 Dump_Original_Only
:= False;
497 Current_Source_File
:= No_Source_File
;
499 if Arg
in List_Range
then
500 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
502 elsif Arg
in Node_Range
then
503 Sprint_Node
(Node_Id
(Arg
));
516 procedure Set_Debug_Sloc
is
518 if Debug_Generated_Code
and then Present
(Dump_Node
) then
520 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
523 -- Do not change the location of nodes defined in package Standard
524 -- and nodes of pragmas scanned by Targparm.
526 if Loc
<= Standard_Location
then
529 -- Update the location of a node which is part of the current .dg
530 -- output. This situation occurs in comma separated parameter
531 -- declarations since each parameter references the same parameter
532 -- type node (ie. obj1, obj2 : <param-type>).
534 -- Note: This case is needed here since we cannot use the routine
535 -- In_Extended_Main_Code_Unit with nodes whose location is a .dg
538 elsif Loc
>= First_Debug_Sloc
then
539 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
541 -- Do not change the location of nodes which are not part of the
544 elsif not In_Extended_Main_Code_Unit
(Loc
) then
548 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
552 -- We do not know the actual end location in the generated code and
553 -- it could be much closer than in the source code, so play safe.
555 if Nkind_In
(Dump_Node
, N_Case_Statement
, N_If_Statement
) then
556 Set_End_Location
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
567 procedure Source_Dump
is
570 -- Put underline under string we just printed
576 procedure Underline
is
577 Col
: constant Int
:= Column
;
582 while Col
> Column
loop
589 -- Start of processing for Source_Dump
592 Dump_Generated_Only
:= Debug_Flag_G
or
593 Print_Generated_Code
or
594 Debug_Generated_Code
;
595 Dump_Original_Only
:= Debug_Flag_O
;
596 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
598 -- Note that we turn off the tree dump flags immediately, before
599 -- starting the dump. This avoids generating two copies of the dump
600 -- if an abort occurs after printing the dump, and more importantly,
601 -- avoids an infinite loop if an abort occurs during the dump.
604 Current_Source_File
:= No_Source_File
;
605 Debug_Flag_Z
:= False;
608 Write_Str
("Source recreated from tree of Standard (spec)");
610 Sprint_Node
(Standard_Package_Node
);
615 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
616 Debug_Flag_G
:= False;
617 Debug_Flag_O
:= False;
618 Debug_Flag_S
:= False;
619 First_Debug_Sloc
:= No_Location
;
621 -- Dump requested units
623 for U
in Main_Unit
.. Last_Unit
loop
624 Current_Source_File
:= Source_Index
(U
);
626 -- Dump all units if -gnatdf set, otherwise we dump only
627 -- the source files that are in the extended main source.
630 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
632 -- If we are generating debug files, setup to write them
634 if Debug_Generated_Code
then
635 Set_Special_Output
(Print_Debug_Line
'Access);
636 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
637 First_Debug_Sloc
:= Debug_Sloc
;
638 Write_Source_Line
(1);
639 Last_Line_Printed
:= 1;
640 Sprint_Node
(Cunit
(U
));
641 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
644 Set_Special_Output
(null);
646 -- Normal output to standard output file
649 Write_Str
("Source recreated from tree for ");
650 Write_Unit_Name
(Unit_Name
(U
));
652 Write_Source_Line
(1);
653 Last_Line_Printed
:= 1;
654 Sprint_Node
(Cunit
(U
));
655 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
664 ---------------------
665 -- Sprint_And_List --
666 ---------------------
668 procedure Sprint_And_List
(List
: List_Id
) is
671 if Is_Non_Empty_List
(List
) then
672 Node
:= First
(List
);
676 exit when Node
= Empty
;
682 ----------------------------------
683 -- Sprint_Aspect_Specifications --
684 ----------------------------------
686 procedure Sprint_Aspect_Specifications
690 AS
: constant List_Id
:= Aspect_Specifications
(Node
);
695 Write_Erase_Char
(';');
696 Indent
:= Indent
+ 2;
699 Indent
:= Indent
+ 5;
702 Write_Str
(" with ");
707 Sprint_Node
(Identifier
(A
));
709 if Class_Present
(A
) then
710 Write_Str
("'Class");
713 if Present
(Expression
(A
)) then
715 Sprint_Node
(Expression
(A
));
729 Indent
:= Indent
- 7;
732 end Sprint_Aspect_Specifications
;
734 ---------------------
735 -- Sprint_Bar_List --
736 ---------------------
738 procedure Sprint_Bar_List
(List
: List_Id
) is
741 if Is_Non_Empty_List
(List
) then
742 Node
:= First
(List
);
746 exit when Node
= Empty
;
752 ----------------------
753 -- Sprint_End_Label --
754 ----------------------
756 procedure Sprint_End_Label
762 and then Present
(End_Label
(Node
))
763 and then Is_Entity_Name
(End_Label
(Node
))
765 Set_Entity
(End_Label
(Node
), Default
);
767 -- For a function whose name is an operator, use the qualified name
768 -- created for the defining entity.
770 if Nkind
(End_Label
(Node
)) = N_Operator_Symbol
then
771 Set_Chars
(End_Label
(Node
), Chars
(Default
));
774 Sprint_Node
(End_Label
(Node
));
776 Sprint_Node
(Default
);
778 end Sprint_End_Label
;
780 -----------------------
781 -- Sprint_Comma_List --
782 -----------------------
784 procedure Sprint_Comma_List
(List
: List_Id
) is
788 if Is_Non_Empty_List
(List
) then
789 Node
:= First
(List
);
793 exit when Node
= Empty
;
795 if not Is_Rewrite_Insertion
(Node
)
796 or else not Dump_Original_Only
802 end Sprint_Comma_List
;
804 --------------------------
805 -- Sprint_Indented_List --
806 --------------------------
808 procedure Sprint_Indented_List
(List
: List_Id
) is
811 Sprint_Node_List
(List
);
813 end Sprint_Indented_List
;
815 ---------------------
816 -- Sprint_Left_Opnd --
817 ---------------------
819 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
820 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
823 if Paren_Count
(Opnd
) /= 0
824 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
833 end Sprint_Left_Opnd
;
839 procedure Sprint_Node
(Node
: Node_Id
) is
841 if Is_Rewrite_Insertion
(Node
) then
842 if not Dump_Original_Only
then
844 -- For special cases of nodes that always output <<< >>>
845 -- do not duplicate the output at this point.
847 if Nkind
(Node
) = N_Freeze_Entity
848 or else Nkind
(Node
) = N_Freeze_Generic_Entity
849 or else Nkind
(Node
) = N_Implicit_Label_Declaration
851 Sprint_Node_Actual
(Node
);
853 -- Normal case where <<< >>> may be required
856 Write_Rewrite_Str
("<<<");
857 Sprint_Node_Actual
(Node
);
858 Write_Rewrite_Str
(">>>");
862 elsif Is_Rewrite_Substitution
(Node
) then
864 -- Case of dump generated only
866 if Dump_Generated_Only
then
867 Sprint_Node_Actual
(Node
);
869 -- Case of dump original only
871 elsif Dump_Original_Only
then
872 Sprint_Node_Actual
(Original_Node
(Node
));
874 -- Case of both being dumped
877 Sprint_Node_Actual
(Original_Node
(Node
));
878 Write_Rewrite_Str
("<<<");
879 Sprint_Node_Actual
(Node
);
880 Write_Rewrite_Str
(">>>");
884 Sprint_Node_Actual
(Node
);
888 ------------------------
889 -- Sprint_Node_Actual --
890 ------------------------
892 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
893 Save_Dump_Node
: constant Node_Id
:= Dump_Node
;
900 for J
in 1 .. Paren_Count
(Node
) loop
901 Write_Str_With_Col_Check
("(");
904 -- Setup current dump node
908 if Nkind
(Node
) in N_Subexpr
909 and then Do_Range_Check
(Node
)
911 Write_Str_With_Col_Check
("{");
914 -- Select print circuit based on node kind
917 when N_Abort_Statement
=>
918 Write_Indent_Str_Sloc
("abort ");
919 Sprint_Comma_List
(Names
(Node
));
922 when N_Abortable_Part
=>
924 Write_Str_Sloc
("abort ");
925 Sprint_Indented_List
(Statements
(Node
));
927 when N_Abstract_Subprogram_Declaration
=>
929 Sprint_Node
(Specification
(Node
));
930 Write_Str_With_Col_Check
(" is ");
931 Write_Str_Sloc
("abstract;");
933 when N_Accept_Alternative
=>
934 Sprint_Node_List
(Pragmas_Before
(Node
));
936 if Present
(Condition
(Node
)) then
937 Write_Indent_Str
("when ");
938 Sprint_Node
(Condition
(Node
));
943 Sprint_Node_Sloc
(Accept_Statement
(Node
));
944 Sprint_Node_List
(Statements
(Node
));
946 when N_Accept_Statement
=>
947 Write_Indent_Str_Sloc
("accept ");
948 Write_Id
(Entry_Direct_Name
(Node
));
950 if Present
(Entry_Index
(Node
)) then
951 Write_Str_With_Col_Check
(" (");
952 Sprint_Node
(Entry_Index
(Node
));
956 Write_Param_Specs
(Node
);
958 if Present
(Handled_Statement_Sequence
(Node
)) then
959 Write_Str_With_Col_Check
(" do");
960 Sprint_Node
(Handled_Statement_Sequence
(Node
));
961 Write_Indent_Str
("end ");
962 Write_Id
(Entry_Direct_Name
(Node
));
967 when N_Access_Definition
=>
971 if Present
(Access_To_Subprogram_Definition
(Node
)) then
972 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
976 if Null_Exclusion_Present
(Node
) then
977 Write_Str
("not null ");
980 Write_Str_With_Col_Check_Sloc
("access ");
982 if All_Present
(Node
) then
984 elsif Constant_Present
(Node
) then
985 Write_Str
("constant ");
988 Sprint_Node
(Subtype_Mark
(Node
));
991 when N_Access_Function_Definition
=>
995 if Null_Exclusion_Present
(Node
) then
996 Write_Str
("not null ");
999 Write_Str_With_Col_Check_Sloc
("access ");
1001 if Protected_Present
(Node
) then
1002 Write_Str_With_Col_Check
("protected ");
1005 Write_Str_With_Col_Check
("function");
1006 Write_Param_Specs
(Node
);
1007 Write_Str_With_Col_Check
(" return ");
1008 Sprint_Node
(Result_Definition
(Node
));
1010 when N_Access_Procedure_Definition
=>
1012 -- Ada 2005 (AI-231)
1014 if Null_Exclusion_Present
(Node
) then
1015 Write_Str
("not null ");
1018 Write_Str_With_Col_Check_Sloc
("access ");
1020 if Protected_Present
(Node
) then
1021 Write_Str_With_Col_Check
("protected ");
1024 Write_Str_With_Col_Check
("procedure");
1025 Write_Param_Specs
(Node
);
1027 when N_Access_To_Object_Definition
=>
1028 Write_Str_With_Col_Check_Sloc
("access ");
1030 if All_Present
(Node
) then
1031 Write_Str_With_Col_Check
("all ");
1032 elsif Constant_Present
(Node
) then
1033 Write_Str_With_Col_Check
("constant ");
1036 -- Ada 2005 (AI-231)
1038 if Null_Exclusion_Present
(Node
) then
1039 Write_Str
("not null ");
1042 Sprint_Node
(Subtype_Indication
(Node
));
1045 if Null_Record_Present
(Node
) then
1046 Write_Str_With_Col_Check_Sloc
("(null record)");
1049 Write_Str_With_Col_Check_Sloc
("(");
1051 if Present
(Expressions
(Node
)) then
1052 Sprint_Comma_List
(Expressions
(Node
));
1054 if Present
(Component_Associations
(Node
))
1055 and then not Is_Empty_List
(Component_Associations
(Node
))
1061 if Present
(Component_Associations
(Node
))
1062 and then not Is_Empty_List
(Component_Associations
(Node
))
1070 Nd
:= First
(Component_Associations
(Node
));
1078 if not Is_Rewrite_Insertion
(Nd
)
1079 or else not Dump_Original_Only
1093 Write_Str_With_Col_Check_Sloc
("new ");
1095 -- Ada 2005 (AI-231)
1097 if Null_Exclusion_Present
(Node
) then
1098 Write_Str
("not null ");
1101 Sprint_Node
(Expression
(Node
));
1103 if Present
(Storage_Pool
(Node
)) then
1104 Write_Str_With_Col_Check
("[storage_pool = ");
1105 Sprint_Node
(Storage_Pool
(Node
));
1110 Sprint_Left_Opnd
(Node
);
1111 Write_Str_Sloc
(" and then ");
1112 Sprint_Right_Opnd
(Node
);
1114 -- Note: the following code for N_Aspect_Specification is not
1115 -- normally used, since we deal with aspects as part of a
1116 -- declaration, but it is here in case we deliberately try
1117 -- to print an N_Aspect_Speficiation node (e.g. from GDB).
1119 when N_Aspect_Specification
=>
1120 Sprint_Node
(Identifier
(Node
));
1122 Sprint_Node
(Expression
(Node
));
1124 when N_Assignment_Statement
=>
1126 Sprint_Node
(Name
(Node
));
1127 Write_Str_Sloc
(" := ");
1128 Sprint_Node
(Expression
(Node
));
1131 when N_Asynchronous_Select
=>
1132 Write_Indent_Str_Sloc
("select");
1134 Sprint_Node
(Triggering_Alternative
(Node
));
1137 -- Note: let the printing of Abortable_Part handle outputting
1138 -- the ABORT keyword, so that the Sloc can be set correctly.
1140 Write_Indent_Str
("then ");
1141 Sprint_Node
(Abortable_Part
(Node
));
1142 Write_Indent_Str
("end select;");
1145 Write_Indent_Str_Sloc
("for ");
1146 Write_Id
(Identifier
(Node
));
1147 Write_Str_With_Col_Check
(" use at ");
1148 Sprint_Node
(Expression
(Node
));
1151 when N_Attribute_Definition_Clause
=>
1152 Write_Indent_Str_Sloc
("for ");
1153 Sprint_Node
(Name
(Node
));
1155 Write_Name_With_Col_Check
(Chars
(Node
));
1156 Write_Str_With_Col_Check
(" use ");
1157 Sprint_Node
(Expression
(Node
));
1160 when N_Attribute_Reference
=>
1161 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1165 Sprint_Node
(Prefix
(Node
));
1166 Write_Char_Sloc
(''');
1167 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
1168 Sprint_Paren_Comma_List
(Expressions
(Node
));
1170 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1174 when N_Block_Statement
=>
1177 if Present
(Identifier
(Node
))
1178 and then (not Has_Created_Identifier
(Node
)
1179 or else not Dump_Original_Only
)
1181 Write_Rewrite_Str
("<<<");
1182 Write_Id
(Identifier
(Node
));
1184 Write_Rewrite_Str
(">>>");
1187 if Present
(Declarations
(Node
)) then
1188 Write_Str_With_Col_Check_Sloc
("declare");
1189 Sprint_Indented_List
(Declarations
(Node
));
1193 Write_Str_With_Col_Check_Sloc
("begin");
1194 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1195 Write_Indent_Str
("end");
1197 if Present
(Identifier
(Node
))
1198 and then (not Has_Created_Identifier
(Node
)
1199 or else not Dump_Original_Only
)
1201 Write_Rewrite_Str
("<<<");
1203 Write_Id
(Identifier
(Node
));
1204 Write_Rewrite_Str
(">>>");
1209 when N_Case_Expression
=>
1211 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
1215 -- The syntax for case_expression does not include parentheses,
1216 -- but sometimes parentheses are required, so unconditionally
1217 -- generate them here unless already present.
1219 if not Has_Parens
then
1223 Write_Str_With_Col_Check_Sloc
("case ");
1224 Sprint_Node
(Expression
(Node
));
1225 Write_Str_With_Col_Check
(" is");
1227 Alt
:= First
(Alternatives
(Node
));
1235 if not Has_Parens
then
1240 when N_Case_Expression_Alternative
=>
1241 Write_Str_With_Col_Check
(" when ");
1242 Sprint_Bar_List
(Discrete_Choices
(Node
));
1244 Sprint_Node
(Expression
(Node
));
1246 when N_Case_Statement
=>
1247 Write_Indent_Str_Sloc
("case ");
1248 Sprint_Node
(Expression
(Node
));
1250 Sprint_Indented_List
(Alternatives
(Node
));
1251 Write_Indent_Str
("end case;");
1253 when N_Case_Statement_Alternative
=>
1254 Write_Indent_Str_Sloc
("when ");
1255 Sprint_Bar_List
(Discrete_Choices
(Node
));
1257 Sprint_Indented_List
(Statements
(Node
));
1259 when N_Character_Literal
=>
1260 if Column
> Sprint_Line_Limit
- 2 then
1261 Write_Indent_Str
(" ");
1264 Write_Char_Sloc
(''');
1265 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
1268 when N_Code_Statement
=>
1271 Sprint_Node
(Expression
(Node
));
1274 when N_Compilation_Unit
=>
1275 Sprint_Node_List
(Context_Items
(Node
));
1276 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
1278 if Private_Present
(Node
) then
1279 Write_Indent_Str
("private ");
1283 Sprint_Node_Sloc
(Unit
(Node
));
1285 if Present
(Actions
(Aux_Decls_Node
(Node
)))
1287 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
1292 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
1293 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
1295 when N_Compilation_Unit_Aux
=>
1296 null; -- nothing to do, never used, see above
1298 when N_Component_Association
=>
1300 Sprint_Bar_List
(Choices
(Node
));
1303 -- Ada 2005 (AI-287): Print the box if present
1305 if Box_Present
(Node
) then
1306 Write_Str_With_Col_Check
("<>");
1308 Sprint_Node
(Expression
(Node
));
1311 when N_Component_Clause
=>
1313 Sprint_Node
(Component_Name
(Node
));
1314 Write_Str_Sloc
(" at ");
1315 Sprint_Node
(Position
(Node
));
1317 Write_Str_With_Col_Check
("range ");
1318 Sprint_Node
(First_Bit
(Node
));
1320 Sprint_Node
(Last_Bit
(Node
));
1323 when N_Component_Definition
=>
1326 -- Ada 2005 (AI-230): Access definition components
1328 if Present
(Access_Definition
(Node
)) then
1329 Sprint_Node
(Access_Definition
(Node
));
1331 elsif Present
(Subtype_Indication
(Node
)) then
1332 if Aliased_Present
(Node
) then
1333 Write_Str_With_Col_Check
("aliased ");
1336 -- Ada 2005 (AI-231)
1338 if Null_Exclusion_Present
(Node
) then
1339 Write_Str
(" not null ");
1342 Sprint_Node
(Subtype_Indication
(Node
));
1345 Write_Str
(" ??? ");
1348 when N_Component_Declaration
=>
1349 if Write_Indent_Identifiers_Sloc
(Node
) then
1351 Sprint_Node
(Component_Definition
(Node
));
1353 if Present
(Expression
(Node
)) then
1355 Sprint_Node
(Expression
(Node
));
1361 when N_Component_List
=>
1362 if Null_Present
(Node
) then
1364 Write_Indent_Str_Sloc
("null");
1370 Sprint_Indented_List
(Component_Items
(Node
));
1371 Sprint_Node
(Variant_Part
(Node
));
1374 when N_Compound_Statement
=>
1375 Write_Indent_Str
("do");
1377 Sprint_Node_List
(Actions
(Node
));
1379 Write_Indent_Str
("end;");
1381 when N_Conditional_Entry_Call
=>
1382 Write_Indent_Str_Sloc
("select");
1384 Sprint_Node
(Entry_Call_Alternative
(Node
));
1386 Write_Indent_Str
("else");
1387 Sprint_Indented_List
(Else_Statements
(Node
));
1388 Write_Indent_Str
("end select;");
1390 when N_Constrained_Array_Definition
=>
1391 Write_Str_With_Col_Check_Sloc
("array ");
1392 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1395 Sprint_Node
(Component_Definition
(Node
));
1397 -- A contract node should not appear in the tree. It is a semantic
1398 -- node attached to entry and [generic] subprogram entities. But we
1399 -- still provide meaningful output, in case called from the debugger.
1407 Write_Str
("N_Contract node");
1410 Write_Indent_Str
("Pre_Post_Conditions");
1413 P
:= Pre_Post_Conditions
(Node
);
1414 while Present
(P
) loop
1416 P
:= Next_Pragma
(P
);
1422 Write_Indent_Str
("Contract_Test_Cases");
1425 P
:= Contract_Test_Cases
(Node
);
1426 while Present
(P
) loop
1428 P
:= Next_Pragma
(P
);
1434 Write_Indent_Str
("Classifications");
1437 P
:= Classifications
(Node
);
1438 while Present
(P
) loop
1440 P
:= Next_Pragma
(P
);
1448 when N_Decimal_Fixed_Point_Definition
=>
1449 Write_Str_With_Col_Check_Sloc
(" delta ");
1450 Sprint_Node
(Delta_Expression
(Node
));
1451 Write_Str_With_Col_Check
("digits ");
1452 Sprint_Node
(Digits_Expression
(Node
));
1453 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1455 when N_Defining_Character_Literal
=>
1456 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1458 when N_Defining_Identifier
=>
1462 when N_Defining_Operator_Symbol
=>
1463 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1465 when N_Defining_Program_Unit_Name
=>
1467 Sprint_Node
(Name
(Node
));
1469 Write_Id
(Defining_Identifier
(Node
));
1471 when N_Delay_Alternative
=>
1472 Sprint_Node_List
(Pragmas_Before
(Node
));
1474 if Present
(Condition
(Node
)) then
1476 Write_Str_With_Col_Check
("when ");
1477 Sprint_Node
(Condition
(Node
));
1482 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1483 Sprint_Node_List
(Statements
(Node
));
1485 when N_Delay_Relative_Statement
=>
1486 Write_Indent_Str_Sloc
("delay ");
1487 Sprint_Node
(Expression
(Node
));
1490 when N_Delay_Until_Statement
=>
1491 Write_Indent_Str_Sloc
("delay until ");
1492 Sprint_Node
(Expression
(Node
));
1495 when N_Delta_Constraint
=>
1496 Write_Str_With_Col_Check_Sloc
("delta ");
1497 Sprint_Node
(Delta_Expression
(Node
));
1498 Sprint_Opt_Node
(Range_Constraint
(Node
));
1500 when N_Derived_Type_Definition
=>
1501 if Abstract_Present
(Node
) then
1502 Write_Str_With_Col_Check
("abstract ");
1505 Write_Str_With_Col_Check
("new ");
1507 -- Ada 2005 (AI-231)
1509 if Null_Exclusion_Present
(Node
) then
1510 Write_Str_With_Col_Check
("not null ");
1513 Sprint_Node
(Subtype_Indication
(Node
));
1515 if Present
(Interface_List
(Node
)) then
1516 Write_Str_With_Col_Check
(" and ");
1517 Sprint_And_List
(Interface_List
(Node
));
1518 Write_Str_With_Col_Check
(" with ");
1521 if Present
(Record_Extension_Part
(Node
)) then
1522 if No
(Interface_List
(Node
)) then
1523 Write_Str_With_Col_Check
(" with ");
1526 Sprint_Node
(Record_Extension_Part
(Node
));
1529 when N_Designator
=>
1530 Sprint_Node
(Name
(Node
));
1531 Write_Char_Sloc
('.');
1532 Write_Id
(Identifier
(Node
));
1534 when N_Digits_Constraint
=>
1535 Write_Str_With_Col_Check_Sloc
("digits ");
1536 Sprint_Node
(Digits_Expression
(Node
));
1537 Sprint_Opt_Node
(Range_Constraint
(Node
));
1539 when N_Discriminant_Association
=>
1542 if Present
(Selector_Names
(Node
)) then
1543 Sprint_Bar_List
(Selector_Names
(Node
));
1548 Sprint_Node
(Expression
(Node
));
1550 when N_Discriminant_Specification
=>
1553 if Write_Identifiers
(Node
) then
1556 if Null_Exclusion_Present
(Node
) then
1557 Write_Str
("not null ");
1560 Sprint_Node
(Discriminant_Type
(Node
));
1562 if Present
(Expression
(Node
)) then
1564 Sprint_Node
(Expression
(Node
));
1570 when N_Elsif_Part
=>
1571 Write_Indent_Str_Sloc
("elsif ");
1572 Sprint_Node
(Condition
(Node
));
1573 Write_Str_With_Col_Check
(" then");
1574 Sprint_Indented_List
(Then_Statements
(Node
));
1579 when N_Entry_Body
=>
1580 Write_Indent_Str_Sloc
("entry ");
1581 Write_Id
(Defining_Identifier
(Node
));
1582 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1583 Write_Str_With_Col_Check
(" is");
1584 Sprint_Indented_List
(Declarations
(Node
));
1585 Write_Indent_Str
("begin");
1586 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1587 Write_Indent_Str
("end ");
1588 Write_Id
(Defining_Identifier
(Node
));
1591 when N_Entry_Body_Formal_Part
=>
1592 if Present
(Entry_Index_Specification
(Node
)) then
1593 Write_Str_With_Col_Check_Sloc
(" (");
1594 Sprint_Node
(Entry_Index_Specification
(Node
));
1598 Write_Param_Specs
(Node
);
1599 Write_Str_With_Col_Check_Sloc
(" when ");
1600 Sprint_Node
(Condition
(Node
));
1602 when N_Entry_Call_Alternative
=>
1603 Sprint_Node_List
(Pragmas_Before
(Node
));
1604 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1605 Sprint_Node_List
(Statements
(Node
));
1607 when N_Entry_Call_Statement
=>
1609 Sprint_Node_Sloc
(Name
(Node
));
1610 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1613 when N_Entry_Declaration
=>
1614 Write_Indent_Str_Sloc
("entry ");
1615 Write_Id
(Defining_Identifier
(Node
));
1617 if Present
(Discrete_Subtype_Definition
(Node
)) then
1618 Write_Str_With_Col_Check
(" (");
1619 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1623 Write_Param_Specs
(Node
);
1626 when N_Entry_Index_Specification
=>
1627 Write_Str_With_Col_Check_Sloc
("for ");
1628 Write_Id
(Defining_Identifier
(Node
));
1629 Write_Str_With_Col_Check
(" in ");
1630 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1632 when N_Enumeration_Representation_Clause
=>
1633 Write_Indent_Str_Sloc
("for ");
1634 Write_Id
(Identifier
(Node
));
1635 Write_Str_With_Col_Check
(" use ");
1636 Sprint_Node
(Array_Aggregate
(Node
));
1639 when N_Enumeration_Type_Definition
=>
1642 -- Skip attempt to print Literals field if it's not there and
1643 -- we are in package Standard (case of Character, which is
1644 -- handled specially (without an explicit literals list).
1646 if Sloc
(Node
) > Standard_Location
1647 or else Present
(Literals
(Node
))
1649 Sprint_Paren_Comma_List
(Literals
(Node
));
1653 Write_Str_With_Col_Check_Sloc
("<error>");
1655 when N_Exception_Declaration
=>
1656 if Write_Indent_Identifiers
(Node
) then
1657 Write_Str_With_Col_Check
(" : ");
1659 if Is_Statically_Allocated
(Defining_Identifier
(Node
)) then
1660 Write_Str_With_Col_Check
("static ");
1663 Write_Str_Sloc
("exception");
1665 if Present
(Expression
(Node
)) then
1667 Sprint_Node
(Expression
(Node
));
1673 when N_Exception_Handler
=>
1674 Write_Indent_Str_Sloc
("when ");
1676 if Present
(Choice_Parameter
(Node
)) then
1677 Sprint_Node
(Choice_Parameter
(Node
));
1681 Sprint_Bar_List
(Exception_Choices
(Node
));
1683 Sprint_Indented_List
(Statements
(Node
));
1685 when N_Exception_Renaming_Declaration
=>
1688 Sprint_Node
(Defining_Identifier
(Node
));
1689 Write_Str_With_Col_Check
(" : exception renames ");
1690 Sprint_Node
(Name
(Node
));
1693 when N_Exit_Statement
=>
1694 Write_Indent_Str_Sloc
("exit");
1695 Sprint_Opt_Node
(Name
(Node
));
1697 if Present
(Condition
(Node
)) then
1698 Write_Str_With_Col_Check
(" when ");
1699 Sprint_Node
(Condition
(Node
));
1704 when N_Expanded_Name
=>
1705 Sprint_Node
(Prefix
(Node
));
1706 Write_Char_Sloc
('.');
1707 Sprint_Node
(Selector_Name
(Node
));
1709 when N_Explicit_Dereference
=>
1710 Sprint_Node
(Prefix
(Node
));
1711 Write_Char_Sloc
('.');
1712 Write_Str_Sloc
("all");
1714 when N_Expression_With_Actions
=>
1716 Write_Indent_Str_Sloc
("do ");
1718 Sprint_Node_List
(Actions
(Node
));
1721 Write_Str_With_Col_Check_Sloc
("in ");
1722 Sprint_Node
(Expression
(Node
));
1723 Write_Str_With_Col_Check
(" end");
1727 when N_Expression_Function
=>
1729 Sprint_Node_Sloc
(Specification
(Node
));
1733 Sprint_Node
(Expression
(Node
));
1737 when N_Extended_Return_Statement
=>
1738 Write_Indent_Str_Sloc
("return ");
1739 Sprint_Node_List
(Return_Object_Declarations
(Node
));
1741 if Present
(Handled_Statement_Sequence
(Node
)) then
1742 Write_Str_With_Col_Check
(" do");
1743 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1744 Write_Indent_Str
("end return;");
1746 Write_Indent_Str
(";");
1749 when N_Extension_Aggregate
=>
1750 Write_Str_With_Col_Check_Sloc
("(");
1751 Sprint_Node
(Ancestor_Part
(Node
));
1752 Write_Str_With_Col_Check
(" with ");
1754 if Null_Record_Present
(Node
) then
1755 Write_Str_With_Col_Check
("null record");
1757 if Present
(Expressions
(Node
)) then
1758 Sprint_Comma_List
(Expressions
(Node
));
1760 if Present
(Component_Associations
(Node
)) then
1765 if Present
(Component_Associations
(Node
)) then
1766 Sprint_Comma_List
(Component_Associations
(Node
));
1772 when N_Floating_Point_Definition
=>
1773 Write_Str_With_Col_Check_Sloc
("digits ");
1774 Sprint_Node
(Digits_Expression
(Node
));
1775 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1777 when N_Formal_Decimal_Fixed_Point_Definition
=>
1778 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1780 when N_Formal_Derived_Type_Definition
=>
1781 Write_Str_With_Col_Check_Sloc
("new ");
1782 Sprint_Node
(Subtype_Mark
(Node
));
1784 if Present
(Interface_List
(Node
)) then
1785 Write_Str_With_Col_Check
(" and ");
1786 Sprint_And_List
(Interface_List
(Node
));
1789 if Private_Present
(Node
) then
1790 Write_Str_With_Col_Check
(" with private");
1793 when N_Formal_Abstract_Subprogram_Declaration
=>
1794 Write_Indent_Str_Sloc
("with ");
1795 Sprint_Node
(Specification
(Node
));
1797 Write_Str_With_Col_Check
(" is abstract");
1799 if Box_Present
(Node
) then
1800 Write_Str_With_Col_Check
(" <>");
1801 elsif Present
(Default_Name
(Node
)) then
1802 Write_Str_With_Col_Check
(" ");
1803 Sprint_Node
(Default_Name
(Node
));
1808 when N_Formal_Concrete_Subprogram_Declaration
=>
1809 Write_Indent_Str_Sloc
("with ");
1810 Sprint_Node
(Specification
(Node
));
1812 if Box_Present
(Node
) then
1813 Write_Str_With_Col_Check
(" is <>");
1814 elsif Present
(Default_Name
(Node
)) then
1815 Write_Str_With_Col_Check
(" is ");
1816 Sprint_Node
(Default_Name
(Node
));
1821 when N_Formal_Discrete_Type_Definition
=>
1822 Write_Str_With_Col_Check_Sloc
("<>");
1824 when N_Formal_Floating_Point_Definition
=>
1825 Write_Str_With_Col_Check_Sloc
("digits <>");
1827 when N_Formal_Modular_Type_Definition
=>
1828 Write_Str_With_Col_Check_Sloc
("mod <>");
1830 when N_Formal_Object_Declaration
=>
1833 if Write_Indent_Identifiers
(Node
) then
1836 if In_Present
(Node
) then
1837 Write_Str_With_Col_Check
("in ");
1840 if Out_Present
(Node
) then
1841 Write_Str_With_Col_Check
("out ");
1844 if Present
(Subtype_Mark
(Node
)) then
1846 -- Ada 2005 (AI-423): Formal object with null exclusion
1848 if Null_Exclusion_Present
(Node
) then
1849 Write_Str
("not null ");
1852 Sprint_Node
(Subtype_Mark
(Node
));
1854 -- Ada 2005 (AI-423): Formal object with access definition
1857 pragma Assert
(Present
(Access_Definition
(Node
)));
1859 Sprint_Node
(Access_Definition
(Node
));
1862 if Present
(Default_Expression
(Node
)) then
1864 Sprint_Node
(Default_Expression
(Node
));
1870 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1871 Write_Str_With_Col_Check_Sloc
("delta <>");
1873 when N_Formal_Package_Declaration
=>
1874 Write_Indent_Str_Sloc
("with package ");
1875 Write_Id
(Defining_Identifier
(Node
));
1876 Write_Str_With_Col_Check
(" is new ");
1877 Sprint_Node
(Name
(Node
));
1878 Write_Str_With_Col_Check
(" (<>);");
1880 when N_Formal_Private_Type_Definition
=>
1881 if Abstract_Present
(Node
) then
1882 Write_Str_With_Col_Check
("abstract ");
1885 if Tagged_Present
(Node
) then
1886 Write_Str_With_Col_Check
("tagged ");
1889 if Limited_Present
(Node
) then
1890 Write_Str_With_Col_Check
("limited ");
1893 Write_Str_With_Col_Check_Sloc
("private");
1895 when N_Formal_Incomplete_Type_Definition
=>
1896 if Tagged_Present
(Node
) then
1897 Write_Str_With_Col_Check
("is tagged ");
1900 when N_Formal_Signed_Integer_Type_Definition
=>
1901 Write_Str_With_Col_Check_Sloc
("range <>");
1903 when N_Formal_Type_Declaration
=>
1904 Write_Indent_Str_Sloc
("type ");
1905 Write_Id
(Defining_Identifier
(Node
));
1907 if Present
(Discriminant_Specifications
(Node
)) then
1908 Write_Discr_Specs
(Node
);
1909 elsif Unknown_Discriminants_Present
(Node
) then
1910 Write_Str_With_Col_Check
("(<>)");
1913 if Nkind
(Formal_Type_Definition
(Node
)) /=
1914 N_Formal_Incomplete_Type_Definition
1916 Write_Str_With_Col_Check
(" is ");
1919 Sprint_Node
(Formal_Type_Definition
(Node
));
1922 when N_Free_Statement
=>
1923 Write_Indent_Str_Sloc
("free ");
1924 Sprint_Node
(Expression
(Node
));
1927 when N_Freeze_Entity
=>
1928 if Dump_Original_Only
then
1931 -- A freeze node is output if it has some effect (i.e. non-empty
1932 -- actions, or freeze node for an itype, which causes elaboration
1933 -- of the itype), and is also always output if Dump_Freeze_Null
1936 elsif Present
(Actions
(Node
))
1937 or else Is_Itype
(Entity
(Node
))
1938 or else Dump_Freeze_Null
1941 Write_Rewrite_Str
("<<<");
1942 Write_Str_With_Col_Check_Sloc
("freeze ");
1943 Write_Id
(Entity
(Node
));
1946 if No
(Actions
(Node
)) then
1950 -- Output freeze actions. We increment Freeze_Indent during
1951 -- this output to avoid generating extra blank lines before
1952 -- any procedures included in the freeze actions.
1954 Freeze_Indent
:= Freeze_Indent
+ 1;
1955 Sprint_Indented_List
(Actions
(Node
));
1956 Freeze_Indent
:= Freeze_Indent
- 1;
1957 Write_Indent_Str
("]");
1960 Write_Rewrite_Str
(">>>");
1963 when N_Freeze_Generic_Entity
=>
1964 if Dump_Original_Only
then
1969 Write_Str_With_Col_Check_Sloc
("freeze_generic ");
1970 Write_Id
(Entity
(Node
));
1973 when N_Full_Type_Declaration
=>
1974 Write_Indent_Str_Sloc
("type ");
1975 Sprint_Node
(Defining_Identifier
(Node
));
1976 Write_Discr_Specs
(Node
);
1977 Write_Str_With_Col_Check
(" is ");
1978 Sprint_Node
(Type_Definition
(Node
));
1981 when N_Function_Call
=>
1983 Write_Subprogram_Name
(Name
(Node
));
1984 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1986 when N_Function_Instantiation
=>
1987 Write_Indent_Str_Sloc
("function ");
1988 Sprint_Node
(Defining_Unit_Name
(Node
));
1989 Write_Str_With_Col_Check
(" is new ");
1990 Sprint_Node
(Name
(Node
));
1991 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1994 when N_Function_Specification
=>
1995 Write_Str_With_Col_Check_Sloc
("function ");
1996 Sprint_Node
(Defining_Unit_Name
(Node
));
1997 Write_Param_Specs
(Node
);
1998 Write_Str_With_Col_Check
(" return ");
2000 -- Ada 2005 (AI-231)
2002 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
2003 and then Null_Exclusion_Present
(Node
)
2005 Write_Str
(" not null ");
2008 Sprint_Node
(Result_Definition
(Node
));
2010 when N_Generic_Association
=>
2013 if Present
(Selector_Name
(Node
)) then
2014 Sprint_Node
(Selector_Name
(Node
));
2018 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
2020 when N_Generic_Function_Renaming_Declaration
=>
2021 Write_Indent_Str_Sloc
("generic function ");
2022 Sprint_Node
(Defining_Unit_Name
(Node
));
2023 Write_Str_With_Col_Check
(" renames ");
2024 Sprint_Node
(Name
(Node
));
2027 when N_Generic_Package_Declaration
=>
2029 Write_Indent_Str_Sloc
("generic ");
2030 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
2032 Sprint_Node
(Specification
(Node
));
2035 when N_Generic_Package_Renaming_Declaration
=>
2036 Write_Indent_Str_Sloc
("generic package ");
2037 Sprint_Node
(Defining_Unit_Name
(Node
));
2038 Write_Str_With_Col_Check
(" renames ");
2039 Sprint_Node
(Name
(Node
));
2042 when N_Generic_Procedure_Renaming_Declaration
=>
2043 Write_Indent_Str_Sloc
("generic procedure ");
2044 Sprint_Node
(Defining_Unit_Name
(Node
));
2045 Write_Str_With_Col_Check
(" renames ");
2046 Sprint_Node
(Name
(Node
));
2049 when N_Generic_Subprogram_Declaration
=>
2051 Write_Indent_Str_Sloc
("generic ");
2052 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
2054 Sprint_Node
(Specification
(Node
));
2057 when N_Goto_Statement
=>
2058 Write_Indent_Str_Sloc
("goto ");
2059 Sprint_Node
(Name
(Node
));
2062 if Nkind
(Next
(Node
)) = N_Label
then
2066 when N_Handled_Sequence_Of_Statements
=>
2068 Sprint_Indented_List
(Statements
(Node
));
2070 if Present
(Exception_Handlers
(Node
)) then
2071 Write_Indent_Str
("exception");
2073 Sprint_Node_List
(Exception_Handlers
(Node
));
2077 if Present
(At_End_Proc
(Node
)) then
2078 Write_Indent_Str
("at end");
2081 Sprint_Node
(At_End_Proc
(Node
));
2086 when N_Identifier
=>
2090 when N_If_Expression
=>
2092 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
2093 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
2094 Then_Expr
: constant Node_Id
:= Next
(Condition
);
2097 -- The syntax for if_expression does not include parentheses,
2098 -- but sometimes parentheses are required, so unconditionally
2099 -- generate them here unless already present.
2101 if not Has_Parens
then
2105 Write_Str_With_Col_Check_Sloc
("if ");
2106 Sprint_Node
(Condition
);
2107 Write_Str_With_Col_Check
(" then ");
2109 -- Defense against junk here
2111 if Present
(Then_Expr
) then
2112 Sprint_Node
(Then_Expr
);
2114 if Present
(Next
(Then_Expr
)) then
2115 Write_Str_With_Col_Check
(" else ");
2116 Sprint_Node
(Next
(Then_Expr
));
2120 if not Has_Parens
then
2125 when N_If_Statement
=>
2126 Write_Indent_Str_Sloc
("if ");
2127 Sprint_Node
(Condition
(Node
));
2128 Write_Str_With_Col_Check
(" then");
2129 Sprint_Indented_List
(Then_Statements
(Node
));
2130 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
2132 if Present
(Else_Statements
(Node
)) then
2133 Write_Indent_Str
("else");
2134 Sprint_Indented_List
(Else_Statements
(Node
));
2137 Write_Indent_Str
("end if;");
2139 when N_Implicit_Label_Declaration
=>
2140 if not Dump_Original_Only
then
2142 Write_Rewrite_Str
("<<<");
2144 Write_Id
(Defining_Identifier
(Node
));
2146 Write_Str_With_Col_Check
("label");
2147 Write_Rewrite_Str
(">>>");
2151 Sprint_Left_Opnd
(Node
);
2152 Write_Str_Sloc
(" in ");
2154 if Present
(Right_Opnd
(Node
)) then
2155 Sprint_Right_Opnd
(Node
);
2157 Sprint_Bar_List
(Alternatives
(Node
));
2160 when N_Incomplete_Type_Declaration
=>
2161 Write_Indent_Str_Sloc
("type ");
2162 Write_Id
(Defining_Identifier
(Node
));
2164 if Present
(Discriminant_Specifications
(Node
)) then
2165 Write_Discr_Specs
(Node
);
2166 elsif Unknown_Discriminants_Present
(Node
) then
2167 Write_Str_With_Col_Check
("(<>)");
2172 when N_Index_Or_Discriminant_Constraint
=>
2174 Sprint_Paren_Comma_List
(Constraints
(Node
));
2176 when N_Indexed_Component
=>
2177 Sprint_Node_Sloc
(Prefix
(Node
));
2178 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
2180 when N_Integer_Literal
=>
2181 if Print_In_Hex
(Node
) then
2182 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
2184 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
2187 when N_Iteration_Scheme
=>
2188 if Present
(Condition
(Node
)) then
2189 Write_Str_With_Col_Check_Sloc
("while ");
2190 Sprint_Node
(Condition
(Node
));
2192 Write_Str_With_Col_Check_Sloc
("for ");
2194 if Present
(Iterator_Specification
(Node
)) then
2195 Sprint_Node
(Iterator_Specification
(Node
));
2197 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2203 when N_Iterator_Specification
=>
2205 Write_Id
(Defining_Identifier
(Node
));
2207 if Present
(Subtype_Indication
(Node
)) then
2208 Write_Str_With_Col_Check
(" : ");
2209 Sprint_Node
(Subtype_Indication
(Node
));
2212 if Of_Present
(Node
) then
2213 Write_Str_With_Col_Check
(" of ");
2215 Write_Str_With_Col_Check
(" in ");
2218 if Reverse_Present
(Node
) then
2219 Write_Str_With_Col_Check
("reverse ");
2222 Sprint_Node
(Name
(Node
));
2224 when N_Itype_Reference
=>
2225 Write_Indent_Str_Sloc
("reference ");
2226 Write_Id
(Itype
(Node
));
2229 Write_Indent_Str_Sloc
("<<");
2230 Write_Id
(Identifier
(Node
));
2233 when N_Loop_Parameter_Specification
=>
2235 Write_Id
(Defining_Identifier
(Node
));
2236 Write_Str_With_Col_Check
(" in ");
2238 if Reverse_Present
(Node
) then
2239 Write_Str_With_Col_Check
("reverse ");
2242 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
2244 when N_Loop_Statement
=>
2247 if Present
(Identifier
(Node
))
2248 and then (not Has_Created_Identifier
(Node
)
2249 or else not Dump_Original_Only
)
2251 Write_Rewrite_Str
("<<<");
2252 Write_Id
(Identifier
(Node
));
2254 Write_Rewrite_Str
(">>>");
2255 Sprint_Node
(Iteration_Scheme
(Node
));
2256 Write_Str_With_Col_Check_Sloc
("loop");
2257 Sprint_Indented_List
(Statements
(Node
));
2258 Write_Indent_Str
("end loop ");
2259 Write_Rewrite_Str
("<<<");
2260 Write_Id
(Identifier
(Node
));
2261 Write_Rewrite_Str
(">>>");
2265 Sprint_Node
(Iteration_Scheme
(Node
));
2266 Write_Str_With_Col_Check_Sloc
("loop");
2267 Sprint_Indented_List
(Statements
(Node
));
2268 Write_Indent_Str
("end loop;");
2271 when N_Mod_Clause
=>
2272 Sprint_Node_List
(Pragmas_Before
(Node
));
2273 Write_Str_With_Col_Check_Sloc
("at mod ");
2274 Sprint_Node
(Expression
(Node
));
2276 when N_Modular_Type_Definition
=>
2277 Write_Str_With_Col_Check_Sloc
("mod ");
2278 Sprint_Node
(Expression
(Node
));
2281 Sprint_Left_Opnd
(Node
);
2282 Write_Str_Sloc
(" not in ");
2284 if Present
(Right_Opnd
(Node
)) then
2285 Sprint_Right_Opnd
(Node
);
2287 Sprint_Bar_List
(Alternatives
(Node
));
2291 Write_Str_With_Col_Check_Sloc
("null");
2293 when N_Null_Statement
=>
2294 if Comes_From_Source
(Node
)
2295 or else Dump_Freeze_Null
2296 or else not Is_List_Member
(Node
)
2297 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
2299 Write_Indent_Str_Sloc
("null;");
2302 when N_Number_Declaration
=>
2305 if Write_Indent_Identifiers
(Node
) then
2306 Write_Str_With_Col_Check
(" : constant ");
2308 Sprint_Node
(Expression
(Node
));
2312 when N_Object_Declaration
=>
2315 if Write_Indent_Identifiers
(Node
) then
2317 Def_Id
: constant Entity_Id
:= Defining_Identifier
(Node
);
2320 Write_Str_With_Col_Check
(" : ");
2322 if Is_Statically_Allocated
(Def_Id
) then
2323 Write_Str_With_Col_Check
("static ");
2326 if Aliased_Present
(Node
) then
2327 Write_Str_With_Col_Check
("aliased ");
2330 if Constant_Present
(Node
) then
2331 Write_Str_With_Col_Check
("constant ");
2334 -- Ada 2005 (AI-231)
2336 if Null_Exclusion_Present
(Node
) then
2337 Write_Str_With_Col_Check
("not null ");
2340 -- Print type. We used to print the Object_Definition from
2341 -- the node, but it is much more useful to print the Etype
2342 -- of the defining identifier for the case where the nominal
2343 -- type is an unconstrained array type. For example, this
2344 -- will be a clear reference to the Itype with the bounds
2345 -- in the case of a type like String. The object after
2346 -- all is constrained, even if its nominal subtype is
2350 Odef
: constant Node_Id
:= Object_Definition
(Node
);
2353 if Nkind
(Odef
) = N_Identifier
2354 and then Present
(Etype
(Odef
))
2355 and then Is_Array_Type
(Etype
(Odef
))
2356 and then not Is_Constrained
(Etype
(Odef
))
2357 and then Present
(Etype
(Def_Id
))
2359 Sprint_Node
(Etype
(Def_Id
));
2361 -- In other cases, the nominal type is fine to print
2368 if Present
(Expression
(Node
)) then
2370 Sprint_Node
(Expression
(Node
));
2375 -- Handle implicit importation and implicit exportation of
2376 -- object declarations:
2377 -- $pragma import (Convention_Id, Def_Id, "...");
2378 -- $pragma export (Convention_Id, Def_Id, "...");
2380 if Is_Internal
(Def_Id
)
2381 and then Present
(Interface_Name
(Def_Id
))
2383 Write_Indent_Str_Sloc
("$pragma ");
2385 if Is_Imported
(Def_Id
) then
2386 Write_Str
("import (");
2388 else pragma Assert
(Is_Exported
(Def_Id
));
2389 Write_Str
("export (");
2393 Prefix
: constant String := "Convention_";
2394 S
: constant String := Convention
(Def_Id
)'Img;
2397 Name_Len
:= S
'Last - Prefix
'Last;
2398 Name_Buffer
(1 .. Name_Len
) :=
2399 S
(Prefix
'Last + 1 .. S
'Last);
2400 Set_Casing
(All_Lower_Case
);
2401 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2407 Write_String_Table_Entry
2408 (Strval
(Interface_Name
(Def_Id
)));
2414 when N_Object_Renaming_Declaration
=>
2417 Sprint_Node
(Defining_Identifier
(Node
));
2420 -- Ada 2005 (AI-230): Access renamings
2422 if Present
(Access_Definition
(Node
)) then
2423 Sprint_Node
(Access_Definition
(Node
));
2425 elsif Present
(Subtype_Mark
(Node
)) then
2427 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2429 if Null_Exclusion_Present
(Node
) then
2430 Write_Str
("not null ");
2433 Sprint_Node
(Subtype_Mark
(Node
));
2436 Write_Str
(" ??? ");
2439 Write_Str_With_Col_Check
(" renames ");
2440 Sprint_Node
(Name
(Node
));
2444 Write_Operator
(Node
, "abs ");
2445 Sprint_Right_Opnd
(Node
);
2448 Sprint_Left_Opnd
(Node
);
2449 Write_Operator
(Node
, " + ");
2450 Sprint_Right_Opnd
(Node
);
2453 Sprint_Left_Opnd
(Node
);
2454 Write_Operator
(Node
, " and ");
2455 Sprint_Right_Opnd
(Node
);
2458 Sprint_Left_Opnd
(Node
);
2459 Write_Operator
(Node
, " & ");
2460 Sprint_Right_Opnd
(Node
);
2463 Sprint_Left_Opnd
(Node
);
2465 Process_TFAI_RR_Flags
(Node
);
2466 Write_Operator
(Node
, "/ ");
2467 Sprint_Right_Opnd
(Node
);
2470 Sprint_Left_Opnd
(Node
);
2471 Write_Operator
(Node
, " = ");
2472 Sprint_Right_Opnd
(Node
);
2475 Sprint_Left_Opnd
(Node
);
2476 Write_Operator
(Node
, " ** ");
2477 Sprint_Right_Opnd
(Node
);
2480 Sprint_Left_Opnd
(Node
);
2481 Write_Operator
(Node
, " >= ");
2482 Sprint_Right_Opnd
(Node
);
2485 Sprint_Left_Opnd
(Node
);
2486 Write_Operator
(Node
, " > ");
2487 Sprint_Right_Opnd
(Node
);
2490 Sprint_Left_Opnd
(Node
);
2491 Write_Operator
(Node
, " <= ");
2492 Sprint_Right_Opnd
(Node
);
2495 Sprint_Left_Opnd
(Node
);
2496 Write_Operator
(Node
, " < ");
2497 Sprint_Right_Opnd
(Node
);
2500 Write_Operator
(Node
, "-");
2501 Sprint_Right_Opnd
(Node
);
2504 Sprint_Left_Opnd
(Node
);
2506 if Treat_Fixed_As_Integer
(Node
) then
2510 Write_Operator
(Node
, " mod ");
2511 Sprint_Right_Opnd
(Node
);
2513 when N_Op_Multiply
=>
2514 Sprint_Left_Opnd
(Node
);
2516 Process_TFAI_RR_Flags
(Node
);
2517 Write_Operator
(Node
, "* ");
2518 Sprint_Right_Opnd
(Node
);
2521 Sprint_Left_Opnd
(Node
);
2522 Write_Operator
(Node
, " /= ");
2523 Sprint_Right_Opnd
(Node
);
2526 Write_Operator
(Node
, "not ");
2527 Sprint_Right_Opnd
(Node
);
2530 Sprint_Left_Opnd
(Node
);
2531 Write_Operator
(Node
, " or ");
2532 Sprint_Right_Opnd
(Node
);
2535 Write_Operator
(Node
, "+");
2536 Sprint_Right_Opnd
(Node
);
2539 Sprint_Left_Opnd
(Node
);
2541 if Treat_Fixed_As_Integer
(Node
) then
2545 Write_Operator
(Node
, " rem ");
2546 Sprint_Right_Opnd
(Node
);
2552 Write_Str_With_Col_Check
("(");
2553 Sprint_Node
(Left_Opnd
(Node
));
2555 Sprint_Node
(Right_Opnd
(Node
));
2558 when N_Op_Subtract
=>
2559 Sprint_Left_Opnd
(Node
);
2560 Write_Operator
(Node
, " - ");
2561 Sprint_Right_Opnd
(Node
);
2564 Sprint_Left_Opnd
(Node
);
2565 Write_Operator
(Node
, " xor ");
2566 Sprint_Right_Opnd
(Node
);
2568 when N_Operator_Symbol
=>
2569 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
2571 when N_Ordinary_Fixed_Point_Definition
=>
2572 Write_Str_With_Col_Check_Sloc
("delta ");
2573 Sprint_Node
(Delta_Expression
(Node
));
2574 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
2577 Sprint_Left_Opnd
(Node
);
2578 Write_Str_Sloc
(" or else ");
2579 Sprint_Right_Opnd
(Node
);
2581 when N_Others_Choice
=>
2582 if All_Others
(Node
) then
2583 Write_Str_With_Col_Check
("all ");
2586 Write_Str_With_Col_Check_Sloc
("others");
2588 when N_Package_Body
=>
2590 Write_Indent_Str_Sloc
("package body ");
2591 Sprint_Node
(Defining_Unit_Name
(Node
));
2593 Sprint_Indented_List
(Declarations
(Node
));
2595 if Present
(Handled_Statement_Sequence
(Node
)) then
2596 Write_Indent_Str
("begin");
2597 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2600 Write_Indent_Str
("end ");
2602 (Handled_Statement_Sequence
(Node
), Defining_Unit_Name
(Node
));
2605 when N_Package_Body_Stub
=>
2606 Write_Indent_Str_Sloc
("package body ");
2607 Sprint_Node
(Defining_Identifier
(Node
));
2608 Write_Str_With_Col_Check
(" is separate;");
2610 when N_Package_Declaration
=>
2613 Sprint_Node_Sloc
(Specification
(Node
));
2616 -- If this is an instantiation, get the aspects from the original
2617 -- instantiation node.
2619 if Is_Generic_Instance
(Defining_Entity
(Node
))
2620 and then Has_Aspects
2621 (Package_Instantiation
(Defining_Entity
(Node
)))
2623 Sprint_Aspect_Specifications
2624 (Package_Instantiation
(Defining_Entity
(Node
)),
2628 when N_Package_Instantiation
=>
2630 Write_Indent_Str_Sloc
("package ");
2631 Sprint_Node
(Defining_Unit_Name
(Node
));
2632 Write_Str
(" is new ");
2633 Sprint_Node
(Name
(Node
));
2634 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2637 when N_Package_Renaming_Declaration
=>
2638 Write_Indent_Str_Sloc
("package ");
2639 Sprint_Node
(Defining_Unit_Name
(Node
));
2640 Write_Str_With_Col_Check
(" renames ");
2641 Sprint_Node
(Name
(Node
));
2644 when N_Package_Specification
=>
2645 Write_Str_With_Col_Check_Sloc
("package ");
2646 Sprint_Node
(Defining_Unit_Name
(Node
));
2648 if Nkind
(Parent
(Node
)) = N_Generic_Package_Declaration
2649 and then Has_Aspects
(Parent
(Node
))
2651 Sprint_Aspect_Specifications
2652 (Parent
(Node
), Semicolon
=> False);
2654 -- An instantiation is rewritten as a package declaration, but
2655 -- the aspects belong to the instantiation node.
2657 elsif Nkind
(Parent
(Node
)) = N_Package_Declaration
then
2659 Pack
: constant Entity_Id
:= Defining_Entity
(Node
);
2662 if not Is_Generic_Instance
(Pack
) then
2663 if Has_Aspects
(Parent
(Node
)) then
2664 Sprint_Aspect_Specifications
2665 (Parent
(Node
), Semicolon
=> False);
2672 Sprint_Indented_List
(Visible_Declarations
(Node
));
2674 if Present
(Private_Declarations
(Node
)) then
2675 Write_Indent_Str
("private");
2676 Sprint_Indented_List
(Private_Declarations
(Node
));
2679 Write_Indent_Str
("end ");
2680 Sprint_Node
(Defining_Unit_Name
(Node
));
2682 when N_Parameter_Association
=>
2683 Sprint_Node_Sloc
(Selector_Name
(Node
));
2685 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2687 when N_Parameter_Specification
=>
2690 if Write_Identifiers
(Node
) then
2693 if In_Present
(Node
) then
2694 Write_Str_With_Col_Check
("in ");
2697 if Out_Present
(Node
) then
2698 Write_Str_With_Col_Check
("out ");
2701 -- Ada 2005 (AI-231): Parameter specification may carry null
2702 -- exclusion. Do not print it now if this is an access formal,
2703 -- it is emitted when the access definition is displayed.
2705 if Null_Exclusion_Present
(Node
)
2706 and then Nkind
(Parameter_Type
(Node
))
2707 /= N_Access_Definition
2709 Write_Str
("not null ");
2712 Sprint_Node
(Parameter_Type
(Node
));
2714 if Present
(Expression
(Node
)) then
2716 Sprint_Node
(Expression
(Node
));
2722 when N_Pop_Constraint_Error_Label
=>
2723 Write_Indent_Str
("%pop_constraint_error_label");
2725 when N_Pop_Program_Error_Label
=>
2726 Write_Indent_Str
("%pop_program_error_label");
2728 when N_Pop_Storage_Error_Label
=>
2729 Write_Indent_Str
("%pop_storage_error_label");
2731 when N_Private_Extension_Declaration
=>
2732 Write_Indent_Str_Sloc
("type ");
2733 Write_Id
(Defining_Identifier
(Node
));
2735 if Present
(Discriminant_Specifications
(Node
)) then
2736 Write_Discr_Specs
(Node
);
2737 elsif Unknown_Discriminants_Present
(Node
) then
2738 Write_Str_With_Col_Check
("(<>)");
2741 Write_Str_With_Col_Check
(" is new ");
2742 Sprint_Node
(Subtype_Indication
(Node
));
2744 if Present
(Interface_List
(Node
)) then
2745 Write_Str_With_Col_Check
(" and ");
2746 Sprint_And_List
(Interface_List
(Node
));
2749 Write_Str_With_Col_Check
(" with private;");
2751 when N_Private_Type_Declaration
=>
2752 Write_Indent_Str_Sloc
("type ");
2753 Write_Id
(Defining_Identifier
(Node
));
2755 if Present
(Discriminant_Specifications
(Node
)) then
2756 Write_Discr_Specs
(Node
);
2757 elsif Unknown_Discriminants_Present
(Node
) then
2758 Write_Str_With_Col_Check
("(<>)");
2763 if Tagged_Present
(Node
) then
2764 Write_Str_With_Col_Check
("tagged ");
2767 if Limited_Present
(Node
) then
2768 Write_Str_With_Col_Check
("limited ");
2771 Write_Str_With_Col_Check
("private;");
2773 when N_Push_Constraint_Error_Label
=>
2774 Write_Indent_Str
("%push_constraint_error_label (");
2776 if Present
(Exception_Label
(Node
)) then
2777 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2782 when N_Push_Program_Error_Label
=>
2783 Write_Indent_Str
("%push_program_error_label (");
2785 if Present
(Exception_Label
(Node
)) then
2786 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2791 when N_Push_Storage_Error_Label
=>
2792 Write_Indent_Str
("%push_storage_error_label (");
2794 if Present
(Exception_Label
(Node
)) then
2795 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2801 Write_Indent_Str_Sloc
("pragma ");
2802 Write_Name_With_Col_Check
(Pragma_Name
(Node
));
2804 if Present
(Pragma_Argument_Associations
(Node
)) then
2805 Sprint_Opt_Paren_Comma_List
2806 (Pragma_Argument_Associations
(Node
));
2811 when N_Pragma_Argument_Association
=>
2814 if Chars
(Node
) /= No_Name
then
2815 Write_Name_With_Col_Check
(Chars
(Node
));
2819 Sprint_Node
(Expression
(Node
));
2821 when N_Procedure_Call_Statement
=>
2824 Write_Subprogram_Name
(Name
(Node
));
2825 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2828 when N_Procedure_Instantiation
=>
2829 Write_Indent_Str_Sloc
("procedure ");
2830 Sprint_Node
(Defining_Unit_Name
(Node
));
2831 Write_Str_With_Col_Check
(" is new ");
2832 Sprint_Node
(Name
(Node
));
2833 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2836 when N_Procedure_Specification
=>
2837 Write_Str_With_Col_Check_Sloc
("procedure ");
2838 Sprint_Node
(Defining_Unit_Name
(Node
));
2839 Write_Param_Specs
(Node
);
2841 when N_Protected_Body
=>
2842 Write_Indent_Str_Sloc
("protected body ");
2843 Write_Id
(Defining_Identifier
(Node
));
2845 Sprint_Indented_List
(Declarations
(Node
));
2846 Write_Indent_Str
("end ");
2847 Write_Id
(Defining_Identifier
(Node
));
2850 when N_Protected_Body_Stub
=>
2851 Write_Indent_Str_Sloc
("protected body ");
2852 Write_Id
(Defining_Identifier
(Node
));
2853 Write_Str_With_Col_Check
(" is separate;");
2855 when N_Protected_Definition
=>
2857 Sprint_Indented_List
(Visible_Declarations
(Node
));
2859 if Present
(Private_Declarations
(Node
)) then
2860 Write_Indent_Str
("private");
2861 Sprint_Indented_List
(Private_Declarations
(Node
));
2864 Write_Indent_Str
("end ");
2866 when N_Protected_Type_Declaration
=>
2867 Write_Indent_Str_Sloc
("protected type ");
2868 Sprint_Node
(Defining_Identifier
(Node
));
2869 Write_Discr_Specs
(Node
);
2871 if Present
(Interface_List
(Node
)) then
2872 Write_Str
(" is new ");
2873 Sprint_And_List
(Interface_List
(Node
));
2874 Write_Str
(" with ");
2879 Sprint_Node
(Protected_Definition
(Node
));
2880 Write_Id
(Defining_Identifier
(Node
));
2883 when N_Qualified_Expression
=>
2884 Sprint_Node
(Subtype_Mark
(Node
));
2885 Write_Char_Sloc
(''');
2887 -- Print expression, make sure we have at least one level of
2888 -- parentheses around the expression. For cases of qualified
2889 -- expressions in the source, this is always the case, but
2890 -- for generated qualifications, there may be no explicit
2891 -- parentheses present.
2893 if Paren_Count
(Expression
(Node
)) /= 0 then
2894 Sprint_Node
(Expression
(Node
));
2898 Sprint_Node
(Expression
(Node
));
2900 -- Odd case, for the qualified expressions used in machine
2901 -- code the argument may be a procedure call, resulting in
2902 -- a junk semicolon before the right parent, get rid of it.
2904 Write_Erase_Char
(';');
2906 -- Now we can add the terminating right paren
2911 when N_Quantified_Expression
=>
2914 if All_Present
(Node
) then
2915 Write_Str
(" all ");
2917 Write_Str
(" some ");
2920 if Present
(Iterator_Specification
(Node
)) then
2921 Sprint_Node
(Iterator_Specification
(Node
));
2923 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2927 Sprint_Node
(Condition
(Node
));
2929 when N_Raise_Expression
=>
2931 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
2934 -- The syntax for raise_expression does not include parentheses
2935 -- but sometimes parentheses are required, so unconditionally
2936 -- generate them here unless already present.
2938 if not Has_Parens
then
2942 Write_Str_With_Col_Check_Sloc
("raise ");
2943 Sprint_Node
(Name
(Node
));
2945 if Present
(Expression
(Node
)) then
2946 Write_Str_With_Col_Check
(" with ");
2947 Sprint_Node
(Expression
(Node
));
2950 if not Has_Parens
then
2955 when N_Raise_Constraint_Error
=>
2957 -- This node can be used either as a subexpression or as a
2958 -- statement form. The following test is a reasonably reliable
2959 -- way to distinguish the two cases.
2961 if Is_List_Member
(Node
)
2962 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2967 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2968 Write_Condition_And_Reason
(Node
);
2970 when N_Raise_Program_Error
=>
2972 -- This node can be used either as a subexpression or as a
2973 -- statement form. The following test is a reasonably reliable
2974 -- way to distinguish the two cases.
2976 if Is_List_Member
(Node
)
2977 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2982 Write_Str_With_Col_Check_Sloc
("[program_error");
2983 Write_Condition_And_Reason
(Node
);
2985 when N_Raise_Storage_Error
=>
2987 -- This node can be used either as a subexpression or as a
2988 -- statement form. The following test is a reasonably reliable
2989 -- way to distinguish the two cases.
2991 if Is_List_Member
(Node
)
2992 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2997 Write_Str_With_Col_Check_Sloc
("[storage_error");
2998 Write_Condition_And_Reason
(Node
);
3000 when N_Raise_Statement
=>
3001 Write_Indent_Str_Sloc
("raise ");
3002 Sprint_Node
(Name
(Node
));
3004 if Present
(Expression
(Node
)) then
3005 Write_Str_With_Col_Check_Sloc
(" with ");
3006 Sprint_Node
(Expression
(Node
));
3012 Sprint_Node
(Low_Bound
(Node
));
3013 Write_Str_Sloc
(" .. ");
3014 Sprint_Node
(High_Bound
(Node
));
3015 Update_Itype
(Node
);
3017 when N_Range_Constraint
=>
3018 Write_Str_With_Col_Check_Sloc
("range ");
3019 Sprint_Node
(Range_Expression
(Node
));
3021 when N_Real_Literal
=>
3022 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
3024 when N_Real_Range_Specification
=>
3025 Write_Str_With_Col_Check_Sloc
("range ");
3026 Sprint_Node
(Low_Bound
(Node
));
3028 Sprint_Node
(High_Bound
(Node
));
3030 when N_Record_Definition
=>
3031 if Abstract_Present
(Node
) then
3032 Write_Str_With_Col_Check
("abstract ");
3035 if Tagged_Present
(Node
) then
3036 Write_Str_With_Col_Check
("tagged ");
3039 if Limited_Present
(Node
) then
3040 Write_Str_With_Col_Check
("limited ");
3043 if Null_Present
(Node
) then
3044 Write_Str_With_Col_Check_Sloc
("null record");
3047 Write_Str_With_Col_Check_Sloc
("record");
3048 Sprint_Node
(Component_List
(Node
));
3049 Write_Indent_Str
("end record");
3052 when N_Record_Representation_Clause
=>
3053 Write_Indent_Str_Sloc
("for ");
3054 Sprint_Node
(Identifier
(Node
));
3055 Write_Str_With_Col_Check
(" use record ");
3057 if Present
(Mod_Clause
(Node
)) then
3058 Sprint_Node
(Mod_Clause
(Node
));
3061 Sprint_Indented_List
(Component_Clauses
(Node
));
3062 Write_Indent_Str
("end record;");
3065 Sprint_Node
(Prefix
(Node
));
3066 Write_Str_With_Col_Check_Sloc
("'reference");
3068 when N_Requeue_Statement
=>
3069 Write_Indent_Str_Sloc
("requeue ");
3070 Sprint_Node
(Name
(Node
));
3072 if Abort_Present
(Node
) then
3073 Write_Str_With_Col_Check
(" with abort");
3078 -- Don't we want to print more detail???
3080 -- Doc of this extended syntax belongs in sinfo.ads and/or
3083 when N_SCIL_Dispatch_Table_Tag_Init
=>
3084 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Tag_Init]");
3086 when N_SCIL_Dispatching_Call
=>
3087 Write_Indent_Str
("[N_SCIL_Dispatching_Node]");
3089 when N_SCIL_Membership_Test
=>
3090 Write_Indent_Str
("[N_SCIL_Membership_Test]");
3092 when N_Simple_Return_Statement
=>
3093 if Present
(Expression
(Node
)) then
3094 Write_Indent_Str_Sloc
("return ");
3095 Sprint_Node
(Expression
(Node
));
3098 Write_Indent_Str_Sloc
("return;");
3101 when N_Selective_Accept
=>
3102 Write_Indent_Str_Sloc
("select");
3107 Alt_Node
:= First
(Select_Alternatives
(Node
));
3110 Sprint_Node
(Alt_Node
);
3113 exit when No
(Alt_Node
);
3114 Write_Indent_Str
("or");
3118 if Present
(Else_Statements
(Node
)) then
3119 Write_Indent_Str
("else");
3120 Sprint_Indented_List
(Else_Statements
(Node
));
3123 Write_Indent_Str
("end select;");
3125 when N_Signed_Integer_Type_Definition
=>
3126 Write_Str_With_Col_Check_Sloc
("range ");
3127 Sprint_Node
(Low_Bound
(Node
));
3129 Sprint_Node
(High_Bound
(Node
));
3131 when N_Single_Protected_Declaration
=>
3132 Write_Indent_Str_Sloc
("protected ");
3133 Write_Id
(Defining_Identifier
(Node
));
3135 Sprint_Node
(Protected_Definition
(Node
));
3136 Write_Id
(Defining_Identifier
(Node
));
3139 when N_Single_Task_Declaration
=>
3140 Write_Indent_Str_Sloc
("task ");
3141 Sprint_Node
(Defining_Identifier
(Node
));
3143 if Present
(Task_Definition
(Node
)) then
3145 Sprint_Node
(Task_Definition
(Node
));
3150 when N_Selected_Component
=>
3151 Sprint_Node
(Prefix
(Node
));
3152 Write_Char_Sloc
('.');
3153 Sprint_Node
(Selector_Name
(Node
));
3157 Sprint_Node
(Prefix
(Node
));
3158 Write_Str_With_Col_Check
(" (");
3159 Sprint_Node
(Discrete_Range
(Node
));
3162 when N_String_Literal
=>
3163 if String_Length
(Strval
(Node
)) + Column
> Sprint_Line_Limit
then
3164 Write_Indent_Str
(" ");
3168 Write_String_Table_Entry
(Strval
(Node
));
3170 when N_Subprogram_Body
=>
3172 -- Output extra blank line unless we are in freeze actions
3174 if Freeze_Indent
= 0 then
3180 if Present
(Corresponding_Spec
(Node
)) then
3181 Sprint_Node_Sloc
(Parent
(Corresponding_Spec
(Node
)));
3183 Sprint_Node_Sloc
(Specification
(Node
));
3188 Sprint_Indented_List
(Declarations
(Node
));
3189 Write_Indent_Str
("begin");
3190 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3192 Write_Indent_Str
("end ");
3195 (Handled_Statement_Sequence
(Node
),
3196 Defining_Unit_Name
(Specification
(Node
)));
3199 if Is_List_Member
(Node
)
3200 and then Present
(Next
(Node
))
3201 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
3206 when N_Subprogram_Body_Stub
=>
3208 Sprint_Node_Sloc
(Specification
(Node
));
3209 Write_Str_With_Col_Check
(" is separate;");
3211 when N_Subprogram_Declaration
=>
3213 Sprint_Node_Sloc
(Specification
(Node
));
3215 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
3216 and then Null_Present
(Specification
(Node
))
3218 Write_Str_With_Col_Check
(" is null");
3223 when N_Subprogram_Renaming_Declaration
=>
3225 Sprint_Node
(Specification
(Node
));
3226 Write_Str_With_Col_Check_Sloc
(" renames ");
3227 Sprint_Node
(Name
(Node
));
3230 when N_Subtype_Declaration
=>
3231 Write_Indent_Str_Sloc
("subtype ");
3232 Sprint_Node
(Defining_Identifier
(Node
));
3235 -- Ada 2005 (AI-231)
3237 if Null_Exclusion_Present
(Node
) then
3238 Write_Str
("not null ");
3241 Sprint_Node
(Subtype_Indication
(Node
));
3244 when N_Subtype_Indication
=>
3245 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
3247 Sprint_Node
(Constraint
(Node
));
3250 Write_Indent_Str_Sloc
("separate (");
3251 Sprint_Node
(Name
(Node
));
3254 Sprint_Node
(Proper_Body
(Node
));
3257 Write_Indent_Str_Sloc
("task body ");
3258 Write_Id
(Defining_Identifier
(Node
));
3260 Sprint_Indented_List
(Declarations
(Node
));
3261 Write_Indent_Str
("begin");
3262 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3263 Write_Indent_Str
("end ");
3265 (Handled_Statement_Sequence
(Node
), Defining_Identifier
(Node
));
3268 when N_Task_Body_Stub
=>
3269 Write_Indent_Str_Sloc
("task body ");
3270 Write_Id
(Defining_Identifier
(Node
));
3271 Write_Str_With_Col_Check
(" is separate;");
3273 when N_Task_Definition
=>
3275 Sprint_Indented_List
(Visible_Declarations
(Node
));
3277 if Present
(Private_Declarations
(Node
)) then
3278 Write_Indent_Str
("private");
3279 Sprint_Indented_List
(Private_Declarations
(Node
));
3282 Write_Indent_Str
("end ");
3283 Sprint_End_Label
(Node
, Defining_Identifier
(Parent
(Node
)));
3285 when N_Task_Type_Declaration
=>
3286 Write_Indent_Str_Sloc
("task type ");
3287 Sprint_Node
(Defining_Identifier
(Node
));
3288 Write_Discr_Specs
(Node
);
3290 if Present
(Interface_List
(Node
)) then
3291 Write_Str
(" is new ");
3292 Sprint_And_List
(Interface_List
(Node
));
3295 if Present
(Task_Definition
(Node
)) then
3296 if No
(Interface_List
(Node
)) then
3299 Write_Str
(" with ");
3302 Sprint_Node
(Task_Definition
(Node
));
3307 when N_Terminate_Alternative
=>
3308 Sprint_Node_List
(Pragmas_Before
(Node
));
3311 if Present
(Condition
(Node
)) then
3312 Write_Str_With_Col_Check
("when ");
3313 Sprint_Node
(Condition
(Node
));
3317 Write_Str_With_Col_Check_Sloc
("terminate;");
3318 Sprint_Node_List
(Pragmas_After
(Node
));
3320 when N_Timed_Entry_Call
=>
3321 Write_Indent_Str_Sloc
("select");
3323 Sprint_Node
(Entry_Call_Alternative
(Node
));
3325 Write_Indent_Str
("or");
3327 Sprint_Node
(Delay_Alternative
(Node
));
3329 Write_Indent_Str
("end select;");
3331 when N_Triggering_Alternative
=>
3332 Sprint_Node_List
(Pragmas_Before
(Node
));
3333 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
3334 Sprint_Node_List
(Statements
(Node
));
3336 when N_Type_Conversion
=>
3338 Sprint_Node
(Subtype_Mark
(Node
));
3341 if Conversion_OK
(Node
) then
3345 if Float_Truncate
(Node
) then
3349 if Rounded_Result
(Node
) then
3354 Sprint_Node
(Expression
(Node
));
3357 when N_Unchecked_Expression
=>
3360 Sprint_Node_Sloc
(Expression
(Node
));
3363 when N_Unchecked_Type_Conversion
=>
3364 Sprint_Node
(Subtype_Mark
(Node
));
3366 Write_Str_With_Col_Check
("(");
3367 Sprint_Node_Sloc
(Expression
(Node
));
3370 when N_Unconstrained_Array_Definition
=>
3371 Write_Str_With_Col_Check_Sloc
("array (");
3376 Node1
:= First
(Subtype_Marks
(Node
));
3378 Sprint_Node
(Node1
);
3379 Write_Str_With_Col_Check
(" range <>");
3381 exit when Node1
= Empty
;
3386 Write_Str
(") of ");
3387 Sprint_Node
(Component_Definition
(Node
));
3389 when N_Unused_At_Start | N_Unused_At_End
=>
3390 Write_Indent_Str
("***** Error, unused node encountered *****");
3393 when N_Use_Package_Clause
=>
3394 Write_Indent_Str_Sloc
("use ");
3395 Sprint_Comma_List
(Names
(Node
));
3398 when N_Use_Type_Clause
=>
3399 Write_Indent_Str_Sloc
("use type ");
3400 Sprint_Comma_List
(Subtype_Marks
(Node
));
3403 when N_Validate_Unchecked_Conversion
=>
3404 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
3405 Sprint_Node
(Source_Type
(Node
));
3407 Sprint_Node
(Target_Type
(Node
));
3411 Write_Indent_Str_Sloc
("when ");
3412 Sprint_Bar_List
(Discrete_Choices
(Node
));
3414 Sprint_Node
(Component_List
(Node
));
3416 when N_Variant_Part
=>
3418 Write_Indent_Str_Sloc
("case ");
3419 Sprint_Node
(Name
(Node
));
3421 Sprint_Indented_List
(Variants
(Node
));
3422 Write_Indent_Str
("end case");
3425 when N_With_Clause
=>
3427 -- Special test, if we are dumping the original tree only,
3428 -- then we want to eliminate the bogus with clauses that
3429 -- correspond to the non-existent children of Text_IO.
3431 if Dump_Original_Only
3432 and then Is_Text_IO_Special_Unit
(Name
(Node
))
3436 -- Normal case, output the with clause
3439 if First_Name
(Node
) or else not Dump_Original_Only
then
3441 -- Ada 2005 (AI-50217): Print limited with_clauses
3443 if Private_Present
(Node
) and Limited_Present
(Node
) then
3444 Write_Indent_Str
("limited private with ");
3446 elsif Private_Present
(Node
) then
3447 Write_Indent_Str
("private with ");
3449 elsif Limited_Present
(Node
) then
3450 Write_Indent_Str
("limited with ");
3453 Write_Indent_Str
("with ");
3460 Sprint_Node_Sloc
(Name
(Node
));
3462 if Last_Name
(Node
) or else not Dump_Original_Only
then
3468 -- Print aspects, except for special case of package declaration,
3469 -- where the aspects are printed inside the package specification.
3471 if Has_Aspects
(Node
)
3472 and then not Nkind_In
(Node
, N_Package_Declaration
,
3473 N_Generic_Package_Declaration
)
3475 Sprint_Aspect_Specifications
(Node
, Semicolon
=> True);
3478 if Nkind
(Node
) in N_Subexpr
3479 and then Do_Range_Check
(Node
)
3484 for J
in 1 .. Paren_Count
(Node
) loop
3488 Dump_Node
:= Save_Dump_Node
;
3489 end Sprint_Node_Actual
;
3491 ----------------------
3492 -- Sprint_Node_List --
3493 ----------------------
3495 procedure Sprint_Node_List
(List
: List_Id
; New_Lines
: Boolean := False) is
3499 if Is_Non_Empty_List
(List
) then
3500 Node
:= First
(List
);
3505 exit when Node
= Empty
;
3509 if New_Lines
and then Column
/= 1 then
3512 end Sprint_Node_List
;
3514 ----------------------
3515 -- Sprint_Node_Sloc --
3516 ----------------------
3518 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
3522 if Debug_Generated_Code
and then Present
(Dump_Node
) then
3523 Set_Sloc
(Dump_Node
, Sloc
(Node
));
3526 end Sprint_Node_Sloc
;
3528 ---------------------
3529 -- Sprint_Opt_Node --
3530 ---------------------
3532 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
3534 if Present
(Node
) then
3538 end Sprint_Opt_Node
;
3540 --------------------------
3541 -- Sprint_Opt_Node_List --
3542 --------------------------
3544 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
3546 if Present
(List
) then
3547 Sprint_Node_List
(List
);
3549 end Sprint_Opt_Node_List
;
3551 ---------------------------------
3552 -- Sprint_Opt_Paren_Comma_List --
3553 ---------------------------------
3555 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
3557 if Is_Non_Empty_List
(List
) then
3559 Sprint_Paren_Comma_List
(List
);
3561 end Sprint_Opt_Paren_Comma_List
;
3563 -----------------------------
3564 -- Sprint_Paren_Comma_List --
3565 -----------------------------
3567 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
3569 Node_Exists
: Boolean := False;
3573 if Is_Non_Empty_List
(List
) then
3575 if Dump_Original_Only
then
3577 while Present
(N
) loop
3578 if not Is_Rewrite_Insertion
(N
) then
3579 Node_Exists
:= True;
3586 if not Node_Exists
then
3591 Write_Str_With_Col_Check
("(");
3592 Sprint_Comma_List
(List
);
3595 end Sprint_Paren_Comma_List
;
3597 ----------------------
3598 -- Sprint_Right_Opnd --
3599 ----------------------
3601 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
3602 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
3605 if Paren_Count
(Opnd
) /= 0
3606 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
3615 end Sprint_Right_Opnd
;
3621 procedure Update_Itype
(Node
: Node_Id
) is
3623 if Present
(Etype
(Node
))
3624 and then Is_Itype
(Etype
(Node
))
3625 and then Debug_Generated_Code
3627 Set_Sloc
(Etype
(Node
), Sloc
(Node
));
3631 ---------------------
3632 -- Write_Char_Sloc --
3633 ---------------------
3635 procedure Write_Char_Sloc
(C
: Character) is
3637 if Debug_Generated_Code
and then C
/= ' ' then
3642 end Write_Char_Sloc
;
3644 --------------------------------
3645 -- Write_Condition_And_Reason --
3646 --------------------------------
3648 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
3649 Cond
: constant Node_Id
:= Condition
(Node
);
3650 Image
: constant String := RT_Exception_Code
'Image
3651 (RT_Exception_Code
'Val
3652 (UI_To_Int
(Reason
(Node
))));
3655 if Present
(Cond
) then
3657 -- If condition is a single entity, or NOT with a single entity,
3658 -- output all on one line, since it will likely fit just fine.
3660 if Is_Entity_Name
(Cond
)
3661 or else (Nkind
(Cond
) = N_Op_Not
3662 and then Is_Entity_Name
(Right_Opnd
(Cond
)))
3664 Write_Str_With_Col_Check
(" when ");
3668 -- Otherwise for more complex condition, multiple lines
3671 Write_Str_With_Col_Check
(" when");
3672 Indent
:= Indent
+ 2;
3676 Indent
:= Indent
- 2;
3679 -- If no condition, just need a space (all on one line)
3689 for J
in 4 .. Image
'Last loop
3690 if Image
(J
) = '_' then
3693 Write_Char
(Fold_Lower
(Image
(J
)));
3698 end Write_Condition_And_Reason
;
3700 --------------------------------
3701 -- Write_Corresponding_Source --
3702 --------------------------------
3704 procedure Write_Corresponding_Source
(S
: String) is
3706 Src
: Source_Buffer_Ptr
;
3709 -- Ignore if not in dump source text mode, or if in freeze actions
3711 if Dump_Source_Text
and then Freeze_Indent
= 0 then
3713 -- Ignore null string
3719 -- Ignore space or semicolon at end of given string
3721 if S
(S
'Last) = ' ' or else S
(S
'Last) = ';' then
3722 Write_Corresponding_Source
(S
(S
'First .. S
'Last - 1));
3726 -- Loop to look at next lines not yet printed in source file
3729 Last_Line_Printed
+ 1 .. Last_Source_Line
(Current_Source_File
)
3731 Src
:= Source_Text
(Current_Source_File
);
3732 Loc
:= Line_Start
(L
, Current_Source_File
);
3734 -- If comment, keep looking
3736 if Src
(Loc
.. Loc
+ 1) = "--" then
3739 -- Search to first non-blank
3742 while Src
(Loc
) not in Line_Terminator
loop
3746 if Src
(Loc
) /= ' ' and then Src
(Loc
) /= ASCII
.HT
then
3748 -- Loop through characters in string to see if we match
3750 for J
in S
'Range loop
3752 -- If mismatch, then not the case we are looking for
3754 if Src
(Loc
) /= S
(J
) then
3761 -- If we fall through, string matched, if white space or
3762 -- semicolon after the matched string, this is the case
3763 -- we are looking for.
3765 if Src
(Loc
) in Line_Terminator
3766 or else Src
(Loc
) = ' '
3767 or else Src
(Loc
) = ASCII
.HT
3768 or else Src
(Loc
) = ';'
3770 -- So output source lines up to and including this one
3772 Write_Source_Lines
(L
);
3781 -- Line was all blanks, or a comment line, keep looking
3785 end Write_Corresponding_Source
;
3787 -----------------------
3788 -- Write_Discr_Specs --
3789 -----------------------
3791 procedure Write_Discr_Specs
(N
: Node_Id
) is
3796 Specs
:= Discriminant_Specifications
(N
);
3798 if Present
(Specs
) then
3799 Write_Str_With_Col_Check
(" (");
3800 Spec
:= First
(Specs
);
3805 exit when Spec
= Empty
;
3807 -- Add semicolon, unless we are printing original tree and the
3808 -- next specification is part of a list (but not the first
3809 -- element of that list)
3811 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3818 end Write_Discr_Specs
;
3824 procedure Write_Ekind
(E
: Entity_Id
) is
3825 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
3828 Name_Len
:= S
'Length;
3829 Name_Buffer
(1 .. Name_Len
) := S
;
3830 Set_Casing
(Mixed_Case
);
3831 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3838 procedure Write_Id
(N
: Node_Id
) is
3840 -- Deal with outputting Itype
3842 -- Note: if we are printing the full tree with -gnatds, then we may
3843 -- end up picking up the Associated_Node link from a generic template
3844 -- here which overlaps the Entity field, but as documented, Write_Itype
3845 -- is defended against junk calls.
3847 if Nkind
(N
) in N_Entity
then
3849 elsif Nkind
(N
) in N_Has_Entity
then
3850 Write_Itype
(Entity
(N
));
3853 -- Case of a defining identifier
3855 if Nkind
(N
) = N_Defining_Identifier
then
3857 -- If defining identifier has an interface name (and no
3858 -- address clause), then we output the interface name.
3860 if (Is_Imported
(N
) or else Is_Exported
(N
))
3861 and then Present
(Interface_Name
(N
))
3862 and then No
(Address_Clause
(N
))
3864 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
3865 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3867 -- If no interface name (or inactive because there was
3868 -- an address clause), then just output the Chars name.
3871 Write_Name_With_Col_Check
(Chars
(N
));
3874 -- Case of selector of an expanded name where the expanded name
3875 -- has an associated entity, output this entity. Check that the
3876 -- entity or associated node is of the right kind, see above.
3878 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
3879 and then Selector_Name
(Parent
(N
)) = N
3880 and then Present
(Entity_Or_Associated_Node
(Parent
(N
)))
3881 and then Nkind
(Entity
(Parent
(N
))) in N_Entity
3883 Write_Id
(Entity
(Parent
(N
)));
3885 -- For any other node with an associated entity, output it
3887 elsif Nkind
(N
) in N_Has_Entity
3888 and then Present
(Entity_Or_Associated_Node
(N
))
3889 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
3891 Write_Id
(Entity
(N
));
3893 -- All other cases, we just print the Chars field
3896 Write_Name_With_Col_Check
(Chars
(N
));
3900 -----------------------
3901 -- Write_Identifiers --
3902 -----------------------
3904 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
3906 Sprint_Node
(Defining_Identifier
(Node
));
3907 Update_Itype
(Defining_Identifier
(Node
));
3909 -- The remainder of the declaration must be printed unless we are
3910 -- printing the original tree and this is not the last identifier
3913 not Dump_Original_Only
or else not More_Ids
(Node
);
3915 end Write_Identifiers
;
3917 ------------------------
3918 -- Write_Implicit_Def --
3919 ------------------------
3921 procedure Write_Implicit_Def
(E
: Entity_Id
) is
3926 when E_Array_Subtype
=>
3927 Write_Str_With_Col_Check
("subtype ");
3929 Write_Str_With_Col_Check
(" is ");
3930 Write_Id
(Base_Type
(E
));
3931 Write_Str_With_Col_Check
(" (");
3933 Ind
:= First_Index
(E
);
3934 while Present
(Ind
) loop
3938 if Present
(Ind
) then
3945 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
3946 Write_Str_With_Col_Check
("subtype ");
3949 Write_Id
(Etype
(E
));
3950 Write_Str_With_Col_Check
(" range ");
3951 Sprint_Node
(Scalar_Range
(E
));
3955 Write_Str_With_Col_Check
("type ");
3957 Write_Str_With_Col_Check
(" is <");
3962 end Write_Implicit_Def
;
3968 procedure Write_Indent
is
3969 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
3972 if Indent_Annull_Flag
then
3973 Indent_Annull_Flag
:= False;
3975 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3976 -- label declarations, since they typically have the sloc of the
3977 -- corresponding label, which really messes up the -gnatL output.
3980 and then Loc
> No_Location
3981 and then Nkind
(Dump_Node
) /= N_Implicit_Label_Declaration
3983 if Get_Source_File_Index
(Loc
) = Current_Source_File
then
3985 (Get_Physical_Line_Number
(Sloc
(Dump_Node
)));
3991 for J
in 1 .. Indent
loop
3997 ------------------------------
3998 -- Write_Indent_Identifiers --
3999 ------------------------------
4001 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
4003 -- We need to start a new line for every node, except in the case
4004 -- where we are printing the original tree and this is not the first
4005 -- defining identifier in the list.
4007 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
4010 -- If printing original tree and this is not the first defining
4011 -- identifier in the list, then the previous call to this procedure
4012 -- printed only the name, and we add a comma to separate the names.
4018 Sprint_Node
(Defining_Identifier
(Node
));
4020 -- The remainder of the declaration must be printed unless we are
4021 -- printing the original tree and this is not the last identifier
4024 not Dump_Original_Only
or else not More_Ids
(Node
);
4025 end Write_Indent_Identifiers
;
4027 -----------------------------------
4028 -- Write_Indent_Identifiers_Sloc --
4029 -----------------------------------
4031 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
4033 -- We need to start a new line for every node, except in the case
4034 -- where we are printing the original tree and this is not the first
4035 -- defining identifier in the list.
4037 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
4040 -- If printing original tree and this is not the first defining
4041 -- identifier in the list, then the previous call to this procedure
4042 -- printed only the name, and we add a comma to separate the names.
4049 Sprint_Node
(Defining_Identifier
(Node
));
4051 -- The remainder of the declaration must be printed unless we are
4052 -- printing the original tree and this is not the last identifier
4054 return not Dump_Original_Only
or else not More_Ids
(Node
);
4055 end Write_Indent_Identifiers_Sloc
;
4057 ----------------------
4058 -- Write_Indent_Str --
4059 ----------------------
4061 procedure Write_Indent_Str
(S
: String) is
4063 Write_Corresponding_Source
(S
);
4066 end Write_Indent_Str
;
4068 ---------------------------
4069 -- Write_Indent_Str_Sloc --
4070 ---------------------------
4072 procedure Write_Indent_Str_Sloc
(S
: String) is
4074 Write_Corresponding_Source
(S
);
4077 end Write_Indent_Str_Sloc
;
4083 procedure Write_Itype
(Typ
: Entity_Id
) is
4085 procedure Write_Header
(T
: Boolean := True);
4086 -- Write type if T is True, subtype if T is false
4092 procedure Write_Header
(T
: Boolean := True) is
4095 Write_Str
("[type ");
4097 Write_Str
("[subtype ");
4100 Write_Name_With_Col_Check
(Chars
(Typ
));
4104 -- Start of processing for Write_Itype
4107 if Nkind
(Typ
) in N_Entity
4108 and then Is_Itype
(Typ
)
4109 and then not Itype_Printed
(Typ
)
4111 -- Itype to be printed
4114 B
: constant Node_Id
:= Etype
(Typ
);
4116 P
: constant Node_Id
:= Parent
(Typ
);
4118 S
: constant Saved_Output_Buffer
:= Save_Output_Buffer
;
4119 -- Save current output buffer
4121 Old_Sloc
: Source_Ptr
;
4122 -- Save sloc of related node, so it is not modified when
4123 -- printing with -gnatD.
4126 -- Write indentation at start of line
4128 for J
in 1 .. Indent
loop
4132 -- If we have a constructed declaration for the itype, print it
4135 and then Nkind
(P
) in N_Declaration
4136 and then Defining_Entity
(P
) = Typ
4138 -- We must set Itype_Printed true before the recursive call to
4139 -- print the node, otherwise we get an infinite recursion.
4141 Set_Itype_Printed
(Typ
, True);
4143 -- Write the declaration enclosed in [], avoiding new line
4144 -- at start of declaration, and semicolon at end.
4146 -- Note: The itype may be imported from another unit, in which
4147 -- case we do not want to modify the Sloc of the declaration.
4148 -- Otherwise the itype may appear to be in the current unit,
4149 -- and the back-end will reject a reference out of scope.
4152 Indent_Annull_Flag
:= True;
4153 Old_Sloc
:= Sloc
(P
);
4155 Set_Sloc
(P
, Old_Sloc
);
4156 Write_Erase_Char
(';');
4158 -- If no constructed declaration, then we have to concoct the
4159 -- source corresponding to the type entity that we have at hand.
4164 -- Access types and subtypes
4167 Write_Header
(Ekind
(Typ
) = E_Access_Type
);
4169 if Can_Never_Be_Null
(Typ
) then
4170 Write_Str
("not null ");
4173 Write_Str
("access ");
4175 if Is_Access_Constant
(Typ
) then
4176 Write_Str
("constant ");
4179 Write_Id
(Directly_Designated_Type
(Typ
));
4181 -- Array types and string types
4183 when E_Array_Type
=>
4185 Write_Str
("array (");
4187 X
:= First_Index
(Typ
);
4191 if not Is_Constrained
(Typ
) then
4192 Write_Str
(" range <>");
4200 Write_Str
(") of ");
4201 X
:= Component_Type
(Typ
);
4203 -- Preserve sloc of component type, which is defined
4204 -- elsewhere than the itype (see comment above).
4206 Old_Sloc
:= Sloc
(X
);
4208 Set_Sloc
(X
, Old_Sloc
);
4210 -- Array subtypes and string subtypes.
4211 -- Preserve Sloc of index subtypes, as above.
4213 when E_Array_Subtype | E_String_Subtype
=>
4214 Write_Header
(False);
4215 Write_Id
(Etype
(Typ
));
4218 X
:= First_Index
(Typ
);
4220 Old_Sloc
:= Sloc
(X
);
4222 Set_Sloc
(X
, Old_Sloc
);
4230 -- Signed integer types, and modular integer subtypes,
4231 -- and also enumeration subtypes.
4233 when E_Signed_Integer_Type |
4234 E_Signed_Integer_Subtype |
4235 E_Modular_Integer_Subtype |
4236 E_Enumeration_Subtype
=>
4238 Write_Header
(Ekind
(Typ
) = E_Signed_Integer_Type
);
4240 if Ekind
(Typ
) = E_Signed_Integer_Type
then
4246 -- Print bounds if different from base type
4249 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4250 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4255 -- B can either be a scalar type, in which case the
4256 -- declaration of Typ may constrain it with different
4257 -- bounds, or a private type, in which case we know
4258 -- that the declaration of Typ cannot have a scalar
4261 if Is_Scalar_Type
(B
) then
4262 LE
:= Type_Low_Bound
(B
);
4263 HE
:= Type_High_Bound
(B
);
4271 and then Nkind
(L
) = N_Integer_Literal
4272 and then Nkind
(H
) = N_Integer_Literal
4273 and then Nkind
(LE
) = N_Integer_Literal
4274 and then Nkind
(HE
) = N_Integer_Literal
4275 and then UI_Eq
(Intval
(L
), Intval
(LE
))
4276 and then UI_Eq
(Intval
(H
), Intval
(HE
)))
4281 Write_Str
(" range ");
4282 Sprint_Node
(Type_Low_Bound
(Typ
));
4284 Sprint_Node
(Type_High_Bound
(Typ
));
4288 -- Modular integer types
4290 when E_Modular_Integer_Type
=>
4293 Write_Uint_With_Col_Check
(Modulus
(Typ
), Auto
);
4295 -- Floating point types and subtypes
4297 when E_Floating_Point_Type |
4298 E_Floating_Point_Subtype
=>
4300 Write_Header
(Ekind
(Typ
) = E_Floating_Point_Type
);
4302 if Ekind
(Typ
) = E_Floating_Point_Type
then
4306 Write_Id
(Etype
(Typ
));
4308 if Digits_Value
(Typ
) /= Digits_Value
(Etype
(Typ
)) then
4309 Write_Str
(" digits ");
4310 Write_Uint_With_Col_Check
4311 (Digits_Value
(Typ
), Decimal
);
4314 -- Print bounds if not different from base type
4317 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4318 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4319 LE
: constant Node_Id
:= Type_Low_Bound
(B
);
4320 HE
: constant Node_Id
:= Type_High_Bound
(B
);
4323 if Nkind
(L
) = N_Real_Literal
4324 and then Nkind
(H
) = N_Real_Literal
4325 and then Nkind
(LE
) = N_Real_Literal
4326 and then Nkind
(HE
) = N_Real_Literal
4327 and then UR_Eq
(Realval
(L
), Realval
(LE
))
4328 and then UR_Eq
(Realval
(H
), Realval
(HE
))
4333 Write_Str
(" range ");
4334 Sprint_Node
(Type_Low_Bound
(Typ
));
4336 Sprint_Node
(Type_High_Bound
(Typ
));
4342 when E_Record_Subtype | E_Record_Subtype_With_Private
=>
4343 Write_Header
(False);
4344 Write_Str
("record");
4350 C
:= First_Entity
(Typ
);
4351 while Present
(C
) loop
4355 Write_Id
(Etype
(C
));
4361 Write_Indent_Str
(" end record");
4365 when E_Class_Wide_Type |
4366 E_Class_Wide_Subtype
=>
4367 Write_Header
(Ekind
(Typ
) = E_Class_Wide_Type
);
4368 Write_Name_With_Col_Check
(Chars
(Etype
(Typ
)));
4369 Write_Str
("'Class");
4373 when E_Subprogram_Type
=>
4376 if Etype
(Typ
) = Standard_Void_Type
then
4377 Write_Str
("procedure");
4379 Write_Str
("function");
4382 if Present
(First_Entity
(Typ
)) then
4389 Param
:= First_Entity
(Typ
);
4394 if Ekind
(Param
) = E_In_Out_Parameter
then
4395 Write_Str
("in out ");
4396 elsif Ekind
(Param
) = E_Out_Parameter
then
4400 Write_Id
(Etype
(Param
));
4401 Next_Entity
(Param
);
4402 exit when No
(Param
);
4410 if Etype
(Typ
) /= Standard_Void_Type
then
4411 Write_Str
(" return ");
4412 Write_Id
(Etype
(Typ
));
4415 when E_String_Literal_Subtype
=>
4417 LB
: constant Uint
:=
4418 Expr_Value
(String_Literal_Low_Bound
(Typ
));
4419 Len
: constant Uint
:=
4420 String_Literal_Length
(Typ
);
4422 Write_Header
(False);
4423 Write_Str
("String (");
4424 Write_Int
(UI_To_Int
(LB
));
4426 Write_Int
(UI_To_Int
(LB
+ Len
) - 1);
4430 -- For all other Itypes, print ??? (fill in later)
4433 Write_Header
(True);
4439 -- Add terminating bracket and restore output buffer
4443 Restore_Output_Buffer
(S
);
4446 Set_Itype_Printed
(Typ
);
4450 -------------------------------
4451 -- Write_Name_With_Col_Check --
4452 -------------------------------
4454 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
4460 Get_Name_String
(N
);
4462 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4463 -- upper case letter, nnn is one or more digits and b is a lower case
4464 -- letter by C...b, so that listings do not depend on serial numbers.
4466 if Debug_Flag_II
then
4468 while J
< Name_Len
- 1 loop
4469 if Name_Buffer
(J
) in 'A' .. 'Z'
4470 and then Name_Buffer
(J
+ 1) in '0' .. '9'
4473 while K
< Name_Len
loop
4474 exit when Name_Buffer
(K
) not in '0' .. '9';
4478 if Name_Buffer
(K
) in 'a' .. 'z' then
4479 L
:= Name_Len
- K
+ 1;
4481 Name_Buffer
(J
+ 4 .. J
+ L
+ 3) :=
4482 Name_Buffer
(K
.. Name_Len
);
4483 Name_Buffer
(J
+ 1 .. J
+ 3) := "...";
4484 Name_Len
:= J
+ L
+ 3;
4497 -- Fall through for normal case
4499 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4500 end Write_Name_With_Col_Check
;
4502 ------------------------------------
4503 -- Write_Name_With_Col_Check_Sloc --
4504 ------------------------------------
4506 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
4508 Get_Name_String
(N
);
4509 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
4510 end Write_Name_With_Col_Check_Sloc
;
4512 --------------------
4513 -- Write_Operator --
4514 --------------------
4516 procedure Write_Operator
(N
: Node_Id
; S
: String) is
4517 F
: Natural := S
'First;
4518 T
: Natural := S
'Last;
4521 -- If no overflow check, just write string out, and we are done
4523 if not Do_Overflow_Check
(N
) then
4526 -- If overflow check, we want to surround the operator with curly
4527 -- brackets, but not include spaces within the brackets.
4540 Write_Str_Sloc
(S
(F
.. T
));
4543 if S
(S
'Last) = ' ' then
4549 -----------------------
4550 -- Write_Param_Specs --
4551 -----------------------
4553 procedure Write_Param_Specs
(N
: Node_Id
) is
4559 Specs
:= Parameter_Specifications
(N
);
4561 if Is_Non_Empty_List
(Specs
) then
4562 Write_Str_With_Col_Check
(" (");
4563 Spec
:= First
(Specs
);
4567 Formal
:= Defining_Identifier
(Spec
);
4569 exit when Spec
= Empty
;
4571 -- Add semicolon, unless we are printing original tree and the
4572 -- next specification is part of a list (but not the first element
4575 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4580 -- Write out any extra formals
4582 while Present
(Extra_Formal
(Formal
)) loop
4583 Formal
:= Extra_Formal
(Formal
);
4585 Write_Name_With_Col_Check
(Chars
(Formal
));
4587 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
4592 end Write_Param_Specs
;
4594 -----------------------
4595 -- Write_Rewrite_Str --
4596 -----------------------
4598 procedure Write_Rewrite_Str
(S
: String) is
4600 if not Dump_Generated_Only
then
4601 if S
'Length = 3 and then S
= ">>>" then
4604 Write_Str_With_Col_Check
(S
);
4607 end Write_Rewrite_Str
;
4609 -----------------------
4610 -- Write_Source_Line --
4611 -----------------------
4613 procedure Write_Source_Line
(L
: Physical_Line_Number
) is
4615 Src
: Source_Buffer_Ptr
;
4619 if Dump_Source_Text
then
4620 Src
:= Source_Text
(Current_Source_File
);
4621 Loc
:= Line_Start
(L
, Current_Source_File
);
4624 -- See if line is a comment line, if not, and if not line one,
4625 -- precede with blank line.
4628 while Src
(Scn
) = ' ' or else Src
(Scn
) = ASCII
.HT
loop
4632 if (Src
(Scn
) in Line_Terminator
4633 or else Src
(Scn
.. Scn
+ 1) /= "--")
4639 -- Now write the source text of the line
4642 Write_Int
(Int
(L
));
4645 while Src
(Loc
) not in Line_Terminator
loop
4646 Write_Char
(Src
(Loc
));
4650 end Write_Source_Line
;
4652 ------------------------
4653 -- Write_Source_Lines --
4654 ------------------------
4656 procedure Write_Source_Lines
(L
: Physical_Line_Number
) is
4658 while Last_Line_Printed
< L
loop
4659 Last_Line_Printed
:= Last_Line_Printed
+ 1;
4660 Write_Source_Line
(Last_Line_Printed
);
4662 end Write_Source_Lines
;
4664 --------------------
4665 -- Write_Str_Sloc --
4666 --------------------
4668 procedure Write_Str_Sloc
(S
: String) is
4670 for J
in S
'Range loop
4671 Write_Char_Sloc
(S
(J
));
4675 ------------------------------
4676 -- Write_Str_With_Col_Check --
4677 ------------------------------
4679 procedure Write_Str_With_Col_Check
(S
: String) is
4681 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4682 Write_Indent_Str
(" ");
4684 if S
(S
'First) = ' ' then
4685 Write_Str
(S
(S
'First + 1 .. S
'Last));
4693 end Write_Str_With_Col_Check
;
4695 -----------------------------------
4696 -- Write_Str_With_Col_Check_Sloc --
4697 -----------------------------------
4699 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
4701 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4702 Write_Indent_Str
(" ");
4704 if S
(S
'First) = ' ' then
4705 Write_Str_Sloc
(S
(S
'First + 1 .. S
'Last));
4713 end Write_Str_With_Col_Check_Sloc
;
4715 ---------------------------
4716 -- Write_Subprogram_Name --
4717 ---------------------------
4719 procedure Write_Subprogram_Name
(N
: Node_Id
) is
4721 if not Comes_From_Source
(N
)
4722 and then Is_Entity_Name
(N
)
4725 Ent
: constant Entity_Id
:= Entity
(N
);
4727 if not In_Extended_Main_Source_Unit
(Ent
)
4729 Is_Predefined_File_Name
4730 (Unit_File_Name
(Get_Source_Unit
(Ent
)))
4732 -- Run-time routine name, output name with a preceding dollar
4733 -- making sure that we do not get a line split between them.
4735 Col_Check
(Length_Of_Name
(Chars
(Ent
)) + 1);
4737 Write_Name
(Chars
(Ent
));
4743 -- Normal case, not a run-time routine name
4746 end Write_Subprogram_Name
;
4748 -------------------------------
4749 -- Write_Uint_With_Col_Check --
4750 -------------------------------
4752 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
) is
4754 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4755 UI_Write
(U
, Format
);
4756 end Write_Uint_With_Col_Check
;
4758 ------------------------------------
4759 -- Write_Uint_With_Col_Check_Sloc --
4760 ------------------------------------
4762 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
4764 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4766 UI_Write
(U
, Format
);
4767 end Write_Uint_With_Col_Check_Sloc
;
4769 -------------------------------------
4770 -- Write_Ureal_With_Col_Check_Sloc --
4771 -------------------------------------
4773 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
4774 D
: constant Uint
:= Denominator
(U
);
4775 N
: constant Uint
:= Numerator
(U
);
4777 Col_Check
(UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
4779 UR_Write
(U
, Brackets
=> True);
4780 end Write_Ureal_With_Col_Check_Sloc
;