1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2009, 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 Atree
; use Atree
;
27 with Casing
; use Casing
;
28 with Csets
; use Csets
;
29 with Debug
; use Debug
;
30 with Einfo
; use Einfo
;
31 with Fname
; use Fname
;
33 with Namet
; use Namet
;
34 with Nlists
; use Nlists
;
36 with Output
; use Output
;
37 with Rtsfind
; use Rtsfind
;
38 with Sem_Util
; use Sem_Util
;
39 with Sinfo
; use Sinfo
;
40 with Sinput
; use Sinput
;
41 with Sinput
.D
; use Sinput
.D
;
42 with Snames
; use Snames
;
43 with Stand
; use Stand
;
44 with Stringt
; use Stringt
;
45 with Uintp
; use Uintp
;
46 with Uname
; use Uname
;
47 with Urealp
; use Urealp
;
49 package body Sprint
is
50 Current_Source_File
: Source_File_Index
;
51 -- Index of source file whose generated code is being dumped
53 Dump_Node
: Node_Id
:= Empty
;
54 -- This is set to the current node, used for printing line numbers. In
55 -- Debug_Generated_Code mode, Dump_Node is set to the current node
56 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
57 -- value. The call clears it back to Empty.
59 Debug_Sloc
: Source_Ptr
;
60 -- Sloc of first byte of line currently being written if we are
61 -- generating a source debug file.
63 Dump_Original_Only
: Boolean;
64 -- Set True if the -gnatdo (dump original tree) flag is set
66 Dump_Generated_Only
: Boolean;
67 -- Set True if the -gnatG (dump generated tree) debug flag is set
68 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
70 Dump_Freeze_Null
: Boolean;
71 -- Set True if freeze nodes and non-source null statements output
73 Freeze_Indent
: Int
:= 0;
74 -- Keep track of freeze indent level (controls output of blank lines before
75 -- procedures within expression freeze actions). Relevant only if we are
76 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
77 -- output these blank lines in any case.
80 -- Number of columns for current line output indentation
82 Indent_Annull_Flag
: Boolean := False;
83 -- Set True if subsequent Write_Indent call to be ignored, gets reset
84 -- by this call, so it is only active to suppress a single indent call.
86 Last_Line_Printed
: Physical_Line_Number
;
87 -- This keeps track of the physical line number of the last source line
88 -- that has been output. The value is only valid in Dump_Source_Text mode.
90 -------------------------------
91 -- Operator Precedence Table --
92 -------------------------------
94 -- This table is used to decide whether a subexpression needs to be
95 -- parenthesized. The rule is that if an operand of an operator (which
96 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
97 -- with a lower precedence than the operator (or equal precedence if
98 -- appearing as the right operand), then parentheses are required.
100 Op_Prec
: constant array (N_Subexpr
) of Short_Short_Integer :=
133 procedure Sprint_Left_Opnd
(N
: Node_Id
);
134 -- Print left operand of operator, parenthesizing if necessary
136 procedure Sprint_Right_Opnd
(N
: Node_Id
);
137 -- Print right operand of operator, parenthesizing if necessary
139 -----------------------
140 -- Local Subprograms --
141 -----------------------
143 procedure Col_Check
(N
: Nat
);
144 -- Check that at least N characters remain on current line, and if not,
145 -- then start an extra line with two characters extra indentation for
146 -- continuing text on the next line.
148 procedure Extra_Blank_Line
;
149 -- In some situations we write extra blank lines to separate the generated
150 -- code to make it more readable. However, these extra blank lines are not
151 -- generated in Dump_Source_Text mode, since there the source text lines
152 -- output with preceding blank lines are quite sufficient as separators.
153 -- This procedure writes a blank line if Dump_Source_Text is False.
155 procedure Indent_Annull
;
156 -- Causes following call to Write_Indent to be ignored. This is used when
157 -- a higher level node wants to stop a lower level node from starting a
158 -- new line, when it would otherwise be inclined to do so (e.g. the case
159 -- of an accept statement called from an accept alternative with a guard)
161 procedure Indent_Begin
;
162 -- Increase indentation level
164 procedure Indent_End
;
165 -- Decrease indentation level
167 procedure Print_Debug_Line
(S
: String);
168 -- Used to print output lines in Debug_Generated_Code mode (this is used
169 -- as the argument for a call to Set_Special_Output in package Output).
171 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
);
172 -- Given a divide, multiplication or division node, check the flags
173 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
174 -- appropriate special syntax characters (# and @).
176 procedure Set_Debug_Sloc
;
177 -- If Dump_Node is non-empty, this routine sets the appropriate value
178 -- in its Sloc field, from the current location in the debug source file
179 -- that is currently being written.
181 procedure Sprint_And_List
(List
: List_Id
);
182 -- Print the given list with items separated by vertical "and"
184 procedure Sprint_Bar_List
(List
: List_Id
);
185 -- Print the given list with items separated by vertical bars
187 procedure Sprint_End_Label
190 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
191 -- If there is not end label, use the defining identifier of the enclosing
192 -- construct. If the end label is present, treat it as a reference to the
193 -- defining entity of the construct: this guarantees that it carries the
194 -- proper sloc information for debugging purposes.
196 procedure Sprint_Node_Actual
(Node
: Node_Id
);
197 -- This routine prints its node argument. It is a lower level routine than
198 -- Sprint_Node, in that it does not bother about rewritten trees.
200 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
201 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
202 -- sets the Sloc of the current debug node to be a copy of the Sloc
203 -- of the sprinted node Node. Note that this is done after printing
204 -- Node, so that the Sloc is the proper updated value for the debug file.
206 procedure Update_Itype
(Node
: Node_Id
);
207 -- Update the Sloc of an itype that is not attached to the tree, when
208 -- debugging expanded code. This routine is called from nodes whose
209 -- type can be an Itype, such as defining_identifiers that may be of
210 -- an anonymous access type, or ranges in slices.
212 procedure Write_Char_Sloc
(C
: Character);
213 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
214 -- called to ensure that the current node has a proper Sloc set.
216 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
217 -- Write Condition and Reason codes of Raise_xxx_Error node
219 procedure Write_Corresponding_Source
(S
: String);
220 -- If S is a string with a single keyword (possibly followed by a space),
221 -- and if the next non-comment non-blank source line matches this keyword,
222 -- then output all source lines up to this matching line.
224 procedure Write_Discr_Specs
(N
: Node_Id
);
225 -- Output discriminant specification for node, which is any of the type
226 -- declarations that can have discriminants.
228 procedure Write_Ekind
(E
: Entity_Id
);
229 -- Write the String corresponding to the Ekind without "E_"
231 procedure Write_Id
(N
: Node_Id
);
232 -- N is a node with a Chars field. This procedure writes the name that
233 -- will be used in the generated code associated with the name. For a
234 -- node with no associated entity, this is simply the Chars field. For
235 -- the case where there is an entity associated with the node, we print
236 -- the name associated with the entity (since it may have been encoded).
237 -- One other special case is that an entity has an active external name
238 -- (i.e. an external name present with no address clause), then this
239 -- external name is output. This procedure also deals with outputting
240 -- declarations of referenced itypes, if not output earlier.
242 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
243 -- Handle node where the grammar has a list of defining identifiers, but
244 -- the tree has a separate declaration for each identifier. Handles the
245 -- printing of the defining identifier, and returns True if the type and
246 -- initialization information is to be printed, False if it is to be
247 -- skipped (the latter case happens when printing defining identifiers
248 -- other than the first in the original tree output case).
250 procedure Write_Implicit_Def
(E
: Entity_Id
);
251 pragma Warnings
(Off
, Write_Implicit_Def
);
252 -- Write the definition of the implicit type E according to its Ekind
253 -- For now a debugging procedure, but might be used in the future.
255 procedure Write_Indent
;
256 -- Start a new line and write indentation spacing
258 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
259 -- Like Write_Identifiers except that each new printed declaration
260 -- is at the start of a new line.
262 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
263 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
264 -- mode, the Sloc of the current debug node is set to point to the
265 -- first output identifier.
267 procedure Write_Indent_Str
(S
: String);
268 -- Start a new line and write indent spacing followed by given string
270 procedure Write_Indent_Str_Sloc
(S
: String);
271 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
272 -- the Sloc of the current node is set to the first non-blank character
275 procedure Write_Itype
(Typ
: Entity_Id
);
276 -- If Typ is an Itype that has not been written yet, write it. If Typ is
277 -- any other kind of entity or tree node, the call is ignored.
279 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
280 -- Write name (using Write_Name) with initial column check, and possible
281 -- initial Write_Indent (to get new line) if current line is too full.
283 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
284 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
285 -- mode, sets Sloc of current debug node to first character of name.
287 procedure Write_Operator
(N
: Node_Id
; S
: String);
288 -- Like Write_Str_Sloc, used for operators, encloses the string in
289 -- characters {} if the Do_Overflow flag is set on the node N.
291 procedure Write_Param_Specs
(N
: Node_Id
);
292 -- Output parameter specifications for node (which is either a function
293 -- or procedure specification with a Parameter_Specifications field)
295 procedure Write_Rewrite_Str
(S
: String);
296 -- Writes out a string (typically containing <<< or >>>}) for a node
297 -- created by rewriting the tree. Suppressed if we are outputting the
298 -- generated code only, since in this case we don't specially mark nodes
299 -- created by rewriting).
301 procedure Write_Source_Line
(L
: Physical_Line_Number
);
302 -- If writing of interspersed source lines is enabled, then write the given
303 -- line from the source file, preceded by Eol, then an extra blank line if
304 -- the line has at least one blank, is not a comment and is not line one,
305 -- then "--" and the line number followed by period followed by text of the
306 -- source line (without terminating Eol). If interspersed source line
307 -- output not enabled, then the call has no effect.
309 procedure Write_Source_Lines
(L
: Physical_Line_Number
);
310 -- If writing of interspersed source lines is enabled, then writes source
311 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
312 -- interspersed source line output not enabled, then call has no effect.
314 procedure Write_Str_Sloc
(S
: String);
315 -- Like Write_Str, but sets debug Sloc of current debug node to first
316 -- non-blank character if a current debug node is active.
318 procedure Write_Str_With_Col_Check
(S
: String);
319 -- Write string (using Write_Str) with initial column check, and possible
320 -- initial Write_Indent (to get new line) if current line is too full.
322 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
323 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
324 -- node to first non-blank character if a current debug node is active.
326 procedure Write_Subprogram_Name
(N
: Node_Id
);
327 -- N is the Name field of a function call or procedure statement call.
328 -- The effect of the call is to output the name, preceded by a $ if the
329 -- call is identified as an implicit call to a run time routine.
331 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
);
332 -- Write Uint (using UI_Write) with initial column check, and possible
333 -- initial Write_Indent (to get new line) if current line is too full.
334 -- The format parameter determines the output format (see UI_Write).
336 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
337 -- Write Uint (using UI_Write) with initial column check, and possible
338 -- initial Write_Indent (to get new line) if current line is too full.
339 -- The format parameter determines the output format (see UI_Write).
340 -- In addition, in Debug_Generated_Code mode, sets the current node
341 -- Sloc to the first character of the output value.
343 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
344 -- Write Ureal (using same output format as UR_Write) with column checks
345 -- and a possible initial Write_Indent (to get new line) if current line
346 -- is too full. In addition, in Debug_Generated_Code mode, sets the
347 -- current node Sloc to the first character of the output value.
353 procedure Col_Check
(N
: Nat
) is
355 if N
+ Column
> Sprint_Line_Limit
then
356 Write_Indent_Str
(" ");
360 ----------------------
361 -- Extra_Blank_Line --
362 ----------------------
364 procedure Extra_Blank_Line
is
366 if not Dump_Source_Text
then
369 end Extra_Blank_Line
;
375 procedure Indent_Annull
is
377 Indent_Annull_Flag
:= True;
384 procedure Indent_Begin
is
386 Indent
:= Indent
+ 3;
393 procedure Indent_End
is
395 Indent
:= Indent
- 3;
402 procedure pg
(Arg
: Union_Id
) is
404 Dump_Generated_Only
:= True;
405 Dump_Original_Only
:= False;
406 Current_Source_File
:= No_Source_File
;
408 if Arg
in List_Range
then
409 Sprint_Node_List
(List_Id
(Arg
));
411 elsif Arg
in Node_Range
then
412 Sprint_Node
(Node_Id
(Arg
));
425 procedure po
(Arg
: Union_Id
) is
427 Dump_Generated_Only
:= False;
428 Dump_Original_Only
:= True;
429 Current_Source_File
:= No_Source_File
;
431 if Arg
in List_Range
then
432 Sprint_Node_List
(List_Id
(Arg
));
434 elsif Arg
in Node_Range
then
435 Sprint_Node
(Node_Id
(Arg
));
444 ----------------------
445 -- Print_Debug_Line --
446 ----------------------
448 procedure Print_Debug_Line
(S
: String) is
450 Write_Debug_Line
(S
, Debug_Sloc
);
451 end Print_Debug_Line
;
453 ---------------------------
454 -- Process_TFAI_RR_Flags --
455 ---------------------------
457 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
459 if Treat_Fixed_As_Integer
(Nod
) then
463 if Rounded_Result
(Nod
) then
466 end Process_TFAI_RR_Flags
;
472 procedure ps
(Arg
: Union_Id
) is
474 Dump_Generated_Only
:= False;
475 Dump_Original_Only
:= False;
476 Current_Source_File
:= No_Source_File
;
478 if Arg
in List_Range
then
479 Sprint_Node_List
(List_Id
(Arg
));
481 elsif Arg
in Node_Range
then
482 Sprint_Node
(Node_Id
(Arg
));
495 procedure Set_Debug_Sloc
is
497 if Debug_Generated_Code
and then Present
(Dump_Node
) then
498 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
507 procedure Source_Dump
is
510 -- Put underline under string we just printed
516 procedure Underline
is
517 Col
: constant Int
:= Column
;
522 while Col
> Column
loop
529 -- Start of processing for Tree_Dump
532 Dump_Generated_Only
:= Debug_Flag_G
or
533 Print_Generated_Code
or
534 Debug_Generated_Code
;
535 Dump_Original_Only
:= Debug_Flag_O
;
536 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
538 -- Note that we turn off the tree dump flags immediately, before
539 -- starting the dump. This avoids generating two copies of the dump
540 -- if an abort occurs after printing the dump, and more importantly,
541 -- avoids an infinite loop if an abort occurs during the dump.
544 Current_Source_File
:= No_Source_File
;
545 Debug_Flag_Z
:= False;
548 Write_Str
("Source recreated from tree of Standard (spec)");
550 Sprint_Node
(Standard_Package_Node
);
555 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
556 Debug_Flag_G
:= False;
557 Debug_Flag_O
:= False;
558 Debug_Flag_S
:= False;
560 -- Dump requested units
562 for U
in Main_Unit
.. Last_Unit
loop
563 Current_Source_File
:= Source_Index
(U
);
565 -- Dump all units if -gnatdf set, otherwise we dump only
566 -- the source files that are in the extended main source.
569 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
571 -- If we are generating debug files, setup to write them
573 if Debug_Generated_Code
then
574 Set_Special_Output
(Print_Debug_Line
'Access);
575 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
576 Write_Source_Line
(1);
577 Last_Line_Printed
:= 1;
578 Sprint_Node
(Cunit
(U
));
579 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
582 Set_Special_Output
(null);
584 -- Normal output to standard output file
587 Write_Str
("Source recreated from tree for ");
588 Write_Unit_Name
(Unit_Name
(U
));
590 Write_Source_Line
(1);
591 Last_Line_Printed
:= 1;
592 Sprint_Node
(Cunit
(U
));
593 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
602 ---------------------
603 -- Sprint_And_List --
604 ---------------------
606 procedure Sprint_And_List
(List
: List_Id
) is
609 if Is_Non_Empty_List
(List
) then
610 Node
:= First
(List
);
614 exit when Node
= Empty
;
620 ---------------------
621 -- Sprint_Bar_List --
622 ---------------------
624 procedure Sprint_Bar_List
(List
: List_Id
) is
627 if Is_Non_Empty_List
(List
) then
628 Node
:= First
(List
);
632 exit when Node
= Empty
;
638 ----------------------
639 -- Sprint_End_Label --
640 ----------------------
642 procedure Sprint_End_Label
648 and then Present
(End_Label
(Node
))
649 and then Is_Entity_Name
(End_Label
(Node
))
651 Set_Entity
(End_Label
(Node
), Default
);
653 -- For a function whose name is an operator, use the qualified name
654 -- created for the defining entity.
656 if Nkind
(End_Label
(Node
)) = N_Operator_Symbol
then
657 Set_Chars
(End_Label
(Node
), Chars
(Default
));
660 Sprint_Node
(End_Label
(Node
));
662 Sprint_Node
(Default
);
664 end Sprint_End_Label
;
666 -----------------------
667 -- Sprint_Comma_List --
668 -----------------------
670 procedure Sprint_Comma_List
(List
: List_Id
) is
674 if Is_Non_Empty_List
(List
) then
675 Node
:= First
(List
);
679 exit when Node
= Empty
;
681 if not Is_Rewrite_Insertion
(Node
)
682 or else not Dump_Original_Only
688 end Sprint_Comma_List
;
690 --------------------------
691 -- Sprint_Indented_List --
692 --------------------------
694 procedure Sprint_Indented_List
(List
: List_Id
) is
697 Sprint_Node_List
(List
);
699 end Sprint_Indented_List
;
701 ---------------------
702 -- Sprint_Left_Opnd --
703 ---------------------
705 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
706 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
709 if Paren_Count
(Opnd
) /= 0
710 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
719 end Sprint_Left_Opnd
;
725 procedure Sprint_Node
(Node
: Node_Id
) is
727 if Is_Rewrite_Insertion
(Node
) then
728 if not Dump_Original_Only
then
730 -- For special cases of nodes that always output <<< >>>
731 -- do not duplicate the output at this point.
733 if Nkind
(Node
) = N_Freeze_Entity
734 or else Nkind
(Node
) = N_Implicit_Label_Declaration
736 Sprint_Node_Actual
(Node
);
738 -- Normal case where <<< >>> may be required
741 Write_Rewrite_Str
("<<<");
742 Sprint_Node_Actual
(Node
);
743 Write_Rewrite_Str
(">>>");
747 elsif Is_Rewrite_Substitution
(Node
) then
749 -- Case of dump generated only
751 if Dump_Generated_Only
then
752 Sprint_Node_Actual
(Node
);
754 -- Case of dump original only
756 elsif Dump_Original_Only
then
757 Sprint_Node_Actual
(Original_Node
(Node
));
759 -- Case of both being dumped
762 Sprint_Node_Actual
(Original_Node
(Node
));
763 Write_Rewrite_Str
("<<<");
764 Sprint_Node_Actual
(Node
);
765 Write_Rewrite_Str
(">>>");
769 Sprint_Node_Actual
(Node
);
773 ------------------------
774 -- Sprint_Node_Actual --
775 ------------------------
777 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
778 Save_Dump_Node
: constant Node_Id
:= Dump_Node
;
785 for J
in 1 .. Paren_Count
(Node
) loop
786 Write_Str_With_Col_Check
("(");
789 -- Setup current dump node
793 if Nkind
(Node
) in N_Subexpr
794 and then Do_Range_Check
(Node
)
796 Write_Str_With_Col_Check
("{");
799 -- Select print circuit based on node kind
803 when N_Abort_Statement
=>
804 Write_Indent_Str_Sloc
("abort ");
805 Sprint_Comma_List
(Names
(Node
));
808 when N_Abortable_Part
=>
810 Write_Str_Sloc
("abort ");
811 Sprint_Indented_List
(Statements
(Node
));
813 when N_Abstract_Subprogram_Declaration
=>
815 Sprint_Node
(Specification
(Node
));
816 Write_Str_With_Col_Check
(" is ");
817 Write_Str_Sloc
("abstract;");
819 when N_Accept_Alternative
=>
820 Sprint_Node_List
(Pragmas_Before
(Node
));
822 if Present
(Condition
(Node
)) then
823 Write_Indent_Str
("when ");
824 Sprint_Node
(Condition
(Node
));
829 Sprint_Node_Sloc
(Accept_Statement
(Node
));
830 Sprint_Node_List
(Statements
(Node
));
832 when N_Accept_Statement
=>
833 Write_Indent_Str_Sloc
("accept ");
834 Write_Id
(Entry_Direct_Name
(Node
));
836 if Present
(Entry_Index
(Node
)) then
837 Write_Str_With_Col_Check
(" (");
838 Sprint_Node
(Entry_Index
(Node
));
842 Write_Param_Specs
(Node
);
844 if Present
(Handled_Statement_Sequence
(Node
)) then
845 Write_Str_With_Col_Check
(" do");
846 Sprint_Node
(Handled_Statement_Sequence
(Node
));
847 Write_Indent_Str
("end ");
848 Write_Id
(Entry_Direct_Name
(Node
));
853 when N_Access_Definition
=>
857 if Present
(Access_To_Subprogram_Definition
(Node
)) then
858 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
862 if Null_Exclusion_Present
(Node
) then
863 Write_Str
("not null ");
866 Write_Str_With_Col_Check_Sloc
("access ");
868 if All_Present
(Node
) then
870 elsif Constant_Present
(Node
) then
871 Write_Str
("constant ");
874 Sprint_Node
(Subtype_Mark
(Node
));
877 when N_Access_Function_Definition
=>
881 if Null_Exclusion_Present
(Node
) then
882 Write_Str
("not null ");
885 Write_Str_With_Col_Check_Sloc
("access ");
887 if Protected_Present
(Node
) then
888 Write_Str_With_Col_Check
("protected ");
891 Write_Str_With_Col_Check
("function");
892 Write_Param_Specs
(Node
);
893 Write_Str_With_Col_Check
(" return ");
894 Sprint_Node
(Result_Definition
(Node
));
896 when N_Access_Procedure_Definition
=>
900 if Null_Exclusion_Present
(Node
) then
901 Write_Str
("not null ");
904 Write_Str_With_Col_Check_Sloc
("access ");
906 if Protected_Present
(Node
) then
907 Write_Str_With_Col_Check
("protected ");
910 Write_Str_With_Col_Check
("procedure");
911 Write_Param_Specs
(Node
);
913 when N_Access_To_Object_Definition
=>
914 Write_Str_With_Col_Check_Sloc
("access ");
916 if All_Present
(Node
) then
917 Write_Str_With_Col_Check
("all ");
918 elsif Constant_Present
(Node
) then
919 Write_Str_With_Col_Check
("constant ");
924 if Null_Exclusion_Present
(Node
) then
925 Write_Str
("not null ");
928 Sprint_Node
(Subtype_Indication
(Node
));
931 if Null_Record_Present
(Node
) then
932 Write_Str_With_Col_Check_Sloc
("(null record)");
935 Write_Str_With_Col_Check_Sloc
("(");
937 if Present
(Expressions
(Node
)) then
938 Sprint_Comma_List
(Expressions
(Node
));
940 if Present
(Component_Associations
(Node
))
941 and then not Is_Empty_List
(Component_Associations
(Node
))
947 if Present
(Component_Associations
(Node
))
948 and then not Is_Empty_List
(Component_Associations
(Node
))
956 Nd
:= First
(Component_Associations
(Node
));
964 if not Is_Rewrite_Insertion
(Nd
)
965 or else not Dump_Original_Only
979 Write_Str_With_Col_Check_Sloc
("new ");
983 if Null_Exclusion_Present
(Node
) then
984 Write_Str
("not null ");
987 Sprint_Node
(Expression
(Node
));
989 if Present
(Storage_Pool
(Node
)) then
990 Write_Str_With_Col_Check
("[storage_pool = ");
991 Sprint_Node
(Storage_Pool
(Node
));
996 Sprint_Left_Opnd
(Node
);
997 Write_Str_Sloc
(" and then ");
998 Sprint_Right_Opnd
(Node
);
1001 Write_Indent_Str_Sloc
("for ");
1002 Write_Id
(Identifier
(Node
));
1003 Write_Str_With_Col_Check
(" use at ");
1004 Sprint_Node
(Expression
(Node
));
1007 when N_Assignment_Statement
=>
1009 Sprint_Node
(Name
(Node
));
1010 Write_Str_Sloc
(" := ");
1011 Sprint_Node
(Expression
(Node
));
1014 when N_Asynchronous_Select
=>
1015 Write_Indent_Str_Sloc
("select");
1017 Sprint_Node
(Triggering_Alternative
(Node
));
1020 -- Note: let the printing of Abortable_Part handle outputting
1021 -- the ABORT keyword, so that the Sloc can be set correctly.
1023 Write_Indent_Str
("then ");
1024 Sprint_Node
(Abortable_Part
(Node
));
1025 Write_Indent_Str
("end select;");
1027 when N_Attribute_Definition_Clause
=>
1028 Write_Indent_Str_Sloc
("for ");
1029 Sprint_Node
(Name
(Node
));
1031 Write_Name_With_Col_Check
(Chars
(Node
));
1032 Write_Str_With_Col_Check
(" use ");
1033 Sprint_Node
(Expression
(Node
));
1036 when N_Attribute_Reference
=>
1037 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1041 Sprint_Node
(Prefix
(Node
));
1042 Write_Char_Sloc
(''');
1043 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
1044 Sprint_Paren_Comma_List
(Expressions
(Node
));
1046 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1050 when N_Block_Statement
=>
1053 if Present
(Identifier
(Node
))
1054 and then (not Has_Created_Identifier
(Node
)
1055 or else not Dump_Original_Only
)
1057 Write_Rewrite_Str
("<<<");
1058 Write_Id
(Identifier
(Node
));
1060 Write_Rewrite_Str
(">>>");
1063 if Present
(Declarations
(Node
)) then
1064 Write_Str_With_Col_Check_Sloc
("declare");
1065 Sprint_Indented_List
(Declarations
(Node
));
1069 Write_Str_With_Col_Check_Sloc
("begin");
1070 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1071 Write_Indent_Str
("end");
1073 if Present
(Identifier
(Node
))
1074 and then (not Has_Created_Identifier
(Node
)
1075 or else not Dump_Original_Only
)
1077 Write_Rewrite_Str
("<<<");
1079 Write_Id
(Identifier
(Node
));
1080 Write_Rewrite_Str
(">>>");
1085 when N_Case_Statement
=>
1086 Write_Indent_Str_Sloc
("case ");
1087 Sprint_Node
(Expression
(Node
));
1089 Sprint_Indented_List
(Alternatives
(Node
));
1090 Write_Indent_Str
("end case;");
1092 when N_Case_Statement_Alternative
=>
1093 Write_Indent_Str_Sloc
("when ");
1094 Sprint_Bar_List
(Discrete_Choices
(Node
));
1096 Sprint_Indented_List
(Statements
(Node
));
1098 when N_Character_Literal
=>
1099 if Column
> Sprint_Line_Limit
- 2 then
1100 Write_Indent_Str
(" ");
1103 Write_Char_Sloc
(''');
1104 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
1107 when N_Code_Statement
=>
1110 Sprint_Node
(Expression
(Node
));
1113 when N_Compilation_Unit
=>
1114 Sprint_Node_List
(Context_Items
(Node
));
1115 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
1117 if Private_Present
(Node
) then
1118 Write_Indent_Str
("private ");
1122 Sprint_Node_Sloc
(Unit
(Node
));
1124 if Present
(Actions
(Aux_Decls_Node
(Node
)))
1126 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
1131 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
1132 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
1134 when N_Compilation_Unit_Aux
=>
1135 null; -- nothing to do, never used, see above
1137 when N_Component_Association
=>
1139 Sprint_Bar_List
(Choices
(Node
));
1142 -- Ada 2005 (AI-287): Print the box if present
1144 if Box_Present
(Node
) then
1145 Write_Str_With_Col_Check
("<>");
1147 Sprint_Node
(Expression
(Node
));
1150 when N_Component_Clause
=>
1152 Sprint_Node
(Component_Name
(Node
));
1153 Write_Str_Sloc
(" at ");
1154 Sprint_Node
(Position
(Node
));
1156 Write_Str_With_Col_Check
("range ");
1157 Sprint_Node
(First_Bit
(Node
));
1159 Sprint_Node
(Last_Bit
(Node
));
1162 when N_Component_Definition
=>
1165 -- Ada 2005 (AI-230): Access definition components
1167 if Present
(Access_Definition
(Node
)) then
1168 Sprint_Node
(Access_Definition
(Node
));
1170 elsif Present
(Subtype_Indication
(Node
)) then
1171 if Aliased_Present
(Node
) then
1172 Write_Str_With_Col_Check
("aliased ");
1175 -- Ada 2005 (AI-231)
1177 if Null_Exclusion_Present
(Node
) then
1178 Write_Str
(" not null ");
1181 Sprint_Node
(Subtype_Indication
(Node
));
1184 Write_Str
(" ??? ");
1187 when N_Component_Declaration
=>
1188 if Write_Indent_Identifiers_Sloc
(Node
) then
1190 Sprint_Node
(Component_Definition
(Node
));
1192 if Present
(Expression
(Node
)) then
1194 Sprint_Node
(Expression
(Node
));
1200 when N_Component_List
=>
1201 if Null_Present
(Node
) then
1203 Write_Indent_Str_Sloc
("null");
1209 Sprint_Indented_List
(Component_Items
(Node
));
1210 Sprint_Node
(Variant_Part
(Node
));
1213 when N_Conditional_Entry_Call
=>
1214 Write_Indent_Str_Sloc
("select");
1216 Sprint_Node
(Entry_Call_Alternative
(Node
));
1218 Write_Indent_Str
("else");
1219 Sprint_Indented_List
(Else_Statements
(Node
));
1220 Write_Indent_Str
("end select;");
1222 when N_Conditional_Expression
=>
1224 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
1225 Then_Expr
: constant Node_Id
:= Next
(Condition
);
1226 Else_Expr
: constant Node_Id
:= Next
(Then_Expr
);
1228 Write_Str_With_Col_Check_Sloc
("(if ");
1229 Sprint_Node
(Condition
);
1230 Write_Str_With_Col_Check
(" then ");
1231 Sprint_Node
(Then_Expr
);
1232 Write_Str_With_Col_Check
(" else ");
1233 Sprint_Node
(Else_Expr
);
1237 when N_Constrained_Array_Definition
=>
1238 Write_Str_With_Col_Check_Sloc
("array ");
1239 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1242 Sprint_Node
(Component_Definition
(Node
));
1244 when N_Decimal_Fixed_Point_Definition
=>
1245 Write_Str_With_Col_Check_Sloc
(" delta ");
1246 Sprint_Node
(Delta_Expression
(Node
));
1247 Write_Str_With_Col_Check
("digits ");
1248 Sprint_Node
(Digits_Expression
(Node
));
1249 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1251 when N_Defining_Character_Literal
=>
1252 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1254 when N_Defining_Identifier
=>
1258 when N_Defining_Operator_Symbol
=>
1259 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1261 when N_Defining_Program_Unit_Name
=>
1263 Sprint_Node
(Name
(Node
));
1265 Write_Id
(Defining_Identifier
(Node
));
1267 when N_Delay_Alternative
=>
1268 Sprint_Node_List
(Pragmas_Before
(Node
));
1270 if Present
(Condition
(Node
)) then
1272 Write_Str_With_Col_Check
("when ");
1273 Sprint_Node
(Condition
(Node
));
1278 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1279 Sprint_Node_List
(Statements
(Node
));
1281 when N_Delay_Relative_Statement
=>
1282 Write_Indent_Str_Sloc
("delay ");
1283 Sprint_Node
(Expression
(Node
));
1286 when N_Delay_Until_Statement
=>
1287 Write_Indent_Str_Sloc
("delay until ");
1288 Sprint_Node
(Expression
(Node
));
1291 when N_Delta_Constraint
=>
1292 Write_Str_With_Col_Check_Sloc
("delta ");
1293 Sprint_Node
(Delta_Expression
(Node
));
1294 Sprint_Opt_Node
(Range_Constraint
(Node
));
1296 when N_Derived_Type_Definition
=>
1297 if Abstract_Present
(Node
) then
1298 Write_Str_With_Col_Check
("abstract ");
1301 Write_Str_With_Col_Check_Sloc
("new ");
1303 -- Ada 2005 (AI-231)
1305 if Null_Exclusion_Present
(Node
) then
1306 Write_Str_With_Col_Check
("not null ");
1309 Sprint_Node
(Subtype_Indication
(Node
));
1311 if Present
(Interface_List
(Node
)) then
1312 Write_Str_With_Col_Check
(" and ");
1313 Sprint_And_List
(Interface_List
(Node
));
1314 Write_Str_With_Col_Check
(" with ");
1317 if Present
(Record_Extension_Part
(Node
)) then
1318 if No
(Interface_List
(Node
)) then
1319 Write_Str_With_Col_Check
(" with ");
1322 Sprint_Node
(Record_Extension_Part
(Node
));
1325 when N_Designator
=>
1326 Sprint_Node
(Name
(Node
));
1327 Write_Char_Sloc
('.');
1328 Write_Id
(Identifier
(Node
));
1330 when N_Digits_Constraint
=>
1331 Write_Str_With_Col_Check_Sloc
("digits ");
1332 Sprint_Node
(Digits_Expression
(Node
));
1333 Sprint_Opt_Node
(Range_Constraint
(Node
));
1335 when N_Discriminant_Association
=>
1338 if Present
(Selector_Names
(Node
)) then
1339 Sprint_Bar_List
(Selector_Names
(Node
));
1344 Sprint_Node
(Expression
(Node
));
1346 when N_Discriminant_Specification
=>
1349 if Write_Identifiers
(Node
) then
1352 if Null_Exclusion_Present
(Node
) then
1353 Write_Str
("not null ");
1356 Sprint_Node
(Discriminant_Type
(Node
));
1358 if Present
(Expression
(Node
)) then
1360 Sprint_Node
(Expression
(Node
));
1366 when N_Elsif_Part
=>
1367 Write_Indent_Str_Sloc
("elsif ");
1368 Sprint_Node
(Condition
(Node
));
1369 Write_Str_With_Col_Check
(" then");
1370 Sprint_Indented_List
(Then_Statements
(Node
));
1375 when N_Entry_Body
=>
1376 Write_Indent_Str_Sloc
("entry ");
1377 Write_Id
(Defining_Identifier
(Node
));
1378 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1379 Write_Str_With_Col_Check
(" is");
1380 Sprint_Indented_List
(Declarations
(Node
));
1381 Write_Indent_Str
("begin");
1382 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1383 Write_Indent_Str
("end ");
1384 Write_Id
(Defining_Identifier
(Node
));
1387 when N_Entry_Body_Formal_Part
=>
1388 if Present
(Entry_Index_Specification
(Node
)) then
1389 Write_Str_With_Col_Check_Sloc
(" (");
1390 Sprint_Node
(Entry_Index_Specification
(Node
));
1394 Write_Param_Specs
(Node
);
1395 Write_Str_With_Col_Check_Sloc
(" when ");
1396 Sprint_Node
(Condition
(Node
));
1398 when N_Entry_Call_Alternative
=>
1399 Sprint_Node_List
(Pragmas_Before
(Node
));
1400 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1401 Sprint_Node_List
(Statements
(Node
));
1403 when N_Entry_Call_Statement
=>
1405 Sprint_Node_Sloc
(Name
(Node
));
1406 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1409 when N_Entry_Declaration
=>
1410 Write_Indent_Str_Sloc
("entry ");
1411 Write_Id
(Defining_Identifier
(Node
));
1413 if Present
(Discrete_Subtype_Definition
(Node
)) then
1414 Write_Str_With_Col_Check
(" (");
1415 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1419 Write_Param_Specs
(Node
);
1422 when N_Entry_Index_Specification
=>
1423 Write_Str_With_Col_Check_Sloc
("for ");
1424 Write_Id
(Defining_Identifier
(Node
));
1425 Write_Str_With_Col_Check
(" in ");
1426 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1428 when N_Enumeration_Representation_Clause
=>
1429 Write_Indent_Str_Sloc
("for ");
1430 Write_Id
(Identifier
(Node
));
1431 Write_Str_With_Col_Check
(" use ");
1432 Sprint_Node
(Array_Aggregate
(Node
));
1435 when N_Enumeration_Type_Definition
=>
1438 -- Skip attempt to print Literals field if it's not there and
1439 -- we are in package Standard (case of Character, which is
1440 -- handled specially (without an explicit literals list).
1442 if Sloc
(Node
) > Standard_Location
1443 or else Present
(Literals
(Node
))
1445 Sprint_Paren_Comma_List
(Literals
(Node
));
1449 Write_Str_With_Col_Check_Sloc
("<error>");
1451 when N_Exception_Declaration
=>
1452 if Write_Indent_Identifiers
(Node
) then
1453 Write_Str_With_Col_Check
(" : ");
1455 if Is_Statically_Allocated
(Defining_Identifier
(Node
)) then
1456 Write_Str_With_Col_Check
("static ");
1459 Write_Str_Sloc
("exception");
1461 if Present
(Expression
(Node
)) then
1463 Sprint_Node
(Expression
(Node
));
1469 when N_Exception_Handler
=>
1470 Write_Indent_Str_Sloc
("when ");
1472 if Present
(Choice_Parameter
(Node
)) then
1473 Sprint_Node
(Choice_Parameter
(Node
));
1477 Sprint_Bar_List
(Exception_Choices
(Node
));
1479 Sprint_Indented_List
(Statements
(Node
));
1481 when N_Exception_Renaming_Declaration
=>
1484 Sprint_Node
(Defining_Identifier
(Node
));
1485 Write_Str_With_Col_Check
(" : exception renames ");
1486 Sprint_Node
(Name
(Node
));
1489 when N_Exit_Statement
=>
1490 Write_Indent_Str_Sloc
("exit");
1491 Sprint_Opt_Node
(Name
(Node
));
1493 if Present
(Condition
(Node
)) then
1494 Write_Str_With_Col_Check
(" when ");
1495 Sprint_Node
(Condition
(Node
));
1500 when N_Expanded_Name
=>
1501 Sprint_Node
(Prefix
(Node
));
1502 Write_Char_Sloc
('.');
1503 Sprint_Node
(Selector_Name
(Node
));
1505 when N_Explicit_Dereference
=>
1506 Sprint_Node
(Prefix
(Node
));
1507 Write_Char_Sloc
('.');
1508 Write_Str_Sloc
("all");
1510 when N_Extended_Return_Statement
=>
1511 Write_Indent_Str_Sloc
("return ");
1512 Sprint_Node_List
(Return_Object_Declarations
(Node
));
1514 if Present
(Handled_Statement_Sequence
(Node
)) then
1515 Write_Str_With_Col_Check
(" do");
1516 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1517 Write_Indent_Str
("end return;");
1519 Write_Indent_Str
(";");
1522 when N_Extension_Aggregate
=>
1523 Write_Str_With_Col_Check_Sloc
("(");
1524 Sprint_Node
(Ancestor_Part
(Node
));
1525 Write_Str_With_Col_Check
(" with ");
1527 if Null_Record_Present
(Node
) then
1528 Write_Str_With_Col_Check
("null record");
1530 if Present
(Expressions
(Node
)) then
1531 Sprint_Comma_List
(Expressions
(Node
));
1533 if Present
(Component_Associations
(Node
)) then
1538 if Present
(Component_Associations
(Node
)) then
1539 Sprint_Comma_List
(Component_Associations
(Node
));
1545 when N_Floating_Point_Definition
=>
1546 Write_Str_With_Col_Check_Sloc
("digits ");
1547 Sprint_Node
(Digits_Expression
(Node
));
1548 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1550 when N_Formal_Decimal_Fixed_Point_Definition
=>
1551 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1553 when N_Formal_Derived_Type_Definition
=>
1554 Write_Str_With_Col_Check_Sloc
("new ");
1555 Sprint_Node
(Subtype_Mark
(Node
));
1557 if Present
(Interface_List
(Node
)) then
1558 Write_Str_With_Col_Check
(" and ");
1559 Sprint_And_List
(Interface_List
(Node
));
1562 if Private_Present
(Node
) then
1563 Write_Str_With_Col_Check
(" with private");
1566 when N_Formal_Abstract_Subprogram_Declaration
=>
1567 Write_Indent_Str_Sloc
("with ");
1568 Sprint_Node
(Specification
(Node
));
1570 Write_Str_With_Col_Check
(" is abstract");
1572 if Box_Present
(Node
) then
1573 Write_Str_With_Col_Check
(" <>");
1574 elsif Present
(Default_Name
(Node
)) then
1575 Write_Str_With_Col_Check
(" ");
1576 Sprint_Node
(Default_Name
(Node
));
1581 when N_Formal_Concrete_Subprogram_Declaration
=>
1582 Write_Indent_Str_Sloc
("with ");
1583 Sprint_Node
(Specification
(Node
));
1585 if Box_Present
(Node
) then
1586 Write_Str_With_Col_Check
(" is <>");
1587 elsif Present
(Default_Name
(Node
)) then
1588 Write_Str_With_Col_Check
(" is ");
1589 Sprint_Node
(Default_Name
(Node
));
1594 when N_Formal_Discrete_Type_Definition
=>
1595 Write_Str_With_Col_Check_Sloc
("<>");
1597 when N_Formal_Floating_Point_Definition
=>
1598 Write_Str_With_Col_Check_Sloc
("digits <>");
1600 when N_Formal_Modular_Type_Definition
=>
1601 Write_Str_With_Col_Check_Sloc
("mod <>");
1603 when N_Formal_Object_Declaration
=>
1606 if Write_Indent_Identifiers
(Node
) then
1609 if In_Present
(Node
) then
1610 Write_Str_With_Col_Check
("in ");
1613 if Out_Present
(Node
) then
1614 Write_Str_With_Col_Check
("out ");
1617 if Present
(Subtype_Mark
(Node
)) then
1619 -- Ada 2005 (AI-423): Formal object with null exclusion
1621 if Null_Exclusion_Present
(Node
) then
1622 Write_Str
("not null ");
1625 Sprint_Node
(Subtype_Mark
(Node
));
1627 -- Ada 2005 (AI-423): Formal object with access definition
1630 pragma Assert
(Present
(Access_Definition
(Node
)));
1632 Sprint_Node
(Access_Definition
(Node
));
1635 if Present
(Default_Expression
(Node
)) then
1637 Sprint_Node
(Default_Expression
(Node
));
1643 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1644 Write_Str_With_Col_Check_Sloc
("delta <>");
1646 when N_Formal_Package_Declaration
=>
1647 Write_Indent_Str_Sloc
("with package ");
1648 Write_Id
(Defining_Identifier
(Node
));
1649 Write_Str_With_Col_Check
(" is new ");
1650 Sprint_Node
(Name
(Node
));
1651 Write_Str_With_Col_Check
(" (<>);");
1653 when N_Formal_Private_Type_Definition
=>
1654 if Abstract_Present
(Node
) then
1655 Write_Str_With_Col_Check
("abstract ");
1658 if Tagged_Present
(Node
) then
1659 Write_Str_With_Col_Check
("tagged ");
1662 if Limited_Present
(Node
) then
1663 Write_Str_With_Col_Check
("limited ");
1666 Write_Str_With_Col_Check_Sloc
("private");
1668 when N_Formal_Signed_Integer_Type_Definition
=>
1669 Write_Str_With_Col_Check_Sloc
("range <>");
1671 when N_Formal_Type_Declaration
=>
1672 Write_Indent_Str_Sloc
("type ");
1673 Write_Id
(Defining_Identifier
(Node
));
1675 if Present
(Discriminant_Specifications
(Node
)) then
1676 Write_Discr_Specs
(Node
);
1677 elsif Unknown_Discriminants_Present
(Node
) then
1678 Write_Str_With_Col_Check
("(<>)");
1681 Write_Str_With_Col_Check
(" is ");
1682 Sprint_Node
(Formal_Type_Definition
(Node
));
1685 when N_Free_Statement
=>
1686 Write_Indent_Str_Sloc
("free ");
1687 Sprint_Node
(Expression
(Node
));
1690 when N_Freeze_Entity
=>
1691 if Dump_Original_Only
then
1694 elsif Present
(Actions
(Node
)) or else Dump_Freeze_Null
then
1696 Write_Rewrite_Str
("<<<");
1697 Write_Str_With_Col_Check_Sloc
("freeze ");
1698 Write_Id
(Entity
(Node
));
1701 if No
(Actions
(Node
)) then
1705 -- Output freeze actions. We increment Freeze_Indent during
1706 -- this output to avoid generating extra blank lines before
1707 -- any procedures included in the freeze actions.
1709 Freeze_Indent
:= Freeze_Indent
+ 1;
1710 Sprint_Indented_List
(Actions
(Node
));
1711 Freeze_Indent
:= Freeze_Indent
- 1;
1712 Write_Indent_Str
("]");
1715 Write_Rewrite_Str
(">>>");
1718 when N_Full_Type_Declaration
=>
1719 Write_Indent_Str_Sloc
("type ");
1720 Sprint_Node
(Defining_Identifier
(Node
));
1721 Write_Discr_Specs
(Node
);
1722 Write_Str_With_Col_Check
(" is ");
1723 Sprint_Node
(Type_Definition
(Node
));
1726 when N_Function_Call
=>
1728 Write_Subprogram_Name
(Name
(Node
));
1729 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1731 when N_Function_Instantiation
=>
1732 Write_Indent_Str_Sloc
("function ");
1733 Sprint_Node
(Defining_Unit_Name
(Node
));
1734 Write_Str_With_Col_Check
(" is new ");
1735 Sprint_Node
(Name
(Node
));
1736 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1739 when N_Function_Specification
=>
1740 Write_Str_With_Col_Check_Sloc
("function ");
1741 Sprint_Node
(Defining_Unit_Name
(Node
));
1742 Write_Param_Specs
(Node
);
1743 Write_Str_With_Col_Check
(" return ");
1745 -- Ada 2005 (AI-231)
1747 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
1748 and then Null_Exclusion_Present
(Node
)
1750 Write_Str
(" not null ");
1753 Sprint_Node
(Result_Definition
(Node
));
1755 when N_Generic_Association
=>
1758 if Present
(Selector_Name
(Node
)) then
1759 Sprint_Node
(Selector_Name
(Node
));
1763 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
1765 when N_Generic_Function_Renaming_Declaration
=>
1766 Write_Indent_Str_Sloc
("generic function ");
1767 Sprint_Node
(Defining_Unit_Name
(Node
));
1768 Write_Str_With_Col_Check
(" renames ");
1769 Sprint_Node
(Name
(Node
));
1772 when N_Generic_Package_Declaration
=>
1774 Write_Indent_Str_Sloc
("generic ");
1775 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1777 Sprint_Node
(Specification
(Node
));
1780 when N_Generic_Package_Renaming_Declaration
=>
1781 Write_Indent_Str_Sloc
("generic package ");
1782 Sprint_Node
(Defining_Unit_Name
(Node
));
1783 Write_Str_With_Col_Check
(" renames ");
1784 Sprint_Node
(Name
(Node
));
1787 when N_Generic_Procedure_Renaming_Declaration
=>
1788 Write_Indent_Str_Sloc
("generic procedure ");
1789 Sprint_Node
(Defining_Unit_Name
(Node
));
1790 Write_Str_With_Col_Check
(" renames ");
1791 Sprint_Node
(Name
(Node
));
1794 when N_Generic_Subprogram_Declaration
=>
1796 Write_Indent_Str_Sloc
("generic ");
1797 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1799 Sprint_Node
(Specification
(Node
));
1802 when N_Goto_Statement
=>
1803 Write_Indent_Str_Sloc
("goto ");
1804 Sprint_Node
(Name
(Node
));
1807 if Nkind
(Next
(Node
)) = N_Label
then
1811 when N_Handled_Sequence_Of_Statements
=>
1813 Sprint_Indented_List
(Statements
(Node
));
1815 if Present
(Exception_Handlers
(Node
)) then
1816 Write_Indent_Str
("exception");
1818 Sprint_Node_List
(Exception_Handlers
(Node
));
1822 if Present
(At_End_Proc
(Node
)) then
1823 Write_Indent_Str
("at end");
1826 Sprint_Node
(At_End_Proc
(Node
));
1831 when N_Identifier
=>
1835 when N_If_Statement
=>
1836 Write_Indent_Str_Sloc
("if ");
1837 Sprint_Node
(Condition
(Node
));
1838 Write_Str_With_Col_Check
(" then");
1839 Sprint_Indented_List
(Then_Statements
(Node
));
1840 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
1842 if Present
(Else_Statements
(Node
)) then
1843 Write_Indent_Str
("else");
1844 Sprint_Indented_List
(Else_Statements
(Node
));
1847 Write_Indent_Str
("end if;");
1849 when N_Implicit_Label_Declaration
=>
1850 if not Dump_Original_Only
then
1852 Write_Rewrite_Str
("<<<");
1854 Write_Id
(Defining_Identifier
(Node
));
1856 Write_Str_With_Col_Check
("label");
1857 Write_Rewrite_Str
(">>>");
1861 Sprint_Left_Opnd
(Node
);
1862 Write_Str_Sloc
(" in ");
1864 if Present
(Right_Opnd
(Node
)) then
1865 Sprint_Right_Opnd
(Node
);
1867 Sprint_Bar_List
(Alternatives
(Node
));
1870 when N_Incomplete_Type_Declaration
=>
1871 Write_Indent_Str_Sloc
("type ");
1872 Write_Id
(Defining_Identifier
(Node
));
1874 if Present
(Discriminant_Specifications
(Node
)) then
1875 Write_Discr_Specs
(Node
);
1876 elsif Unknown_Discriminants_Present
(Node
) then
1877 Write_Str_With_Col_Check
("(<>)");
1882 when N_Index_Or_Discriminant_Constraint
=>
1884 Sprint_Paren_Comma_List
(Constraints
(Node
));
1886 when N_Indexed_Component
=>
1887 Sprint_Node_Sloc
(Prefix
(Node
));
1888 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
1890 when N_Integer_Literal
=>
1891 if Print_In_Hex
(Node
) then
1892 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
1894 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
1897 when N_Iteration_Scheme
=>
1898 if Present
(Condition
(Node
)) then
1899 Write_Str_With_Col_Check_Sloc
("while ");
1900 Sprint_Node
(Condition
(Node
));
1902 Write_Str_With_Col_Check_Sloc
("for ");
1903 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1908 when N_Itype_Reference
=>
1909 Write_Indent_Str_Sloc
("reference ");
1910 Write_Id
(Itype
(Node
));
1913 Write_Indent_Str_Sloc
("<<");
1914 Write_Id
(Identifier
(Node
));
1917 when N_Loop_Parameter_Specification
=>
1919 Write_Id
(Defining_Identifier
(Node
));
1920 Write_Str_With_Col_Check
(" in ");
1922 if Reverse_Present
(Node
) then
1923 Write_Str_With_Col_Check
("reverse ");
1926 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1928 when N_Loop_Statement
=>
1931 if Present
(Identifier
(Node
))
1932 and then (not Has_Created_Identifier
(Node
)
1933 or else not Dump_Original_Only
)
1935 Write_Rewrite_Str
("<<<");
1936 Write_Id
(Identifier
(Node
));
1938 Write_Rewrite_Str
(">>>");
1939 Sprint_Node
(Iteration_Scheme
(Node
));
1940 Write_Str_With_Col_Check_Sloc
("loop");
1941 Sprint_Indented_List
(Statements
(Node
));
1942 Write_Indent_Str
("end loop ");
1943 Write_Rewrite_Str
("<<<");
1944 Write_Id
(Identifier
(Node
));
1945 Write_Rewrite_Str
(">>>");
1949 Sprint_Node
(Iteration_Scheme
(Node
));
1950 Write_Str_With_Col_Check_Sloc
("loop");
1951 Sprint_Indented_List
(Statements
(Node
));
1952 Write_Indent_Str
("end loop;");
1955 when N_Mod_Clause
=>
1956 Sprint_Node_List
(Pragmas_Before
(Node
));
1957 Write_Str_With_Col_Check_Sloc
("at mod ");
1958 Sprint_Node
(Expression
(Node
));
1960 when N_Modular_Type_Definition
=>
1961 Write_Str_With_Col_Check_Sloc
("mod ");
1962 Sprint_Node
(Expression
(Node
));
1965 Sprint_Left_Opnd
(Node
);
1966 Write_Str_Sloc
(" not in ");
1968 if Present
(Right_Opnd
(Node
)) then
1969 Sprint_Right_Opnd
(Node
);
1971 Sprint_Bar_List
(Alternatives
(Node
));
1975 Write_Str_With_Col_Check_Sloc
("null");
1977 when N_Null_Statement
=>
1978 if Comes_From_Source
(Node
)
1979 or else Dump_Freeze_Null
1980 or else not Is_List_Member
(Node
)
1981 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
1983 Write_Indent_Str_Sloc
("null;");
1986 when N_Number_Declaration
=>
1989 if Write_Indent_Identifiers
(Node
) then
1990 Write_Str_With_Col_Check
(" : constant ");
1992 Sprint_Node
(Expression
(Node
));
1996 when N_Object_Declaration
=>
1999 if Write_Indent_Identifiers
(Node
) then
2001 Def_Id
: constant Entity_Id
:= Defining_Identifier
(Node
);
2004 Write_Str_With_Col_Check
(" : ");
2006 if Is_Statically_Allocated
(Def_Id
) then
2007 Write_Str_With_Col_Check
("static ");
2010 if Aliased_Present
(Node
) then
2011 Write_Str_With_Col_Check
("aliased ");
2014 if Constant_Present
(Node
) then
2015 Write_Str_With_Col_Check
("constant ");
2018 -- Ada 2005 (AI-231)
2020 if Null_Exclusion_Present
(Node
) then
2021 Write_Str_With_Col_Check
("not null ");
2024 Sprint_Node
(Object_Definition
(Node
));
2026 if Present
(Expression
(Node
)) then
2028 Sprint_Node
(Expression
(Node
));
2033 -- Handle implicit importation and implicit exportation of
2034 -- object declarations:
2035 -- $pragma import (Convention_Id, Def_Id, "...");
2036 -- $pragma export (Convention_Id, Def_Id, "...");
2038 if Is_Internal
(Def_Id
)
2039 and then Present
(Interface_Name
(Def_Id
))
2041 Write_Indent_Str_Sloc
("$pragma ");
2043 if Is_Imported
(Def_Id
) then
2044 Write_Str
("import (");
2046 else pragma Assert
(Is_Exported
(Def_Id
));
2047 Write_Str
("export (");
2051 Prefix
: constant String := "Convention_";
2052 S
: constant String := Convention
(Def_Id
)'Img;
2055 Name_Len
:= S
'Last - Prefix
'Last;
2056 Name_Buffer
(1 .. Name_Len
) :=
2057 S
(Prefix
'Last + 1 .. S
'Last);
2058 Set_Casing
(All_Lower_Case
);
2059 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2065 Write_String_Table_Entry
2066 (Strval
(Interface_Name
(Def_Id
)));
2072 when N_Object_Renaming_Declaration
=>
2075 Sprint_Node
(Defining_Identifier
(Node
));
2078 -- Ada 2005 (AI-230): Access renamings
2080 if Present
(Access_Definition
(Node
)) then
2081 Sprint_Node
(Access_Definition
(Node
));
2083 elsif Present
(Subtype_Mark
(Node
)) then
2085 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2087 if Null_Exclusion_Present
(Node
) then
2088 Write_Str
("not null ");
2091 Sprint_Node
(Subtype_Mark
(Node
));
2094 Write_Str
(" ??? ");
2097 Write_Str_With_Col_Check
(" renames ");
2098 Sprint_Node
(Name
(Node
));
2102 Write_Operator
(Node
, "abs ");
2103 Sprint_Right_Opnd
(Node
);
2106 Sprint_Left_Opnd
(Node
);
2107 Write_Operator
(Node
, " + ");
2108 Sprint_Right_Opnd
(Node
);
2111 Sprint_Left_Opnd
(Node
);
2112 Write_Operator
(Node
, " and ");
2113 Sprint_Right_Opnd
(Node
);
2116 Sprint_Left_Opnd
(Node
);
2117 Write_Operator
(Node
, " & ");
2118 Sprint_Right_Opnd
(Node
);
2121 Sprint_Left_Opnd
(Node
);
2123 Process_TFAI_RR_Flags
(Node
);
2124 Write_Operator
(Node
, "/ ");
2125 Sprint_Right_Opnd
(Node
);
2128 Sprint_Left_Opnd
(Node
);
2129 Write_Operator
(Node
, " = ");
2130 Sprint_Right_Opnd
(Node
);
2133 Sprint_Left_Opnd
(Node
);
2134 Write_Operator
(Node
, " ** ");
2135 Sprint_Right_Opnd
(Node
);
2138 Sprint_Left_Opnd
(Node
);
2139 Write_Operator
(Node
, " >= ");
2140 Sprint_Right_Opnd
(Node
);
2143 Sprint_Left_Opnd
(Node
);
2144 Write_Operator
(Node
, " > ");
2145 Sprint_Right_Opnd
(Node
);
2148 Sprint_Left_Opnd
(Node
);
2149 Write_Operator
(Node
, " <= ");
2150 Sprint_Right_Opnd
(Node
);
2153 Sprint_Left_Opnd
(Node
);
2154 Write_Operator
(Node
, " < ");
2155 Sprint_Right_Opnd
(Node
);
2158 Write_Operator
(Node
, "-");
2159 Sprint_Right_Opnd
(Node
);
2162 Sprint_Left_Opnd
(Node
);
2164 if Treat_Fixed_As_Integer
(Node
) then
2168 Write_Operator
(Node
, " mod ");
2169 Sprint_Right_Opnd
(Node
);
2171 when N_Op_Multiply
=>
2172 Sprint_Left_Opnd
(Node
);
2174 Process_TFAI_RR_Flags
(Node
);
2175 Write_Operator
(Node
, "* ");
2176 Sprint_Right_Opnd
(Node
);
2179 Sprint_Left_Opnd
(Node
);
2180 Write_Operator
(Node
, " /= ");
2181 Sprint_Right_Opnd
(Node
);
2184 Write_Operator
(Node
, "not ");
2185 Sprint_Right_Opnd
(Node
);
2188 Sprint_Left_Opnd
(Node
);
2189 Write_Operator
(Node
, " or ");
2190 Sprint_Right_Opnd
(Node
);
2193 Write_Operator
(Node
, "+");
2194 Sprint_Right_Opnd
(Node
);
2197 Sprint_Left_Opnd
(Node
);
2199 if Treat_Fixed_As_Integer
(Node
) then
2203 Write_Operator
(Node
, " rem ");
2204 Sprint_Right_Opnd
(Node
);
2210 Write_Str_With_Col_Check
("(");
2211 Sprint_Node
(Left_Opnd
(Node
));
2213 Sprint_Node
(Right_Opnd
(Node
));
2216 when N_Op_Subtract
=>
2217 Sprint_Left_Opnd
(Node
);
2218 Write_Operator
(Node
, " - ");
2219 Sprint_Right_Opnd
(Node
);
2222 Sprint_Left_Opnd
(Node
);
2223 Write_Operator
(Node
, " xor ");
2224 Sprint_Right_Opnd
(Node
);
2226 when N_Operator_Symbol
=>
2227 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
2229 when N_Ordinary_Fixed_Point_Definition
=>
2230 Write_Str_With_Col_Check_Sloc
("delta ");
2231 Sprint_Node
(Delta_Expression
(Node
));
2232 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
2235 Sprint_Left_Opnd
(Node
);
2236 Write_Str_Sloc
(" or else ");
2237 Sprint_Right_Opnd
(Node
);
2239 when N_Others_Choice
=>
2240 if All_Others
(Node
) then
2241 Write_Str_With_Col_Check
("all ");
2244 Write_Str_With_Col_Check_Sloc
("others");
2246 when N_Package_Body
=>
2248 Write_Indent_Str_Sloc
("package body ");
2249 Sprint_Node
(Defining_Unit_Name
(Node
));
2251 Sprint_Indented_List
(Declarations
(Node
));
2253 if Present
(Handled_Statement_Sequence
(Node
)) then
2254 Write_Indent_Str
("begin");
2255 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2258 Write_Indent_Str
("end ");
2260 (Handled_Statement_Sequence
(Node
), Defining_Unit_Name
(Node
));
2263 when N_Package_Body_Stub
=>
2264 Write_Indent_Str_Sloc
("package body ");
2265 Sprint_Node
(Defining_Identifier
(Node
));
2266 Write_Str_With_Col_Check
(" is separate;");
2268 when N_Package_Declaration
=>
2271 Sprint_Node_Sloc
(Specification
(Node
));
2274 when N_Package_Instantiation
=>
2276 Write_Indent_Str_Sloc
("package ");
2277 Sprint_Node
(Defining_Unit_Name
(Node
));
2278 Write_Str
(" is new ");
2279 Sprint_Node
(Name
(Node
));
2280 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2283 when N_Package_Renaming_Declaration
=>
2284 Write_Indent_Str_Sloc
("package ");
2285 Sprint_Node
(Defining_Unit_Name
(Node
));
2286 Write_Str_With_Col_Check
(" renames ");
2287 Sprint_Node
(Name
(Node
));
2290 when N_Package_Specification
=>
2291 Write_Str_With_Col_Check_Sloc
("package ");
2292 Sprint_Node
(Defining_Unit_Name
(Node
));
2294 Sprint_Indented_List
(Visible_Declarations
(Node
));
2296 if Present
(Private_Declarations
(Node
)) then
2297 Write_Indent_Str
("private");
2298 Sprint_Indented_List
(Private_Declarations
(Node
));
2301 Write_Indent_Str
("end ");
2302 Sprint_Node
(Defining_Unit_Name
(Node
));
2304 when N_Parameter_Association
=>
2305 Sprint_Node_Sloc
(Selector_Name
(Node
));
2307 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2309 when N_Parameter_Specification
=>
2312 if Write_Identifiers
(Node
) then
2315 if In_Present
(Node
) then
2316 Write_Str_With_Col_Check
("in ");
2319 if Out_Present
(Node
) then
2320 Write_Str_With_Col_Check
("out ");
2323 -- Ada 2005 (AI-231): Parameter specification may carry null
2324 -- exclusion. Do not print it now if this is an access formal,
2325 -- it is emitted when the access definition is displayed.
2327 if Null_Exclusion_Present
(Node
)
2328 and then Nkind
(Parameter_Type
(Node
))
2329 /= N_Access_Definition
2331 Write_Str
("not null ");
2334 Sprint_Node
(Parameter_Type
(Node
));
2336 if Present
(Expression
(Node
)) then
2338 Sprint_Node
(Expression
(Node
));
2344 when N_Pop_Constraint_Error_Label
=>
2345 Write_Indent_Str
("%pop_constraint_error_label");
2347 when N_Pop_Program_Error_Label
=>
2348 Write_Indent_Str
("%pop_program_error_label");
2350 when N_Pop_Storage_Error_Label
=>
2351 Write_Indent_Str
("%pop_storage_error_label");
2353 when N_Push_Constraint_Error_Label
=>
2354 Write_Indent_Str
("%push_constraint_error_label (");
2356 if Present
(Exception_Label
(Node
)) then
2357 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2362 when N_Push_Program_Error_Label
=>
2363 Write_Indent_Str
("%push_program_error_label (");
2365 if Present
(Exception_Label
(Node
)) then
2366 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2371 when N_Push_Storage_Error_Label
=>
2372 Write_Indent_Str
("%push_storage_error_label (");
2374 if Present
(Exception_Label
(Node
)) then
2375 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2381 Write_Indent_Str_Sloc
("pragma ");
2382 Write_Name_With_Col_Check
(Pragma_Name
(Node
));
2384 if Present
(Pragma_Argument_Associations
(Node
)) then
2385 Sprint_Opt_Paren_Comma_List
2386 (Pragma_Argument_Associations
(Node
));
2391 when N_Pragma_Argument_Association
=>
2394 if Chars
(Node
) /= No_Name
then
2395 Write_Name_With_Col_Check
(Chars
(Node
));
2399 Sprint_Node
(Expression
(Node
));
2401 when N_Private_Type_Declaration
=>
2402 Write_Indent_Str_Sloc
("type ");
2403 Write_Id
(Defining_Identifier
(Node
));
2405 if Present
(Discriminant_Specifications
(Node
)) then
2406 Write_Discr_Specs
(Node
);
2407 elsif Unknown_Discriminants_Present
(Node
) then
2408 Write_Str_With_Col_Check
("(<>)");
2413 if Tagged_Present
(Node
) then
2414 Write_Str_With_Col_Check
("tagged ");
2417 if Limited_Present
(Node
) then
2418 Write_Str_With_Col_Check
("limited ");
2421 Write_Str_With_Col_Check
("private;");
2423 when N_Private_Extension_Declaration
=>
2424 Write_Indent_Str_Sloc
("type ");
2425 Write_Id
(Defining_Identifier
(Node
));
2427 if Present
(Discriminant_Specifications
(Node
)) then
2428 Write_Discr_Specs
(Node
);
2429 elsif Unknown_Discriminants_Present
(Node
) then
2430 Write_Str_With_Col_Check
("(<>)");
2433 Write_Str_With_Col_Check
(" is new ");
2434 Sprint_Node
(Subtype_Indication
(Node
));
2436 if Present
(Interface_List
(Node
)) then
2437 Write_Str_With_Col_Check
(" and ");
2438 Sprint_And_List
(Interface_List
(Node
));
2441 Write_Str_With_Col_Check
(" with private;");
2443 when N_Procedure_Call_Statement
=>
2446 Write_Subprogram_Name
(Name
(Node
));
2447 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2450 when N_Procedure_Instantiation
=>
2451 Write_Indent_Str_Sloc
("procedure ");
2452 Sprint_Node
(Defining_Unit_Name
(Node
));
2453 Write_Str_With_Col_Check
(" is new ");
2454 Sprint_Node
(Name
(Node
));
2455 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2458 when N_Procedure_Specification
=>
2459 Write_Str_With_Col_Check_Sloc
("procedure ");
2460 Sprint_Node
(Defining_Unit_Name
(Node
));
2461 Write_Param_Specs
(Node
);
2463 when N_Protected_Body
=>
2464 Write_Indent_Str_Sloc
("protected body ");
2465 Write_Id
(Defining_Identifier
(Node
));
2467 Sprint_Indented_List
(Declarations
(Node
));
2468 Write_Indent_Str
("end ");
2469 Write_Id
(Defining_Identifier
(Node
));
2472 when N_Protected_Body_Stub
=>
2473 Write_Indent_Str_Sloc
("protected body ");
2474 Write_Id
(Defining_Identifier
(Node
));
2475 Write_Str_With_Col_Check
(" is separate;");
2477 when N_Protected_Definition
=>
2479 Sprint_Indented_List
(Visible_Declarations
(Node
));
2481 if Present
(Private_Declarations
(Node
)) then
2482 Write_Indent_Str
("private");
2483 Sprint_Indented_List
(Private_Declarations
(Node
));
2486 Write_Indent_Str
("end ");
2488 when N_Protected_Type_Declaration
=>
2489 Write_Indent_Str_Sloc
("protected type ");
2490 Sprint_Node
(Defining_Identifier
(Node
));
2491 Write_Discr_Specs
(Node
);
2493 if Present
(Interface_List
(Node
)) then
2494 Write_Str
(" is new ");
2495 Sprint_And_List
(Interface_List
(Node
));
2496 Write_Str
(" with ");
2501 Sprint_Node
(Protected_Definition
(Node
));
2502 Write_Id
(Defining_Identifier
(Node
));
2505 when N_Qualified_Expression
=>
2506 Sprint_Node
(Subtype_Mark
(Node
));
2507 Write_Char_Sloc
(''');
2509 -- Print expression, make sure we have at least one level of
2510 -- parentheses around the expression. For cases of qualified
2511 -- expressions in the source, this is always the case, but
2512 -- for generated qualifications, there may be no explicit
2513 -- parentheses present.
2515 if Paren_Count
(Expression
(Node
)) /= 0 then
2516 Sprint_Node
(Expression
(Node
));
2519 Sprint_Node
(Expression
(Node
));
2523 when N_Raise_Constraint_Error
=>
2525 -- This node can be used either as a subexpression or as a
2526 -- statement form. The following test is a reasonably reliable
2527 -- way to distinguish the two cases.
2529 if Is_List_Member
(Node
)
2530 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2535 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2536 Write_Condition_And_Reason
(Node
);
2538 when N_Raise_Program_Error
=>
2540 -- This node can be used either as a subexpression or as a
2541 -- statement form. The following test is a reasonably reliable
2542 -- way to distinguish the two cases.
2544 if Is_List_Member
(Node
)
2545 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2550 Write_Str_With_Col_Check_Sloc
("[program_error");
2551 Write_Condition_And_Reason
(Node
);
2553 when N_Raise_Storage_Error
=>
2555 -- This node can be used either as a subexpression or as a
2556 -- statement form. The following test is a reasonably reliable
2557 -- way to distinguish the two cases.
2559 if Is_List_Member
(Node
)
2560 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2565 Write_Str_With_Col_Check_Sloc
("[storage_error");
2566 Write_Condition_And_Reason
(Node
);
2568 when N_Raise_Statement
=>
2569 Write_Indent_Str_Sloc
("raise ");
2570 Sprint_Node
(Name
(Node
));
2574 Sprint_Node
(Low_Bound
(Node
));
2575 Write_Str_Sloc
(" .. ");
2576 Sprint_Node
(High_Bound
(Node
));
2577 Update_Itype
(Node
);
2579 when N_Range_Constraint
=>
2580 Write_Str_With_Col_Check_Sloc
("range ");
2581 Sprint_Node
(Range_Expression
(Node
));
2583 when N_Real_Literal
=>
2584 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
2586 when N_Real_Range_Specification
=>
2587 Write_Str_With_Col_Check_Sloc
("range ");
2588 Sprint_Node
(Low_Bound
(Node
));
2590 Sprint_Node
(High_Bound
(Node
));
2592 when N_Record_Definition
=>
2593 if Abstract_Present
(Node
) then
2594 Write_Str_With_Col_Check
("abstract ");
2597 if Tagged_Present
(Node
) then
2598 Write_Str_With_Col_Check
("tagged ");
2601 if Limited_Present
(Node
) then
2602 Write_Str_With_Col_Check
("limited ");
2605 if Null_Present
(Node
) then
2606 Write_Str_With_Col_Check_Sloc
("null record");
2609 Write_Str_With_Col_Check_Sloc
("record");
2610 Sprint_Node
(Component_List
(Node
));
2611 Write_Indent_Str
("end record");
2614 when N_Record_Representation_Clause
=>
2615 Write_Indent_Str_Sloc
("for ");
2616 Sprint_Node
(Identifier
(Node
));
2617 Write_Str_With_Col_Check
(" use record ");
2619 if Present
(Mod_Clause
(Node
)) then
2620 Sprint_Node
(Mod_Clause
(Node
));
2623 Sprint_Indented_List
(Component_Clauses
(Node
));
2624 Write_Indent_Str
("end record;");
2627 Sprint_Node
(Prefix
(Node
));
2628 Write_Str_With_Col_Check_Sloc
("'reference");
2630 when N_Requeue_Statement
=>
2631 Write_Indent_Str_Sloc
("requeue ");
2632 Sprint_Node
(Name
(Node
));
2634 if Abort_Present
(Node
) then
2635 Write_Str_With_Col_Check
(" with abort");
2640 -- Don't we want to print more detail???
2642 -- Doc of this extended syntax belongs in sinfo.ads and/or
2645 when N_SCIL_Dispatch_Table_Object_Init
=>
2646 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Object_Init]");
2648 when N_SCIL_Dispatch_Table_Tag_Init
=>
2649 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Tag_Init]");
2651 when N_SCIL_Dispatching_Call
=>
2652 Write_Indent_Str
("[N_SCIL_Dispatching_Node]");
2654 when N_SCIL_Tag_Init
=>
2655 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Tag_Init]");
2657 when N_Simple_Return_Statement
=>
2658 if Present
(Expression
(Node
)) then
2659 Write_Indent_Str_Sloc
("return ");
2660 Sprint_Node
(Expression
(Node
));
2663 Write_Indent_Str_Sloc
("return;");
2666 when N_Selective_Accept
=>
2667 Write_Indent_Str_Sloc
("select");
2672 Alt_Node
:= First
(Select_Alternatives
(Node
));
2675 Sprint_Node
(Alt_Node
);
2678 exit when No
(Alt_Node
);
2679 Write_Indent_Str
("or");
2683 if Present
(Else_Statements
(Node
)) then
2684 Write_Indent_Str
("else");
2685 Sprint_Indented_List
(Else_Statements
(Node
));
2688 Write_Indent_Str
("end select;");
2690 when N_Signed_Integer_Type_Definition
=>
2691 Write_Str_With_Col_Check_Sloc
("range ");
2692 Sprint_Node
(Low_Bound
(Node
));
2694 Sprint_Node
(High_Bound
(Node
));
2696 when N_Single_Protected_Declaration
=>
2697 Write_Indent_Str_Sloc
("protected ");
2698 Write_Id
(Defining_Identifier
(Node
));
2700 Sprint_Node
(Protected_Definition
(Node
));
2701 Write_Id
(Defining_Identifier
(Node
));
2704 when N_Single_Task_Declaration
=>
2705 Write_Indent_Str_Sloc
("task ");
2706 Sprint_Node
(Defining_Identifier
(Node
));
2708 if Present
(Task_Definition
(Node
)) then
2710 Sprint_Node
(Task_Definition
(Node
));
2715 when N_Selected_Component
=>
2716 Sprint_Node
(Prefix
(Node
));
2717 Write_Char_Sloc
('.');
2718 Sprint_Node
(Selector_Name
(Node
));
2722 Sprint_Node
(Prefix
(Node
));
2723 Write_Str_With_Col_Check
(" (");
2724 Sprint_Node
(Discrete_Range
(Node
));
2727 when N_String_Literal
=>
2728 if String_Length
(Strval
(Node
)) + Column
> Sprint_Line_Limit
then
2729 Write_Indent_Str
(" ");
2733 Write_String_Table_Entry
(Strval
(Node
));
2735 when N_Subprogram_Body
=>
2737 -- Output extra blank line unless we are in freeze actions
2739 if Freeze_Indent
= 0 then
2744 Sprint_Node_Sloc
(Specification
(Node
));
2747 Sprint_Indented_List
(Declarations
(Node
));
2748 Write_Indent_Str
("begin");
2749 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2751 Write_Indent_Str
("end ");
2754 (Handled_Statement_Sequence
(Node
),
2755 Defining_Unit_Name
(Specification
(Node
)));
2758 if Is_List_Member
(Node
)
2759 and then Present
(Next
(Node
))
2760 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
2765 when N_Subprogram_Body_Stub
=>
2767 Sprint_Node_Sloc
(Specification
(Node
));
2768 Write_Str_With_Col_Check
(" is separate;");
2770 when N_Subprogram_Declaration
=>
2772 Sprint_Node_Sloc
(Specification
(Node
));
2774 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
2775 and then Null_Present
(Specification
(Node
))
2777 Write_Str_With_Col_Check
(" is null");
2782 when N_Subprogram_Info
=>
2783 Sprint_Node
(Identifier
(Node
));
2784 Write_Str_With_Col_Check_Sloc
("'subprogram_info");
2786 when N_Subprogram_Renaming_Declaration
=>
2788 Sprint_Node
(Specification
(Node
));
2789 Write_Str_With_Col_Check_Sloc
(" renames ");
2790 Sprint_Node
(Name
(Node
));
2793 when N_Subtype_Declaration
=>
2794 Write_Indent_Str_Sloc
("subtype ");
2795 Sprint_Node
(Defining_Identifier
(Node
));
2798 -- Ada 2005 (AI-231)
2800 if Null_Exclusion_Present
(Node
) then
2801 Write_Str
("not null ");
2804 Sprint_Node
(Subtype_Indication
(Node
));
2807 when N_Subtype_Indication
=>
2808 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
2810 Sprint_Node
(Constraint
(Node
));
2813 Write_Indent_Str_Sloc
("separate (");
2814 Sprint_Node
(Name
(Node
));
2817 Sprint_Node
(Proper_Body
(Node
));
2820 Write_Indent_Str_Sloc
("task body ");
2821 Write_Id
(Defining_Identifier
(Node
));
2823 Sprint_Indented_List
(Declarations
(Node
));
2824 Write_Indent_Str
("begin");
2825 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2826 Write_Indent_Str
("end ");
2828 (Handled_Statement_Sequence
(Node
), Defining_Identifier
(Node
));
2831 when N_Task_Body_Stub
=>
2832 Write_Indent_Str_Sloc
("task body ");
2833 Write_Id
(Defining_Identifier
(Node
));
2834 Write_Str_With_Col_Check
(" is separate;");
2836 when N_Task_Definition
=>
2838 Sprint_Indented_List
(Visible_Declarations
(Node
));
2840 if Present
(Private_Declarations
(Node
)) then
2841 Write_Indent_Str
("private");
2842 Sprint_Indented_List
(Private_Declarations
(Node
));
2845 Write_Indent_Str
("end ");
2846 Sprint_End_Label
(Node
, Defining_Identifier
(Parent
(Node
)));
2848 when N_Task_Type_Declaration
=>
2849 Write_Indent_Str_Sloc
("task type ");
2850 Sprint_Node
(Defining_Identifier
(Node
));
2851 Write_Discr_Specs
(Node
);
2853 if Present
(Interface_List
(Node
)) then
2854 Write_Str
(" is new ");
2855 Sprint_And_List
(Interface_List
(Node
));
2858 if Present
(Task_Definition
(Node
)) then
2859 if No
(Interface_List
(Node
)) then
2862 Write_Str
(" with ");
2865 Sprint_Node
(Task_Definition
(Node
));
2870 when N_Terminate_Alternative
=>
2871 Sprint_Node_List
(Pragmas_Before
(Node
));
2875 if Present
(Condition
(Node
)) then
2876 Write_Str_With_Col_Check
("when ");
2877 Sprint_Node
(Condition
(Node
));
2881 Write_Str_With_Col_Check_Sloc
("terminate;");
2882 Sprint_Node_List
(Pragmas_After
(Node
));
2884 when N_Timed_Entry_Call
=>
2885 Write_Indent_Str_Sloc
("select");
2887 Sprint_Node
(Entry_Call_Alternative
(Node
));
2889 Write_Indent_Str
("or");
2891 Sprint_Node
(Delay_Alternative
(Node
));
2893 Write_Indent_Str
("end select;");
2895 when N_Triggering_Alternative
=>
2896 Sprint_Node_List
(Pragmas_Before
(Node
));
2897 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
2898 Sprint_Node_List
(Statements
(Node
));
2900 when N_Type_Conversion
=>
2902 Sprint_Node
(Subtype_Mark
(Node
));
2905 if Conversion_OK
(Node
) then
2909 if Float_Truncate
(Node
) then
2913 if Rounded_Result
(Node
) then
2918 Sprint_Node
(Expression
(Node
));
2921 when N_Unchecked_Expression
=>
2924 Sprint_Node_Sloc
(Expression
(Node
));
2927 when N_Unchecked_Type_Conversion
=>
2928 Sprint_Node
(Subtype_Mark
(Node
));
2930 Write_Str_With_Col_Check
("(");
2931 Sprint_Node_Sloc
(Expression
(Node
));
2934 when N_Unconstrained_Array_Definition
=>
2935 Write_Str_With_Col_Check_Sloc
("array (");
2940 Node1
:= First
(Subtype_Marks
(Node
));
2942 Sprint_Node
(Node1
);
2943 Write_Str_With_Col_Check
(" range <>");
2945 exit when Node1
= Empty
;
2950 Write_Str
(") of ");
2951 Sprint_Node
(Component_Definition
(Node
));
2953 when N_Unused_At_Start | N_Unused_At_End
=>
2954 Write_Indent_Str
("***** Error, unused node encountered *****");
2957 when N_Use_Package_Clause
=>
2958 Write_Indent_Str_Sloc
("use ");
2959 Sprint_Comma_List
(Names
(Node
));
2962 when N_Use_Type_Clause
=>
2963 Write_Indent_Str_Sloc
("use type ");
2964 Sprint_Comma_List
(Subtype_Marks
(Node
));
2967 when N_Validate_Unchecked_Conversion
=>
2968 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
2969 Sprint_Node
(Source_Type
(Node
));
2971 Sprint_Node
(Target_Type
(Node
));
2975 Write_Indent_Str_Sloc
("when ");
2976 Sprint_Bar_List
(Discrete_Choices
(Node
));
2978 Sprint_Node
(Component_List
(Node
));
2980 when N_Variant_Part
=>
2982 Write_Indent_Str_Sloc
("case ");
2983 Sprint_Node
(Name
(Node
));
2985 Sprint_Indented_List
(Variants
(Node
));
2986 Write_Indent_Str
("end case");
2989 when N_With_Clause
=>
2991 -- Special test, if we are dumping the original tree only,
2992 -- then we want to eliminate the bogus with clauses that
2993 -- correspond to the non-existent children of Text_IO.
2995 if Dump_Original_Only
2996 and then Is_Text_IO_Kludge_Unit
(Name
(Node
))
3000 -- Normal case, output the with clause
3003 if First_Name
(Node
) or else not Dump_Original_Only
then
3005 -- Ada 2005 (AI-50217): Print limited with_clauses
3007 if Private_Present
(Node
) and Limited_Present
(Node
) then
3008 Write_Indent_Str
("limited private with ");
3010 elsif Private_Present
(Node
) then
3011 Write_Indent_Str
("private with ");
3013 elsif Limited_Present
(Node
) then
3014 Write_Indent_Str
("limited with ");
3017 Write_Indent_Str
("with ");
3024 Sprint_Node_Sloc
(Name
(Node
));
3026 if Last_Name
(Node
) or else not Dump_Original_Only
then
3033 if Nkind
(Node
) in N_Subexpr
3034 and then Do_Range_Check
(Node
)
3039 for J
in 1 .. Paren_Count
(Node
) loop
3043 Dump_Node
:= Save_Dump_Node
;
3044 end Sprint_Node_Actual
;
3046 ----------------------
3047 -- Sprint_Node_List --
3048 ----------------------
3050 procedure Sprint_Node_List
(List
: List_Id
) is
3054 if Is_Non_Empty_List
(List
) then
3055 Node
:= First
(List
);
3060 exit when Node
= Empty
;
3063 end Sprint_Node_List
;
3065 ----------------------
3066 -- Sprint_Node_Sloc --
3067 ----------------------
3069 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
3073 if Debug_Generated_Code
and then Present
(Dump_Node
) then
3074 Set_Sloc
(Dump_Node
, Sloc
(Node
));
3077 end Sprint_Node_Sloc
;
3079 ---------------------
3080 -- Sprint_Opt_Node --
3081 ---------------------
3083 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
3085 if Present
(Node
) then
3089 end Sprint_Opt_Node
;
3091 --------------------------
3092 -- Sprint_Opt_Node_List --
3093 --------------------------
3095 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
3097 if Present
(List
) then
3098 Sprint_Node_List
(List
);
3100 end Sprint_Opt_Node_List
;
3102 ---------------------------------
3103 -- Sprint_Opt_Paren_Comma_List --
3104 ---------------------------------
3106 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
3108 if Is_Non_Empty_List
(List
) then
3110 Sprint_Paren_Comma_List
(List
);
3112 end Sprint_Opt_Paren_Comma_List
;
3114 -----------------------------
3115 -- Sprint_Paren_Comma_List --
3116 -----------------------------
3118 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
3120 Node_Exists
: Boolean := False;
3124 if Is_Non_Empty_List
(List
) then
3126 if Dump_Original_Only
then
3128 while Present
(N
) loop
3129 if not Is_Rewrite_Insertion
(N
) then
3130 Node_Exists
:= True;
3137 if not Node_Exists
then
3142 Write_Str_With_Col_Check
("(");
3143 Sprint_Comma_List
(List
);
3146 end Sprint_Paren_Comma_List
;
3148 ----------------------
3149 -- Sprint_Right_Opnd --
3150 ----------------------
3152 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
3153 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
3156 if Paren_Count
(Opnd
) /= 0
3157 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
3166 end Sprint_Right_Opnd
;
3172 procedure Update_Itype
(Node
: Node_Id
) is
3174 if Present
(Etype
(Node
))
3175 and then Is_Itype
(Etype
(Node
))
3176 and then Debug_Generated_Code
3178 Set_Sloc
(Etype
(Node
), Sloc
(Node
));
3182 ---------------------
3183 -- Write_Char_Sloc --
3184 ---------------------
3186 procedure Write_Char_Sloc
(C
: Character) is
3188 if Debug_Generated_Code
and then C
/= ' ' then
3193 end Write_Char_Sloc
;
3195 --------------------------------
3196 -- Write_Condition_And_Reason --
3197 --------------------------------
3199 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
3200 Cond
: constant Node_Id
:= Condition
(Node
);
3201 Image
: constant String := RT_Exception_Code
'Image
3202 (RT_Exception_Code
'Val
3203 (UI_To_Int
(Reason
(Node
))));
3206 if Present
(Cond
) then
3208 -- If condition is a single entity, or NOT with a single entity,
3209 -- output all on one line, since it will likely fit just fine.
3211 if Is_Entity_Name
(Cond
)
3212 or else (Nkind
(Cond
) = N_Op_Not
3213 and then Is_Entity_Name
(Right_Opnd
(Cond
)))
3215 Write_Str_With_Col_Check
(" when ");
3219 -- Otherwise for more complex condition, multiple lines
3222 Write_Str_With_Col_Check
(" when");
3223 Indent
:= Indent
+ 2;
3227 Indent
:= Indent
- 2;
3230 -- If no condition, just need a space (all on one line)
3240 for J
in 4 .. Image
'Last loop
3241 if Image
(J
) = '_' then
3244 Write_Char
(Fold_Lower
(Image
(J
)));
3249 end Write_Condition_And_Reason
;
3251 --------------------------------
3252 -- Write_Corresponding_Source --
3253 --------------------------------
3255 procedure Write_Corresponding_Source
(S
: String) is
3257 Src
: Source_Buffer_Ptr
;
3260 -- Ignore if not in dump source text mode, or if in freeze actions
3262 if Dump_Source_Text
and then Freeze_Indent
= 0 then
3264 -- Ignore null string
3270 -- Ignore space or semicolon at end of given string
3272 if S
(S
'Last) = ' ' or else S
(S
'Last) = ';' then
3273 Write_Corresponding_Source
(S
(S
'First .. S
'Last - 1));
3277 -- Loop to look at next lines not yet printed in source file
3280 Last_Line_Printed
+ 1 .. Last_Source_Line
(Current_Source_File
)
3282 Src
:= Source_Text
(Current_Source_File
);
3283 Loc
:= Line_Start
(L
, Current_Source_File
);
3285 -- If comment, keep looking
3287 if Src
(Loc
.. Loc
+ 1) = "--" then
3290 -- Search to first non-blank
3293 while Src
(Loc
) not in Line_Terminator
loop
3297 if Src
(Loc
) /= ' ' and then Src
(Loc
) /= ASCII
.HT
then
3299 -- Loop through characters in string to see if we match
3301 for J
in S
'Range loop
3303 -- If mismatch, then not the case we are looking for
3305 if Src
(Loc
) /= S
(J
) then
3312 -- If we fall through, string matched, if white space or
3313 -- semicolon after the matched string, this is the case
3314 -- we are looking for.
3316 if Src
(Loc
) in Line_Terminator
3317 or else Src
(Loc
) = ' '
3318 or else Src
(Loc
) = ASCII
.HT
3319 or else Src
(Loc
) = ';'
3321 -- So output source lines up to and including this one
3323 Write_Source_Lines
(L
);
3332 -- Line was all blanks, or a comment line, keep looking
3336 end Write_Corresponding_Source
;
3338 -----------------------
3339 -- Write_Discr_Specs --
3340 -----------------------
3342 procedure Write_Discr_Specs
(N
: Node_Id
) is
3347 Specs
:= Discriminant_Specifications
(N
);
3349 if Present
(Specs
) then
3350 Write_Str_With_Col_Check
(" (");
3351 Spec
:= First
(Specs
);
3356 exit when Spec
= Empty
;
3358 -- Add semicolon, unless we are printing original tree and the
3359 -- next specification is part of a list (but not the first
3360 -- element of that list)
3362 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3369 end Write_Discr_Specs
;
3375 procedure Write_Ekind
(E
: Entity_Id
) is
3376 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
3379 Name_Len
:= S
'Length;
3380 Name_Buffer
(1 .. Name_Len
) := S
;
3381 Set_Casing
(Mixed_Case
);
3382 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3389 procedure Write_Id
(N
: Node_Id
) is
3391 -- Deal with outputting Itype
3393 -- Note: if we are printing the full tree with -gnatds, then we may
3394 -- end up picking up the Associated_Node link from a generic template
3395 -- here which overlaps the Entity field, but as documented, Write_Itype
3396 -- is defended against junk calls.
3398 if Nkind
(N
) in N_Entity
then
3400 elsif Nkind
(N
) in N_Has_Entity
then
3401 Write_Itype
(Entity
(N
));
3404 -- Case of a defining identifier
3406 if Nkind
(N
) = N_Defining_Identifier
then
3408 -- If defining identifier has an interface name (and no
3409 -- address clause), then we output the interface name.
3411 if (Is_Imported
(N
) or else Is_Exported
(N
))
3412 and then Present
(Interface_Name
(N
))
3413 and then No
(Address_Clause
(N
))
3415 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
3416 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3418 -- If no interface name (or inactive because there was
3419 -- an address clause), then just output the Chars name.
3422 Write_Name_With_Col_Check
(Chars
(N
));
3425 -- Case of selector of an expanded name where the expanded name
3426 -- has an associated entity, output this entity.
3428 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
3429 and then Selector_Name
(Parent
(N
)) = N
3430 and then Present
(Entity
(Parent
(N
)))
3432 Write_Id
(Entity
(Parent
(N
)));
3434 -- For any other node with an associated entity, output it
3436 elsif Nkind
(N
) in N_Has_Entity
3437 and then Present
(Entity_Or_Associated_Node
(N
))
3438 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
3440 Write_Id
(Entity
(N
));
3442 -- All other cases, we just print the Chars field
3445 Write_Name_With_Col_Check
(Chars
(N
));
3449 -----------------------
3450 -- Write_Identifiers --
3451 -----------------------
3453 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
3455 Sprint_Node
(Defining_Identifier
(Node
));
3456 Update_Itype
(Defining_Identifier
(Node
));
3458 -- The remainder of the declaration must be printed unless we are
3459 -- printing the original tree and this is not the last identifier
3462 not Dump_Original_Only
or else not More_Ids
(Node
);
3464 end Write_Identifiers
;
3466 ------------------------
3467 -- Write_Implicit_Def --
3468 ------------------------
3470 procedure Write_Implicit_Def
(E
: Entity_Id
) is
3475 when E_Array_Subtype
=>
3476 Write_Str_With_Col_Check
("subtype ");
3478 Write_Str_With_Col_Check
(" is ");
3479 Write_Id
(Base_Type
(E
));
3480 Write_Str_With_Col_Check
(" (");
3482 Ind
:= First_Index
(E
);
3483 while Present
(Ind
) loop
3487 if Present
(Ind
) then
3494 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
3495 Write_Str_With_Col_Check
("subtype ");
3498 Write_Id
(Etype
(E
));
3499 Write_Str_With_Col_Check
(" range ");
3500 Sprint_Node
(Scalar_Range
(E
));
3504 Write_Str_With_Col_Check
("type ");
3506 Write_Str_With_Col_Check
(" is <");
3511 end Write_Implicit_Def
;
3517 procedure Write_Indent
is
3518 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
3521 if Indent_Annull_Flag
then
3522 Indent_Annull_Flag
:= False;
3524 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3525 -- label declarations, since they typically have the sloc of the
3526 -- corresponding label, which really messes up the -gnatL output.
3529 and then Loc
> No_Location
3530 and then Nkind
(Dump_Node
) /= N_Implicit_Label_Declaration
3532 if Get_Source_File_Index
(Loc
) = Current_Source_File
then
3534 (Get_Physical_Line_Number
(Sloc
(Dump_Node
)));
3540 for J
in 1 .. Indent
loop
3546 ------------------------------
3547 -- Write_Indent_Identifiers --
3548 ------------------------------
3550 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
3552 -- We need to start a new line for every node, except in the case
3553 -- where we are printing the original tree and this is not the first
3554 -- defining identifier in the list.
3556 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3559 -- If printing original tree and this is not the first defining
3560 -- identifier in the list, then the previous call to this procedure
3561 -- printed only the name, and we add a comma to separate the names.
3567 Sprint_Node
(Defining_Identifier
(Node
));
3569 -- The remainder of the declaration must be printed unless we are
3570 -- printing the original tree and this is not the last identifier
3573 not Dump_Original_Only
or else not More_Ids
(Node
);
3574 end Write_Indent_Identifiers
;
3576 -----------------------------------
3577 -- Write_Indent_Identifiers_Sloc --
3578 -----------------------------------
3580 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
3582 -- We need to start a new line for every node, except in the case
3583 -- where we are printing the original tree and this is not the first
3584 -- defining identifier in the list.
3586 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3589 -- If printing original tree and this is not the first defining
3590 -- identifier in the list, then the previous call to this procedure
3591 -- printed only the name, and we add a comma to separate the names.
3598 Sprint_Node
(Defining_Identifier
(Node
));
3600 -- The remainder of the declaration must be printed unless we are
3601 -- printing the original tree and this is not the last identifier
3603 return not Dump_Original_Only
or else not More_Ids
(Node
);
3604 end Write_Indent_Identifiers_Sloc
;
3606 ----------------------
3607 -- Write_Indent_Str --
3608 ----------------------
3610 procedure Write_Indent_Str
(S
: String) is
3612 Write_Corresponding_Source
(S
);
3615 end Write_Indent_Str
;
3617 ---------------------------
3618 -- Write_Indent_Str_Sloc --
3619 ---------------------------
3621 procedure Write_Indent_Str_Sloc
(S
: String) is
3623 Write_Corresponding_Source
(S
);
3626 end Write_Indent_Str_Sloc
;
3632 procedure Write_Itype
(Typ
: Entity_Id
) is
3634 procedure Write_Header
(T
: Boolean := True);
3635 -- Write type if T is True, subtype if T is false
3641 procedure Write_Header
(T
: Boolean := True) is
3644 Write_Str
("[type ");
3646 Write_Str
("[subtype ");
3649 Write_Name_With_Col_Check
(Chars
(Typ
));
3653 -- Start of processing for Write_Itype
3656 if Nkind
(Typ
) in N_Entity
3657 and then Is_Itype
(Typ
)
3658 and then not Itype_Printed
(Typ
)
3660 -- Itype to be printed
3663 B
: constant Node_Id
:= Etype
(Typ
);
3665 P
: constant Node_Id
:= Parent
(Typ
);
3667 S
: constant Saved_Output_Buffer
:= Save_Output_Buffer
;
3668 -- Save current output buffer
3670 Old_Sloc
: Source_Ptr
;
3671 -- Save sloc of related node, so it is not modified when
3672 -- printing with -gnatD.
3675 -- Write indentation at start of line
3677 for J
in 1 .. Indent
loop
3681 -- If we have a constructed declaration for the itype, print it
3684 and then Nkind
(P
) in N_Declaration
3685 and then Defining_Entity
(P
) = Typ
3687 -- We must set Itype_Printed true before the recursive call to
3688 -- print the node, otherwise we get an infinite recursion!
3690 Set_Itype_Printed
(Typ
, True);
3692 -- Write the declaration enclosed in [], avoiding new line
3693 -- at start of declaration, and semicolon at end.
3695 -- Note: The itype may be imported from another unit, in which
3696 -- case we do not want to modify the Sloc of the declaration.
3697 -- Otherwise the itype may appear to be in the current unit,
3698 -- and the back-end will reject a reference out of scope.
3701 Indent_Annull_Flag
:= True;
3702 Old_Sloc
:= Sloc
(P
);
3704 Set_Sloc
(P
, Old_Sloc
);
3705 Write_Erase_Char
(';');
3707 -- If no constructed declaration, then we have to concoct the
3708 -- source corresponding to the type entity that we have at hand.
3713 -- Access types and subtypes
3716 Write_Header
(Ekind
(Typ
) = E_Access_Type
);
3717 Write_Str
("access ");
3719 if Is_Access_Constant
(Typ
) then
3720 Write_Str
("constant ");
3721 elsif Can_Never_Be_Null
(Typ
) then
3722 Write_Str
("not null ");
3725 Write_Id
(Directly_Designated_Type
(Typ
));
3727 -- Array types and string types
3729 when E_Array_Type | E_String_Type
=>
3731 Write_Str
("array (");
3733 X
:= First_Index
(Typ
);
3737 if not Is_Constrained
(Typ
) then
3738 Write_Str
(" range <>");
3746 Write_Str
(") of ");
3747 X
:= Component_Type
(Typ
);
3749 -- Preserve sloc of component type, which is defined
3750 -- elsewhere than the itype (see comment above).
3752 Old_Sloc
:= Sloc
(X
);
3754 Set_Sloc
(X
, Old_Sloc
);
3756 -- Array subtypes and string subtypes.
3757 -- Preserve Sloc of index subtypes, as above.
3759 when E_Array_Subtype | E_String_Subtype
=>
3760 Write_Header
(False);
3761 Write_Id
(Etype
(Typ
));
3764 X
:= First_Index
(Typ
);
3766 Old_Sloc
:= Sloc
(X
);
3768 Set_Sloc
(X
, Old_Sloc
);
3776 -- Signed integer types, and modular integer subtypes,
3777 -- and also enumeration subtypes.
3779 when E_Signed_Integer_Type |
3780 E_Signed_Integer_Subtype |
3781 E_Modular_Integer_Subtype |
3782 E_Enumeration_Subtype
=>
3784 Write_Header
(Ekind
(Typ
) = E_Signed_Integer_Type
);
3786 if Ekind
(Typ
) = E_Signed_Integer_Type
then
3792 -- Print bounds if different from base type
3795 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
3796 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
3801 -- B can either be a scalar type, in which case the
3802 -- declaration of Typ may constrain it with different
3803 -- bounds, or a private type, in which case we know
3804 -- that the declaration of Typ cannot have a scalar
3807 if Is_Scalar_Type
(B
) then
3808 LE
:= Type_Low_Bound
(B
);
3809 HE
:= Type_High_Bound
(B
);
3817 and then Nkind
(L
) = N_Integer_Literal
3818 and then Nkind
(H
) = N_Integer_Literal
3819 and then Nkind
(LE
) = N_Integer_Literal
3820 and then Nkind
(HE
) = N_Integer_Literal
3821 and then UI_Eq
(Intval
(L
), Intval
(LE
))
3822 and then UI_Eq
(Intval
(H
), Intval
(HE
)))
3827 Write_Str
(" range ");
3828 Sprint_Node
(Type_Low_Bound
(Typ
));
3830 Sprint_Node
(Type_High_Bound
(Typ
));
3834 -- Modular integer types
3836 when E_Modular_Integer_Type
=>
3838 Write_Str
(" mod ");
3839 Write_Uint_With_Col_Check
(Modulus
(Typ
), Auto
);
3841 -- Floating point types and subtypes
3843 when E_Floating_Point_Type |
3844 E_Floating_Point_Subtype
=>
3846 Write_Header
(Ekind
(Typ
) = E_Floating_Point_Type
);
3848 if Ekind
(Typ
) = E_Floating_Point_Type
then
3852 Write_Id
(Etype
(Typ
));
3854 if Digits_Value
(Typ
) /= Digits_Value
(Etype
(Typ
)) then
3855 Write_Str
(" digits ");
3856 Write_Uint_With_Col_Check
3857 (Digits_Value
(Typ
), Decimal
);
3860 -- Print bounds if not different from base type
3863 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
3864 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
3865 LE
: constant Node_Id
:= Type_Low_Bound
(B
);
3866 HE
: constant Node_Id
:= Type_High_Bound
(B
);
3869 if Nkind
(L
) = N_Real_Literal
3870 and then Nkind
(H
) = N_Real_Literal
3871 and then Nkind
(LE
) = N_Real_Literal
3872 and then Nkind
(HE
) = N_Real_Literal
3873 and then UR_Eq
(Realval
(L
), Realval
(LE
))
3874 and then UR_Eq
(Realval
(H
), Realval
(HE
))
3879 Write_Str
(" range ");
3880 Sprint_Node
(Type_Low_Bound
(Typ
));
3882 Sprint_Node
(Type_High_Bound
(Typ
));
3888 when E_Record_Subtype
=>
3889 Write_Header
(False);
3890 Write_Str
("record");
3896 C
:= First_Entity
(Typ
);
3897 while Present
(C
) loop
3901 Write_Id
(Etype
(C
));
3907 Write_Indent_Str
(" end record");
3911 when E_Class_Wide_Type |
3912 E_Class_Wide_Subtype
=>
3914 Write_Name_With_Col_Check
(Chars
(Etype
(Typ
)));
3915 Write_Str
("'Class");
3919 when E_Subprogram_Type
=>
3922 if Etype
(Typ
) = Standard_Void_Type
then
3923 Write_Str
("procedure");
3925 Write_Str
("function");
3928 if Present
(First_Entity
(Typ
)) then
3935 Param
:= First_Entity
(Typ
);
3940 if Ekind
(Param
) = E_In_Out_Parameter
then
3941 Write_Str
("in out ");
3942 elsif Ekind
(Param
) = E_Out_Parameter
then
3946 Write_Id
(Etype
(Param
));
3947 Next_Entity
(Param
);
3948 exit when No
(Param
);
3956 if Etype
(Typ
) /= Standard_Void_Type
then
3957 Write_Str
(" return ");
3958 Write_Id
(Etype
(Typ
));
3961 when E_String_Literal_Subtype
=>
3963 LB
: constant Uint
:=
3964 Intval
(String_Literal_Low_Bound
(Typ
));
3965 Len
: constant Uint
:=
3966 String_Literal_Length
(Typ
);
3968 Write_Str
("String (");
3969 Write_Int
(UI_To_Int
(LB
));
3971 Write_Int
(UI_To_Int
(LB
+ Len
) - 1);
3975 -- For all other Itypes, print ??? (fill in later)
3978 Write_Header
(True);
3984 -- Add terminating bracket and restore output buffer
3988 Restore_Output_Buffer
(S
);
3991 Set_Itype_Printed
(Typ
);
3995 -------------------------------
3996 -- Write_Name_With_Col_Check --
3997 -------------------------------
3999 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
4005 Get_Name_String
(N
);
4007 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4008 -- upper case letter, nnn is one or more digits and b is a lower case
4009 -- letter by C...b, so that listings do not depend on serial numbers.
4011 if Debug_Flag_II
then
4013 while J
< Name_Len
- 1 loop
4014 if Name_Buffer
(J
) in 'A' .. 'Z'
4015 and then Name_Buffer
(J
+ 1) in '0' .. '9'
4018 while K
< Name_Len
loop
4019 exit when Name_Buffer
(K
) not in '0' .. '9';
4023 if Name_Buffer
(K
) in 'a' .. 'z' then
4024 L
:= Name_Len
- K
+ 1;
4026 Name_Buffer
(J
+ 4 .. J
+ L
+ 3) :=
4027 Name_Buffer
(K
.. Name_Len
);
4028 Name_Buffer
(J
+ 1 .. J
+ 3) := "...";
4029 Name_Len
:= J
+ L
+ 3;
4042 -- Fall through for normal case
4044 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4045 end Write_Name_With_Col_Check
;
4047 ------------------------------------
4048 -- Write_Name_With_Col_Check_Sloc --
4049 ------------------------------------
4051 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
4053 Get_Name_String
(N
);
4054 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
4055 end Write_Name_With_Col_Check_Sloc
;
4057 --------------------
4058 -- Write_Operator --
4059 --------------------
4061 procedure Write_Operator
(N
: Node_Id
; S
: String) is
4062 F
: Natural := S
'First;
4063 T
: Natural := S
'Last;
4066 -- If no overflow check, just write string out, and we are done
4068 if not Do_Overflow_Check
(N
) then
4071 -- If overflow check, we want to surround the operator with curly
4072 -- brackets, but not include spaces within the brackets.
4085 Write_Str_Sloc
(S
(F
.. T
));
4088 if S
(S
'Last) = ' ' then
4094 -----------------------
4095 -- Write_Param_Specs --
4096 -----------------------
4098 procedure Write_Param_Specs
(N
: Node_Id
) is
4104 Specs
:= Parameter_Specifications
(N
);
4106 if Is_Non_Empty_List
(Specs
) then
4107 Write_Str_With_Col_Check
(" (");
4108 Spec
:= First
(Specs
);
4112 Formal
:= Defining_Identifier
(Spec
);
4114 exit when Spec
= Empty
;
4116 -- Add semicolon, unless we are printing original tree and the
4117 -- next specification is part of a list (but not the first element
4120 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4125 -- Write out any extra formals
4127 while Present
(Extra_Formal
(Formal
)) loop
4128 Formal
:= Extra_Formal
(Formal
);
4130 Write_Name_With_Col_Check
(Chars
(Formal
));
4132 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
4137 end Write_Param_Specs
;
4139 -----------------------
4140 -- Write_Rewrite_Str --
4141 -----------------------
4143 procedure Write_Rewrite_Str
(S
: String) is
4145 if not Dump_Generated_Only
then
4146 if S
'Length = 3 and then S
= ">>>" then
4149 Write_Str_With_Col_Check
(S
);
4152 end Write_Rewrite_Str
;
4154 -----------------------
4155 -- Write_Source_Line --
4156 -----------------------
4158 procedure Write_Source_Line
(L
: Physical_Line_Number
) is
4160 Src
: Source_Buffer_Ptr
;
4164 if Dump_Source_Text
then
4165 Src
:= Source_Text
(Current_Source_File
);
4166 Loc
:= Line_Start
(L
, Current_Source_File
);
4169 -- See if line is a comment line, if not, and if not line one,
4170 -- precede with blank line.
4173 while Src
(Scn
) = ' ' or else Src
(Scn
) = ASCII
.HT
loop
4177 if (Src
(Scn
) in Line_Terminator
4178 or else Src
(Scn
.. Scn
+ 1) /= "--")
4184 -- Now write the source text of the line
4187 Write_Int
(Int
(L
));
4190 while Src
(Loc
) not in Line_Terminator
loop
4191 Write_Char
(Src
(Loc
));
4195 end Write_Source_Line
;
4197 ------------------------
4198 -- Write_Source_Lines --
4199 ------------------------
4201 procedure Write_Source_Lines
(L
: Physical_Line_Number
) is
4203 while Last_Line_Printed
< L
loop
4204 Last_Line_Printed
:= Last_Line_Printed
+ 1;
4205 Write_Source_Line
(Last_Line_Printed
);
4207 end Write_Source_Lines
;
4209 --------------------
4210 -- Write_Str_Sloc --
4211 --------------------
4213 procedure Write_Str_Sloc
(S
: String) is
4215 for J
in S
'Range loop
4216 Write_Char_Sloc
(S
(J
));
4220 ------------------------------
4221 -- Write_Str_With_Col_Check --
4222 ------------------------------
4224 procedure Write_Str_With_Col_Check
(S
: String) is
4226 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4227 Write_Indent_Str
(" ");
4229 if S
(S
'First) = ' ' then
4230 Write_Str
(S
(S
'First + 1 .. S
'Last));
4238 end Write_Str_With_Col_Check
;
4240 -----------------------------------
4241 -- Write_Str_With_Col_Check_Sloc --
4242 -----------------------------------
4244 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
4246 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4247 Write_Indent_Str
(" ");
4249 if S
(S
'First) = ' ' then
4250 Write_Str_Sloc
(S
(S
'First + 1 .. S
'Last));
4258 end Write_Str_With_Col_Check_Sloc
;
4260 ---------------------------
4261 -- Write_Subprogram_Name --
4262 ---------------------------
4264 procedure Write_Subprogram_Name
(N
: Node_Id
) is
4266 if not Comes_From_Source
(N
)
4267 and then Is_Entity_Name
(N
)
4270 Ent
: constant Entity_Id
:= Entity
(N
);
4272 if not In_Extended_Main_Source_Unit
(Ent
)
4274 Is_Predefined_File_Name
4275 (Unit_File_Name
(Get_Source_Unit
(Ent
)))
4277 -- Run-time routine name, output name with a preceding dollar
4278 -- making sure that we do not get a line split between them.
4280 Col_Check
(Length_Of_Name
(Chars
(Ent
)) + 1);
4282 Write_Name
(Chars
(Ent
));
4288 -- Normal case, not a run-time routine name
4291 end Write_Subprogram_Name
;
4293 -------------------------------
4294 -- Write_Uint_With_Col_Check --
4295 -------------------------------
4297 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
) is
4299 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4300 UI_Write
(U
, Format
);
4301 end Write_Uint_With_Col_Check
;
4303 ------------------------------------
4304 -- Write_Uint_With_Col_Check_Sloc --
4305 ------------------------------------
4307 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
4309 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4311 UI_Write
(U
, Format
);
4312 end Write_Uint_With_Col_Check_Sloc
;
4314 -------------------------------------
4315 -- Write_Ureal_With_Col_Check_Sloc --
4316 -------------------------------------
4318 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
4319 D
: constant Uint
:= Denominator
(U
);
4320 N
: constant Uint
:= Numerator
(U
);
4324 (UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
4327 end Write_Ureal_With_Col_Check_Sloc
;