1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
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
;
33 with Namet
; use Namet
;
34 with Nlists
; use Nlists
;
36 with Output
; use Output
;
37 with Rtsfind
; use Rtsfind
;
38 with Sinfo
; use Sinfo
;
39 with Sinput
; use Sinput
;
40 with Sinput
.D
; use Sinput
.D
;
41 with Snames
; use Snames
;
42 with Stand
; use Stand
;
43 with Stringt
; use Stringt
;
44 with Uintp
; use Uintp
;
45 with Uname
; use Uname
;
46 with Urealp
; use Urealp
;
48 package body Sprint
is
50 Debug_Node
: Node_Id
:= Empty
;
51 -- If we are in Debug_Generated_Code mode, then this location is set
52 -- to the current node requiring Sloc fixup, until Set_Debug_Sloc is
53 -- called to set the proper value. The call clears it back to Empty.
55 Debug_Sloc
: Source_Ptr
;
56 -- Sloc of first byte of line currently being written if we are
57 -- generating a source debug file.
59 Dump_Original_Only
: Boolean;
60 -- Set True if the -gnatdo (dump original tree) flag is set
62 Dump_Generated_Only
: Boolean;
63 -- Set True if the -gnatG (dump generated tree) debug flag is set
64 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
66 Dump_Freeze_Null
: Boolean;
67 -- Set True if freeze nodes and non-source null statements output
70 -- Number of columns for current line output indentation
72 Indent_Annull_Flag
: Boolean := False;
73 -- Set True if subsequent Write_Indent call to be ignored, gets reset
74 -- by this call, so it is only active to suppress a single indent call.
76 Line_Limit
: constant := 72;
77 -- Limit value for chopping long lines
79 Freeze_Indent
: Int
:= 0;
80 -- Keep track of freeze indent level (controls blank lines before
81 -- procedures within expression freeze actions)
83 -------------------------------
84 -- Operator Precedence Table --
85 -------------------------------
87 -- This table is used to decide whether a subexpression needs to be
88 -- parenthesized. The rule is that if an operand of an operator (which
89 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
90 -- with a lower precedence than the operator (or equal precedence if
91 -- appearing as the right operand), then parentheses are required.
93 Op_Prec
: constant array (N_Subexpr
) of Short_Short_Integer :=
126 procedure Sprint_Left_Opnd
(N
: Node_Id
);
127 -- Print left operand of operator, parenthesizing if necessary
129 procedure Sprint_Right_Opnd
(N
: Node_Id
);
130 -- Print right operand of operator, parenthesizing if necessary
132 -----------------------
133 -- Local Subprograms --
134 -----------------------
136 procedure Col_Check
(N
: Nat
);
137 -- Check that at least N characters remain on current line, and if not,
138 -- then start an extra line with two characters extra indentation for
139 -- continuing text on the next line.
141 procedure Indent_Annull
;
142 -- Causes following call to Write_Indent to be ignored. This is used when
143 -- a higher level node wants to stop a lower level node from starting a
144 -- new line, when it would otherwise be inclined to do so (e.g. the case
145 -- of an accept statement called from an accept alternative with a guard)
147 procedure Indent_Begin
;
148 -- Increase indentation level
150 procedure Indent_End
;
151 -- Decrease indentation level
153 procedure Print_Debug_Line
(S
: String);
154 -- Used to print output lines in Debug_Generated_Code mode (this is used
155 -- as the argument for a call to Set_Special_Output in package Output).
157 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
);
158 -- Given a divide, multiplication or division node, check the flags
159 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
160 -- appropriate special syntax characters (# and @).
162 procedure Set_Debug_Sloc
;
163 -- If Debug_Node is non-empty, this routine sets the appropriate value
164 -- in its Sloc field, from the current location in the debug source file
165 -- that is currently being written. Note that Debug_Node is always empty
166 -- if a debug source file is not being written.
168 procedure Sprint_Bar_List
(List
: List_Id
);
169 -- Print the given list with items separated by vertical bars
171 procedure Sprint_Node_Actual
(Node
: Node_Id
);
172 -- This routine prints its node argument. It is a lower level routine than
173 -- Sprint_Node, in that it does not bother about rewritten trees.
175 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
176 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
177 -- sets the Sloc of the current debug node to be a copy of the Sloc
178 -- of the sprinted node Node. Note that this is done after printing
179 -- Node, so that the Sloc is the proper updated value for the debug file.
181 procedure Write_Char_Sloc
(C
: Character);
182 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
183 -- called to ensure that the current node has a proper Sloc set.
185 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
186 -- Write Condition and Reason codes of Raise_xxx_Error node
188 procedure Write_Discr_Specs
(N
: Node_Id
);
189 -- Ouput discriminant specification for node, which is any of the type
190 -- declarations that can have discriminants.
192 procedure Write_Ekind
(E
: Entity_Id
);
193 -- Write the String corresponding to the Ekind without "E_".
195 procedure Write_Id
(N
: Node_Id
);
196 -- N is a node with a Chars field. This procedure writes the name that
197 -- will be used in the generated code associated with the name. For a
198 -- node with no associated entity, this is simply the Chars field. For
199 -- the case where there is an entity associated with the node, we print
200 -- the name associated with the entity (since it may have been encoded).
201 -- One other special case is that an entity has an active external name
202 -- (i.e. an external name present with no address clause), then this
203 -- external name is output.
205 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
206 -- Handle node where the grammar has a list of defining identifiers, but
207 -- the tree has a separate declaration for each identifier. Handles the
208 -- printing of the defining identifier, and returns True if the type and
209 -- initialization information is to be printed, False if it is to be
210 -- skipped (the latter case happens when printing defining identifiers
211 -- other than the first in the original tree output case).
213 procedure Write_Implicit_Def
(E
: Entity_Id
);
214 pragma Warnings
(Off
, Write_Implicit_Def
);
215 -- Write the definition of the implicit type E according to its Ekind
216 -- For now a debugging procedure, but might be used in the future.
218 procedure Write_Indent
;
219 -- Start a new line and write indentation spacing
221 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
222 -- Like Write_Identifiers except that each new printed declaration
223 -- is at the start of a new line.
225 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
226 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
227 -- mode, the Sloc of the current debug node is set to point ot the
228 -- first output identifier.
230 procedure Write_Indent_Str
(S
: String);
231 -- Start a new line and write indent spacing followed by given string
233 procedure Write_Indent_Str_Sloc
(S
: String);
234 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
235 -- the Sloc of the current node is set to the first non-blank character
238 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
239 -- Write name (using Write_Name) with initial column check, and possible
240 -- initial Write_Indent (to get new line) if current line is too full.
242 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
243 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
244 -- mode, sets Sloc of current debug node to first character of name.
246 procedure Write_Operator
(N
: Node_Id
; S
: String);
247 -- Like Write_Str_Sloc, used for operators, encloses the string in
248 -- characters {} if the Do_Overflow flag is set on the node N.
250 procedure Write_Param_Specs
(N
: Node_Id
);
251 -- Output parameter specifications for node (which is either a function
252 -- or procedure specification with a Parameter_Specifications field)
254 procedure Write_Rewrite_Str
(S
: String);
255 -- Writes out a string (typically containing <<< or >>>}) for a node
256 -- created by rewriting the tree. Suppressed if we are outputting the
257 -- generated code only, since in this case we don't specially mark nodes
258 -- created by rewriting).
260 procedure Write_Str_Sloc
(S
: String);
261 -- Like Write_Str, but sets debug Sloc of current debug node to first
262 -- non-blank character if a current debug node is active.
264 procedure Write_Str_With_Col_Check
(S
: String);
265 -- Write string (using Write_Str) with initial column check, and possible
266 -- initial Write_Indent (to get new line) if current line is too full.
268 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
269 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
270 -- node to first non-blank character if a current debug node is active.
272 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
273 -- Write Uint (using UI_Write) with initial column check, and possible
274 -- initial Write_Indent (to get new line) if current line is too full.
275 -- The format parameter determines the output format (see UI_Write).
276 -- In addition, in Debug_Generated_Code mode, sets the current node
277 -- Sloc to the first character of the output value.
279 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
280 -- Write Ureal (using same output format as UR_Write) with column checks
281 -- and a possible initial Write_Indent (to get new line) if current line
282 -- is too full. In addition, in Debug_Generated_Code mode, sets the
283 -- current node Sloc to the first character of the output value.
289 procedure Col_Check
(N
: Nat
) is
291 if N
+ Column
> Line_Limit
then
292 Write_Indent_Str
(" ");
300 procedure Indent_Annull
is
302 Indent_Annull_Flag
:= True;
309 procedure Indent_Begin
is
311 Indent
:= Indent
+ 3;
318 procedure Indent_End
is
320 Indent
:= Indent
- 3;
327 procedure pg
(Node
: Node_Id
) is
329 Dump_Generated_Only
:= True;
330 Dump_Original_Only
:= False;
339 procedure po
(Node
: Node_Id
) is
341 Dump_Generated_Only
:= False;
342 Dump_Original_Only
:= True;
347 ----------------------
348 -- Print_Debug_Line --
349 ----------------------
351 procedure Print_Debug_Line
(S
: String) is
353 Write_Debug_Line
(S
, Debug_Sloc
);
354 end Print_Debug_Line
;
356 ---------------------------
357 -- Process_TFAI_RR_Flags --
358 ---------------------------
360 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
362 if Treat_Fixed_As_Integer
(Nod
) then
366 if Rounded_Result
(Nod
) then
369 end Process_TFAI_RR_Flags
;
375 procedure ps
(Node
: Node_Id
) is
377 Dump_Generated_Only
:= False;
378 Dump_Original_Only
:= False;
387 procedure Set_Debug_Sloc
is
389 if Present
(Debug_Node
) then
390 Set_Sloc
(Debug_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
399 procedure Source_Dump
is
402 -- Put underline under string we just printed
404 procedure Underline
is
405 Col
: constant Int
:= Column
;
410 while Col
> Column
loop
417 -- Start of processing for Tree_Dump.
420 Dump_Generated_Only
:= Debug_Flag_G
or
421 Print_Generated_Code
or
422 Debug_Generated_Code
;
423 Dump_Original_Only
:= Debug_Flag_O
;
424 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
426 -- Note that we turn off the tree dump flags immediately, before
427 -- starting the dump. This avoids generating two copies of the dump
428 -- if an abort occurs after printing the dump, and more importantly,
429 -- avoids an infinite loop if an abort occurs during the dump.
432 Debug_Flag_Z
:= False;
435 Write_Str
("Source recreated from tree of Standard (spec)");
437 Sprint_Node
(Standard_Package_Node
);
442 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
443 Debug_Flag_G
:= False;
444 Debug_Flag_O
:= False;
445 Debug_Flag_S
:= False;
447 -- Dump requested units
449 for U
in Main_Unit
.. Last_Unit
loop
451 -- Dump all units if -gnatdf set, otherwise we dump only
452 -- the source files that are in the extended main source.
455 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
457 -- If we are generating debug files, setup to write them
459 if Debug_Generated_Code
then
460 Set_Special_Output
(Print_Debug_Line
'Access);
461 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
462 Sprint_Node
(Cunit
(U
));
465 Set_Special_Output
(null);
467 -- Normal output to standard output file
470 Write_Str
("Source recreated from tree for ");
471 Write_Unit_Name
(Unit_Name
(U
));
473 Sprint_Node
(Cunit
(U
));
482 ---------------------
483 -- Sprint_Bar_List --
484 ---------------------
486 procedure Sprint_Bar_List
(List
: List_Id
) is
490 if Is_Non_Empty_List
(List
) then
491 Node
:= First
(List
);
496 exit when Node
= Empty
;
502 -----------------------
503 -- Sprint_Comma_List --
504 -----------------------
506 procedure Sprint_Comma_List
(List
: List_Id
) is
510 if Is_Non_Empty_List
(List
) then
511 Node
:= First
(List
);
516 exit when Node
= Empty
;
518 if not Is_Rewrite_Insertion
(Node
)
519 or else not Dump_Original_Only
526 end Sprint_Comma_List
;
528 --------------------------
529 -- Sprint_Indented_List --
530 --------------------------
532 procedure Sprint_Indented_List
(List
: List_Id
) is
535 Sprint_Node_List
(List
);
537 end Sprint_Indented_List
;
539 ---------------------
540 -- Sprint_Left_Opnd --
541 ---------------------
543 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
544 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
547 if Paren_Count
(Opnd
) /= 0
548 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
557 end Sprint_Left_Opnd
;
563 procedure Sprint_Node
(Node
: Node_Id
) is
565 if Is_Rewrite_Insertion
(Node
) then
566 if not Dump_Original_Only
then
568 -- For special cases of nodes that always output <<< >>>
569 -- do not duplicate the output at this point.
571 if Nkind
(Node
) = N_Freeze_Entity
572 or else Nkind
(Node
) = N_Implicit_Label_Declaration
574 Sprint_Node_Actual
(Node
);
576 -- Normal case where <<< >>> may be required
579 Write_Rewrite_Str
("<<<");
580 Sprint_Node_Actual
(Node
);
581 Write_Rewrite_Str
(">>>");
585 elsif Is_Rewrite_Substitution
(Node
) then
587 -- Case of dump generated only
589 if Dump_Generated_Only
then
590 Sprint_Node_Actual
(Node
);
592 -- Case of dump original only
594 elsif Dump_Original_Only
then
595 Sprint_Node_Actual
(Original_Node
(Node
));
597 -- Case of both being dumped
600 Sprint_Node_Actual
(Original_Node
(Node
));
601 Write_Rewrite_Str
("<<<");
602 Sprint_Node_Actual
(Node
);
603 Write_Rewrite_Str
(">>>");
607 Sprint_Node_Actual
(Node
);
611 ------------------------
612 -- Sprint_Node_Actual --
613 ------------------------
615 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
616 Save_Debug_Node
: constant Node_Id
:= Debug_Node
;
623 for J
in 1 .. Paren_Count
(Node
) loop
624 Write_Str_With_Col_Check
("(");
627 -- Setup node for Sloc fixup if writing a debug source file. Note
628 -- that we take care of any previous node not yet properly set.
630 if Debug_Generated_Code
then
634 if Nkind
(Node
) in N_Subexpr
635 and then Do_Range_Check
(Node
)
637 Write_Str_With_Col_Check
("{");
640 -- Select print circuit based on node kind
644 when N_Abort_Statement
=>
645 Write_Indent_Str_Sloc
("abort ");
646 Sprint_Comma_List
(Names
(Node
));
649 when N_Abortable_Part
=>
651 Write_Str_Sloc
("abort ");
652 Sprint_Indented_List
(Statements
(Node
));
654 when N_Abstract_Subprogram_Declaration
=>
656 Sprint_Node
(Specification
(Node
));
657 Write_Str_With_Col_Check
(" is ");
658 Write_Str_Sloc
("abstract;");
660 when N_Accept_Alternative
=>
661 Sprint_Node_List
(Pragmas_Before
(Node
));
663 if Present
(Condition
(Node
)) then
664 Write_Indent_Str
("when ");
665 Sprint_Node
(Condition
(Node
));
670 Sprint_Node_Sloc
(Accept_Statement
(Node
));
671 Sprint_Node_List
(Statements
(Node
));
673 when N_Accept_Statement
=>
674 Write_Indent_Str_Sloc
("accept ");
675 Write_Id
(Entry_Direct_Name
(Node
));
677 if Present
(Entry_Index
(Node
)) then
678 Write_Str_With_Col_Check
(" (");
679 Sprint_Node
(Entry_Index
(Node
));
683 Write_Param_Specs
(Node
);
685 if Present
(Handled_Statement_Sequence
(Node
)) then
686 Write_Str_With_Col_Check
(" do");
687 Sprint_Node
(Handled_Statement_Sequence
(Node
));
688 Write_Indent_Str
("end ");
689 Write_Id
(Entry_Direct_Name
(Node
));
694 when N_Access_Definition
=>
698 if Present
(Access_To_Subprogram_Definition
(Node
)) then
699 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
703 if Null_Exclusion_Present
(Node
) then
704 Write_Str
("not null ");
707 Write_Str_With_Col_Check_Sloc
("access ");
709 if All_Present
(Node
) then
711 elsif Constant_Present
(Node
) then
712 Write_Str
("constant ");
715 Sprint_Node
(Subtype_Mark
(Node
));
718 when N_Access_Function_Definition
=>
722 if Null_Exclusion_Present
(Node
) then
723 Write_Str
("not null ");
726 Write_Str_With_Col_Check_Sloc
("access ");
728 if Protected_Present
(Node
) then
729 Write_Str_With_Col_Check
("protected ");
732 Write_Str_With_Col_Check
("function");
733 Write_Param_Specs
(Node
);
734 Write_Str_With_Col_Check
(" return ");
735 Sprint_Node
(Subtype_Mark
(Node
));
737 when N_Access_Procedure_Definition
=>
740 if Null_Exclusion_Present
(Node
) then
741 Write_Str
("not null ");
744 Write_Str_With_Col_Check_Sloc
("access ");
746 if Protected_Present
(Node
) then
747 Write_Str_With_Col_Check
("protected ");
750 Write_Str_With_Col_Check
("procedure");
751 Write_Param_Specs
(Node
);
753 when N_Access_To_Object_Definition
=>
754 Write_Str_With_Col_Check_Sloc
("access ");
756 if All_Present
(Node
) then
757 Write_Str_With_Col_Check
("all ");
758 elsif Constant_Present
(Node
) then
759 Write_Str_With_Col_Check
("constant ");
764 if Null_Exclusion_Present
(Node
) then
765 Write_Str
("not null ");
768 Sprint_Node
(Subtype_Indication
(Node
));
771 if Null_Record_Present
(Node
) then
772 Write_Str_With_Col_Check_Sloc
("(null record)");
775 Write_Str_With_Col_Check_Sloc
("(");
777 if Present
(Expressions
(Node
)) then
778 Sprint_Comma_List
(Expressions
(Node
));
780 if Present
(Component_Associations
(Node
)) then
785 if Present
(Component_Associations
(Node
)) then
792 Nd
:= First
(Component_Associations
(Node
));
800 if not Is_Rewrite_Insertion
(Nd
)
801 or else not Dump_Original_Only
815 Write_Str_With_Col_Check_Sloc
("new ");
818 if Null_Exclusion_Present
(Node
) then
819 Write_Str
("not null ");
822 Sprint_Node
(Expression
(Node
));
824 if Present
(Storage_Pool
(Node
)) then
825 Write_Str_With_Col_Check
("[storage_pool = ");
826 Sprint_Node
(Storage_Pool
(Node
));
831 Sprint_Left_Opnd
(Node
);
832 Write_Str_Sloc
(" and then ");
833 Sprint_Right_Opnd
(Node
);
836 Write_Indent_Str_Sloc
("for ");
837 Write_Id
(Identifier
(Node
));
838 Write_Str_With_Col_Check
(" use at ");
839 Sprint_Node
(Expression
(Node
));
842 when N_Assignment_Statement
=>
844 Sprint_Node
(Name
(Node
));
845 Write_Str_Sloc
(" := ");
846 Sprint_Node
(Expression
(Node
));
849 when N_Asynchronous_Select
=>
850 Write_Indent_Str_Sloc
("select");
852 Sprint_Node
(Triggering_Alternative
(Node
));
855 -- Note: let the printing of Abortable_Part handle outputting
856 -- the ABORT keyword, so that the Slco can be set correctly.
858 Write_Indent_Str
("then ");
859 Sprint_Node
(Abortable_Part
(Node
));
860 Write_Indent_Str
("end select;");
862 when N_Attribute_Definition_Clause
=>
863 Write_Indent_Str_Sloc
("for ");
864 Sprint_Node
(Name
(Node
));
866 Write_Name_With_Col_Check
(Chars
(Node
));
867 Write_Str_With_Col_Check
(" use ");
868 Sprint_Node
(Expression
(Node
));
871 when N_Attribute_Reference
=>
872 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
876 Sprint_Node
(Prefix
(Node
));
877 Write_Char_Sloc
(''');
878 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
879 Sprint_Paren_Comma_List
(Expressions
(Node
));
881 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
885 when N_Block_Statement
=>
888 if Present
(Identifier
(Node
))
889 and then (not Has_Created_Identifier
(Node
)
890 or else not Dump_Original_Only
)
892 Write_Rewrite_Str
("<<<");
893 Write_Id
(Identifier
(Node
));
895 Write_Rewrite_Str
(">>>");
898 if Present
(Declarations
(Node
)) then
899 Write_Str_With_Col_Check_Sloc
("declare");
900 Sprint_Indented_List
(Declarations
(Node
));
904 Write_Str_With_Col_Check_Sloc
("begin");
905 Sprint_Node
(Handled_Statement_Sequence
(Node
));
906 Write_Indent_Str
("end");
908 if Present
(Identifier
(Node
))
909 and then (not Has_Created_Identifier
(Node
)
910 or else not Dump_Original_Only
)
912 Write_Rewrite_Str
("<<<");
914 Write_Id
(Identifier
(Node
));
915 Write_Rewrite_Str
(">>>");
920 when N_Case_Statement
=>
921 Write_Indent_Str_Sloc
("case ");
922 Sprint_Node
(Expression
(Node
));
924 Sprint_Indented_List
(Alternatives
(Node
));
925 Write_Indent_Str
("end case;");
927 when N_Case_Statement_Alternative
=>
928 Write_Indent_Str_Sloc
("when ");
929 Sprint_Bar_List
(Discrete_Choices
(Node
));
931 Sprint_Indented_List
(Statements
(Node
));
933 when N_Character_Literal
=>
935 Write_Indent_Str
(" ");
938 Write_Char_Sloc
(''');
939 Write_Char_Code
(Char_Literal_Value
(Node
));
942 when N_Code_Statement
=>
945 Sprint_Node
(Expression
(Node
));
948 when N_Compilation_Unit
=>
949 Sprint_Node_List
(Context_Items
(Node
));
950 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
952 if Private_Present
(Node
) then
953 Write_Indent_Str
("private ");
957 Sprint_Node_Sloc
(Unit
(Node
));
959 if Present
(Actions
(Aux_Decls_Node
(Node
)))
961 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
966 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
967 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
969 when N_Compilation_Unit_Aux
=>
970 null; -- nothing to do, never used, see above
972 when N_Component_Association
=>
974 Sprint_Bar_List
(Choices
(Node
));
977 -- Ada 0Y (AI-287): Print the mbox if present
979 if Box_Present
(Node
) then
980 Write_Str_With_Col_Check
("<>");
982 Sprint_Node
(Expression
(Node
));
985 when N_Component_Clause
=>
987 Sprint_Node
(Component_Name
(Node
));
988 Write_Str_Sloc
(" at ");
989 Sprint_Node
(Position
(Node
));
991 Write_Str_With_Col_Check
("range ");
992 Sprint_Node
(First_Bit
(Node
));
994 Sprint_Node
(Last_Bit
(Node
));
997 when N_Component_Definition
=>
1000 -- Ada 0Y (AI-230): Access definition components
1002 if Present
(Access_Definition
(Node
)) then
1003 Sprint_Node
(Access_Definition
(Node
));
1005 elsif Present
(Subtype_Indication
(Node
)) then
1006 if Aliased_Present
(Node
) then
1007 Write_Str_With_Col_Check
("aliased ");
1012 if Null_Exclusion_Present
(Node
) then
1013 Write_Str
(" not null ");
1016 Sprint_Node
(Subtype_Indication
(Node
));
1019 Write_Str
(" ??? ");
1022 when N_Component_Declaration
=>
1023 if Write_Indent_Identifiers_Sloc
(Node
) then
1025 Sprint_Node
(Component_Definition
(Node
));
1027 if Present
(Expression
(Node
)) then
1029 Sprint_Node
(Expression
(Node
));
1035 when N_Component_List
=>
1036 if Null_Present
(Node
) then
1038 Write_Indent_Str_Sloc
("null");
1044 Sprint_Indented_List
(Component_Items
(Node
));
1045 Sprint_Node
(Variant_Part
(Node
));
1048 when N_Conditional_Entry_Call
=>
1049 Write_Indent_Str_Sloc
("select");
1051 Sprint_Node
(Entry_Call_Alternative
(Node
));
1053 Write_Indent_Str
("else");
1054 Sprint_Indented_List
(Else_Statements
(Node
));
1055 Write_Indent_Str
("end select;");
1057 when N_Conditional_Expression
=>
1059 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
1060 Then_Expr
: constant Node_Id
:= Next
(Condition
);
1061 Else_Expr
: constant Node_Id
:= Next
(Then_Expr
);
1064 Write_Str_With_Col_Check_Sloc
("(if ");
1065 Sprint_Node
(Condition
);
1066 Write_Str_With_Col_Check
(" then ");
1067 Sprint_Node
(Then_Expr
);
1068 Write_Str_With_Col_Check
(" else ");
1069 Sprint_Node
(Else_Expr
);
1073 when N_Constrained_Array_Definition
=>
1074 Write_Str_With_Col_Check_Sloc
("array ");
1075 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1078 Sprint_Node
(Component_Definition
(Node
));
1080 when N_Decimal_Fixed_Point_Definition
=>
1081 Write_Str_With_Col_Check_Sloc
(" delta ");
1082 Sprint_Node
(Delta_Expression
(Node
));
1083 Write_Str_With_Col_Check
("digits ");
1084 Sprint_Node
(Digits_Expression
(Node
));
1085 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1087 when N_Defining_Character_Literal
=>
1088 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1090 when N_Defining_Identifier
=>
1094 when N_Defining_Operator_Symbol
=>
1095 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1097 when N_Defining_Program_Unit_Name
=>
1099 Sprint_Node
(Name
(Node
));
1101 Write_Id
(Defining_Identifier
(Node
));
1103 when N_Delay_Alternative
=>
1104 Sprint_Node_List
(Pragmas_Before
(Node
));
1106 if Present
(Condition
(Node
)) then
1108 Write_Str_With_Col_Check
("when ");
1109 Sprint_Node
(Condition
(Node
));
1114 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1115 Sprint_Node_List
(Statements
(Node
));
1117 when N_Delay_Relative_Statement
=>
1118 Write_Indent_Str_Sloc
("delay ");
1119 Sprint_Node
(Expression
(Node
));
1122 when N_Delay_Until_Statement
=>
1123 Write_Indent_Str_Sloc
("delay until ");
1124 Sprint_Node
(Expression
(Node
));
1127 when N_Delta_Constraint
=>
1128 Write_Str_With_Col_Check_Sloc
("delta ");
1129 Sprint_Node
(Delta_Expression
(Node
));
1130 Sprint_Opt_Node
(Range_Constraint
(Node
));
1132 when N_Derived_Type_Definition
=>
1133 if Abstract_Present
(Node
) then
1134 Write_Str_With_Col_Check
("abstract ");
1137 Write_Str_With_Col_Check_Sloc
("new ");
1141 if Null_Exclusion_Present
(Node
) then
1142 Write_Str_With_Col_Check
("not null ");
1145 Sprint_Node
(Subtype_Indication
(Node
));
1147 if Present
(Record_Extension_Part
(Node
)) then
1148 Write_Str_With_Col_Check
(" with ");
1149 Sprint_Node
(Record_Extension_Part
(Node
));
1152 when N_Designator
=>
1153 Sprint_Node
(Name
(Node
));
1154 Write_Char_Sloc
('.');
1155 Write_Id
(Identifier
(Node
));
1157 when N_Digits_Constraint
=>
1158 Write_Str_With_Col_Check_Sloc
("digits ");
1159 Sprint_Node
(Digits_Expression
(Node
));
1160 Sprint_Opt_Node
(Range_Constraint
(Node
));
1162 when N_Discriminant_Association
=>
1165 if Present
(Selector_Names
(Node
)) then
1166 Sprint_Bar_List
(Selector_Names
(Node
));
1171 Sprint_Node
(Expression
(Node
));
1173 when N_Discriminant_Specification
=>
1176 if Write_Identifiers
(Node
) then
1179 if Null_Exclusion_Present
(Node
) then
1180 Write_Str
("not null ");
1183 Sprint_Node
(Discriminant_Type
(Node
));
1185 if Present
(Expression
(Node
)) then
1187 Sprint_Node
(Expression
(Node
));
1193 when N_Elsif_Part
=>
1194 Write_Indent_Str_Sloc
("elsif ");
1195 Sprint_Node
(Condition
(Node
));
1196 Write_Str_With_Col_Check
(" then");
1197 Sprint_Indented_List
(Then_Statements
(Node
));
1202 when N_Entry_Body
=>
1203 Write_Indent_Str_Sloc
("entry ");
1204 Write_Id
(Defining_Identifier
(Node
));
1205 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1206 Write_Str_With_Col_Check
(" is");
1207 Sprint_Indented_List
(Declarations
(Node
));
1208 Write_Indent_Str
("begin");
1209 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1210 Write_Indent_Str
("end ");
1211 Write_Id
(Defining_Identifier
(Node
));
1214 when N_Entry_Body_Formal_Part
=>
1215 if Present
(Entry_Index_Specification
(Node
)) then
1216 Write_Str_With_Col_Check_Sloc
(" (");
1217 Sprint_Node
(Entry_Index_Specification
(Node
));
1221 Write_Param_Specs
(Node
);
1222 Write_Str_With_Col_Check_Sloc
(" when ");
1223 Sprint_Node
(Condition
(Node
));
1225 when N_Entry_Call_Alternative
=>
1226 Sprint_Node_List
(Pragmas_Before
(Node
));
1227 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1228 Sprint_Node_List
(Statements
(Node
));
1230 when N_Entry_Call_Statement
=>
1232 Sprint_Node_Sloc
(Name
(Node
));
1233 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1236 when N_Entry_Declaration
=>
1237 Write_Indent_Str_Sloc
("entry ");
1238 Write_Id
(Defining_Identifier
(Node
));
1240 if Present
(Discrete_Subtype_Definition
(Node
)) then
1241 Write_Str_With_Col_Check
(" (");
1242 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1246 Write_Param_Specs
(Node
);
1249 when N_Entry_Index_Specification
=>
1250 Write_Str_With_Col_Check_Sloc
("for ");
1251 Write_Id
(Defining_Identifier
(Node
));
1252 Write_Str_With_Col_Check
(" in ");
1253 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1255 when N_Enumeration_Representation_Clause
=>
1256 Write_Indent_Str_Sloc
("for ");
1257 Write_Id
(Identifier
(Node
));
1258 Write_Str_With_Col_Check
(" use ");
1259 Sprint_Node
(Array_Aggregate
(Node
));
1262 when N_Enumeration_Type_Definition
=>
1265 -- Skip attempt to print Literals field if it's not there and
1266 -- we are in package Standard (case of Character, which is
1267 -- handled specially (without an explicit literals list).
1269 if Sloc
(Node
) > Standard_Location
1270 or else Present
(Literals
(Node
))
1272 Sprint_Paren_Comma_List
(Literals
(Node
));
1276 Write_Str_With_Col_Check_Sloc
("<error>");
1278 when N_Exception_Declaration
=>
1279 if Write_Indent_Identifiers
(Node
) then
1280 Write_Str_With_Col_Check
(" : ");
1281 Write_Str_Sloc
("exception;");
1284 when N_Exception_Handler
=>
1285 Write_Indent_Str_Sloc
("when ");
1287 if Present
(Choice_Parameter
(Node
)) then
1288 Sprint_Node
(Choice_Parameter
(Node
));
1292 Sprint_Bar_List
(Exception_Choices
(Node
));
1294 Sprint_Indented_List
(Statements
(Node
));
1296 when N_Exception_Renaming_Declaration
=>
1299 Sprint_Node
(Defining_Identifier
(Node
));
1300 Write_Str_With_Col_Check
(" : exception renames ");
1301 Sprint_Node
(Name
(Node
));
1304 when N_Exit_Statement
=>
1305 Write_Indent_Str_Sloc
("exit");
1306 Sprint_Opt_Node
(Name
(Node
));
1308 if Present
(Condition
(Node
)) then
1309 Write_Str_With_Col_Check
(" when ");
1310 Sprint_Node
(Condition
(Node
));
1315 when N_Expanded_Name
=>
1316 Sprint_Node
(Prefix
(Node
));
1317 Write_Char_Sloc
('.');
1318 Sprint_Node
(Selector_Name
(Node
));
1320 when N_Explicit_Dereference
=>
1321 Sprint_Node
(Prefix
(Node
));
1322 Write_Char_Sloc
('.');
1323 Write_Str_Sloc
("all");
1325 when N_Extension_Aggregate
=>
1326 Write_Str_With_Col_Check_Sloc
("(");
1327 Sprint_Node
(Ancestor_Part
(Node
));
1328 Write_Str_With_Col_Check
(" with ");
1330 if Null_Record_Present
(Node
) then
1331 Write_Str_With_Col_Check
("null record");
1333 if Present
(Expressions
(Node
)) then
1334 Sprint_Comma_List
(Expressions
(Node
));
1336 if Present
(Component_Associations
(Node
)) then
1341 if Present
(Component_Associations
(Node
)) then
1342 Sprint_Comma_List
(Component_Associations
(Node
));
1348 when N_Floating_Point_Definition
=>
1349 Write_Str_With_Col_Check_Sloc
("digits ");
1350 Sprint_Node
(Digits_Expression
(Node
));
1351 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1353 when N_Formal_Decimal_Fixed_Point_Definition
=>
1354 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1356 when N_Formal_Derived_Type_Definition
=>
1357 Write_Str_With_Col_Check_Sloc
("new ");
1358 Sprint_Node
(Subtype_Mark
(Node
));
1360 if Private_Present
(Node
) then
1361 Write_Str_With_Col_Check
(" with private");
1364 when N_Formal_Discrete_Type_Definition
=>
1365 Write_Str_With_Col_Check_Sloc
("<>");
1367 when N_Formal_Floating_Point_Definition
=>
1368 Write_Str_With_Col_Check_Sloc
("digits <>");
1370 when N_Formal_Modular_Type_Definition
=>
1371 Write_Str_With_Col_Check_Sloc
("mod <>");
1373 when N_Formal_Object_Declaration
=>
1376 if Write_Indent_Identifiers
(Node
) then
1379 if In_Present
(Node
) then
1380 Write_Str_With_Col_Check
("in ");
1383 if Out_Present
(Node
) then
1384 Write_Str_With_Col_Check
("out ");
1387 Sprint_Node
(Subtype_Mark
(Node
));
1389 if Present
(Expression
(Node
)) then
1391 Sprint_Node
(Expression
(Node
));
1397 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1398 Write_Str_With_Col_Check_Sloc
("delta <>");
1400 when N_Formal_Package_Declaration
=>
1401 Write_Indent_Str_Sloc
("with package ");
1402 Write_Id
(Defining_Identifier
(Node
));
1403 Write_Str_With_Col_Check
(" is new ");
1404 Sprint_Node
(Name
(Node
));
1405 Write_Str_With_Col_Check
(" (<>);");
1407 when N_Formal_Private_Type_Definition
=>
1408 if Abstract_Present
(Node
) then
1409 Write_Str_With_Col_Check
("abstract ");
1412 if Tagged_Present
(Node
) then
1413 Write_Str_With_Col_Check
("tagged ");
1416 if Limited_Present
(Node
) then
1417 Write_Str_With_Col_Check
("limited ");
1420 Write_Str_With_Col_Check_Sloc
("private");
1422 when N_Formal_Signed_Integer_Type_Definition
=>
1423 Write_Str_With_Col_Check_Sloc
("range <>");
1425 when N_Formal_Subprogram_Declaration
=>
1426 Write_Indent_Str_Sloc
("with ");
1427 Sprint_Node
(Specification
(Node
));
1429 if Box_Present
(Node
) then
1430 Write_Str_With_Col_Check
(" is <>");
1431 elsif Present
(Default_Name
(Node
)) then
1432 Write_Str_With_Col_Check
(" is ");
1433 Sprint_Node
(Default_Name
(Node
));
1438 when N_Formal_Type_Declaration
=>
1439 Write_Indent_Str_Sloc
("type ");
1440 Write_Id
(Defining_Identifier
(Node
));
1442 if Present
(Discriminant_Specifications
(Node
)) then
1443 Write_Discr_Specs
(Node
);
1444 elsif Unknown_Discriminants_Present
(Node
) then
1445 Write_Str_With_Col_Check
("(<>)");
1448 Write_Str_With_Col_Check
(" is ");
1449 Sprint_Node
(Formal_Type_Definition
(Node
));
1452 when N_Free_Statement
=>
1453 Write_Indent_Str_Sloc
("free ");
1454 Sprint_Node
(Expression
(Node
));
1457 when N_Freeze_Entity
=>
1458 if Dump_Original_Only
then
1461 elsif Present
(Actions
(Node
)) or else Dump_Freeze_Null
then
1463 Write_Rewrite_Str
("<<<");
1464 Write_Str_With_Col_Check_Sloc
("freeze ");
1465 Write_Id
(Entity
(Node
));
1468 if No
(Actions
(Node
)) then
1472 Freeze_Indent
:= Freeze_Indent
+ 1;
1473 Sprint_Indented_List
(Actions
(Node
));
1474 Freeze_Indent
:= Freeze_Indent
- 1;
1475 Write_Indent_Str
("]");
1478 Write_Rewrite_Str
(">>>");
1481 when N_Full_Type_Declaration
=>
1482 Write_Indent_Str_Sloc
("type ");
1483 Write_Id
(Defining_Identifier
(Node
));
1484 Write_Discr_Specs
(Node
);
1485 Write_Str_With_Col_Check
(" is ");
1486 Sprint_Node
(Type_Definition
(Node
));
1489 when N_Function_Call
=>
1491 Sprint_Node
(Name
(Node
));
1492 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1494 when N_Function_Instantiation
=>
1495 Write_Indent_Str_Sloc
("function ");
1496 Sprint_Node
(Defining_Unit_Name
(Node
));
1497 Write_Str_With_Col_Check
(" is new ");
1498 Sprint_Node
(Name
(Node
));
1499 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1502 when N_Function_Specification
=>
1503 Write_Str_With_Col_Check_Sloc
("function ");
1504 Sprint_Node
(Defining_Unit_Name
(Node
));
1505 Write_Param_Specs
(Node
);
1506 Write_Str_With_Col_Check
(" return ");
1507 Sprint_Node
(Subtype_Mark
(Node
));
1509 when N_Generic_Association
=>
1512 if Present
(Selector_Name
(Node
)) then
1513 Sprint_Node
(Selector_Name
(Node
));
1517 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
1519 when N_Generic_Function_Renaming_Declaration
=>
1520 Write_Indent_Str_Sloc
("generic function ");
1521 Sprint_Node
(Defining_Unit_Name
(Node
));
1522 Write_Str_With_Col_Check
(" renames ");
1523 Sprint_Node
(Name
(Node
));
1526 when N_Generic_Package_Declaration
=>
1528 Write_Indent_Str_Sloc
("generic ");
1529 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1531 Sprint_Node
(Specification
(Node
));
1534 when N_Generic_Package_Renaming_Declaration
=>
1535 Write_Indent_Str_Sloc
("generic package ");
1536 Sprint_Node
(Defining_Unit_Name
(Node
));
1537 Write_Str_With_Col_Check
(" renames ");
1538 Sprint_Node
(Name
(Node
));
1541 when N_Generic_Procedure_Renaming_Declaration
=>
1542 Write_Indent_Str_Sloc
("generic procedure ");
1543 Sprint_Node
(Defining_Unit_Name
(Node
));
1544 Write_Str_With_Col_Check
(" renames ");
1545 Sprint_Node
(Name
(Node
));
1548 when N_Generic_Subprogram_Declaration
=>
1550 Write_Indent_Str_Sloc
("generic ");
1551 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1553 Sprint_Node
(Specification
(Node
));
1556 when N_Goto_Statement
=>
1557 Write_Indent_Str_Sloc
("goto ");
1558 Sprint_Node
(Name
(Node
));
1561 if Nkind
(Next
(Node
)) = N_Label
then
1565 when N_Handled_Sequence_Of_Statements
=>
1567 Sprint_Indented_List
(Statements
(Node
));
1569 if Present
(Exception_Handlers
(Node
)) then
1570 Write_Indent_Str
("exception");
1572 Sprint_Node_List
(Exception_Handlers
(Node
));
1576 if Present
(At_End_Proc
(Node
)) then
1577 Write_Indent_Str
("at end");
1580 Sprint_Node
(At_End_Proc
(Node
));
1585 when N_Identifier
=>
1589 when N_If_Statement
=>
1590 Write_Indent_Str_Sloc
("if ");
1591 Sprint_Node
(Condition
(Node
));
1592 Write_Str_With_Col_Check
(" then");
1593 Sprint_Indented_List
(Then_Statements
(Node
));
1594 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
1596 if Present
(Else_Statements
(Node
)) then
1597 Write_Indent_Str
("else");
1598 Sprint_Indented_List
(Else_Statements
(Node
));
1601 Write_Indent_Str
("end if;");
1603 when N_Implicit_Label_Declaration
=>
1604 if not Dump_Original_Only
then
1606 Write_Rewrite_Str
("<<<");
1608 Write_Id
(Defining_Identifier
(Node
));
1610 Write_Str_With_Col_Check
("label");
1611 Write_Rewrite_Str
(">>>");
1615 Sprint_Left_Opnd
(Node
);
1616 Write_Str_Sloc
(" in ");
1617 Sprint_Right_Opnd
(Node
);
1619 when N_Incomplete_Type_Declaration
=>
1620 Write_Indent_Str_Sloc
("type ");
1621 Write_Id
(Defining_Identifier
(Node
));
1623 if Present
(Discriminant_Specifications
(Node
)) then
1624 Write_Discr_Specs
(Node
);
1625 elsif Unknown_Discriminants_Present
(Node
) then
1626 Write_Str_With_Col_Check
("(<>)");
1631 when N_Index_Or_Discriminant_Constraint
=>
1633 Sprint_Paren_Comma_List
(Constraints
(Node
));
1635 when N_Indexed_Component
=>
1636 Sprint_Node_Sloc
(Prefix
(Node
));
1637 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
1639 when N_Integer_Literal
=>
1640 if Print_In_Hex
(Node
) then
1641 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
1643 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
1646 when N_Iteration_Scheme
=>
1647 if Present
(Condition
(Node
)) then
1648 Write_Str_With_Col_Check_Sloc
("while ");
1649 Sprint_Node
(Condition
(Node
));
1651 Write_Str_With_Col_Check_Sloc
("for ");
1652 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1657 when N_Itype_Reference
=>
1658 Write_Indent_Str_Sloc
("reference ");
1659 Write_Id
(Itype
(Node
));
1662 Write_Indent_Str_Sloc
("<<");
1663 Write_Id
(Identifier
(Node
));
1666 when N_Loop_Parameter_Specification
=>
1668 Write_Id
(Defining_Identifier
(Node
));
1669 Write_Str_With_Col_Check
(" in ");
1671 if Reverse_Present
(Node
) then
1672 Write_Str_With_Col_Check
("reverse ");
1675 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1677 when N_Loop_Statement
=>
1680 if Present
(Identifier
(Node
))
1681 and then (not Has_Created_Identifier
(Node
)
1682 or else not Dump_Original_Only
)
1684 Write_Rewrite_Str
("<<<");
1685 Write_Id
(Identifier
(Node
));
1687 Write_Rewrite_Str
(">>>");
1688 Sprint_Node
(Iteration_Scheme
(Node
));
1689 Write_Str_With_Col_Check_Sloc
("loop");
1690 Sprint_Indented_List
(Statements
(Node
));
1691 Write_Indent_Str
("end loop ");
1692 Write_Rewrite_Str
("<<<");
1693 Write_Id
(Identifier
(Node
));
1694 Write_Rewrite_Str
(">>>");
1698 Sprint_Node
(Iteration_Scheme
(Node
));
1699 Write_Str_With_Col_Check_Sloc
("loop");
1700 Sprint_Indented_List
(Statements
(Node
));
1701 Write_Indent_Str
("end loop;");
1704 when N_Mod_Clause
=>
1705 Sprint_Node_List
(Pragmas_Before
(Node
));
1706 Write_Str_With_Col_Check_Sloc
("at mod ");
1707 Sprint_Node
(Expression
(Node
));
1709 when N_Modular_Type_Definition
=>
1710 Write_Str_With_Col_Check_Sloc
("mod ");
1711 Sprint_Node
(Expression
(Node
));
1714 Sprint_Left_Opnd
(Node
);
1715 Write_Str_Sloc
(" not in ");
1716 Sprint_Right_Opnd
(Node
);
1719 Write_Str_With_Col_Check_Sloc
("null");
1721 when N_Null_Statement
=>
1722 if Comes_From_Source
(Node
)
1723 or else Dump_Freeze_Null
1724 or else not Is_List_Member
(Node
)
1725 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
1727 Write_Indent_Str_Sloc
("null;");
1730 when N_Number_Declaration
=>
1733 if Write_Indent_Identifiers
(Node
) then
1734 Write_Str_With_Col_Check
(" : constant ");
1736 Sprint_Node
(Expression
(Node
));
1740 when N_Object_Declaration
=>
1743 if Write_Indent_Identifiers
(Node
) then
1746 if Aliased_Present
(Node
) then
1747 Write_Str_With_Col_Check
("aliased ");
1750 if Constant_Present
(Node
) then
1751 Write_Str_With_Col_Check
("constant ");
1756 if Null_Exclusion_Present
(Node
) then
1757 Write_Str_With_Col_Check
("not null ");
1760 Sprint_Node
(Object_Definition
(Node
));
1762 if Present
(Expression
(Node
)) then
1764 Sprint_Node
(Expression
(Node
));
1770 when N_Object_Renaming_Declaration
=>
1773 Sprint_Node
(Defining_Identifier
(Node
));
1776 -- Ada 0Y (AI-230): Access renamings
1778 if Present
(Access_Definition
(Node
)) then
1779 Sprint_Node
(Access_Definition
(Node
));
1781 elsif Present
(Subtype_Mark
(Node
)) then
1782 Sprint_Node
(Subtype_Mark
(Node
));
1785 Write_Str
(" ??? ");
1788 Write_Str_With_Col_Check
(" renames ");
1789 Sprint_Node
(Name
(Node
));
1793 Write_Operator
(Node
, "abs ");
1794 Sprint_Right_Opnd
(Node
);
1797 Sprint_Left_Opnd
(Node
);
1798 Write_Operator
(Node
, " + ");
1799 Sprint_Right_Opnd
(Node
);
1802 Sprint_Left_Opnd
(Node
);
1803 Write_Operator
(Node
, " and ");
1804 Sprint_Right_Opnd
(Node
);
1807 Sprint_Left_Opnd
(Node
);
1808 Write_Operator
(Node
, " & ");
1809 Sprint_Right_Opnd
(Node
);
1812 Sprint_Left_Opnd
(Node
);
1814 Process_TFAI_RR_Flags
(Node
);
1815 Write_Operator
(Node
, "/ ");
1816 Sprint_Right_Opnd
(Node
);
1819 Sprint_Left_Opnd
(Node
);
1820 Write_Operator
(Node
, " = ");
1821 Sprint_Right_Opnd
(Node
);
1824 Sprint_Left_Opnd
(Node
);
1825 Write_Operator
(Node
, " ** ");
1826 Sprint_Right_Opnd
(Node
);
1829 Sprint_Left_Opnd
(Node
);
1830 Write_Operator
(Node
, " >= ");
1831 Sprint_Right_Opnd
(Node
);
1834 Sprint_Left_Opnd
(Node
);
1835 Write_Operator
(Node
, " > ");
1836 Sprint_Right_Opnd
(Node
);
1839 Sprint_Left_Opnd
(Node
);
1840 Write_Operator
(Node
, " <= ");
1841 Sprint_Right_Opnd
(Node
);
1844 Sprint_Left_Opnd
(Node
);
1845 Write_Operator
(Node
, " < ");
1846 Sprint_Right_Opnd
(Node
);
1849 Write_Operator
(Node
, "-");
1850 Sprint_Right_Opnd
(Node
);
1853 Sprint_Left_Opnd
(Node
);
1855 if Treat_Fixed_As_Integer
(Node
) then
1859 Write_Operator
(Node
, " mod ");
1860 Sprint_Right_Opnd
(Node
);
1862 when N_Op_Multiply
=>
1863 Sprint_Left_Opnd
(Node
);
1865 Process_TFAI_RR_Flags
(Node
);
1866 Write_Operator
(Node
, "* ");
1867 Sprint_Right_Opnd
(Node
);
1870 Sprint_Left_Opnd
(Node
);
1871 Write_Operator
(Node
, " /= ");
1872 Sprint_Right_Opnd
(Node
);
1875 Write_Operator
(Node
, "not ");
1876 Sprint_Right_Opnd
(Node
);
1879 Sprint_Left_Opnd
(Node
);
1880 Write_Operator
(Node
, " or ");
1881 Sprint_Right_Opnd
(Node
);
1884 Write_Operator
(Node
, "+");
1885 Sprint_Right_Opnd
(Node
);
1888 Sprint_Left_Opnd
(Node
);
1890 if Treat_Fixed_As_Integer
(Node
) then
1894 Write_Operator
(Node
, " rem ");
1895 Sprint_Right_Opnd
(Node
);
1901 Write_Str_With_Col_Check
("(");
1902 Sprint_Node
(Left_Opnd
(Node
));
1904 Sprint_Node
(Right_Opnd
(Node
));
1907 when N_Op_Subtract
=>
1908 Sprint_Left_Opnd
(Node
);
1909 Write_Operator
(Node
, " - ");
1910 Sprint_Right_Opnd
(Node
);
1913 Sprint_Left_Opnd
(Node
);
1914 Write_Operator
(Node
, " xor ");
1915 Sprint_Right_Opnd
(Node
);
1917 when N_Operator_Symbol
=>
1918 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1920 when N_Ordinary_Fixed_Point_Definition
=>
1921 Write_Str_With_Col_Check_Sloc
("delta ");
1922 Sprint_Node
(Delta_Expression
(Node
));
1923 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1926 Sprint_Left_Opnd
(Node
);
1927 Write_Str_Sloc
(" or else ");
1928 Sprint_Right_Opnd
(Node
);
1930 when N_Others_Choice
=>
1931 if All_Others
(Node
) then
1932 Write_Str_With_Col_Check
("all ");
1935 Write_Str_With_Col_Check_Sloc
("others");
1937 when N_Package_Body
=>
1939 Write_Indent_Str_Sloc
("package body ");
1940 Sprint_Node
(Defining_Unit_Name
(Node
));
1942 Sprint_Indented_List
(Declarations
(Node
));
1944 if Present
(Handled_Statement_Sequence
(Node
)) then
1945 Write_Indent_Str
("begin");
1946 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1949 Write_Indent_Str
("end ");
1950 Sprint_Node
(Defining_Unit_Name
(Node
));
1953 when N_Package_Body_Stub
=>
1954 Write_Indent_Str_Sloc
("package body ");
1955 Sprint_Node
(Defining_Identifier
(Node
));
1956 Write_Str_With_Col_Check
(" is separate;");
1958 when N_Package_Declaration
=>
1961 Sprint_Node_Sloc
(Specification
(Node
));
1964 when N_Package_Instantiation
=>
1966 Write_Indent_Str_Sloc
("package ");
1967 Sprint_Node
(Defining_Unit_Name
(Node
));
1968 Write_Str
(" is new ");
1969 Sprint_Node
(Name
(Node
));
1970 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1973 when N_Package_Renaming_Declaration
=>
1974 Write_Indent_Str_Sloc
("package ");
1975 Sprint_Node
(Defining_Unit_Name
(Node
));
1976 Write_Str_With_Col_Check
(" renames ");
1977 Sprint_Node
(Name
(Node
));
1980 when N_Package_Specification
=>
1981 Write_Str_With_Col_Check_Sloc
("package ");
1982 Sprint_Node
(Defining_Unit_Name
(Node
));
1984 Sprint_Indented_List
(Visible_Declarations
(Node
));
1986 if Present
(Private_Declarations
(Node
)) then
1987 Write_Indent_Str
("private");
1988 Sprint_Indented_List
(Private_Declarations
(Node
));
1991 Write_Indent_Str
("end ");
1992 Sprint_Node
(Defining_Unit_Name
(Node
));
1994 when N_Parameter_Association
=>
1995 Sprint_Node_Sloc
(Selector_Name
(Node
));
1997 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
1999 when N_Parameter_Specification
=>
2002 if Write_Identifiers
(Node
) then
2005 if In_Present
(Node
) then
2006 Write_Str_With_Col_Check
("in ");
2009 if Out_Present
(Node
) then
2010 Write_Str_With_Col_Check
("out ");
2015 if Null_Exclusion_Present
(Node
) then
2016 Write_Str
("not null ");
2019 Sprint_Node
(Parameter_Type
(Node
));
2021 if Present
(Expression
(Node
)) then
2023 Sprint_Node
(Expression
(Node
));
2030 Write_Indent_Str_Sloc
("pragma ");
2031 Write_Name_With_Col_Check
(Chars
(Node
));
2033 if Present
(Pragma_Argument_Associations
(Node
)) then
2034 Sprint_Opt_Paren_Comma_List
2035 (Pragma_Argument_Associations
(Node
));
2040 when N_Pragma_Argument_Association
=>
2043 if Chars
(Node
) /= No_Name
then
2044 Write_Name_With_Col_Check
(Chars
(Node
));
2048 Sprint_Node
(Expression
(Node
));
2050 when N_Private_Type_Declaration
=>
2051 Write_Indent_Str_Sloc
("type ");
2052 Write_Id
(Defining_Identifier
(Node
));
2054 if Present
(Discriminant_Specifications
(Node
)) then
2055 Write_Discr_Specs
(Node
);
2056 elsif Unknown_Discriminants_Present
(Node
) then
2057 Write_Str_With_Col_Check
("(<>)");
2062 if Tagged_Present
(Node
) then
2063 Write_Str_With_Col_Check
("tagged ");
2066 if Limited_Present
(Node
) then
2067 Write_Str_With_Col_Check
("limited ");
2070 Write_Str_With_Col_Check
("private;");
2072 when N_Private_Extension_Declaration
=>
2073 Write_Indent_Str_Sloc
("type ");
2074 Write_Id
(Defining_Identifier
(Node
));
2076 if Present
(Discriminant_Specifications
(Node
)) then
2077 Write_Discr_Specs
(Node
);
2078 elsif Unknown_Discriminants_Present
(Node
) then
2079 Write_Str_With_Col_Check
("(<>)");
2082 Write_Str_With_Col_Check
(" is new ");
2083 Sprint_Node
(Subtype_Indication
(Node
));
2084 Write_Str_With_Col_Check
(" with private;");
2086 when N_Procedure_Call_Statement
=>
2089 Sprint_Node
(Name
(Node
));
2090 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2093 when N_Procedure_Instantiation
=>
2094 Write_Indent_Str_Sloc
("procedure ");
2095 Sprint_Node
(Defining_Unit_Name
(Node
));
2096 Write_Str_With_Col_Check
(" is new ");
2097 Sprint_Node
(Name
(Node
));
2098 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2101 when N_Procedure_Specification
=>
2102 Write_Str_With_Col_Check_Sloc
("procedure ");
2103 Sprint_Node
(Defining_Unit_Name
(Node
));
2104 Write_Param_Specs
(Node
);
2106 when N_Protected_Body
=>
2107 Write_Indent_Str_Sloc
("protected body ");
2108 Write_Id
(Defining_Identifier
(Node
));
2110 Sprint_Indented_List
(Declarations
(Node
));
2111 Write_Indent_Str
("end ");
2112 Write_Id
(Defining_Identifier
(Node
));
2115 when N_Protected_Body_Stub
=>
2116 Write_Indent_Str_Sloc
("protected body ");
2117 Write_Id
(Defining_Identifier
(Node
));
2118 Write_Str_With_Col_Check
(" is separate;");
2120 when N_Protected_Definition
=>
2122 Sprint_Indented_List
(Visible_Declarations
(Node
));
2124 if Present
(Private_Declarations
(Node
)) then
2125 Write_Indent_Str
("private");
2126 Sprint_Indented_List
(Private_Declarations
(Node
));
2129 Write_Indent_Str
("end ");
2131 when N_Protected_Type_Declaration
=>
2132 Write_Indent_Str_Sloc
("protected type ");
2133 Write_Id
(Defining_Identifier
(Node
));
2134 Write_Discr_Specs
(Node
);
2136 Sprint_Node
(Protected_Definition
(Node
));
2137 Write_Id
(Defining_Identifier
(Node
));
2140 when N_Qualified_Expression
=>
2141 Sprint_Node
(Subtype_Mark
(Node
));
2142 Write_Char_Sloc
(''');
2144 -- Print expression, make sure we have at least one level of
2145 -- parentheses around the expression. For cases of qualified
2146 -- expressions in the source, this is always the case, but
2147 -- for generated qualifications, there may be no explicit
2148 -- parentheses present.
2150 if Paren_Count
(Expression
(Node
)) /= 0 then
2151 Sprint_Node
(Expression
(Node
));
2154 Sprint_Node
(Expression
(Node
));
2158 when N_Raise_Constraint_Error
=>
2160 -- This node can be used either as a subexpression or as a
2161 -- statement form. The following test is a reasonably reliable
2162 -- way to distinguish the two cases.
2164 if Is_List_Member
(Node
)
2165 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2170 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2171 Write_Condition_And_Reason
(Node
);
2173 when N_Raise_Program_Error
=>
2175 -- This node can be used either as a subexpression or as a
2176 -- statement form. The following test is a reasonably reliable
2177 -- way to distinguish the two cases.
2179 if Is_List_Member
(Node
)
2180 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2185 Write_Str_With_Col_Check_Sloc
("[program_error");
2186 Write_Condition_And_Reason
(Node
);
2188 when N_Raise_Storage_Error
=>
2190 -- This node can be used either as a subexpression or as a
2191 -- statement form. The following test is a reasonably reliable
2192 -- way to distinguish the two cases.
2194 if Is_List_Member
(Node
)
2195 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2200 Write_Str_With_Col_Check_Sloc
("[storage_error");
2201 Write_Condition_And_Reason
(Node
);
2203 when N_Raise_Statement
=>
2204 Write_Indent_Str_Sloc
("raise ");
2205 Sprint_Node
(Name
(Node
));
2209 Sprint_Node
(Low_Bound
(Node
));
2210 Write_Str_Sloc
(" .. ");
2211 Sprint_Node
(High_Bound
(Node
));
2213 when N_Range_Constraint
=>
2214 Write_Str_With_Col_Check_Sloc
("range ");
2215 Sprint_Node
(Range_Expression
(Node
));
2217 when N_Real_Literal
=>
2218 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
2220 when N_Real_Range_Specification
=>
2221 Write_Str_With_Col_Check_Sloc
("range ");
2222 Sprint_Node
(Low_Bound
(Node
));
2224 Sprint_Node
(High_Bound
(Node
));
2226 when N_Record_Definition
=>
2227 if Abstract_Present
(Node
) then
2228 Write_Str_With_Col_Check
("abstract ");
2231 if Tagged_Present
(Node
) then
2232 Write_Str_With_Col_Check
("tagged ");
2235 if Limited_Present
(Node
) then
2236 Write_Str_With_Col_Check
("limited ");
2239 if Null_Present
(Node
) then
2240 Write_Str_With_Col_Check_Sloc
("null record");
2243 Write_Str_With_Col_Check_Sloc
("record");
2244 Sprint_Node
(Component_List
(Node
));
2245 Write_Indent_Str
("end record");
2248 when N_Record_Representation_Clause
=>
2249 Write_Indent_Str_Sloc
("for ");
2250 Sprint_Node
(Identifier
(Node
));
2251 Write_Str_With_Col_Check
(" use record ");
2253 if Present
(Mod_Clause
(Node
)) then
2254 Sprint_Node
(Mod_Clause
(Node
));
2257 Sprint_Indented_List
(Component_Clauses
(Node
));
2258 Write_Indent_Str
("end record;");
2261 Sprint_Node
(Prefix
(Node
));
2262 Write_Str_With_Col_Check_Sloc
("'reference");
2264 when N_Requeue_Statement
=>
2265 Write_Indent_Str_Sloc
("requeue ");
2266 Sprint_Node
(Name
(Node
));
2268 if Abort_Present
(Node
) then
2269 Write_Str_With_Col_Check
(" with abort");
2274 when N_Return_Statement
=>
2275 if Present
(Expression
(Node
)) then
2276 Write_Indent_Str_Sloc
("return ");
2277 Sprint_Node
(Expression
(Node
));
2280 Write_Indent_Str_Sloc
("return;");
2283 when N_Selective_Accept
=>
2284 Write_Indent_Str_Sloc
("select");
2290 Alt_Node
:= First
(Select_Alternatives
(Node
));
2293 Sprint_Node
(Alt_Node
);
2296 exit when No
(Alt_Node
);
2297 Write_Indent_Str
("or");
2301 if Present
(Else_Statements
(Node
)) then
2302 Write_Indent_Str
("else");
2303 Sprint_Indented_List
(Else_Statements
(Node
));
2306 Write_Indent_Str
("end select;");
2308 when N_Signed_Integer_Type_Definition
=>
2309 Write_Str_With_Col_Check_Sloc
("range ");
2310 Sprint_Node
(Low_Bound
(Node
));
2312 Sprint_Node
(High_Bound
(Node
));
2314 when N_Single_Protected_Declaration
=>
2315 Write_Indent_Str_Sloc
("protected ");
2316 Write_Id
(Defining_Identifier
(Node
));
2318 Sprint_Node
(Protected_Definition
(Node
));
2319 Write_Id
(Defining_Identifier
(Node
));
2322 when N_Single_Task_Declaration
=>
2323 Write_Indent_Str_Sloc
("task ");
2324 Write_Id
(Defining_Identifier
(Node
));
2326 if Present
(Task_Definition
(Node
)) then
2328 Sprint_Node
(Task_Definition
(Node
));
2329 Write_Id
(Defining_Identifier
(Node
));
2334 when N_Selected_Component
=>
2335 Sprint_Node
(Prefix
(Node
));
2336 Write_Char_Sloc
('.');
2337 Sprint_Node
(Selector_Name
(Node
));
2341 Sprint_Node
(Prefix
(Node
));
2342 Write_Str_With_Col_Check
(" (");
2343 Sprint_Node
(Discrete_Range
(Node
));
2346 when N_String_Literal
=>
2347 if String_Length
(Strval
(Node
)) + Column
> 75 then
2348 Write_Indent_Str
(" ");
2352 Write_String_Table_Entry
(Strval
(Node
));
2354 when N_Subprogram_Body
=>
2355 if Freeze_Indent
= 0 then
2360 Sprint_Node_Sloc
(Specification
(Node
));
2363 Sprint_Indented_List
(Declarations
(Node
));
2364 Write_Indent_Str
("begin");
2365 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2367 Write_Indent_Str
("end ");
2368 Sprint_Node
(Defining_Unit_Name
(Specification
(Node
)));
2371 if Is_List_Member
(Node
)
2372 and then Present
(Next
(Node
))
2373 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
2378 when N_Subprogram_Body_Stub
=>
2380 Sprint_Node_Sloc
(Specification
(Node
));
2381 Write_Str_With_Col_Check
(" is separate;");
2383 when N_Subprogram_Declaration
=>
2385 Sprint_Node_Sloc
(Specification
(Node
));
2388 when N_Subprogram_Info
=>
2389 Sprint_Node
(Identifier
(Node
));
2390 Write_Str_With_Col_Check_Sloc
("'subprogram_info");
2392 when N_Subprogram_Renaming_Declaration
=>
2394 Sprint_Node
(Specification
(Node
));
2395 Write_Str_With_Col_Check_Sloc
(" renames ");
2396 Sprint_Node
(Name
(Node
));
2399 when N_Subtype_Declaration
=>
2400 Write_Indent_Str_Sloc
("subtype ");
2401 Write_Id
(Defining_Identifier
(Node
));
2406 if Null_Exclusion_Present
(Node
) then
2407 Write_Str
("not null ");
2410 Sprint_Node
(Subtype_Indication
(Node
));
2413 when N_Subtype_Indication
=>
2414 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
2416 Sprint_Node
(Constraint
(Node
));
2419 Write_Indent_Str_Sloc
("separate (");
2420 Sprint_Node
(Name
(Node
));
2423 Sprint_Node
(Proper_Body
(Node
));
2426 Write_Indent_Str_Sloc
("task body ");
2427 Write_Id
(Defining_Identifier
(Node
));
2429 Sprint_Indented_List
(Declarations
(Node
));
2430 Write_Indent_Str
("begin");
2431 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2432 Write_Indent_Str
("end ");
2433 Write_Id
(Defining_Identifier
(Node
));
2436 when N_Task_Body_Stub
=>
2437 Write_Indent_Str_Sloc
("task body ");
2438 Write_Id
(Defining_Identifier
(Node
));
2439 Write_Str_With_Col_Check
(" is separate;");
2441 when N_Task_Definition
=>
2443 Sprint_Indented_List
(Visible_Declarations
(Node
));
2445 if Present
(Private_Declarations
(Node
)) then
2446 Write_Indent_Str
("private");
2447 Sprint_Indented_List
(Private_Declarations
(Node
));
2450 Write_Indent_Str
("end ");
2452 when N_Task_Type_Declaration
=>
2453 Write_Indent_Str_Sloc
("task type ");
2454 Write_Id
(Defining_Identifier
(Node
));
2455 Write_Discr_Specs
(Node
);
2457 if Present
(Task_Definition
(Node
)) then
2459 Sprint_Node
(Task_Definition
(Node
));
2460 Write_Id
(Defining_Identifier
(Node
));
2465 when N_Terminate_Alternative
=>
2466 Sprint_Node_List
(Pragmas_Before
(Node
));
2470 if Present
(Condition
(Node
)) then
2471 Write_Str_With_Col_Check
("when ");
2472 Sprint_Node
(Condition
(Node
));
2476 Write_Str_With_Col_Check_Sloc
("terminate;");
2477 Sprint_Node_List
(Pragmas_After
(Node
));
2479 when N_Timed_Entry_Call
=>
2480 Write_Indent_Str_Sloc
("select");
2482 Sprint_Node
(Entry_Call_Alternative
(Node
));
2484 Write_Indent_Str
("or");
2486 Sprint_Node
(Delay_Alternative
(Node
));
2488 Write_Indent_Str
("end select;");
2490 when N_Triggering_Alternative
=>
2491 Sprint_Node_List
(Pragmas_Before
(Node
));
2492 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
2493 Sprint_Node_List
(Statements
(Node
));
2495 when N_Type_Conversion
=>
2497 Sprint_Node
(Subtype_Mark
(Node
));
2500 if Conversion_OK
(Node
) then
2504 if Float_Truncate
(Node
) then
2508 if Rounded_Result
(Node
) then
2513 Sprint_Node
(Expression
(Node
));
2516 when N_Unchecked_Expression
=>
2519 Sprint_Node_Sloc
(Expression
(Node
));
2522 when N_Unchecked_Type_Conversion
=>
2523 Sprint_Node
(Subtype_Mark
(Node
));
2525 Write_Str_With_Col_Check
("(");
2526 Sprint_Node_Sloc
(Expression
(Node
));
2529 when N_Unconstrained_Array_Definition
=>
2530 Write_Str_With_Col_Check_Sloc
("array (");
2536 Node1
:= First
(Subtype_Marks
(Node
));
2538 Sprint_Node
(Node1
);
2539 Write_Str_With_Col_Check
(" range <>");
2541 exit when Node1
= Empty
;
2546 Write_Str
(") of ");
2547 Sprint_Node
(Component_Definition
(Node
));
2549 when N_Unused_At_Start | N_Unused_At_End
=>
2550 Write_Indent_Str
("***** Error, unused node encountered *****");
2553 when N_Use_Package_Clause
=>
2554 Write_Indent_Str_Sloc
("use ");
2555 Sprint_Comma_List
(Names
(Node
));
2558 when N_Use_Type_Clause
=>
2559 Write_Indent_Str_Sloc
("use type ");
2560 Sprint_Comma_List
(Subtype_Marks
(Node
));
2563 when N_Validate_Unchecked_Conversion
=>
2564 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
2565 Sprint_Node
(Source_Type
(Node
));
2567 Sprint_Node
(Target_Type
(Node
));
2571 Write_Indent_Str_Sloc
("when ");
2572 Sprint_Bar_List
(Discrete_Choices
(Node
));
2574 Sprint_Node
(Component_List
(Node
));
2576 when N_Variant_Part
=>
2578 Write_Indent_Str_Sloc
("case ");
2579 Sprint_Node
(Name
(Node
));
2581 Sprint_Indented_List
(Variants
(Node
));
2582 Write_Indent_Str
("end case");
2585 when N_With_Clause
=>
2587 -- Special test, if we are dumping the original tree only,
2588 -- then we want to eliminate the bogus with clauses that
2589 -- correspond to the non-existent children of Text_IO.
2591 if Dump_Original_Only
2592 and then Is_Text_IO_Kludge_Unit
(Name
(Node
))
2596 -- Normal case, output the with clause
2599 if First_Name
(Node
) or else not Dump_Original_Only
then
2601 -- Ada 0Y (AI-50217): Print limited with_clauses
2603 if Private_Present
(Node
) and Limited_Present
(Node
) then
2604 Write_Indent_Str
("limited private with ");
2606 elsif Private_Present
(Node
) then
2607 Write_Indent_Str
("private with ");
2609 elsif Limited_Present
(Node
) then
2610 Write_Indent_Str
("limited with ");
2613 Write_Indent_Str
("with ");
2620 Sprint_Node_Sloc
(Name
(Node
));
2622 if Last_Name
(Node
) or else not Dump_Original_Only
then
2627 when N_With_Type_Clause
=>
2628 Write_Indent_Str
("with type ");
2629 Sprint_Node_Sloc
(Name
(Node
));
2631 if Tagged_Present
(Node
) then
2632 Write_Str
(" is tagged;");
2634 Write_Str
(" is access;");
2639 if Nkind
(Node
) in N_Subexpr
2640 and then Do_Range_Check
(Node
)
2645 for J
in 1 .. Paren_Count
(Node
) loop
2649 pragma Assert
(No
(Debug_Node
));
2650 Debug_Node
:= Save_Debug_Node
;
2651 end Sprint_Node_Actual
;
2653 ----------------------
2654 -- Sprint_Node_List --
2655 ----------------------
2657 procedure Sprint_Node_List
(List
: List_Id
) is
2661 if Is_Non_Empty_List
(List
) then
2662 Node
:= First
(List
);
2667 exit when Node
= Empty
;
2670 end Sprint_Node_List
;
2672 ----------------------
2673 -- Sprint_Node_Sloc --
2674 ----------------------
2676 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
2680 if Present
(Debug_Node
) then
2681 Set_Sloc
(Debug_Node
, Sloc
(Node
));
2682 Debug_Node
:= Empty
;
2684 end Sprint_Node_Sloc
;
2686 ---------------------
2687 -- Sprint_Opt_Node --
2688 ---------------------
2690 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
2692 if Present
(Node
) then
2696 end Sprint_Opt_Node
;
2698 --------------------------
2699 -- Sprint_Opt_Node_List --
2700 --------------------------
2702 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
2704 if Present
(List
) then
2705 Sprint_Node_List
(List
);
2707 end Sprint_Opt_Node_List
;
2709 ---------------------------------
2710 -- Sprint_Opt_Paren_Comma_List --
2711 ---------------------------------
2713 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
2715 if Is_Non_Empty_List
(List
) then
2717 Sprint_Paren_Comma_List
(List
);
2719 end Sprint_Opt_Paren_Comma_List
;
2721 -----------------------------
2722 -- Sprint_Paren_Comma_List --
2723 -----------------------------
2725 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
2727 Node_Exists
: Boolean := False;
2731 if Is_Non_Empty_List
(List
) then
2733 if Dump_Original_Only
then
2736 while Present
(N
) loop
2738 if not Is_Rewrite_Insertion
(N
) then
2739 Node_Exists
:= True;
2746 if not Node_Exists
then
2751 Write_Str_With_Col_Check
("(");
2752 Sprint_Comma_List
(List
);
2755 end Sprint_Paren_Comma_List
;
2757 ----------------------
2758 -- Sprint_Right_Opnd --
2759 ----------------------
2761 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
2762 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
2765 if Paren_Count
(Opnd
) /= 0
2766 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
2775 end Sprint_Right_Opnd
;
2777 ---------------------
2778 -- Write_Char_Sloc --
2779 ---------------------
2781 procedure Write_Char_Sloc
(C
: Character) is
2783 if Debug_Generated_Code
and then C
/= ' ' then
2788 end Write_Char_Sloc
;
2790 --------------------------------
2791 -- Write_Condition_And_Reason --
2792 --------------------------------
2794 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
2795 Image
: constant String := RT_Exception_Code
'Image
2796 (RT_Exception_Code
'Val
2797 (UI_To_Int
(Reason
(Node
))));
2800 if Present
(Condition
(Node
)) then
2801 Write_Str_With_Col_Check
(" when ");
2802 Sprint_Node
(Condition
(Node
));
2807 for J
in 4 .. Image
'Last loop
2808 if Image
(J
) = '_' then
2811 Write_Char
(Fold_Lower
(Image
(J
)));
2816 end Write_Condition_And_Reason
;
2818 ------------------------
2819 -- Write_Discr_Specs --
2820 ------------------------
2822 procedure Write_Discr_Specs
(N
: Node_Id
) is
2827 Specs
:= Discriminant_Specifications
(N
);
2829 if Present
(Specs
) then
2830 Write_Str_With_Col_Check
(" (");
2831 Spec
:= First
(Specs
);
2836 exit when Spec
= Empty
;
2838 -- Add semicolon, unless we are printing original tree and the
2839 -- next specification is part of a list (but not the first
2840 -- element of that list)
2842 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
2849 end Write_Discr_Specs
;
2855 procedure Write_Ekind
(E
: Entity_Id
) is
2856 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
2859 Name_Len
:= S
'Length;
2860 Name_Buffer
(1 .. Name_Len
) := S
;
2861 Set_Casing
(Mixed_Case
);
2862 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2869 procedure Write_Id
(N
: Node_Id
) is
2871 -- Case of a defining identifier
2873 if Nkind
(N
) = N_Defining_Identifier
then
2875 -- If defining identifier has an interface name (and no
2876 -- address clause), then we output the interface name.
2878 if (Is_Imported
(N
) or else Is_Exported
(N
))
2879 and then Present
(Interface_Name
(N
))
2880 and then No
(Address_Clause
(N
))
2882 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
2883 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2885 -- If no interface name (or inactive because there was
2886 -- an address clause), then just output the Chars name.
2889 Write_Name_With_Col_Check
(Chars
(N
));
2892 -- Case of selector of an expanded name where the expanded name
2893 -- has an associated entity, output this entity.
2895 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
2896 and then Selector_Name
(Parent
(N
)) = N
2897 and then Present
(Entity
(Parent
(N
)))
2899 Write_Id
(Entity
(Parent
(N
)));
2901 -- For any other node with an associated entity, output it
2903 elsif Nkind
(N
) in N_Has_Entity
2904 and then Present
(Entity_Or_Associated_Node
(N
))
2905 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
2907 Write_Id
(Entity
(N
));
2909 -- All other cases, we just print the Chars field
2912 Write_Name_With_Col_Check
(Chars
(N
));
2916 -----------------------
2917 -- Write_Identifiers --
2918 -----------------------
2920 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
2922 Sprint_Node
(Defining_Identifier
(Node
));
2924 -- The remainder of the declaration must be printed unless we are
2925 -- printing the original tree and this is not the last identifier
2928 not Dump_Original_Only
or else not More_Ids
(Node
);
2930 end Write_Identifiers
;
2932 ------------------------
2933 -- Write_Implicit_Def --
2934 ------------------------
2936 procedure Write_Implicit_Def
(E
: Entity_Id
) is
2941 when E_Array_Subtype
=>
2942 Write_Str_With_Col_Check
("subtype ");
2944 Write_Str_With_Col_Check
(" is ");
2945 Write_Id
(Base_Type
(E
));
2946 Write_Str_With_Col_Check
(" (");
2948 Ind
:= First_Index
(E
);
2950 while Present
(Ind
) loop
2954 if Present
(Ind
) then
2961 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
2962 Write_Str_With_Col_Check
("subtype ");
2965 Write_Id
(Etype
(E
));
2966 Write_Str_With_Col_Check
(" range ");
2967 Sprint_Node
(Scalar_Range
(E
));
2971 Write_Str_With_Col_Check
("type ");
2973 Write_Str_With_Col_Check
(" is <");
2978 end Write_Implicit_Def
;
2984 procedure Write_Indent
is
2986 if Indent_Annull_Flag
then
2987 Indent_Annull_Flag
:= False;
2991 for J
in 1 .. Indent
loop
2997 ------------------------------
2998 -- Write_Indent_Identifiers --
2999 ------------------------------
3001 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
3003 -- We need to start a new line for every node, except in the case
3004 -- where we are printing the original tree and this is not the first
3005 -- defining identifier in the list.
3007 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3010 -- If printing original tree and this is not the first defining
3011 -- identifier in the list, then the previous call to this procedure
3012 -- printed only the name, and we add a comma to separate the names.
3018 Sprint_Node
(Defining_Identifier
(Node
));
3020 -- The remainder of the declaration must be printed unless we are
3021 -- printing the original tree and this is not the last identifier
3024 not Dump_Original_Only
or else not More_Ids
(Node
);
3026 end Write_Indent_Identifiers
;
3028 -----------------------------------
3029 -- Write_Indent_Identifiers_Sloc --
3030 -----------------------------------
3032 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
3034 -- We need to start a new line for every node, except in the case
3035 -- where we are printing the original tree and this is not the first
3036 -- defining identifier in the list.
3038 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3041 -- If printing original tree and this is not the first defining
3042 -- identifier in the list, then the previous call to this procedure
3043 -- printed only the name, and we add a comma to separate the names.
3050 Sprint_Node
(Defining_Identifier
(Node
));
3052 -- The remainder of the declaration must be printed unless we are
3053 -- printing the original tree and this is not the last identifier
3056 not Dump_Original_Only
or else not More_Ids
(Node
);
3058 end Write_Indent_Identifiers_Sloc
;
3060 ----------------------
3061 -- Write_Indent_Str --
3062 ----------------------
3064 procedure Write_Indent_Str
(S
: String) is
3068 end Write_Indent_Str
;
3070 ---------------------------
3071 -- Write_Indent_Str_Sloc --
3072 ---------------------------
3074 procedure Write_Indent_Str_Sloc
(S
: String) is
3078 end Write_Indent_Str_Sloc
;
3080 -------------------------------
3081 -- Write_Name_With_Col_Check --
3082 -------------------------------
3084 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
3088 Get_Name_String
(N
);
3090 -- Deal with -gnatI which replaces digits in an internal
3091 -- name by three dots (e.g. R7b becomes R...b).
3093 if Debug_Flag_II
and then Name_Buffer
(1) in 'A' .. 'Z' then
3096 while J
< Name_Len
loop
3097 exit when Name_Buffer
(J
) not in 'A' .. 'Z';
3101 if Name_Buffer
(J
) in '0' .. '9' then
3102 Write_Str_With_Col_Check
(Name_Buffer
(1 .. J
- 1));
3105 while J
<= Name_Len
loop
3106 if Name_Buffer
(J
) not in '0' .. '9' then
3107 Write_Str
(Name_Buffer
(J
.. Name_Len
));
3119 -- Fall through for normal case
3121 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3122 end Write_Name_With_Col_Check
;
3124 ------------------------------------
3125 -- Write_Name_With_Col_Check_Sloc --
3126 ------------------------------------
3128 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
3130 Get_Name_String
(N
);
3131 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
3132 end Write_Name_With_Col_Check_Sloc
;
3134 --------------------
3135 -- Write_Operator --
3136 --------------------
3138 procedure Write_Operator
(N
: Node_Id
; S
: String) is
3139 F
: Natural := S
'First;
3140 T
: Natural := S
'Last;
3143 -- If no overflow check, just write string out, and we are done
3145 if not Do_Overflow_Check
(N
) then
3148 -- If overflow check, we want to surround the operator with curly
3149 -- brackets, but not include spaces within the brackets.
3162 Write_Str_Sloc
(S
(F
.. T
));
3165 if S
(S
'Last) = ' ' then
3171 -----------------------
3172 -- Write_Param_Specs --
3173 -----------------------
3175 procedure Write_Param_Specs
(N
: Node_Id
) is
3181 Specs
:= Parameter_Specifications
(N
);
3183 if Is_Non_Empty_List
(Specs
) then
3184 Write_Str_With_Col_Check
(" (");
3185 Spec
:= First
(Specs
);
3189 Formal
:= Defining_Identifier
(Spec
);
3191 exit when Spec
= Empty
;
3193 -- Add semicolon, unless we are printing original tree and the
3194 -- next specification is part of a list (but not the first
3195 -- element of that list)
3197 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3202 -- Write out any extra formals
3204 while Present
(Extra_Formal
(Formal
)) loop
3205 Formal
:= Extra_Formal
(Formal
);
3207 Write_Name_With_Col_Check
(Chars
(Formal
));
3209 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
3214 end Write_Param_Specs
;
3216 --------------------------
3217 -- Write_Rewrite_Str --
3218 --------------------------
3220 procedure Write_Rewrite_Str
(S
: String) is
3222 if not Dump_Generated_Only
then
3223 if S
'Length = 3 and then S
= ">>>" then
3226 Write_Str_With_Col_Check
(S
);
3229 end Write_Rewrite_Str
;
3231 --------------------
3232 -- Write_Str_Sloc --
3233 --------------------
3235 procedure Write_Str_Sloc
(S
: String) is
3237 for J
in S
'Range loop
3238 Write_Char_Sloc
(S
(J
));
3242 ------------------------------
3243 -- Write_Str_With_Col_Check --
3244 ------------------------------
3246 procedure Write_Str_With_Col_Check
(S
: String) is
3248 if Int
(S
'Last) + Column
> Line_Limit
then
3249 Write_Indent_Str
(" ");
3252 Write_Str
(S
(2 .. S
'Length));
3260 end Write_Str_With_Col_Check
;
3262 -----------------------------------
3263 -- Write_Str_With_Col_Check_Sloc --
3264 -----------------------------------
3266 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
3268 if Int
(S
'Last) + Column
> Line_Limit
then
3269 Write_Indent_Str
(" ");
3272 Write_Str_Sloc
(S
(2 .. S
'Length));
3280 end Write_Str_With_Col_Check_Sloc
;
3282 ------------------------------------
3283 -- Write_Uint_With_Col_Check_Sloc --
3284 ------------------------------------
3286 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
3288 Col_Check
(UI_Decimal_Digits_Hi
(U
));
3290 UI_Write
(U
, Format
);
3291 end Write_Uint_With_Col_Check_Sloc
;
3293 -------------------------------------
3294 -- Write_Ureal_With_Col_Check_Sloc --
3295 -------------------------------------
3297 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
3298 D
: constant Uint
:= Denominator
(U
);
3299 N
: constant Uint
:= Numerator
(U
);
3303 (UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
3306 end Write_Ureal_With_Col_Check_Sloc
;