1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 with Atree
; use Atree
;
30 with Casing
; use Casing
;
31 with Debug
; use Debug
;
32 with Einfo
; use Einfo
;
34 with Namet
; use Namet
;
35 with Nlists
; use Nlists
;
37 with Output
; use Output
;
38 with Rtsfind
; use Rtsfind
;
39 with Sinfo
; use Sinfo
;
40 with Sinput
; use Sinput
;
41 with Sinput
.L
; use Sinput
.L
;
42 with Snames
; use Snames
;
43 with Stand
; use Stand
;
44 with Stringt
; use Stringt
;
45 with Uintp
; use Uintp
;
46 with Uname
; use Uname
;
47 with Urealp
; use Urealp
;
49 package body Sprint
is
51 Debug_Node
: Node_Id
:= Empty
;
52 -- If we are in Debug_Generated_Code mode, then this location is set
53 -- to the current node requiring Sloc fixup, until Set_Debug_Sloc is
54 -- called to set the proper value. The call clears it back to Empty.
56 Debug_Sloc
: Source_Ptr
;
57 -- Sloc of first byte of line currently being written if we are
58 -- generating a source debug file.
60 Dump_Original_Only
: Boolean;
61 -- Set True if the -gnatdo (dump original tree) flag is set
63 Dump_Generated_Only
: Boolean;
64 -- Set True if the -gnatG (dump generated tree) debug flag is set
65 -- or for Print_Generated_Code (-gnatG) or Dump_Gnerated_Code (-gnatD).
67 Dump_Freeze_Null
: Boolean;
68 -- Set True if freeze nodes and non-source null statements output
71 -- Number of columns for current line output indentation
73 Indent_Annull_Flag
: Boolean := False;
74 -- Set True if subsequent Write_Indent call to be ignored, gets reset
75 -- by this call, so it is only active to suppress a single indent call.
77 Line_Limit
: constant := 72;
78 -- Limit value for chopping long lines
80 Freeze_Indent
: Int
:= 0;
81 -- Keep track of freeze indent level (controls blank lines before
82 -- procedures within expression freeze actions)
84 -----------------------
85 -- Local Subprograms --
86 -----------------------
88 procedure Col_Check
(N
: Nat
);
89 -- Check that at least N characters remain on current line, and if not,
90 -- then start an extra line with two characters extra indentation for
91 -- continuing text on the next line.
93 procedure Indent_Annull
;
94 -- Causes following call to Write_Indent to be ignored. This is used when
95 -- a higher level node wants to stop a lower level node from starting a
96 -- new line, when it would otherwise be inclined to do so (e.g. the case
97 -- of an accept statement called from an accept alternative with a guard)
99 procedure Indent_Begin
;
100 -- Increase indentation level
102 procedure Indent_End
;
103 -- Decrease indentation level
106 -- Terminate current line in line buffer
108 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
);
109 -- Given a divide, multiplication or division node, check the flags
110 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
111 -- appropriate special syntax characters (# and @).
113 procedure Set_Debug_Sloc
;
114 -- If Debug_Node is non-empty, this routine sets the appropriate value
115 -- in its Sloc field, from the current location in the debug source file
116 -- that is currently being written. Note that Debug_Node is always empty
117 -- if a debug source file is not being written.
119 procedure Sprint_Bar_List
(List
: List_Id
);
120 -- Print the given list with items separated by vertical bars
122 procedure Sprint_Node_Actual
(Node
: Node_Id
);
123 -- This routine prints its node argument. It is a lower level routine than
124 -- Sprint_Node, in that it does not bother about rewritten trees.
126 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
127 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
128 -- sets the Sloc of the current debug node to be a copy of the Sloc
129 -- of the sprinted node Node. Note that this is done after printing
130 -- Node, so that the Sloc is the proper updated value for the debug file.
132 procedure Write_Char_Sloc
(C
: Character);
133 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
134 -- called to ensure that the current node has a proper Sloc set.
136 procedure Write_Discr_Specs
(N
: Node_Id
);
137 -- Output discriminant specification for node, which is any of the type
138 -- declarations that can have discriminants.
140 procedure Write_Ekind
(E
: Entity_Id
);
141 -- Write the String corresponding to the Ekind without "E_".
143 procedure Write_Id
(N
: Node_Id
);
144 -- N is a node with a Chars field. This procedure writes the name that
145 -- will be used in the generated code associated with the name. For a
146 -- node with no associated entity, this is simply the Chars field. For
147 -- the case where there is an entity associated with the node, we print
148 -- the name associated with the entity (since it may have been encoded).
149 -- One other special case is that an entity has an active external name
150 -- (i.e. an external name present with no address clause), then this
151 -- external name is output.
153 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
154 -- Handle node where the grammar has a list of defining identifiers, but
155 -- the tree has a separate declaration for each identifier. Handles the
156 -- printing of the defining identifier, and returns True if the type and
157 -- initialization information is to be printed, False if it is to be
158 -- skipped (the latter case happens when printing defining identifiers
159 -- other than the first in the original tree output case).
161 procedure Write_Implicit_Def
(E
: Entity_Id
);
162 pragma Warnings
(Off
, Write_Implicit_Def
);
163 -- Write the definition of the implicit type E according to its Ekind
164 -- For now a debugging procedure, but might be used in the future.
166 procedure Write_Indent
;
167 -- Start a new line and write indentation spacing
169 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
170 -- Like Write_Identifiers except that each new printed declaration
171 -- is at the start of a new line.
173 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
174 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
175 -- mode, the Sloc of the current debug node is set to point ot the
176 -- first output identifier.
178 procedure Write_Indent_Str
(S
: String);
179 -- Start a new line and write indent spacing followed by given string
181 procedure Write_Indent_Str_Sloc
(S
: String);
182 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
183 -- the Sloc of the current node is set to the first non-blank character
186 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
187 -- Write name (using Write_Name) with initial column check, and possible
188 -- initial Write_Indent (to get new line) if current line is too full.
190 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
191 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
192 -- mode, sets Sloc of current debug node to first character of name.
194 procedure Write_Operator
(N
: Node_Id
; S
: String);
195 -- Like Write_Str_Sloc, used for operators, encloses the string in
196 -- characters {} if the Do_Overflow flag is set on the node N.
198 procedure Write_Param_Specs
(N
: Node_Id
);
199 -- Output parameter specifications for node (which is either a function
200 -- or procedure specification with a Parameter_Specifications field)
202 procedure Write_Rewrite_Str
(S
: String);
203 -- Writes out a string (typically containing <<< or >>>}) for a node
204 -- created by rewriting the tree. Suppressed if we are outputting the
205 -- generated code only, since in this case we don't specially mark nodes
206 -- created by rewriting).
208 procedure Write_Str_Sloc
(S
: String);
209 -- Like Write_Str, but sets debug Sloc of current debug node to first
210 -- non-blank character if a current debug node is active.
212 procedure Write_Str_With_Col_Check
(S
: String);
213 -- Write string (using Write_Str) with initial column check, and possible
214 -- initial Write_Indent (to get new line) if current line is too full.
216 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
217 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
218 -- node to first non-blank character if a current debug node is active.
220 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
221 -- Write Uint (using UI_Write) with initial column check, and possible
222 -- initial Write_Indent (to get new line) if current line is too full.
223 -- The format parameter determines the output format (see UI_Write).
224 -- In addition, in Debug_Generated_Code mode, sets the current node
225 -- Sloc to the first character of the output value.
227 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
228 -- Write Ureal (using same output format as UR_Write) with column checks
229 -- and a possible initial Write_Indent (to get new line) if current line
230 -- is too full. In addition, in Debug_Generated_Code mode, sets the
231 -- current node Sloc to the first character of the output value.
237 procedure Col_Check
(N
: Nat
) is
239 if N
+ Column
> Line_Limit
then
240 Write_Indent_Str
(" ");
248 procedure Indent_Annull
is
250 Indent_Annull_Flag
:= True;
257 procedure Indent_Begin
is
259 Indent
:= Indent
+ 3;
266 procedure Indent_End
is
268 Indent
:= Indent
- 3;
275 procedure PG
(Node
: Node_Id
) is
277 Dump_Generated_Only
:= True;
278 Dump_Original_Only
:= False;
287 procedure PO
(Node
: Node_Id
) is
289 Dump_Generated_Only
:= False;
290 Dump_Original_Only
:= True;
299 procedure Print_Eol
is
301 -- If we are writing a debug source file, then grab it from the
302 -- Output buffer, and reset the column counter (the routines in
303 -- Output never actually write any output for us in this mode,
304 -- they just build line images in Buffer).
306 if Debug_Generated_Code
then
307 Write_Debug_Line
(Buffer
(1 .. Natural (Column
) - 1), Debug_Sloc
);
310 -- In normal mode, we call Write_Eol to write the line normally
317 ---------------------------
318 -- Process_TFAI_RR_Flags --
319 ---------------------------
321 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
323 if Treat_Fixed_As_Integer
(Nod
) then
327 if Rounded_Result
(Nod
) then
330 end Process_TFAI_RR_Flags
;
336 procedure PS
(Node
: Node_Id
) is
338 Dump_Generated_Only
:= False;
339 Dump_Original_Only
:= False;
348 procedure Set_Debug_Sloc
is
350 if Present
(Debug_Node
) then
351 Set_Sloc
(Debug_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
360 procedure Source_Dump
is
363 -- Put underline under string we just printed
365 procedure Underline
is
366 Col
: constant Int
:= Column
;
371 while Col
> Column
loop
378 -- Start of processing for Tree_Dump.
381 Dump_Generated_Only
:= Debug_Flag_G
or
382 Print_Generated_Code
or
383 Debug_Generated_Code
;
384 Dump_Original_Only
:= Debug_Flag_O
;
385 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
387 -- Note that we turn off the tree dump flags immediately, before
388 -- starting the dump. This avoids generating two copies of the dump
389 -- if an abort occurs after printing the dump, and more importantly,
390 -- avoids an infinite loop if an abort occurs during the dump.
393 Debug_Flag_Z
:= False;
396 Write_Str
("Source recreated from tree of Standard (spec)");
398 Sprint_Node
(Standard_Package_Node
);
403 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
404 Debug_Flag_G
:= False;
405 Debug_Flag_O
:= False;
406 Debug_Flag_S
:= False;
408 -- Dump requested units
410 for U
in Main_Unit
.. Last_Unit
loop
412 -- Dump all units if -gnatdf set, otherwise we dump only
413 -- the source files that are in the extended main source.
416 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
418 -- If we are generating debug files, setup to write them
420 if Debug_Generated_Code
then
421 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
422 Sprint_Node
(Cunit
(U
));
426 -- Normal output to standard output file
429 Write_Str
("Source recreated from tree for ");
430 Write_Unit_Name
(Unit_Name
(U
));
432 Sprint_Node
(Cunit
(U
));
441 ---------------------
442 -- Sprint_Bar_List --
443 ---------------------
445 procedure Sprint_Bar_List
(List
: List_Id
) is
449 if Is_Non_Empty_List
(List
) then
450 Node
:= First
(List
);
455 exit when Node
= Empty
;
461 -----------------------
462 -- Sprint_Comma_List --
463 -----------------------
465 procedure Sprint_Comma_List
(List
: List_Id
) is
469 if Is_Non_Empty_List
(List
) then
470 Node
:= First
(List
);
475 exit when Node
= Empty
;
477 if not Is_Rewrite_Insertion
(Node
)
478 or else not Dump_Original_Only
485 end Sprint_Comma_List
;
487 --------------------------
488 -- Sprint_Indented_List --
489 --------------------------
491 procedure Sprint_Indented_List
(List
: List_Id
) is
494 Sprint_Node_List
(List
);
496 end Sprint_Indented_List
;
502 procedure Sprint_Node
(Node
: Node_Id
) is
504 if Is_Rewrite_Insertion
(Node
) then
505 if not Dump_Original_Only
then
507 -- For special cases of nodes that always output <<< >>>
508 -- do not duplicate the output at this point.
510 if Nkind
(Node
) = N_Freeze_Entity
511 or else Nkind
(Node
) = N_Implicit_Label_Declaration
513 Sprint_Node_Actual
(Node
);
515 -- Normal case where <<< >>> may be required
518 Write_Rewrite_Str
("<<<");
519 Sprint_Node_Actual
(Node
);
520 Write_Rewrite_Str
(">>>");
524 elsif Is_Rewrite_Substitution
(Node
) then
526 -- Case of dump generated only
528 if Dump_Generated_Only
then
529 Sprint_Node_Actual
(Node
);
531 -- Case of dump original only
533 elsif Dump_Original_Only
then
534 Sprint_Node_Actual
(Original_Node
(Node
));
536 -- Case of both being dumped
539 Sprint_Node_Actual
(Original_Node
(Node
));
540 Write_Rewrite_Str
("<<<");
541 Sprint_Node_Actual
(Node
);
542 Write_Rewrite_Str
(">>>");
546 Sprint_Node_Actual
(Node
);
550 ------------------------
551 -- Sprint_Node_Actual --
552 ------------------------
554 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
555 Save_Debug_Node
: constant Node_Id
:= Debug_Node
;
562 for J
in 1 .. Paren_Count
(Node
) loop
563 Write_Str_With_Col_Check
("(");
566 -- Setup node for Sloc fixup if writing a debug source file. Note
567 -- that we take care of any previous node not yet properly set.
569 if Debug_Generated_Code
then
573 if Nkind
(Node
) in N_Subexpr
574 and then Do_Range_Check
(Node
)
576 Write_Str_With_Col_Check
("{");
579 -- Select print circuit based on node kind
583 when N_Abort_Statement
=>
584 Write_Indent_Str_Sloc
("abort ");
585 Sprint_Comma_List
(Names
(Node
));
588 when N_Abortable_Part
=>
590 Write_Str_Sloc
("abort ");
591 Sprint_Indented_List
(Statements
(Node
));
593 when N_Abstract_Subprogram_Declaration
=>
595 Sprint_Node
(Specification
(Node
));
596 Write_Str_With_Col_Check
(" is ");
597 Write_Str_Sloc
("abstract;");
599 when N_Accept_Alternative
=>
600 Sprint_Node_List
(Pragmas_Before
(Node
));
602 if Present
(Condition
(Node
)) then
603 Write_Indent_Str
("when ");
604 Sprint_Node
(Condition
(Node
));
609 Sprint_Node_Sloc
(Accept_Statement
(Node
));
610 Sprint_Node_List
(Statements
(Node
));
612 when N_Accept_Statement
=>
613 Write_Indent_Str_Sloc
("accept ");
614 Write_Id
(Entry_Direct_Name
(Node
));
616 if Present
(Entry_Index
(Node
)) then
617 Write_Str_With_Col_Check
(" (");
618 Sprint_Node
(Entry_Index
(Node
));
622 Write_Param_Specs
(Node
);
624 if Present
(Handled_Statement_Sequence
(Node
)) then
625 Write_Str_With_Col_Check
(" do");
626 Sprint_Node
(Handled_Statement_Sequence
(Node
));
627 Write_Indent_Str
("end ");
628 Write_Id
(Entry_Direct_Name
(Node
));
633 when N_Access_Definition
=>
634 Write_Str_With_Col_Check_Sloc
("access ");
635 Sprint_Node
(Subtype_Mark
(Node
));
637 when N_Access_Function_Definition
=>
638 Write_Str_With_Col_Check_Sloc
("access ");
640 if Protected_Present
(Node
) then
641 Write_Str_With_Col_Check
("protected ");
644 Write_Str_With_Col_Check
("function");
645 Write_Param_Specs
(Node
);
646 Write_Str_With_Col_Check
(" return ");
647 Sprint_Node
(Subtype_Mark
(Node
));
649 when N_Access_Procedure_Definition
=>
650 Write_Str_With_Col_Check_Sloc
("access ");
652 if Protected_Present
(Node
) then
653 Write_Str_With_Col_Check
("protected ");
656 Write_Str_With_Col_Check
("procedure");
657 Write_Param_Specs
(Node
);
659 when N_Access_To_Object_Definition
=>
660 Write_Str_With_Col_Check_Sloc
("access ");
662 if All_Present
(Node
) then
663 Write_Str_With_Col_Check
("all ");
664 elsif Constant_Present
(Node
) then
665 Write_Str_With_Col_Check
("constant ");
668 Sprint_Node
(Subtype_Indication
(Node
));
671 if Null_Record_Present
(Node
) then
672 Write_Str_With_Col_Check_Sloc
("(null record)");
675 Write_Str_With_Col_Check_Sloc
("(");
677 if Present
(Expressions
(Node
)) then
678 Sprint_Comma_List
(Expressions
(Node
));
680 if Present
(Component_Associations
(Node
)) then
685 if Present
(Component_Associations
(Node
)) then
692 Nd
:= First
(Component_Associations
(Node
));
700 if not Is_Rewrite_Insertion
(Nd
)
701 or else not Dump_Original_Only
715 Write_Str_With_Col_Check_Sloc
("new ");
716 Sprint_Node
(Expression
(Node
));
718 if Present
(Storage_Pool
(Node
)) then
719 Write_Str_With_Col_Check
("[storage_pool = ");
720 Sprint_Node
(Storage_Pool
(Node
));
725 Sprint_Node
(Left_Opnd
(Node
));
726 Write_Str_Sloc
(" and then ");
727 Sprint_Node
(Right_Opnd
(Node
));
730 Write_Indent_Str_Sloc
("for ");
731 Write_Id
(Identifier
(Node
));
732 Write_Str_With_Col_Check
(" use at ");
733 Sprint_Node
(Expression
(Node
));
736 when N_Assignment_Statement
=>
738 Sprint_Node
(Name
(Node
));
739 Write_Str_Sloc
(" := ");
740 Sprint_Node
(Expression
(Node
));
743 when N_Asynchronous_Select
=>
744 Write_Indent_Str_Sloc
("select");
746 Sprint_Node
(Triggering_Alternative
(Node
));
749 -- Note: let the printing of Abortable_Part handle outputting
750 -- the ABORT keyword, so that the Slco can be set correctly.
752 Write_Indent_Str
("then ");
753 Sprint_Node
(Abortable_Part
(Node
));
754 Write_Indent_Str
("end select;");
756 when N_Attribute_Definition_Clause
=>
757 Write_Indent_Str_Sloc
("for ");
758 Sprint_Node
(Name
(Node
));
760 Write_Name_With_Col_Check
(Chars
(Node
));
761 Write_Str_With_Col_Check
(" use ");
762 Sprint_Node
(Expression
(Node
));
765 when N_Attribute_Reference
=>
766 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
770 Sprint_Node
(Prefix
(Node
));
771 Write_Char_Sloc
(''');
772 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
773 Sprint_Paren_Comma_List
(Expressions
(Node
));
775 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
779 when N_Block_Statement
=>
782 if Present
(Identifier
(Node
))
783 and then (not Has_Created_Identifier
(Node
)
784 or else not Dump_Original_Only
)
786 Write_Rewrite_Str
("<<<");
787 Write_Id
(Identifier
(Node
));
789 Write_Rewrite_Str
(">>>");
792 if Present
(Declarations
(Node
)) then
793 Write_Str_With_Col_Check_Sloc
("declare");
794 Sprint_Indented_List
(Declarations
(Node
));
798 Write_Str_With_Col_Check_Sloc
("begin");
799 Sprint_Node
(Handled_Statement_Sequence
(Node
));
800 Write_Indent_Str
("end");
802 if Present
(Identifier
(Node
))
803 and then (not Has_Created_Identifier
(Node
)
804 or else not Dump_Original_Only
)
806 Write_Rewrite_Str
("<<<");
808 Write_Id
(Identifier
(Node
));
809 Write_Rewrite_Str
(">>>");
814 when N_Case_Statement
=>
815 Write_Indent_Str_Sloc
("case ");
816 Sprint_Node
(Expression
(Node
));
818 Sprint_Indented_List
(Alternatives
(Node
));
819 Write_Indent_Str
("end case;");
821 when N_Case_Statement_Alternative
=>
822 Write_Indent_Str_Sloc
("when ");
823 Sprint_Bar_List
(Discrete_Choices
(Node
));
825 Sprint_Indented_List
(Statements
(Node
));
827 when N_Character_Literal
=>
829 Write_Indent_Str
(" ");
832 Write_Char_Sloc
(''');
833 Write_Char_Code
(Char_Literal_Value
(Node
));
836 when N_Code_Statement
=>
839 Sprint_Node
(Expression
(Node
));
842 when N_Compilation_Unit
=>
843 Sprint_Node_List
(Context_Items
(Node
));
844 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
846 if Private_Present
(Node
) then
847 Write_Indent_Str
("private ");
851 Sprint_Node_Sloc
(Unit
(Node
));
853 if Present
(Actions
(Aux_Decls_Node
(Node
)))
855 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
860 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
861 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
863 when N_Compilation_Unit_Aux
=>
864 null; -- nothing to do, never used, see above
866 when N_Component_Association
=>
868 Sprint_Bar_List
(Choices
(Node
));
870 Sprint_Node
(Expression
(Node
));
872 when N_Component_Clause
=>
874 Sprint_Node
(Component_Name
(Node
));
875 Write_Str_Sloc
(" at ");
876 Sprint_Node
(Position
(Node
));
878 Write_Str_With_Col_Check
("range ");
879 Sprint_Node
(First_Bit
(Node
));
881 Sprint_Node
(Last_Bit
(Node
));
884 when N_Component_Declaration
=>
885 if Write_Indent_Identifiers_Sloc
(Node
) then
888 if Aliased_Present
(Node
) then
889 Write_Str_With_Col_Check
("aliased ");
892 Sprint_Node
(Subtype_Indication
(Node
));
894 if Present
(Expression
(Node
)) then
896 Sprint_Node
(Expression
(Node
));
902 when N_Component_List
=>
903 if Null_Present
(Node
) then
905 Write_Indent_Str_Sloc
("null");
911 Sprint_Indented_List
(Component_Items
(Node
));
912 Sprint_Node
(Variant_Part
(Node
));
915 when N_Conditional_Entry_Call
=>
916 Write_Indent_Str_Sloc
("select");
918 Sprint_Node
(Entry_Call_Alternative
(Node
));
920 Write_Indent_Str
("else");
921 Sprint_Indented_List
(Else_Statements
(Node
));
922 Write_Indent_Str
("end select;");
924 when N_Conditional_Expression
=>
926 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
927 Then_Expr
: constant Node_Id
:= Next
(Condition
);
928 Else_Expr
: constant Node_Id
:= Next
(Then_Expr
);
931 Write_Str_With_Col_Check_Sloc
("(if ");
932 Sprint_Node
(Condition
);
933 Write_Str_With_Col_Check
(" then ");
934 Sprint_Node
(Then_Expr
);
935 Write_Str_With_Col_Check
(" else ");
936 Sprint_Node
(Else_Expr
);
940 when N_Constrained_Array_Definition
=>
941 Write_Str_With_Col_Check_Sloc
("array ");
942 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
945 if Aliased_Present
(Node
) then
946 Write_Str_With_Col_Check
("aliased ");
949 Sprint_Node
(Subtype_Indication
(Node
));
951 when N_Decimal_Fixed_Point_Definition
=>
952 Write_Str_With_Col_Check_Sloc
(" delta ");
953 Sprint_Node
(Delta_Expression
(Node
));
954 Write_Str_With_Col_Check
("digits ");
955 Sprint_Node
(Digits_Expression
(Node
));
956 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
958 when N_Defining_Character_Literal
=>
959 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
961 when N_Defining_Identifier
=>
965 when N_Defining_Operator_Symbol
=>
966 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
968 when N_Defining_Program_Unit_Name
=>
970 Sprint_Node
(Name
(Node
));
972 Write_Id
(Defining_Identifier
(Node
));
974 when N_Delay_Alternative
=>
975 Sprint_Node_List
(Pragmas_Before
(Node
));
977 if Present
(Condition
(Node
)) then
979 Write_Str_With_Col_Check
("when ");
980 Sprint_Node
(Condition
(Node
));
985 Sprint_Node_Sloc
(Delay_Statement
(Node
));
986 Sprint_Node_List
(Statements
(Node
));
988 when N_Delay_Relative_Statement
=>
989 Write_Indent_Str_Sloc
("delay ");
990 Sprint_Node
(Expression
(Node
));
993 when N_Delay_Until_Statement
=>
994 Write_Indent_Str_Sloc
("delay until ");
995 Sprint_Node
(Expression
(Node
));
998 when N_Delta_Constraint
=>
999 Write_Str_With_Col_Check_Sloc
("delta ");
1000 Sprint_Node
(Delta_Expression
(Node
));
1001 Sprint_Opt_Node
(Range_Constraint
(Node
));
1003 when N_Derived_Type_Definition
=>
1004 if Abstract_Present
(Node
) then
1005 Write_Str_With_Col_Check
("abstract ");
1008 Write_Str_With_Col_Check_Sloc
("new ");
1009 Sprint_Node
(Subtype_Indication
(Node
));
1011 if Present
(Record_Extension_Part
(Node
)) then
1012 Write_Str_With_Col_Check
(" with ");
1013 Sprint_Node
(Record_Extension_Part
(Node
));
1016 when N_Designator
=>
1017 Sprint_Node
(Name
(Node
));
1018 Write_Char_Sloc
('.');
1019 Write_Id
(Identifier
(Node
));
1021 when N_Digits_Constraint
=>
1022 Write_Str_With_Col_Check_Sloc
("digits ");
1023 Sprint_Node
(Digits_Expression
(Node
));
1024 Sprint_Opt_Node
(Range_Constraint
(Node
));
1026 when N_Discriminant_Association
=>
1029 if Present
(Selector_Names
(Node
)) then
1030 Sprint_Bar_List
(Selector_Names
(Node
));
1035 Sprint_Node
(Expression
(Node
));
1037 when N_Discriminant_Specification
=>
1040 if Write_Identifiers
(Node
) then
1042 Sprint_Node
(Discriminant_Type
(Node
));
1044 if Present
(Expression
(Node
)) then
1046 Sprint_Node
(Expression
(Node
));
1052 when N_Elsif_Part
=>
1053 Write_Indent_Str_Sloc
("elsif ");
1054 Sprint_Node
(Condition
(Node
));
1055 Write_Str_With_Col_Check
(" then");
1056 Sprint_Indented_List
(Then_Statements
(Node
));
1061 when N_Entry_Body
=>
1062 Write_Indent_Str_Sloc
("entry ");
1063 Write_Id
(Defining_Identifier
(Node
));
1064 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1065 Write_Str_With_Col_Check
(" is");
1066 Sprint_Indented_List
(Declarations
(Node
));
1067 Write_Indent_Str
("begin");
1068 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1069 Write_Indent_Str
("end ");
1070 Write_Id
(Defining_Identifier
(Node
));
1073 when N_Entry_Body_Formal_Part
=>
1074 if Present
(Entry_Index_Specification
(Node
)) then
1075 Write_Str_With_Col_Check_Sloc
(" (");
1076 Sprint_Node
(Entry_Index_Specification
(Node
));
1080 Write_Param_Specs
(Node
);
1081 Write_Str_With_Col_Check_Sloc
(" when ");
1082 Sprint_Node
(Condition
(Node
));
1084 when N_Entry_Call_Alternative
=>
1085 Sprint_Node_List
(Pragmas_Before
(Node
));
1086 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1087 Sprint_Node_List
(Statements
(Node
));
1089 when N_Entry_Call_Statement
=>
1091 Sprint_Node_Sloc
(Name
(Node
));
1092 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1095 when N_Entry_Declaration
=>
1096 Write_Indent_Str_Sloc
("entry ");
1097 Write_Id
(Defining_Identifier
(Node
));
1099 if Present
(Discrete_Subtype_Definition
(Node
)) then
1100 Write_Str_With_Col_Check
(" (");
1101 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1105 Write_Param_Specs
(Node
);
1108 when N_Entry_Index_Specification
=>
1109 Write_Str_With_Col_Check_Sloc
("for ");
1110 Write_Id
(Defining_Identifier
(Node
));
1111 Write_Str_With_Col_Check
(" in ");
1112 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1114 when N_Enumeration_Representation_Clause
=>
1115 Write_Indent_Str_Sloc
("for ");
1116 Write_Id
(Identifier
(Node
));
1117 Write_Str_With_Col_Check
(" use ");
1118 Sprint_Node
(Array_Aggregate
(Node
));
1121 when N_Enumeration_Type_Definition
=>
1124 -- Skip attempt to print Literals field if it's not there and
1125 -- we are in package Standard (case of Character, which is
1126 -- handled specially (without an explicit literals list).
1128 if Sloc
(Node
) > Standard_Location
1129 or else Present
(Literals
(Node
))
1131 Sprint_Paren_Comma_List
(Literals
(Node
));
1135 Write_Str_With_Col_Check_Sloc
("<error>");
1137 when N_Exception_Declaration
=>
1138 if Write_Indent_Identifiers
(Node
) then
1139 Write_Str_With_Col_Check
(" : ");
1140 Write_Str_Sloc
("exception;");
1143 when N_Exception_Handler
=>
1144 Write_Indent_Str_Sloc
("when ");
1146 if Present
(Choice_Parameter
(Node
)) then
1147 Sprint_Node
(Choice_Parameter
(Node
));
1151 Sprint_Bar_List
(Exception_Choices
(Node
));
1153 Sprint_Indented_List
(Statements
(Node
));
1155 when N_Exception_Renaming_Declaration
=>
1158 Sprint_Node
(Defining_Identifier
(Node
));
1159 Write_Str_With_Col_Check
(" : exception renames ");
1160 Sprint_Node
(Name
(Node
));
1163 when N_Exit_Statement
=>
1164 Write_Indent_Str_Sloc
("exit");
1165 Sprint_Opt_Node
(Name
(Node
));
1167 if Present
(Condition
(Node
)) then
1168 Write_Str_With_Col_Check
(" when ");
1169 Sprint_Node
(Condition
(Node
));
1174 when N_Explicit_Dereference
=>
1175 Sprint_Node
(Prefix
(Node
));
1177 Write_Str_Sloc
("all");
1179 when N_Extension_Aggregate
=>
1180 Write_Str_With_Col_Check_Sloc
("(");
1181 Sprint_Node
(Ancestor_Part
(Node
));
1182 Write_Str_With_Col_Check
(" with ");
1184 if Null_Record_Present
(Node
) then
1185 Write_Str_With_Col_Check
("null record");
1187 if Present
(Expressions
(Node
)) then
1188 Sprint_Comma_List
(Expressions
(Node
));
1190 if Present
(Component_Associations
(Node
)) then
1195 if Present
(Component_Associations
(Node
)) then
1196 Sprint_Comma_List
(Component_Associations
(Node
));
1202 when N_Floating_Point_Definition
=>
1203 Write_Str_With_Col_Check_Sloc
("digits ");
1204 Sprint_Node
(Digits_Expression
(Node
));
1205 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1207 when N_Formal_Decimal_Fixed_Point_Definition
=>
1208 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1210 when N_Formal_Derived_Type_Definition
=>
1211 Write_Str_With_Col_Check_Sloc
("new ");
1212 Sprint_Node
(Subtype_Mark
(Node
));
1214 if Private_Present
(Node
) then
1215 Write_Str_With_Col_Check
(" with private");
1218 when N_Formal_Discrete_Type_Definition
=>
1219 Write_Str_With_Col_Check_Sloc
("<>");
1221 when N_Formal_Floating_Point_Definition
=>
1222 Write_Str_With_Col_Check_Sloc
("digits <>");
1224 when N_Formal_Modular_Type_Definition
=>
1225 Write_Str_With_Col_Check_Sloc
("mod <>");
1227 when N_Formal_Object_Declaration
=>
1230 if Write_Indent_Identifiers
(Node
) then
1233 if In_Present
(Node
) then
1234 Write_Str_With_Col_Check
("in ");
1237 if Out_Present
(Node
) then
1238 Write_Str_With_Col_Check
("out ");
1241 Sprint_Node
(Subtype_Mark
(Node
));
1243 if Present
(Expression
(Node
)) then
1245 Sprint_Node
(Expression
(Node
));
1251 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1252 Write_Str_With_Col_Check_Sloc
("delta <>");
1254 when N_Formal_Package_Declaration
=>
1255 Write_Indent_Str_Sloc
("with package ");
1256 Write_Id
(Defining_Identifier
(Node
));
1257 Write_Str_With_Col_Check
(" is new ");
1258 Sprint_Node
(Name
(Node
));
1259 Write_Str_With_Col_Check
(" (<>);");
1261 when N_Formal_Private_Type_Definition
=>
1262 if Abstract_Present
(Node
) then
1263 Write_Str_With_Col_Check
("abstract ");
1266 if Tagged_Present
(Node
) then
1267 Write_Str_With_Col_Check
("tagged ");
1270 if Limited_Present
(Node
) then
1271 Write_Str_With_Col_Check
("limited ");
1274 Write_Str_With_Col_Check_Sloc
("private");
1276 when N_Formal_Signed_Integer_Type_Definition
=>
1277 Write_Str_With_Col_Check_Sloc
("range <>");
1279 when N_Formal_Subprogram_Declaration
=>
1280 Write_Indent_Str_Sloc
("with ");
1281 Sprint_Node
(Specification
(Node
));
1283 if Box_Present
(Node
) then
1284 Write_Str_With_Col_Check
(" is <>");
1285 elsif Present
(Default_Name
(Node
)) then
1286 Write_Str_With_Col_Check
(" is ");
1287 Sprint_Node
(Default_Name
(Node
));
1292 when N_Formal_Type_Declaration
=>
1293 Write_Indent_Str_Sloc
("type ");
1294 Write_Id
(Defining_Identifier
(Node
));
1296 if Present
(Discriminant_Specifications
(Node
)) then
1297 Write_Discr_Specs
(Node
);
1298 elsif Unknown_Discriminants_Present
(Node
) then
1299 Write_Str_With_Col_Check
("(<>)");
1302 Write_Str_With_Col_Check
(" is ");
1303 Sprint_Node
(Formal_Type_Definition
(Node
));
1306 when N_Free_Statement
=>
1307 Write_Indent_Str_Sloc
("free ");
1308 Sprint_Node
(Expression
(Node
));
1311 when N_Freeze_Entity
=>
1312 if Dump_Original_Only
then
1315 elsif Present
(Actions
(Node
)) or else Dump_Freeze_Null
then
1317 Write_Rewrite_Str
("<<<");
1318 Write_Str_With_Col_Check_Sloc
("freeze ");
1319 Write_Id
(Entity
(Node
));
1322 if No
(Actions
(Node
)) then
1326 Freeze_Indent
:= Freeze_Indent
+ 1;
1327 Sprint_Indented_List
(Actions
(Node
));
1328 Freeze_Indent
:= Freeze_Indent
- 1;
1329 Write_Indent_Str
("]");
1332 Write_Rewrite_Str
(">>>");
1335 when N_Full_Type_Declaration
=>
1336 Write_Indent_Str_Sloc
("type ");
1337 Write_Id
(Defining_Identifier
(Node
));
1338 Write_Discr_Specs
(Node
);
1339 Write_Str_With_Col_Check
(" is ");
1340 Sprint_Node
(Type_Definition
(Node
));
1343 when N_Function_Call
=>
1345 Sprint_Node
(Name
(Node
));
1346 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1348 when N_Function_Instantiation
=>
1349 Write_Indent_Str_Sloc
("function ");
1350 Sprint_Node
(Defining_Unit_Name
(Node
));
1351 Write_Str_With_Col_Check
(" is new ");
1352 Sprint_Node
(Name
(Node
));
1353 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1356 when N_Function_Specification
=>
1357 Write_Str_With_Col_Check_Sloc
("function ");
1358 Sprint_Node
(Defining_Unit_Name
(Node
));
1359 Write_Param_Specs
(Node
);
1360 Write_Str_With_Col_Check
(" return ");
1361 Sprint_Node
(Subtype_Mark
(Node
));
1363 when N_Generic_Association
=>
1366 if Present
(Selector_Name
(Node
)) then
1367 Sprint_Node
(Selector_Name
(Node
));
1371 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
1373 when N_Generic_Function_Renaming_Declaration
=>
1374 Write_Indent_Str_Sloc
("generic function ");
1375 Sprint_Node
(Defining_Unit_Name
(Node
));
1376 Write_Str_With_Col_Check
(" renames ");
1377 Sprint_Node
(Name
(Node
));
1380 when N_Generic_Package_Declaration
=>
1382 Write_Indent_Str_Sloc
("generic ");
1383 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1385 Sprint_Node
(Specification
(Node
));
1388 when N_Generic_Package_Renaming_Declaration
=>
1389 Write_Indent_Str_Sloc
("generic package ");
1390 Sprint_Node
(Defining_Unit_Name
(Node
));
1391 Write_Str_With_Col_Check
(" renames ");
1392 Sprint_Node
(Name
(Node
));
1395 when N_Generic_Procedure_Renaming_Declaration
=>
1396 Write_Indent_Str_Sloc
("generic procedure ");
1397 Sprint_Node
(Defining_Unit_Name
(Node
));
1398 Write_Str_With_Col_Check
(" renames ");
1399 Sprint_Node
(Name
(Node
));
1402 when N_Generic_Subprogram_Declaration
=>
1404 Write_Indent_Str_Sloc
("generic ");
1405 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1407 Sprint_Node
(Specification
(Node
));
1410 when N_Goto_Statement
=>
1411 Write_Indent_Str_Sloc
("goto ");
1412 Sprint_Node
(Name
(Node
));
1415 if Nkind
(Next
(Node
)) = N_Label
then
1419 when N_Handled_Sequence_Of_Statements
=>
1421 Sprint_Indented_List
(Statements
(Node
));
1423 if Present
(Exception_Handlers
(Node
)) then
1424 Write_Indent_Str
("exception");
1426 Sprint_Node_List
(Exception_Handlers
(Node
));
1430 if Present
(At_End_Proc
(Node
)) then
1431 Write_Indent_Str
("at end");
1434 Sprint_Node
(At_End_Proc
(Node
));
1439 when N_Identifier
=>
1443 when N_If_Statement
=>
1444 Write_Indent_Str_Sloc
("if ");
1445 Sprint_Node
(Condition
(Node
));
1446 Write_Str_With_Col_Check
(" then");
1447 Sprint_Indented_List
(Then_Statements
(Node
));
1448 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
1450 if Present
(Else_Statements
(Node
)) then
1451 Write_Indent_Str
("else");
1452 Sprint_Indented_List
(Else_Statements
(Node
));
1455 Write_Indent_Str
("end if;");
1457 when N_Implicit_Label_Declaration
=>
1458 if not Dump_Original_Only
then
1460 Write_Rewrite_Str
("<<<");
1462 Write_Id
(Defining_Identifier
(Node
));
1464 Write_Str_With_Col_Check
("label");
1465 Write_Rewrite_Str
(">>>");
1469 Sprint_Node
(Left_Opnd
(Node
));
1470 Write_Str_Sloc
(" in ");
1471 Sprint_Node
(Right_Opnd
(Node
));
1473 when N_Incomplete_Type_Declaration
=>
1474 Write_Indent_Str_Sloc
("type ");
1475 Write_Id
(Defining_Identifier
(Node
));
1477 if Present
(Discriminant_Specifications
(Node
)) then
1478 Write_Discr_Specs
(Node
);
1479 elsif Unknown_Discriminants_Present
(Node
) then
1480 Write_Str_With_Col_Check
("(<>)");
1485 when N_Index_Or_Discriminant_Constraint
=>
1487 Sprint_Paren_Comma_List
(Constraints
(Node
));
1489 when N_Indexed_Component
=>
1490 Sprint_Node_Sloc
(Prefix
(Node
));
1491 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
1493 when N_Integer_Literal
=>
1494 if Print_In_Hex
(Node
) then
1495 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
1497 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
1500 when N_Iteration_Scheme
=>
1501 if Present
(Condition
(Node
)) then
1502 Write_Str_With_Col_Check_Sloc
("while ");
1503 Sprint_Node
(Condition
(Node
));
1505 Write_Str_With_Col_Check_Sloc
("for ");
1506 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1511 when N_Itype_Reference
=>
1512 Write_Indent_Str_Sloc
("reference ");
1513 Write_Id
(Itype
(Node
));
1516 Write_Indent_Str_Sloc
("<<");
1517 Write_Id
(Identifier
(Node
));
1520 when N_Loop_Parameter_Specification
=>
1522 Write_Id
(Defining_Identifier
(Node
));
1523 Write_Str_With_Col_Check
(" in ");
1525 if Reverse_Present
(Node
) then
1526 Write_Str_With_Col_Check
("reverse ");
1529 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1531 when N_Loop_Statement
=>
1534 if Present
(Identifier
(Node
))
1535 and then (not Has_Created_Identifier
(Node
)
1536 or else not Dump_Original_Only
)
1538 Write_Rewrite_Str
("<<<");
1539 Write_Id
(Identifier
(Node
));
1541 Write_Rewrite_Str
(">>>");
1542 Sprint_Node
(Iteration_Scheme
(Node
));
1543 Write_Str_With_Col_Check_Sloc
("loop");
1544 Sprint_Indented_List
(Statements
(Node
));
1545 Write_Indent_Str
("end loop ");
1546 Write_Rewrite_Str
("<<<");
1547 Write_Id
(Identifier
(Node
));
1548 Write_Rewrite_Str
(">>>");
1552 Sprint_Node
(Iteration_Scheme
(Node
));
1553 Write_Str_With_Col_Check_Sloc
("loop");
1554 Sprint_Indented_List
(Statements
(Node
));
1555 Write_Indent_Str
("end loop;");
1558 when N_Mod_Clause
=>
1559 Sprint_Node_List
(Pragmas_Before
(Node
));
1560 Write_Str_With_Col_Check_Sloc
("at mod ");
1561 Sprint_Node
(Expression
(Node
));
1563 when N_Modular_Type_Definition
=>
1564 Write_Str_With_Col_Check_Sloc
("mod ");
1565 Sprint_Node
(Expression
(Node
));
1568 Sprint_Node
(Left_Opnd
(Node
));
1569 Write_Str_Sloc
(" not in ");
1570 Sprint_Node
(Right_Opnd
(Node
));
1573 Write_Str_With_Col_Check_Sloc
("null");
1575 when N_Null_Statement
=>
1576 if Comes_From_Source
(Node
)
1577 or else Dump_Freeze_Null
1578 or else not Is_List_Member
(Node
)
1579 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
1581 Write_Indent_Str_Sloc
("null;");
1584 when N_Number_Declaration
=>
1587 if Write_Indent_Identifiers
(Node
) then
1588 Write_Str_With_Col_Check
(" : constant ");
1590 Sprint_Node
(Expression
(Node
));
1594 when N_Object_Declaration
=>
1596 -- Put extra blank line before and after if this is a handler
1597 -- record or a subprogram descriptor.
1600 Typ
: constant Entity_Id
:= Etype
(Defining_Identifier
(Node
));
1601 Exc
: constant Boolean :=
1602 Is_RTE
(Typ
, RE_Handler_Record
)
1604 Is_RTE
(Typ
, RE_Subprogram_Descriptor
);
1613 if Write_Indent_Identifiers
(Node
) then
1616 if Aliased_Present
(Node
) then
1617 Write_Str_With_Col_Check
("aliased ");
1620 if Constant_Present
(Node
) then
1621 Write_Str_With_Col_Check
("constant ");
1624 Sprint_Node
(Object_Definition
(Node
));
1626 if Present
(Expression
(Node
)) then
1628 Sprint_Node
(Expression
(Node
));
1639 when N_Object_Renaming_Declaration
=>
1642 Sprint_Node
(Defining_Identifier
(Node
));
1644 Sprint_Node
(Subtype_Mark
(Node
));
1645 Write_Str_With_Col_Check
(" renames ");
1646 Sprint_Node
(Name
(Node
));
1650 Write_Operator
(Node
, "abs ");
1651 Sprint_Node
(Right_Opnd
(Node
));
1654 Sprint_Node
(Left_Opnd
(Node
));
1655 Write_Operator
(Node
, " + ");
1656 Sprint_Node
(Right_Opnd
(Node
));
1659 Sprint_Node
(Left_Opnd
(Node
));
1660 Write_Operator
(Node
, " and ");
1661 Sprint_Node
(Right_Opnd
(Node
));
1664 Sprint_Node
(Left_Opnd
(Node
));
1665 Write_Operator
(Node
, " & ");
1666 Sprint_Node
(Right_Opnd
(Node
));
1669 Sprint_Node
(Left_Opnd
(Node
));
1671 Process_TFAI_RR_Flags
(Node
);
1672 Write_Operator
(Node
, "/ ");
1673 Sprint_Node
(Right_Opnd
(Node
));
1676 Sprint_Node
(Left_Opnd
(Node
));
1677 Write_Operator
(Node
, " = ");
1678 Sprint_Node
(Right_Opnd
(Node
));
1681 Sprint_Node
(Left_Opnd
(Node
));
1682 Write_Operator
(Node
, " ** ");
1683 Sprint_Node
(Right_Opnd
(Node
));
1686 Sprint_Node
(Left_Opnd
(Node
));
1687 Write_Operator
(Node
, " >= ");
1688 Sprint_Node
(Right_Opnd
(Node
));
1691 Sprint_Node
(Left_Opnd
(Node
));
1692 Write_Operator
(Node
, " > ");
1693 Sprint_Node
(Right_Opnd
(Node
));
1696 Sprint_Node
(Left_Opnd
(Node
));
1697 Write_Operator
(Node
, " <= ");
1698 Sprint_Node
(Right_Opnd
(Node
));
1701 Sprint_Node
(Left_Opnd
(Node
));
1702 Write_Operator
(Node
, " < ");
1703 Sprint_Node
(Right_Opnd
(Node
));
1706 Write_Operator
(Node
, "-");
1707 Sprint_Node
(Right_Opnd
(Node
));
1710 Sprint_Node
(Left_Opnd
(Node
));
1712 if Treat_Fixed_As_Integer
(Node
) then
1716 Write_Operator
(Node
, " mod ");
1717 Sprint_Node
(Right_Opnd
(Node
));
1719 when N_Op_Multiply
=>
1720 Sprint_Node
(Left_Opnd
(Node
));
1722 Process_TFAI_RR_Flags
(Node
);
1723 Write_Operator
(Node
, "* ");
1724 Sprint_Node
(Right_Opnd
(Node
));
1727 Sprint_Node
(Left_Opnd
(Node
));
1728 Write_Operator
(Node
, " /= ");
1729 Sprint_Node
(Right_Opnd
(Node
));
1732 Write_Operator
(Node
, "not ");
1733 Sprint_Node
(Right_Opnd
(Node
));
1736 Sprint_Node
(Left_Opnd
(Node
));
1737 Write_Operator
(Node
, " or ");
1738 Sprint_Node
(Right_Opnd
(Node
));
1741 Write_Operator
(Node
, "+");
1742 Sprint_Node
(Right_Opnd
(Node
));
1745 Sprint_Node
(Left_Opnd
(Node
));
1747 if Treat_Fixed_As_Integer
(Node
) then
1751 Write_Operator
(Node
, " rem ");
1752 Sprint_Node
(Right_Opnd
(Node
));
1758 Write_Str_With_Col_Check
("(");
1759 Sprint_Node
(Left_Opnd
(Node
));
1761 Sprint_Node
(Right_Opnd
(Node
));
1764 when N_Op_Subtract
=>
1765 Sprint_Node
(Left_Opnd
(Node
));
1766 Write_Operator
(Node
, " - ");
1767 Sprint_Node
(Right_Opnd
(Node
));
1770 Sprint_Node
(Left_Opnd
(Node
));
1771 Write_Operator
(Node
, " xor ");
1772 Sprint_Node
(Right_Opnd
(Node
));
1774 when N_Operator_Symbol
=>
1775 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1777 when N_Ordinary_Fixed_Point_Definition
=>
1778 Write_Str_With_Col_Check_Sloc
("delta ");
1779 Sprint_Node
(Delta_Expression
(Node
));
1780 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1783 Sprint_Node
(Left_Opnd
(Node
));
1784 Write_Str_Sloc
(" or else ");
1785 Sprint_Node
(Right_Opnd
(Node
));
1787 when N_Others_Choice
=>
1788 if All_Others
(Node
) then
1789 Write_Str_With_Col_Check
("all ");
1792 Write_Str_With_Col_Check_Sloc
("others");
1794 when N_Package_Body
=>
1796 Write_Indent_Str_Sloc
("package body ");
1797 Sprint_Node
(Defining_Unit_Name
(Node
));
1799 Sprint_Indented_List
(Declarations
(Node
));
1801 if Present
(Handled_Statement_Sequence
(Node
)) then
1802 Write_Indent_Str
("begin");
1803 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1806 Write_Indent_Str
("end ");
1807 Sprint_Node
(Defining_Unit_Name
(Node
));
1810 when N_Package_Body_Stub
=>
1811 Write_Indent_Str_Sloc
("package body ");
1812 Sprint_Node
(Defining_Identifier
(Node
));
1813 Write_Str_With_Col_Check
(" is separate;");
1815 when N_Package_Declaration
=>
1818 Sprint_Node_Sloc
(Specification
(Node
));
1821 when N_Package_Instantiation
=>
1823 Write_Indent_Str_Sloc
("package ");
1824 Sprint_Node
(Defining_Unit_Name
(Node
));
1825 Write_Str
(" is new ");
1826 Sprint_Node
(Name
(Node
));
1827 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1830 when N_Package_Renaming_Declaration
=>
1831 Write_Indent_Str_Sloc
("package ");
1832 Sprint_Node
(Defining_Unit_Name
(Node
));
1833 Write_Str_With_Col_Check
(" renames ");
1834 Sprint_Node
(Name
(Node
));
1837 when N_Package_Specification
=>
1838 Write_Str_With_Col_Check_Sloc
("package ");
1839 Sprint_Node
(Defining_Unit_Name
(Node
));
1841 Sprint_Indented_List
(Visible_Declarations
(Node
));
1843 if Present
(Private_Declarations
(Node
)) then
1844 Write_Indent_Str
("private");
1845 Sprint_Indented_List
(Private_Declarations
(Node
));
1848 Write_Indent_Str
("end ");
1849 Sprint_Node
(Defining_Unit_Name
(Node
));
1851 when N_Parameter_Association
=>
1852 Sprint_Node_Sloc
(Selector_Name
(Node
));
1854 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
1856 when N_Parameter_Specification
=>
1859 if Write_Identifiers
(Node
) then
1862 if In_Present
(Node
) then
1863 Write_Str_With_Col_Check
("in ");
1866 if Out_Present
(Node
) then
1867 Write_Str_With_Col_Check
("out ");
1870 Sprint_Node
(Parameter_Type
(Node
));
1872 if Present
(Expression
(Node
)) then
1874 Sprint_Node
(Expression
(Node
));
1881 Write_Indent_Str_Sloc
("pragma ");
1882 Write_Name_With_Col_Check
(Chars
(Node
));
1884 if Present
(Pragma_Argument_Associations
(Node
)) then
1885 Sprint_Opt_Paren_Comma_List
1886 (Pragma_Argument_Associations
(Node
));
1891 when N_Pragma_Argument_Association
=>
1894 if Chars
(Node
) /= No_Name
then
1895 Write_Name_With_Col_Check
(Chars
(Node
));
1899 Sprint_Node
(Expression
(Node
));
1901 when N_Private_Type_Declaration
=>
1902 Write_Indent_Str_Sloc
("type ");
1903 Write_Id
(Defining_Identifier
(Node
));
1905 if Present
(Discriminant_Specifications
(Node
)) then
1906 Write_Discr_Specs
(Node
);
1907 elsif Unknown_Discriminants_Present
(Node
) then
1908 Write_Str_With_Col_Check
("(<>)");
1913 if Tagged_Present
(Node
) then
1914 Write_Str_With_Col_Check
("tagged ");
1917 if Limited_Present
(Node
) then
1918 Write_Str_With_Col_Check
("limited ");
1921 Write_Str_With_Col_Check
("private;");
1923 when N_Private_Extension_Declaration
=>
1924 Write_Indent_Str_Sloc
("type ");
1925 Write_Id
(Defining_Identifier
(Node
));
1927 if Present
(Discriminant_Specifications
(Node
)) then
1928 Write_Discr_Specs
(Node
);
1929 elsif Unknown_Discriminants_Present
(Node
) then
1930 Write_Str_With_Col_Check
("(<>)");
1933 Write_Str_With_Col_Check
(" is new ");
1934 Sprint_Node
(Subtype_Indication
(Node
));
1935 Write_Str_With_Col_Check
(" with private;");
1937 when N_Procedure_Call_Statement
=>
1940 Sprint_Node
(Name
(Node
));
1941 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1944 when N_Procedure_Instantiation
=>
1945 Write_Indent_Str_Sloc
("procedure ");
1946 Sprint_Node
(Defining_Unit_Name
(Node
));
1947 Write_Str_With_Col_Check
(" is new ");
1948 Sprint_Node
(Name
(Node
));
1949 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1952 when N_Procedure_Specification
=>
1953 Write_Str_With_Col_Check_Sloc
("procedure ");
1954 Sprint_Node
(Defining_Unit_Name
(Node
));
1955 Write_Param_Specs
(Node
);
1957 when N_Protected_Body
=>
1958 Write_Indent_Str_Sloc
("protected body ");
1959 Write_Id
(Defining_Identifier
(Node
));
1961 Sprint_Indented_List
(Declarations
(Node
));
1962 Write_Indent_Str
("end ");
1963 Write_Id
(Defining_Identifier
(Node
));
1966 when N_Protected_Body_Stub
=>
1967 Write_Indent_Str_Sloc
("protected body ");
1968 Write_Id
(Defining_Identifier
(Node
));
1969 Write_Str_With_Col_Check
(" is separate;");
1971 when N_Protected_Definition
=>
1973 Sprint_Indented_List
(Visible_Declarations
(Node
));
1975 if Present
(Private_Declarations
(Node
)) then
1976 Write_Indent_Str
("private");
1977 Sprint_Indented_List
(Private_Declarations
(Node
));
1980 Write_Indent_Str
("end ");
1982 when N_Protected_Type_Declaration
=>
1983 Write_Indent_Str_Sloc
("protected type ");
1984 Write_Id
(Defining_Identifier
(Node
));
1985 Write_Discr_Specs
(Node
);
1987 Sprint_Node
(Protected_Definition
(Node
));
1988 Write_Id
(Defining_Identifier
(Node
));
1991 when N_Qualified_Expression
=>
1992 Sprint_Node
(Subtype_Mark
(Node
));
1993 Write_Char_Sloc
(''');
1994 Sprint_Node
(Expression
(Node
));
1996 when N_Raise_Constraint_Error
=>
1998 -- This node can be used either as a subexpression or as a
1999 -- statement form. The following test is a reasonably reliable
2000 -- way to distinguish the two cases.
2002 if Is_List_Member
(Node
)
2003 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2008 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2010 if Present
(Condition
(Node
)) then
2011 Write_Str_With_Col_Check
(" when ");
2012 Sprint_Node
(Condition
(Node
));
2017 when N_Raise_Program_Error
=>
2019 Write_Str_With_Col_Check_Sloc
("[program_error");
2021 if Present
(Condition
(Node
)) then
2022 Write_Str_With_Col_Check
(" when ");
2023 Sprint_Node
(Condition
(Node
));
2028 when N_Raise_Storage_Error
=>
2030 Write_Str_With_Col_Check_Sloc
("[storage_error");
2032 if Present
(Condition
(Node
)) then
2033 Write_Str_With_Col_Check
(" when ");
2034 Sprint_Node
(Condition
(Node
));
2039 when N_Raise_Statement
=>
2040 Write_Indent_Str_Sloc
("raise ");
2041 Sprint_Node
(Name
(Node
));
2045 Sprint_Node
(Low_Bound
(Node
));
2046 Write_Str_Sloc
(" .. ");
2047 Sprint_Node
(High_Bound
(Node
));
2049 when N_Range_Constraint
=>
2050 Write_Str_With_Col_Check_Sloc
("range ");
2051 Sprint_Node
(Range_Expression
(Node
));
2053 when N_Real_Literal
=>
2054 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
2056 when N_Real_Range_Specification
=>
2057 Write_Str_With_Col_Check_Sloc
("range ");
2058 Sprint_Node
(Low_Bound
(Node
));
2060 Sprint_Node
(High_Bound
(Node
));
2062 when N_Record_Definition
=>
2063 if Abstract_Present
(Node
) then
2064 Write_Str_With_Col_Check
("abstract ");
2067 if Tagged_Present
(Node
) then
2068 Write_Str_With_Col_Check
("tagged ");
2071 if Limited_Present
(Node
) then
2072 Write_Str_With_Col_Check
("limited ");
2075 if Null_Present
(Node
) then
2076 Write_Str_With_Col_Check_Sloc
("null record");
2079 Write_Str_With_Col_Check_Sloc
("record");
2080 Sprint_Node
(Component_List
(Node
));
2081 Write_Indent_Str
("end record");
2084 when N_Record_Representation_Clause
=>
2085 Write_Indent_Str_Sloc
("for ");
2086 Sprint_Node
(Identifier
(Node
));
2087 Write_Str_With_Col_Check
(" use record ");
2089 if Present
(Mod_Clause
(Node
)) then
2090 Sprint_Node
(Mod_Clause
(Node
));
2093 Sprint_Indented_List
(Component_Clauses
(Node
));
2094 Write_Indent_Str
("end record;");
2097 Sprint_Node
(Prefix
(Node
));
2098 Write_Str_With_Col_Check_Sloc
("'reference");
2100 when N_Requeue_Statement
=>
2101 Write_Indent_Str_Sloc
("requeue ");
2102 Sprint_Node
(Name
(Node
));
2104 if Abort_Present
(Node
) then
2105 Write_Str_With_Col_Check
(" with abort");
2110 when N_Return_Statement
=>
2111 if Present
(Expression
(Node
)) then
2112 Write_Indent_Str_Sloc
("return ");
2113 Sprint_Node
(Expression
(Node
));
2116 Write_Indent_Str_Sloc
("return;");
2119 when N_Selective_Accept
=>
2120 Write_Indent_Str_Sloc
("select");
2126 Alt_Node
:= First
(Select_Alternatives
(Node
));
2129 Sprint_Node
(Alt_Node
);
2132 exit when No
(Alt_Node
);
2133 Write_Indent_Str
("or");
2137 if Present
(Else_Statements
(Node
)) then
2138 Write_Indent_Str
("else");
2139 Sprint_Indented_List
(Else_Statements
(Node
));
2142 Write_Indent_Str
("end select;");
2144 when N_Signed_Integer_Type_Definition
=>
2145 Write_Str_With_Col_Check_Sloc
("range ");
2146 Sprint_Node
(Low_Bound
(Node
));
2148 Sprint_Node
(High_Bound
(Node
));
2150 when N_Single_Protected_Declaration
=>
2151 Write_Indent_Str_Sloc
("protected ");
2152 Write_Id
(Defining_Identifier
(Node
));
2154 Sprint_Node
(Protected_Definition
(Node
));
2155 Write_Id
(Defining_Identifier
(Node
));
2158 when N_Single_Task_Declaration
=>
2159 Write_Indent_Str_Sloc
("task ");
2160 Write_Id
(Defining_Identifier
(Node
));
2162 if Present
(Task_Definition
(Node
)) then
2164 Sprint_Node
(Task_Definition
(Node
));
2165 Write_Id
(Defining_Identifier
(Node
));
2170 when N_Selected_Component | N_Expanded_Name
=>
2171 Sprint_Node
(Prefix
(Node
));
2172 Write_Char_Sloc
('.');
2173 Sprint_Node
(Selector_Name
(Node
));
2177 Sprint_Node
(Prefix
(Node
));
2178 Write_Str_With_Col_Check
(" (");
2179 Sprint_Node
(Discrete_Range
(Node
));
2182 when N_String_Literal
=>
2183 if String_Length
(Strval
(Node
)) + Column
> 75 then
2184 Write_Indent_Str
(" ");
2188 Write_String_Table_Entry
(Strval
(Node
));
2190 when N_Subprogram_Body
=>
2191 if Freeze_Indent
= 0 then
2196 Sprint_Node_Sloc
(Specification
(Node
));
2199 Sprint_Indented_List
(Declarations
(Node
));
2200 Write_Indent_Str
("begin");
2201 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2203 Write_Indent_Str
("end ");
2204 Sprint_Node
(Defining_Unit_Name
(Specification
(Node
)));
2207 if Is_List_Member
(Node
)
2208 and then Present
(Next
(Node
))
2209 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
2214 when N_Subprogram_Body_Stub
=>
2216 Sprint_Node_Sloc
(Specification
(Node
));
2217 Write_Str_With_Col_Check
(" is separate;");
2219 when N_Subprogram_Declaration
=>
2221 Sprint_Node_Sloc
(Specification
(Node
));
2224 when N_Subprogram_Info
=>
2225 Sprint_Node
(Identifier
(Node
));
2226 Write_Str_With_Col_Check_Sloc
("'subprogram_info");
2228 when N_Subprogram_Renaming_Declaration
=>
2230 Sprint_Node
(Specification
(Node
));
2231 Write_Str_With_Col_Check_Sloc
(" renames ");
2232 Sprint_Node
(Name
(Node
));
2235 when N_Subtype_Declaration
=>
2236 Write_Indent_Str_Sloc
("subtype ");
2237 Write_Id
(Defining_Identifier
(Node
));
2239 Sprint_Node
(Subtype_Indication
(Node
));
2242 when N_Subtype_Indication
=>
2243 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
2245 Sprint_Node
(Constraint
(Node
));
2248 Write_Indent_Str_Sloc
("separate (");
2249 Sprint_Node
(Name
(Node
));
2252 Sprint_Node
(Proper_Body
(Node
));
2255 Write_Indent_Str_Sloc
("task body ");
2256 Write_Id
(Defining_Identifier
(Node
));
2258 Sprint_Indented_List
(Declarations
(Node
));
2259 Write_Indent_Str
("begin");
2260 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2261 Write_Indent_Str
("end ");
2262 Write_Id
(Defining_Identifier
(Node
));
2265 when N_Task_Body_Stub
=>
2266 Write_Indent_Str_Sloc
("task body ");
2267 Write_Id
(Defining_Identifier
(Node
));
2268 Write_Str_With_Col_Check
(" is separate;");
2270 when N_Task_Definition
=>
2272 Sprint_Indented_List
(Visible_Declarations
(Node
));
2274 if Present
(Private_Declarations
(Node
)) then
2275 Write_Indent_Str
("private");
2276 Sprint_Indented_List
(Private_Declarations
(Node
));
2279 Write_Indent_Str
("end ");
2281 when N_Task_Type_Declaration
=>
2282 Write_Indent_Str_Sloc
("task type ");
2283 Write_Id
(Defining_Identifier
(Node
));
2284 Write_Discr_Specs
(Node
);
2285 if Present
(Task_Definition
(Node
)) then
2287 Sprint_Node
(Task_Definition
(Node
));
2288 Write_Id
(Defining_Identifier
(Node
));
2293 when N_Terminate_Alternative
=>
2294 Sprint_Node_List
(Pragmas_Before
(Node
));
2298 if Present
(Condition
(Node
)) then
2299 Write_Str_With_Col_Check
("when ");
2300 Sprint_Node
(Condition
(Node
));
2304 Write_Str_With_Col_Check_Sloc
("terminate;");
2305 Sprint_Node_List
(Pragmas_After
(Node
));
2307 when N_Timed_Entry_Call
=>
2308 Write_Indent_Str_Sloc
("select");
2310 Sprint_Node
(Entry_Call_Alternative
(Node
));
2312 Write_Indent_Str
("or");
2314 Sprint_Node
(Delay_Alternative
(Node
));
2316 Write_Indent_Str
("end select;");
2318 when N_Triggering_Alternative
=>
2319 Sprint_Node_List
(Pragmas_Before
(Node
));
2320 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
2321 Sprint_Node_List
(Statements
(Node
));
2323 when N_Type_Conversion
=>
2325 Sprint_Node
(Subtype_Mark
(Node
));
2328 if Conversion_OK
(Node
) then
2332 if Float_Truncate
(Node
) then
2336 if Rounded_Result
(Node
) then
2341 Sprint_Node
(Expression
(Node
));
2344 when N_Unchecked_Expression
=>
2347 Sprint_Node_Sloc
(Expression
(Node
));
2350 when N_Unchecked_Type_Conversion
=>
2351 Sprint_Node
(Subtype_Mark
(Node
));
2353 Write_Str_With_Col_Check
("(");
2354 Sprint_Node_Sloc
(Expression
(Node
));
2357 when N_Unconstrained_Array_Definition
=>
2358 Write_Str_With_Col_Check_Sloc
("array (");
2364 Node1
:= First
(Subtype_Marks
(Node
));
2366 Sprint_Node
(Node1
);
2367 Write_Str_With_Col_Check
(" range <>");
2369 exit when Node1
= Empty
;
2374 Write_Str
(") of ");
2376 if Aliased_Present
(Node
) then
2377 Write_Str_With_Col_Check
("aliased ");
2380 Sprint_Node
(Subtype_Indication
(Node
));
2382 when N_Unused_At_Start | N_Unused_At_End
=>
2383 Write_Indent_Str
("***** Error, unused node encountered *****");
2386 when N_Use_Package_Clause
=>
2387 Write_Indent_Str_Sloc
("use ");
2388 Sprint_Comma_List
(Names
(Node
));
2391 when N_Use_Type_Clause
=>
2392 Write_Indent_Str_Sloc
("use type ");
2393 Sprint_Comma_List
(Subtype_Marks
(Node
));
2396 when N_Validate_Unchecked_Conversion
=>
2397 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
2398 Sprint_Node
(Source_Type
(Node
));
2400 Sprint_Node
(Target_Type
(Node
));
2404 Write_Indent_Str_Sloc
("when ");
2405 Sprint_Bar_List
(Discrete_Choices
(Node
));
2407 Sprint_Node
(Component_List
(Node
));
2409 when N_Variant_Part
=>
2411 Write_Indent_Str_Sloc
("case ");
2412 Sprint_Node
(Name
(Node
));
2414 Sprint_Indented_List
(Variants
(Node
));
2415 Write_Indent_Str
("end case");
2418 when N_With_Clause
=>
2420 -- Special test, if we are dumping the original tree only,
2421 -- then we want to eliminate the bogus with clauses that
2422 -- correspond to the non-existent children of Text_IO.
2424 if Dump_Original_Only
2425 and then Is_Text_IO_Kludge_Unit
(Name
(Node
))
2429 -- Normal case, output the with clause
2432 if First_Name
(Node
) or else not Dump_Original_Only
then
2433 Write_Indent_Str
("with ");
2438 Sprint_Node_Sloc
(Name
(Node
));
2440 if Last_Name
(Node
) or else not Dump_Original_Only
then
2445 when N_With_Type_Clause
=>
2447 Write_Indent_Str
("with type ");
2448 Sprint_Node_Sloc
(Name
(Node
));
2450 if Tagged_Present
(Node
) then
2451 Write_Str
(" is tagged;");
2453 Write_Str
(" is access;");
2458 if Nkind
(Node
) in N_Subexpr
2459 and then Do_Range_Check
(Node
)
2464 for J
in 1 .. Paren_Count
(Node
) loop
2468 pragma Assert
(No
(Debug_Node
));
2469 Debug_Node
:= Save_Debug_Node
;
2470 end Sprint_Node_Actual
;
2472 ----------------------
2473 -- Sprint_Node_List --
2474 ----------------------
2476 procedure Sprint_Node_List
(List
: List_Id
) is
2480 if Is_Non_Empty_List
(List
) then
2481 Node
:= First
(List
);
2486 exit when Node
= Empty
;
2489 end Sprint_Node_List
;
2491 ----------------------
2492 -- Sprint_Node_Sloc --
2493 ----------------------
2495 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
2499 if Present
(Debug_Node
) then
2500 Set_Sloc
(Debug_Node
, Sloc
(Node
));
2501 Debug_Node
:= Empty
;
2503 end Sprint_Node_Sloc
;
2505 ---------------------
2506 -- Sprint_Opt_Node --
2507 ---------------------
2509 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
2511 if Present
(Node
) then
2515 end Sprint_Opt_Node
;
2517 --------------------------
2518 -- Sprint_Opt_Node_List --
2519 --------------------------
2521 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
2523 if Present
(List
) then
2524 Sprint_Node_List
(List
);
2526 end Sprint_Opt_Node_List
;
2528 ---------------------------------
2529 -- Sprint_Opt_Paren_Comma_List --
2530 ---------------------------------
2532 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
2534 if Is_Non_Empty_List
(List
) then
2536 Sprint_Paren_Comma_List
(List
);
2538 end Sprint_Opt_Paren_Comma_List
;
2540 -----------------------------
2541 -- Sprint_Paren_Comma_List --
2542 -----------------------------
2544 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
2546 Node_Exists
: Boolean := False;
2550 if Is_Non_Empty_List
(List
) then
2552 if Dump_Original_Only
then
2555 while Present
(N
) loop
2557 if not Is_Rewrite_Insertion
(N
) then
2558 Node_Exists
:= True;
2565 if not Node_Exists
then
2570 Write_Str_With_Col_Check
("(");
2571 Sprint_Comma_List
(List
);
2574 end Sprint_Paren_Comma_List
;
2576 ---------------------
2577 -- Write_Char_Sloc --
2578 ---------------------
2580 procedure Write_Char_Sloc
(C
: Character) is
2582 if Debug_Generated_Code
and then C
/= ' ' then
2587 end Write_Char_Sloc
;
2589 ------------------------
2590 -- Write_Discr_Specs --
2591 ------------------------
2593 procedure Write_Discr_Specs
(N
: Node_Id
) is
2598 Specs
:= Discriminant_Specifications
(N
);
2600 if Present
(Specs
) then
2601 Write_Str_With_Col_Check
(" (");
2602 Spec
:= First
(Specs
);
2607 exit when Spec
= Empty
;
2609 -- Add semicolon, unless we are printing original tree and the
2610 -- next specification is part of a list (but not the first
2611 -- element of that list)
2613 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
2620 end Write_Discr_Specs
;
2626 procedure Write_Ekind
(E
: Entity_Id
) is
2627 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
2630 Name_Len
:= S
'Length;
2631 Name_Buffer
(1 .. Name_Len
) := S
;
2632 Set_Casing
(Mixed_Case
);
2633 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2640 procedure Write_Id
(N
: Node_Id
) is
2642 -- Case of a defining identifier
2644 if Nkind
(N
) = N_Defining_Identifier
then
2646 -- If defining identifier has an interface name (and no
2647 -- address clause), then we output the interface name.
2649 if (Is_Imported
(N
) or else Is_Exported
(N
))
2650 and then Present
(Interface_Name
(N
))
2651 and then No
(Address_Clause
(N
))
2653 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
2654 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2656 -- If no interface name (or inactive because there was
2657 -- an address clause), then just output the Chars name.
2660 Write_Name_With_Col_Check
(Chars
(N
));
2663 -- Case of selector of an expanded name where the expanded name
2664 -- has an associated entity, output this entity.
2666 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
2667 and then Selector_Name
(Parent
(N
)) = N
2668 and then Present
(Entity
(Parent
(N
)))
2670 Write_Id
(Entity
(Parent
(N
)));
2672 -- For any other kind of node with an associated entity, output it.
2674 elsif Nkind
(N
) in N_Has_Entity
2675 and then Present
(Entity
(N
))
2677 Write_Id
(Entity
(N
));
2679 -- All other cases, we just print the Chars field
2682 Write_Name_With_Col_Check
(Chars
(N
));
2686 -----------------------
2687 -- Write_Identifiers --
2688 -----------------------
2690 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
2692 Sprint_Node
(Defining_Identifier
(Node
));
2694 -- The remainder of the declaration must be printed unless we are
2695 -- printing the original tree and this is not the last identifier
2698 not Dump_Original_Only
or else not More_Ids
(Node
);
2700 end Write_Identifiers
;
2702 ------------------------
2703 -- Write_Implicit_Def --
2704 ------------------------
2706 procedure Write_Implicit_Def
(E
: Entity_Id
) is
2711 when E_Array_Subtype
=>
2712 Write_Str_With_Col_Check
("subtype ");
2714 Write_Str_With_Col_Check
(" is ");
2715 Write_Id
(Base_Type
(E
));
2716 Write_Str_With_Col_Check
(" (");
2718 Ind
:= First_Index
(E
);
2720 while Present
(Ind
) loop
2724 if Present
(Ind
) then
2731 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
2732 Write_Str_With_Col_Check
("subtype ");
2735 Write_Id
(Etype
(E
));
2736 Write_Str_With_Col_Check
(" range ");
2737 Sprint_Node
(Scalar_Range
(E
));
2741 Write_Str_With_Col_Check
("type ");
2743 Write_Str_With_Col_Check
(" is <");
2748 end Write_Implicit_Def
;
2754 procedure Write_Indent
is
2756 if Indent_Annull_Flag
then
2757 Indent_Annull_Flag
:= False;
2760 for J
in 1 .. Indent
loop
2766 ------------------------------
2767 -- Write_Indent_Identifiers --
2768 ------------------------------
2770 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
2772 -- We need to start a new line for every node, except in the case
2773 -- where we are printing the original tree and this is not the first
2774 -- defining identifier in the list.
2776 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
2779 -- If printing original tree and this is not the first defining
2780 -- identifier in the list, then the previous call to this procedure
2781 -- printed only the name, and we add a comma to separate the names.
2787 Sprint_Node
(Defining_Identifier
(Node
));
2789 -- The remainder of the declaration must be printed unless we are
2790 -- printing the original tree and this is not the last identifier
2793 not Dump_Original_Only
or else not More_Ids
(Node
);
2795 end Write_Indent_Identifiers
;
2797 -----------------------------------
2798 -- Write_Indent_Identifiers_Sloc --
2799 -----------------------------------
2801 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
2803 -- We need to start a new line for every node, except in the case
2804 -- where we are printing the original tree and this is not the first
2805 -- defining identifier in the list.
2807 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
2810 -- If printing original tree and this is not the first defining
2811 -- identifier in the list, then the previous call to this procedure
2812 -- printed only the name, and we add a comma to separate the names.
2819 Sprint_Node
(Defining_Identifier
(Node
));
2821 -- The remainder of the declaration must be printed unless we are
2822 -- printing the original tree and this is not the last identifier
2825 not Dump_Original_Only
or else not More_Ids
(Node
);
2827 end Write_Indent_Identifiers_Sloc
;
2829 ----------------------
2830 -- Write_Indent_Str --
2831 ----------------------
2833 procedure Write_Indent_Str
(S
: String) is
2837 end Write_Indent_Str
;
2839 ---------------------------
2840 -- Write_Indent_Str_Sloc --
2841 ---------------------------
2843 procedure Write_Indent_Str_Sloc
(S
: String) is
2847 end Write_Indent_Str_Sloc
;
2849 -------------------------------
2850 -- Write_Name_With_Col_Check --
2851 -------------------------------
2853 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
2857 Get_Name_String
(N
);
2859 -- Deal with -gnatI which replaces digits in an internal
2860 -- name by three dots (e.g. R7b becomes R...b).
2862 if Debug_Flag_II
and then Name_Buffer
(1) in 'A' .. 'Z' then
2865 while J
< Name_Len
loop
2866 exit when Name_Buffer
(J
) not in 'A' .. 'Z';
2870 if Name_Buffer
(J
) in '0' .. '9' then
2871 Write_Str_With_Col_Check
(Name_Buffer
(1 .. J
- 1));
2874 while J
<= Name_Len
loop
2875 if Name_Buffer
(J
) not in '0' .. '9' then
2876 Write_Str
(Name_Buffer
(J
.. Name_Len
));
2888 -- Fall through for normal case
2890 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2891 end Write_Name_With_Col_Check
;
2893 ------------------------------------
2894 -- Write_Name_With_Col_Check_Sloc --
2895 ------------------------------------
2897 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
2899 Get_Name_String
(N
);
2900 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
2901 end Write_Name_With_Col_Check_Sloc
;
2903 --------------------
2904 -- Write_Operator --
2905 --------------------
2907 procedure Write_Operator
(N
: Node_Id
; S
: String) is
2908 F
: Natural := S
'First;
2909 T
: Natural := S
'Last;
2921 if Do_Overflow_Check
(N
) then
2923 Write_Str_Sloc
(S
(F
.. T
));
2929 if S
(S
'Last) = ' ' then
2934 -----------------------
2935 -- Write_Param_Specs --
2936 -----------------------
2938 procedure Write_Param_Specs
(N
: Node_Id
) is
2944 Specs
:= Parameter_Specifications
(N
);
2946 if Is_Non_Empty_List
(Specs
) then
2947 Write_Str_With_Col_Check
(" (");
2948 Spec
:= First
(Specs
);
2952 Formal
:= Defining_Identifier
(Spec
);
2954 exit when Spec
= Empty
;
2956 -- Add semicolon, unless we are printing original tree and the
2957 -- next specification is part of a list (but not the first
2958 -- element of that list)
2960 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
2965 -- Write out any extra formals
2967 while Present
(Extra_Formal
(Formal
)) loop
2968 Formal
:= Extra_Formal
(Formal
);
2970 Write_Name_With_Col_Check
(Chars
(Formal
));
2972 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
2977 end Write_Param_Specs
;
2979 --------------------------
2980 -- Write_Rewrite_Str --
2981 --------------------------
2983 procedure Write_Rewrite_Str
(S
: String) is
2985 if not Dump_Generated_Only
then
2986 if S
'Length = 3 and then S
= ">>>" then
2989 Write_Str_With_Col_Check
(S
);
2992 end Write_Rewrite_Str
;
2994 --------------------
2995 -- Write_Str_Sloc --
2996 --------------------
2998 procedure Write_Str_Sloc
(S
: String) is
3000 for J
in S
'Range loop
3001 Write_Char_Sloc
(S
(J
));
3005 ------------------------------
3006 -- Write_Str_With_Col_Check --
3007 ------------------------------
3009 procedure Write_Str_With_Col_Check
(S
: String) is
3011 if Int
(S
'Last) + Column
> Line_Limit
then
3012 Write_Indent_Str
(" ");
3015 Write_Str
(S
(2 .. S
'Length));
3023 end Write_Str_With_Col_Check
;
3025 -----------------------------------
3026 -- Write_Str_With_Col_Check_Sloc --
3027 -----------------------------------
3029 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
3031 if Int
(S
'Last) + Column
> Line_Limit
then
3032 Write_Indent_Str
(" ");
3035 Write_Str_Sloc
(S
(2 .. S
'Length));
3043 end Write_Str_With_Col_Check_Sloc
;
3045 ------------------------------------
3046 -- Write_Uint_With_Col_Check_Sloc --
3047 ------------------------------------
3049 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
3051 Col_Check
(UI_Decimal_Digits_Hi
(U
));
3053 UI_Write
(U
, Format
);
3054 end Write_Uint_With_Col_Check_Sloc
;
3056 -------------------------------------
3057 -- Write_Ureal_With_Col_Check_Sloc --
3058 -------------------------------------
3060 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
3061 D
: constant Uint
:= Denominator
(U
);
3062 N
: constant Uint
:= Numerator
(U
);
3066 (UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
3069 end Write_Ureal_With_Col_Check_Sloc
;