1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Aspects
; use Aspects
;
27 with Atree
; use Atree
;
28 with Casing
; use Casing
;
29 with Csets
; use Csets
;
30 with Debug
; use Debug
;
31 with Einfo
; use Einfo
;
32 with Fname
; use Fname
;
34 with Namet
; use Namet
;
35 with Nlists
; use Nlists
;
37 with Output
; use Output
;
38 with Rtsfind
; use Rtsfind
;
39 with Sem_Eval
; use Sem_Eval
;
40 with Sem_Util
; use Sem_Util
;
41 with Sinfo
; use Sinfo
;
42 with Sinput
; use Sinput
;
43 with Sinput
.D
; use Sinput
.D
;
44 with Snames
; use Snames
;
45 with Stand
; use Stand
;
46 with Stringt
; use Stringt
;
47 with Uintp
; use Uintp
;
48 with Uname
; use Uname
;
49 with Urealp
; use Urealp
;
51 package body Sprint
is
52 Current_Source_File
: Source_File_Index
;
53 -- Index of source file whose generated code is being dumped
55 Dump_Node
: Node_Id
:= Empty
;
56 -- This is set to the current node, used for printing line numbers. In
57 -- Debug_Generated_Code mode, Dump_Node is set to the current node
58 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
59 -- value. The call clears it back to Empty.
61 Debug_Sloc
: Source_Ptr
;
62 -- Sloc of first byte of line currently being written if we are
63 -- generating a source debug file.
65 Dump_Original_Only
: Boolean;
66 -- Set True if the -gnatdo (dump original tree) flag is set
68 Dump_Generated_Only
: Boolean;
69 -- Set True if the -gnatdG (dump generated tree) debug flag is set
70 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
72 Dump_Freeze_Null
: Boolean;
73 -- Set True if empty freeze nodes and non-source null statements output.
74 -- Note that freeze nodes containing freeze actions are always output,
75 -- as are freeze nodes for itypes, which in general have the effect of
76 -- causing elaboration of the itype.
78 Freeze_Indent
: Int
:= 0;
79 -- Keep track of freeze indent level (controls output of blank lines before
80 -- procedures within expression freeze actions). Relevant only if we are
81 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
82 -- output these blank lines in any case.
85 -- Number of columns for current line output indentation
87 Indent_Annull_Flag
: Boolean := False;
88 -- Set True if subsequent Write_Indent call to be ignored, gets reset
89 -- by this call, so it is only active to suppress a single indent call.
91 Last_Line_Printed
: Physical_Line_Number
;
92 -- This keeps track of the physical line number of the last source line
93 -- that has been output. The value is only valid in Dump_Source_Text mode.
95 -------------------------------
96 -- Operator Precedence Table --
97 -------------------------------
99 -- This table is used to decide whether a subexpression needs to be
100 -- parenthesized. The rule is that if an operand of an operator (which
101 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
102 -- with a lower precedence than the operator (or equal precedence if
103 -- appearing as the right operand), then parentheses are required.
105 Op_Prec
: constant array (N_Subexpr
) of Short_Short_Integer :=
138 procedure Sprint_Left_Opnd
(N
: Node_Id
);
139 -- Print left operand of operator, parenthesizing if necessary
141 procedure Sprint_Right_Opnd
(N
: Node_Id
);
142 -- Print right operand of operator, parenthesizing if necessary
144 -----------------------
145 -- Local Subprograms --
146 -----------------------
148 procedure Col_Check
(N
: Nat
);
149 -- Check that at least N characters remain on current line, and if not,
150 -- then start an extra line with two characters extra indentation for
151 -- continuing text on the next line.
153 procedure Extra_Blank_Line
;
154 -- In some situations we write extra blank lines to separate the generated
155 -- code to make it more readable. However, these extra blank lines are not
156 -- generated in Dump_Source_Text mode, since there the source text lines
157 -- output with preceding blank lines are quite sufficient as separators.
158 -- This procedure writes a blank line if Dump_Source_Text is False.
160 procedure Indent_Annull
;
161 -- Causes following call to Write_Indent to be ignored. This is used when
162 -- a higher level node wants to stop a lower level node from starting a
163 -- new line, when it would otherwise be inclined to do so (e.g. the case
164 -- of an accept statement called from an accept alternative with a guard)
166 procedure Indent_Begin
;
167 -- Increase indentation level
169 procedure Indent_End
;
170 -- Decrease indentation level
172 procedure Print_Debug_Line
(S
: String);
173 -- Used to print output lines in Debug_Generated_Code mode (this is used
174 -- as the argument for a call to Set_Special_Output in package Output).
176 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
);
177 -- Given a divide, multiplication or division node, check the flags
178 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
179 -- appropriate special syntax characters (# and @).
181 procedure Set_Debug_Sloc
;
182 -- If Dump_Node is non-empty, this routine sets the appropriate value
183 -- in its Sloc field, from the current location in the debug source file
184 -- that is currently being written.
186 procedure Sprint_And_List
(List
: List_Id
);
187 -- Print the given list with items separated by vertical "and"
189 procedure Sprint_Aspect_Specifications
191 Semicolon
: Boolean);
192 -- Node is a declaration node that has aspect specifications (Has_Aspects
193 -- flag set True). It outputs the aspect specifications. For the case
194 -- of Semicolon = True, it is called after outputting the terminating
195 -- semicolon for the related node. The effect is to remove the semicolon
196 -- and print the aspect specifications followed by a terminating semicolon.
197 -- For the case of Semicolon False, no semicolon is removed or output, and
198 -- all the aspects are printed on a single line.
200 procedure Sprint_Bar_List
(List
: List_Id
);
201 -- Print the given list with items separated by vertical bars
203 procedure Sprint_End_Label
206 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
207 -- If there is no end label, use the defining identifier of the enclosing
208 -- construct. If the end label is present, treat it as a reference to the
209 -- defining entity of the construct: this guarantees that it carries the
210 -- proper sloc information for debugging purposes.
212 procedure Sprint_Node_Actual
(Node
: Node_Id
);
213 -- This routine prints its node argument. It is a lower level routine than
214 -- Sprint_Node, in that it does not bother about rewritten trees.
216 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
217 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
218 -- sets the Sloc of the current debug node to be a copy of the Sloc
219 -- of the sprinted node Node. Note that this is done after printing
220 -- Node, so that the Sloc is the proper updated value for the debug file.
222 procedure Update_Itype
(Node
: Node_Id
);
223 -- Update the Sloc of an itype that is not attached to the tree, when
224 -- debugging expanded code. This routine is called from nodes whose
225 -- type can be an Itype, such as defining_identifiers that may be of
226 -- an anonymous access type, or ranges in slices.
228 procedure Write_Char_Sloc
(C
: Character);
229 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
230 -- called to ensure that the current node has a proper Sloc set.
232 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
233 -- Write Condition and Reason codes of Raise_xxx_Error node
235 procedure Write_Corresponding_Source
(S
: String);
236 -- If S is a string with a single keyword (possibly followed by a space),
237 -- and if the next non-comment non-blank source line matches this keyword,
238 -- then output all source lines up to this matching line.
240 procedure Write_Discr_Specs
(N
: Node_Id
);
241 -- Output discriminant specification for node, which is any of the type
242 -- declarations that can have discriminants.
244 procedure Write_Ekind
(E
: Entity_Id
);
245 -- Write the String corresponding to the Ekind without "E_"
247 procedure Write_Id
(N
: Node_Id
);
248 -- N is a node with a Chars field. This procedure writes the name that
249 -- will be used in the generated code associated with the name. For a
250 -- node with no associated entity, this is simply the Chars field. For
251 -- the case where there is an entity associated with the node, we print
252 -- the name associated with the entity (since it may have been encoded).
253 -- One other special case is that an entity has an active external name
254 -- (i.e. an external name present with no address clause), then this
255 -- external name is output. This procedure also deals with outputting
256 -- declarations of referenced itypes, if not output earlier.
258 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
259 -- Handle node where the grammar has a list of defining identifiers, but
260 -- the tree has a separate declaration for each identifier. Handles the
261 -- printing of the defining identifier, and returns True if the type and
262 -- initialization information is to be printed, False if it is to be
263 -- skipped (the latter case happens when printing defining identifiers
264 -- other than the first in the original tree output case).
266 procedure Write_Implicit_Def
(E
: Entity_Id
);
267 pragma Warnings
(Off
, Write_Implicit_Def
);
268 -- Write the definition of the implicit type E according to its Ekind
269 -- For now a debugging procedure, but might be used in the future.
271 procedure Write_Indent
;
272 -- Start a new line and write indentation spacing
274 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
275 -- Like Write_Identifiers except that each new printed declaration
276 -- is at the start of a new line.
278 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
279 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
280 -- mode, the Sloc of the current debug node is set to point to the
281 -- first output identifier.
283 procedure Write_Indent_Str
(S
: String);
284 -- Start a new line and write indent spacing followed by given string
286 procedure Write_Indent_Str_Sloc
(S
: String);
287 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
288 -- the Sloc of the current node is set to the first non-blank character
291 procedure Write_Itype
(Typ
: Entity_Id
);
292 -- If Typ is an Itype that has not been written yet, write it. If Typ is
293 -- any other kind of entity or tree node, the call is ignored.
295 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
296 -- Write name (using Write_Name) with initial column check, and possible
297 -- initial Write_Indent (to get new line) if current line is too full.
299 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
300 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
301 -- mode, sets Sloc of current debug node to first character of name.
303 procedure Write_Operator
(N
: Node_Id
; S
: String);
304 -- Like Write_Str_Sloc, used for operators, encloses the string in
305 -- characters {} if the Do_Overflow flag is set on the node N.
307 procedure Write_Param_Specs
(N
: Node_Id
);
308 -- Output parameter specifications for node (which is either a function
309 -- or procedure specification with a Parameter_Specifications field)
311 procedure Write_Rewrite_Str
(S
: String);
312 -- Writes out a string (typically containing <<< or >>>}) for a node
313 -- created by rewriting the tree. Suppressed if we are outputting the
314 -- generated code only, since in this case we don't specially mark nodes
315 -- created by rewriting).
317 procedure Write_Source_Line
(L
: Physical_Line_Number
);
318 -- If writing of interspersed source lines is enabled, then write the given
319 -- line from the source file, preceded by Eol, then an extra blank line if
320 -- the line has at least one blank, is not a comment and is not line one,
321 -- then "--" and the line number followed by period followed by text of the
322 -- source line (without terminating Eol). If interspersed source line
323 -- output not enabled, then the call has no effect.
325 procedure Write_Source_Lines
(L
: Physical_Line_Number
);
326 -- If writing of interspersed source lines is enabled, then writes source
327 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
328 -- interspersed source line output not enabled, then call has no effect.
330 procedure Write_Str_Sloc
(S
: String);
331 -- Like Write_Str, but sets debug Sloc of current debug node to first
332 -- non-blank character if a current debug node is active.
334 procedure Write_Str_With_Col_Check
(S
: String);
335 -- Write string (using Write_Str) with initial column check, and possible
336 -- initial Write_Indent (to get new line) if current line is too full.
338 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
339 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
340 -- node to first non-blank character if a current debug node is active.
342 procedure Write_Subprogram_Name
(N
: Node_Id
);
343 -- N is the Name field of a function call or procedure statement call.
344 -- The effect of the call is to output the name, preceded by a $ if the
345 -- call is identified as an implicit call to a run time routine.
347 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
);
348 -- Write Uint (using UI_Write) with initial column check, and possible
349 -- initial Write_Indent (to get new line) if current line is too full.
350 -- The format parameter determines the output format (see UI_Write).
352 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
353 -- Write Uint (using UI_Write) with initial column check, and possible
354 -- initial Write_Indent (to get new line) if current line is too full.
355 -- The format parameter determines the output format (see UI_Write).
356 -- In addition, in Debug_Generated_Code mode, sets the current node
357 -- Sloc to the first character of the output value.
359 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
360 -- Write Ureal (using same output format as UR_Write) with column checks
361 -- and a possible initial Write_Indent (to get new line) if current line
362 -- is too full. In addition, in Debug_Generated_Code mode, sets the
363 -- current node Sloc to the first character of the output value.
369 procedure Col_Check
(N
: Nat
) is
371 if N
+ Column
> Sprint_Line_Limit
then
372 Write_Indent_Str
(" ");
376 ----------------------
377 -- Extra_Blank_Line --
378 ----------------------
380 procedure Extra_Blank_Line
is
382 if not Dump_Source_Text
then
385 end Extra_Blank_Line
;
391 procedure Indent_Annull
is
393 Indent_Annull_Flag
:= True;
400 procedure Indent_Begin
is
402 Indent
:= Indent
+ 3;
409 procedure Indent_End
is
411 Indent
:= Indent
- 3;
418 procedure pg
(Arg
: Union_Id
) is
420 Dump_Generated_Only
:= True;
421 Dump_Original_Only
:= False;
422 Dump_Freeze_Null
:= True;
423 Current_Source_File
:= No_Source_File
;
425 if Arg
in List_Range
then
426 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
428 elsif Arg
in Node_Range
then
429 Sprint_Node
(Node_Id
(Arg
));
442 procedure po
(Arg
: Union_Id
) is
444 Dump_Generated_Only
:= False;
445 Dump_Original_Only
:= True;
446 Current_Source_File
:= No_Source_File
;
448 if Arg
in List_Range
then
449 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
451 elsif Arg
in Node_Range
then
452 Sprint_Node
(Node_Id
(Arg
));
461 ----------------------
462 -- Print_Debug_Line --
463 ----------------------
465 procedure Print_Debug_Line
(S
: String) is
467 Write_Debug_Line
(S
, Debug_Sloc
);
468 end Print_Debug_Line
;
470 ---------------------------
471 -- Process_TFAI_RR_Flags --
472 ---------------------------
474 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
476 if Treat_Fixed_As_Integer
(Nod
) then
480 if Rounded_Result
(Nod
) then
483 end Process_TFAI_RR_Flags
;
489 procedure ps
(Arg
: Union_Id
) is
491 Dump_Generated_Only
:= False;
492 Dump_Original_Only
:= False;
493 Current_Source_File
:= No_Source_File
;
495 if Arg
in List_Range
then
496 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
498 elsif Arg
in Node_Range
then
499 Sprint_Node
(Node_Id
(Arg
));
512 procedure Set_Debug_Sloc
is
514 if Debug_Generated_Code
and then Present
(Dump_Node
) then
515 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
517 -- We do not know the actual end location in the generated code and
518 -- it could be much closer than in the source code, so play safe.
520 if Nkind_In
(Dump_Node
, N_Case_Statement
, N_If_Statement
) then
521 Set_End_Location
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
532 procedure Source_Dump
is
535 -- Put underline under string we just printed
541 procedure Underline
is
542 Col
: constant Int
:= Column
;
547 while Col
> Column
loop
554 -- Start of processing for Source_Dump
557 Dump_Generated_Only
:= Debug_Flag_G
or
558 Print_Generated_Code
or
559 Debug_Generated_Code
;
560 Dump_Original_Only
:= Debug_Flag_O
;
561 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
563 -- Note that we turn off the tree dump flags immediately, before
564 -- starting the dump. This avoids generating two copies of the dump
565 -- if an abort occurs after printing the dump, and more importantly,
566 -- avoids an infinite loop if an abort occurs during the dump.
569 Current_Source_File
:= No_Source_File
;
570 Debug_Flag_Z
:= False;
573 Write_Str
("Source recreated from tree of Standard (spec)");
575 Sprint_Node
(Standard_Package_Node
);
580 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
581 Debug_Flag_G
:= False;
582 Debug_Flag_O
:= False;
583 Debug_Flag_S
:= False;
585 -- Dump requested units
587 for U
in Main_Unit
.. Last_Unit
loop
588 Current_Source_File
:= Source_Index
(U
);
590 -- Dump all units if -gnatdf set, otherwise we dump only
591 -- the source files that are in the extended main source.
594 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
596 -- If we are generating debug files, setup to write them
598 if Debug_Generated_Code
then
599 Set_Special_Output
(Print_Debug_Line
'Access);
600 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
601 Write_Source_Line
(1);
602 Last_Line_Printed
:= 1;
603 Sprint_Node
(Cunit
(U
));
604 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
607 Set_Special_Output
(null);
609 -- Normal output to standard output file
612 Write_Str
("Source recreated from tree for ");
613 Write_Unit_Name
(Unit_Name
(U
));
615 Write_Source_Line
(1);
616 Last_Line_Printed
:= 1;
617 Sprint_Node
(Cunit
(U
));
618 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
627 ---------------------
628 -- Sprint_And_List --
629 ---------------------
631 procedure Sprint_And_List
(List
: List_Id
) is
634 if Is_Non_Empty_List
(List
) then
635 Node
:= First
(List
);
639 exit when Node
= Empty
;
645 ----------------------------------
646 -- Sprint_Aspect_Specifications --
647 ----------------------------------
649 procedure Sprint_Aspect_Specifications
653 AS
: constant List_Id
:= Aspect_Specifications
(Node
);
658 Write_Erase_Char
(';');
659 Indent
:= Indent
+ 2;
662 Indent
:= Indent
+ 5;
665 Write_Str
(" with ");
670 Sprint_Node
(Identifier
(A
));
672 if Class_Present
(A
) then
673 Write_Str
("'Class");
676 if Present
(Expression
(A
)) then
678 Sprint_Node
(Expression
(A
));
692 Indent
:= Indent
- 7;
695 end Sprint_Aspect_Specifications
;
697 ---------------------
698 -- Sprint_Bar_List --
699 ---------------------
701 procedure Sprint_Bar_List
(List
: List_Id
) is
704 if Is_Non_Empty_List
(List
) then
705 Node
:= First
(List
);
709 exit when Node
= Empty
;
715 ----------------------
716 -- Sprint_End_Label --
717 ----------------------
719 procedure Sprint_End_Label
725 and then Present
(End_Label
(Node
))
726 and then Is_Entity_Name
(End_Label
(Node
))
728 Set_Entity
(End_Label
(Node
), Default
);
730 -- For a function whose name is an operator, use the qualified name
731 -- created for the defining entity.
733 if Nkind
(End_Label
(Node
)) = N_Operator_Symbol
then
734 Set_Chars
(End_Label
(Node
), Chars
(Default
));
737 Sprint_Node
(End_Label
(Node
));
739 Sprint_Node
(Default
);
741 end Sprint_End_Label
;
743 -----------------------
744 -- Sprint_Comma_List --
745 -----------------------
747 procedure Sprint_Comma_List
(List
: List_Id
) is
751 if Is_Non_Empty_List
(List
) then
752 Node
:= First
(List
);
756 exit when Node
= Empty
;
758 if not Is_Rewrite_Insertion
(Node
)
759 or else not Dump_Original_Only
765 end Sprint_Comma_List
;
767 --------------------------
768 -- Sprint_Indented_List --
769 --------------------------
771 procedure Sprint_Indented_List
(List
: List_Id
) is
774 Sprint_Node_List
(List
);
776 end Sprint_Indented_List
;
778 ---------------------
779 -- Sprint_Left_Opnd --
780 ---------------------
782 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
783 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
786 if Paren_Count
(Opnd
) /= 0
787 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
796 end Sprint_Left_Opnd
;
802 procedure Sprint_Node
(Node
: Node_Id
) is
804 if Is_Rewrite_Insertion
(Node
) then
805 if not Dump_Original_Only
then
807 -- For special cases of nodes that always output <<< >>>
808 -- do not duplicate the output at this point.
810 if Nkind
(Node
) = N_Freeze_Entity
811 or else Nkind
(Node
) = N_Freeze_Generic_Entity
812 or else Nkind
(Node
) = N_Implicit_Label_Declaration
814 Sprint_Node_Actual
(Node
);
816 -- Normal case where <<< >>> may be required
819 Write_Rewrite_Str
("<<<");
820 Sprint_Node_Actual
(Node
);
821 Write_Rewrite_Str
(">>>");
825 elsif Is_Rewrite_Substitution
(Node
) then
827 -- Case of dump generated only
829 if Dump_Generated_Only
then
830 Sprint_Node_Actual
(Node
);
832 -- Case of dump original only
834 elsif Dump_Original_Only
then
835 Sprint_Node_Actual
(Original_Node
(Node
));
837 -- Case of both being dumped
840 Sprint_Node_Actual
(Original_Node
(Node
));
841 Write_Rewrite_Str
("<<<");
842 Sprint_Node_Actual
(Node
);
843 Write_Rewrite_Str
(">>>");
847 Sprint_Node_Actual
(Node
);
851 ------------------------
852 -- Sprint_Node_Actual --
853 ------------------------
855 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
856 Save_Dump_Node
: constant Node_Id
:= Dump_Node
;
863 for J
in 1 .. Paren_Count
(Node
) loop
864 Write_Str_With_Col_Check
("(");
867 -- Setup current dump node
871 if Nkind
(Node
) in N_Subexpr
872 and then Do_Range_Check
(Node
)
874 Write_Str_With_Col_Check
("{");
877 -- Select print circuit based on node kind
880 when N_Abort_Statement
=>
881 Write_Indent_Str_Sloc
("abort ");
882 Sprint_Comma_List
(Names
(Node
));
885 when N_Abortable_Part
=>
887 Write_Str_Sloc
("abort ");
888 Sprint_Indented_List
(Statements
(Node
));
890 when N_Abstract_Subprogram_Declaration
=>
892 Sprint_Node
(Specification
(Node
));
893 Write_Str_With_Col_Check
(" is ");
894 Write_Str_Sloc
("abstract;");
896 when N_Accept_Alternative
=>
897 Sprint_Node_List
(Pragmas_Before
(Node
));
899 if Present
(Condition
(Node
)) then
900 Write_Indent_Str
("when ");
901 Sprint_Node
(Condition
(Node
));
906 Sprint_Node_Sloc
(Accept_Statement
(Node
));
907 Sprint_Node_List
(Statements
(Node
));
909 when N_Accept_Statement
=>
910 Write_Indent_Str_Sloc
("accept ");
911 Write_Id
(Entry_Direct_Name
(Node
));
913 if Present
(Entry_Index
(Node
)) then
914 Write_Str_With_Col_Check
(" (");
915 Sprint_Node
(Entry_Index
(Node
));
919 Write_Param_Specs
(Node
);
921 if Present
(Handled_Statement_Sequence
(Node
)) then
922 Write_Str_With_Col_Check
(" do");
923 Sprint_Node
(Handled_Statement_Sequence
(Node
));
924 Write_Indent_Str
("end ");
925 Write_Id
(Entry_Direct_Name
(Node
));
930 when N_Access_Definition
=>
934 if Present
(Access_To_Subprogram_Definition
(Node
)) then
935 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
939 if Null_Exclusion_Present
(Node
) then
940 Write_Str
("not null ");
943 Write_Str_With_Col_Check_Sloc
("access ");
945 if All_Present
(Node
) then
947 elsif Constant_Present
(Node
) then
948 Write_Str
("constant ");
951 Sprint_Node
(Subtype_Mark
(Node
));
954 when N_Access_Function_Definition
=>
958 if Null_Exclusion_Present
(Node
) then
959 Write_Str
("not null ");
962 Write_Str_With_Col_Check_Sloc
("access ");
964 if Protected_Present
(Node
) then
965 Write_Str_With_Col_Check
("protected ");
968 Write_Str_With_Col_Check
("function");
969 Write_Param_Specs
(Node
);
970 Write_Str_With_Col_Check
(" return ");
971 Sprint_Node
(Result_Definition
(Node
));
973 when N_Access_Procedure_Definition
=>
977 if Null_Exclusion_Present
(Node
) then
978 Write_Str
("not null ");
981 Write_Str_With_Col_Check_Sloc
("access ");
983 if Protected_Present
(Node
) then
984 Write_Str_With_Col_Check
("protected ");
987 Write_Str_With_Col_Check
("procedure");
988 Write_Param_Specs
(Node
);
990 when N_Access_To_Object_Definition
=>
991 Write_Str_With_Col_Check_Sloc
("access ");
993 if All_Present
(Node
) then
994 Write_Str_With_Col_Check
("all ");
995 elsif Constant_Present
(Node
) then
996 Write_Str_With_Col_Check
("constant ");
1001 if Null_Exclusion_Present
(Node
) then
1002 Write_Str
("not null ");
1005 Sprint_Node
(Subtype_Indication
(Node
));
1008 if Null_Record_Present
(Node
) then
1009 Write_Str_With_Col_Check_Sloc
("(null record)");
1012 Write_Str_With_Col_Check_Sloc
("(");
1014 if Present
(Expressions
(Node
)) then
1015 Sprint_Comma_List
(Expressions
(Node
));
1017 if Present
(Component_Associations
(Node
))
1018 and then not Is_Empty_List
(Component_Associations
(Node
))
1024 if Present
(Component_Associations
(Node
))
1025 and then not Is_Empty_List
(Component_Associations
(Node
))
1033 Nd
:= First
(Component_Associations
(Node
));
1041 if not Is_Rewrite_Insertion
(Nd
)
1042 or else not Dump_Original_Only
1056 Write_Str_With_Col_Check_Sloc
("new ");
1058 -- Ada 2005 (AI-231)
1060 if Null_Exclusion_Present
(Node
) then
1061 Write_Str
("not null ");
1064 Sprint_Node
(Expression
(Node
));
1066 if Present
(Storage_Pool
(Node
)) then
1067 Write_Str_With_Col_Check
("[storage_pool = ");
1068 Sprint_Node
(Storage_Pool
(Node
));
1073 Sprint_Left_Opnd
(Node
);
1074 Write_Str_Sloc
(" and then ");
1075 Sprint_Right_Opnd
(Node
);
1077 -- Note: the following code for N_Aspect_Specification is not
1078 -- normally used, since we deal with aspects as part of a
1079 -- declaration, but it is here in case we deliberately try
1080 -- to print an N_Aspect_Speficiation node (e.g. from GDB).
1082 when N_Aspect_Specification
=>
1083 Sprint_Node
(Identifier
(Node
));
1085 Sprint_Node
(Expression
(Node
));
1087 when N_Assignment_Statement
=>
1089 Sprint_Node
(Name
(Node
));
1090 Write_Str_Sloc
(" := ");
1091 Sprint_Node
(Expression
(Node
));
1094 when N_Asynchronous_Select
=>
1095 Write_Indent_Str_Sloc
("select");
1097 Sprint_Node
(Triggering_Alternative
(Node
));
1100 -- Note: let the printing of Abortable_Part handle outputting
1101 -- the ABORT keyword, so that the Sloc can be set correctly.
1103 Write_Indent_Str
("then ");
1104 Sprint_Node
(Abortable_Part
(Node
));
1105 Write_Indent_Str
("end select;");
1108 Write_Indent_Str_Sloc
("for ");
1109 Write_Id
(Identifier
(Node
));
1110 Write_Str_With_Col_Check
(" use at ");
1111 Sprint_Node
(Expression
(Node
));
1114 when N_Attribute_Definition_Clause
=>
1115 Write_Indent_Str_Sloc
("for ");
1116 Sprint_Node
(Name
(Node
));
1118 Write_Name_With_Col_Check
(Chars
(Node
));
1119 Write_Str_With_Col_Check
(" use ");
1120 Sprint_Node
(Expression
(Node
));
1123 when N_Attribute_Reference
=>
1124 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1128 Sprint_Node
(Prefix
(Node
));
1129 Write_Char_Sloc
(''');
1130 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
1131 Sprint_Paren_Comma_List
(Expressions
(Node
));
1133 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1137 when N_Block_Statement
=>
1140 if Present
(Identifier
(Node
))
1141 and then (not Has_Created_Identifier
(Node
)
1142 or else not Dump_Original_Only
)
1144 Write_Rewrite_Str
("<<<");
1145 Write_Id
(Identifier
(Node
));
1147 Write_Rewrite_Str
(">>>");
1150 if Present
(Declarations
(Node
)) then
1151 Write_Str_With_Col_Check_Sloc
("declare");
1152 Sprint_Indented_List
(Declarations
(Node
));
1156 Write_Str_With_Col_Check_Sloc
("begin");
1157 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1158 Write_Indent_Str
("end");
1160 if Present
(Identifier
(Node
))
1161 and then (not Has_Created_Identifier
(Node
)
1162 or else not Dump_Original_Only
)
1164 Write_Rewrite_Str
("<<<");
1166 Write_Id
(Identifier
(Node
));
1167 Write_Rewrite_Str
(">>>");
1172 when N_Case_Expression
=>
1174 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
1178 -- The syntax for case_expression does not include parentheses,
1179 -- but sometimes parentheses are required, so unconditionally
1180 -- generate them here unless already present.
1182 if not Has_Parens
then
1186 Write_Str_With_Col_Check_Sloc
("case ");
1187 Sprint_Node
(Expression
(Node
));
1188 Write_Str_With_Col_Check
(" is");
1190 Alt
:= First
(Alternatives
(Node
));
1198 if not Has_Parens
then
1203 when N_Case_Expression_Alternative
=>
1204 Write_Str_With_Col_Check
(" when ");
1205 Sprint_Bar_List
(Discrete_Choices
(Node
));
1207 Sprint_Node
(Expression
(Node
));
1209 when N_Case_Statement
=>
1210 Write_Indent_Str_Sloc
("case ");
1211 Sprint_Node
(Expression
(Node
));
1213 Sprint_Indented_List
(Alternatives
(Node
));
1214 Write_Indent_Str
("end case;");
1216 when N_Case_Statement_Alternative
=>
1217 Write_Indent_Str_Sloc
("when ");
1218 Sprint_Bar_List
(Discrete_Choices
(Node
));
1220 Sprint_Indented_List
(Statements
(Node
));
1222 when N_Character_Literal
=>
1223 if Column
> Sprint_Line_Limit
- 2 then
1224 Write_Indent_Str
(" ");
1227 Write_Char_Sloc
(''');
1228 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
1231 when N_Code_Statement
=>
1234 Sprint_Node
(Expression
(Node
));
1237 when N_Compilation_Unit
=>
1238 Sprint_Node_List
(Context_Items
(Node
));
1239 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
1241 if Private_Present
(Node
) then
1242 Write_Indent_Str
("private ");
1246 Sprint_Node_Sloc
(Unit
(Node
));
1248 if Present
(Actions
(Aux_Decls_Node
(Node
)))
1250 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
1255 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
1256 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
1258 when N_Compilation_Unit_Aux
=>
1259 null; -- nothing to do, never used, see above
1261 when N_Component_Association
=>
1263 Sprint_Bar_List
(Choices
(Node
));
1266 -- Ada 2005 (AI-287): Print the box if present
1268 if Box_Present
(Node
) then
1269 Write_Str_With_Col_Check
("<>");
1271 Sprint_Node
(Expression
(Node
));
1274 when N_Component_Clause
=>
1276 Sprint_Node
(Component_Name
(Node
));
1277 Write_Str_Sloc
(" at ");
1278 Sprint_Node
(Position
(Node
));
1280 Write_Str_With_Col_Check
("range ");
1281 Sprint_Node
(First_Bit
(Node
));
1283 Sprint_Node
(Last_Bit
(Node
));
1286 when N_Component_Definition
=>
1289 -- Ada 2005 (AI-230): Access definition components
1291 if Present
(Access_Definition
(Node
)) then
1292 Sprint_Node
(Access_Definition
(Node
));
1294 elsif Present
(Subtype_Indication
(Node
)) then
1295 if Aliased_Present
(Node
) then
1296 Write_Str_With_Col_Check
("aliased ");
1299 -- Ada 2005 (AI-231)
1301 if Null_Exclusion_Present
(Node
) then
1302 Write_Str
(" not null ");
1305 Sprint_Node
(Subtype_Indication
(Node
));
1308 Write_Str
(" ??? ");
1311 when N_Component_Declaration
=>
1312 if Write_Indent_Identifiers_Sloc
(Node
) then
1314 Sprint_Node
(Component_Definition
(Node
));
1316 if Present
(Expression
(Node
)) then
1318 Sprint_Node
(Expression
(Node
));
1324 when N_Component_List
=>
1325 if Null_Present
(Node
) then
1327 Write_Indent_Str_Sloc
("null");
1333 Sprint_Indented_List
(Component_Items
(Node
));
1334 Sprint_Node
(Variant_Part
(Node
));
1337 when N_Compound_Statement
=>
1338 Write_Indent_Str
("do");
1340 Sprint_Node_List
(Actions
(Node
));
1342 Write_Indent_Str
("end;");
1344 when N_Conditional_Entry_Call
=>
1345 Write_Indent_Str_Sloc
("select");
1347 Sprint_Node
(Entry_Call_Alternative
(Node
));
1349 Write_Indent_Str
("else");
1350 Sprint_Indented_List
(Else_Statements
(Node
));
1351 Write_Indent_Str
("end select;");
1353 when N_Constrained_Array_Definition
=>
1354 Write_Str_With_Col_Check_Sloc
("array ");
1355 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1358 Sprint_Node
(Component_Definition
(Node
));
1360 -- A contract node should not appear in the tree. It is a semantic
1361 -- node attached to entry and [generic] subprogram entities.
1364 raise Program_Error
;
1366 when N_Decimal_Fixed_Point_Definition
=>
1367 Write_Str_With_Col_Check_Sloc
(" delta ");
1368 Sprint_Node
(Delta_Expression
(Node
));
1369 Write_Str_With_Col_Check
("digits ");
1370 Sprint_Node
(Digits_Expression
(Node
));
1371 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1373 when N_Defining_Character_Literal
=>
1374 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1376 when N_Defining_Identifier
=>
1380 when N_Defining_Operator_Symbol
=>
1381 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1383 when N_Defining_Program_Unit_Name
=>
1385 Sprint_Node
(Name
(Node
));
1387 Write_Id
(Defining_Identifier
(Node
));
1389 when N_Delay_Alternative
=>
1390 Sprint_Node_List
(Pragmas_Before
(Node
));
1392 if Present
(Condition
(Node
)) then
1394 Write_Str_With_Col_Check
("when ");
1395 Sprint_Node
(Condition
(Node
));
1400 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1401 Sprint_Node_List
(Statements
(Node
));
1403 when N_Delay_Relative_Statement
=>
1404 Write_Indent_Str_Sloc
("delay ");
1405 Sprint_Node
(Expression
(Node
));
1408 when N_Delay_Until_Statement
=>
1409 Write_Indent_Str_Sloc
("delay until ");
1410 Sprint_Node
(Expression
(Node
));
1413 when N_Delta_Constraint
=>
1414 Write_Str_With_Col_Check_Sloc
("delta ");
1415 Sprint_Node
(Delta_Expression
(Node
));
1416 Sprint_Opt_Node
(Range_Constraint
(Node
));
1418 when N_Derived_Type_Definition
=>
1419 if Abstract_Present
(Node
) then
1420 Write_Str_With_Col_Check
("abstract ");
1423 Write_Str_With_Col_Check
("new ");
1425 -- Ada 2005 (AI-231)
1427 if Null_Exclusion_Present
(Node
) then
1428 Write_Str_With_Col_Check
("not null ");
1431 Sprint_Node
(Subtype_Indication
(Node
));
1433 if Present
(Interface_List
(Node
)) then
1434 Write_Str_With_Col_Check
(" and ");
1435 Sprint_And_List
(Interface_List
(Node
));
1436 Write_Str_With_Col_Check
(" with ");
1439 if Present
(Record_Extension_Part
(Node
)) then
1440 if No
(Interface_List
(Node
)) then
1441 Write_Str_With_Col_Check
(" with ");
1444 Sprint_Node
(Record_Extension_Part
(Node
));
1447 when N_Designator
=>
1448 Sprint_Node
(Name
(Node
));
1449 Write_Char_Sloc
('.');
1450 Write_Id
(Identifier
(Node
));
1452 when N_Digits_Constraint
=>
1453 Write_Str_With_Col_Check_Sloc
("digits ");
1454 Sprint_Node
(Digits_Expression
(Node
));
1455 Sprint_Opt_Node
(Range_Constraint
(Node
));
1457 when N_Discriminant_Association
=>
1460 if Present
(Selector_Names
(Node
)) then
1461 Sprint_Bar_List
(Selector_Names
(Node
));
1466 Sprint_Node
(Expression
(Node
));
1468 when N_Discriminant_Specification
=>
1471 if Write_Identifiers
(Node
) then
1474 if Null_Exclusion_Present
(Node
) then
1475 Write_Str
("not null ");
1478 Sprint_Node
(Discriminant_Type
(Node
));
1480 if Present
(Expression
(Node
)) then
1482 Sprint_Node
(Expression
(Node
));
1488 when N_Elsif_Part
=>
1489 Write_Indent_Str_Sloc
("elsif ");
1490 Sprint_Node
(Condition
(Node
));
1491 Write_Str_With_Col_Check
(" then");
1492 Sprint_Indented_List
(Then_Statements
(Node
));
1497 when N_Entry_Body
=>
1498 Write_Indent_Str_Sloc
("entry ");
1499 Write_Id
(Defining_Identifier
(Node
));
1500 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1501 Write_Str_With_Col_Check
(" is");
1502 Sprint_Indented_List
(Declarations
(Node
));
1503 Write_Indent_Str
("begin");
1504 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1505 Write_Indent_Str
("end ");
1506 Write_Id
(Defining_Identifier
(Node
));
1509 when N_Entry_Body_Formal_Part
=>
1510 if Present
(Entry_Index_Specification
(Node
)) then
1511 Write_Str_With_Col_Check_Sloc
(" (");
1512 Sprint_Node
(Entry_Index_Specification
(Node
));
1516 Write_Param_Specs
(Node
);
1517 Write_Str_With_Col_Check_Sloc
(" when ");
1518 Sprint_Node
(Condition
(Node
));
1520 when N_Entry_Call_Alternative
=>
1521 Sprint_Node_List
(Pragmas_Before
(Node
));
1522 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1523 Sprint_Node_List
(Statements
(Node
));
1525 when N_Entry_Call_Statement
=>
1527 Sprint_Node_Sloc
(Name
(Node
));
1528 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1531 when N_Entry_Declaration
=>
1532 Write_Indent_Str_Sloc
("entry ");
1533 Write_Id
(Defining_Identifier
(Node
));
1535 if Present
(Discrete_Subtype_Definition
(Node
)) then
1536 Write_Str_With_Col_Check
(" (");
1537 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1541 Write_Param_Specs
(Node
);
1544 when N_Entry_Index_Specification
=>
1545 Write_Str_With_Col_Check_Sloc
("for ");
1546 Write_Id
(Defining_Identifier
(Node
));
1547 Write_Str_With_Col_Check
(" in ");
1548 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1550 when N_Enumeration_Representation_Clause
=>
1551 Write_Indent_Str_Sloc
("for ");
1552 Write_Id
(Identifier
(Node
));
1553 Write_Str_With_Col_Check
(" use ");
1554 Sprint_Node
(Array_Aggregate
(Node
));
1557 when N_Enumeration_Type_Definition
=>
1560 -- Skip attempt to print Literals field if it's not there and
1561 -- we are in package Standard (case of Character, which is
1562 -- handled specially (without an explicit literals list).
1564 if Sloc
(Node
) > Standard_Location
1565 or else Present
(Literals
(Node
))
1567 Sprint_Paren_Comma_List
(Literals
(Node
));
1571 Write_Str_With_Col_Check_Sloc
("<error>");
1573 when N_Exception_Declaration
=>
1574 if Write_Indent_Identifiers
(Node
) then
1575 Write_Str_With_Col_Check
(" : ");
1577 if Is_Statically_Allocated
(Defining_Identifier
(Node
)) then
1578 Write_Str_With_Col_Check
("static ");
1581 Write_Str_Sloc
("exception");
1583 if Present
(Expression
(Node
)) then
1585 Sprint_Node
(Expression
(Node
));
1591 when N_Exception_Handler
=>
1592 Write_Indent_Str_Sloc
("when ");
1594 if Present
(Choice_Parameter
(Node
)) then
1595 Sprint_Node
(Choice_Parameter
(Node
));
1599 Sprint_Bar_List
(Exception_Choices
(Node
));
1601 Sprint_Indented_List
(Statements
(Node
));
1603 when N_Exception_Renaming_Declaration
=>
1606 Sprint_Node
(Defining_Identifier
(Node
));
1607 Write_Str_With_Col_Check
(" : exception renames ");
1608 Sprint_Node
(Name
(Node
));
1611 when N_Exit_Statement
=>
1612 Write_Indent_Str_Sloc
("exit");
1613 Sprint_Opt_Node
(Name
(Node
));
1615 if Present
(Condition
(Node
)) then
1616 Write_Str_With_Col_Check
(" when ");
1617 Sprint_Node
(Condition
(Node
));
1622 when N_Expanded_Name
=>
1623 Sprint_Node
(Prefix
(Node
));
1624 Write_Char_Sloc
('.');
1625 Sprint_Node
(Selector_Name
(Node
));
1627 when N_Explicit_Dereference
=>
1628 Sprint_Node
(Prefix
(Node
));
1629 Write_Char_Sloc
('.');
1630 Write_Str_Sloc
("all");
1632 when N_Expression_With_Actions
=>
1634 Write_Indent_Str_Sloc
("do ");
1636 Sprint_Node_List
(Actions
(Node
));
1639 Write_Str_With_Col_Check_Sloc
("in ");
1640 Sprint_Node
(Expression
(Node
));
1641 Write_Str_With_Col_Check
(" end");
1645 when N_Expression_Function
=>
1647 Sprint_Node_Sloc
(Specification
(Node
));
1651 Sprint_Node
(Expression
(Node
));
1655 when N_Extended_Return_Statement
=>
1656 Write_Indent_Str_Sloc
("return ");
1657 Sprint_Node_List
(Return_Object_Declarations
(Node
));
1659 if Present
(Handled_Statement_Sequence
(Node
)) then
1660 Write_Str_With_Col_Check
(" do");
1661 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1662 Write_Indent_Str
("end return;");
1664 Write_Indent_Str
(";");
1667 when N_Extension_Aggregate
=>
1668 Write_Str_With_Col_Check_Sloc
("(");
1669 Sprint_Node
(Ancestor_Part
(Node
));
1670 Write_Str_With_Col_Check
(" with ");
1672 if Null_Record_Present
(Node
) then
1673 Write_Str_With_Col_Check
("null record");
1675 if Present
(Expressions
(Node
)) then
1676 Sprint_Comma_List
(Expressions
(Node
));
1678 if Present
(Component_Associations
(Node
)) then
1683 if Present
(Component_Associations
(Node
)) then
1684 Sprint_Comma_List
(Component_Associations
(Node
));
1690 when N_Floating_Point_Definition
=>
1691 Write_Str_With_Col_Check_Sloc
("digits ");
1692 Sprint_Node
(Digits_Expression
(Node
));
1693 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1695 when N_Formal_Decimal_Fixed_Point_Definition
=>
1696 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1698 when N_Formal_Derived_Type_Definition
=>
1699 Write_Str_With_Col_Check_Sloc
("new ");
1700 Sprint_Node
(Subtype_Mark
(Node
));
1702 if Present
(Interface_List
(Node
)) then
1703 Write_Str_With_Col_Check
(" and ");
1704 Sprint_And_List
(Interface_List
(Node
));
1707 if Private_Present
(Node
) then
1708 Write_Str_With_Col_Check
(" with private");
1711 when N_Formal_Abstract_Subprogram_Declaration
=>
1712 Write_Indent_Str_Sloc
("with ");
1713 Sprint_Node
(Specification
(Node
));
1715 Write_Str_With_Col_Check
(" is abstract");
1717 if Box_Present
(Node
) then
1718 Write_Str_With_Col_Check
(" <>");
1719 elsif Present
(Default_Name
(Node
)) then
1720 Write_Str_With_Col_Check
(" ");
1721 Sprint_Node
(Default_Name
(Node
));
1726 when N_Formal_Concrete_Subprogram_Declaration
=>
1727 Write_Indent_Str_Sloc
("with ");
1728 Sprint_Node
(Specification
(Node
));
1730 if Box_Present
(Node
) then
1731 Write_Str_With_Col_Check
(" is <>");
1732 elsif Present
(Default_Name
(Node
)) then
1733 Write_Str_With_Col_Check
(" is ");
1734 Sprint_Node
(Default_Name
(Node
));
1739 when N_Formal_Discrete_Type_Definition
=>
1740 Write_Str_With_Col_Check_Sloc
("<>");
1742 when N_Formal_Floating_Point_Definition
=>
1743 Write_Str_With_Col_Check_Sloc
("digits <>");
1745 when N_Formal_Modular_Type_Definition
=>
1746 Write_Str_With_Col_Check_Sloc
("mod <>");
1748 when N_Formal_Object_Declaration
=>
1751 if Write_Indent_Identifiers
(Node
) then
1754 if In_Present
(Node
) then
1755 Write_Str_With_Col_Check
("in ");
1758 if Out_Present
(Node
) then
1759 Write_Str_With_Col_Check
("out ");
1762 if Present
(Subtype_Mark
(Node
)) then
1764 -- Ada 2005 (AI-423): Formal object with null exclusion
1766 if Null_Exclusion_Present
(Node
) then
1767 Write_Str
("not null ");
1770 Sprint_Node
(Subtype_Mark
(Node
));
1772 -- Ada 2005 (AI-423): Formal object with access definition
1775 pragma Assert
(Present
(Access_Definition
(Node
)));
1777 Sprint_Node
(Access_Definition
(Node
));
1780 if Present
(Default_Expression
(Node
)) then
1782 Sprint_Node
(Default_Expression
(Node
));
1788 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1789 Write_Str_With_Col_Check_Sloc
("delta <>");
1791 when N_Formal_Package_Declaration
=>
1792 Write_Indent_Str_Sloc
("with package ");
1793 Write_Id
(Defining_Identifier
(Node
));
1794 Write_Str_With_Col_Check
(" is new ");
1795 Sprint_Node
(Name
(Node
));
1796 Write_Str_With_Col_Check
(" (<>);");
1798 when N_Formal_Private_Type_Definition
=>
1799 if Abstract_Present
(Node
) then
1800 Write_Str_With_Col_Check
("abstract ");
1803 if Tagged_Present
(Node
) then
1804 Write_Str_With_Col_Check
("tagged ");
1807 if Limited_Present
(Node
) then
1808 Write_Str_With_Col_Check
("limited ");
1811 Write_Str_With_Col_Check_Sloc
("private");
1813 when N_Formal_Incomplete_Type_Definition
=>
1814 if Tagged_Present
(Node
) then
1815 Write_Str_With_Col_Check
("is tagged ");
1818 when N_Formal_Signed_Integer_Type_Definition
=>
1819 Write_Str_With_Col_Check_Sloc
("range <>");
1821 when N_Formal_Type_Declaration
=>
1822 Write_Indent_Str_Sloc
("type ");
1823 Write_Id
(Defining_Identifier
(Node
));
1825 if Present
(Discriminant_Specifications
(Node
)) then
1826 Write_Discr_Specs
(Node
);
1827 elsif Unknown_Discriminants_Present
(Node
) then
1828 Write_Str_With_Col_Check
("(<>)");
1831 if Nkind
(Formal_Type_Definition
(Node
)) /=
1832 N_Formal_Incomplete_Type_Definition
1834 Write_Str_With_Col_Check
(" is ");
1837 Sprint_Node
(Formal_Type_Definition
(Node
));
1840 when N_Free_Statement
=>
1841 Write_Indent_Str_Sloc
("free ");
1842 Sprint_Node
(Expression
(Node
));
1845 when N_Freeze_Entity
=>
1846 if Dump_Original_Only
then
1849 -- A freeze node is output if it has some effect (i.e. non-empty
1850 -- actions, or freeze node for an itype, which causes elaboration
1851 -- of the itype), and is also always output if Dump_Freeze_Null
1854 elsif Present
(Actions
(Node
))
1855 or else Is_Itype
(Entity
(Node
))
1856 or else Dump_Freeze_Null
1859 Write_Rewrite_Str
("<<<");
1860 Write_Str_With_Col_Check_Sloc
("freeze ");
1861 Write_Id
(Entity
(Node
));
1864 if No
(Actions
(Node
)) then
1868 -- Output freeze actions. We increment Freeze_Indent during
1869 -- this output to avoid generating extra blank lines before
1870 -- any procedures included in the freeze actions.
1872 Freeze_Indent
:= Freeze_Indent
+ 1;
1873 Sprint_Indented_List
(Actions
(Node
));
1874 Freeze_Indent
:= Freeze_Indent
- 1;
1875 Write_Indent_Str
("]");
1878 Write_Rewrite_Str
(">>>");
1881 when N_Freeze_Generic_Entity
=>
1882 if Dump_Original_Only
then
1887 Write_Str_With_Col_Check_Sloc
("freeze_generic ");
1888 Write_Id
(Entity
(Node
));
1891 when N_Full_Type_Declaration
=>
1892 Write_Indent_Str_Sloc
("type ");
1893 Sprint_Node
(Defining_Identifier
(Node
));
1894 Write_Discr_Specs
(Node
);
1895 Write_Str_With_Col_Check
(" is ");
1896 Sprint_Node
(Type_Definition
(Node
));
1899 when N_Function_Call
=>
1901 Write_Subprogram_Name
(Name
(Node
));
1902 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1904 when N_Function_Instantiation
=>
1905 Write_Indent_Str_Sloc
("function ");
1906 Sprint_Node
(Defining_Unit_Name
(Node
));
1907 Write_Str_With_Col_Check
(" is new ");
1908 Sprint_Node
(Name
(Node
));
1909 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1912 when N_Function_Specification
=>
1913 Write_Str_With_Col_Check_Sloc
("function ");
1914 Sprint_Node
(Defining_Unit_Name
(Node
));
1915 Write_Param_Specs
(Node
);
1916 Write_Str_With_Col_Check
(" return ");
1918 -- Ada 2005 (AI-231)
1920 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
1921 and then Null_Exclusion_Present
(Node
)
1923 Write_Str
(" not null ");
1926 Sprint_Node
(Result_Definition
(Node
));
1928 when N_Generic_Association
=>
1931 if Present
(Selector_Name
(Node
)) then
1932 Sprint_Node
(Selector_Name
(Node
));
1936 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
1938 when N_Generic_Function_Renaming_Declaration
=>
1939 Write_Indent_Str_Sloc
("generic function ");
1940 Sprint_Node
(Defining_Unit_Name
(Node
));
1941 Write_Str_With_Col_Check
(" renames ");
1942 Sprint_Node
(Name
(Node
));
1945 when N_Generic_Package_Declaration
=>
1947 Write_Indent_Str_Sloc
("generic ");
1948 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1950 Sprint_Node
(Specification
(Node
));
1953 when N_Generic_Package_Renaming_Declaration
=>
1954 Write_Indent_Str_Sloc
("generic package ");
1955 Sprint_Node
(Defining_Unit_Name
(Node
));
1956 Write_Str_With_Col_Check
(" renames ");
1957 Sprint_Node
(Name
(Node
));
1960 when N_Generic_Procedure_Renaming_Declaration
=>
1961 Write_Indent_Str_Sloc
("generic procedure ");
1962 Sprint_Node
(Defining_Unit_Name
(Node
));
1963 Write_Str_With_Col_Check
(" renames ");
1964 Sprint_Node
(Name
(Node
));
1967 when N_Generic_Subprogram_Declaration
=>
1969 Write_Indent_Str_Sloc
("generic ");
1970 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1972 Sprint_Node
(Specification
(Node
));
1975 when N_Goto_Statement
=>
1976 Write_Indent_Str_Sloc
("goto ");
1977 Sprint_Node
(Name
(Node
));
1980 if Nkind
(Next
(Node
)) = N_Label
then
1984 when N_Handled_Sequence_Of_Statements
=>
1986 Sprint_Indented_List
(Statements
(Node
));
1988 if Present
(Exception_Handlers
(Node
)) then
1989 Write_Indent_Str
("exception");
1991 Sprint_Node_List
(Exception_Handlers
(Node
));
1995 if Present
(At_End_Proc
(Node
)) then
1996 Write_Indent_Str
("at end");
1999 Sprint_Node
(At_End_Proc
(Node
));
2004 when N_Identifier
=>
2008 when N_If_Expression
=>
2010 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
2011 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
2012 Then_Expr
: constant Node_Id
:= Next
(Condition
);
2015 -- The syntax for if_expression does not include parentheses,
2016 -- but sometimes parentheses are required, so unconditionally
2017 -- generate them here unless already present.
2019 if not Has_Parens
then
2023 Write_Str_With_Col_Check_Sloc
("if ");
2024 Sprint_Node
(Condition
);
2025 Write_Str_With_Col_Check
(" then ");
2027 -- Defense against junk here
2029 if Present
(Then_Expr
) then
2030 Sprint_Node
(Then_Expr
);
2032 if Present
(Next
(Then_Expr
)) then
2033 Write_Str_With_Col_Check
(" else ");
2034 Sprint_Node
(Next
(Then_Expr
));
2038 if not Has_Parens
then
2043 when N_If_Statement
=>
2044 Write_Indent_Str_Sloc
("if ");
2045 Sprint_Node
(Condition
(Node
));
2046 Write_Str_With_Col_Check
(" then");
2047 Sprint_Indented_List
(Then_Statements
(Node
));
2048 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
2050 if Present
(Else_Statements
(Node
)) then
2051 Write_Indent_Str
("else");
2052 Sprint_Indented_List
(Else_Statements
(Node
));
2055 Write_Indent_Str
("end if;");
2057 when N_Implicit_Label_Declaration
=>
2058 if not Dump_Original_Only
then
2060 Write_Rewrite_Str
("<<<");
2062 Write_Id
(Defining_Identifier
(Node
));
2064 Write_Str_With_Col_Check
("label");
2065 Write_Rewrite_Str
(">>>");
2069 Sprint_Left_Opnd
(Node
);
2070 Write_Str_Sloc
(" in ");
2072 if Present
(Right_Opnd
(Node
)) then
2073 Sprint_Right_Opnd
(Node
);
2075 Sprint_Bar_List
(Alternatives
(Node
));
2078 when N_Incomplete_Type_Declaration
=>
2079 Write_Indent_Str_Sloc
("type ");
2080 Write_Id
(Defining_Identifier
(Node
));
2082 if Present
(Discriminant_Specifications
(Node
)) then
2083 Write_Discr_Specs
(Node
);
2084 elsif Unknown_Discriminants_Present
(Node
) then
2085 Write_Str_With_Col_Check
("(<>)");
2090 when N_Index_Or_Discriminant_Constraint
=>
2092 Sprint_Paren_Comma_List
(Constraints
(Node
));
2094 when N_Indexed_Component
=>
2095 Sprint_Node_Sloc
(Prefix
(Node
));
2096 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
2098 when N_Integer_Literal
=>
2099 if Print_In_Hex
(Node
) then
2100 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
2102 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
2105 when N_Iteration_Scheme
=>
2106 if Present
(Condition
(Node
)) then
2107 Write_Str_With_Col_Check_Sloc
("while ");
2108 Sprint_Node
(Condition
(Node
));
2110 Write_Str_With_Col_Check_Sloc
("for ");
2112 if Present
(Iterator_Specification
(Node
)) then
2113 Sprint_Node
(Iterator_Specification
(Node
));
2115 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2121 when N_Iterator_Specification
=>
2123 Write_Id
(Defining_Identifier
(Node
));
2125 if Present
(Subtype_Indication
(Node
)) then
2126 Write_Str_With_Col_Check
(" : ");
2127 Sprint_Node
(Subtype_Indication
(Node
));
2130 if Of_Present
(Node
) then
2131 Write_Str_With_Col_Check
(" of ");
2133 Write_Str_With_Col_Check
(" in ");
2136 if Reverse_Present
(Node
) then
2137 Write_Str_With_Col_Check
("reverse ");
2140 Sprint_Node
(Name
(Node
));
2142 when N_Itype_Reference
=>
2143 Write_Indent_Str_Sloc
("reference ");
2144 Write_Id
(Itype
(Node
));
2147 Write_Indent_Str_Sloc
("<<");
2148 Write_Id
(Identifier
(Node
));
2151 when N_Loop_Parameter_Specification
=>
2153 Write_Id
(Defining_Identifier
(Node
));
2154 Write_Str_With_Col_Check
(" in ");
2156 if Reverse_Present
(Node
) then
2157 Write_Str_With_Col_Check
("reverse ");
2160 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
2162 when N_Loop_Statement
=>
2165 if Present
(Identifier
(Node
))
2166 and then (not Has_Created_Identifier
(Node
)
2167 or else not Dump_Original_Only
)
2169 Write_Rewrite_Str
("<<<");
2170 Write_Id
(Identifier
(Node
));
2172 Write_Rewrite_Str
(">>>");
2173 Sprint_Node
(Iteration_Scheme
(Node
));
2174 Write_Str_With_Col_Check_Sloc
("loop");
2175 Sprint_Indented_List
(Statements
(Node
));
2176 Write_Indent_Str
("end loop ");
2177 Write_Rewrite_Str
("<<<");
2178 Write_Id
(Identifier
(Node
));
2179 Write_Rewrite_Str
(">>>");
2183 Sprint_Node
(Iteration_Scheme
(Node
));
2184 Write_Str_With_Col_Check_Sloc
("loop");
2185 Sprint_Indented_List
(Statements
(Node
));
2186 Write_Indent_Str
("end loop;");
2189 when N_Mod_Clause
=>
2190 Sprint_Node_List
(Pragmas_Before
(Node
));
2191 Write_Str_With_Col_Check_Sloc
("at mod ");
2192 Sprint_Node
(Expression
(Node
));
2194 when N_Modular_Type_Definition
=>
2195 Write_Str_With_Col_Check_Sloc
("mod ");
2196 Sprint_Node
(Expression
(Node
));
2199 Sprint_Left_Opnd
(Node
);
2200 Write_Str_Sloc
(" not in ");
2202 if Present
(Right_Opnd
(Node
)) then
2203 Sprint_Right_Opnd
(Node
);
2205 Sprint_Bar_List
(Alternatives
(Node
));
2209 Write_Str_With_Col_Check_Sloc
("null");
2211 when N_Null_Statement
=>
2212 if Comes_From_Source
(Node
)
2213 or else Dump_Freeze_Null
2214 or else not Is_List_Member
(Node
)
2215 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
2217 Write_Indent_Str_Sloc
("null;");
2220 when N_Number_Declaration
=>
2223 if Write_Indent_Identifiers
(Node
) then
2224 Write_Str_With_Col_Check
(" : constant ");
2226 Sprint_Node
(Expression
(Node
));
2230 when N_Object_Declaration
=>
2233 if Write_Indent_Identifiers
(Node
) then
2235 Def_Id
: constant Entity_Id
:= Defining_Identifier
(Node
);
2238 Write_Str_With_Col_Check
(" : ");
2240 if Is_Statically_Allocated
(Def_Id
) then
2241 Write_Str_With_Col_Check
("static ");
2244 if Aliased_Present
(Node
) then
2245 Write_Str_With_Col_Check
("aliased ");
2248 if Constant_Present
(Node
) then
2249 Write_Str_With_Col_Check
("constant ");
2252 -- Ada 2005 (AI-231)
2254 if Null_Exclusion_Present
(Node
) then
2255 Write_Str_With_Col_Check
("not null ");
2258 -- Print type. We used to print the Object_Definition from
2259 -- the node, but it is much more useful to print the Etype
2260 -- of the defining identifier for the case where the nominal
2261 -- type is an unconstrained array type. For example, this
2262 -- will be a clear reference to the Itype with the bounds
2263 -- in the case of a type like String. The object after
2264 -- all is constrained, even if its nominal subtype is
2268 Odef
: constant Node_Id
:= Object_Definition
(Node
);
2271 if Nkind
(Odef
) = N_Identifier
2272 and then Present
(Etype
(Odef
))
2273 and then Is_Array_Type
(Etype
(Odef
))
2274 and then not Is_Constrained
(Etype
(Odef
))
2275 and then Present
(Etype
(Def_Id
))
2277 Sprint_Node
(Etype
(Def_Id
));
2279 -- In other cases, the nominal type is fine to print
2286 if Present
(Expression
(Node
)) then
2288 Sprint_Node
(Expression
(Node
));
2293 -- Handle implicit importation and implicit exportation of
2294 -- object declarations:
2295 -- $pragma import (Convention_Id, Def_Id, "...");
2296 -- $pragma export (Convention_Id, Def_Id, "...");
2298 if Is_Internal
(Def_Id
)
2299 and then Present
(Interface_Name
(Def_Id
))
2301 Write_Indent_Str_Sloc
("$pragma ");
2303 if Is_Imported
(Def_Id
) then
2304 Write_Str
("import (");
2306 else pragma Assert
(Is_Exported
(Def_Id
));
2307 Write_Str
("export (");
2311 Prefix
: constant String := "Convention_";
2312 S
: constant String := Convention
(Def_Id
)'Img;
2315 Name_Len
:= S
'Last - Prefix
'Last;
2316 Name_Buffer
(1 .. Name_Len
) :=
2317 S
(Prefix
'Last + 1 .. S
'Last);
2318 Set_Casing
(All_Lower_Case
);
2319 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2325 Write_String_Table_Entry
2326 (Strval
(Interface_Name
(Def_Id
)));
2332 when N_Object_Renaming_Declaration
=>
2335 Sprint_Node
(Defining_Identifier
(Node
));
2338 -- Ada 2005 (AI-230): Access renamings
2340 if Present
(Access_Definition
(Node
)) then
2341 Sprint_Node
(Access_Definition
(Node
));
2343 elsif Present
(Subtype_Mark
(Node
)) then
2345 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2347 if Null_Exclusion_Present
(Node
) then
2348 Write_Str
("not null ");
2351 Sprint_Node
(Subtype_Mark
(Node
));
2354 Write_Str
(" ??? ");
2357 Write_Str_With_Col_Check
(" renames ");
2358 Sprint_Node
(Name
(Node
));
2362 Write_Operator
(Node
, "abs ");
2363 Sprint_Right_Opnd
(Node
);
2366 Sprint_Left_Opnd
(Node
);
2367 Write_Operator
(Node
, " + ");
2368 Sprint_Right_Opnd
(Node
);
2371 Sprint_Left_Opnd
(Node
);
2372 Write_Operator
(Node
, " and ");
2373 Sprint_Right_Opnd
(Node
);
2376 Sprint_Left_Opnd
(Node
);
2377 Write_Operator
(Node
, " & ");
2378 Sprint_Right_Opnd
(Node
);
2381 Sprint_Left_Opnd
(Node
);
2383 Process_TFAI_RR_Flags
(Node
);
2384 Write_Operator
(Node
, "/ ");
2385 Sprint_Right_Opnd
(Node
);
2388 Sprint_Left_Opnd
(Node
);
2389 Write_Operator
(Node
, " = ");
2390 Sprint_Right_Opnd
(Node
);
2393 Sprint_Left_Opnd
(Node
);
2394 Write_Operator
(Node
, " ** ");
2395 Sprint_Right_Opnd
(Node
);
2398 Sprint_Left_Opnd
(Node
);
2399 Write_Operator
(Node
, " >= ");
2400 Sprint_Right_Opnd
(Node
);
2403 Sprint_Left_Opnd
(Node
);
2404 Write_Operator
(Node
, " > ");
2405 Sprint_Right_Opnd
(Node
);
2408 Sprint_Left_Opnd
(Node
);
2409 Write_Operator
(Node
, " <= ");
2410 Sprint_Right_Opnd
(Node
);
2413 Sprint_Left_Opnd
(Node
);
2414 Write_Operator
(Node
, " < ");
2415 Sprint_Right_Opnd
(Node
);
2418 Write_Operator
(Node
, "-");
2419 Sprint_Right_Opnd
(Node
);
2422 Sprint_Left_Opnd
(Node
);
2424 if Treat_Fixed_As_Integer
(Node
) then
2428 Write_Operator
(Node
, " mod ");
2429 Sprint_Right_Opnd
(Node
);
2431 when N_Op_Multiply
=>
2432 Sprint_Left_Opnd
(Node
);
2434 Process_TFAI_RR_Flags
(Node
);
2435 Write_Operator
(Node
, "* ");
2436 Sprint_Right_Opnd
(Node
);
2439 Sprint_Left_Opnd
(Node
);
2440 Write_Operator
(Node
, " /= ");
2441 Sprint_Right_Opnd
(Node
);
2444 Write_Operator
(Node
, "not ");
2445 Sprint_Right_Opnd
(Node
);
2448 Sprint_Left_Opnd
(Node
);
2449 Write_Operator
(Node
, " or ");
2450 Sprint_Right_Opnd
(Node
);
2453 Write_Operator
(Node
, "+");
2454 Sprint_Right_Opnd
(Node
);
2457 Sprint_Left_Opnd
(Node
);
2459 if Treat_Fixed_As_Integer
(Node
) then
2463 Write_Operator
(Node
, " rem ");
2464 Sprint_Right_Opnd
(Node
);
2470 Write_Str_With_Col_Check
("(");
2471 Sprint_Node
(Left_Opnd
(Node
));
2473 Sprint_Node
(Right_Opnd
(Node
));
2476 when N_Op_Subtract
=>
2477 Sprint_Left_Opnd
(Node
);
2478 Write_Operator
(Node
, " - ");
2479 Sprint_Right_Opnd
(Node
);
2482 Sprint_Left_Opnd
(Node
);
2483 Write_Operator
(Node
, " xor ");
2484 Sprint_Right_Opnd
(Node
);
2486 when N_Operator_Symbol
=>
2487 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
2489 when N_Ordinary_Fixed_Point_Definition
=>
2490 Write_Str_With_Col_Check_Sloc
("delta ");
2491 Sprint_Node
(Delta_Expression
(Node
));
2492 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
2495 Sprint_Left_Opnd
(Node
);
2496 Write_Str_Sloc
(" or else ");
2497 Sprint_Right_Opnd
(Node
);
2499 when N_Others_Choice
=>
2500 if All_Others
(Node
) then
2501 Write_Str_With_Col_Check
("all ");
2504 Write_Str_With_Col_Check_Sloc
("others");
2506 when N_Package_Body
=>
2508 Write_Indent_Str_Sloc
("package body ");
2509 Sprint_Node
(Defining_Unit_Name
(Node
));
2511 Sprint_Indented_List
(Declarations
(Node
));
2513 if Present
(Handled_Statement_Sequence
(Node
)) then
2514 Write_Indent_Str
("begin");
2515 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2518 Write_Indent_Str
("end ");
2520 (Handled_Statement_Sequence
(Node
), Defining_Unit_Name
(Node
));
2523 when N_Package_Body_Stub
=>
2524 Write_Indent_Str_Sloc
("package body ");
2525 Sprint_Node
(Defining_Identifier
(Node
));
2526 Write_Str_With_Col_Check
(" is separate;");
2528 when N_Package_Declaration
=>
2531 Sprint_Node_Sloc
(Specification
(Node
));
2534 -- If this is an instantiation, get the aspects from the original
2535 -- instantiation node.
2537 if Is_Generic_Instance
(Defining_Entity
(Node
))
2538 and then Has_Aspects
2539 (Package_Instantiation
(Defining_Entity
(Node
)))
2541 Sprint_Aspect_Specifications
2542 (Package_Instantiation
(Defining_Entity
(Node
)),
2546 when N_Package_Instantiation
=>
2548 Write_Indent_Str_Sloc
("package ");
2549 Sprint_Node
(Defining_Unit_Name
(Node
));
2550 Write_Str
(" is new ");
2551 Sprint_Node
(Name
(Node
));
2552 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2555 when N_Package_Renaming_Declaration
=>
2556 Write_Indent_Str_Sloc
("package ");
2557 Sprint_Node
(Defining_Unit_Name
(Node
));
2558 Write_Str_With_Col_Check
(" renames ");
2559 Sprint_Node
(Name
(Node
));
2562 when N_Package_Specification
=>
2563 Write_Str_With_Col_Check_Sloc
("package ");
2564 Sprint_Node
(Defining_Unit_Name
(Node
));
2566 if Nkind
(Parent
(Node
)) = N_Generic_Package_Declaration
2567 and then Has_Aspects
(Parent
(Node
))
2569 Sprint_Aspect_Specifications
2570 (Parent
(Node
), Semicolon
=> False);
2572 -- An instantiation is rewritten as a package declaration, but
2573 -- the aspects belong to the instantiation node.
2575 elsif Nkind
(Parent
(Node
)) = N_Package_Declaration
then
2577 Pack
: constant Entity_Id
:= Defining_Entity
(Node
);
2580 if not Is_Generic_Instance
(Pack
) then
2581 if Has_Aspects
(Parent
(Node
)) then
2582 Sprint_Aspect_Specifications
2583 (Parent
(Node
), Semicolon
=> False);
2590 Sprint_Indented_List
(Visible_Declarations
(Node
));
2592 if Present
(Private_Declarations
(Node
)) then
2593 Write_Indent_Str
("private");
2594 Sprint_Indented_List
(Private_Declarations
(Node
));
2597 Write_Indent_Str
("end ");
2598 Sprint_Node
(Defining_Unit_Name
(Node
));
2600 when N_Parameter_Association
=>
2601 Sprint_Node_Sloc
(Selector_Name
(Node
));
2603 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2605 when N_Parameter_Specification
=>
2608 if Write_Identifiers
(Node
) then
2611 if In_Present
(Node
) then
2612 Write_Str_With_Col_Check
("in ");
2615 if Out_Present
(Node
) then
2616 Write_Str_With_Col_Check
("out ");
2619 -- Ada 2005 (AI-231): Parameter specification may carry null
2620 -- exclusion. Do not print it now if this is an access formal,
2621 -- it is emitted when the access definition is displayed.
2623 if Null_Exclusion_Present
(Node
)
2624 and then Nkind
(Parameter_Type
(Node
))
2625 /= N_Access_Definition
2627 Write_Str
("not null ");
2630 Sprint_Node
(Parameter_Type
(Node
));
2632 if Present
(Expression
(Node
)) then
2634 Sprint_Node
(Expression
(Node
));
2640 when N_Pop_Constraint_Error_Label
=>
2641 Write_Indent_Str
("%pop_constraint_error_label");
2643 when N_Pop_Program_Error_Label
=>
2644 Write_Indent_Str
("%pop_program_error_label");
2646 when N_Pop_Storage_Error_Label
=>
2647 Write_Indent_Str
("%pop_storage_error_label");
2649 when N_Private_Extension_Declaration
=>
2650 Write_Indent_Str_Sloc
("type ");
2651 Write_Id
(Defining_Identifier
(Node
));
2653 if Present
(Discriminant_Specifications
(Node
)) then
2654 Write_Discr_Specs
(Node
);
2655 elsif Unknown_Discriminants_Present
(Node
) then
2656 Write_Str_With_Col_Check
("(<>)");
2659 Write_Str_With_Col_Check
(" is new ");
2660 Sprint_Node
(Subtype_Indication
(Node
));
2662 if Present
(Interface_List
(Node
)) then
2663 Write_Str_With_Col_Check
(" and ");
2664 Sprint_And_List
(Interface_List
(Node
));
2667 Write_Str_With_Col_Check
(" with private;");
2669 when N_Private_Type_Declaration
=>
2670 Write_Indent_Str_Sloc
("type ");
2671 Write_Id
(Defining_Identifier
(Node
));
2673 if Present
(Discriminant_Specifications
(Node
)) then
2674 Write_Discr_Specs
(Node
);
2675 elsif Unknown_Discriminants_Present
(Node
) then
2676 Write_Str_With_Col_Check
("(<>)");
2681 if Tagged_Present
(Node
) then
2682 Write_Str_With_Col_Check
("tagged ");
2685 if Limited_Present
(Node
) then
2686 Write_Str_With_Col_Check
("limited ");
2689 Write_Str_With_Col_Check
("private;");
2691 when N_Push_Constraint_Error_Label
=>
2692 Write_Indent_Str
("%push_constraint_error_label (");
2694 if Present
(Exception_Label
(Node
)) then
2695 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2700 when N_Push_Program_Error_Label
=>
2701 Write_Indent_Str
("%push_program_error_label (");
2703 if Present
(Exception_Label
(Node
)) then
2704 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2709 when N_Push_Storage_Error_Label
=>
2710 Write_Indent_Str
("%push_storage_error_label (");
2712 if Present
(Exception_Label
(Node
)) then
2713 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2719 Write_Indent_Str_Sloc
("pragma ");
2720 Write_Name_With_Col_Check
(Pragma_Name
(Node
));
2722 if Present
(Pragma_Argument_Associations
(Node
)) then
2723 Sprint_Opt_Paren_Comma_List
2724 (Pragma_Argument_Associations
(Node
));
2729 when N_Pragma_Argument_Association
=>
2732 if Chars
(Node
) /= No_Name
then
2733 Write_Name_With_Col_Check
(Chars
(Node
));
2737 Sprint_Node
(Expression
(Node
));
2739 when N_Procedure_Call_Statement
=>
2742 Write_Subprogram_Name
(Name
(Node
));
2743 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2746 when N_Procedure_Instantiation
=>
2747 Write_Indent_Str_Sloc
("procedure ");
2748 Sprint_Node
(Defining_Unit_Name
(Node
));
2749 Write_Str_With_Col_Check
(" is new ");
2750 Sprint_Node
(Name
(Node
));
2751 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2754 when N_Procedure_Specification
=>
2755 Write_Str_With_Col_Check_Sloc
("procedure ");
2756 Sprint_Node
(Defining_Unit_Name
(Node
));
2757 Write_Param_Specs
(Node
);
2759 when N_Protected_Body
=>
2760 Write_Indent_Str_Sloc
("protected body ");
2761 Write_Id
(Defining_Identifier
(Node
));
2763 Sprint_Indented_List
(Declarations
(Node
));
2764 Write_Indent_Str
("end ");
2765 Write_Id
(Defining_Identifier
(Node
));
2768 when N_Protected_Body_Stub
=>
2769 Write_Indent_Str_Sloc
("protected body ");
2770 Write_Id
(Defining_Identifier
(Node
));
2771 Write_Str_With_Col_Check
(" is separate;");
2773 when N_Protected_Definition
=>
2775 Sprint_Indented_List
(Visible_Declarations
(Node
));
2777 if Present
(Private_Declarations
(Node
)) then
2778 Write_Indent_Str
("private");
2779 Sprint_Indented_List
(Private_Declarations
(Node
));
2782 Write_Indent_Str
("end ");
2784 when N_Protected_Type_Declaration
=>
2785 Write_Indent_Str_Sloc
("protected type ");
2786 Sprint_Node
(Defining_Identifier
(Node
));
2787 Write_Discr_Specs
(Node
);
2789 if Present
(Interface_List
(Node
)) then
2790 Write_Str
(" is new ");
2791 Sprint_And_List
(Interface_List
(Node
));
2792 Write_Str
(" with ");
2797 Sprint_Node
(Protected_Definition
(Node
));
2798 Write_Id
(Defining_Identifier
(Node
));
2801 when N_Qualified_Expression
=>
2802 Sprint_Node
(Subtype_Mark
(Node
));
2803 Write_Char_Sloc
(''');
2805 -- Print expression, make sure we have at least one level of
2806 -- parentheses around the expression. For cases of qualified
2807 -- expressions in the source, this is always the case, but
2808 -- for generated qualifications, there may be no explicit
2809 -- parentheses present.
2811 if Paren_Count
(Expression
(Node
)) /= 0 then
2812 Sprint_Node
(Expression
(Node
));
2816 Sprint_Node
(Expression
(Node
));
2818 -- Odd case, for the qualified expressions used in machine
2819 -- code the argument may be a procedure call, resulting in
2820 -- a junk semicolon before the right parent, get rid of it.
2822 Write_Erase_Char
(';');
2824 -- Now we can add the terminating right paren
2829 when N_Quantified_Expression
=>
2832 if All_Present
(Node
) then
2833 Write_Str
(" all ");
2835 Write_Str
(" some ");
2838 if Present
(Iterator_Specification
(Node
)) then
2839 Sprint_Node
(Iterator_Specification
(Node
));
2841 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2845 Sprint_Node
(Condition
(Node
));
2847 when N_Raise_Expression
=>
2849 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
2852 -- The syntax for raise_expression does not include parentheses
2853 -- but sometimes parentheses are required, so unconditionally
2854 -- generate them here unless already present.
2856 if not Has_Parens
then
2860 Write_Str_With_Col_Check_Sloc
("raise ");
2861 Sprint_Node
(Name
(Node
));
2863 if Present
(Expression
(Node
)) then
2864 Write_Str_With_Col_Check
(" with ");
2865 Sprint_Node
(Expression
(Node
));
2868 if not Has_Parens
then
2873 when N_Raise_Constraint_Error
=>
2875 -- This node can be used either as a subexpression or as a
2876 -- statement form. The following test is a reasonably reliable
2877 -- way to distinguish the two cases.
2879 if Is_List_Member
(Node
)
2880 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2885 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2886 Write_Condition_And_Reason
(Node
);
2888 when N_Raise_Program_Error
=>
2890 -- This node can be used either as a subexpression or as a
2891 -- statement form. The following test is a reasonably reliable
2892 -- way to distinguish the two cases.
2894 if Is_List_Member
(Node
)
2895 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2900 Write_Str_With_Col_Check_Sloc
("[program_error");
2901 Write_Condition_And_Reason
(Node
);
2903 when N_Raise_Storage_Error
=>
2905 -- This node can be used either as a subexpression or as a
2906 -- statement form. The following test is a reasonably reliable
2907 -- way to distinguish the two cases.
2909 if Is_List_Member
(Node
)
2910 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2915 Write_Str_With_Col_Check_Sloc
("[storage_error");
2916 Write_Condition_And_Reason
(Node
);
2918 when N_Raise_Statement
=>
2919 Write_Indent_Str_Sloc
("raise ");
2920 Sprint_Node
(Name
(Node
));
2924 Sprint_Node
(Low_Bound
(Node
));
2925 Write_Str_Sloc
(" .. ");
2926 Sprint_Node
(High_Bound
(Node
));
2927 Update_Itype
(Node
);
2929 when N_Range_Constraint
=>
2930 Write_Str_With_Col_Check_Sloc
("range ");
2931 Sprint_Node
(Range_Expression
(Node
));
2933 when N_Real_Literal
=>
2934 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
2936 when N_Real_Range_Specification
=>
2937 Write_Str_With_Col_Check_Sloc
("range ");
2938 Sprint_Node
(Low_Bound
(Node
));
2940 Sprint_Node
(High_Bound
(Node
));
2942 when N_Record_Definition
=>
2943 if Abstract_Present
(Node
) then
2944 Write_Str_With_Col_Check
("abstract ");
2947 if Tagged_Present
(Node
) then
2948 Write_Str_With_Col_Check
("tagged ");
2951 if Limited_Present
(Node
) then
2952 Write_Str_With_Col_Check
("limited ");
2955 if Null_Present
(Node
) then
2956 Write_Str_With_Col_Check_Sloc
("null record");
2959 Write_Str_With_Col_Check_Sloc
("record");
2960 Sprint_Node
(Component_List
(Node
));
2961 Write_Indent_Str
("end record");
2964 when N_Record_Representation_Clause
=>
2965 Write_Indent_Str_Sloc
("for ");
2966 Sprint_Node
(Identifier
(Node
));
2967 Write_Str_With_Col_Check
(" use record ");
2969 if Present
(Mod_Clause
(Node
)) then
2970 Sprint_Node
(Mod_Clause
(Node
));
2973 Sprint_Indented_List
(Component_Clauses
(Node
));
2974 Write_Indent_Str
("end record;");
2977 Sprint_Node
(Prefix
(Node
));
2978 Write_Str_With_Col_Check_Sloc
("'reference");
2980 when N_Requeue_Statement
=>
2981 Write_Indent_Str_Sloc
("requeue ");
2982 Sprint_Node
(Name
(Node
));
2984 if Abort_Present
(Node
) then
2985 Write_Str_With_Col_Check
(" with abort");
2990 -- Don't we want to print more detail???
2992 -- Doc of this extended syntax belongs in sinfo.ads and/or
2995 when N_SCIL_Dispatch_Table_Tag_Init
=>
2996 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Tag_Init]");
2998 when N_SCIL_Dispatching_Call
=>
2999 Write_Indent_Str
("[N_SCIL_Dispatching_Node]");
3001 when N_SCIL_Membership_Test
=>
3002 Write_Indent_Str
("[N_SCIL_Membership_Test]");
3004 when N_Simple_Return_Statement
=>
3005 if Present
(Expression
(Node
)) then
3006 Write_Indent_Str_Sloc
("return ");
3007 Sprint_Node
(Expression
(Node
));
3010 Write_Indent_Str_Sloc
("return;");
3013 when N_Selective_Accept
=>
3014 Write_Indent_Str_Sloc
("select");
3019 Alt_Node
:= First
(Select_Alternatives
(Node
));
3022 Sprint_Node
(Alt_Node
);
3025 exit when No
(Alt_Node
);
3026 Write_Indent_Str
("or");
3030 if Present
(Else_Statements
(Node
)) then
3031 Write_Indent_Str
("else");
3032 Sprint_Indented_List
(Else_Statements
(Node
));
3035 Write_Indent_Str
("end select;");
3037 when N_Signed_Integer_Type_Definition
=>
3038 Write_Str_With_Col_Check_Sloc
("range ");
3039 Sprint_Node
(Low_Bound
(Node
));
3041 Sprint_Node
(High_Bound
(Node
));
3043 when N_Single_Protected_Declaration
=>
3044 Write_Indent_Str_Sloc
("protected ");
3045 Write_Id
(Defining_Identifier
(Node
));
3047 Sprint_Node
(Protected_Definition
(Node
));
3048 Write_Id
(Defining_Identifier
(Node
));
3051 when N_Single_Task_Declaration
=>
3052 Write_Indent_Str_Sloc
("task ");
3053 Sprint_Node
(Defining_Identifier
(Node
));
3055 if Present
(Task_Definition
(Node
)) then
3057 Sprint_Node
(Task_Definition
(Node
));
3062 when N_Selected_Component
=>
3063 Sprint_Node
(Prefix
(Node
));
3064 Write_Char_Sloc
('.');
3065 Sprint_Node
(Selector_Name
(Node
));
3069 Sprint_Node
(Prefix
(Node
));
3070 Write_Str_With_Col_Check
(" (");
3071 Sprint_Node
(Discrete_Range
(Node
));
3074 when N_String_Literal
=>
3075 if String_Length
(Strval
(Node
)) + Column
> Sprint_Line_Limit
then
3076 Write_Indent_Str
(" ");
3080 Write_String_Table_Entry
(Strval
(Node
));
3082 when N_Subprogram_Body
=>
3084 -- Output extra blank line unless we are in freeze actions
3086 if Freeze_Indent
= 0 then
3092 if Present
(Corresponding_Spec
(Node
)) then
3093 Sprint_Node_Sloc
(Parent
(Corresponding_Spec
(Node
)));
3095 Sprint_Node_Sloc
(Specification
(Node
));
3100 Sprint_Indented_List
(Declarations
(Node
));
3101 Write_Indent_Str
("begin");
3102 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3104 Write_Indent_Str
("end ");
3107 (Handled_Statement_Sequence
(Node
),
3108 Defining_Unit_Name
(Specification
(Node
)));
3111 if Is_List_Member
(Node
)
3112 and then Present
(Next
(Node
))
3113 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
3118 when N_Subprogram_Body_Stub
=>
3120 Sprint_Node_Sloc
(Specification
(Node
));
3121 Write_Str_With_Col_Check
(" is separate;");
3123 when N_Subprogram_Declaration
=>
3125 Sprint_Node_Sloc
(Specification
(Node
));
3127 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
3128 and then Null_Present
(Specification
(Node
))
3130 Write_Str_With_Col_Check
(" is null");
3135 when N_Subprogram_Renaming_Declaration
=>
3137 Sprint_Node
(Specification
(Node
));
3138 Write_Str_With_Col_Check_Sloc
(" renames ");
3139 Sprint_Node
(Name
(Node
));
3142 when N_Subtype_Declaration
=>
3143 Write_Indent_Str_Sloc
("subtype ");
3144 Sprint_Node
(Defining_Identifier
(Node
));
3147 -- Ada 2005 (AI-231)
3149 if Null_Exclusion_Present
(Node
) then
3150 Write_Str
("not null ");
3153 Sprint_Node
(Subtype_Indication
(Node
));
3156 when N_Subtype_Indication
=>
3157 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
3159 Sprint_Node
(Constraint
(Node
));
3162 Write_Indent_Str_Sloc
("separate (");
3163 Sprint_Node
(Name
(Node
));
3166 Sprint_Node
(Proper_Body
(Node
));
3169 Write_Indent_Str_Sloc
("task body ");
3170 Write_Id
(Defining_Identifier
(Node
));
3172 Sprint_Indented_List
(Declarations
(Node
));
3173 Write_Indent_Str
("begin");
3174 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3175 Write_Indent_Str
("end ");
3177 (Handled_Statement_Sequence
(Node
), Defining_Identifier
(Node
));
3180 when N_Task_Body_Stub
=>
3181 Write_Indent_Str_Sloc
("task body ");
3182 Write_Id
(Defining_Identifier
(Node
));
3183 Write_Str_With_Col_Check
(" is separate;");
3185 when N_Task_Definition
=>
3187 Sprint_Indented_List
(Visible_Declarations
(Node
));
3189 if Present
(Private_Declarations
(Node
)) then
3190 Write_Indent_Str
("private");
3191 Sprint_Indented_List
(Private_Declarations
(Node
));
3194 Write_Indent_Str
("end ");
3195 Sprint_End_Label
(Node
, Defining_Identifier
(Parent
(Node
)));
3197 when N_Task_Type_Declaration
=>
3198 Write_Indent_Str_Sloc
("task type ");
3199 Sprint_Node
(Defining_Identifier
(Node
));
3200 Write_Discr_Specs
(Node
);
3202 if Present
(Interface_List
(Node
)) then
3203 Write_Str
(" is new ");
3204 Sprint_And_List
(Interface_List
(Node
));
3207 if Present
(Task_Definition
(Node
)) then
3208 if No
(Interface_List
(Node
)) then
3211 Write_Str
(" with ");
3214 Sprint_Node
(Task_Definition
(Node
));
3219 when N_Terminate_Alternative
=>
3220 Sprint_Node_List
(Pragmas_Before
(Node
));
3223 if Present
(Condition
(Node
)) then
3224 Write_Str_With_Col_Check
("when ");
3225 Sprint_Node
(Condition
(Node
));
3229 Write_Str_With_Col_Check_Sloc
("terminate;");
3230 Sprint_Node_List
(Pragmas_After
(Node
));
3232 when N_Timed_Entry_Call
=>
3233 Write_Indent_Str_Sloc
("select");
3235 Sprint_Node
(Entry_Call_Alternative
(Node
));
3237 Write_Indent_Str
("or");
3239 Sprint_Node
(Delay_Alternative
(Node
));
3241 Write_Indent_Str
("end select;");
3243 when N_Triggering_Alternative
=>
3244 Sprint_Node_List
(Pragmas_Before
(Node
));
3245 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
3246 Sprint_Node_List
(Statements
(Node
));
3248 when N_Type_Conversion
=>
3250 Sprint_Node
(Subtype_Mark
(Node
));
3253 if Conversion_OK
(Node
) then
3257 if Float_Truncate
(Node
) then
3261 if Rounded_Result
(Node
) then
3266 Sprint_Node
(Expression
(Node
));
3269 when N_Unchecked_Expression
=>
3272 Sprint_Node_Sloc
(Expression
(Node
));
3275 when N_Unchecked_Type_Conversion
=>
3276 Sprint_Node
(Subtype_Mark
(Node
));
3278 Write_Str_With_Col_Check
("(");
3279 Sprint_Node_Sloc
(Expression
(Node
));
3282 when N_Unconstrained_Array_Definition
=>
3283 Write_Str_With_Col_Check_Sloc
("array (");
3288 Node1
:= First
(Subtype_Marks
(Node
));
3290 Sprint_Node
(Node1
);
3291 Write_Str_With_Col_Check
(" range <>");
3293 exit when Node1
= Empty
;
3298 Write_Str
(") of ");
3299 Sprint_Node
(Component_Definition
(Node
));
3301 when N_Unused_At_Start | N_Unused_At_End
=>
3302 Write_Indent_Str
("***** Error, unused node encountered *****");
3305 when N_Use_Package_Clause
=>
3306 Write_Indent_Str_Sloc
("use ");
3307 Sprint_Comma_List
(Names
(Node
));
3310 when N_Use_Type_Clause
=>
3311 Write_Indent_Str_Sloc
("use type ");
3312 Sprint_Comma_List
(Subtype_Marks
(Node
));
3315 when N_Validate_Unchecked_Conversion
=>
3316 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
3317 Sprint_Node
(Source_Type
(Node
));
3319 Sprint_Node
(Target_Type
(Node
));
3323 Write_Indent_Str_Sloc
("when ");
3324 Sprint_Bar_List
(Discrete_Choices
(Node
));
3326 Sprint_Node
(Component_List
(Node
));
3328 when N_Variant_Part
=>
3330 Write_Indent_Str_Sloc
("case ");
3331 Sprint_Node
(Name
(Node
));
3333 Sprint_Indented_List
(Variants
(Node
));
3334 Write_Indent_Str
("end case");
3337 when N_With_Clause
=>
3339 -- Special test, if we are dumping the original tree only,
3340 -- then we want to eliminate the bogus with clauses that
3341 -- correspond to the non-existent children of Text_IO.
3343 if Dump_Original_Only
3344 and then Is_Text_IO_Special_Unit
(Name
(Node
))
3348 -- Normal case, output the with clause
3351 if First_Name
(Node
) or else not Dump_Original_Only
then
3353 -- Ada 2005 (AI-50217): Print limited with_clauses
3355 if Private_Present
(Node
) and Limited_Present
(Node
) then
3356 Write_Indent_Str
("limited private with ");
3358 elsif Private_Present
(Node
) then
3359 Write_Indent_Str
("private with ");
3361 elsif Limited_Present
(Node
) then
3362 Write_Indent_Str
("limited with ");
3365 Write_Indent_Str
("with ");
3372 Sprint_Node_Sloc
(Name
(Node
));
3374 if Last_Name
(Node
) or else not Dump_Original_Only
then
3380 -- Print aspects, except for special case of package declaration,
3381 -- where the aspects are printed inside the package specification.
3383 if Has_Aspects
(Node
)
3384 and then not Nkind_In
(Node
, N_Package_Declaration
,
3385 N_Generic_Package_Declaration
)
3387 Sprint_Aspect_Specifications
(Node
, Semicolon
=> True);
3390 if Nkind
(Node
) in N_Subexpr
3391 and then Do_Range_Check
(Node
)
3396 for J
in 1 .. Paren_Count
(Node
) loop
3400 Dump_Node
:= Save_Dump_Node
;
3401 end Sprint_Node_Actual
;
3403 ----------------------
3404 -- Sprint_Node_List --
3405 ----------------------
3407 procedure Sprint_Node_List
(List
: List_Id
; New_Lines
: Boolean := False) is
3411 if Is_Non_Empty_List
(List
) then
3412 Node
:= First
(List
);
3417 exit when Node
= Empty
;
3421 if New_Lines
and then Column
/= 1 then
3424 end Sprint_Node_List
;
3426 ----------------------
3427 -- Sprint_Node_Sloc --
3428 ----------------------
3430 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
3434 if Debug_Generated_Code
and then Present
(Dump_Node
) then
3435 Set_Sloc
(Dump_Node
, Sloc
(Node
));
3438 end Sprint_Node_Sloc
;
3440 ---------------------
3441 -- Sprint_Opt_Node --
3442 ---------------------
3444 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
3446 if Present
(Node
) then
3450 end Sprint_Opt_Node
;
3452 --------------------------
3453 -- Sprint_Opt_Node_List --
3454 --------------------------
3456 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
3458 if Present
(List
) then
3459 Sprint_Node_List
(List
);
3461 end Sprint_Opt_Node_List
;
3463 ---------------------------------
3464 -- Sprint_Opt_Paren_Comma_List --
3465 ---------------------------------
3467 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
3469 if Is_Non_Empty_List
(List
) then
3471 Sprint_Paren_Comma_List
(List
);
3473 end Sprint_Opt_Paren_Comma_List
;
3475 -----------------------------
3476 -- Sprint_Paren_Comma_List --
3477 -----------------------------
3479 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
3481 Node_Exists
: Boolean := False;
3485 if Is_Non_Empty_List
(List
) then
3487 if Dump_Original_Only
then
3489 while Present
(N
) loop
3490 if not Is_Rewrite_Insertion
(N
) then
3491 Node_Exists
:= True;
3498 if not Node_Exists
then
3503 Write_Str_With_Col_Check
("(");
3504 Sprint_Comma_List
(List
);
3507 end Sprint_Paren_Comma_List
;
3509 ----------------------
3510 -- Sprint_Right_Opnd --
3511 ----------------------
3513 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
3514 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
3517 if Paren_Count
(Opnd
) /= 0
3518 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
3527 end Sprint_Right_Opnd
;
3533 procedure Update_Itype
(Node
: Node_Id
) is
3535 if Present
(Etype
(Node
))
3536 and then Is_Itype
(Etype
(Node
))
3537 and then Debug_Generated_Code
3539 Set_Sloc
(Etype
(Node
), Sloc
(Node
));
3543 ---------------------
3544 -- Write_Char_Sloc --
3545 ---------------------
3547 procedure Write_Char_Sloc
(C
: Character) is
3549 if Debug_Generated_Code
and then C
/= ' ' then
3554 end Write_Char_Sloc
;
3556 --------------------------------
3557 -- Write_Condition_And_Reason --
3558 --------------------------------
3560 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
3561 Cond
: constant Node_Id
:= Condition
(Node
);
3562 Image
: constant String := RT_Exception_Code
'Image
3563 (RT_Exception_Code
'Val
3564 (UI_To_Int
(Reason
(Node
))));
3567 if Present
(Cond
) then
3569 -- If condition is a single entity, or NOT with a single entity,
3570 -- output all on one line, since it will likely fit just fine.
3572 if Is_Entity_Name
(Cond
)
3573 or else (Nkind
(Cond
) = N_Op_Not
3574 and then Is_Entity_Name
(Right_Opnd
(Cond
)))
3576 Write_Str_With_Col_Check
(" when ");
3580 -- Otherwise for more complex condition, multiple lines
3583 Write_Str_With_Col_Check
(" when");
3584 Indent
:= Indent
+ 2;
3588 Indent
:= Indent
- 2;
3591 -- If no condition, just need a space (all on one line)
3601 for J
in 4 .. Image
'Last loop
3602 if Image
(J
) = '_' then
3605 Write_Char
(Fold_Lower
(Image
(J
)));
3610 end Write_Condition_And_Reason
;
3612 --------------------------------
3613 -- Write_Corresponding_Source --
3614 --------------------------------
3616 procedure Write_Corresponding_Source
(S
: String) is
3618 Src
: Source_Buffer_Ptr
;
3621 -- Ignore if not in dump source text mode, or if in freeze actions
3623 if Dump_Source_Text
and then Freeze_Indent
= 0 then
3625 -- Ignore null string
3631 -- Ignore space or semicolon at end of given string
3633 if S
(S
'Last) = ' ' or else S
(S
'Last) = ';' then
3634 Write_Corresponding_Source
(S
(S
'First .. S
'Last - 1));
3638 -- Loop to look at next lines not yet printed in source file
3641 Last_Line_Printed
+ 1 .. Last_Source_Line
(Current_Source_File
)
3643 Src
:= Source_Text
(Current_Source_File
);
3644 Loc
:= Line_Start
(L
, Current_Source_File
);
3646 -- If comment, keep looking
3648 if Src
(Loc
.. Loc
+ 1) = "--" then
3651 -- Search to first non-blank
3654 while Src
(Loc
) not in Line_Terminator
loop
3658 if Src
(Loc
) /= ' ' and then Src
(Loc
) /= ASCII
.HT
then
3660 -- Loop through characters in string to see if we match
3662 for J
in S
'Range loop
3664 -- If mismatch, then not the case we are looking for
3666 if Src
(Loc
) /= S
(J
) then
3673 -- If we fall through, string matched, if white space or
3674 -- semicolon after the matched string, this is the case
3675 -- we are looking for.
3677 if Src
(Loc
) in Line_Terminator
3678 or else Src
(Loc
) = ' '
3679 or else Src
(Loc
) = ASCII
.HT
3680 or else Src
(Loc
) = ';'
3682 -- So output source lines up to and including this one
3684 Write_Source_Lines
(L
);
3693 -- Line was all blanks, or a comment line, keep looking
3697 end Write_Corresponding_Source
;
3699 -----------------------
3700 -- Write_Discr_Specs --
3701 -----------------------
3703 procedure Write_Discr_Specs
(N
: Node_Id
) is
3708 Specs
:= Discriminant_Specifications
(N
);
3710 if Present
(Specs
) then
3711 Write_Str_With_Col_Check
(" (");
3712 Spec
:= First
(Specs
);
3717 exit when Spec
= Empty
;
3719 -- Add semicolon, unless we are printing original tree and the
3720 -- next specification is part of a list (but not the first
3721 -- element of that list)
3723 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3730 end Write_Discr_Specs
;
3736 procedure Write_Ekind
(E
: Entity_Id
) is
3737 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
3740 Name_Len
:= S
'Length;
3741 Name_Buffer
(1 .. Name_Len
) := S
;
3742 Set_Casing
(Mixed_Case
);
3743 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3750 procedure Write_Id
(N
: Node_Id
) is
3752 -- Deal with outputting Itype
3754 -- Note: if we are printing the full tree with -gnatds, then we may
3755 -- end up picking up the Associated_Node link from a generic template
3756 -- here which overlaps the Entity field, but as documented, Write_Itype
3757 -- is defended against junk calls.
3759 if Nkind
(N
) in N_Entity
then
3761 elsif Nkind
(N
) in N_Has_Entity
then
3762 Write_Itype
(Entity
(N
));
3765 -- Case of a defining identifier
3767 if Nkind
(N
) = N_Defining_Identifier
then
3769 -- If defining identifier has an interface name (and no
3770 -- address clause), then we output the interface name.
3772 if (Is_Imported
(N
) or else Is_Exported
(N
))
3773 and then Present
(Interface_Name
(N
))
3774 and then No
(Address_Clause
(N
))
3776 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
3777 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3779 -- If no interface name (or inactive because there was
3780 -- an address clause), then just output the Chars name.
3783 Write_Name_With_Col_Check
(Chars
(N
));
3786 -- Case of selector of an expanded name where the expanded name
3787 -- has an associated entity, output this entity. Check that the
3788 -- entity or associated node is of the right kind, see above.
3790 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
3791 and then Selector_Name
(Parent
(N
)) = N
3792 and then Present
(Entity_Or_Associated_Node
(Parent
(N
)))
3793 and then Nkind
(Entity
(Parent
(N
))) in N_Entity
3795 Write_Id
(Entity
(Parent
(N
)));
3797 -- For any other node with an associated entity, output it
3799 elsif Nkind
(N
) in N_Has_Entity
3800 and then Present
(Entity_Or_Associated_Node
(N
))
3801 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
3803 Write_Id
(Entity
(N
));
3805 -- All other cases, we just print the Chars field
3808 Write_Name_With_Col_Check
(Chars
(N
));
3812 -----------------------
3813 -- Write_Identifiers --
3814 -----------------------
3816 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
3818 Sprint_Node
(Defining_Identifier
(Node
));
3819 Update_Itype
(Defining_Identifier
(Node
));
3821 -- The remainder of the declaration must be printed unless we are
3822 -- printing the original tree and this is not the last identifier
3825 not Dump_Original_Only
or else not More_Ids
(Node
);
3827 end Write_Identifiers
;
3829 ------------------------
3830 -- Write_Implicit_Def --
3831 ------------------------
3833 procedure Write_Implicit_Def
(E
: Entity_Id
) is
3838 when E_Array_Subtype
=>
3839 Write_Str_With_Col_Check
("subtype ");
3841 Write_Str_With_Col_Check
(" is ");
3842 Write_Id
(Base_Type
(E
));
3843 Write_Str_With_Col_Check
(" (");
3845 Ind
:= First_Index
(E
);
3846 while Present
(Ind
) loop
3850 if Present
(Ind
) then
3857 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
3858 Write_Str_With_Col_Check
("subtype ");
3861 Write_Id
(Etype
(E
));
3862 Write_Str_With_Col_Check
(" range ");
3863 Sprint_Node
(Scalar_Range
(E
));
3867 Write_Str_With_Col_Check
("type ");
3869 Write_Str_With_Col_Check
(" is <");
3874 end Write_Implicit_Def
;
3880 procedure Write_Indent
is
3881 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
3884 if Indent_Annull_Flag
then
3885 Indent_Annull_Flag
:= False;
3887 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3888 -- label declarations, since they typically have the sloc of the
3889 -- corresponding label, which really messes up the -gnatL output.
3892 and then Loc
> No_Location
3893 and then Nkind
(Dump_Node
) /= N_Implicit_Label_Declaration
3895 if Get_Source_File_Index
(Loc
) = Current_Source_File
then
3897 (Get_Physical_Line_Number
(Sloc
(Dump_Node
)));
3903 for J
in 1 .. Indent
loop
3909 ------------------------------
3910 -- Write_Indent_Identifiers --
3911 ------------------------------
3913 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
3915 -- We need to start a new line for every node, except in the case
3916 -- where we are printing the original tree and this is not the first
3917 -- defining identifier in the list.
3919 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3922 -- If printing original tree and this is not the first defining
3923 -- identifier in the list, then the previous call to this procedure
3924 -- printed only the name, and we add a comma to separate the names.
3930 Sprint_Node
(Defining_Identifier
(Node
));
3932 -- The remainder of the declaration must be printed unless we are
3933 -- printing the original tree and this is not the last identifier
3936 not Dump_Original_Only
or else not More_Ids
(Node
);
3937 end Write_Indent_Identifiers
;
3939 -----------------------------------
3940 -- Write_Indent_Identifiers_Sloc --
3941 -----------------------------------
3943 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
3945 -- We need to start a new line for every node, except in the case
3946 -- where we are printing the original tree and this is not the first
3947 -- defining identifier in the list.
3949 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3952 -- If printing original tree and this is not the first defining
3953 -- identifier in the list, then the previous call to this procedure
3954 -- printed only the name, and we add a comma to separate the names.
3961 Sprint_Node
(Defining_Identifier
(Node
));
3963 -- The remainder of the declaration must be printed unless we are
3964 -- printing the original tree and this is not the last identifier
3966 return not Dump_Original_Only
or else not More_Ids
(Node
);
3967 end Write_Indent_Identifiers_Sloc
;
3969 ----------------------
3970 -- Write_Indent_Str --
3971 ----------------------
3973 procedure Write_Indent_Str
(S
: String) is
3975 Write_Corresponding_Source
(S
);
3978 end Write_Indent_Str
;
3980 ---------------------------
3981 -- Write_Indent_Str_Sloc --
3982 ---------------------------
3984 procedure Write_Indent_Str_Sloc
(S
: String) is
3986 Write_Corresponding_Source
(S
);
3989 end Write_Indent_Str_Sloc
;
3995 procedure Write_Itype
(Typ
: Entity_Id
) is
3997 procedure Write_Header
(T
: Boolean := True);
3998 -- Write type if T is True, subtype if T is false
4004 procedure Write_Header
(T
: Boolean := True) is
4007 Write_Str
("[type ");
4009 Write_Str
("[subtype ");
4012 Write_Name_With_Col_Check
(Chars
(Typ
));
4016 -- Start of processing for Write_Itype
4019 if Nkind
(Typ
) in N_Entity
4020 and then Is_Itype
(Typ
)
4021 and then not Itype_Printed
(Typ
)
4023 -- Itype to be printed
4026 B
: constant Node_Id
:= Etype
(Typ
);
4028 P
: constant Node_Id
:= Parent
(Typ
);
4030 S
: constant Saved_Output_Buffer
:= Save_Output_Buffer
;
4031 -- Save current output buffer
4033 Old_Sloc
: Source_Ptr
;
4034 -- Save sloc of related node, so it is not modified when
4035 -- printing with -gnatD.
4038 -- Write indentation at start of line
4040 for J
in 1 .. Indent
loop
4044 -- If we have a constructed declaration for the itype, print it
4047 and then Nkind
(P
) in N_Declaration
4048 and then Defining_Entity
(P
) = Typ
4050 -- We must set Itype_Printed true before the recursive call to
4051 -- print the node, otherwise we get an infinite recursion.
4053 Set_Itype_Printed
(Typ
, True);
4055 -- Write the declaration enclosed in [], avoiding new line
4056 -- at start of declaration, and semicolon at end.
4058 -- Note: The itype may be imported from another unit, in which
4059 -- case we do not want to modify the Sloc of the declaration.
4060 -- Otherwise the itype may appear to be in the current unit,
4061 -- and the back-end will reject a reference out of scope.
4064 Indent_Annull_Flag
:= True;
4065 Old_Sloc
:= Sloc
(P
);
4067 Set_Sloc
(P
, Old_Sloc
);
4068 Write_Erase_Char
(';');
4070 -- If no constructed declaration, then we have to concoct the
4071 -- source corresponding to the type entity that we have at hand.
4076 -- Access types and subtypes
4079 Write_Header
(Ekind
(Typ
) = E_Access_Type
);
4081 if Can_Never_Be_Null
(Typ
) then
4082 Write_Str
("not null ");
4085 Write_Str
("access ");
4087 if Is_Access_Constant
(Typ
) then
4088 Write_Str
("constant ");
4091 Write_Id
(Directly_Designated_Type
(Typ
));
4093 -- Array types and string types
4095 when E_Array_Type
=>
4097 Write_Str
("array (");
4099 X
:= First_Index
(Typ
);
4103 if not Is_Constrained
(Typ
) then
4104 Write_Str
(" range <>");
4112 Write_Str
(") of ");
4113 X
:= Component_Type
(Typ
);
4115 -- Preserve sloc of component type, which is defined
4116 -- elsewhere than the itype (see comment above).
4118 Old_Sloc
:= Sloc
(X
);
4120 Set_Sloc
(X
, Old_Sloc
);
4122 -- Array subtypes and string subtypes.
4123 -- Preserve Sloc of index subtypes, as above.
4125 when E_Array_Subtype | E_String_Subtype
=>
4126 Write_Header
(False);
4127 Write_Id
(Etype
(Typ
));
4130 X
:= First_Index
(Typ
);
4132 Old_Sloc
:= Sloc
(X
);
4134 Set_Sloc
(X
, Old_Sloc
);
4142 -- Signed integer types, and modular integer subtypes,
4143 -- and also enumeration subtypes.
4145 when E_Signed_Integer_Type |
4146 E_Signed_Integer_Subtype |
4147 E_Modular_Integer_Subtype |
4148 E_Enumeration_Subtype
=>
4150 Write_Header
(Ekind
(Typ
) = E_Signed_Integer_Type
);
4152 if Ekind
(Typ
) = E_Signed_Integer_Type
then
4158 -- Print bounds if different from base type
4161 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4162 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4167 -- B can either be a scalar type, in which case the
4168 -- declaration of Typ may constrain it with different
4169 -- bounds, or a private type, in which case we know
4170 -- that the declaration of Typ cannot have a scalar
4173 if Is_Scalar_Type
(B
) then
4174 LE
:= Type_Low_Bound
(B
);
4175 HE
:= Type_High_Bound
(B
);
4183 and then Nkind
(L
) = N_Integer_Literal
4184 and then Nkind
(H
) = N_Integer_Literal
4185 and then Nkind
(LE
) = N_Integer_Literal
4186 and then Nkind
(HE
) = N_Integer_Literal
4187 and then UI_Eq
(Intval
(L
), Intval
(LE
))
4188 and then UI_Eq
(Intval
(H
), Intval
(HE
)))
4193 Write_Str
(" range ");
4194 Sprint_Node
(Type_Low_Bound
(Typ
));
4196 Sprint_Node
(Type_High_Bound
(Typ
));
4200 -- Modular integer types
4202 when E_Modular_Integer_Type
=>
4205 Write_Uint_With_Col_Check
(Modulus
(Typ
), Auto
);
4207 -- Floating point types and subtypes
4209 when E_Floating_Point_Type |
4210 E_Floating_Point_Subtype
=>
4212 Write_Header
(Ekind
(Typ
) = E_Floating_Point_Type
);
4214 if Ekind
(Typ
) = E_Floating_Point_Type
then
4218 Write_Id
(Etype
(Typ
));
4220 if Digits_Value
(Typ
) /= Digits_Value
(Etype
(Typ
)) then
4221 Write_Str
(" digits ");
4222 Write_Uint_With_Col_Check
4223 (Digits_Value
(Typ
), Decimal
);
4226 -- Print bounds if not different from base type
4229 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4230 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4231 LE
: constant Node_Id
:= Type_Low_Bound
(B
);
4232 HE
: constant Node_Id
:= Type_High_Bound
(B
);
4235 if Nkind
(L
) = N_Real_Literal
4236 and then Nkind
(H
) = N_Real_Literal
4237 and then Nkind
(LE
) = N_Real_Literal
4238 and then Nkind
(HE
) = N_Real_Literal
4239 and then UR_Eq
(Realval
(L
), Realval
(LE
))
4240 and then UR_Eq
(Realval
(H
), Realval
(HE
))
4245 Write_Str
(" range ");
4246 Sprint_Node
(Type_Low_Bound
(Typ
));
4248 Sprint_Node
(Type_High_Bound
(Typ
));
4254 when E_Record_Subtype | E_Record_Subtype_With_Private
=>
4255 Write_Header
(False);
4256 Write_Str
("record");
4262 C
:= First_Entity
(Typ
);
4263 while Present
(C
) loop
4267 Write_Id
(Etype
(C
));
4273 Write_Indent_Str
(" end record");
4277 when E_Class_Wide_Type |
4278 E_Class_Wide_Subtype
=>
4279 Write_Header
(Ekind
(Typ
) = E_Class_Wide_Type
);
4280 Write_Name_With_Col_Check
(Chars
(Etype
(Typ
)));
4281 Write_Str
("'Class");
4285 when E_Subprogram_Type
=>
4288 if Etype
(Typ
) = Standard_Void_Type
then
4289 Write_Str
("procedure");
4291 Write_Str
("function");
4294 if Present
(First_Entity
(Typ
)) then
4301 Param
:= First_Entity
(Typ
);
4306 if Ekind
(Param
) = E_In_Out_Parameter
then
4307 Write_Str
("in out ");
4308 elsif Ekind
(Param
) = E_Out_Parameter
then
4312 Write_Id
(Etype
(Param
));
4313 Next_Entity
(Param
);
4314 exit when No
(Param
);
4322 if Etype
(Typ
) /= Standard_Void_Type
then
4323 Write_Str
(" return ");
4324 Write_Id
(Etype
(Typ
));
4327 when E_String_Literal_Subtype
=>
4329 LB
: constant Uint
:=
4330 Expr_Value
(String_Literal_Low_Bound
(Typ
));
4331 Len
: constant Uint
:=
4332 String_Literal_Length
(Typ
);
4334 Write_Header
(False);
4335 Write_Str
("String (");
4336 Write_Int
(UI_To_Int
(LB
));
4338 Write_Int
(UI_To_Int
(LB
+ Len
) - 1);
4342 -- For all other Itypes, print ??? (fill in later)
4345 Write_Header
(True);
4351 -- Add terminating bracket and restore output buffer
4355 Restore_Output_Buffer
(S
);
4358 Set_Itype_Printed
(Typ
);
4362 -------------------------------
4363 -- Write_Name_With_Col_Check --
4364 -------------------------------
4366 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
4372 Get_Name_String
(N
);
4374 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4375 -- upper case letter, nnn is one or more digits and b is a lower case
4376 -- letter by C...b, so that listings do not depend on serial numbers.
4378 if Debug_Flag_II
then
4380 while J
< Name_Len
- 1 loop
4381 if Name_Buffer
(J
) in 'A' .. 'Z'
4382 and then Name_Buffer
(J
+ 1) in '0' .. '9'
4385 while K
< Name_Len
loop
4386 exit when Name_Buffer
(K
) not in '0' .. '9';
4390 if Name_Buffer
(K
) in 'a' .. 'z' then
4391 L
:= Name_Len
- K
+ 1;
4393 Name_Buffer
(J
+ 4 .. J
+ L
+ 3) :=
4394 Name_Buffer
(K
.. Name_Len
);
4395 Name_Buffer
(J
+ 1 .. J
+ 3) := "...";
4396 Name_Len
:= J
+ L
+ 3;
4409 -- Fall through for normal case
4411 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4412 end Write_Name_With_Col_Check
;
4414 ------------------------------------
4415 -- Write_Name_With_Col_Check_Sloc --
4416 ------------------------------------
4418 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
4420 Get_Name_String
(N
);
4421 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
4422 end Write_Name_With_Col_Check_Sloc
;
4424 --------------------
4425 -- Write_Operator --
4426 --------------------
4428 procedure Write_Operator
(N
: Node_Id
; S
: String) is
4429 F
: Natural := S
'First;
4430 T
: Natural := S
'Last;
4433 -- If no overflow check, just write string out, and we are done
4435 if not Do_Overflow_Check
(N
) then
4438 -- If overflow check, we want to surround the operator with curly
4439 -- brackets, but not include spaces within the brackets.
4452 Write_Str_Sloc
(S
(F
.. T
));
4455 if S
(S
'Last) = ' ' then
4461 -----------------------
4462 -- Write_Param_Specs --
4463 -----------------------
4465 procedure Write_Param_Specs
(N
: Node_Id
) is
4471 Specs
:= Parameter_Specifications
(N
);
4473 if Is_Non_Empty_List
(Specs
) then
4474 Write_Str_With_Col_Check
(" (");
4475 Spec
:= First
(Specs
);
4479 Formal
:= Defining_Identifier
(Spec
);
4481 exit when Spec
= Empty
;
4483 -- Add semicolon, unless we are printing original tree and the
4484 -- next specification is part of a list (but not the first element
4487 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4492 -- Write out any extra formals
4494 while Present
(Extra_Formal
(Formal
)) loop
4495 Formal
:= Extra_Formal
(Formal
);
4497 Write_Name_With_Col_Check
(Chars
(Formal
));
4499 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
4504 end Write_Param_Specs
;
4506 -----------------------
4507 -- Write_Rewrite_Str --
4508 -----------------------
4510 procedure Write_Rewrite_Str
(S
: String) is
4512 if not Dump_Generated_Only
then
4513 if S
'Length = 3 and then S
= ">>>" then
4516 Write_Str_With_Col_Check
(S
);
4519 end Write_Rewrite_Str
;
4521 -----------------------
4522 -- Write_Source_Line --
4523 -----------------------
4525 procedure Write_Source_Line
(L
: Physical_Line_Number
) is
4527 Src
: Source_Buffer_Ptr
;
4531 if Dump_Source_Text
then
4532 Src
:= Source_Text
(Current_Source_File
);
4533 Loc
:= Line_Start
(L
, Current_Source_File
);
4536 -- See if line is a comment line, if not, and if not line one,
4537 -- precede with blank line.
4540 while Src
(Scn
) = ' ' or else Src
(Scn
) = ASCII
.HT
loop
4544 if (Src
(Scn
) in Line_Terminator
4545 or else Src
(Scn
.. Scn
+ 1) /= "--")
4551 -- Now write the source text of the line
4554 Write_Int
(Int
(L
));
4557 while Src
(Loc
) not in Line_Terminator
loop
4558 Write_Char
(Src
(Loc
));
4562 end Write_Source_Line
;
4564 ------------------------
4565 -- Write_Source_Lines --
4566 ------------------------
4568 procedure Write_Source_Lines
(L
: Physical_Line_Number
) is
4570 while Last_Line_Printed
< L
loop
4571 Last_Line_Printed
:= Last_Line_Printed
+ 1;
4572 Write_Source_Line
(Last_Line_Printed
);
4574 end Write_Source_Lines
;
4576 --------------------
4577 -- Write_Str_Sloc --
4578 --------------------
4580 procedure Write_Str_Sloc
(S
: String) is
4582 for J
in S
'Range loop
4583 Write_Char_Sloc
(S
(J
));
4587 ------------------------------
4588 -- Write_Str_With_Col_Check --
4589 ------------------------------
4591 procedure Write_Str_With_Col_Check
(S
: String) is
4593 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4594 Write_Indent_Str
(" ");
4596 if S
(S
'First) = ' ' then
4597 Write_Str
(S
(S
'First + 1 .. S
'Last));
4605 end Write_Str_With_Col_Check
;
4607 -----------------------------------
4608 -- Write_Str_With_Col_Check_Sloc --
4609 -----------------------------------
4611 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
4613 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4614 Write_Indent_Str
(" ");
4616 if S
(S
'First) = ' ' then
4617 Write_Str_Sloc
(S
(S
'First + 1 .. S
'Last));
4625 end Write_Str_With_Col_Check_Sloc
;
4627 ---------------------------
4628 -- Write_Subprogram_Name --
4629 ---------------------------
4631 procedure Write_Subprogram_Name
(N
: Node_Id
) is
4633 if not Comes_From_Source
(N
)
4634 and then Is_Entity_Name
(N
)
4637 Ent
: constant Entity_Id
:= Entity
(N
);
4639 if not In_Extended_Main_Source_Unit
(Ent
)
4641 Is_Predefined_File_Name
4642 (Unit_File_Name
(Get_Source_Unit
(Ent
)))
4644 -- Run-time routine name, output name with a preceding dollar
4645 -- making sure that we do not get a line split between them.
4647 Col_Check
(Length_Of_Name
(Chars
(Ent
)) + 1);
4649 Write_Name
(Chars
(Ent
));
4655 -- Normal case, not a run-time routine name
4658 end Write_Subprogram_Name
;
4660 -------------------------------
4661 -- Write_Uint_With_Col_Check --
4662 -------------------------------
4664 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
) is
4666 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4667 UI_Write
(U
, Format
);
4668 end Write_Uint_With_Col_Check
;
4670 ------------------------------------
4671 -- Write_Uint_With_Col_Check_Sloc --
4672 ------------------------------------
4674 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
4676 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4678 UI_Write
(U
, Format
);
4679 end Write_Uint_With_Col_Check_Sloc
;
4681 -------------------------------------
4682 -- Write_Ureal_With_Col_Check_Sloc --
4683 -------------------------------------
4685 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
4686 D
: constant Uint
:= Denominator
(U
);
4687 N
: constant Uint
:= Numerator
(U
);
4689 Col_Check
(UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
4691 UR_Write
(U
, Brackets
=> True);
4692 end Write_Ureal_With_Col_Check_Sloc
;