1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree
; use Atree
;
27 with Casing
; use Casing
;
28 with Csets
; use Csets
;
29 with Debug
; use Debug
;
30 with Einfo
; use Einfo
;
31 with Fname
; use Fname
;
33 with Namet
; use Namet
;
34 with Nlists
; use Nlists
;
36 with Output
; use Output
;
37 with Rtsfind
; use Rtsfind
;
38 with Sem_Eval
; use Sem_Eval
;
39 with Sem_Util
; use Sem_Util
;
40 with Sinfo
; use Sinfo
;
41 with Sinput
; use Sinput
;
42 with Sinput
.D
; use Sinput
.D
;
43 with Snames
; use Snames
;
44 with Stand
; use Stand
;
45 with Stringt
; use Stringt
;
46 with Uintp
; use Uintp
;
47 with Uname
; use Uname
;
48 with Urealp
; use Urealp
;
50 package body Sprint
is
51 Current_Source_File
: Source_File_Index
;
52 -- Index of source file whose generated code is being dumped
54 Dump_Node
: Node_Id
:= Empty
;
55 -- This is set to the current node, used for printing line numbers. In
56 -- Debug_Generated_Code mode, Dump_Node is set to the current node
57 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
58 -- value. The call clears it back to Empty.
60 Debug_Sloc
: Source_Ptr
;
61 -- Sloc of first byte of line currently being written if we are
62 -- generating a source debug file.
64 Dump_Original_Only
: Boolean;
65 -- Set True if the -gnatdo (dump original tree) flag is set
67 Dump_Generated_Only
: Boolean;
68 -- Set True if the -gnatG (dump generated tree) debug flag is set
69 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
71 Dump_Freeze_Null
: Boolean;
72 -- Set True if freeze nodes and non-source null statements output
74 Freeze_Indent
: Int
:= 0;
75 -- Keep track of freeze indent level (controls output of blank lines before
76 -- procedures within expression freeze actions). Relevant only if we are
77 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
78 -- output these blank lines in any case.
81 -- Number of columns for current line output indentation
83 Indent_Annull_Flag
: Boolean := False;
84 -- Set True if subsequent Write_Indent call to be ignored, gets reset
85 -- by this call, so it is only active to suppress a single indent call.
87 Last_Line_Printed
: Physical_Line_Number
;
88 -- This keeps track of the physical line number of the last source line
89 -- that has been output. The value is only valid in Dump_Source_Text mode.
91 -------------------------------
92 -- Operator Precedence Table --
93 -------------------------------
95 -- This table is used to decide whether a subexpression needs to be
96 -- parenthesized. The rule is that if an operand of an operator (which
97 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
98 -- with a lower precedence than the operator (or equal precedence if
99 -- appearing as the right operand), then parentheses are required.
101 Op_Prec
: constant array (N_Subexpr
) of Short_Short_Integer :=
134 procedure Sprint_Left_Opnd
(N
: Node_Id
);
135 -- Print left operand of operator, parenthesizing if necessary
137 procedure Sprint_Right_Opnd
(N
: Node_Id
);
138 -- Print right operand of operator, parenthesizing if necessary
140 -----------------------
141 -- Local Subprograms --
142 -----------------------
144 procedure Col_Check
(N
: Nat
);
145 -- Check that at least N characters remain on current line, and if not,
146 -- then start an extra line with two characters extra indentation for
147 -- continuing text on the next line.
149 procedure Extra_Blank_Line
;
150 -- In some situations we write extra blank lines to separate the generated
151 -- code to make it more readable. However, these extra blank lines are not
152 -- generated in Dump_Source_Text mode, since there the source text lines
153 -- output with preceding blank lines are quite sufficient as separators.
154 -- This procedure writes a blank line if Dump_Source_Text is False.
156 procedure Indent_Annull
;
157 -- Causes following call to Write_Indent to be ignored. This is used when
158 -- a higher level node wants to stop a lower level node from starting a
159 -- new line, when it would otherwise be inclined to do so (e.g. the case
160 -- of an accept statement called from an accept alternative with a guard)
162 procedure Indent_Begin
;
163 -- Increase indentation level
165 procedure Indent_End
;
166 -- Decrease indentation level
168 procedure Print_Debug_Line
(S
: String);
169 -- Used to print output lines in Debug_Generated_Code mode (this is used
170 -- as the argument for a call to Set_Special_Output in package Output).
172 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
);
173 -- Given a divide, multiplication or division node, check the flags
174 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
175 -- appropriate special syntax characters (# and @).
177 procedure Set_Debug_Sloc
;
178 -- If Dump_Node is non-empty, this routine sets the appropriate value
179 -- in its Sloc field, from the current location in the debug source file
180 -- that is currently being written.
182 procedure Sprint_And_List
(List
: List_Id
);
183 -- Print the given list with items separated by vertical "and"
185 procedure Sprint_Bar_List
(List
: List_Id
);
186 -- Print the given list with items separated by vertical bars
188 procedure Sprint_End_Label
191 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
192 -- If there is not end label, use the defining identifier of the enclosing
193 -- construct. If the end label is present, treat it as a reference to the
194 -- defining entity of the construct: this guarantees that it carries the
195 -- proper sloc information for debugging purposes.
197 procedure Sprint_Node_Actual
(Node
: Node_Id
);
198 -- This routine prints its node argument. It is a lower level routine than
199 -- Sprint_Node, in that it does not bother about rewritten trees.
201 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
202 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
203 -- sets the Sloc of the current debug node to be a copy of the Sloc
204 -- of the sprinted node Node. Note that this is done after printing
205 -- Node, so that the Sloc is the proper updated value for the debug file.
207 procedure Update_Itype
(Node
: Node_Id
);
208 -- Update the Sloc of an itype that is not attached to the tree, when
209 -- debugging expanded code. This routine is called from nodes whose
210 -- type can be an Itype, such as defining_identifiers that may be of
211 -- an anonymous access type, or ranges in slices.
213 procedure Write_Char_Sloc
(C
: Character);
214 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
215 -- called to ensure that the current node has a proper Sloc set.
217 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
218 -- Write Condition and Reason codes of Raise_xxx_Error node
220 procedure Write_Corresponding_Source
(S
: String);
221 -- If S is a string with a single keyword (possibly followed by a space),
222 -- and if the next non-comment non-blank source line matches this keyword,
223 -- then output all source lines up to this matching line.
225 procedure Write_Discr_Specs
(N
: Node_Id
);
226 -- Output discriminant specification for node, which is any of the type
227 -- declarations that can have discriminants.
229 procedure Write_Ekind
(E
: Entity_Id
);
230 -- Write the String corresponding to the Ekind without "E_"
232 procedure Write_Id
(N
: Node_Id
);
233 -- N is a node with a Chars field. This procedure writes the name that
234 -- will be used in the generated code associated with the name. For a
235 -- node with no associated entity, this is simply the Chars field. For
236 -- the case where there is an entity associated with the node, we print
237 -- the name associated with the entity (since it may have been encoded).
238 -- One other special case is that an entity has an active external name
239 -- (i.e. an external name present with no address clause), then this
240 -- external name is output. This procedure also deals with outputting
241 -- declarations of referenced itypes, if not output earlier.
243 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
244 -- Handle node where the grammar has a list of defining identifiers, but
245 -- the tree has a separate declaration for each identifier. Handles the
246 -- printing of the defining identifier, and returns True if the type and
247 -- initialization information is to be printed, False if it is to be
248 -- skipped (the latter case happens when printing defining identifiers
249 -- other than the first in the original tree output case).
251 procedure Write_Implicit_Def
(E
: Entity_Id
);
252 pragma Warnings
(Off
, Write_Implicit_Def
);
253 -- Write the definition of the implicit type E according to its Ekind
254 -- For now a debugging procedure, but might be used in the future.
256 procedure Write_Indent
;
257 -- Start a new line and write indentation spacing
259 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
260 -- Like Write_Identifiers except that each new printed declaration
261 -- is at the start of a new line.
263 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
264 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
265 -- mode, the Sloc of the current debug node is set to point to the
266 -- first output identifier.
268 procedure Write_Indent_Str
(S
: String);
269 -- Start a new line and write indent spacing followed by given string
271 procedure Write_Indent_Str_Sloc
(S
: String);
272 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
273 -- the Sloc of the current node is set to the first non-blank character
276 procedure Write_Itype
(Typ
: Entity_Id
);
277 -- If Typ is an Itype that has not been written yet, write it. If Typ is
278 -- any other kind of entity or tree node, the call is ignored.
280 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
281 -- Write name (using Write_Name) with initial column check, and possible
282 -- initial Write_Indent (to get new line) if current line is too full.
284 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
285 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
286 -- mode, sets Sloc of current debug node to first character of name.
288 procedure Write_Operator
(N
: Node_Id
; S
: String);
289 -- Like Write_Str_Sloc, used for operators, encloses the string in
290 -- characters {} if the Do_Overflow flag is set on the node N.
292 procedure Write_Param_Specs
(N
: Node_Id
);
293 -- Output parameter specifications for node (which is either a function
294 -- or procedure specification with a Parameter_Specifications field)
296 procedure Write_Rewrite_Str
(S
: String);
297 -- Writes out a string (typically containing <<< or >>>}) for a node
298 -- created by rewriting the tree. Suppressed if we are outputting the
299 -- generated code only, since in this case we don't specially mark nodes
300 -- created by rewriting).
302 procedure Write_Source_Line
(L
: Physical_Line_Number
);
303 -- If writing of interspersed source lines is enabled, then write the given
304 -- line from the source file, preceded by Eol, then an extra blank line if
305 -- the line has at least one blank, is not a comment and is not line one,
306 -- then "--" and the line number followed by period followed by text of the
307 -- source line (without terminating Eol). If interspersed source line
308 -- output not enabled, then the call has no effect.
310 procedure Write_Source_Lines
(L
: Physical_Line_Number
);
311 -- If writing of interspersed source lines is enabled, then writes source
312 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
313 -- interspersed source line output not enabled, then call has no effect.
315 procedure Write_Str_Sloc
(S
: String);
316 -- Like Write_Str, but sets debug Sloc of current debug node to first
317 -- non-blank character if a current debug node is active.
319 procedure Write_Str_With_Col_Check
(S
: String);
320 -- Write string (using Write_Str) with initial column check, and possible
321 -- initial Write_Indent (to get new line) if current line is too full.
323 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
324 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
325 -- node to first non-blank character if a current debug node is active.
327 procedure Write_Subprogram_Name
(N
: Node_Id
);
328 -- N is the Name field of a function call or procedure statement call.
329 -- The effect of the call is to output the name, preceded by a $ if the
330 -- call is identified as an implicit call to a run time routine.
332 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
);
333 -- Write Uint (using UI_Write) with initial column check, and possible
334 -- initial Write_Indent (to get new line) if current line is too full.
335 -- The format parameter determines the output format (see UI_Write).
337 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
338 -- Write Uint (using UI_Write) with initial column check, and possible
339 -- initial Write_Indent (to get new line) if current line is too full.
340 -- The format parameter determines the output format (see UI_Write).
341 -- In addition, in Debug_Generated_Code mode, sets the current node
342 -- Sloc to the first character of the output value.
344 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
345 -- Write Ureal (using same output format as UR_Write) with column checks
346 -- and a possible initial Write_Indent (to get new line) if current line
347 -- is too full. In addition, in Debug_Generated_Code mode, sets the
348 -- current node Sloc to the first character of the output value.
354 procedure Col_Check
(N
: Nat
) is
356 if N
+ Column
> Sprint_Line_Limit
then
357 Write_Indent_Str
(" ");
361 ----------------------
362 -- Extra_Blank_Line --
363 ----------------------
365 procedure Extra_Blank_Line
is
367 if not Dump_Source_Text
then
370 end Extra_Blank_Line
;
376 procedure Indent_Annull
is
378 Indent_Annull_Flag
:= True;
385 procedure Indent_Begin
is
387 Indent
:= Indent
+ 3;
394 procedure Indent_End
is
396 Indent
:= Indent
- 3;
403 procedure pg
(Arg
: Union_Id
) is
405 Dump_Generated_Only
:= True;
406 Dump_Original_Only
:= False;
407 Dump_Freeze_Null
:= True;
408 Current_Source_File
:= No_Source_File
;
410 if Arg
in List_Range
then
411 Sprint_Node_List
(List_Id
(Arg
));
413 elsif Arg
in Node_Range
then
414 Sprint_Node
(Node_Id
(Arg
));
427 procedure po
(Arg
: Union_Id
) is
429 Dump_Generated_Only
:= False;
430 Dump_Original_Only
:= True;
431 Current_Source_File
:= No_Source_File
;
433 if Arg
in List_Range
then
434 Sprint_Node_List
(List_Id
(Arg
));
436 elsif Arg
in Node_Range
then
437 Sprint_Node
(Node_Id
(Arg
));
446 ----------------------
447 -- Print_Debug_Line --
448 ----------------------
450 procedure Print_Debug_Line
(S
: String) is
452 Write_Debug_Line
(S
, Debug_Sloc
);
453 end Print_Debug_Line
;
455 ---------------------------
456 -- Process_TFAI_RR_Flags --
457 ---------------------------
459 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
461 if Treat_Fixed_As_Integer
(Nod
) then
465 if Rounded_Result
(Nod
) then
468 end Process_TFAI_RR_Flags
;
474 procedure ps
(Arg
: Union_Id
) is
476 Dump_Generated_Only
:= False;
477 Dump_Original_Only
:= False;
478 Current_Source_File
:= No_Source_File
;
480 if Arg
in List_Range
then
481 Sprint_Node_List
(List_Id
(Arg
));
483 elsif Arg
in Node_Range
then
484 Sprint_Node
(Node_Id
(Arg
));
497 procedure Set_Debug_Sloc
is
499 if Debug_Generated_Code
and then Present
(Dump_Node
) then
500 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
509 procedure Source_Dump
is
512 -- Put underline under string we just printed
518 procedure Underline
is
519 Col
: constant Int
:= Column
;
524 while Col
> Column
loop
531 -- Start of processing for Source_Dump
534 Dump_Generated_Only
:= Debug_Flag_G
or
535 Print_Generated_Code
or
536 Debug_Generated_Code
;
537 Dump_Original_Only
:= Debug_Flag_O
;
538 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
540 -- Note that we turn off the tree dump flags immediately, before
541 -- starting the dump. This avoids generating two copies of the dump
542 -- if an abort occurs after printing the dump, and more importantly,
543 -- avoids an infinite loop if an abort occurs during the dump.
546 Current_Source_File
:= No_Source_File
;
547 Debug_Flag_Z
:= False;
550 Write_Str
("Source recreated from tree of Standard (spec)");
552 Sprint_Node
(Standard_Package_Node
);
557 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
558 Debug_Flag_G
:= False;
559 Debug_Flag_O
:= False;
560 Debug_Flag_S
:= False;
562 -- Dump requested units
564 for U
in Main_Unit
.. Last_Unit
loop
565 Current_Source_File
:= Source_Index
(U
);
567 -- Dump all units if -gnatdf set, otherwise we dump only
568 -- the source files that are in the extended main source.
571 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
573 -- If we are generating debug files, setup to write them
575 if Debug_Generated_Code
then
576 Set_Special_Output
(Print_Debug_Line
'Access);
577 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
578 Write_Source_Line
(1);
579 Last_Line_Printed
:= 1;
580 Sprint_Node
(Cunit
(U
));
581 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
584 Set_Special_Output
(null);
586 -- Normal output to standard output file
589 Write_Str
("Source recreated from tree for ");
590 Write_Unit_Name
(Unit_Name
(U
));
592 Write_Source_Line
(1);
593 Last_Line_Printed
:= 1;
594 Sprint_Node
(Cunit
(U
));
595 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
604 ---------------------
605 -- Sprint_And_List --
606 ---------------------
608 procedure Sprint_And_List
(List
: List_Id
) is
611 if Is_Non_Empty_List
(List
) then
612 Node
:= First
(List
);
616 exit when Node
= Empty
;
622 ---------------------
623 -- Sprint_Bar_List --
624 ---------------------
626 procedure Sprint_Bar_List
(List
: List_Id
) is
629 if Is_Non_Empty_List
(List
) then
630 Node
:= First
(List
);
634 exit when Node
= Empty
;
640 ----------------------
641 -- Sprint_End_Label --
642 ----------------------
644 procedure Sprint_End_Label
650 and then Present
(End_Label
(Node
))
651 and then Is_Entity_Name
(End_Label
(Node
))
653 Set_Entity
(End_Label
(Node
), Default
);
655 -- For a function whose name is an operator, use the qualified name
656 -- created for the defining entity.
658 if Nkind
(End_Label
(Node
)) = N_Operator_Symbol
then
659 Set_Chars
(End_Label
(Node
), Chars
(Default
));
662 Sprint_Node
(End_Label
(Node
));
664 Sprint_Node
(Default
);
666 end Sprint_End_Label
;
668 -----------------------
669 -- Sprint_Comma_List --
670 -----------------------
672 procedure Sprint_Comma_List
(List
: List_Id
) is
676 if Is_Non_Empty_List
(List
) then
677 Node
:= First
(List
);
681 exit when Node
= Empty
;
683 if not Is_Rewrite_Insertion
(Node
)
684 or else not Dump_Original_Only
690 end Sprint_Comma_List
;
692 --------------------------
693 -- Sprint_Indented_List --
694 --------------------------
696 procedure Sprint_Indented_List
(List
: List_Id
) is
699 Sprint_Node_List
(List
);
701 end Sprint_Indented_List
;
703 ---------------------
704 -- Sprint_Left_Opnd --
705 ---------------------
707 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
708 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
711 if Paren_Count
(Opnd
) /= 0
712 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
721 end Sprint_Left_Opnd
;
727 procedure Sprint_Node
(Node
: Node_Id
) is
729 if Is_Rewrite_Insertion
(Node
) then
730 if not Dump_Original_Only
then
732 -- For special cases of nodes that always output <<< >>>
733 -- do not duplicate the output at this point.
735 if Nkind
(Node
) = N_Freeze_Entity
736 or else Nkind
(Node
) = N_Implicit_Label_Declaration
738 Sprint_Node_Actual
(Node
);
740 -- Normal case where <<< >>> may be required
743 Write_Rewrite_Str
("<<<");
744 Sprint_Node_Actual
(Node
);
745 Write_Rewrite_Str
(">>>");
749 elsif Is_Rewrite_Substitution
(Node
) then
751 -- Case of dump generated only
753 if Dump_Generated_Only
then
754 Sprint_Node_Actual
(Node
);
756 -- Case of dump original only
758 elsif Dump_Original_Only
then
759 Sprint_Node_Actual
(Original_Node
(Node
));
761 -- Case of both being dumped
764 Sprint_Node_Actual
(Original_Node
(Node
));
765 Write_Rewrite_Str
("<<<");
766 Sprint_Node_Actual
(Node
);
767 Write_Rewrite_Str
(">>>");
771 Sprint_Node_Actual
(Node
);
775 ------------------------
776 -- Sprint_Node_Actual --
777 ------------------------
779 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
780 Save_Dump_Node
: constant Node_Id
:= Dump_Node
;
787 for J
in 1 .. Paren_Count
(Node
) loop
788 Write_Str_With_Col_Check
("(");
791 -- Setup current dump node
795 if Nkind
(Node
) in N_Subexpr
796 and then Do_Range_Check
(Node
)
798 Write_Str_With_Col_Check
("{");
801 -- Select print circuit based on node kind
805 when N_Abort_Statement
=>
806 Write_Indent_Str_Sloc
("abort ");
807 Sprint_Comma_List
(Names
(Node
));
810 when N_Abortable_Part
=>
812 Write_Str_Sloc
("abort ");
813 Sprint_Indented_List
(Statements
(Node
));
815 when N_Abstract_Subprogram_Declaration
=>
817 Sprint_Node
(Specification
(Node
));
818 Write_Str_With_Col_Check
(" is ");
819 Write_Str_Sloc
("abstract;");
821 when N_Accept_Alternative
=>
822 Sprint_Node_List
(Pragmas_Before
(Node
));
824 if Present
(Condition
(Node
)) then
825 Write_Indent_Str
("when ");
826 Sprint_Node
(Condition
(Node
));
831 Sprint_Node_Sloc
(Accept_Statement
(Node
));
832 Sprint_Node_List
(Statements
(Node
));
834 when N_Accept_Statement
=>
835 Write_Indent_Str_Sloc
("accept ");
836 Write_Id
(Entry_Direct_Name
(Node
));
838 if Present
(Entry_Index
(Node
)) then
839 Write_Str_With_Col_Check
(" (");
840 Sprint_Node
(Entry_Index
(Node
));
844 Write_Param_Specs
(Node
);
846 if Present
(Handled_Statement_Sequence
(Node
)) then
847 Write_Str_With_Col_Check
(" do");
848 Sprint_Node
(Handled_Statement_Sequence
(Node
));
849 Write_Indent_Str
("end ");
850 Write_Id
(Entry_Direct_Name
(Node
));
855 when N_Access_Definition
=>
859 if Present
(Access_To_Subprogram_Definition
(Node
)) then
860 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
864 if Null_Exclusion_Present
(Node
) then
865 Write_Str
("not null ");
868 Write_Str_With_Col_Check_Sloc
("access ");
870 if All_Present
(Node
) then
872 elsif Constant_Present
(Node
) then
873 Write_Str
("constant ");
876 Sprint_Node
(Subtype_Mark
(Node
));
879 when N_Access_Function_Definition
=>
883 if Null_Exclusion_Present
(Node
) then
884 Write_Str
("not null ");
887 Write_Str_With_Col_Check_Sloc
("access ");
889 if Protected_Present
(Node
) then
890 Write_Str_With_Col_Check
("protected ");
893 Write_Str_With_Col_Check
("function");
894 Write_Param_Specs
(Node
);
895 Write_Str_With_Col_Check
(" return ");
896 Sprint_Node
(Result_Definition
(Node
));
898 when N_Access_Procedure_Definition
=>
902 if Null_Exclusion_Present
(Node
) then
903 Write_Str
("not null ");
906 Write_Str_With_Col_Check_Sloc
("access ");
908 if Protected_Present
(Node
) then
909 Write_Str_With_Col_Check
("protected ");
912 Write_Str_With_Col_Check
("procedure");
913 Write_Param_Specs
(Node
);
915 when N_Access_To_Object_Definition
=>
916 Write_Str_With_Col_Check_Sloc
("access ");
918 if All_Present
(Node
) then
919 Write_Str_With_Col_Check
("all ");
920 elsif Constant_Present
(Node
) then
921 Write_Str_With_Col_Check
("constant ");
926 if Null_Exclusion_Present
(Node
) then
927 Write_Str
("not null ");
930 Sprint_Node
(Subtype_Indication
(Node
));
933 if Null_Record_Present
(Node
) then
934 Write_Str_With_Col_Check_Sloc
("(null record)");
937 Write_Str_With_Col_Check_Sloc
("(");
939 if Present
(Expressions
(Node
)) then
940 Sprint_Comma_List
(Expressions
(Node
));
942 if Present
(Component_Associations
(Node
))
943 and then not Is_Empty_List
(Component_Associations
(Node
))
949 if Present
(Component_Associations
(Node
))
950 and then not Is_Empty_List
(Component_Associations
(Node
))
958 Nd
:= First
(Component_Associations
(Node
));
966 if not Is_Rewrite_Insertion
(Nd
)
967 or else not Dump_Original_Only
981 Write_Str_With_Col_Check_Sloc
("new ");
985 if Null_Exclusion_Present
(Node
) then
986 Write_Str
("not null ");
989 Sprint_Node
(Expression
(Node
));
991 if Present
(Storage_Pool
(Node
)) then
992 Write_Str_With_Col_Check
("[storage_pool = ");
993 Sprint_Node
(Storage_Pool
(Node
));
998 Sprint_Left_Opnd
(Node
);
999 Write_Str_Sloc
(" and then ");
1000 Sprint_Right_Opnd
(Node
);
1003 Write_Indent_Str_Sloc
("for ");
1004 Write_Id
(Identifier
(Node
));
1005 Write_Str_With_Col_Check
(" use at ");
1006 Sprint_Node
(Expression
(Node
));
1009 when N_Assignment_Statement
=>
1011 Sprint_Node
(Name
(Node
));
1012 Write_Str_Sloc
(" := ");
1013 Sprint_Node
(Expression
(Node
));
1016 when N_Asynchronous_Select
=>
1017 Write_Indent_Str_Sloc
("select");
1019 Sprint_Node
(Triggering_Alternative
(Node
));
1022 -- Note: let the printing of Abortable_Part handle outputting
1023 -- the ABORT keyword, so that the Sloc can be set correctly.
1025 Write_Indent_Str
("then ");
1026 Sprint_Node
(Abortable_Part
(Node
));
1027 Write_Indent_Str
("end select;");
1029 when N_Attribute_Definition_Clause
=>
1030 Write_Indent_Str_Sloc
("for ");
1031 Sprint_Node
(Name
(Node
));
1033 Write_Name_With_Col_Check
(Chars
(Node
));
1034 Write_Str_With_Col_Check
(" use ");
1035 Sprint_Node
(Expression
(Node
));
1038 when N_Attribute_Reference
=>
1039 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1043 Sprint_Node
(Prefix
(Node
));
1044 Write_Char_Sloc
(''');
1045 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
1046 Sprint_Paren_Comma_List
(Expressions
(Node
));
1048 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1052 when N_Block_Statement
=>
1055 if Present
(Identifier
(Node
))
1056 and then (not Has_Created_Identifier
(Node
)
1057 or else not Dump_Original_Only
)
1059 Write_Rewrite_Str
("<<<");
1060 Write_Id
(Identifier
(Node
));
1062 Write_Rewrite_Str
(">>>");
1065 if Present
(Declarations
(Node
)) then
1066 Write_Str_With_Col_Check_Sloc
("declare");
1067 Sprint_Indented_List
(Declarations
(Node
));
1071 Write_Str_With_Col_Check_Sloc
("begin");
1072 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1073 Write_Indent_Str
("end");
1075 if Present
(Identifier
(Node
))
1076 and then (not Has_Created_Identifier
(Node
)
1077 or else not Dump_Original_Only
)
1079 Write_Rewrite_Str
("<<<");
1081 Write_Id
(Identifier
(Node
));
1082 Write_Rewrite_Str
(">>>");
1087 when N_Case_Expression
=>
1092 Write_Str_With_Col_Check_Sloc
("(case ");
1093 Sprint_Node
(Expression
(Node
));
1094 Write_Str_With_Col_Check
(" is");
1096 Alt
:= First
(Alternatives
(Node
));
1107 when N_Case_Expression_Alternative
=>
1108 Write_Str_With_Col_Check
(" when ");
1109 Sprint_Bar_List
(Discrete_Choices
(Node
));
1111 Sprint_Node
(Expression
(Node
));
1113 when N_Case_Statement
=>
1114 Write_Indent_Str_Sloc
("case ");
1115 Sprint_Node
(Expression
(Node
));
1117 Sprint_Indented_List
(Alternatives
(Node
));
1118 Write_Indent_Str
("end case;");
1120 when N_Case_Statement_Alternative
=>
1121 Write_Indent_Str_Sloc
("when ");
1122 Sprint_Bar_List
(Discrete_Choices
(Node
));
1124 Sprint_Indented_List
(Statements
(Node
));
1126 when N_Character_Literal
=>
1127 if Column
> Sprint_Line_Limit
- 2 then
1128 Write_Indent_Str
(" ");
1131 Write_Char_Sloc
(''');
1132 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
1135 when N_Code_Statement
=>
1138 Sprint_Node
(Expression
(Node
));
1141 when N_Compilation_Unit
=>
1142 Sprint_Node_List
(Context_Items
(Node
));
1143 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
1145 if Private_Present
(Node
) then
1146 Write_Indent_Str
("private ");
1150 Sprint_Node_Sloc
(Unit
(Node
));
1152 if Present
(Actions
(Aux_Decls_Node
(Node
)))
1154 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
1159 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
1160 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
1162 when N_Compilation_Unit_Aux
=>
1163 null; -- nothing to do, never used, see above
1165 when N_Component_Association
=>
1167 Sprint_Bar_List
(Choices
(Node
));
1170 -- Ada 2005 (AI-287): Print the box if present
1172 if Box_Present
(Node
) then
1173 Write_Str_With_Col_Check
("<>");
1175 Sprint_Node
(Expression
(Node
));
1178 when N_Component_Clause
=>
1180 Sprint_Node
(Component_Name
(Node
));
1181 Write_Str_Sloc
(" at ");
1182 Sprint_Node
(Position
(Node
));
1184 Write_Str_With_Col_Check
("range ");
1185 Sprint_Node
(First_Bit
(Node
));
1187 Sprint_Node
(Last_Bit
(Node
));
1190 when N_Component_Definition
=>
1193 -- Ada 2005 (AI-230): Access definition components
1195 if Present
(Access_Definition
(Node
)) then
1196 Sprint_Node
(Access_Definition
(Node
));
1198 elsif Present
(Subtype_Indication
(Node
)) then
1199 if Aliased_Present
(Node
) then
1200 Write_Str_With_Col_Check
("aliased ");
1203 -- Ada 2005 (AI-231)
1205 if Null_Exclusion_Present
(Node
) then
1206 Write_Str
(" not null ");
1209 Sprint_Node
(Subtype_Indication
(Node
));
1212 Write_Str
(" ??? ");
1215 when N_Component_Declaration
=>
1216 if Write_Indent_Identifiers_Sloc
(Node
) then
1218 Sprint_Node
(Component_Definition
(Node
));
1220 if Present
(Expression
(Node
)) then
1222 Sprint_Node
(Expression
(Node
));
1228 when N_Component_List
=>
1229 if Null_Present
(Node
) then
1231 Write_Indent_Str_Sloc
("null");
1237 Sprint_Indented_List
(Component_Items
(Node
));
1238 Sprint_Node
(Variant_Part
(Node
));
1241 when N_Conditional_Entry_Call
=>
1242 Write_Indent_Str_Sloc
("select");
1244 Sprint_Node
(Entry_Call_Alternative
(Node
));
1246 Write_Indent_Str
("else");
1247 Sprint_Indented_List
(Else_Statements
(Node
));
1248 Write_Indent_Str
("end select;");
1250 when N_Conditional_Expression
=>
1252 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
1253 Then_Expr
: constant Node_Id
:= Next
(Condition
);
1256 Write_Str_With_Col_Check_Sloc
("(if ");
1257 Sprint_Node
(Condition
);
1258 Write_Str_With_Col_Check
(" then ");
1260 -- Defense against junk here!
1262 if Present
(Then_Expr
) then
1263 Sprint_Node
(Then_Expr
);
1264 Write_Str_With_Col_Check
(" else ");
1265 Sprint_Node
(Next
(Then_Expr
));
1271 when N_Constrained_Array_Definition
=>
1272 Write_Str_With_Col_Check_Sloc
("array ");
1273 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1276 Sprint_Node
(Component_Definition
(Node
));
1278 when N_Decimal_Fixed_Point_Definition
=>
1279 Write_Str_With_Col_Check_Sloc
(" delta ");
1280 Sprint_Node
(Delta_Expression
(Node
));
1281 Write_Str_With_Col_Check
("digits ");
1282 Sprint_Node
(Digits_Expression
(Node
));
1283 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1285 when N_Defining_Character_Literal
=>
1286 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1288 when N_Defining_Identifier
=>
1292 when N_Defining_Operator_Symbol
=>
1293 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1295 when N_Defining_Program_Unit_Name
=>
1297 Sprint_Node
(Name
(Node
));
1299 Write_Id
(Defining_Identifier
(Node
));
1301 when N_Delay_Alternative
=>
1302 Sprint_Node_List
(Pragmas_Before
(Node
));
1304 if Present
(Condition
(Node
)) then
1306 Write_Str_With_Col_Check
("when ");
1307 Sprint_Node
(Condition
(Node
));
1312 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1313 Sprint_Node_List
(Statements
(Node
));
1315 when N_Delay_Relative_Statement
=>
1316 Write_Indent_Str_Sloc
("delay ");
1317 Sprint_Node
(Expression
(Node
));
1320 when N_Delay_Until_Statement
=>
1321 Write_Indent_Str_Sloc
("delay until ");
1322 Sprint_Node
(Expression
(Node
));
1325 when N_Delta_Constraint
=>
1326 Write_Str_With_Col_Check_Sloc
("delta ");
1327 Sprint_Node
(Delta_Expression
(Node
));
1328 Sprint_Opt_Node
(Range_Constraint
(Node
));
1330 when N_Derived_Type_Definition
=>
1331 if Abstract_Present
(Node
) then
1332 Write_Str_With_Col_Check
("abstract ");
1335 Write_Str_With_Col_Check_Sloc
("new ");
1337 -- Ada 2005 (AI-231)
1339 if Null_Exclusion_Present
(Node
) then
1340 Write_Str_With_Col_Check
("not null ");
1343 Sprint_Node
(Subtype_Indication
(Node
));
1345 if Present
(Interface_List
(Node
)) then
1346 Write_Str_With_Col_Check
(" and ");
1347 Sprint_And_List
(Interface_List
(Node
));
1348 Write_Str_With_Col_Check
(" with ");
1351 if Present
(Record_Extension_Part
(Node
)) then
1352 if No
(Interface_List
(Node
)) then
1353 Write_Str_With_Col_Check
(" with ");
1356 Sprint_Node
(Record_Extension_Part
(Node
));
1359 when N_Designator
=>
1360 Sprint_Node
(Name
(Node
));
1361 Write_Char_Sloc
('.');
1362 Write_Id
(Identifier
(Node
));
1364 when N_Digits_Constraint
=>
1365 Write_Str_With_Col_Check_Sloc
("digits ");
1366 Sprint_Node
(Digits_Expression
(Node
));
1367 Sprint_Opt_Node
(Range_Constraint
(Node
));
1369 when N_Discriminant_Association
=>
1372 if Present
(Selector_Names
(Node
)) then
1373 Sprint_Bar_List
(Selector_Names
(Node
));
1378 Sprint_Node
(Expression
(Node
));
1380 when N_Discriminant_Specification
=>
1383 if Write_Identifiers
(Node
) then
1386 if Null_Exclusion_Present
(Node
) then
1387 Write_Str
("not null ");
1390 Sprint_Node
(Discriminant_Type
(Node
));
1392 if Present
(Expression
(Node
)) then
1394 Sprint_Node
(Expression
(Node
));
1400 when N_Elsif_Part
=>
1401 Write_Indent_Str_Sloc
("elsif ");
1402 Sprint_Node
(Condition
(Node
));
1403 Write_Str_With_Col_Check
(" then");
1404 Sprint_Indented_List
(Then_Statements
(Node
));
1409 when N_Entry_Body
=>
1410 Write_Indent_Str_Sloc
("entry ");
1411 Write_Id
(Defining_Identifier
(Node
));
1412 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1413 Write_Str_With_Col_Check
(" is");
1414 Sprint_Indented_List
(Declarations
(Node
));
1415 Write_Indent_Str
("begin");
1416 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1417 Write_Indent_Str
("end ");
1418 Write_Id
(Defining_Identifier
(Node
));
1421 when N_Entry_Body_Formal_Part
=>
1422 if Present
(Entry_Index_Specification
(Node
)) then
1423 Write_Str_With_Col_Check_Sloc
(" (");
1424 Sprint_Node
(Entry_Index_Specification
(Node
));
1428 Write_Param_Specs
(Node
);
1429 Write_Str_With_Col_Check_Sloc
(" when ");
1430 Sprint_Node
(Condition
(Node
));
1432 when N_Entry_Call_Alternative
=>
1433 Sprint_Node_List
(Pragmas_Before
(Node
));
1434 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1435 Sprint_Node_List
(Statements
(Node
));
1437 when N_Entry_Call_Statement
=>
1439 Sprint_Node_Sloc
(Name
(Node
));
1440 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1443 when N_Entry_Declaration
=>
1444 Write_Indent_Str_Sloc
("entry ");
1445 Write_Id
(Defining_Identifier
(Node
));
1447 if Present
(Discrete_Subtype_Definition
(Node
)) then
1448 Write_Str_With_Col_Check
(" (");
1449 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1453 Write_Param_Specs
(Node
);
1456 when N_Entry_Index_Specification
=>
1457 Write_Str_With_Col_Check_Sloc
("for ");
1458 Write_Id
(Defining_Identifier
(Node
));
1459 Write_Str_With_Col_Check
(" in ");
1460 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1462 when N_Enumeration_Representation_Clause
=>
1463 Write_Indent_Str_Sloc
("for ");
1464 Write_Id
(Identifier
(Node
));
1465 Write_Str_With_Col_Check
(" use ");
1466 Sprint_Node
(Array_Aggregate
(Node
));
1469 when N_Enumeration_Type_Definition
=>
1472 -- Skip attempt to print Literals field if it's not there and
1473 -- we are in package Standard (case of Character, which is
1474 -- handled specially (without an explicit literals list).
1476 if Sloc
(Node
) > Standard_Location
1477 or else Present
(Literals
(Node
))
1479 Sprint_Paren_Comma_List
(Literals
(Node
));
1483 Write_Str_With_Col_Check_Sloc
("<error>");
1485 when N_Exception_Declaration
=>
1486 if Write_Indent_Identifiers
(Node
) then
1487 Write_Str_With_Col_Check
(" : ");
1489 if Is_Statically_Allocated
(Defining_Identifier
(Node
)) then
1490 Write_Str_With_Col_Check
("static ");
1493 Write_Str_Sloc
("exception");
1495 if Present
(Expression
(Node
)) then
1497 Sprint_Node
(Expression
(Node
));
1503 when N_Exception_Handler
=>
1504 Write_Indent_Str_Sloc
("when ");
1506 if Present
(Choice_Parameter
(Node
)) then
1507 Sprint_Node
(Choice_Parameter
(Node
));
1511 Sprint_Bar_List
(Exception_Choices
(Node
));
1513 Sprint_Indented_List
(Statements
(Node
));
1515 when N_Exception_Renaming_Declaration
=>
1518 Sprint_Node
(Defining_Identifier
(Node
));
1519 Write_Str_With_Col_Check
(" : exception renames ");
1520 Sprint_Node
(Name
(Node
));
1523 when N_Exit_Statement
=>
1524 Write_Indent_Str_Sloc
("exit");
1525 Sprint_Opt_Node
(Name
(Node
));
1527 if Present
(Condition
(Node
)) then
1528 Write_Str_With_Col_Check
(" when ");
1529 Sprint_Node
(Condition
(Node
));
1534 when N_Expanded_Name
=>
1535 Sprint_Node
(Prefix
(Node
));
1536 Write_Char_Sloc
('.');
1537 Sprint_Node
(Selector_Name
(Node
));
1539 when N_Explicit_Dereference
=>
1540 Sprint_Node
(Prefix
(Node
));
1541 Write_Char_Sloc
('.');
1542 Write_Str_Sloc
("all");
1544 when N_Expression_With_Actions
=>
1546 Write_Indent_Str_Sloc
("do ");
1548 Sprint_Node_List
(Actions
(Node
));
1551 Write_Str_With_Col_Check_Sloc
("in ");
1552 Sprint_Node
(Expression
(Node
));
1553 Write_Str_With_Col_Check
(" end");
1557 when N_Extended_Return_Statement
=>
1558 Write_Indent_Str_Sloc
("return ");
1559 Sprint_Node_List
(Return_Object_Declarations
(Node
));
1561 if Present
(Handled_Statement_Sequence
(Node
)) then
1562 Write_Str_With_Col_Check
(" do");
1563 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1564 Write_Indent_Str
("end return;");
1566 Write_Indent_Str
(";");
1569 when N_Extension_Aggregate
=>
1570 Write_Str_With_Col_Check_Sloc
("(");
1571 Sprint_Node
(Ancestor_Part
(Node
));
1572 Write_Str_With_Col_Check
(" with ");
1574 if Null_Record_Present
(Node
) then
1575 Write_Str_With_Col_Check
("null record");
1577 if Present
(Expressions
(Node
)) then
1578 Sprint_Comma_List
(Expressions
(Node
));
1580 if Present
(Component_Associations
(Node
)) then
1585 if Present
(Component_Associations
(Node
)) then
1586 Sprint_Comma_List
(Component_Associations
(Node
));
1592 when N_Floating_Point_Definition
=>
1593 Write_Str_With_Col_Check_Sloc
("digits ");
1594 Sprint_Node
(Digits_Expression
(Node
));
1595 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1597 when N_Formal_Decimal_Fixed_Point_Definition
=>
1598 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1600 when N_Formal_Derived_Type_Definition
=>
1601 Write_Str_With_Col_Check_Sloc
("new ");
1602 Sprint_Node
(Subtype_Mark
(Node
));
1604 if Present
(Interface_List
(Node
)) then
1605 Write_Str_With_Col_Check
(" and ");
1606 Sprint_And_List
(Interface_List
(Node
));
1609 if Private_Present
(Node
) then
1610 Write_Str_With_Col_Check
(" with private");
1613 when N_Formal_Abstract_Subprogram_Declaration
=>
1614 Write_Indent_Str_Sloc
("with ");
1615 Sprint_Node
(Specification
(Node
));
1617 Write_Str_With_Col_Check
(" is abstract");
1619 if Box_Present
(Node
) then
1620 Write_Str_With_Col_Check
(" <>");
1621 elsif Present
(Default_Name
(Node
)) then
1622 Write_Str_With_Col_Check
(" ");
1623 Sprint_Node
(Default_Name
(Node
));
1628 when N_Formal_Concrete_Subprogram_Declaration
=>
1629 Write_Indent_Str_Sloc
("with ");
1630 Sprint_Node
(Specification
(Node
));
1632 if Box_Present
(Node
) then
1633 Write_Str_With_Col_Check
(" is <>");
1634 elsif Present
(Default_Name
(Node
)) then
1635 Write_Str_With_Col_Check
(" is ");
1636 Sprint_Node
(Default_Name
(Node
));
1641 when N_Formal_Discrete_Type_Definition
=>
1642 Write_Str_With_Col_Check_Sloc
("<>");
1644 when N_Formal_Floating_Point_Definition
=>
1645 Write_Str_With_Col_Check_Sloc
("digits <>");
1647 when N_Formal_Modular_Type_Definition
=>
1648 Write_Str_With_Col_Check_Sloc
("mod <>");
1650 when N_Formal_Object_Declaration
=>
1653 if Write_Indent_Identifiers
(Node
) then
1656 if In_Present
(Node
) then
1657 Write_Str_With_Col_Check
("in ");
1660 if Out_Present
(Node
) then
1661 Write_Str_With_Col_Check
("out ");
1664 if Present
(Subtype_Mark
(Node
)) then
1666 -- Ada 2005 (AI-423): Formal object with null exclusion
1668 if Null_Exclusion_Present
(Node
) then
1669 Write_Str
("not null ");
1672 Sprint_Node
(Subtype_Mark
(Node
));
1674 -- Ada 2005 (AI-423): Formal object with access definition
1677 pragma Assert
(Present
(Access_Definition
(Node
)));
1679 Sprint_Node
(Access_Definition
(Node
));
1682 if Present
(Default_Expression
(Node
)) then
1684 Sprint_Node
(Default_Expression
(Node
));
1690 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1691 Write_Str_With_Col_Check_Sloc
("delta <>");
1693 when N_Formal_Package_Declaration
=>
1694 Write_Indent_Str_Sloc
("with package ");
1695 Write_Id
(Defining_Identifier
(Node
));
1696 Write_Str_With_Col_Check
(" is new ");
1697 Sprint_Node
(Name
(Node
));
1698 Write_Str_With_Col_Check
(" (<>);");
1700 when N_Formal_Private_Type_Definition
=>
1701 if Abstract_Present
(Node
) then
1702 Write_Str_With_Col_Check
("abstract ");
1705 if Tagged_Present
(Node
) then
1706 Write_Str_With_Col_Check
("tagged ");
1709 if Limited_Present
(Node
) then
1710 Write_Str_With_Col_Check
("limited ");
1713 Write_Str_With_Col_Check_Sloc
("private");
1715 when N_Formal_Signed_Integer_Type_Definition
=>
1716 Write_Str_With_Col_Check_Sloc
("range <>");
1718 when N_Formal_Type_Declaration
=>
1719 Write_Indent_Str_Sloc
("type ");
1720 Write_Id
(Defining_Identifier
(Node
));
1722 if Present
(Discriminant_Specifications
(Node
)) then
1723 Write_Discr_Specs
(Node
);
1724 elsif Unknown_Discriminants_Present
(Node
) then
1725 Write_Str_With_Col_Check
("(<>)");
1728 Write_Str_With_Col_Check
(" is ");
1729 Sprint_Node
(Formal_Type_Definition
(Node
));
1732 when N_Free_Statement
=>
1733 Write_Indent_Str_Sloc
("free ");
1734 Sprint_Node
(Expression
(Node
));
1737 when N_Freeze_Entity
=>
1738 if Dump_Original_Only
then
1741 elsif Present
(Actions
(Node
)) or else Dump_Freeze_Null
then
1743 Write_Rewrite_Str
("<<<");
1744 Write_Str_With_Col_Check_Sloc
("freeze ");
1745 Write_Id
(Entity
(Node
));
1748 if No
(Actions
(Node
)) then
1752 -- Output freeze actions. We increment Freeze_Indent during
1753 -- this output to avoid generating extra blank lines before
1754 -- any procedures included in the freeze actions.
1756 Freeze_Indent
:= Freeze_Indent
+ 1;
1757 Sprint_Indented_List
(Actions
(Node
));
1758 Freeze_Indent
:= Freeze_Indent
- 1;
1759 Write_Indent_Str
("]");
1762 Write_Rewrite_Str
(">>>");
1765 when N_Full_Type_Declaration
=>
1766 Write_Indent_Str_Sloc
("type ");
1767 Sprint_Node
(Defining_Identifier
(Node
));
1768 Write_Discr_Specs
(Node
);
1769 Write_Str_With_Col_Check
(" is ");
1770 Sprint_Node
(Type_Definition
(Node
));
1773 when N_Function_Call
=>
1775 Write_Subprogram_Name
(Name
(Node
));
1776 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1778 when N_Function_Instantiation
=>
1779 Write_Indent_Str_Sloc
("function ");
1780 Sprint_Node
(Defining_Unit_Name
(Node
));
1781 Write_Str_With_Col_Check
(" is new ");
1782 Sprint_Node
(Name
(Node
));
1783 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1786 when N_Function_Specification
=>
1787 Write_Str_With_Col_Check_Sloc
("function ");
1788 Sprint_Node
(Defining_Unit_Name
(Node
));
1789 Write_Param_Specs
(Node
);
1790 Write_Str_With_Col_Check
(" return ");
1792 -- Ada 2005 (AI-231)
1794 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
1795 and then Null_Exclusion_Present
(Node
)
1797 Write_Str
(" not null ");
1800 Sprint_Node
(Result_Definition
(Node
));
1802 when N_Generic_Association
=>
1805 if Present
(Selector_Name
(Node
)) then
1806 Sprint_Node
(Selector_Name
(Node
));
1810 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
1812 when N_Generic_Function_Renaming_Declaration
=>
1813 Write_Indent_Str_Sloc
("generic function ");
1814 Sprint_Node
(Defining_Unit_Name
(Node
));
1815 Write_Str_With_Col_Check
(" renames ");
1816 Sprint_Node
(Name
(Node
));
1819 when N_Generic_Package_Declaration
=>
1821 Write_Indent_Str_Sloc
("generic ");
1822 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1824 Sprint_Node
(Specification
(Node
));
1827 when N_Generic_Package_Renaming_Declaration
=>
1828 Write_Indent_Str_Sloc
("generic package ");
1829 Sprint_Node
(Defining_Unit_Name
(Node
));
1830 Write_Str_With_Col_Check
(" renames ");
1831 Sprint_Node
(Name
(Node
));
1834 when N_Generic_Procedure_Renaming_Declaration
=>
1835 Write_Indent_Str_Sloc
("generic procedure ");
1836 Sprint_Node
(Defining_Unit_Name
(Node
));
1837 Write_Str_With_Col_Check
(" renames ");
1838 Sprint_Node
(Name
(Node
));
1841 when N_Generic_Subprogram_Declaration
=>
1843 Write_Indent_Str_Sloc
("generic ");
1844 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1846 Sprint_Node
(Specification
(Node
));
1849 when N_Goto_Statement
=>
1850 Write_Indent_Str_Sloc
("goto ");
1851 Sprint_Node
(Name
(Node
));
1854 if Nkind
(Next
(Node
)) = N_Label
then
1858 when N_Handled_Sequence_Of_Statements
=>
1860 Sprint_Indented_List
(Statements
(Node
));
1862 if Present
(Exception_Handlers
(Node
)) then
1863 Write_Indent_Str
("exception");
1865 Sprint_Node_List
(Exception_Handlers
(Node
));
1869 if Present
(At_End_Proc
(Node
)) then
1870 Write_Indent_Str
("at end");
1873 Sprint_Node
(At_End_Proc
(Node
));
1878 when N_Identifier
=>
1882 when N_If_Statement
=>
1883 Write_Indent_Str_Sloc
("if ");
1884 Sprint_Node
(Condition
(Node
));
1885 Write_Str_With_Col_Check
(" then");
1886 Sprint_Indented_List
(Then_Statements
(Node
));
1887 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
1889 if Present
(Else_Statements
(Node
)) then
1890 Write_Indent_Str
("else");
1891 Sprint_Indented_List
(Else_Statements
(Node
));
1894 Write_Indent_Str
("end if;");
1896 when N_Implicit_Label_Declaration
=>
1897 if not Dump_Original_Only
then
1899 Write_Rewrite_Str
("<<<");
1901 Write_Id
(Defining_Identifier
(Node
));
1903 Write_Str_With_Col_Check
("label");
1904 Write_Rewrite_Str
(">>>");
1908 Sprint_Left_Opnd
(Node
);
1909 Write_Str_Sloc
(" in ");
1911 if Present
(Right_Opnd
(Node
)) then
1912 Sprint_Right_Opnd
(Node
);
1914 Sprint_Bar_List
(Alternatives
(Node
));
1917 when N_Incomplete_Type_Declaration
=>
1918 Write_Indent_Str_Sloc
("type ");
1919 Write_Id
(Defining_Identifier
(Node
));
1921 if Present
(Discriminant_Specifications
(Node
)) then
1922 Write_Discr_Specs
(Node
);
1923 elsif Unknown_Discriminants_Present
(Node
) then
1924 Write_Str_With_Col_Check
("(<>)");
1929 when N_Index_Or_Discriminant_Constraint
=>
1931 Sprint_Paren_Comma_List
(Constraints
(Node
));
1933 when N_Indexed_Component
=>
1934 Sprint_Node_Sloc
(Prefix
(Node
));
1935 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
1937 when N_Integer_Literal
=>
1938 if Print_In_Hex
(Node
) then
1939 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
1941 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
1944 when N_Iteration_Scheme
=>
1945 if Present
(Condition
(Node
)) then
1946 Write_Str_With_Col_Check_Sloc
("while ");
1947 Sprint_Node
(Condition
(Node
));
1949 Write_Str_With_Col_Check_Sloc
("for ");
1950 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1955 when N_Itype_Reference
=>
1956 Write_Indent_Str_Sloc
("reference ");
1957 Write_Id
(Itype
(Node
));
1960 Write_Indent_Str_Sloc
("<<");
1961 Write_Id
(Identifier
(Node
));
1964 when N_Loop_Parameter_Specification
=>
1966 Write_Id
(Defining_Identifier
(Node
));
1967 Write_Str_With_Col_Check
(" in ");
1969 if Reverse_Present
(Node
) then
1970 Write_Str_With_Col_Check
("reverse ");
1973 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1975 when N_Loop_Statement
=>
1978 if Present
(Identifier
(Node
))
1979 and then (not Has_Created_Identifier
(Node
)
1980 or else not Dump_Original_Only
)
1982 Write_Rewrite_Str
("<<<");
1983 Write_Id
(Identifier
(Node
));
1985 Write_Rewrite_Str
(">>>");
1986 Sprint_Node
(Iteration_Scheme
(Node
));
1987 Write_Str_With_Col_Check_Sloc
("loop");
1988 Sprint_Indented_List
(Statements
(Node
));
1989 Write_Indent_Str
("end loop ");
1990 Write_Rewrite_Str
("<<<");
1991 Write_Id
(Identifier
(Node
));
1992 Write_Rewrite_Str
(">>>");
1996 Sprint_Node
(Iteration_Scheme
(Node
));
1997 Write_Str_With_Col_Check_Sloc
("loop");
1998 Sprint_Indented_List
(Statements
(Node
));
1999 Write_Indent_Str
("end loop;");
2002 when N_Mod_Clause
=>
2003 Sprint_Node_List
(Pragmas_Before
(Node
));
2004 Write_Str_With_Col_Check_Sloc
("at mod ");
2005 Sprint_Node
(Expression
(Node
));
2007 when N_Modular_Type_Definition
=>
2008 Write_Str_With_Col_Check_Sloc
("mod ");
2009 Sprint_Node
(Expression
(Node
));
2012 Sprint_Left_Opnd
(Node
);
2013 Write_Str_Sloc
(" not in ");
2015 if Present
(Right_Opnd
(Node
)) then
2016 Sprint_Right_Opnd
(Node
);
2018 Sprint_Bar_List
(Alternatives
(Node
));
2022 Write_Str_With_Col_Check_Sloc
("null");
2024 when N_Null_Statement
=>
2025 if Comes_From_Source
(Node
)
2026 or else Dump_Freeze_Null
2027 or else not Is_List_Member
(Node
)
2028 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
2030 Write_Indent_Str_Sloc
("null;");
2033 when N_Number_Declaration
=>
2036 if Write_Indent_Identifiers
(Node
) then
2037 Write_Str_With_Col_Check
(" : constant ");
2039 Sprint_Node
(Expression
(Node
));
2043 when N_Object_Declaration
=>
2046 if Write_Indent_Identifiers
(Node
) then
2048 Def_Id
: constant Entity_Id
:= Defining_Identifier
(Node
);
2051 Write_Str_With_Col_Check
(" : ");
2053 if Is_Statically_Allocated
(Def_Id
) then
2054 Write_Str_With_Col_Check
("static ");
2057 if Aliased_Present
(Node
) then
2058 Write_Str_With_Col_Check
("aliased ");
2061 if Constant_Present
(Node
) then
2062 Write_Str_With_Col_Check
("constant ");
2065 -- Ada 2005 (AI-231)
2067 if Null_Exclusion_Present
(Node
) then
2068 Write_Str_With_Col_Check
("not null ");
2071 Sprint_Node
(Object_Definition
(Node
));
2073 if Present
(Expression
(Node
)) then
2075 Sprint_Node
(Expression
(Node
));
2080 -- Handle implicit importation and implicit exportation of
2081 -- object declarations:
2082 -- $pragma import (Convention_Id, Def_Id, "...");
2083 -- $pragma export (Convention_Id, Def_Id, "...");
2085 if Is_Internal
(Def_Id
)
2086 and then Present
(Interface_Name
(Def_Id
))
2088 Write_Indent_Str_Sloc
("$pragma ");
2090 if Is_Imported
(Def_Id
) then
2091 Write_Str
("import (");
2093 else pragma Assert
(Is_Exported
(Def_Id
));
2094 Write_Str
("export (");
2098 Prefix
: constant String := "Convention_";
2099 S
: constant String := Convention
(Def_Id
)'Img;
2102 Name_Len
:= S
'Last - Prefix
'Last;
2103 Name_Buffer
(1 .. Name_Len
) :=
2104 S
(Prefix
'Last + 1 .. S
'Last);
2105 Set_Casing
(All_Lower_Case
);
2106 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2112 Write_String_Table_Entry
2113 (Strval
(Interface_Name
(Def_Id
)));
2119 when N_Object_Renaming_Declaration
=>
2122 Sprint_Node
(Defining_Identifier
(Node
));
2125 -- Ada 2005 (AI-230): Access renamings
2127 if Present
(Access_Definition
(Node
)) then
2128 Sprint_Node
(Access_Definition
(Node
));
2130 elsif Present
(Subtype_Mark
(Node
)) then
2132 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2134 if Null_Exclusion_Present
(Node
) then
2135 Write_Str
("not null ");
2138 Sprint_Node
(Subtype_Mark
(Node
));
2141 Write_Str
(" ??? ");
2144 Write_Str_With_Col_Check
(" renames ");
2145 Sprint_Node
(Name
(Node
));
2149 Write_Operator
(Node
, "abs ");
2150 Sprint_Right_Opnd
(Node
);
2153 Sprint_Left_Opnd
(Node
);
2154 Write_Operator
(Node
, " + ");
2155 Sprint_Right_Opnd
(Node
);
2158 Sprint_Left_Opnd
(Node
);
2159 Write_Operator
(Node
, " and ");
2160 Sprint_Right_Opnd
(Node
);
2163 Sprint_Left_Opnd
(Node
);
2164 Write_Operator
(Node
, " & ");
2165 Sprint_Right_Opnd
(Node
);
2168 Sprint_Left_Opnd
(Node
);
2170 Process_TFAI_RR_Flags
(Node
);
2171 Write_Operator
(Node
, "/ ");
2172 Sprint_Right_Opnd
(Node
);
2175 Sprint_Left_Opnd
(Node
);
2176 Write_Operator
(Node
, " = ");
2177 Sprint_Right_Opnd
(Node
);
2180 Sprint_Left_Opnd
(Node
);
2181 Write_Operator
(Node
, " ** ");
2182 Sprint_Right_Opnd
(Node
);
2185 Sprint_Left_Opnd
(Node
);
2186 Write_Operator
(Node
, " >= ");
2187 Sprint_Right_Opnd
(Node
);
2190 Sprint_Left_Opnd
(Node
);
2191 Write_Operator
(Node
, " > ");
2192 Sprint_Right_Opnd
(Node
);
2195 Sprint_Left_Opnd
(Node
);
2196 Write_Operator
(Node
, " <= ");
2197 Sprint_Right_Opnd
(Node
);
2200 Sprint_Left_Opnd
(Node
);
2201 Write_Operator
(Node
, " < ");
2202 Sprint_Right_Opnd
(Node
);
2205 Write_Operator
(Node
, "-");
2206 Sprint_Right_Opnd
(Node
);
2209 Sprint_Left_Opnd
(Node
);
2211 if Treat_Fixed_As_Integer
(Node
) then
2215 Write_Operator
(Node
, " mod ");
2216 Sprint_Right_Opnd
(Node
);
2218 when N_Op_Multiply
=>
2219 Sprint_Left_Opnd
(Node
);
2221 Process_TFAI_RR_Flags
(Node
);
2222 Write_Operator
(Node
, "* ");
2223 Sprint_Right_Opnd
(Node
);
2226 Sprint_Left_Opnd
(Node
);
2227 Write_Operator
(Node
, " /= ");
2228 Sprint_Right_Opnd
(Node
);
2231 Write_Operator
(Node
, "not ");
2232 Sprint_Right_Opnd
(Node
);
2235 Sprint_Left_Opnd
(Node
);
2236 Write_Operator
(Node
, " or ");
2237 Sprint_Right_Opnd
(Node
);
2240 Write_Operator
(Node
, "+");
2241 Sprint_Right_Opnd
(Node
);
2244 Sprint_Left_Opnd
(Node
);
2246 if Treat_Fixed_As_Integer
(Node
) then
2250 Write_Operator
(Node
, " rem ");
2251 Sprint_Right_Opnd
(Node
);
2257 Write_Str_With_Col_Check
("(");
2258 Sprint_Node
(Left_Opnd
(Node
));
2260 Sprint_Node
(Right_Opnd
(Node
));
2263 when N_Op_Subtract
=>
2264 Sprint_Left_Opnd
(Node
);
2265 Write_Operator
(Node
, " - ");
2266 Sprint_Right_Opnd
(Node
);
2269 Sprint_Left_Opnd
(Node
);
2270 Write_Operator
(Node
, " xor ");
2271 Sprint_Right_Opnd
(Node
);
2273 when N_Operator_Symbol
=>
2274 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
2276 when N_Ordinary_Fixed_Point_Definition
=>
2277 Write_Str_With_Col_Check_Sloc
("delta ");
2278 Sprint_Node
(Delta_Expression
(Node
));
2279 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
2282 Sprint_Left_Opnd
(Node
);
2283 Write_Str_Sloc
(" or else ");
2284 Sprint_Right_Opnd
(Node
);
2286 when N_Others_Choice
=>
2287 if All_Others
(Node
) then
2288 Write_Str_With_Col_Check
("all ");
2291 Write_Str_With_Col_Check_Sloc
("others");
2293 when N_Package_Body
=>
2295 Write_Indent_Str_Sloc
("package body ");
2296 Sprint_Node
(Defining_Unit_Name
(Node
));
2298 Sprint_Indented_List
(Declarations
(Node
));
2300 if Present
(Handled_Statement_Sequence
(Node
)) then
2301 Write_Indent_Str
("begin");
2302 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2305 Write_Indent_Str
("end ");
2307 (Handled_Statement_Sequence
(Node
), Defining_Unit_Name
(Node
));
2310 when N_Package_Body_Stub
=>
2311 Write_Indent_Str_Sloc
("package body ");
2312 Sprint_Node
(Defining_Identifier
(Node
));
2313 Write_Str_With_Col_Check
(" is separate;");
2315 when N_Package_Declaration
=>
2318 Sprint_Node_Sloc
(Specification
(Node
));
2321 when N_Package_Instantiation
=>
2323 Write_Indent_Str_Sloc
("package ");
2324 Sprint_Node
(Defining_Unit_Name
(Node
));
2325 Write_Str
(" is new ");
2326 Sprint_Node
(Name
(Node
));
2327 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2330 when N_Package_Renaming_Declaration
=>
2331 Write_Indent_Str_Sloc
("package ");
2332 Sprint_Node
(Defining_Unit_Name
(Node
));
2333 Write_Str_With_Col_Check
(" renames ");
2334 Sprint_Node
(Name
(Node
));
2337 when N_Package_Specification
=>
2338 Write_Str_With_Col_Check_Sloc
("package ");
2339 Sprint_Node
(Defining_Unit_Name
(Node
));
2341 Sprint_Indented_List
(Visible_Declarations
(Node
));
2343 if Present
(Private_Declarations
(Node
)) then
2344 Write_Indent_Str
("private");
2345 Sprint_Indented_List
(Private_Declarations
(Node
));
2348 Write_Indent_Str
("end ");
2349 Sprint_Node
(Defining_Unit_Name
(Node
));
2351 when N_Parameter_Association
=>
2352 Sprint_Node_Sloc
(Selector_Name
(Node
));
2354 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2356 when N_Parameter_Specification
=>
2359 if Write_Identifiers
(Node
) then
2362 if In_Present
(Node
) then
2363 Write_Str_With_Col_Check
("in ");
2366 if Out_Present
(Node
) then
2367 Write_Str_With_Col_Check
("out ");
2370 -- Ada 2005 (AI-231): Parameter specification may carry null
2371 -- exclusion. Do not print it now if this is an access formal,
2372 -- it is emitted when the access definition is displayed.
2374 if Null_Exclusion_Present
(Node
)
2375 and then Nkind
(Parameter_Type
(Node
))
2376 /= N_Access_Definition
2378 Write_Str
("not null ");
2381 Sprint_Node
(Parameter_Type
(Node
));
2383 if Present
(Expression
(Node
)) then
2385 Sprint_Node
(Expression
(Node
));
2391 when N_Pop_Constraint_Error_Label
=>
2392 Write_Indent_Str
("%pop_constraint_error_label");
2394 when N_Pop_Program_Error_Label
=>
2395 Write_Indent_Str
("%pop_program_error_label");
2397 when N_Pop_Storage_Error_Label
=>
2398 Write_Indent_Str
("%pop_storage_error_label");
2400 when N_Push_Constraint_Error_Label
=>
2401 Write_Indent_Str
("%push_constraint_error_label (");
2403 if Present
(Exception_Label
(Node
)) then
2404 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2409 when N_Push_Program_Error_Label
=>
2410 Write_Indent_Str
("%push_program_error_label (");
2412 if Present
(Exception_Label
(Node
)) then
2413 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2418 when N_Push_Storage_Error_Label
=>
2419 Write_Indent_Str
("%push_storage_error_label (");
2421 if Present
(Exception_Label
(Node
)) then
2422 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2428 Write_Indent_Str_Sloc
("pragma ");
2429 Write_Name_With_Col_Check
(Pragma_Name
(Node
));
2431 if Present
(Pragma_Argument_Associations
(Node
)) then
2432 Sprint_Opt_Paren_Comma_List
2433 (Pragma_Argument_Associations
(Node
));
2438 when N_Pragma_Argument_Association
=>
2441 if Chars
(Node
) /= No_Name
then
2442 Write_Name_With_Col_Check
(Chars
(Node
));
2446 Sprint_Node
(Expression
(Node
));
2448 when N_Private_Type_Declaration
=>
2449 Write_Indent_Str_Sloc
("type ");
2450 Write_Id
(Defining_Identifier
(Node
));
2452 if Present
(Discriminant_Specifications
(Node
)) then
2453 Write_Discr_Specs
(Node
);
2454 elsif Unknown_Discriminants_Present
(Node
) then
2455 Write_Str_With_Col_Check
("(<>)");
2460 if Tagged_Present
(Node
) then
2461 Write_Str_With_Col_Check
("tagged ");
2464 if Limited_Present
(Node
) then
2465 Write_Str_With_Col_Check
("limited ");
2468 Write_Str_With_Col_Check
("private;");
2470 when N_Private_Extension_Declaration
=>
2471 Write_Indent_Str_Sloc
("type ");
2472 Write_Id
(Defining_Identifier
(Node
));
2474 if Present
(Discriminant_Specifications
(Node
)) then
2475 Write_Discr_Specs
(Node
);
2476 elsif Unknown_Discriminants_Present
(Node
) then
2477 Write_Str_With_Col_Check
("(<>)");
2480 Write_Str_With_Col_Check
(" is new ");
2481 Sprint_Node
(Subtype_Indication
(Node
));
2483 if Present
(Interface_List
(Node
)) then
2484 Write_Str_With_Col_Check
(" and ");
2485 Sprint_And_List
(Interface_List
(Node
));
2488 Write_Str_With_Col_Check
(" with private;");
2490 when N_Procedure_Call_Statement
=>
2493 Write_Subprogram_Name
(Name
(Node
));
2494 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2497 when N_Procedure_Instantiation
=>
2498 Write_Indent_Str_Sloc
("procedure ");
2499 Sprint_Node
(Defining_Unit_Name
(Node
));
2500 Write_Str_With_Col_Check
(" is new ");
2501 Sprint_Node
(Name
(Node
));
2502 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2505 when N_Procedure_Specification
=>
2506 Write_Str_With_Col_Check_Sloc
("procedure ");
2507 Sprint_Node
(Defining_Unit_Name
(Node
));
2508 Write_Param_Specs
(Node
);
2510 when N_Protected_Body
=>
2511 Write_Indent_Str_Sloc
("protected body ");
2512 Write_Id
(Defining_Identifier
(Node
));
2514 Sprint_Indented_List
(Declarations
(Node
));
2515 Write_Indent_Str
("end ");
2516 Write_Id
(Defining_Identifier
(Node
));
2519 when N_Protected_Body_Stub
=>
2520 Write_Indent_Str_Sloc
("protected body ");
2521 Write_Id
(Defining_Identifier
(Node
));
2522 Write_Str_With_Col_Check
(" is separate;");
2524 when N_Protected_Definition
=>
2526 Sprint_Indented_List
(Visible_Declarations
(Node
));
2528 if Present
(Private_Declarations
(Node
)) then
2529 Write_Indent_Str
("private");
2530 Sprint_Indented_List
(Private_Declarations
(Node
));
2533 Write_Indent_Str
("end ");
2535 when N_Protected_Type_Declaration
=>
2536 Write_Indent_Str_Sloc
("protected type ");
2537 Sprint_Node
(Defining_Identifier
(Node
));
2538 Write_Discr_Specs
(Node
);
2540 if Present
(Interface_List
(Node
)) then
2541 Write_Str
(" is new ");
2542 Sprint_And_List
(Interface_List
(Node
));
2543 Write_Str
(" with ");
2548 Sprint_Node
(Protected_Definition
(Node
));
2549 Write_Id
(Defining_Identifier
(Node
));
2552 when N_Qualified_Expression
=>
2553 Sprint_Node
(Subtype_Mark
(Node
));
2554 Write_Char_Sloc
(''');
2556 -- Print expression, make sure we have at least one level of
2557 -- parentheses around the expression. For cases of qualified
2558 -- expressions in the source, this is always the case, but
2559 -- for generated qualifications, there may be no explicit
2560 -- parentheses present.
2562 if Paren_Count
(Expression
(Node
)) /= 0 then
2563 Sprint_Node
(Expression
(Node
));
2566 Sprint_Node
(Expression
(Node
));
2570 when N_Raise_Constraint_Error
=>
2572 -- This node can be used either as a subexpression or as a
2573 -- statement form. The following test is a reasonably reliable
2574 -- way to distinguish the two cases.
2576 if Is_List_Member
(Node
)
2577 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2582 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2583 Write_Condition_And_Reason
(Node
);
2585 when N_Raise_Program_Error
=>
2587 -- This node can be used either as a subexpression or as a
2588 -- statement form. The following test is a reasonably reliable
2589 -- way to distinguish the two cases.
2591 if Is_List_Member
(Node
)
2592 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2597 Write_Str_With_Col_Check_Sloc
("[program_error");
2598 Write_Condition_And_Reason
(Node
);
2600 when N_Raise_Storage_Error
=>
2602 -- This node can be used either as a subexpression or as a
2603 -- statement form. The following test is a reasonably reliable
2604 -- way to distinguish the two cases.
2606 if Is_List_Member
(Node
)
2607 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2612 Write_Str_With_Col_Check_Sloc
("[storage_error");
2613 Write_Condition_And_Reason
(Node
);
2615 when N_Raise_Statement
=>
2616 Write_Indent_Str_Sloc
("raise ");
2617 Sprint_Node
(Name
(Node
));
2621 Sprint_Node
(Low_Bound
(Node
));
2622 Write_Str_Sloc
(" .. ");
2623 Sprint_Node
(High_Bound
(Node
));
2624 Update_Itype
(Node
);
2626 when N_Range_Constraint
=>
2627 Write_Str_With_Col_Check_Sloc
("range ");
2628 Sprint_Node
(Range_Expression
(Node
));
2630 when N_Real_Literal
=>
2631 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
2633 when N_Real_Range_Specification
=>
2634 Write_Str_With_Col_Check_Sloc
("range ");
2635 Sprint_Node
(Low_Bound
(Node
));
2637 Sprint_Node
(High_Bound
(Node
));
2639 when N_Record_Definition
=>
2640 if Abstract_Present
(Node
) then
2641 Write_Str_With_Col_Check
("abstract ");
2644 if Tagged_Present
(Node
) then
2645 Write_Str_With_Col_Check
("tagged ");
2648 if Limited_Present
(Node
) then
2649 Write_Str_With_Col_Check
("limited ");
2652 if Null_Present
(Node
) then
2653 Write_Str_With_Col_Check_Sloc
("null record");
2656 Write_Str_With_Col_Check_Sloc
("record");
2657 Sprint_Node
(Component_List
(Node
));
2658 Write_Indent_Str
("end record");
2661 when N_Record_Representation_Clause
=>
2662 Write_Indent_Str_Sloc
("for ");
2663 Sprint_Node
(Identifier
(Node
));
2664 Write_Str_With_Col_Check
(" use record ");
2666 if Present
(Mod_Clause
(Node
)) then
2667 Sprint_Node
(Mod_Clause
(Node
));
2670 Sprint_Indented_List
(Component_Clauses
(Node
));
2671 Write_Indent_Str
("end record;");
2674 Sprint_Node
(Prefix
(Node
));
2675 Write_Str_With_Col_Check_Sloc
("'reference");
2677 when N_Requeue_Statement
=>
2678 Write_Indent_Str_Sloc
("requeue ");
2679 Sprint_Node
(Name
(Node
));
2681 if Abort_Present
(Node
) then
2682 Write_Str_With_Col_Check
(" with abort");
2687 -- Don't we want to print more detail???
2689 -- Doc of this extended syntax belongs in sinfo.ads and/or
2692 when N_SCIL_Dispatch_Table_Tag_Init
=>
2693 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Tag_Init]");
2695 when N_SCIL_Dispatching_Call
=>
2696 Write_Indent_Str
("[N_SCIL_Dispatching_Node]");
2698 when N_SCIL_Membership_Test
=>
2699 Write_Indent_Str
("[N_SCIL_Membership_Test]");
2701 when N_Simple_Return_Statement
=>
2702 if Present
(Expression
(Node
)) then
2703 Write_Indent_Str_Sloc
("return ");
2704 Sprint_Node
(Expression
(Node
));
2707 Write_Indent_Str_Sloc
("return;");
2710 when N_Selective_Accept
=>
2711 Write_Indent_Str_Sloc
("select");
2716 Alt_Node
:= First
(Select_Alternatives
(Node
));
2719 Sprint_Node
(Alt_Node
);
2722 exit when No
(Alt_Node
);
2723 Write_Indent_Str
("or");
2727 if Present
(Else_Statements
(Node
)) then
2728 Write_Indent_Str
("else");
2729 Sprint_Indented_List
(Else_Statements
(Node
));
2732 Write_Indent_Str
("end select;");
2734 when N_Signed_Integer_Type_Definition
=>
2735 Write_Str_With_Col_Check_Sloc
("range ");
2736 Sprint_Node
(Low_Bound
(Node
));
2738 Sprint_Node
(High_Bound
(Node
));
2740 when N_Single_Protected_Declaration
=>
2741 Write_Indent_Str_Sloc
("protected ");
2742 Write_Id
(Defining_Identifier
(Node
));
2744 Sprint_Node
(Protected_Definition
(Node
));
2745 Write_Id
(Defining_Identifier
(Node
));
2748 when N_Single_Task_Declaration
=>
2749 Write_Indent_Str_Sloc
("task ");
2750 Sprint_Node
(Defining_Identifier
(Node
));
2752 if Present
(Task_Definition
(Node
)) then
2754 Sprint_Node
(Task_Definition
(Node
));
2759 when N_Selected_Component
=>
2760 Sprint_Node
(Prefix
(Node
));
2761 Write_Char_Sloc
('.');
2762 Sprint_Node
(Selector_Name
(Node
));
2766 Sprint_Node
(Prefix
(Node
));
2767 Write_Str_With_Col_Check
(" (");
2768 Sprint_Node
(Discrete_Range
(Node
));
2771 when N_String_Literal
=>
2772 if String_Length
(Strval
(Node
)) + Column
> Sprint_Line_Limit
then
2773 Write_Indent_Str
(" ");
2777 Write_String_Table_Entry
(Strval
(Node
));
2779 when N_Subprogram_Body
=>
2781 -- Output extra blank line unless we are in freeze actions
2783 if Freeze_Indent
= 0 then
2788 Sprint_Node_Sloc
(Specification
(Node
));
2791 Sprint_Indented_List
(Declarations
(Node
));
2792 Write_Indent_Str
("begin");
2793 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2795 Write_Indent_Str
("end ");
2798 (Handled_Statement_Sequence
(Node
),
2799 Defining_Unit_Name
(Specification
(Node
)));
2802 if Is_List_Member
(Node
)
2803 and then Present
(Next
(Node
))
2804 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
2809 when N_Subprogram_Body_Stub
=>
2811 Sprint_Node_Sloc
(Specification
(Node
));
2812 Write_Str_With_Col_Check
(" is separate;");
2814 when N_Subprogram_Declaration
=>
2816 Sprint_Node_Sloc
(Specification
(Node
));
2818 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
2819 and then Null_Present
(Specification
(Node
))
2821 Write_Str_With_Col_Check
(" is null");
2826 when N_Subprogram_Info
=>
2827 Sprint_Node
(Identifier
(Node
));
2828 Write_Str_With_Col_Check_Sloc
("'subprogram_info");
2830 when N_Subprogram_Renaming_Declaration
=>
2832 Sprint_Node
(Specification
(Node
));
2833 Write_Str_With_Col_Check_Sloc
(" renames ");
2834 Sprint_Node
(Name
(Node
));
2837 when N_Subtype_Declaration
=>
2838 Write_Indent_Str_Sloc
("subtype ");
2839 Sprint_Node
(Defining_Identifier
(Node
));
2842 -- Ada 2005 (AI-231)
2844 if Null_Exclusion_Present
(Node
) then
2845 Write_Str
("not null ");
2848 Sprint_Node
(Subtype_Indication
(Node
));
2851 when N_Subtype_Indication
=>
2852 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
2854 Sprint_Node
(Constraint
(Node
));
2857 Write_Indent_Str_Sloc
("separate (");
2858 Sprint_Node
(Name
(Node
));
2861 Sprint_Node
(Proper_Body
(Node
));
2864 Write_Indent_Str_Sloc
("task body ");
2865 Write_Id
(Defining_Identifier
(Node
));
2867 Sprint_Indented_List
(Declarations
(Node
));
2868 Write_Indent_Str
("begin");
2869 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2870 Write_Indent_Str
("end ");
2872 (Handled_Statement_Sequence
(Node
), Defining_Identifier
(Node
));
2875 when N_Task_Body_Stub
=>
2876 Write_Indent_Str_Sloc
("task body ");
2877 Write_Id
(Defining_Identifier
(Node
));
2878 Write_Str_With_Col_Check
(" is separate;");
2880 when N_Task_Definition
=>
2882 Sprint_Indented_List
(Visible_Declarations
(Node
));
2884 if Present
(Private_Declarations
(Node
)) then
2885 Write_Indent_Str
("private");
2886 Sprint_Indented_List
(Private_Declarations
(Node
));
2889 Write_Indent_Str
("end ");
2890 Sprint_End_Label
(Node
, Defining_Identifier
(Parent
(Node
)));
2892 when N_Task_Type_Declaration
=>
2893 Write_Indent_Str_Sloc
("task type ");
2894 Sprint_Node
(Defining_Identifier
(Node
));
2895 Write_Discr_Specs
(Node
);
2897 if Present
(Interface_List
(Node
)) then
2898 Write_Str
(" is new ");
2899 Sprint_And_List
(Interface_List
(Node
));
2902 if Present
(Task_Definition
(Node
)) then
2903 if No
(Interface_List
(Node
)) then
2906 Write_Str
(" with ");
2909 Sprint_Node
(Task_Definition
(Node
));
2914 when N_Terminate_Alternative
=>
2915 Sprint_Node_List
(Pragmas_Before
(Node
));
2919 if Present
(Condition
(Node
)) then
2920 Write_Str_With_Col_Check
("when ");
2921 Sprint_Node
(Condition
(Node
));
2925 Write_Str_With_Col_Check_Sloc
("terminate;");
2926 Sprint_Node_List
(Pragmas_After
(Node
));
2928 when N_Timed_Entry_Call
=>
2929 Write_Indent_Str_Sloc
("select");
2931 Sprint_Node
(Entry_Call_Alternative
(Node
));
2933 Write_Indent_Str
("or");
2935 Sprint_Node
(Delay_Alternative
(Node
));
2937 Write_Indent_Str
("end select;");
2939 when N_Triggering_Alternative
=>
2940 Sprint_Node_List
(Pragmas_Before
(Node
));
2941 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
2942 Sprint_Node_List
(Statements
(Node
));
2944 when N_Type_Conversion
=>
2946 Sprint_Node
(Subtype_Mark
(Node
));
2949 if Conversion_OK
(Node
) then
2953 if Float_Truncate
(Node
) then
2957 if Rounded_Result
(Node
) then
2962 Sprint_Node
(Expression
(Node
));
2965 when N_Unchecked_Expression
=>
2968 Sprint_Node_Sloc
(Expression
(Node
));
2971 when N_Unchecked_Type_Conversion
=>
2972 Sprint_Node
(Subtype_Mark
(Node
));
2974 Write_Str_With_Col_Check
("(");
2975 Sprint_Node_Sloc
(Expression
(Node
));
2978 when N_Unconstrained_Array_Definition
=>
2979 Write_Str_With_Col_Check_Sloc
("array (");
2984 Node1
:= First
(Subtype_Marks
(Node
));
2986 Sprint_Node
(Node1
);
2987 Write_Str_With_Col_Check
(" range <>");
2989 exit when Node1
= Empty
;
2994 Write_Str
(") of ");
2995 Sprint_Node
(Component_Definition
(Node
));
2997 when N_Unused_At_Start | N_Unused_At_End
=>
2998 Write_Indent_Str
("***** Error, unused node encountered *****");
3001 when N_Use_Package_Clause
=>
3002 Write_Indent_Str_Sloc
("use ");
3003 Sprint_Comma_List
(Names
(Node
));
3006 when N_Use_Type_Clause
=>
3007 Write_Indent_Str_Sloc
("use type ");
3008 Sprint_Comma_List
(Subtype_Marks
(Node
));
3011 when N_Validate_Unchecked_Conversion
=>
3012 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
3013 Sprint_Node
(Source_Type
(Node
));
3015 Sprint_Node
(Target_Type
(Node
));
3019 Write_Indent_Str_Sloc
("when ");
3020 Sprint_Bar_List
(Discrete_Choices
(Node
));
3022 Sprint_Node
(Component_List
(Node
));
3024 when N_Variant_Part
=>
3026 Write_Indent_Str_Sloc
("case ");
3027 Sprint_Node
(Name
(Node
));
3029 Sprint_Indented_List
(Variants
(Node
));
3030 Write_Indent_Str
("end case");
3033 when N_With_Clause
=>
3035 -- Special test, if we are dumping the original tree only,
3036 -- then we want to eliminate the bogus with clauses that
3037 -- correspond to the non-existent children of Text_IO.
3039 if Dump_Original_Only
3040 and then Is_Text_IO_Kludge_Unit
(Name
(Node
))
3044 -- Normal case, output the with clause
3047 if First_Name
(Node
) or else not Dump_Original_Only
then
3049 -- Ada 2005 (AI-50217): Print limited with_clauses
3051 if Private_Present
(Node
) and Limited_Present
(Node
) then
3052 Write_Indent_Str
("limited private with ");
3054 elsif Private_Present
(Node
) then
3055 Write_Indent_Str
("private with ");
3057 elsif Limited_Present
(Node
) then
3058 Write_Indent_Str
("limited with ");
3061 Write_Indent_Str
("with ");
3068 Sprint_Node_Sloc
(Name
(Node
));
3070 if Last_Name
(Node
) or else not Dump_Original_Only
then
3077 if Nkind
(Node
) in N_Subexpr
3078 and then Do_Range_Check
(Node
)
3083 for J
in 1 .. Paren_Count
(Node
) loop
3087 Dump_Node
:= Save_Dump_Node
;
3088 end Sprint_Node_Actual
;
3090 ----------------------
3091 -- Sprint_Node_List --
3092 ----------------------
3094 procedure Sprint_Node_List
(List
: List_Id
) is
3098 if Is_Non_Empty_List
(List
) then
3099 Node
:= First
(List
);
3104 exit when Node
= Empty
;
3107 end Sprint_Node_List
;
3109 ----------------------
3110 -- Sprint_Node_Sloc --
3111 ----------------------
3113 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
3117 if Debug_Generated_Code
and then Present
(Dump_Node
) then
3118 Set_Sloc
(Dump_Node
, Sloc
(Node
));
3121 end Sprint_Node_Sloc
;
3123 ---------------------
3124 -- Sprint_Opt_Node --
3125 ---------------------
3127 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
3129 if Present
(Node
) then
3133 end Sprint_Opt_Node
;
3135 --------------------------
3136 -- Sprint_Opt_Node_List --
3137 --------------------------
3139 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
3141 if Present
(List
) then
3142 Sprint_Node_List
(List
);
3144 end Sprint_Opt_Node_List
;
3146 ---------------------------------
3147 -- Sprint_Opt_Paren_Comma_List --
3148 ---------------------------------
3150 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
3152 if Is_Non_Empty_List
(List
) then
3154 Sprint_Paren_Comma_List
(List
);
3156 end Sprint_Opt_Paren_Comma_List
;
3158 -----------------------------
3159 -- Sprint_Paren_Comma_List --
3160 -----------------------------
3162 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
3164 Node_Exists
: Boolean := False;
3168 if Is_Non_Empty_List
(List
) then
3170 if Dump_Original_Only
then
3172 while Present
(N
) loop
3173 if not Is_Rewrite_Insertion
(N
) then
3174 Node_Exists
:= True;
3181 if not Node_Exists
then
3186 Write_Str_With_Col_Check
("(");
3187 Sprint_Comma_List
(List
);
3190 end Sprint_Paren_Comma_List
;
3192 ----------------------
3193 -- Sprint_Right_Opnd --
3194 ----------------------
3196 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
3197 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
3200 if Paren_Count
(Opnd
) /= 0
3201 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
3210 end Sprint_Right_Opnd
;
3216 procedure Update_Itype
(Node
: Node_Id
) is
3218 if Present
(Etype
(Node
))
3219 and then Is_Itype
(Etype
(Node
))
3220 and then Debug_Generated_Code
3222 Set_Sloc
(Etype
(Node
), Sloc
(Node
));
3226 ---------------------
3227 -- Write_Char_Sloc --
3228 ---------------------
3230 procedure Write_Char_Sloc
(C
: Character) is
3232 if Debug_Generated_Code
and then C
/= ' ' then
3237 end Write_Char_Sloc
;
3239 --------------------------------
3240 -- Write_Condition_And_Reason --
3241 --------------------------------
3243 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
3244 Cond
: constant Node_Id
:= Condition
(Node
);
3245 Image
: constant String := RT_Exception_Code
'Image
3246 (RT_Exception_Code
'Val
3247 (UI_To_Int
(Reason
(Node
))));
3250 if Present
(Cond
) then
3252 -- If condition is a single entity, or NOT with a single entity,
3253 -- output all on one line, since it will likely fit just fine.
3255 if Is_Entity_Name
(Cond
)
3256 or else (Nkind
(Cond
) = N_Op_Not
3257 and then Is_Entity_Name
(Right_Opnd
(Cond
)))
3259 Write_Str_With_Col_Check
(" when ");
3263 -- Otherwise for more complex condition, multiple lines
3266 Write_Str_With_Col_Check
(" when");
3267 Indent
:= Indent
+ 2;
3271 Indent
:= Indent
- 2;
3274 -- If no condition, just need a space (all on one line)
3284 for J
in 4 .. Image
'Last loop
3285 if Image
(J
) = '_' then
3288 Write_Char
(Fold_Lower
(Image
(J
)));
3293 end Write_Condition_And_Reason
;
3295 --------------------------------
3296 -- Write_Corresponding_Source --
3297 --------------------------------
3299 procedure Write_Corresponding_Source
(S
: String) is
3301 Src
: Source_Buffer_Ptr
;
3304 -- Ignore if not in dump source text mode, or if in freeze actions
3306 if Dump_Source_Text
and then Freeze_Indent
= 0 then
3308 -- Ignore null string
3314 -- Ignore space or semicolon at end of given string
3316 if S
(S
'Last) = ' ' or else S
(S
'Last) = ';' then
3317 Write_Corresponding_Source
(S
(S
'First .. S
'Last - 1));
3321 -- Loop to look at next lines not yet printed in source file
3324 Last_Line_Printed
+ 1 .. Last_Source_Line
(Current_Source_File
)
3326 Src
:= Source_Text
(Current_Source_File
);
3327 Loc
:= Line_Start
(L
, Current_Source_File
);
3329 -- If comment, keep looking
3331 if Src
(Loc
.. Loc
+ 1) = "--" then
3334 -- Search to first non-blank
3337 while Src
(Loc
) not in Line_Terminator
loop
3341 if Src
(Loc
) /= ' ' and then Src
(Loc
) /= ASCII
.HT
then
3343 -- Loop through characters in string to see if we match
3345 for J
in S
'Range loop
3347 -- If mismatch, then not the case we are looking for
3349 if Src
(Loc
) /= S
(J
) then
3356 -- If we fall through, string matched, if white space or
3357 -- semicolon after the matched string, this is the case
3358 -- we are looking for.
3360 if Src
(Loc
) in Line_Terminator
3361 or else Src
(Loc
) = ' '
3362 or else Src
(Loc
) = ASCII
.HT
3363 or else Src
(Loc
) = ';'
3365 -- So output source lines up to and including this one
3367 Write_Source_Lines
(L
);
3376 -- Line was all blanks, or a comment line, keep looking
3380 end Write_Corresponding_Source
;
3382 -----------------------
3383 -- Write_Discr_Specs --
3384 -----------------------
3386 procedure Write_Discr_Specs
(N
: Node_Id
) is
3391 Specs
:= Discriminant_Specifications
(N
);
3393 if Present
(Specs
) then
3394 Write_Str_With_Col_Check
(" (");
3395 Spec
:= First
(Specs
);
3400 exit when Spec
= Empty
;
3402 -- Add semicolon, unless we are printing original tree and the
3403 -- next specification is part of a list (but not the first
3404 -- element of that list)
3406 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3413 end Write_Discr_Specs
;
3419 procedure Write_Ekind
(E
: Entity_Id
) is
3420 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
3423 Name_Len
:= S
'Length;
3424 Name_Buffer
(1 .. Name_Len
) := S
;
3425 Set_Casing
(Mixed_Case
);
3426 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3433 procedure Write_Id
(N
: Node_Id
) is
3435 -- Deal with outputting Itype
3437 -- Note: if we are printing the full tree with -gnatds, then we may
3438 -- end up picking up the Associated_Node link from a generic template
3439 -- here which overlaps the Entity field, but as documented, Write_Itype
3440 -- is defended against junk calls.
3442 if Nkind
(N
) in N_Entity
then
3444 elsif Nkind
(N
) in N_Has_Entity
then
3445 Write_Itype
(Entity
(N
));
3448 -- Case of a defining identifier
3450 if Nkind
(N
) = N_Defining_Identifier
then
3452 -- If defining identifier has an interface name (and no
3453 -- address clause), then we output the interface name.
3455 if (Is_Imported
(N
) or else Is_Exported
(N
))
3456 and then Present
(Interface_Name
(N
))
3457 and then No
(Address_Clause
(N
))
3459 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
3460 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3462 -- If no interface name (or inactive because there was
3463 -- an address clause), then just output the Chars name.
3466 Write_Name_With_Col_Check
(Chars
(N
));
3469 -- Case of selector of an expanded name where the expanded name
3470 -- has an associated entity, output this entity.
3472 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
3473 and then Selector_Name
(Parent
(N
)) = N
3474 and then Present
(Entity
(Parent
(N
)))
3476 Write_Id
(Entity
(Parent
(N
)));
3478 -- For any other node with an associated entity, output it
3480 elsif Nkind
(N
) in N_Has_Entity
3481 and then Present
(Entity_Or_Associated_Node
(N
))
3482 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
3484 Write_Id
(Entity
(N
));
3486 -- All other cases, we just print the Chars field
3489 Write_Name_With_Col_Check
(Chars
(N
));
3493 -----------------------
3494 -- Write_Identifiers --
3495 -----------------------
3497 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
3499 Sprint_Node
(Defining_Identifier
(Node
));
3500 Update_Itype
(Defining_Identifier
(Node
));
3502 -- The remainder of the declaration must be printed unless we are
3503 -- printing the original tree and this is not the last identifier
3506 not Dump_Original_Only
or else not More_Ids
(Node
);
3508 end Write_Identifiers
;
3510 ------------------------
3511 -- Write_Implicit_Def --
3512 ------------------------
3514 procedure Write_Implicit_Def
(E
: Entity_Id
) is
3519 when E_Array_Subtype
=>
3520 Write_Str_With_Col_Check
("subtype ");
3522 Write_Str_With_Col_Check
(" is ");
3523 Write_Id
(Base_Type
(E
));
3524 Write_Str_With_Col_Check
(" (");
3526 Ind
:= First_Index
(E
);
3527 while Present
(Ind
) loop
3531 if Present
(Ind
) then
3538 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
3539 Write_Str_With_Col_Check
("subtype ");
3542 Write_Id
(Etype
(E
));
3543 Write_Str_With_Col_Check
(" range ");
3544 Sprint_Node
(Scalar_Range
(E
));
3548 Write_Str_With_Col_Check
("type ");
3550 Write_Str_With_Col_Check
(" is <");
3555 end Write_Implicit_Def
;
3561 procedure Write_Indent
is
3562 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
3565 if Indent_Annull_Flag
then
3566 Indent_Annull_Flag
:= False;
3568 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3569 -- label declarations, since they typically have the sloc of the
3570 -- corresponding label, which really messes up the -gnatL output.
3573 and then Loc
> No_Location
3574 and then Nkind
(Dump_Node
) /= N_Implicit_Label_Declaration
3576 if Get_Source_File_Index
(Loc
) = Current_Source_File
then
3578 (Get_Physical_Line_Number
(Sloc
(Dump_Node
)));
3584 for J
in 1 .. Indent
loop
3590 ------------------------------
3591 -- Write_Indent_Identifiers --
3592 ------------------------------
3594 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
3596 -- We need to start a new line for every node, except in the case
3597 -- where we are printing the original tree and this is not the first
3598 -- defining identifier in the list.
3600 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3603 -- If printing original tree and this is not the first defining
3604 -- identifier in the list, then the previous call to this procedure
3605 -- printed only the name, and we add a comma to separate the names.
3611 Sprint_Node
(Defining_Identifier
(Node
));
3613 -- The remainder of the declaration must be printed unless we are
3614 -- printing the original tree and this is not the last identifier
3617 not Dump_Original_Only
or else not More_Ids
(Node
);
3618 end Write_Indent_Identifiers
;
3620 -----------------------------------
3621 -- Write_Indent_Identifiers_Sloc --
3622 -----------------------------------
3624 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
3626 -- We need to start a new line for every node, except in the case
3627 -- where we are printing the original tree and this is not the first
3628 -- defining identifier in the list.
3630 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3633 -- If printing original tree and this is not the first defining
3634 -- identifier in the list, then the previous call to this procedure
3635 -- printed only the name, and we add a comma to separate the names.
3642 Sprint_Node
(Defining_Identifier
(Node
));
3644 -- The remainder of the declaration must be printed unless we are
3645 -- printing the original tree and this is not the last identifier
3647 return not Dump_Original_Only
or else not More_Ids
(Node
);
3648 end Write_Indent_Identifiers_Sloc
;
3650 ----------------------
3651 -- Write_Indent_Str --
3652 ----------------------
3654 procedure Write_Indent_Str
(S
: String) is
3656 Write_Corresponding_Source
(S
);
3659 end Write_Indent_Str
;
3661 ---------------------------
3662 -- Write_Indent_Str_Sloc --
3663 ---------------------------
3665 procedure Write_Indent_Str_Sloc
(S
: String) is
3667 Write_Corresponding_Source
(S
);
3670 end Write_Indent_Str_Sloc
;
3676 procedure Write_Itype
(Typ
: Entity_Id
) is
3678 procedure Write_Header
(T
: Boolean := True);
3679 -- Write type if T is True, subtype if T is false
3685 procedure Write_Header
(T
: Boolean := True) is
3688 Write_Str
("[type ");
3690 Write_Str
("[subtype ");
3693 Write_Name_With_Col_Check
(Chars
(Typ
));
3697 -- Start of processing for Write_Itype
3700 if Nkind
(Typ
) in N_Entity
3701 and then Is_Itype
(Typ
)
3702 and then not Itype_Printed
(Typ
)
3704 -- Itype to be printed
3707 B
: constant Node_Id
:= Etype
(Typ
);
3709 P
: constant Node_Id
:= Parent
(Typ
);
3711 S
: constant Saved_Output_Buffer
:= Save_Output_Buffer
;
3712 -- Save current output buffer
3714 Old_Sloc
: Source_Ptr
;
3715 -- Save sloc of related node, so it is not modified when
3716 -- printing with -gnatD.
3719 -- Write indentation at start of line
3721 for J
in 1 .. Indent
loop
3725 -- If we have a constructed declaration for the itype, print it
3728 and then Nkind
(P
) in N_Declaration
3729 and then Defining_Entity
(P
) = Typ
3731 -- We must set Itype_Printed true before the recursive call to
3732 -- print the node, otherwise we get an infinite recursion!
3734 Set_Itype_Printed
(Typ
, True);
3736 -- Write the declaration enclosed in [], avoiding new line
3737 -- at start of declaration, and semicolon at end.
3739 -- Note: The itype may be imported from another unit, in which
3740 -- case we do not want to modify the Sloc of the declaration.
3741 -- Otherwise the itype may appear to be in the current unit,
3742 -- and the back-end will reject a reference out of scope.
3745 Indent_Annull_Flag
:= True;
3746 Old_Sloc
:= Sloc
(P
);
3748 Set_Sloc
(P
, Old_Sloc
);
3749 Write_Erase_Char
(';');
3751 -- If no constructed declaration, then we have to concoct the
3752 -- source corresponding to the type entity that we have at hand.
3757 -- Access types and subtypes
3760 Write_Header
(Ekind
(Typ
) = E_Access_Type
);
3761 Write_Str
("access ");
3763 if Is_Access_Constant
(Typ
) then
3764 Write_Str
("constant ");
3765 elsif Can_Never_Be_Null
(Typ
) then
3766 Write_Str
("not null ");
3769 Write_Id
(Directly_Designated_Type
(Typ
));
3771 -- Array types and string types
3773 when E_Array_Type | E_String_Type
=>
3775 Write_Str
("array (");
3777 X
:= First_Index
(Typ
);
3781 if not Is_Constrained
(Typ
) then
3782 Write_Str
(" range <>");
3790 Write_Str
(") of ");
3791 X
:= Component_Type
(Typ
);
3793 -- Preserve sloc of component type, which is defined
3794 -- elsewhere than the itype (see comment above).
3796 Old_Sloc
:= Sloc
(X
);
3798 Set_Sloc
(X
, Old_Sloc
);
3800 -- Array subtypes and string subtypes.
3801 -- Preserve Sloc of index subtypes, as above.
3803 when E_Array_Subtype | E_String_Subtype
=>
3804 Write_Header
(False);
3805 Write_Id
(Etype
(Typ
));
3808 X
:= First_Index
(Typ
);
3810 Old_Sloc
:= Sloc
(X
);
3812 Set_Sloc
(X
, Old_Sloc
);
3820 -- Signed integer types, and modular integer subtypes,
3821 -- and also enumeration subtypes.
3823 when E_Signed_Integer_Type |
3824 E_Signed_Integer_Subtype |
3825 E_Modular_Integer_Subtype |
3826 E_Enumeration_Subtype
=>
3828 Write_Header
(Ekind
(Typ
) = E_Signed_Integer_Type
);
3830 if Ekind
(Typ
) = E_Signed_Integer_Type
then
3836 -- Print bounds if different from base type
3839 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
3840 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
3845 -- B can either be a scalar type, in which case the
3846 -- declaration of Typ may constrain it with different
3847 -- bounds, or a private type, in which case we know
3848 -- that the declaration of Typ cannot have a scalar
3851 if Is_Scalar_Type
(B
) then
3852 LE
:= Type_Low_Bound
(B
);
3853 HE
:= Type_High_Bound
(B
);
3861 and then Nkind
(L
) = N_Integer_Literal
3862 and then Nkind
(H
) = N_Integer_Literal
3863 and then Nkind
(LE
) = N_Integer_Literal
3864 and then Nkind
(HE
) = N_Integer_Literal
3865 and then UI_Eq
(Intval
(L
), Intval
(LE
))
3866 and then UI_Eq
(Intval
(H
), Intval
(HE
)))
3871 Write_Str
(" range ");
3872 Sprint_Node
(Type_Low_Bound
(Typ
));
3874 Sprint_Node
(Type_High_Bound
(Typ
));
3878 -- Modular integer types
3880 when E_Modular_Integer_Type
=>
3882 Write_Str
(" mod ");
3883 Write_Uint_With_Col_Check
(Modulus
(Typ
), Auto
);
3885 -- Floating point types and subtypes
3887 when E_Floating_Point_Type |
3888 E_Floating_Point_Subtype
=>
3890 Write_Header
(Ekind
(Typ
) = E_Floating_Point_Type
);
3892 if Ekind
(Typ
) = E_Floating_Point_Type
then
3896 Write_Id
(Etype
(Typ
));
3898 if Digits_Value
(Typ
) /= Digits_Value
(Etype
(Typ
)) then
3899 Write_Str
(" digits ");
3900 Write_Uint_With_Col_Check
3901 (Digits_Value
(Typ
), Decimal
);
3904 -- Print bounds if not different from base type
3907 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
3908 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
3909 LE
: constant Node_Id
:= Type_Low_Bound
(B
);
3910 HE
: constant Node_Id
:= Type_High_Bound
(B
);
3913 if Nkind
(L
) = N_Real_Literal
3914 and then Nkind
(H
) = N_Real_Literal
3915 and then Nkind
(LE
) = N_Real_Literal
3916 and then Nkind
(HE
) = N_Real_Literal
3917 and then UR_Eq
(Realval
(L
), Realval
(LE
))
3918 and then UR_Eq
(Realval
(H
), Realval
(HE
))
3923 Write_Str
(" range ");
3924 Sprint_Node
(Type_Low_Bound
(Typ
));
3926 Sprint_Node
(Type_High_Bound
(Typ
));
3932 when E_Record_Subtype
=>
3933 Write_Header
(False);
3934 Write_Str
("record");
3940 C
:= First_Entity
(Typ
);
3941 while Present
(C
) loop
3945 Write_Id
(Etype
(C
));
3951 Write_Indent_Str
(" end record");
3955 when E_Class_Wide_Type |
3956 E_Class_Wide_Subtype
=>
3958 Write_Name_With_Col_Check
(Chars
(Etype
(Typ
)));
3959 Write_Str
("'Class");
3963 when E_Subprogram_Type
=>
3966 if Etype
(Typ
) = Standard_Void_Type
then
3967 Write_Str
("procedure");
3969 Write_Str
("function");
3972 if Present
(First_Entity
(Typ
)) then
3979 Param
:= First_Entity
(Typ
);
3984 if Ekind
(Param
) = E_In_Out_Parameter
then
3985 Write_Str
("in out ");
3986 elsif Ekind
(Param
) = E_Out_Parameter
then
3990 Write_Id
(Etype
(Param
));
3991 Next_Entity
(Param
);
3992 exit when No
(Param
);
4000 if Etype
(Typ
) /= Standard_Void_Type
then
4001 Write_Str
(" return ");
4002 Write_Id
(Etype
(Typ
));
4005 when E_String_Literal_Subtype
=>
4007 LB
: constant Uint
:=
4008 Expr_Value
(String_Literal_Low_Bound
(Typ
));
4009 Len
: constant Uint
:=
4010 String_Literal_Length
(Typ
);
4012 Write_Str
("String (");
4013 Write_Int
(UI_To_Int
(LB
));
4015 Write_Int
(UI_To_Int
(LB
+ Len
) - 1);
4019 -- For all other Itypes, print ??? (fill in later)
4022 Write_Header
(True);
4028 -- Add terminating bracket and restore output buffer
4032 Restore_Output_Buffer
(S
);
4035 Set_Itype_Printed
(Typ
);
4039 -------------------------------
4040 -- Write_Name_With_Col_Check --
4041 -------------------------------
4043 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
4049 Get_Name_String
(N
);
4051 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4052 -- upper case letter, nnn is one or more digits and b is a lower case
4053 -- letter by C...b, so that listings do not depend on serial numbers.
4055 if Debug_Flag_II
then
4057 while J
< Name_Len
- 1 loop
4058 if Name_Buffer
(J
) in 'A' .. 'Z'
4059 and then Name_Buffer
(J
+ 1) in '0' .. '9'
4062 while K
< Name_Len
loop
4063 exit when Name_Buffer
(K
) not in '0' .. '9';
4067 if Name_Buffer
(K
) in 'a' .. 'z' then
4068 L
:= Name_Len
- K
+ 1;
4070 Name_Buffer
(J
+ 4 .. J
+ L
+ 3) :=
4071 Name_Buffer
(K
.. Name_Len
);
4072 Name_Buffer
(J
+ 1 .. J
+ 3) := "...";
4073 Name_Len
:= J
+ L
+ 3;
4086 -- Fall through for normal case
4088 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4089 end Write_Name_With_Col_Check
;
4091 ------------------------------------
4092 -- Write_Name_With_Col_Check_Sloc --
4093 ------------------------------------
4095 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
4097 Get_Name_String
(N
);
4098 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
4099 end Write_Name_With_Col_Check_Sloc
;
4101 --------------------
4102 -- Write_Operator --
4103 --------------------
4105 procedure Write_Operator
(N
: Node_Id
; S
: String) is
4106 F
: Natural := S
'First;
4107 T
: Natural := S
'Last;
4110 -- If no overflow check, just write string out, and we are done
4112 if not Do_Overflow_Check
(N
) then
4115 -- If overflow check, we want to surround the operator with curly
4116 -- brackets, but not include spaces within the brackets.
4129 Write_Str_Sloc
(S
(F
.. T
));
4132 if S
(S
'Last) = ' ' then
4138 -----------------------
4139 -- Write_Param_Specs --
4140 -----------------------
4142 procedure Write_Param_Specs
(N
: Node_Id
) is
4148 Specs
:= Parameter_Specifications
(N
);
4150 if Is_Non_Empty_List
(Specs
) then
4151 Write_Str_With_Col_Check
(" (");
4152 Spec
:= First
(Specs
);
4156 Formal
:= Defining_Identifier
(Spec
);
4158 exit when Spec
= Empty
;
4160 -- Add semicolon, unless we are printing original tree and the
4161 -- next specification is part of a list (but not the first element
4164 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4169 -- Write out any extra formals
4171 while Present
(Extra_Formal
(Formal
)) loop
4172 Formal
:= Extra_Formal
(Formal
);
4174 Write_Name_With_Col_Check
(Chars
(Formal
));
4176 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
4181 end Write_Param_Specs
;
4183 -----------------------
4184 -- Write_Rewrite_Str --
4185 -----------------------
4187 procedure Write_Rewrite_Str
(S
: String) is
4189 if not Dump_Generated_Only
then
4190 if S
'Length = 3 and then S
= ">>>" then
4193 Write_Str_With_Col_Check
(S
);
4196 end Write_Rewrite_Str
;
4198 -----------------------
4199 -- Write_Source_Line --
4200 -----------------------
4202 procedure Write_Source_Line
(L
: Physical_Line_Number
) is
4204 Src
: Source_Buffer_Ptr
;
4208 if Dump_Source_Text
then
4209 Src
:= Source_Text
(Current_Source_File
);
4210 Loc
:= Line_Start
(L
, Current_Source_File
);
4213 -- See if line is a comment line, if not, and if not line one,
4214 -- precede with blank line.
4217 while Src
(Scn
) = ' ' or else Src
(Scn
) = ASCII
.HT
loop
4221 if (Src
(Scn
) in Line_Terminator
4222 or else Src
(Scn
.. Scn
+ 1) /= "--")
4228 -- Now write the source text of the line
4231 Write_Int
(Int
(L
));
4234 while Src
(Loc
) not in Line_Terminator
loop
4235 Write_Char
(Src
(Loc
));
4239 end Write_Source_Line
;
4241 ------------------------
4242 -- Write_Source_Lines --
4243 ------------------------
4245 procedure Write_Source_Lines
(L
: Physical_Line_Number
) is
4247 while Last_Line_Printed
< L
loop
4248 Last_Line_Printed
:= Last_Line_Printed
+ 1;
4249 Write_Source_Line
(Last_Line_Printed
);
4251 end Write_Source_Lines
;
4253 --------------------
4254 -- Write_Str_Sloc --
4255 --------------------
4257 procedure Write_Str_Sloc
(S
: String) is
4259 for J
in S
'Range loop
4260 Write_Char_Sloc
(S
(J
));
4264 ------------------------------
4265 -- Write_Str_With_Col_Check --
4266 ------------------------------
4268 procedure Write_Str_With_Col_Check
(S
: String) is
4270 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4271 Write_Indent_Str
(" ");
4273 if S
(S
'First) = ' ' then
4274 Write_Str
(S
(S
'First + 1 .. S
'Last));
4282 end Write_Str_With_Col_Check
;
4284 -----------------------------------
4285 -- Write_Str_With_Col_Check_Sloc --
4286 -----------------------------------
4288 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
4290 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4291 Write_Indent_Str
(" ");
4293 if S
(S
'First) = ' ' then
4294 Write_Str_Sloc
(S
(S
'First + 1 .. S
'Last));
4302 end Write_Str_With_Col_Check_Sloc
;
4304 ---------------------------
4305 -- Write_Subprogram_Name --
4306 ---------------------------
4308 procedure Write_Subprogram_Name
(N
: Node_Id
) is
4310 if not Comes_From_Source
(N
)
4311 and then Is_Entity_Name
(N
)
4314 Ent
: constant Entity_Id
:= Entity
(N
);
4316 if not In_Extended_Main_Source_Unit
(Ent
)
4318 Is_Predefined_File_Name
4319 (Unit_File_Name
(Get_Source_Unit
(Ent
)))
4321 -- Run-time routine name, output name with a preceding dollar
4322 -- making sure that we do not get a line split between them.
4324 Col_Check
(Length_Of_Name
(Chars
(Ent
)) + 1);
4326 Write_Name
(Chars
(Ent
));
4332 -- Normal case, not a run-time routine name
4335 end Write_Subprogram_Name
;
4337 -------------------------------
4338 -- Write_Uint_With_Col_Check --
4339 -------------------------------
4341 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
) is
4343 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4344 UI_Write
(U
, Format
);
4345 end Write_Uint_With_Col_Check
;
4347 ------------------------------------
4348 -- Write_Uint_With_Col_Check_Sloc --
4349 ------------------------------------
4351 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
4353 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4355 UI_Write
(U
, Format
);
4356 end Write_Uint_With_Col_Check_Sloc
;
4358 -------------------------------------
4359 -- Write_Ureal_With_Col_Check_Sloc --
4360 -------------------------------------
4362 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
4363 D
: constant Uint
:= Denominator
(U
);
4364 N
: constant Uint
:= Numerator
(U
);
4368 (UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
4371 end Write_Ureal_With_Col_Check_Sloc
;