1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Aspects
; use Aspects
;
27 with Atree
; use Atree
;
28 with Casing
; use Casing
;
29 with Csets
; use Csets
;
30 with Debug
; use Debug
;
31 with Einfo
; use Einfo
;
32 with Fname
; use Fname
;
34 with Namet
; use Namet
;
35 with Nlists
; use Nlists
;
37 with Output
; use Output
;
38 with Rtsfind
; use Rtsfind
;
39 with Sem_Eval
; use Sem_Eval
;
40 with Sem_Util
; use Sem_Util
;
41 with Sinfo
; use Sinfo
;
42 with Sinput
; use Sinput
;
43 with Sinput
.D
; use Sinput
.D
;
44 with Snames
; use Snames
;
45 with Stand
; use Stand
;
46 with Stringt
; use Stringt
;
47 with Uintp
; use Uintp
;
48 with Uname
; use Uname
;
49 with Urealp
; use Urealp
;
51 package body Sprint
is
52 Current_Source_File
: Source_File_Index
;
53 -- Index of source file whose generated code is being dumped
55 Dump_Node
: Node_Id
:= Empty
;
56 -- This is set to the current node, used for printing line numbers. In
57 -- Debug_Generated_Code mode, Dump_Node is set to the current node
58 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
59 -- value. The call clears it back to Empty.
61 Debug_Sloc
: Source_Ptr
;
62 -- Sloc of first byte of line currently being written if we are
63 -- generating a source debug file.
65 Dump_Original_Only
: Boolean;
66 -- Set True if the -gnatdo (dump original tree) flag is set
68 Dump_Generated_Only
: Boolean;
69 -- Set True if the -gnatdG (dump generated tree) debug flag is set
70 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
72 Dump_Freeze_Null
: Boolean;
73 -- Set True if empty freeze nodes and non-source null statements output.
74 -- Note that freeze nodes containing freeze actions are always output,
75 -- as are freeze nodes for itypes, which in general have the effect of
76 -- causing elaboration of the itype.
78 Freeze_Indent
: Int
:= 0;
79 -- Keep track of freeze indent level (controls output of blank lines before
80 -- procedures within expression freeze actions). Relevant only if we are
81 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
82 -- output these blank lines in any case.
85 -- Number of columns for current line output indentation
87 Indent_Annull_Flag
: Boolean := False;
88 -- Set True if subsequent Write_Indent call to be ignored, gets reset
89 -- by this call, so it is only active to suppress a single indent call.
91 Last_Line_Printed
: Physical_Line_Number
;
92 -- This keeps track of the physical line number of the last source line
93 -- that has been output. The value is only valid in Dump_Source_Text mode.
95 -------------------------------
96 -- Operator Precedence Table --
97 -------------------------------
99 -- This table is used to decide whether a subexpression needs to be
100 -- parenthesized. The rule is that if an operand of an operator (which
101 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
102 -- with a lower precedence than the operator (or equal precedence if
103 -- appearing as the right operand), then parentheses are required.
105 Op_Prec
: constant array (N_Subexpr
) of Short_Short_Integer :=
138 procedure Sprint_Left_Opnd
(N
: Node_Id
);
139 -- Print left operand of operator, parenthesizing if necessary
141 procedure Sprint_Right_Opnd
(N
: Node_Id
);
142 -- Print right operand of operator, parenthesizing if necessary
144 -----------------------
145 -- Local Subprograms --
146 -----------------------
148 procedure Col_Check
(N
: Nat
);
149 -- Check that at least N characters remain on current line, and if not,
150 -- then start an extra line with two characters extra indentation for
151 -- continuing text on the next line.
153 procedure Extra_Blank_Line
;
154 -- In some situations we write extra blank lines to separate the generated
155 -- code to make it more readable. However, these extra blank lines are not
156 -- generated in Dump_Source_Text mode, since there the source text lines
157 -- output with preceding blank lines are quite sufficient as separators.
158 -- This procedure writes a blank line if Dump_Source_Text is False.
160 procedure Indent_Annull
;
161 -- Causes following call to Write_Indent to be ignored. This is used when
162 -- a higher level node wants to stop a lower level node from starting a
163 -- new line, when it would otherwise be inclined to do so (e.g. the case
164 -- of an accept statement called from an accept alternative with a guard)
166 procedure Indent_Begin
;
167 -- Increase indentation level
169 procedure Indent_End
;
170 -- Decrease indentation level
172 procedure Print_Debug_Line
(S
: String);
173 -- Used to print output lines in Debug_Generated_Code mode (this is used
174 -- as the argument for a call to Set_Special_Output in package Output).
176 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
);
177 -- Given a divide, multiplication or division node, check the flags
178 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
179 -- appropriate special syntax characters (# and @).
181 procedure Set_Debug_Sloc
;
182 -- If Dump_Node is non-empty, this routine sets the appropriate value
183 -- in its Sloc field, from the current location in the debug source file
184 -- that is currently being written.
186 procedure Sprint_And_List
(List
: List_Id
);
187 -- Print the given list with items separated by vertical "and"
189 procedure Sprint_Aspect_Specifications
191 Semicolon
: Boolean);
192 -- Node is a declaration node that has aspect specifications (Has_Aspects
193 -- flag set True). It outputs the aspect specifications. For the case
194 -- of Semicolon = True, it is called after outputting the terminating
195 -- semicolon for the related node. The effect is to remove the semicolon
196 -- and print the aspect specifications followed by a terminating semicolon.
197 -- For the case of Semicolon False, no semicolon is removed or output, and
198 -- all the aspects are printed on a single line.
200 procedure Sprint_Bar_List
(List
: List_Id
);
201 -- Print the given list with items separated by vertical bars
203 procedure Sprint_End_Label
206 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
207 -- If there is not end label, use the defining identifier of the enclosing
208 -- construct. If the end label is present, treat it as a reference to the
209 -- defining entity of the construct: this guarantees that it carries the
210 -- proper sloc information for debugging purposes.
212 procedure Sprint_Node_Actual
(Node
: Node_Id
);
213 -- This routine prints its node argument. It is a lower level routine than
214 -- Sprint_Node, in that it does not bother about rewritten trees.
216 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
217 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
218 -- sets the Sloc of the current debug node to be a copy of the Sloc
219 -- of the sprinted node Node. Note that this is done after printing
220 -- Node, so that the Sloc is the proper updated value for the debug file.
222 procedure Update_Itype
(Node
: Node_Id
);
223 -- Update the Sloc of an itype that is not attached to the tree, when
224 -- debugging expanded code. This routine is called from nodes whose
225 -- type can be an Itype, such as defining_identifiers that may be of
226 -- an anonymous access type, or ranges in slices.
228 procedure Write_Char_Sloc
(C
: Character);
229 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
230 -- called to ensure that the current node has a proper Sloc set.
232 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
233 -- Write Condition and Reason codes of Raise_xxx_Error node
235 procedure Write_Corresponding_Source
(S
: String);
236 -- If S is a string with a single keyword (possibly followed by a space),
237 -- and if the next non-comment non-blank source line matches this keyword,
238 -- then output all source lines up to this matching line.
240 procedure Write_Discr_Specs
(N
: Node_Id
);
241 -- Output discriminant specification for node, which is any of the type
242 -- declarations that can have discriminants.
244 procedure Write_Ekind
(E
: Entity_Id
);
245 -- Write the String corresponding to the Ekind without "E_"
247 procedure Write_Id
(N
: Node_Id
);
248 -- N is a node with a Chars field. This procedure writes the name that
249 -- will be used in the generated code associated with the name. For a
250 -- node with no associated entity, this is simply the Chars field. For
251 -- the case where there is an entity associated with the node, we print
252 -- the name associated with the entity (since it may have been encoded).
253 -- One other special case is that an entity has an active external name
254 -- (i.e. an external name present with no address clause), then this
255 -- external name is output. This procedure also deals with outputting
256 -- declarations of referenced itypes, if not output earlier.
258 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
259 -- Handle node where the grammar has a list of defining identifiers, but
260 -- the tree has a separate declaration for each identifier. Handles the
261 -- printing of the defining identifier, and returns True if the type and
262 -- initialization information is to be printed, False if it is to be
263 -- skipped (the latter case happens when printing defining identifiers
264 -- other than the first in the original tree output case).
266 procedure Write_Implicit_Def
(E
: Entity_Id
);
267 pragma Warnings
(Off
, Write_Implicit_Def
);
268 -- Write the definition of the implicit type E according to its Ekind
269 -- For now a debugging procedure, but might be used in the future.
271 procedure Write_Indent
;
272 -- Start a new line and write indentation spacing
274 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
275 -- Like Write_Identifiers except that each new printed declaration
276 -- is at the start of a new line.
278 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
279 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
280 -- mode, the Sloc of the current debug node is set to point to the
281 -- first output identifier.
283 procedure Write_Indent_Str
(S
: String);
284 -- Start a new line and write indent spacing followed by given string
286 procedure Write_Indent_Str_Sloc
(S
: String);
287 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
288 -- the Sloc of the current node is set to the first non-blank character
291 procedure Write_Itype
(Typ
: Entity_Id
);
292 -- If Typ is an Itype that has not been written yet, write it. If Typ is
293 -- any other kind of entity or tree node, the call is ignored.
295 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
296 -- Write name (using Write_Name) with initial column check, and possible
297 -- initial Write_Indent (to get new line) if current line is too full.
299 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
300 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
301 -- mode, sets Sloc of current debug node to first character of name.
303 procedure Write_Operator
(N
: Node_Id
; S
: String);
304 -- Like Write_Str_Sloc, used for operators, encloses the string in
305 -- characters {} if the Do_Overflow flag is set on the node N.
307 procedure Write_Param_Specs
(N
: Node_Id
);
308 -- Output parameter specifications for node (which is either a function
309 -- or procedure specification with a Parameter_Specifications field)
311 procedure Write_Rewrite_Str
(S
: String);
312 -- Writes out a string (typically containing <<< or >>>}) for a node
313 -- created by rewriting the tree. Suppressed if we are outputting the
314 -- generated code only, since in this case we don't specially mark nodes
315 -- created by rewriting).
317 procedure Write_Source_Line
(L
: Physical_Line_Number
);
318 -- If writing of interspersed source lines is enabled, then write the given
319 -- line from the source file, preceded by Eol, then an extra blank line if
320 -- the line has at least one blank, is not a comment and is not line one,
321 -- then "--" and the line number followed by period followed by text of the
322 -- source line (without terminating Eol). If interspersed source line
323 -- output not enabled, then the call has no effect.
325 procedure Write_Source_Lines
(L
: Physical_Line_Number
);
326 -- If writing of interspersed source lines is enabled, then writes source
327 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
328 -- interspersed source line output not enabled, then call has no effect.
330 procedure Write_Str_Sloc
(S
: String);
331 -- Like Write_Str, but sets debug Sloc of current debug node to first
332 -- non-blank character if a current debug node is active.
334 procedure Write_Str_With_Col_Check
(S
: String);
335 -- Write string (using Write_Str) with initial column check, and possible
336 -- initial Write_Indent (to get new line) if current line is too full.
338 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
339 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
340 -- node to first non-blank character if a current debug node is active.
342 procedure Write_Subprogram_Name
(N
: Node_Id
);
343 -- N is the Name field of a function call or procedure statement call.
344 -- The effect of the call is to output the name, preceded by a $ if the
345 -- call is identified as an implicit call to a run time routine.
347 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
);
348 -- Write Uint (using UI_Write) with initial column check, and possible
349 -- initial Write_Indent (to get new line) if current line is too full.
350 -- The format parameter determines the output format (see UI_Write).
352 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
353 -- Write Uint (using UI_Write) with initial column check, and possible
354 -- initial Write_Indent (to get new line) if current line is too full.
355 -- The format parameter determines the output format (see UI_Write).
356 -- In addition, in Debug_Generated_Code mode, sets the current node
357 -- Sloc to the first character of the output value.
359 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
360 -- Write Ureal (using same output format as UR_Write) with column checks
361 -- and a possible initial Write_Indent (to get new line) if current line
362 -- is too full. In addition, in Debug_Generated_Code mode, sets the
363 -- current node Sloc to the first character of the output value.
369 procedure Col_Check
(N
: Nat
) is
371 if N
+ Column
> Sprint_Line_Limit
then
372 Write_Indent_Str
(" ");
376 ----------------------
377 -- Extra_Blank_Line --
378 ----------------------
380 procedure Extra_Blank_Line
is
382 if not Dump_Source_Text
then
385 end Extra_Blank_Line
;
391 procedure Indent_Annull
is
393 Indent_Annull_Flag
:= True;
400 procedure Indent_Begin
is
402 Indent
:= Indent
+ 3;
409 procedure Indent_End
is
411 Indent
:= Indent
- 3;
418 procedure pg
(Arg
: Union_Id
) is
420 Dump_Generated_Only
:= True;
421 Dump_Original_Only
:= False;
422 Dump_Freeze_Null
:= True;
423 Current_Source_File
:= No_Source_File
;
425 if Arg
in List_Range
then
426 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
428 elsif Arg
in Node_Range
then
429 Sprint_Node
(Node_Id
(Arg
));
442 procedure po
(Arg
: Union_Id
) is
444 Dump_Generated_Only
:= False;
445 Dump_Original_Only
:= True;
446 Current_Source_File
:= No_Source_File
;
448 if Arg
in List_Range
then
449 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
451 elsif Arg
in Node_Range
then
452 Sprint_Node
(Node_Id
(Arg
));
461 ----------------------
462 -- Print_Debug_Line --
463 ----------------------
465 procedure Print_Debug_Line
(S
: String) is
467 Write_Debug_Line
(S
, Debug_Sloc
);
468 end Print_Debug_Line
;
470 ---------------------------
471 -- Process_TFAI_RR_Flags --
472 ---------------------------
474 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
476 if Treat_Fixed_As_Integer
(Nod
) then
480 if Rounded_Result
(Nod
) then
483 end Process_TFAI_RR_Flags
;
489 procedure ps
(Arg
: Union_Id
) is
491 Dump_Generated_Only
:= False;
492 Dump_Original_Only
:= False;
493 Current_Source_File
:= No_Source_File
;
495 if Arg
in List_Range
then
496 Sprint_Node_List
(List_Id
(Arg
), New_Lines
=> True);
498 elsif Arg
in Node_Range
then
499 Sprint_Node
(Node_Id
(Arg
));
512 procedure Set_Debug_Sloc
is
514 if Debug_Generated_Code
and then Present
(Dump_Node
) then
515 Set_Sloc
(Dump_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
524 procedure Source_Dump
is
527 -- Put underline under string we just printed
533 procedure Underline
is
534 Col
: constant Int
:= Column
;
539 while Col
> Column
loop
546 -- Start of processing for Source_Dump
549 Dump_Generated_Only
:= Debug_Flag_G
or
550 Print_Generated_Code
or
551 Debug_Generated_Code
;
552 Dump_Original_Only
:= Debug_Flag_O
;
553 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
555 -- Note that we turn off the tree dump flags immediately, before
556 -- starting the dump. This avoids generating two copies of the dump
557 -- if an abort occurs after printing the dump, and more importantly,
558 -- avoids an infinite loop if an abort occurs during the dump.
561 Current_Source_File
:= No_Source_File
;
562 Debug_Flag_Z
:= False;
565 Write_Str
("Source recreated from tree of Standard (spec)");
567 Sprint_Node
(Standard_Package_Node
);
572 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
573 Debug_Flag_G
:= False;
574 Debug_Flag_O
:= False;
575 Debug_Flag_S
:= False;
577 -- Dump requested units
579 for U
in Main_Unit
.. Last_Unit
loop
580 Current_Source_File
:= Source_Index
(U
);
582 -- Dump all units if -gnatdf set, otherwise we dump only
583 -- the source files that are in the extended main source.
586 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
588 -- If we are generating debug files, setup to write them
590 if Debug_Generated_Code
then
591 Set_Special_Output
(Print_Debug_Line
'Access);
592 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
593 Write_Source_Line
(1);
594 Last_Line_Printed
:= 1;
595 Sprint_Node
(Cunit
(U
));
596 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
599 Set_Special_Output
(null);
601 -- Normal output to standard output file
604 Write_Str
("Source recreated from tree for ");
605 Write_Unit_Name
(Unit_Name
(U
));
607 Write_Source_Line
(1);
608 Last_Line_Printed
:= 1;
609 Sprint_Node
(Cunit
(U
));
610 Write_Source_Lines
(Last_Source_Line
(Current_Source_File
));
619 ---------------------
620 -- Sprint_And_List --
621 ---------------------
623 procedure Sprint_And_List
(List
: List_Id
) is
626 if Is_Non_Empty_List
(List
) then
627 Node
:= First
(List
);
631 exit when Node
= Empty
;
637 ----------------------------------
638 -- Sprint_Aspect_Specifications --
639 ----------------------------------
641 procedure Sprint_Aspect_Specifications
645 AS
: constant List_Id
:= Aspect_Specifications
(Node
);
650 Write_Erase_Char
(';');
651 Indent
:= Indent
+ 2;
654 Indent
:= Indent
+ 5;
657 Write_Str
(" with ");
662 Sprint_Node
(Identifier
(A
));
664 if Class_Present
(A
) then
665 Write_Str
("'Class");
668 if Present
(Expression
(A
)) then
670 Sprint_Node
(Expression
(A
));
684 Indent
:= Indent
- 7;
687 end Sprint_Aspect_Specifications
;
689 ---------------------
690 -- Sprint_Bar_List --
691 ---------------------
693 procedure Sprint_Bar_List
(List
: List_Id
) is
696 if Is_Non_Empty_List
(List
) then
697 Node
:= First
(List
);
701 exit when Node
= Empty
;
707 ----------------------
708 -- Sprint_End_Label --
709 ----------------------
711 procedure Sprint_End_Label
717 and then Present
(End_Label
(Node
))
718 and then Is_Entity_Name
(End_Label
(Node
))
720 Set_Entity
(End_Label
(Node
), Default
);
722 -- For a function whose name is an operator, use the qualified name
723 -- created for the defining entity.
725 if Nkind
(End_Label
(Node
)) = N_Operator_Symbol
then
726 Set_Chars
(End_Label
(Node
), Chars
(Default
));
729 Sprint_Node
(End_Label
(Node
));
731 Sprint_Node
(Default
);
733 end Sprint_End_Label
;
735 -----------------------
736 -- Sprint_Comma_List --
737 -----------------------
739 procedure Sprint_Comma_List
(List
: List_Id
) is
743 if Is_Non_Empty_List
(List
) then
744 Node
:= First
(List
);
748 exit when Node
= Empty
;
750 if not Is_Rewrite_Insertion
(Node
)
751 or else not Dump_Original_Only
757 end Sprint_Comma_List
;
759 --------------------------
760 -- Sprint_Indented_List --
761 --------------------------
763 procedure Sprint_Indented_List
(List
: List_Id
) is
766 Sprint_Node_List
(List
);
768 end Sprint_Indented_List
;
770 ---------------------
771 -- Sprint_Left_Opnd --
772 ---------------------
774 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
775 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
778 if Paren_Count
(Opnd
) /= 0
779 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
788 end Sprint_Left_Opnd
;
794 procedure Sprint_Node
(Node
: Node_Id
) is
796 if Is_Rewrite_Insertion
(Node
) then
797 if not Dump_Original_Only
then
799 -- For special cases of nodes that always output <<< >>>
800 -- do not duplicate the output at this point.
802 if Nkind
(Node
) = N_Freeze_Entity
803 or else Nkind
(Node
) = N_Implicit_Label_Declaration
805 Sprint_Node_Actual
(Node
);
807 -- Normal case where <<< >>> may be required
810 Write_Rewrite_Str
("<<<");
811 Sprint_Node_Actual
(Node
);
812 Write_Rewrite_Str
(">>>");
816 elsif Is_Rewrite_Substitution
(Node
) then
818 -- Case of dump generated only
820 if Dump_Generated_Only
then
821 Sprint_Node_Actual
(Node
);
823 -- Case of dump original only
825 elsif Dump_Original_Only
then
826 Sprint_Node_Actual
(Original_Node
(Node
));
828 -- Case of both being dumped
831 Sprint_Node_Actual
(Original_Node
(Node
));
832 Write_Rewrite_Str
("<<<");
833 Sprint_Node_Actual
(Node
);
834 Write_Rewrite_Str
(">>>");
838 Sprint_Node_Actual
(Node
);
842 ------------------------
843 -- Sprint_Node_Actual --
844 ------------------------
846 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
847 Save_Dump_Node
: constant Node_Id
:= Dump_Node
;
854 for J
in 1 .. Paren_Count
(Node
) loop
855 Write_Str_With_Col_Check
("(");
858 -- Setup current dump node
862 if Nkind
(Node
) in N_Subexpr
863 and then Do_Range_Check
(Node
)
865 Write_Str_With_Col_Check
("{");
868 -- Select print circuit based on node kind
871 when N_Abort_Statement
=>
872 Write_Indent_Str_Sloc
("abort ");
873 Sprint_Comma_List
(Names
(Node
));
876 when N_Abortable_Part
=>
878 Write_Str_Sloc
("abort ");
879 Sprint_Indented_List
(Statements
(Node
));
881 when N_Abstract_Subprogram_Declaration
=>
883 Sprint_Node
(Specification
(Node
));
884 Write_Str_With_Col_Check
(" is ");
885 Write_Str_Sloc
("abstract;");
887 when N_Accept_Alternative
=>
888 Sprint_Node_List
(Pragmas_Before
(Node
));
890 if Present
(Condition
(Node
)) then
891 Write_Indent_Str
("when ");
892 Sprint_Node
(Condition
(Node
));
897 Sprint_Node_Sloc
(Accept_Statement
(Node
));
898 Sprint_Node_List
(Statements
(Node
));
900 when N_Accept_Statement
=>
901 Write_Indent_Str_Sloc
("accept ");
902 Write_Id
(Entry_Direct_Name
(Node
));
904 if Present
(Entry_Index
(Node
)) then
905 Write_Str_With_Col_Check
(" (");
906 Sprint_Node
(Entry_Index
(Node
));
910 Write_Param_Specs
(Node
);
912 if Present
(Handled_Statement_Sequence
(Node
)) then
913 Write_Str_With_Col_Check
(" do");
914 Sprint_Node
(Handled_Statement_Sequence
(Node
));
915 Write_Indent_Str
("end ");
916 Write_Id
(Entry_Direct_Name
(Node
));
921 when N_Access_Definition
=>
925 if Present
(Access_To_Subprogram_Definition
(Node
)) then
926 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
930 if Null_Exclusion_Present
(Node
) then
931 Write_Str
("not null ");
934 Write_Str_With_Col_Check_Sloc
("access ");
936 if All_Present
(Node
) then
938 elsif Constant_Present
(Node
) then
939 Write_Str
("constant ");
942 Sprint_Node
(Subtype_Mark
(Node
));
945 when N_Access_Function_Definition
=>
949 if Null_Exclusion_Present
(Node
) then
950 Write_Str
("not null ");
953 Write_Str_With_Col_Check_Sloc
("access ");
955 if Protected_Present
(Node
) then
956 Write_Str_With_Col_Check
("protected ");
959 Write_Str_With_Col_Check
("function");
960 Write_Param_Specs
(Node
);
961 Write_Str_With_Col_Check
(" return ");
962 Sprint_Node
(Result_Definition
(Node
));
964 when N_Access_Procedure_Definition
=>
968 if Null_Exclusion_Present
(Node
) then
969 Write_Str
("not null ");
972 Write_Str_With_Col_Check_Sloc
("access ");
974 if Protected_Present
(Node
) then
975 Write_Str_With_Col_Check
("protected ");
978 Write_Str_With_Col_Check
("procedure");
979 Write_Param_Specs
(Node
);
981 when N_Access_To_Object_Definition
=>
982 Write_Str_With_Col_Check_Sloc
("access ");
984 if All_Present
(Node
) then
985 Write_Str_With_Col_Check
("all ");
986 elsif Constant_Present
(Node
) then
987 Write_Str_With_Col_Check
("constant ");
992 if Null_Exclusion_Present
(Node
) then
993 Write_Str
("not null ");
996 Sprint_Node
(Subtype_Indication
(Node
));
999 if Null_Record_Present
(Node
) then
1000 Write_Str_With_Col_Check_Sloc
("(null record)");
1003 Write_Str_With_Col_Check_Sloc
("(");
1005 if Present
(Expressions
(Node
)) then
1006 Sprint_Comma_List
(Expressions
(Node
));
1008 if Present
(Component_Associations
(Node
))
1009 and then not Is_Empty_List
(Component_Associations
(Node
))
1015 if Present
(Component_Associations
(Node
))
1016 and then not Is_Empty_List
(Component_Associations
(Node
))
1024 Nd
:= First
(Component_Associations
(Node
));
1032 if not Is_Rewrite_Insertion
(Nd
)
1033 or else not Dump_Original_Only
1047 Write_Str_With_Col_Check_Sloc
("new ");
1049 -- Ada 2005 (AI-231)
1051 if Null_Exclusion_Present
(Node
) then
1052 Write_Str
("not null ");
1055 Sprint_Node
(Expression
(Node
));
1057 if Present
(Storage_Pool
(Node
)) then
1058 Write_Str_With_Col_Check
("[storage_pool = ");
1059 Sprint_Node
(Storage_Pool
(Node
));
1064 Sprint_Left_Opnd
(Node
);
1065 Write_Str_Sloc
(" and then ");
1066 Sprint_Right_Opnd
(Node
);
1068 -- Note: the following code for N_Aspect_Specification is not
1069 -- normally used, since we deal with aspects as part of a
1070 -- declaration, but it is here in case we deliberately try
1071 -- to print an N_Aspect_Speficiation node (e.g. from GDB).
1073 when N_Aspect_Specification
=>
1074 Sprint_Node
(Identifier
(Node
));
1076 Sprint_Node
(Expression
(Node
));
1078 when N_Assignment_Statement
=>
1080 Sprint_Node
(Name
(Node
));
1081 Write_Str_Sloc
(" := ");
1082 Sprint_Node
(Expression
(Node
));
1085 when N_Asynchronous_Select
=>
1086 Write_Indent_Str_Sloc
("select");
1088 Sprint_Node
(Triggering_Alternative
(Node
));
1091 -- Note: let the printing of Abortable_Part handle outputting
1092 -- the ABORT keyword, so that the Sloc can be set correctly.
1094 Write_Indent_Str
("then ");
1095 Sprint_Node
(Abortable_Part
(Node
));
1096 Write_Indent_Str
("end select;");
1099 Write_Indent_Str_Sloc
("for ");
1100 Write_Id
(Identifier
(Node
));
1101 Write_Str_With_Col_Check
(" use at ");
1102 Sprint_Node
(Expression
(Node
));
1105 when N_Attribute_Definition_Clause
=>
1106 Write_Indent_Str_Sloc
("for ");
1107 Sprint_Node
(Name
(Node
));
1109 Write_Name_With_Col_Check
(Chars
(Node
));
1110 Write_Str_With_Col_Check
(" use ");
1111 Sprint_Node
(Expression
(Node
));
1114 when N_Attribute_Reference
=>
1115 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1119 Sprint_Node
(Prefix
(Node
));
1120 Write_Char_Sloc
(''');
1121 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
1122 Sprint_Paren_Comma_List
(Expressions
(Node
));
1124 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
1128 when N_Block_Statement
=>
1131 if Present
(Identifier
(Node
))
1132 and then (not Has_Created_Identifier
(Node
)
1133 or else not Dump_Original_Only
)
1135 Write_Rewrite_Str
("<<<");
1136 Write_Id
(Identifier
(Node
));
1138 Write_Rewrite_Str
(">>>");
1141 if Present
(Declarations
(Node
)) then
1142 Write_Str_With_Col_Check_Sloc
("declare");
1143 Sprint_Indented_List
(Declarations
(Node
));
1147 Write_Str_With_Col_Check_Sloc
("begin");
1148 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1149 Write_Indent_Str
("end");
1151 if Present
(Identifier
(Node
))
1152 and then (not Has_Created_Identifier
(Node
)
1153 or else not Dump_Original_Only
)
1155 Write_Rewrite_Str
("<<<");
1157 Write_Id
(Identifier
(Node
));
1158 Write_Rewrite_Str
(">>>");
1163 when N_Case_Expression
=>
1165 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
1169 -- The syntax for case_expression does not include parentheses,
1170 -- but sometimes parentheses are required, so unconditionally
1171 -- generate them here unless already present.
1173 if not Has_Parens
then
1177 Write_Str_With_Col_Check_Sloc
("case ");
1178 Sprint_Node
(Expression
(Node
));
1179 Write_Str_With_Col_Check
(" is");
1181 Alt
:= First
(Alternatives
(Node
));
1189 if not Has_Parens
then
1194 when N_Case_Expression_Alternative
=>
1195 Write_Str_With_Col_Check
(" when ");
1196 Sprint_Bar_List
(Discrete_Choices
(Node
));
1198 Sprint_Node
(Expression
(Node
));
1200 when N_Case_Statement
=>
1201 Write_Indent_Str_Sloc
("case ");
1202 Sprint_Node
(Expression
(Node
));
1204 Sprint_Indented_List
(Alternatives
(Node
));
1205 Write_Indent_Str
("end case;");
1207 when N_Case_Statement_Alternative
=>
1208 Write_Indent_Str_Sloc
("when ");
1209 Sprint_Bar_List
(Discrete_Choices
(Node
));
1211 Sprint_Indented_List
(Statements
(Node
));
1213 when N_Character_Literal
=>
1214 if Column
> Sprint_Line_Limit
- 2 then
1215 Write_Indent_Str
(" ");
1218 Write_Char_Sloc
(''');
1219 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
1222 when N_Code_Statement
=>
1225 Sprint_Node
(Expression
(Node
));
1228 when N_Compilation_Unit
=>
1229 Sprint_Node_List
(Context_Items
(Node
));
1230 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
1232 if Private_Present
(Node
) then
1233 Write_Indent_Str
("private ");
1237 Sprint_Node_Sloc
(Unit
(Node
));
1239 if Present
(Actions
(Aux_Decls_Node
(Node
)))
1241 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
1246 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
1247 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
1249 when N_Compilation_Unit_Aux
=>
1250 null; -- nothing to do, never used, see above
1252 when N_Component_Association
=>
1254 Sprint_Bar_List
(Choices
(Node
));
1257 -- Ada 2005 (AI-287): Print the box if present
1259 if Box_Present
(Node
) then
1260 Write_Str_With_Col_Check
("<>");
1262 Sprint_Node
(Expression
(Node
));
1265 when N_Component_Clause
=>
1267 Sprint_Node
(Component_Name
(Node
));
1268 Write_Str_Sloc
(" at ");
1269 Sprint_Node
(Position
(Node
));
1271 Write_Str_With_Col_Check
("range ");
1272 Sprint_Node
(First_Bit
(Node
));
1274 Sprint_Node
(Last_Bit
(Node
));
1277 when N_Component_Definition
=>
1280 -- Ada 2005 (AI-230): Access definition components
1282 if Present
(Access_Definition
(Node
)) then
1283 Sprint_Node
(Access_Definition
(Node
));
1285 elsif Present
(Subtype_Indication
(Node
)) then
1286 if Aliased_Present
(Node
) then
1287 Write_Str_With_Col_Check
("aliased ");
1290 -- Ada 2005 (AI-231)
1292 if Null_Exclusion_Present
(Node
) then
1293 Write_Str
(" not null ");
1296 Sprint_Node
(Subtype_Indication
(Node
));
1299 Write_Str
(" ??? ");
1302 when N_Component_Declaration
=>
1303 if Write_Indent_Identifiers_Sloc
(Node
) then
1305 Sprint_Node
(Component_Definition
(Node
));
1307 if Present
(Expression
(Node
)) then
1309 Sprint_Node
(Expression
(Node
));
1315 when N_Component_List
=>
1316 if Null_Present
(Node
) then
1318 Write_Indent_Str_Sloc
("null");
1324 Sprint_Indented_List
(Component_Items
(Node
));
1325 Sprint_Node
(Variant_Part
(Node
));
1328 when N_Conditional_Entry_Call
=>
1329 Write_Indent_Str_Sloc
("select");
1331 Sprint_Node
(Entry_Call_Alternative
(Node
));
1333 Write_Indent_Str
("else");
1334 Sprint_Indented_List
(Else_Statements
(Node
));
1335 Write_Indent_Str
("end select;");
1337 when N_Constrained_Array_Definition
=>
1338 Write_Str_With_Col_Check_Sloc
("array ");
1339 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1342 Sprint_Node
(Component_Definition
(Node
));
1344 -- A contract node should not appear in the tree. It is a semantic
1345 -- node attached to entry and [generic] subprogram entities.
1348 raise Program_Error
;
1350 when N_Decimal_Fixed_Point_Definition
=>
1351 Write_Str_With_Col_Check_Sloc
(" delta ");
1352 Sprint_Node
(Delta_Expression
(Node
));
1353 Write_Str_With_Col_Check
("digits ");
1354 Sprint_Node
(Digits_Expression
(Node
));
1355 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1357 when N_Defining_Character_Literal
=>
1358 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1360 when N_Defining_Identifier
=>
1364 when N_Defining_Operator_Symbol
=>
1365 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1367 when N_Defining_Program_Unit_Name
=>
1369 Sprint_Node
(Name
(Node
));
1371 Write_Id
(Defining_Identifier
(Node
));
1373 when N_Delay_Alternative
=>
1374 Sprint_Node_List
(Pragmas_Before
(Node
));
1376 if Present
(Condition
(Node
)) then
1378 Write_Str_With_Col_Check
("when ");
1379 Sprint_Node
(Condition
(Node
));
1384 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1385 Sprint_Node_List
(Statements
(Node
));
1387 when N_Delay_Relative_Statement
=>
1388 Write_Indent_Str_Sloc
("delay ");
1389 Sprint_Node
(Expression
(Node
));
1392 when N_Delay_Until_Statement
=>
1393 Write_Indent_Str_Sloc
("delay until ");
1394 Sprint_Node
(Expression
(Node
));
1397 when N_Delta_Constraint
=>
1398 Write_Str_With_Col_Check_Sloc
("delta ");
1399 Sprint_Node
(Delta_Expression
(Node
));
1400 Sprint_Opt_Node
(Range_Constraint
(Node
));
1402 when N_Derived_Type_Definition
=>
1403 if Abstract_Present
(Node
) then
1404 Write_Str_With_Col_Check
("abstract ");
1407 Write_Str_With_Col_Check
("new ");
1409 -- Ada 2005 (AI-231)
1411 if Null_Exclusion_Present
(Node
) then
1412 Write_Str_With_Col_Check
("not null ");
1415 Sprint_Node
(Subtype_Indication
(Node
));
1417 if Present
(Interface_List
(Node
)) then
1418 Write_Str_With_Col_Check
(" and ");
1419 Sprint_And_List
(Interface_List
(Node
));
1420 Write_Str_With_Col_Check
(" with ");
1423 if Present
(Record_Extension_Part
(Node
)) then
1424 if No
(Interface_List
(Node
)) then
1425 Write_Str_With_Col_Check
(" with ");
1428 Sprint_Node
(Record_Extension_Part
(Node
));
1431 when N_Designator
=>
1432 Sprint_Node
(Name
(Node
));
1433 Write_Char_Sloc
('.');
1434 Write_Id
(Identifier
(Node
));
1436 when N_Digits_Constraint
=>
1437 Write_Str_With_Col_Check_Sloc
("digits ");
1438 Sprint_Node
(Digits_Expression
(Node
));
1439 Sprint_Opt_Node
(Range_Constraint
(Node
));
1441 when N_Discriminant_Association
=>
1444 if Present
(Selector_Names
(Node
)) then
1445 Sprint_Bar_List
(Selector_Names
(Node
));
1450 Sprint_Node
(Expression
(Node
));
1452 when N_Discriminant_Specification
=>
1455 if Write_Identifiers
(Node
) then
1458 if Null_Exclusion_Present
(Node
) then
1459 Write_Str
("not null ");
1462 Sprint_Node
(Discriminant_Type
(Node
));
1464 if Present
(Expression
(Node
)) then
1466 Sprint_Node
(Expression
(Node
));
1472 when N_Elsif_Part
=>
1473 Write_Indent_Str_Sloc
("elsif ");
1474 Sprint_Node
(Condition
(Node
));
1475 Write_Str_With_Col_Check
(" then");
1476 Sprint_Indented_List
(Then_Statements
(Node
));
1481 when N_Entry_Body
=>
1482 Write_Indent_Str_Sloc
("entry ");
1483 Write_Id
(Defining_Identifier
(Node
));
1484 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1485 Write_Str_With_Col_Check
(" is");
1486 Sprint_Indented_List
(Declarations
(Node
));
1487 Write_Indent_Str
("begin");
1488 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1489 Write_Indent_Str
("end ");
1490 Write_Id
(Defining_Identifier
(Node
));
1493 when N_Entry_Body_Formal_Part
=>
1494 if Present
(Entry_Index_Specification
(Node
)) then
1495 Write_Str_With_Col_Check_Sloc
(" (");
1496 Sprint_Node
(Entry_Index_Specification
(Node
));
1500 Write_Param_Specs
(Node
);
1501 Write_Str_With_Col_Check_Sloc
(" when ");
1502 Sprint_Node
(Condition
(Node
));
1504 when N_Entry_Call_Alternative
=>
1505 Sprint_Node_List
(Pragmas_Before
(Node
));
1506 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1507 Sprint_Node_List
(Statements
(Node
));
1509 when N_Entry_Call_Statement
=>
1511 Sprint_Node_Sloc
(Name
(Node
));
1512 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1515 when N_Entry_Declaration
=>
1516 Write_Indent_Str_Sloc
("entry ");
1517 Write_Id
(Defining_Identifier
(Node
));
1519 if Present
(Discrete_Subtype_Definition
(Node
)) then
1520 Write_Str_With_Col_Check
(" (");
1521 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1525 Write_Param_Specs
(Node
);
1528 when N_Entry_Index_Specification
=>
1529 Write_Str_With_Col_Check_Sloc
("for ");
1530 Write_Id
(Defining_Identifier
(Node
));
1531 Write_Str_With_Col_Check
(" in ");
1532 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1534 when N_Enumeration_Representation_Clause
=>
1535 Write_Indent_Str_Sloc
("for ");
1536 Write_Id
(Identifier
(Node
));
1537 Write_Str_With_Col_Check
(" use ");
1538 Sprint_Node
(Array_Aggregate
(Node
));
1541 when N_Enumeration_Type_Definition
=>
1544 -- Skip attempt to print Literals field if it's not there and
1545 -- we are in package Standard (case of Character, which is
1546 -- handled specially (without an explicit literals list).
1548 if Sloc
(Node
) > Standard_Location
1549 or else Present
(Literals
(Node
))
1551 Sprint_Paren_Comma_List
(Literals
(Node
));
1555 Write_Str_With_Col_Check_Sloc
("<error>");
1557 when N_Exception_Declaration
=>
1558 if Write_Indent_Identifiers
(Node
) then
1559 Write_Str_With_Col_Check
(" : ");
1561 if Is_Statically_Allocated
(Defining_Identifier
(Node
)) then
1562 Write_Str_With_Col_Check
("static ");
1565 Write_Str_Sloc
("exception");
1567 if Present
(Expression
(Node
)) then
1569 Sprint_Node
(Expression
(Node
));
1575 when N_Exception_Handler
=>
1576 Write_Indent_Str_Sloc
("when ");
1578 if Present
(Choice_Parameter
(Node
)) then
1579 Sprint_Node
(Choice_Parameter
(Node
));
1583 Sprint_Bar_List
(Exception_Choices
(Node
));
1585 Sprint_Indented_List
(Statements
(Node
));
1587 when N_Exception_Renaming_Declaration
=>
1590 Sprint_Node
(Defining_Identifier
(Node
));
1591 Write_Str_With_Col_Check
(" : exception renames ");
1592 Sprint_Node
(Name
(Node
));
1595 when N_Exit_Statement
=>
1596 Write_Indent_Str_Sloc
("exit");
1597 Sprint_Opt_Node
(Name
(Node
));
1599 if Present
(Condition
(Node
)) then
1600 Write_Str_With_Col_Check
(" when ");
1601 Sprint_Node
(Condition
(Node
));
1606 when N_Expanded_Name
=>
1607 Sprint_Node
(Prefix
(Node
));
1608 Write_Char_Sloc
('.');
1609 Sprint_Node
(Selector_Name
(Node
));
1611 when N_Explicit_Dereference
=>
1612 Sprint_Node
(Prefix
(Node
));
1613 Write_Char_Sloc
('.');
1614 Write_Str_Sloc
("all");
1616 when N_Expression_With_Actions
=>
1618 Write_Indent_Str_Sloc
("do ");
1620 Sprint_Node_List
(Actions
(Node
));
1623 Write_Str_With_Col_Check_Sloc
("in ");
1624 Sprint_Node
(Expression
(Node
));
1625 Write_Str_With_Col_Check
(" end");
1629 when N_Expression_Function
=>
1631 Sprint_Node_Sloc
(Specification
(Node
));
1635 Sprint_Node
(Expression
(Node
));
1639 when N_Extended_Return_Statement
=>
1640 Write_Indent_Str_Sloc
("return ");
1641 Sprint_Node_List
(Return_Object_Declarations
(Node
));
1643 if Present
(Handled_Statement_Sequence
(Node
)) then
1644 Write_Str_With_Col_Check
(" do");
1645 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1646 Write_Indent_Str
("end return;");
1648 Write_Indent_Str
(";");
1651 when N_Extension_Aggregate
=>
1652 Write_Str_With_Col_Check_Sloc
("(");
1653 Sprint_Node
(Ancestor_Part
(Node
));
1654 Write_Str_With_Col_Check
(" with ");
1656 if Null_Record_Present
(Node
) then
1657 Write_Str_With_Col_Check
("null record");
1659 if Present
(Expressions
(Node
)) then
1660 Sprint_Comma_List
(Expressions
(Node
));
1662 if Present
(Component_Associations
(Node
)) then
1667 if Present
(Component_Associations
(Node
)) then
1668 Sprint_Comma_List
(Component_Associations
(Node
));
1674 when N_Floating_Point_Definition
=>
1675 Write_Str_With_Col_Check_Sloc
("digits ");
1676 Sprint_Node
(Digits_Expression
(Node
));
1677 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1679 when N_Formal_Decimal_Fixed_Point_Definition
=>
1680 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1682 when N_Formal_Derived_Type_Definition
=>
1683 Write_Str_With_Col_Check_Sloc
("new ");
1684 Sprint_Node
(Subtype_Mark
(Node
));
1686 if Present
(Interface_List
(Node
)) then
1687 Write_Str_With_Col_Check
(" and ");
1688 Sprint_And_List
(Interface_List
(Node
));
1691 if Private_Present
(Node
) then
1692 Write_Str_With_Col_Check
(" with private");
1695 when N_Formal_Abstract_Subprogram_Declaration
=>
1696 Write_Indent_Str_Sloc
("with ");
1697 Sprint_Node
(Specification
(Node
));
1699 Write_Str_With_Col_Check
(" is abstract");
1701 if Box_Present
(Node
) then
1702 Write_Str_With_Col_Check
(" <>");
1703 elsif Present
(Default_Name
(Node
)) then
1704 Write_Str_With_Col_Check
(" ");
1705 Sprint_Node
(Default_Name
(Node
));
1710 when N_Formal_Concrete_Subprogram_Declaration
=>
1711 Write_Indent_Str_Sloc
("with ");
1712 Sprint_Node
(Specification
(Node
));
1714 if Box_Present
(Node
) then
1715 Write_Str_With_Col_Check
(" is <>");
1716 elsif Present
(Default_Name
(Node
)) then
1717 Write_Str_With_Col_Check
(" is ");
1718 Sprint_Node
(Default_Name
(Node
));
1723 when N_Formal_Discrete_Type_Definition
=>
1724 Write_Str_With_Col_Check_Sloc
("<>");
1726 when N_Formal_Floating_Point_Definition
=>
1727 Write_Str_With_Col_Check_Sloc
("digits <>");
1729 when N_Formal_Modular_Type_Definition
=>
1730 Write_Str_With_Col_Check_Sloc
("mod <>");
1732 when N_Formal_Object_Declaration
=>
1735 if Write_Indent_Identifiers
(Node
) then
1738 if In_Present
(Node
) then
1739 Write_Str_With_Col_Check
("in ");
1742 if Out_Present
(Node
) then
1743 Write_Str_With_Col_Check
("out ");
1746 if Present
(Subtype_Mark
(Node
)) then
1748 -- Ada 2005 (AI-423): Formal object with null exclusion
1750 if Null_Exclusion_Present
(Node
) then
1751 Write_Str
("not null ");
1754 Sprint_Node
(Subtype_Mark
(Node
));
1756 -- Ada 2005 (AI-423): Formal object with access definition
1759 pragma Assert
(Present
(Access_Definition
(Node
)));
1761 Sprint_Node
(Access_Definition
(Node
));
1764 if Present
(Default_Expression
(Node
)) then
1766 Sprint_Node
(Default_Expression
(Node
));
1772 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1773 Write_Str_With_Col_Check_Sloc
("delta <>");
1775 when N_Formal_Package_Declaration
=>
1776 Write_Indent_Str_Sloc
("with package ");
1777 Write_Id
(Defining_Identifier
(Node
));
1778 Write_Str_With_Col_Check
(" is new ");
1779 Sprint_Node
(Name
(Node
));
1780 Write_Str_With_Col_Check
(" (<>);");
1782 when N_Formal_Private_Type_Definition
=>
1783 if Abstract_Present
(Node
) then
1784 Write_Str_With_Col_Check
("abstract ");
1787 if Tagged_Present
(Node
) then
1788 Write_Str_With_Col_Check
("tagged ");
1791 if Limited_Present
(Node
) then
1792 Write_Str_With_Col_Check
("limited ");
1795 Write_Str_With_Col_Check_Sloc
("private");
1797 when N_Formal_Incomplete_Type_Definition
=>
1798 if Tagged_Present
(Node
) then
1799 Write_Str_With_Col_Check
("is tagged ");
1802 when N_Formal_Signed_Integer_Type_Definition
=>
1803 Write_Str_With_Col_Check_Sloc
("range <>");
1805 when N_Formal_Type_Declaration
=>
1806 Write_Indent_Str_Sloc
("type ");
1807 Write_Id
(Defining_Identifier
(Node
));
1809 if Present
(Discriminant_Specifications
(Node
)) then
1810 Write_Discr_Specs
(Node
);
1811 elsif Unknown_Discriminants_Present
(Node
) then
1812 Write_Str_With_Col_Check
("(<>)");
1815 if Nkind
(Formal_Type_Definition
(Node
)) /=
1816 N_Formal_Incomplete_Type_Definition
1818 Write_Str_With_Col_Check
(" is ");
1821 Sprint_Node
(Formal_Type_Definition
(Node
));
1824 when N_Free_Statement
=>
1825 Write_Indent_Str_Sloc
("free ");
1826 Sprint_Node
(Expression
(Node
));
1829 when N_Freeze_Entity
=>
1830 if Dump_Original_Only
then
1833 -- A freeze node is output if it has some effect (i.e. non-empty
1834 -- actions, or freeze node for an itype, which causes elaboration
1835 -- of the itype), and is also always output if Dump_Freeze_Null
1838 elsif Present
(Actions
(Node
))
1839 or else Is_Itype
(Entity
(Node
))
1840 or else Dump_Freeze_Null
1843 Write_Rewrite_Str
("<<<");
1844 Write_Str_With_Col_Check_Sloc
("freeze ");
1845 Write_Id
(Entity
(Node
));
1848 if No
(Actions
(Node
)) then
1852 -- Output freeze actions. We increment Freeze_Indent during
1853 -- this output to avoid generating extra blank lines before
1854 -- any procedures included in the freeze actions.
1856 Freeze_Indent
:= Freeze_Indent
+ 1;
1857 Sprint_Indented_List
(Actions
(Node
));
1858 Freeze_Indent
:= Freeze_Indent
- 1;
1859 Write_Indent_Str
("]");
1862 Write_Rewrite_Str
(">>>");
1865 when N_Full_Type_Declaration
=>
1866 Write_Indent_Str_Sloc
("type ");
1867 Sprint_Node
(Defining_Identifier
(Node
));
1868 Write_Discr_Specs
(Node
);
1869 Write_Str_With_Col_Check
(" is ");
1870 Sprint_Node
(Type_Definition
(Node
));
1873 when N_Function_Call
=>
1875 Write_Subprogram_Name
(Name
(Node
));
1876 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1878 when N_Function_Instantiation
=>
1879 Write_Indent_Str_Sloc
("function ");
1880 Sprint_Node
(Defining_Unit_Name
(Node
));
1881 Write_Str_With_Col_Check
(" is new ");
1882 Sprint_Node
(Name
(Node
));
1883 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1886 when N_Function_Specification
=>
1887 Write_Str_With_Col_Check_Sloc
("function ");
1888 Sprint_Node
(Defining_Unit_Name
(Node
));
1889 Write_Param_Specs
(Node
);
1890 Write_Str_With_Col_Check
(" return ");
1892 -- Ada 2005 (AI-231)
1894 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
1895 and then Null_Exclusion_Present
(Node
)
1897 Write_Str
(" not null ");
1900 Sprint_Node
(Result_Definition
(Node
));
1902 when N_Generic_Association
=>
1905 if Present
(Selector_Name
(Node
)) then
1906 Sprint_Node
(Selector_Name
(Node
));
1910 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
1912 when N_Generic_Function_Renaming_Declaration
=>
1913 Write_Indent_Str_Sloc
("generic function ");
1914 Sprint_Node
(Defining_Unit_Name
(Node
));
1915 Write_Str_With_Col_Check
(" renames ");
1916 Sprint_Node
(Name
(Node
));
1919 when N_Generic_Package_Declaration
=>
1921 Write_Indent_Str_Sloc
("generic ");
1922 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1924 Sprint_Node
(Specification
(Node
));
1927 when N_Generic_Package_Renaming_Declaration
=>
1928 Write_Indent_Str_Sloc
("generic package ");
1929 Sprint_Node
(Defining_Unit_Name
(Node
));
1930 Write_Str_With_Col_Check
(" renames ");
1931 Sprint_Node
(Name
(Node
));
1934 when N_Generic_Procedure_Renaming_Declaration
=>
1935 Write_Indent_Str_Sloc
("generic procedure ");
1936 Sprint_Node
(Defining_Unit_Name
(Node
));
1937 Write_Str_With_Col_Check
(" renames ");
1938 Sprint_Node
(Name
(Node
));
1941 when N_Generic_Subprogram_Declaration
=>
1943 Write_Indent_Str_Sloc
("generic ");
1944 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1946 Sprint_Node
(Specification
(Node
));
1949 when N_Goto_Statement
=>
1950 Write_Indent_Str_Sloc
("goto ");
1951 Sprint_Node
(Name
(Node
));
1954 if Nkind
(Next
(Node
)) = N_Label
then
1958 when N_Handled_Sequence_Of_Statements
=>
1960 Sprint_Indented_List
(Statements
(Node
));
1962 if Present
(Exception_Handlers
(Node
)) then
1963 Write_Indent_Str
("exception");
1965 Sprint_Node_List
(Exception_Handlers
(Node
));
1969 if Present
(At_End_Proc
(Node
)) then
1970 Write_Indent_Str
("at end");
1973 Sprint_Node
(At_End_Proc
(Node
));
1978 when N_Identifier
=>
1982 when N_If_Expression
=>
1984 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
1985 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
1986 Then_Expr
: constant Node_Id
:= Next
(Condition
);
1989 -- The syntax for if_expression does not include parentheses,
1990 -- but sometimes parentheses are required, so unconditionally
1991 -- generate them here unless already present.
1993 if not Has_Parens
then
1997 Write_Str_With_Col_Check_Sloc
("if ");
1998 Sprint_Node
(Condition
);
1999 Write_Str_With_Col_Check
(" then ");
2001 -- Defense against junk here!
2003 if Present
(Then_Expr
) then
2004 Sprint_Node
(Then_Expr
);
2006 if Present
(Next
(Then_Expr
)) then
2007 Write_Str_With_Col_Check
(" else ");
2008 Sprint_Node
(Next
(Then_Expr
));
2012 if not Has_Parens
then
2017 when N_If_Statement
=>
2018 Write_Indent_Str_Sloc
("if ");
2019 Sprint_Node
(Condition
(Node
));
2020 Write_Str_With_Col_Check
(" then");
2021 Sprint_Indented_List
(Then_Statements
(Node
));
2022 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
2024 if Present
(Else_Statements
(Node
)) then
2025 Write_Indent_Str
("else");
2026 Sprint_Indented_List
(Else_Statements
(Node
));
2029 Write_Indent_Str
("end if;");
2031 when N_Implicit_Label_Declaration
=>
2032 if not Dump_Original_Only
then
2034 Write_Rewrite_Str
("<<<");
2036 Write_Id
(Defining_Identifier
(Node
));
2038 Write_Str_With_Col_Check
("label");
2039 Write_Rewrite_Str
(">>>");
2043 Sprint_Left_Opnd
(Node
);
2044 Write_Str_Sloc
(" in ");
2046 if Present
(Right_Opnd
(Node
)) then
2047 Sprint_Right_Opnd
(Node
);
2049 Sprint_Bar_List
(Alternatives
(Node
));
2052 when N_Incomplete_Type_Declaration
=>
2053 Write_Indent_Str_Sloc
("type ");
2054 Write_Id
(Defining_Identifier
(Node
));
2056 if Present
(Discriminant_Specifications
(Node
)) then
2057 Write_Discr_Specs
(Node
);
2058 elsif Unknown_Discriminants_Present
(Node
) then
2059 Write_Str_With_Col_Check
("(<>)");
2064 when N_Index_Or_Discriminant_Constraint
=>
2066 Sprint_Paren_Comma_List
(Constraints
(Node
));
2068 when N_Indexed_Component
=>
2069 Sprint_Node_Sloc
(Prefix
(Node
));
2070 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
2072 when N_Integer_Literal
=>
2073 if Print_In_Hex
(Node
) then
2074 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
2076 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
2079 when N_Iteration_Scheme
=>
2080 if Present
(Condition
(Node
)) then
2081 Write_Str_With_Col_Check_Sloc
("while ");
2082 Sprint_Node
(Condition
(Node
));
2084 Write_Str_With_Col_Check_Sloc
("for ");
2086 if Present
(Iterator_Specification
(Node
)) then
2087 Sprint_Node
(Iterator_Specification
(Node
));
2089 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2095 when N_Iterator_Specification
=>
2097 Write_Id
(Defining_Identifier
(Node
));
2099 if Present
(Subtype_Indication
(Node
)) then
2100 Write_Str_With_Col_Check
(" : ");
2101 Sprint_Node
(Subtype_Indication
(Node
));
2104 if Of_Present
(Node
) then
2105 Write_Str_With_Col_Check
(" of ");
2107 Write_Str_With_Col_Check
(" in ");
2110 if Reverse_Present
(Node
) then
2111 Write_Str_With_Col_Check
("reverse ");
2114 Sprint_Node
(Name
(Node
));
2116 when N_Itype_Reference
=>
2117 Write_Indent_Str_Sloc
("reference ");
2118 Write_Id
(Itype
(Node
));
2121 Write_Indent_Str_Sloc
("<<");
2122 Write_Id
(Identifier
(Node
));
2125 when N_Loop_Parameter_Specification
=>
2127 Write_Id
(Defining_Identifier
(Node
));
2128 Write_Str_With_Col_Check
(" in ");
2130 if Reverse_Present
(Node
) then
2131 Write_Str_With_Col_Check
("reverse ");
2134 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
2136 when N_Loop_Statement
=>
2139 if Present
(Identifier
(Node
))
2140 and then (not Has_Created_Identifier
(Node
)
2141 or else not Dump_Original_Only
)
2143 Write_Rewrite_Str
("<<<");
2144 Write_Id
(Identifier
(Node
));
2146 Write_Rewrite_Str
(">>>");
2147 Sprint_Node
(Iteration_Scheme
(Node
));
2148 Write_Str_With_Col_Check_Sloc
("loop");
2149 Sprint_Indented_List
(Statements
(Node
));
2150 Write_Indent_Str
("end loop ");
2151 Write_Rewrite_Str
("<<<");
2152 Write_Id
(Identifier
(Node
));
2153 Write_Rewrite_Str
(">>>");
2157 Sprint_Node
(Iteration_Scheme
(Node
));
2158 Write_Str_With_Col_Check_Sloc
("loop");
2159 Sprint_Indented_List
(Statements
(Node
));
2160 Write_Indent_Str
("end loop;");
2163 when N_Mod_Clause
=>
2164 Sprint_Node_List
(Pragmas_Before
(Node
));
2165 Write_Str_With_Col_Check_Sloc
("at mod ");
2166 Sprint_Node
(Expression
(Node
));
2168 when N_Modular_Type_Definition
=>
2169 Write_Str_With_Col_Check_Sloc
("mod ");
2170 Sprint_Node
(Expression
(Node
));
2173 Sprint_Left_Opnd
(Node
);
2174 Write_Str_Sloc
(" not in ");
2176 if Present
(Right_Opnd
(Node
)) then
2177 Sprint_Right_Opnd
(Node
);
2179 Sprint_Bar_List
(Alternatives
(Node
));
2183 Write_Str_With_Col_Check_Sloc
("null");
2185 when N_Null_Statement
=>
2186 if Comes_From_Source
(Node
)
2187 or else Dump_Freeze_Null
2188 or else not Is_List_Member
(Node
)
2189 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
2191 Write_Indent_Str_Sloc
("null;");
2194 when N_Number_Declaration
=>
2197 if Write_Indent_Identifiers
(Node
) then
2198 Write_Str_With_Col_Check
(" : constant ");
2200 Sprint_Node
(Expression
(Node
));
2204 when N_Object_Declaration
=>
2207 if Write_Indent_Identifiers
(Node
) then
2209 Def_Id
: constant Entity_Id
:= Defining_Identifier
(Node
);
2212 Write_Str_With_Col_Check
(" : ");
2214 if Is_Statically_Allocated
(Def_Id
) then
2215 Write_Str_With_Col_Check
("static ");
2218 if Aliased_Present
(Node
) then
2219 Write_Str_With_Col_Check
("aliased ");
2222 if Constant_Present
(Node
) then
2223 Write_Str_With_Col_Check
("constant ");
2226 -- Ada 2005 (AI-231)
2228 if Null_Exclusion_Present
(Node
) then
2229 Write_Str_With_Col_Check
("not null ");
2232 Sprint_Node
(Object_Definition
(Node
));
2234 if Present
(Expression
(Node
)) then
2236 Sprint_Node
(Expression
(Node
));
2241 -- Handle implicit importation and implicit exportation of
2242 -- object declarations:
2243 -- $pragma import (Convention_Id, Def_Id, "...");
2244 -- $pragma export (Convention_Id, Def_Id, "...");
2246 if Is_Internal
(Def_Id
)
2247 and then Present
(Interface_Name
(Def_Id
))
2249 Write_Indent_Str_Sloc
("$pragma ");
2251 if Is_Imported
(Def_Id
) then
2252 Write_Str
("import (");
2254 else pragma Assert
(Is_Exported
(Def_Id
));
2255 Write_Str
("export (");
2259 Prefix
: constant String := "Convention_";
2260 S
: constant String := Convention
(Def_Id
)'Img;
2263 Name_Len
:= S
'Last - Prefix
'Last;
2264 Name_Buffer
(1 .. Name_Len
) :=
2265 S
(Prefix
'Last + 1 .. S
'Last);
2266 Set_Casing
(All_Lower_Case
);
2267 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2273 Write_String_Table_Entry
2274 (Strval
(Interface_Name
(Def_Id
)));
2280 when N_Object_Renaming_Declaration
=>
2283 Sprint_Node
(Defining_Identifier
(Node
));
2286 -- Ada 2005 (AI-230): Access renamings
2288 if Present
(Access_Definition
(Node
)) then
2289 Sprint_Node
(Access_Definition
(Node
));
2291 elsif Present
(Subtype_Mark
(Node
)) then
2293 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2295 if Null_Exclusion_Present
(Node
) then
2296 Write_Str
("not null ");
2299 Sprint_Node
(Subtype_Mark
(Node
));
2302 Write_Str
(" ??? ");
2305 Write_Str_With_Col_Check
(" renames ");
2306 Sprint_Node
(Name
(Node
));
2310 Write_Operator
(Node
, "abs ");
2311 Sprint_Right_Opnd
(Node
);
2314 Sprint_Left_Opnd
(Node
);
2315 Write_Operator
(Node
, " + ");
2316 Sprint_Right_Opnd
(Node
);
2319 Sprint_Left_Opnd
(Node
);
2320 Write_Operator
(Node
, " and ");
2321 Sprint_Right_Opnd
(Node
);
2324 Sprint_Left_Opnd
(Node
);
2325 Write_Operator
(Node
, " & ");
2326 Sprint_Right_Opnd
(Node
);
2329 Sprint_Left_Opnd
(Node
);
2331 Process_TFAI_RR_Flags
(Node
);
2332 Write_Operator
(Node
, "/ ");
2333 Sprint_Right_Opnd
(Node
);
2336 Sprint_Left_Opnd
(Node
);
2337 Write_Operator
(Node
, " = ");
2338 Sprint_Right_Opnd
(Node
);
2341 Sprint_Left_Opnd
(Node
);
2342 Write_Operator
(Node
, " ** ");
2343 Sprint_Right_Opnd
(Node
);
2346 Sprint_Left_Opnd
(Node
);
2347 Write_Operator
(Node
, " >= ");
2348 Sprint_Right_Opnd
(Node
);
2351 Sprint_Left_Opnd
(Node
);
2352 Write_Operator
(Node
, " > ");
2353 Sprint_Right_Opnd
(Node
);
2356 Sprint_Left_Opnd
(Node
);
2357 Write_Operator
(Node
, " <= ");
2358 Sprint_Right_Opnd
(Node
);
2361 Sprint_Left_Opnd
(Node
);
2362 Write_Operator
(Node
, " < ");
2363 Sprint_Right_Opnd
(Node
);
2366 Write_Operator
(Node
, "-");
2367 Sprint_Right_Opnd
(Node
);
2370 Sprint_Left_Opnd
(Node
);
2372 if Treat_Fixed_As_Integer
(Node
) then
2376 Write_Operator
(Node
, " mod ");
2377 Sprint_Right_Opnd
(Node
);
2379 when N_Op_Multiply
=>
2380 Sprint_Left_Opnd
(Node
);
2382 Process_TFAI_RR_Flags
(Node
);
2383 Write_Operator
(Node
, "* ");
2384 Sprint_Right_Opnd
(Node
);
2387 Sprint_Left_Opnd
(Node
);
2388 Write_Operator
(Node
, " /= ");
2389 Sprint_Right_Opnd
(Node
);
2392 Write_Operator
(Node
, "not ");
2393 Sprint_Right_Opnd
(Node
);
2396 Sprint_Left_Opnd
(Node
);
2397 Write_Operator
(Node
, " or ");
2398 Sprint_Right_Opnd
(Node
);
2401 Write_Operator
(Node
, "+");
2402 Sprint_Right_Opnd
(Node
);
2405 Sprint_Left_Opnd
(Node
);
2407 if Treat_Fixed_As_Integer
(Node
) then
2411 Write_Operator
(Node
, " rem ");
2412 Sprint_Right_Opnd
(Node
);
2418 Write_Str_With_Col_Check
("(");
2419 Sprint_Node
(Left_Opnd
(Node
));
2421 Sprint_Node
(Right_Opnd
(Node
));
2424 when N_Op_Subtract
=>
2425 Sprint_Left_Opnd
(Node
);
2426 Write_Operator
(Node
, " - ");
2427 Sprint_Right_Opnd
(Node
);
2430 Sprint_Left_Opnd
(Node
);
2431 Write_Operator
(Node
, " xor ");
2432 Sprint_Right_Opnd
(Node
);
2434 when N_Operator_Symbol
=>
2435 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
2437 when N_Ordinary_Fixed_Point_Definition
=>
2438 Write_Str_With_Col_Check_Sloc
("delta ");
2439 Sprint_Node
(Delta_Expression
(Node
));
2440 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
2443 Sprint_Left_Opnd
(Node
);
2444 Write_Str_Sloc
(" or else ");
2445 Sprint_Right_Opnd
(Node
);
2447 when N_Others_Choice
=>
2448 if All_Others
(Node
) then
2449 Write_Str_With_Col_Check
("all ");
2452 Write_Str_With_Col_Check_Sloc
("others");
2454 when N_Package_Body
=>
2456 Write_Indent_Str_Sloc
("package body ");
2457 Sprint_Node
(Defining_Unit_Name
(Node
));
2459 Sprint_Indented_List
(Declarations
(Node
));
2461 if Present
(Handled_Statement_Sequence
(Node
)) then
2462 Write_Indent_Str
("begin");
2463 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2466 Write_Indent_Str
("end ");
2468 (Handled_Statement_Sequence
(Node
), Defining_Unit_Name
(Node
));
2471 when N_Package_Body_Stub
=>
2472 Write_Indent_Str_Sloc
("package body ");
2473 Sprint_Node
(Defining_Identifier
(Node
));
2474 Write_Str_With_Col_Check
(" is separate;");
2476 when N_Package_Declaration
=>
2479 Sprint_Node_Sloc
(Specification
(Node
));
2482 when N_Package_Instantiation
=>
2484 Write_Indent_Str_Sloc
("package ");
2485 Sprint_Node
(Defining_Unit_Name
(Node
));
2486 Write_Str
(" is new ");
2487 Sprint_Node
(Name
(Node
));
2488 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2491 when N_Package_Renaming_Declaration
=>
2492 Write_Indent_Str_Sloc
("package ");
2493 Sprint_Node
(Defining_Unit_Name
(Node
));
2494 Write_Str_With_Col_Check
(" renames ");
2495 Sprint_Node
(Name
(Node
));
2498 when N_Package_Specification
=>
2499 Write_Str_With_Col_Check_Sloc
("package ");
2500 Sprint_Node
(Defining_Unit_Name
(Node
));
2502 if Nkind_In
(Parent
(Node
), N_Package_Declaration
,
2503 N_Generic_Package_Declaration
)
2504 and then Has_Aspects
(Parent
(Node
))
2506 Sprint_Aspect_Specifications
2507 (Parent
(Node
), Semicolon
=> False);
2511 Sprint_Indented_List
(Visible_Declarations
(Node
));
2513 if Present
(Private_Declarations
(Node
)) then
2514 Write_Indent_Str
("private");
2515 Sprint_Indented_List
(Private_Declarations
(Node
));
2518 Write_Indent_Str
("end ");
2519 Sprint_Node
(Defining_Unit_Name
(Node
));
2521 when N_Parameter_Association
=>
2522 Sprint_Node_Sloc
(Selector_Name
(Node
));
2524 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2526 when N_Parameter_Specification
=>
2529 if Write_Identifiers
(Node
) then
2532 if In_Present
(Node
) then
2533 Write_Str_With_Col_Check
("in ");
2536 if Out_Present
(Node
) then
2537 Write_Str_With_Col_Check
("out ");
2540 -- Ada 2005 (AI-231): Parameter specification may carry null
2541 -- exclusion. Do not print it now if this is an access formal,
2542 -- it is emitted when the access definition is displayed.
2544 if Null_Exclusion_Present
(Node
)
2545 and then Nkind
(Parameter_Type
(Node
))
2546 /= N_Access_Definition
2548 Write_Str
("not null ");
2551 Sprint_Node
(Parameter_Type
(Node
));
2553 if Present
(Expression
(Node
)) then
2555 Sprint_Node
(Expression
(Node
));
2561 when N_Pop_Constraint_Error_Label
=>
2562 Write_Indent_Str
("%pop_constraint_error_label");
2564 when N_Pop_Program_Error_Label
=>
2565 Write_Indent_Str
("%pop_program_error_label");
2567 when N_Pop_Storage_Error_Label
=>
2568 Write_Indent_Str
("%pop_storage_error_label");
2570 when N_Private_Extension_Declaration
=>
2571 Write_Indent_Str_Sloc
("type ");
2572 Write_Id
(Defining_Identifier
(Node
));
2574 if Present
(Discriminant_Specifications
(Node
)) then
2575 Write_Discr_Specs
(Node
);
2576 elsif Unknown_Discriminants_Present
(Node
) then
2577 Write_Str_With_Col_Check
("(<>)");
2580 Write_Str_With_Col_Check
(" is new ");
2581 Sprint_Node
(Subtype_Indication
(Node
));
2583 if Present
(Interface_List
(Node
)) then
2584 Write_Str_With_Col_Check
(" and ");
2585 Sprint_And_List
(Interface_List
(Node
));
2588 Write_Str_With_Col_Check
(" with private;");
2590 when N_Private_Type_Declaration
=>
2591 Write_Indent_Str_Sloc
("type ");
2592 Write_Id
(Defining_Identifier
(Node
));
2594 if Present
(Discriminant_Specifications
(Node
)) then
2595 Write_Discr_Specs
(Node
);
2596 elsif Unknown_Discriminants_Present
(Node
) then
2597 Write_Str_With_Col_Check
("(<>)");
2602 if Tagged_Present
(Node
) then
2603 Write_Str_With_Col_Check
("tagged ");
2606 if Limited_Present
(Node
) then
2607 Write_Str_With_Col_Check
("limited ");
2610 Write_Str_With_Col_Check
("private;");
2612 when N_Push_Constraint_Error_Label
=>
2613 Write_Indent_Str
("%push_constraint_error_label (");
2615 if Present
(Exception_Label
(Node
)) then
2616 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2621 when N_Push_Program_Error_Label
=>
2622 Write_Indent_Str
("%push_program_error_label (");
2624 if Present
(Exception_Label
(Node
)) then
2625 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2630 when N_Push_Storage_Error_Label
=>
2631 Write_Indent_Str
("%push_storage_error_label (");
2633 if Present
(Exception_Label
(Node
)) then
2634 Write_Name_With_Col_Check
(Chars
(Exception_Label
(Node
)));
2640 Write_Indent_Str_Sloc
("pragma ");
2641 Write_Name_With_Col_Check
(Pragma_Name
(Node
));
2643 if Present
(Pragma_Argument_Associations
(Node
)) then
2644 Sprint_Opt_Paren_Comma_List
2645 (Pragma_Argument_Associations
(Node
));
2650 when N_Pragma_Argument_Association
=>
2653 if Chars
(Node
) /= No_Name
then
2654 Write_Name_With_Col_Check
(Chars
(Node
));
2658 Sprint_Node
(Expression
(Node
));
2660 when N_Procedure_Call_Statement
=>
2663 Write_Subprogram_Name
(Name
(Node
));
2664 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2667 when N_Procedure_Instantiation
=>
2668 Write_Indent_Str_Sloc
("procedure ");
2669 Sprint_Node
(Defining_Unit_Name
(Node
));
2670 Write_Str_With_Col_Check
(" is new ");
2671 Sprint_Node
(Name
(Node
));
2672 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2675 when N_Procedure_Specification
=>
2676 Write_Str_With_Col_Check_Sloc
("procedure ");
2677 Sprint_Node
(Defining_Unit_Name
(Node
));
2678 Write_Param_Specs
(Node
);
2680 when N_Protected_Body
=>
2681 Write_Indent_Str_Sloc
("protected body ");
2682 Write_Id
(Defining_Identifier
(Node
));
2684 Sprint_Indented_List
(Declarations
(Node
));
2685 Write_Indent_Str
("end ");
2686 Write_Id
(Defining_Identifier
(Node
));
2689 when N_Protected_Body_Stub
=>
2690 Write_Indent_Str_Sloc
("protected body ");
2691 Write_Id
(Defining_Identifier
(Node
));
2692 Write_Str_With_Col_Check
(" is separate;");
2694 when N_Protected_Definition
=>
2696 Sprint_Indented_List
(Visible_Declarations
(Node
));
2698 if Present
(Private_Declarations
(Node
)) then
2699 Write_Indent_Str
("private");
2700 Sprint_Indented_List
(Private_Declarations
(Node
));
2703 Write_Indent_Str
("end ");
2705 when N_Protected_Type_Declaration
=>
2706 Write_Indent_Str_Sloc
("protected type ");
2707 Sprint_Node
(Defining_Identifier
(Node
));
2708 Write_Discr_Specs
(Node
);
2710 if Present
(Interface_List
(Node
)) then
2711 Write_Str
(" is new ");
2712 Sprint_And_List
(Interface_List
(Node
));
2713 Write_Str
(" with ");
2718 Sprint_Node
(Protected_Definition
(Node
));
2719 Write_Id
(Defining_Identifier
(Node
));
2722 when N_Qualified_Expression
=>
2723 Sprint_Node
(Subtype_Mark
(Node
));
2724 Write_Char_Sloc
(''');
2726 -- Print expression, make sure we have at least one level of
2727 -- parentheses around the expression. For cases of qualified
2728 -- expressions in the source, this is always the case, but
2729 -- for generated qualifications, there may be no explicit
2730 -- parentheses present.
2732 if Paren_Count
(Expression
(Node
)) /= 0 then
2733 Sprint_Node
(Expression
(Node
));
2737 Sprint_Node
(Expression
(Node
));
2739 -- Odd case, for the qualified expressions used in machine
2740 -- code the argument may be a procedure call, resulting in
2741 -- a junk semicolon before the right parent, get rid of it.
2743 Write_Erase_Char
(';');
2745 -- Now we can add the terminating right paren
2750 when N_Quantified_Expression
=>
2753 if All_Present
(Node
) then
2754 Write_Str
(" all ");
2756 Write_Str
(" some ");
2759 if Present
(Iterator_Specification
(Node
)) then
2760 Sprint_Node
(Iterator_Specification
(Node
));
2762 Sprint_Node
(Loop_Parameter_Specification
(Node
));
2766 Sprint_Node
(Condition
(Node
));
2768 when N_Raise_Expression
=>
2770 Has_Parens
: constant Boolean := Paren_Count
(Node
) > 0;
2773 -- The syntax for raise_expression does not include parentheses
2774 -- but sometimes parentheses are required, so unconditionally
2775 -- generate them here unless already present.
2777 if not Has_Parens
then
2781 Write_Str_With_Col_Check_Sloc
("raise ");
2782 Sprint_Node
(Name
(Node
));
2784 if Present
(Expression
(Node
)) then
2785 Write_Str_With_Col_Check
(" with ");
2786 Sprint_Node
(Expression
(Node
));
2789 if not Has_Parens
then
2794 when N_Raise_Constraint_Error
=>
2796 -- This node can be used either as a subexpression or as a
2797 -- statement form. The following test is a reasonably reliable
2798 -- way to distinguish the two cases.
2800 if Is_List_Member
(Node
)
2801 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2806 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2807 Write_Condition_And_Reason
(Node
);
2809 when N_Raise_Program_Error
=>
2811 -- This node can be used either as a subexpression or as a
2812 -- statement form. The following test is a reasonably reliable
2813 -- way to distinguish the two cases.
2815 if Is_List_Member
(Node
)
2816 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2821 Write_Str_With_Col_Check_Sloc
("[program_error");
2822 Write_Condition_And_Reason
(Node
);
2824 when N_Raise_Storage_Error
=>
2826 -- This node can be used either as a subexpression or as a
2827 -- statement form. The following test is a reasonably reliable
2828 -- way to distinguish the two cases.
2830 if Is_List_Member
(Node
)
2831 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2836 Write_Str_With_Col_Check_Sloc
("[storage_error");
2837 Write_Condition_And_Reason
(Node
);
2839 when N_Raise_Statement
=>
2840 Write_Indent_Str_Sloc
("raise ");
2841 Sprint_Node
(Name
(Node
));
2845 Sprint_Node
(Low_Bound
(Node
));
2846 Write_Str_Sloc
(" .. ");
2847 Sprint_Node
(High_Bound
(Node
));
2848 Update_Itype
(Node
);
2850 when N_Range_Constraint
=>
2851 Write_Str_With_Col_Check_Sloc
("range ");
2852 Sprint_Node
(Range_Expression
(Node
));
2854 when N_Real_Literal
=>
2855 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
2857 when N_Real_Range_Specification
=>
2858 Write_Str_With_Col_Check_Sloc
("range ");
2859 Sprint_Node
(Low_Bound
(Node
));
2861 Sprint_Node
(High_Bound
(Node
));
2863 when N_Record_Definition
=>
2864 if Abstract_Present
(Node
) then
2865 Write_Str_With_Col_Check
("abstract ");
2868 if Tagged_Present
(Node
) then
2869 Write_Str_With_Col_Check
("tagged ");
2872 if Limited_Present
(Node
) then
2873 Write_Str_With_Col_Check
("limited ");
2876 if Null_Present
(Node
) then
2877 Write_Str_With_Col_Check_Sloc
("null record");
2880 Write_Str_With_Col_Check_Sloc
("record");
2881 Sprint_Node
(Component_List
(Node
));
2882 Write_Indent_Str
("end record");
2885 when N_Record_Representation_Clause
=>
2886 Write_Indent_Str_Sloc
("for ");
2887 Sprint_Node
(Identifier
(Node
));
2888 Write_Str_With_Col_Check
(" use record ");
2890 if Present
(Mod_Clause
(Node
)) then
2891 Sprint_Node
(Mod_Clause
(Node
));
2894 Sprint_Indented_List
(Component_Clauses
(Node
));
2895 Write_Indent_Str
("end record;");
2898 Sprint_Node
(Prefix
(Node
));
2899 Write_Str_With_Col_Check_Sloc
("'reference");
2901 when N_Requeue_Statement
=>
2902 Write_Indent_Str_Sloc
("requeue ");
2903 Sprint_Node
(Name
(Node
));
2905 if Abort_Present
(Node
) then
2906 Write_Str_With_Col_Check
(" with abort");
2911 -- Don't we want to print more detail???
2913 -- Doc of this extended syntax belongs in sinfo.ads and/or
2916 when N_SCIL_Dispatch_Table_Tag_Init
=>
2917 Write_Indent_Str
("[N_SCIL_Dispatch_Table_Tag_Init]");
2919 when N_SCIL_Dispatching_Call
=>
2920 Write_Indent_Str
("[N_SCIL_Dispatching_Node]");
2922 when N_SCIL_Membership_Test
=>
2923 Write_Indent_Str
("[N_SCIL_Membership_Test]");
2925 when N_Simple_Return_Statement
=>
2926 if Present
(Expression
(Node
)) then
2927 Write_Indent_Str_Sloc
("return ");
2928 Sprint_Node
(Expression
(Node
));
2931 Write_Indent_Str_Sloc
("return;");
2934 when N_Selective_Accept
=>
2935 Write_Indent_Str_Sloc
("select");
2940 Alt_Node
:= First
(Select_Alternatives
(Node
));
2943 Sprint_Node
(Alt_Node
);
2946 exit when No
(Alt_Node
);
2947 Write_Indent_Str
("or");
2951 if Present
(Else_Statements
(Node
)) then
2952 Write_Indent_Str
("else");
2953 Sprint_Indented_List
(Else_Statements
(Node
));
2956 Write_Indent_Str
("end select;");
2958 when N_Signed_Integer_Type_Definition
=>
2959 Write_Str_With_Col_Check_Sloc
("range ");
2960 Sprint_Node
(Low_Bound
(Node
));
2962 Sprint_Node
(High_Bound
(Node
));
2964 when N_Single_Protected_Declaration
=>
2965 Write_Indent_Str_Sloc
("protected ");
2966 Write_Id
(Defining_Identifier
(Node
));
2968 Sprint_Node
(Protected_Definition
(Node
));
2969 Write_Id
(Defining_Identifier
(Node
));
2972 when N_Single_Task_Declaration
=>
2973 Write_Indent_Str_Sloc
("task ");
2974 Sprint_Node
(Defining_Identifier
(Node
));
2976 if Present
(Task_Definition
(Node
)) then
2978 Sprint_Node
(Task_Definition
(Node
));
2983 when N_Selected_Component
=>
2984 Sprint_Node
(Prefix
(Node
));
2985 Write_Char_Sloc
('.');
2986 Sprint_Node
(Selector_Name
(Node
));
2990 Sprint_Node
(Prefix
(Node
));
2991 Write_Str_With_Col_Check
(" (");
2992 Sprint_Node
(Discrete_Range
(Node
));
2995 when N_String_Literal
=>
2996 if String_Length
(Strval
(Node
)) + Column
> Sprint_Line_Limit
then
2997 Write_Indent_Str
(" ");
3001 Write_String_Table_Entry
(Strval
(Node
));
3003 when N_Subprogram_Body
=>
3005 -- Output extra blank line unless we are in freeze actions
3007 if Freeze_Indent
= 0 then
3013 if Present
(Corresponding_Spec
(Node
)) then
3014 Sprint_Node_Sloc
(Parent
(Corresponding_Spec
(Node
)));
3016 Sprint_Node_Sloc
(Specification
(Node
));
3021 Sprint_Indented_List
(Declarations
(Node
));
3022 Write_Indent_Str
("begin");
3023 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3025 Write_Indent_Str
("end ");
3028 (Handled_Statement_Sequence
(Node
),
3029 Defining_Unit_Name
(Specification
(Node
)));
3032 if Is_List_Member
(Node
)
3033 and then Present
(Next
(Node
))
3034 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
3039 when N_Subprogram_Body_Stub
=>
3041 Sprint_Node_Sloc
(Specification
(Node
));
3042 Write_Str_With_Col_Check
(" is separate;");
3044 when N_Subprogram_Declaration
=>
3046 Sprint_Node_Sloc
(Specification
(Node
));
3048 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
3049 and then Null_Present
(Specification
(Node
))
3051 Write_Str_With_Col_Check
(" is null");
3056 when N_Subprogram_Info
=>
3057 Sprint_Node
(Identifier
(Node
));
3058 Write_Str_With_Col_Check_Sloc
("'subprogram_info");
3060 when N_Subprogram_Renaming_Declaration
=>
3062 Sprint_Node
(Specification
(Node
));
3063 Write_Str_With_Col_Check_Sloc
(" renames ");
3064 Sprint_Node
(Name
(Node
));
3067 when N_Subtype_Declaration
=>
3068 Write_Indent_Str_Sloc
("subtype ");
3069 Sprint_Node
(Defining_Identifier
(Node
));
3072 -- Ada 2005 (AI-231)
3074 if Null_Exclusion_Present
(Node
) then
3075 Write_Str
("not null ");
3078 Sprint_Node
(Subtype_Indication
(Node
));
3081 when N_Subtype_Indication
=>
3082 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
3084 Sprint_Node
(Constraint
(Node
));
3087 Write_Indent_Str_Sloc
("separate (");
3088 Sprint_Node
(Name
(Node
));
3091 Sprint_Node
(Proper_Body
(Node
));
3094 Write_Indent_Str_Sloc
("task body ");
3095 Write_Id
(Defining_Identifier
(Node
));
3097 Sprint_Indented_List
(Declarations
(Node
));
3098 Write_Indent_Str
("begin");
3099 Sprint_Node
(Handled_Statement_Sequence
(Node
));
3100 Write_Indent_Str
("end ");
3102 (Handled_Statement_Sequence
(Node
), Defining_Identifier
(Node
));
3105 when N_Task_Body_Stub
=>
3106 Write_Indent_Str_Sloc
("task body ");
3107 Write_Id
(Defining_Identifier
(Node
));
3108 Write_Str_With_Col_Check
(" is separate;");
3110 when N_Task_Definition
=>
3112 Sprint_Indented_List
(Visible_Declarations
(Node
));
3114 if Present
(Private_Declarations
(Node
)) then
3115 Write_Indent_Str
("private");
3116 Sprint_Indented_List
(Private_Declarations
(Node
));
3119 Write_Indent_Str
("end ");
3120 Sprint_End_Label
(Node
, Defining_Identifier
(Parent
(Node
)));
3122 when N_Task_Type_Declaration
=>
3123 Write_Indent_Str_Sloc
("task type ");
3124 Sprint_Node
(Defining_Identifier
(Node
));
3125 Write_Discr_Specs
(Node
);
3127 if Present
(Interface_List
(Node
)) then
3128 Write_Str
(" is new ");
3129 Sprint_And_List
(Interface_List
(Node
));
3132 if Present
(Task_Definition
(Node
)) then
3133 if No
(Interface_List
(Node
)) then
3136 Write_Str
(" with ");
3139 Sprint_Node
(Task_Definition
(Node
));
3144 when N_Terminate_Alternative
=>
3145 Sprint_Node_List
(Pragmas_Before
(Node
));
3148 if Present
(Condition
(Node
)) then
3149 Write_Str_With_Col_Check
("when ");
3150 Sprint_Node
(Condition
(Node
));
3154 Write_Str_With_Col_Check_Sloc
("terminate;");
3155 Sprint_Node_List
(Pragmas_After
(Node
));
3157 when N_Timed_Entry_Call
=>
3158 Write_Indent_Str_Sloc
("select");
3160 Sprint_Node
(Entry_Call_Alternative
(Node
));
3162 Write_Indent_Str
("or");
3164 Sprint_Node
(Delay_Alternative
(Node
));
3166 Write_Indent_Str
("end select;");
3168 when N_Triggering_Alternative
=>
3169 Sprint_Node_List
(Pragmas_Before
(Node
));
3170 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
3171 Sprint_Node_List
(Statements
(Node
));
3173 when N_Type_Conversion
=>
3175 Sprint_Node
(Subtype_Mark
(Node
));
3178 if Conversion_OK
(Node
) then
3182 if Float_Truncate
(Node
) then
3186 if Rounded_Result
(Node
) then
3191 Sprint_Node
(Expression
(Node
));
3194 when N_Unchecked_Expression
=>
3197 Sprint_Node_Sloc
(Expression
(Node
));
3200 when N_Unchecked_Type_Conversion
=>
3201 Sprint_Node
(Subtype_Mark
(Node
));
3203 Write_Str_With_Col_Check
("(");
3204 Sprint_Node_Sloc
(Expression
(Node
));
3207 when N_Unconstrained_Array_Definition
=>
3208 Write_Str_With_Col_Check_Sloc
("array (");
3213 Node1
:= First
(Subtype_Marks
(Node
));
3215 Sprint_Node
(Node1
);
3216 Write_Str_With_Col_Check
(" range <>");
3218 exit when Node1
= Empty
;
3223 Write_Str
(") of ");
3224 Sprint_Node
(Component_Definition
(Node
));
3226 when N_Unused_At_Start | N_Unused_At_End
=>
3227 Write_Indent_Str
("***** Error, unused node encountered *****");
3230 when N_Use_Package_Clause
=>
3231 Write_Indent_Str_Sloc
("use ");
3232 Sprint_Comma_List
(Names
(Node
));
3235 when N_Use_Type_Clause
=>
3236 Write_Indent_Str_Sloc
("use type ");
3237 Sprint_Comma_List
(Subtype_Marks
(Node
));
3240 when N_Validate_Unchecked_Conversion
=>
3241 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
3242 Sprint_Node
(Source_Type
(Node
));
3244 Sprint_Node
(Target_Type
(Node
));
3248 Write_Indent_Str_Sloc
("when ");
3249 Sprint_Bar_List
(Discrete_Choices
(Node
));
3251 Sprint_Node
(Component_List
(Node
));
3253 when N_Variant_Part
=>
3255 Write_Indent_Str_Sloc
("case ");
3256 Sprint_Node
(Name
(Node
));
3258 Sprint_Indented_List
(Variants
(Node
));
3259 Write_Indent_Str
("end case");
3262 when N_With_Clause
=>
3264 -- Special test, if we are dumping the original tree only,
3265 -- then we want to eliminate the bogus with clauses that
3266 -- correspond to the non-existent children of Text_IO.
3268 if Dump_Original_Only
3269 and then Is_Text_IO_Kludge_Unit
(Name
(Node
))
3273 -- Normal case, output the with clause
3276 if First_Name
(Node
) or else not Dump_Original_Only
then
3278 -- Ada 2005 (AI-50217): Print limited with_clauses
3280 if Private_Present
(Node
) and Limited_Present
(Node
) then
3281 Write_Indent_Str
("limited private with ");
3283 elsif Private_Present
(Node
) then
3284 Write_Indent_Str
("private with ");
3286 elsif Limited_Present
(Node
) then
3287 Write_Indent_Str
("limited with ");
3290 Write_Indent_Str
("with ");
3297 Sprint_Node_Sloc
(Name
(Node
));
3299 if Last_Name
(Node
) or else not Dump_Original_Only
then
3305 -- Print aspects, except for special case of package declaration,
3306 -- where the aspects are printed inside the package specification.
3308 if Has_Aspects
(Node
)
3309 and then not Nkind_In
(Node
, N_Package_Declaration
,
3310 N_Generic_Package_Declaration
)
3312 Sprint_Aspect_Specifications
(Node
, Semicolon
=> True);
3315 if Nkind
(Node
) in N_Subexpr
3316 and then Do_Range_Check
(Node
)
3321 for J
in 1 .. Paren_Count
(Node
) loop
3325 Dump_Node
:= Save_Dump_Node
;
3326 end Sprint_Node_Actual
;
3328 ----------------------
3329 -- Sprint_Node_List --
3330 ----------------------
3332 procedure Sprint_Node_List
(List
: List_Id
; New_Lines
: Boolean := False) is
3336 if Is_Non_Empty_List
(List
) then
3337 Node
:= First
(List
);
3342 exit when Node
= Empty
;
3346 if New_Lines
and then Column
/= 1 then
3349 end Sprint_Node_List
;
3351 ----------------------
3352 -- Sprint_Node_Sloc --
3353 ----------------------
3355 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
3359 if Debug_Generated_Code
and then Present
(Dump_Node
) then
3360 Set_Sloc
(Dump_Node
, Sloc
(Node
));
3363 end Sprint_Node_Sloc
;
3365 ---------------------
3366 -- Sprint_Opt_Node --
3367 ---------------------
3369 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
3371 if Present
(Node
) then
3375 end Sprint_Opt_Node
;
3377 --------------------------
3378 -- Sprint_Opt_Node_List --
3379 --------------------------
3381 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
3383 if Present
(List
) then
3384 Sprint_Node_List
(List
);
3386 end Sprint_Opt_Node_List
;
3388 ---------------------------------
3389 -- Sprint_Opt_Paren_Comma_List --
3390 ---------------------------------
3392 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
3394 if Is_Non_Empty_List
(List
) then
3396 Sprint_Paren_Comma_List
(List
);
3398 end Sprint_Opt_Paren_Comma_List
;
3400 -----------------------------
3401 -- Sprint_Paren_Comma_List --
3402 -----------------------------
3404 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
3406 Node_Exists
: Boolean := False;
3410 if Is_Non_Empty_List
(List
) then
3412 if Dump_Original_Only
then
3414 while Present
(N
) loop
3415 if not Is_Rewrite_Insertion
(N
) then
3416 Node_Exists
:= True;
3423 if not Node_Exists
then
3428 Write_Str_With_Col_Check
("(");
3429 Sprint_Comma_List
(List
);
3432 end Sprint_Paren_Comma_List
;
3434 ----------------------
3435 -- Sprint_Right_Opnd --
3436 ----------------------
3438 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
3439 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
3442 if Paren_Count
(Opnd
) /= 0
3443 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
3452 end Sprint_Right_Opnd
;
3458 procedure Update_Itype
(Node
: Node_Id
) is
3460 if Present
(Etype
(Node
))
3461 and then Is_Itype
(Etype
(Node
))
3462 and then Debug_Generated_Code
3464 Set_Sloc
(Etype
(Node
), Sloc
(Node
));
3468 ---------------------
3469 -- Write_Char_Sloc --
3470 ---------------------
3472 procedure Write_Char_Sloc
(C
: Character) is
3474 if Debug_Generated_Code
and then C
/= ' ' then
3479 end Write_Char_Sloc
;
3481 --------------------------------
3482 -- Write_Condition_And_Reason --
3483 --------------------------------
3485 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
3486 Cond
: constant Node_Id
:= Condition
(Node
);
3487 Image
: constant String := RT_Exception_Code
'Image
3488 (RT_Exception_Code
'Val
3489 (UI_To_Int
(Reason
(Node
))));
3492 if Present
(Cond
) then
3494 -- If condition is a single entity, or NOT with a single entity,
3495 -- output all on one line, since it will likely fit just fine.
3497 if Is_Entity_Name
(Cond
)
3498 or else (Nkind
(Cond
) = N_Op_Not
3499 and then Is_Entity_Name
(Right_Opnd
(Cond
)))
3501 Write_Str_With_Col_Check
(" when ");
3505 -- Otherwise for more complex condition, multiple lines
3508 Write_Str_With_Col_Check
(" when");
3509 Indent
:= Indent
+ 2;
3513 Indent
:= Indent
- 2;
3516 -- If no condition, just need a space (all on one line)
3526 for J
in 4 .. Image
'Last loop
3527 if Image
(J
) = '_' then
3530 Write_Char
(Fold_Lower
(Image
(J
)));
3535 end Write_Condition_And_Reason
;
3537 --------------------------------
3538 -- Write_Corresponding_Source --
3539 --------------------------------
3541 procedure Write_Corresponding_Source
(S
: String) is
3543 Src
: Source_Buffer_Ptr
;
3546 -- Ignore if not in dump source text mode, or if in freeze actions
3548 if Dump_Source_Text
and then Freeze_Indent
= 0 then
3550 -- Ignore null string
3556 -- Ignore space or semicolon at end of given string
3558 if S
(S
'Last) = ' ' or else S
(S
'Last) = ';' then
3559 Write_Corresponding_Source
(S
(S
'First .. S
'Last - 1));
3563 -- Loop to look at next lines not yet printed in source file
3566 Last_Line_Printed
+ 1 .. Last_Source_Line
(Current_Source_File
)
3568 Src
:= Source_Text
(Current_Source_File
);
3569 Loc
:= Line_Start
(L
, Current_Source_File
);
3571 -- If comment, keep looking
3573 if Src
(Loc
.. Loc
+ 1) = "--" then
3576 -- Search to first non-blank
3579 while Src
(Loc
) not in Line_Terminator
loop
3583 if Src
(Loc
) /= ' ' and then Src
(Loc
) /= ASCII
.HT
then
3585 -- Loop through characters in string to see if we match
3587 for J
in S
'Range loop
3589 -- If mismatch, then not the case we are looking for
3591 if Src
(Loc
) /= S
(J
) then
3598 -- If we fall through, string matched, if white space or
3599 -- semicolon after the matched string, this is the case
3600 -- we are looking for.
3602 if Src
(Loc
) in Line_Terminator
3603 or else Src
(Loc
) = ' '
3604 or else Src
(Loc
) = ASCII
.HT
3605 or else Src
(Loc
) = ';'
3607 -- So output source lines up to and including this one
3609 Write_Source_Lines
(L
);
3618 -- Line was all blanks, or a comment line, keep looking
3622 end Write_Corresponding_Source
;
3624 -----------------------
3625 -- Write_Discr_Specs --
3626 -----------------------
3628 procedure Write_Discr_Specs
(N
: Node_Id
) is
3633 Specs
:= Discriminant_Specifications
(N
);
3635 if Present
(Specs
) then
3636 Write_Str_With_Col_Check
(" (");
3637 Spec
:= First
(Specs
);
3642 exit when Spec
= Empty
;
3644 -- Add semicolon, unless we are printing original tree and the
3645 -- next specification is part of a list (but not the first
3646 -- element of that list)
3648 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3655 end Write_Discr_Specs
;
3661 procedure Write_Ekind
(E
: Entity_Id
) is
3662 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
3665 Name_Len
:= S
'Length;
3666 Name_Buffer
(1 .. Name_Len
) := S
;
3667 Set_Casing
(Mixed_Case
);
3668 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3675 procedure Write_Id
(N
: Node_Id
) is
3677 -- Deal with outputting Itype
3679 -- Note: if we are printing the full tree with -gnatds, then we may
3680 -- end up picking up the Associated_Node link from a generic template
3681 -- here which overlaps the Entity field, but as documented, Write_Itype
3682 -- is defended against junk calls.
3684 if Nkind
(N
) in N_Entity
then
3686 elsif Nkind
(N
) in N_Has_Entity
then
3687 Write_Itype
(Entity
(N
));
3690 -- Case of a defining identifier
3692 if Nkind
(N
) = N_Defining_Identifier
then
3694 -- If defining identifier has an interface name (and no
3695 -- address clause), then we output the interface name.
3697 if (Is_Imported
(N
) or else Is_Exported
(N
))
3698 and then Present
(Interface_Name
(N
))
3699 and then No
(Address_Clause
(N
))
3701 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
3702 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3704 -- If no interface name (or inactive because there was
3705 -- an address clause), then just output the Chars name.
3708 Write_Name_With_Col_Check
(Chars
(N
));
3711 -- Case of selector of an expanded name where the expanded name
3712 -- has an associated entity, output this entity. Check that the
3713 -- entity or associated node is of the right kind, see above.
3715 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
3716 and then Selector_Name
(Parent
(N
)) = N
3717 and then Present
(Entity_Or_Associated_Node
(Parent
(N
)))
3718 and then Nkind
(Entity
(Parent
(N
))) in N_Entity
3720 Write_Id
(Entity
(Parent
(N
)));
3722 -- For any other node with an associated entity, output it
3724 elsif Nkind
(N
) in N_Has_Entity
3725 and then Present
(Entity_Or_Associated_Node
(N
))
3726 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
3728 Write_Id
(Entity
(N
));
3730 -- All other cases, we just print the Chars field
3733 Write_Name_With_Col_Check
(Chars
(N
));
3737 -----------------------
3738 -- Write_Identifiers --
3739 -----------------------
3741 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
3743 Sprint_Node
(Defining_Identifier
(Node
));
3744 Update_Itype
(Defining_Identifier
(Node
));
3746 -- The remainder of the declaration must be printed unless we are
3747 -- printing the original tree and this is not the last identifier
3750 not Dump_Original_Only
or else not More_Ids
(Node
);
3752 end Write_Identifiers
;
3754 ------------------------
3755 -- Write_Implicit_Def --
3756 ------------------------
3758 procedure Write_Implicit_Def
(E
: Entity_Id
) is
3763 when E_Array_Subtype
=>
3764 Write_Str_With_Col_Check
("subtype ");
3766 Write_Str_With_Col_Check
(" is ");
3767 Write_Id
(Base_Type
(E
));
3768 Write_Str_With_Col_Check
(" (");
3770 Ind
:= First_Index
(E
);
3771 while Present
(Ind
) loop
3775 if Present
(Ind
) then
3782 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
3783 Write_Str_With_Col_Check
("subtype ");
3786 Write_Id
(Etype
(E
));
3787 Write_Str_With_Col_Check
(" range ");
3788 Sprint_Node
(Scalar_Range
(E
));
3792 Write_Str_With_Col_Check
("type ");
3794 Write_Str_With_Col_Check
(" is <");
3799 end Write_Implicit_Def
;
3805 procedure Write_Indent
is
3806 Loc
: constant Source_Ptr
:= Sloc
(Dump_Node
);
3809 if Indent_Annull_Flag
then
3810 Indent_Annull_Flag
:= False;
3812 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3813 -- label declarations, since they typically have the sloc of the
3814 -- corresponding label, which really messes up the -gnatL output.
3817 and then Loc
> No_Location
3818 and then Nkind
(Dump_Node
) /= N_Implicit_Label_Declaration
3820 if Get_Source_File_Index
(Loc
) = Current_Source_File
then
3822 (Get_Physical_Line_Number
(Sloc
(Dump_Node
)));
3828 for J
in 1 .. Indent
loop
3834 ------------------------------
3835 -- Write_Indent_Identifiers --
3836 ------------------------------
3838 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
3840 -- We need to start a new line for every node, except in the case
3841 -- where we are printing the original tree and this is not the first
3842 -- defining identifier in the list.
3844 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3847 -- If printing original tree and this is not the first defining
3848 -- identifier in the list, then the previous call to this procedure
3849 -- printed only the name, and we add a comma to separate the names.
3855 Sprint_Node
(Defining_Identifier
(Node
));
3857 -- The remainder of the declaration must be printed unless we are
3858 -- printing the original tree and this is not the last identifier
3861 not Dump_Original_Only
or else not More_Ids
(Node
);
3862 end Write_Indent_Identifiers
;
3864 -----------------------------------
3865 -- Write_Indent_Identifiers_Sloc --
3866 -----------------------------------
3868 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
3870 -- We need to start a new line for every node, except in the case
3871 -- where we are printing the original tree and this is not the first
3872 -- defining identifier in the list.
3874 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3877 -- If printing original tree and this is not the first defining
3878 -- identifier in the list, then the previous call to this procedure
3879 -- printed only the name, and we add a comma to separate the names.
3886 Sprint_Node
(Defining_Identifier
(Node
));
3888 -- The remainder of the declaration must be printed unless we are
3889 -- printing the original tree and this is not the last identifier
3891 return not Dump_Original_Only
or else not More_Ids
(Node
);
3892 end Write_Indent_Identifiers_Sloc
;
3894 ----------------------
3895 -- Write_Indent_Str --
3896 ----------------------
3898 procedure Write_Indent_Str
(S
: String) is
3900 Write_Corresponding_Source
(S
);
3903 end Write_Indent_Str
;
3905 ---------------------------
3906 -- Write_Indent_Str_Sloc --
3907 ---------------------------
3909 procedure Write_Indent_Str_Sloc
(S
: String) is
3911 Write_Corresponding_Source
(S
);
3914 end Write_Indent_Str_Sloc
;
3920 procedure Write_Itype
(Typ
: Entity_Id
) is
3922 procedure Write_Header
(T
: Boolean := True);
3923 -- Write type if T is True, subtype if T is false
3929 procedure Write_Header
(T
: Boolean := True) is
3932 Write_Str
("[type ");
3934 Write_Str
("[subtype ");
3937 Write_Name_With_Col_Check
(Chars
(Typ
));
3941 -- Start of processing for Write_Itype
3944 if Nkind
(Typ
) in N_Entity
3945 and then Is_Itype
(Typ
)
3946 and then not Itype_Printed
(Typ
)
3948 -- Itype to be printed
3951 B
: constant Node_Id
:= Etype
(Typ
);
3953 P
: constant Node_Id
:= Parent
(Typ
);
3955 S
: constant Saved_Output_Buffer
:= Save_Output_Buffer
;
3956 -- Save current output buffer
3958 Old_Sloc
: Source_Ptr
;
3959 -- Save sloc of related node, so it is not modified when
3960 -- printing with -gnatD.
3963 -- Write indentation at start of line
3965 for J
in 1 .. Indent
loop
3969 -- If we have a constructed declaration for the itype, print it
3972 and then Nkind
(P
) in N_Declaration
3973 and then Defining_Entity
(P
) = Typ
3975 -- We must set Itype_Printed true before the recursive call to
3976 -- print the node, otherwise we get an infinite recursion!
3978 Set_Itype_Printed
(Typ
, True);
3980 -- Write the declaration enclosed in [], avoiding new line
3981 -- at start of declaration, and semicolon at end.
3983 -- Note: The itype may be imported from another unit, in which
3984 -- case we do not want to modify the Sloc of the declaration.
3985 -- Otherwise the itype may appear to be in the current unit,
3986 -- and the back-end will reject a reference out of scope.
3989 Indent_Annull_Flag
:= True;
3990 Old_Sloc
:= Sloc
(P
);
3992 Set_Sloc
(P
, Old_Sloc
);
3993 Write_Erase_Char
(';');
3995 -- If no constructed declaration, then we have to concoct the
3996 -- source corresponding to the type entity that we have at hand.
4001 -- Access types and subtypes
4004 Write_Header
(Ekind
(Typ
) = E_Access_Type
);
4006 if Can_Never_Be_Null
(Typ
) then
4007 Write_Str
("not null ");
4010 Write_Str
("access ");
4012 if Is_Access_Constant
(Typ
) then
4013 Write_Str
("constant ");
4016 Write_Id
(Directly_Designated_Type
(Typ
));
4018 -- Array types and string types
4020 when E_Array_Type | E_String_Type
=>
4022 Write_Str
("array (");
4024 X
:= First_Index
(Typ
);
4028 if not Is_Constrained
(Typ
) then
4029 Write_Str
(" range <>");
4037 Write_Str
(") of ");
4038 X
:= Component_Type
(Typ
);
4040 -- Preserve sloc of component type, which is defined
4041 -- elsewhere than the itype (see comment above).
4043 Old_Sloc
:= Sloc
(X
);
4045 Set_Sloc
(X
, Old_Sloc
);
4047 -- Array subtypes and string subtypes.
4048 -- Preserve Sloc of index subtypes, as above.
4050 when E_Array_Subtype | E_String_Subtype
=>
4051 Write_Header
(False);
4052 Write_Id
(Etype
(Typ
));
4055 X
:= First_Index
(Typ
);
4057 Old_Sloc
:= Sloc
(X
);
4059 Set_Sloc
(X
, Old_Sloc
);
4067 -- Signed integer types, and modular integer subtypes,
4068 -- and also enumeration subtypes.
4070 when E_Signed_Integer_Type |
4071 E_Signed_Integer_Subtype |
4072 E_Modular_Integer_Subtype |
4073 E_Enumeration_Subtype
=>
4075 Write_Header
(Ekind
(Typ
) = E_Signed_Integer_Type
);
4077 if Ekind
(Typ
) = E_Signed_Integer_Type
then
4083 -- Print bounds if different from base type
4086 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4087 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4092 -- B can either be a scalar type, in which case the
4093 -- declaration of Typ may constrain it with different
4094 -- bounds, or a private type, in which case we know
4095 -- that the declaration of Typ cannot have a scalar
4098 if Is_Scalar_Type
(B
) then
4099 LE
:= Type_Low_Bound
(B
);
4100 HE
:= Type_High_Bound
(B
);
4108 and then Nkind
(L
) = N_Integer_Literal
4109 and then Nkind
(H
) = N_Integer_Literal
4110 and then Nkind
(LE
) = N_Integer_Literal
4111 and then Nkind
(HE
) = N_Integer_Literal
4112 and then UI_Eq
(Intval
(L
), Intval
(LE
))
4113 and then UI_Eq
(Intval
(H
), Intval
(HE
)))
4118 Write_Str
(" range ");
4119 Sprint_Node
(Type_Low_Bound
(Typ
));
4121 Sprint_Node
(Type_High_Bound
(Typ
));
4125 -- Modular integer types
4127 when E_Modular_Integer_Type
=>
4130 Write_Uint_With_Col_Check
(Modulus
(Typ
), Auto
);
4132 -- Floating point types and subtypes
4134 when E_Floating_Point_Type |
4135 E_Floating_Point_Subtype
=>
4137 Write_Header
(Ekind
(Typ
) = E_Floating_Point_Type
);
4139 if Ekind
(Typ
) = E_Floating_Point_Type
then
4143 Write_Id
(Etype
(Typ
));
4145 if Digits_Value
(Typ
) /= Digits_Value
(Etype
(Typ
)) then
4146 Write_Str
(" digits ");
4147 Write_Uint_With_Col_Check
4148 (Digits_Value
(Typ
), Decimal
);
4151 -- Print bounds if not different from base type
4154 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
4155 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
4156 LE
: constant Node_Id
:= Type_Low_Bound
(B
);
4157 HE
: constant Node_Id
:= Type_High_Bound
(B
);
4160 if Nkind
(L
) = N_Real_Literal
4161 and then Nkind
(H
) = N_Real_Literal
4162 and then Nkind
(LE
) = N_Real_Literal
4163 and then Nkind
(HE
) = N_Real_Literal
4164 and then UR_Eq
(Realval
(L
), Realval
(LE
))
4165 and then UR_Eq
(Realval
(H
), Realval
(HE
))
4170 Write_Str
(" range ");
4171 Sprint_Node
(Type_Low_Bound
(Typ
));
4173 Sprint_Node
(Type_High_Bound
(Typ
));
4179 when E_Record_Subtype | E_Record_Subtype_With_Private
=>
4180 Write_Header
(False);
4181 Write_Str
("record");
4187 C
:= First_Entity
(Typ
);
4188 while Present
(C
) loop
4192 Write_Id
(Etype
(C
));
4198 Write_Indent_Str
(" end record");
4202 when E_Class_Wide_Type |
4203 E_Class_Wide_Subtype
=>
4204 Write_Header
(Ekind
(Typ
) = E_Class_Wide_Type
);
4205 Write_Name_With_Col_Check
(Chars
(Etype
(Typ
)));
4206 Write_Str
("'Class");
4210 when E_Subprogram_Type
=>
4213 if Etype
(Typ
) = Standard_Void_Type
then
4214 Write_Str
("procedure");
4216 Write_Str
("function");
4219 if Present
(First_Entity
(Typ
)) then
4226 Param
:= First_Entity
(Typ
);
4231 if Ekind
(Param
) = E_In_Out_Parameter
then
4232 Write_Str
("in out ");
4233 elsif Ekind
(Param
) = E_Out_Parameter
then
4237 Write_Id
(Etype
(Param
));
4238 Next_Entity
(Param
);
4239 exit when No
(Param
);
4247 if Etype
(Typ
) /= Standard_Void_Type
then
4248 Write_Str
(" return ");
4249 Write_Id
(Etype
(Typ
));
4252 when E_String_Literal_Subtype
=>
4254 LB
: constant Uint
:=
4255 Expr_Value
(String_Literal_Low_Bound
(Typ
));
4256 Len
: constant Uint
:=
4257 String_Literal_Length
(Typ
);
4259 Write_Str
("String (");
4260 Write_Int
(UI_To_Int
(LB
));
4262 Write_Int
(UI_To_Int
(LB
+ Len
) - 1);
4266 -- For all other Itypes, print ??? (fill in later)
4269 Write_Header
(True);
4275 -- Add terminating bracket and restore output buffer
4279 Restore_Output_Buffer
(S
);
4282 Set_Itype_Printed
(Typ
);
4286 -------------------------------
4287 -- Write_Name_With_Col_Check --
4288 -------------------------------
4290 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
4296 Get_Name_String
(N
);
4298 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4299 -- upper case letter, nnn is one or more digits and b is a lower case
4300 -- letter by C...b, so that listings do not depend on serial numbers.
4302 if Debug_Flag_II
then
4304 while J
< Name_Len
- 1 loop
4305 if Name_Buffer
(J
) in 'A' .. 'Z'
4306 and then Name_Buffer
(J
+ 1) in '0' .. '9'
4309 while K
< Name_Len
loop
4310 exit when Name_Buffer
(K
) not in '0' .. '9';
4314 if Name_Buffer
(K
) in 'a' .. 'z' then
4315 L
:= Name_Len
- K
+ 1;
4317 Name_Buffer
(J
+ 4 .. J
+ L
+ 3) :=
4318 Name_Buffer
(K
.. Name_Len
);
4319 Name_Buffer
(J
+ 1 .. J
+ 3) := "...";
4320 Name_Len
:= J
+ L
+ 3;
4333 -- Fall through for normal case
4335 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
4336 end Write_Name_With_Col_Check
;
4338 ------------------------------------
4339 -- Write_Name_With_Col_Check_Sloc --
4340 ------------------------------------
4342 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
4344 Get_Name_String
(N
);
4345 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
4346 end Write_Name_With_Col_Check_Sloc
;
4348 --------------------
4349 -- Write_Operator --
4350 --------------------
4352 procedure Write_Operator
(N
: Node_Id
; S
: String) is
4353 F
: Natural := S
'First;
4354 T
: Natural := S
'Last;
4357 -- If no overflow check, just write string out, and we are done
4359 if not Do_Overflow_Check
(N
) then
4362 -- If overflow check, we want to surround the operator with curly
4363 -- brackets, but not include spaces within the brackets.
4376 Write_Str_Sloc
(S
(F
.. T
));
4379 if S
(S
'Last) = ' ' then
4385 -----------------------
4386 -- Write_Param_Specs --
4387 -----------------------
4389 procedure Write_Param_Specs
(N
: Node_Id
) is
4395 Specs
:= Parameter_Specifications
(N
);
4397 if Is_Non_Empty_List
(Specs
) then
4398 Write_Str_With_Col_Check
(" (");
4399 Spec
:= First
(Specs
);
4403 Formal
:= Defining_Identifier
(Spec
);
4405 exit when Spec
= Empty
;
4407 -- Add semicolon, unless we are printing original tree and the
4408 -- next specification is part of a list (but not the first element
4411 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
4416 -- Write out any extra formals
4418 while Present
(Extra_Formal
(Formal
)) loop
4419 Formal
:= Extra_Formal
(Formal
);
4421 Write_Name_With_Col_Check
(Chars
(Formal
));
4423 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
4428 end Write_Param_Specs
;
4430 -----------------------
4431 -- Write_Rewrite_Str --
4432 -----------------------
4434 procedure Write_Rewrite_Str
(S
: String) is
4436 if not Dump_Generated_Only
then
4437 if S
'Length = 3 and then S
= ">>>" then
4440 Write_Str_With_Col_Check
(S
);
4443 end Write_Rewrite_Str
;
4445 -----------------------
4446 -- Write_Source_Line --
4447 -----------------------
4449 procedure Write_Source_Line
(L
: Physical_Line_Number
) is
4451 Src
: Source_Buffer_Ptr
;
4455 if Dump_Source_Text
then
4456 Src
:= Source_Text
(Current_Source_File
);
4457 Loc
:= Line_Start
(L
, Current_Source_File
);
4460 -- See if line is a comment line, if not, and if not line one,
4461 -- precede with blank line.
4464 while Src
(Scn
) = ' ' or else Src
(Scn
) = ASCII
.HT
loop
4468 if (Src
(Scn
) in Line_Terminator
4469 or else Src
(Scn
.. Scn
+ 1) /= "--")
4475 -- Now write the source text of the line
4478 Write_Int
(Int
(L
));
4481 while Src
(Loc
) not in Line_Terminator
loop
4482 Write_Char
(Src
(Loc
));
4486 end Write_Source_Line
;
4488 ------------------------
4489 -- Write_Source_Lines --
4490 ------------------------
4492 procedure Write_Source_Lines
(L
: Physical_Line_Number
) is
4494 while Last_Line_Printed
< L
loop
4495 Last_Line_Printed
:= Last_Line_Printed
+ 1;
4496 Write_Source_Line
(Last_Line_Printed
);
4498 end Write_Source_Lines
;
4500 --------------------
4501 -- Write_Str_Sloc --
4502 --------------------
4504 procedure Write_Str_Sloc
(S
: String) is
4506 for J
in S
'Range loop
4507 Write_Char_Sloc
(S
(J
));
4511 ------------------------------
4512 -- Write_Str_With_Col_Check --
4513 ------------------------------
4515 procedure Write_Str_With_Col_Check
(S
: String) is
4517 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4518 Write_Indent_Str
(" ");
4520 if S
(S
'First) = ' ' then
4521 Write_Str
(S
(S
'First + 1 .. S
'Last));
4529 end Write_Str_With_Col_Check
;
4531 -----------------------------------
4532 -- Write_Str_With_Col_Check_Sloc --
4533 -----------------------------------
4535 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
4537 if Int
(S
'Last) + Column
> Sprint_Line_Limit
then
4538 Write_Indent_Str
(" ");
4540 if S
(S
'First) = ' ' then
4541 Write_Str_Sloc
(S
(S
'First + 1 .. S
'Last));
4549 end Write_Str_With_Col_Check_Sloc
;
4551 ---------------------------
4552 -- Write_Subprogram_Name --
4553 ---------------------------
4555 procedure Write_Subprogram_Name
(N
: Node_Id
) is
4557 if not Comes_From_Source
(N
)
4558 and then Is_Entity_Name
(N
)
4561 Ent
: constant Entity_Id
:= Entity
(N
);
4563 if not In_Extended_Main_Source_Unit
(Ent
)
4565 Is_Predefined_File_Name
4566 (Unit_File_Name
(Get_Source_Unit
(Ent
)))
4568 -- Run-time routine name, output name with a preceding dollar
4569 -- making sure that we do not get a line split between them.
4571 Col_Check
(Length_Of_Name
(Chars
(Ent
)) + 1);
4573 Write_Name
(Chars
(Ent
));
4579 -- Normal case, not a run-time routine name
4582 end Write_Subprogram_Name
;
4584 -------------------------------
4585 -- Write_Uint_With_Col_Check --
4586 -------------------------------
4588 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
) is
4590 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4591 UI_Write
(U
, Format
);
4592 end Write_Uint_With_Col_Check
;
4594 ------------------------------------
4595 -- Write_Uint_With_Col_Check_Sloc --
4596 ------------------------------------
4598 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
4600 Col_Check
(UI_Decimal_Digits_Hi
(U
));
4602 UI_Write
(U
, Format
);
4603 end Write_Uint_With_Col_Check_Sloc
;
4605 -------------------------------------
4606 -- Write_Ureal_With_Col_Check_Sloc --
4607 -------------------------------------
4609 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
4610 D
: constant Uint
:= Denominator
(U
);
4611 N
: constant Uint
:= Numerator
(U
);
4613 Col_Check
(UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
4615 UR_Write
(U
, Brackets
=> True);
4616 end Write_Ureal_With_Col_Check_Sloc
;