1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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_And_List
(List
: List_Id
);
169 -- Print the given list with items separated by vertical "and"
171 procedure Sprint_Bar_List
(List
: List_Id
);
172 -- Print the given list with items separated by vertical bars
174 procedure Sprint_Node_Actual
(Node
: Node_Id
);
175 -- This routine prints its node argument. It is a lower level routine than
176 -- Sprint_Node, in that it does not bother about rewritten trees.
178 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
179 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
180 -- sets the Sloc of the current debug node to be a copy of the Sloc
181 -- of the sprinted node Node. Note that this is done after printing
182 -- Node, so that the Sloc is the proper updated value for the debug file.
184 procedure Write_Char_Sloc
(C
: Character);
185 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
186 -- called to ensure that the current node has a proper Sloc set.
188 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
189 -- Write Condition and Reason codes of Raise_xxx_Error node
191 procedure Write_Discr_Specs
(N
: Node_Id
);
192 -- Ouput discriminant specification for node, which is any of the type
193 -- declarations that can have discriminants.
195 procedure Write_Ekind
(E
: Entity_Id
);
196 -- Write the String corresponding to the Ekind without "E_".
198 procedure Write_Id
(N
: Node_Id
);
199 -- N is a node with a Chars field. This procedure writes the name that
200 -- will be used in the generated code associated with the name. For a
201 -- node with no associated entity, this is simply the Chars field. For
202 -- the case where there is an entity associated with the node, we print
203 -- the name associated with the entity (since it may have been encoded).
204 -- One other special case is that an entity has an active external name
205 -- (i.e. an external name present with no address clause), then this
206 -- external name is output.
208 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
209 -- Handle node where the grammar has a list of defining identifiers, but
210 -- the tree has a separate declaration for each identifier. Handles the
211 -- printing of the defining identifier, and returns True if the type and
212 -- initialization information is to be printed, False if it is to be
213 -- skipped (the latter case happens when printing defining identifiers
214 -- other than the first in the original tree output case).
216 procedure Write_Implicit_Def
(E
: Entity_Id
);
217 pragma Warnings
(Off
, Write_Implicit_Def
);
218 -- Write the definition of the implicit type E according to its Ekind
219 -- For now a debugging procedure, but might be used in the future.
221 procedure Write_Indent
;
222 -- Start a new line and write indentation spacing
224 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
225 -- Like Write_Identifiers except that each new printed declaration
226 -- is at the start of a new line.
228 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
229 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
230 -- mode, the Sloc of the current debug node is set to point ot the
231 -- first output identifier.
233 procedure Write_Indent_Str
(S
: String);
234 -- Start a new line and write indent spacing followed by given string
236 procedure Write_Indent_Str_Sloc
(S
: String);
237 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
238 -- the Sloc of the current node is set to the first non-blank character
241 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
242 -- Write name (using Write_Name) with initial column check, and possible
243 -- initial Write_Indent (to get new line) if current line is too full.
245 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
246 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
247 -- mode, sets Sloc of current debug node to first character of name.
249 procedure Write_Operator
(N
: Node_Id
; S
: String);
250 -- Like Write_Str_Sloc, used for operators, encloses the string in
251 -- characters {} if the Do_Overflow flag is set on the node N.
253 procedure Write_Param_Specs
(N
: Node_Id
);
254 -- Output parameter specifications for node (which is either a function
255 -- or procedure specification with a Parameter_Specifications field)
257 procedure Write_Rewrite_Str
(S
: String);
258 -- Writes out a string (typically containing <<< or >>>}) for a node
259 -- created by rewriting the tree. Suppressed if we are outputting the
260 -- generated code only, since in this case we don't specially mark nodes
261 -- created by rewriting).
263 procedure Write_Str_Sloc
(S
: String);
264 -- Like Write_Str, but sets debug Sloc of current debug node to first
265 -- non-blank character if a current debug node is active.
267 procedure Write_Str_With_Col_Check
(S
: String);
268 -- Write string (using Write_Str) with initial column check, and possible
269 -- initial Write_Indent (to get new line) if current line is too full.
271 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
272 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
273 -- node to first non-blank character if a current debug node is active.
275 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
276 -- Write Uint (using UI_Write) with initial column check, and possible
277 -- initial Write_Indent (to get new line) if current line is too full.
278 -- The format parameter determines the output format (see UI_Write).
279 -- In addition, in Debug_Generated_Code mode, sets the current node
280 -- Sloc to the first character of the output value.
282 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
283 -- Write Ureal (using same output format as UR_Write) with column checks
284 -- and a possible initial Write_Indent (to get new line) if current line
285 -- is too full. In addition, in Debug_Generated_Code mode, sets the
286 -- current node Sloc to the first character of the output value.
292 procedure Col_Check
(N
: Nat
) is
294 if N
+ Column
> Line_Limit
then
295 Write_Indent_Str
(" ");
303 procedure Indent_Annull
is
305 Indent_Annull_Flag
:= True;
312 procedure Indent_Begin
is
314 Indent
:= Indent
+ 3;
321 procedure Indent_End
is
323 Indent
:= Indent
- 3;
330 procedure pg
(Node
: Node_Id
) is
332 Dump_Generated_Only
:= True;
333 Dump_Original_Only
:= False;
342 procedure po
(Node
: Node_Id
) is
344 Dump_Generated_Only
:= False;
345 Dump_Original_Only
:= True;
350 ----------------------
351 -- Print_Debug_Line --
352 ----------------------
354 procedure Print_Debug_Line
(S
: String) is
356 Write_Debug_Line
(S
, Debug_Sloc
);
357 end Print_Debug_Line
;
359 ---------------------------
360 -- Process_TFAI_RR_Flags --
361 ---------------------------
363 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
365 if Treat_Fixed_As_Integer
(Nod
) then
369 if Rounded_Result
(Nod
) then
372 end Process_TFAI_RR_Flags
;
378 procedure ps
(Node
: Node_Id
) is
380 Dump_Generated_Only
:= False;
381 Dump_Original_Only
:= False;
390 procedure Set_Debug_Sloc
is
392 if Present
(Debug_Node
) then
393 Set_Sloc
(Debug_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
402 procedure Source_Dump
is
405 -- Put underline under string we just printed
407 procedure Underline
is
408 Col
: constant Int
:= Column
;
413 while Col
> Column
loop
420 -- Start of processing for Tree_Dump.
423 Dump_Generated_Only
:= Debug_Flag_G
or
424 Print_Generated_Code
or
425 Debug_Generated_Code
;
426 Dump_Original_Only
:= Debug_Flag_O
;
427 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
429 -- Note that we turn off the tree dump flags immediately, before
430 -- starting the dump. This avoids generating two copies of the dump
431 -- if an abort occurs after printing the dump, and more importantly,
432 -- avoids an infinite loop if an abort occurs during the dump.
435 Debug_Flag_Z
:= False;
438 Write_Str
("Source recreated from tree of Standard (spec)");
440 Sprint_Node
(Standard_Package_Node
);
445 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
446 Debug_Flag_G
:= False;
447 Debug_Flag_O
:= False;
448 Debug_Flag_S
:= False;
450 -- Dump requested units
452 for U
in Main_Unit
.. Last_Unit
loop
454 -- Dump all units if -gnatdf set, otherwise we dump only
455 -- the source files that are in the extended main source.
458 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
460 -- If we are generating debug files, setup to write them
462 if Debug_Generated_Code
then
463 Set_Special_Output
(Print_Debug_Line
'Access);
464 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
465 Sprint_Node
(Cunit
(U
));
468 Set_Special_Output
(null);
470 -- Normal output to standard output file
473 Write_Str
("Source recreated from tree for ");
474 Write_Unit_Name
(Unit_Name
(U
));
476 Sprint_Node
(Cunit
(U
));
485 ---------------------
486 -- Sprint_And_List --
487 ---------------------
489 procedure Sprint_And_List
(List
: List_Id
) is
492 if Is_Non_Empty_List
(List
) then
493 Node
:= First
(List
);
497 exit when Node
= Empty
;
503 ---------------------
504 -- Sprint_Bar_List --
505 ---------------------
507 procedure Sprint_Bar_List
(List
: List_Id
) is
510 if Is_Non_Empty_List
(List
) then
511 Node
:= First
(List
);
515 exit when Node
= Empty
;
521 -----------------------
522 -- Sprint_Comma_List --
523 -----------------------
525 procedure Sprint_Comma_List
(List
: List_Id
) is
529 if Is_Non_Empty_List
(List
) then
530 Node
:= First
(List
);
534 exit when Node
= Empty
;
536 if not Is_Rewrite_Insertion
(Node
)
537 or else not Dump_Original_Only
543 end Sprint_Comma_List
;
545 --------------------------
546 -- Sprint_Indented_List --
547 --------------------------
549 procedure Sprint_Indented_List
(List
: List_Id
) is
552 Sprint_Node_List
(List
);
554 end Sprint_Indented_List
;
556 ---------------------
557 -- Sprint_Left_Opnd --
558 ---------------------
560 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
561 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
564 if Paren_Count
(Opnd
) /= 0
565 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
574 end Sprint_Left_Opnd
;
580 procedure Sprint_Node
(Node
: Node_Id
) is
582 if Is_Rewrite_Insertion
(Node
) then
583 if not Dump_Original_Only
then
585 -- For special cases of nodes that always output <<< >>>
586 -- do not duplicate the output at this point.
588 if Nkind
(Node
) = N_Freeze_Entity
589 or else Nkind
(Node
) = N_Implicit_Label_Declaration
591 Sprint_Node_Actual
(Node
);
593 -- Normal case where <<< >>> may be required
596 Write_Rewrite_Str
("<<<");
597 Sprint_Node_Actual
(Node
);
598 Write_Rewrite_Str
(">>>");
602 elsif Is_Rewrite_Substitution
(Node
) then
604 -- Case of dump generated only
606 if Dump_Generated_Only
then
607 Sprint_Node_Actual
(Node
);
609 -- Case of dump original only
611 elsif Dump_Original_Only
then
612 Sprint_Node_Actual
(Original_Node
(Node
));
614 -- Case of both being dumped
617 Sprint_Node_Actual
(Original_Node
(Node
));
618 Write_Rewrite_Str
("<<<");
619 Sprint_Node_Actual
(Node
);
620 Write_Rewrite_Str
(">>>");
624 Sprint_Node_Actual
(Node
);
628 ------------------------
629 -- Sprint_Node_Actual --
630 ------------------------
632 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
633 Save_Debug_Node
: constant Node_Id
:= Debug_Node
;
640 for J
in 1 .. Paren_Count
(Node
) loop
641 Write_Str_With_Col_Check
("(");
644 -- Setup node for Sloc fixup if writing a debug source file. Note
645 -- that we take care of any previous node not yet properly set.
647 if Debug_Generated_Code
then
651 if Nkind
(Node
) in N_Subexpr
652 and then Do_Range_Check
(Node
)
654 Write_Str_With_Col_Check
("{");
657 -- Select print circuit based on node kind
661 when N_Abort_Statement
=>
662 Write_Indent_Str_Sloc
("abort ");
663 Sprint_Comma_List
(Names
(Node
));
666 when N_Abortable_Part
=>
668 Write_Str_Sloc
("abort ");
669 Sprint_Indented_List
(Statements
(Node
));
671 when N_Abstract_Subprogram_Declaration
=>
673 Sprint_Node
(Specification
(Node
));
674 Write_Str_With_Col_Check
(" is ");
675 Write_Str_Sloc
("abstract;");
677 when N_Accept_Alternative
=>
678 Sprint_Node_List
(Pragmas_Before
(Node
));
680 if Present
(Condition
(Node
)) then
681 Write_Indent_Str
("when ");
682 Sprint_Node
(Condition
(Node
));
687 Sprint_Node_Sloc
(Accept_Statement
(Node
));
688 Sprint_Node_List
(Statements
(Node
));
690 when N_Accept_Statement
=>
691 Write_Indent_Str_Sloc
("accept ");
692 Write_Id
(Entry_Direct_Name
(Node
));
694 if Present
(Entry_Index
(Node
)) then
695 Write_Str_With_Col_Check
(" (");
696 Sprint_Node
(Entry_Index
(Node
));
700 Write_Param_Specs
(Node
);
702 if Present
(Handled_Statement_Sequence
(Node
)) then
703 Write_Str_With_Col_Check
(" do");
704 Sprint_Node
(Handled_Statement_Sequence
(Node
));
705 Write_Indent_Str
("end ");
706 Write_Id
(Entry_Direct_Name
(Node
));
711 when N_Access_Definition
=>
715 if Present
(Access_To_Subprogram_Definition
(Node
)) then
716 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
720 if Null_Exclusion_Present
(Node
) then
721 Write_Str
("not null ");
724 Write_Str_With_Col_Check_Sloc
("access ");
726 if All_Present
(Node
) then
728 elsif Constant_Present
(Node
) then
729 Write_Str
("constant ");
732 Sprint_Node
(Subtype_Mark
(Node
));
735 when N_Access_Function_Definition
=>
739 if Null_Exclusion_Present
(Node
) then
740 Write_Str
("not null ");
743 Write_Str_With_Col_Check_Sloc
("access ");
745 if Protected_Present
(Node
) then
746 Write_Str_With_Col_Check
("protected ");
749 Write_Str_With_Col_Check
("function");
750 Write_Param_Specs
(Node
);
751 Write_Str_With_Col_Check
(" return ");
752 Sprint_Node
(Result_Definition
(Node
));
754 when N_Access_Procedure_Definition
=>
758 if Null_Exclusion_Present
(Node
) then
759 Write_Str
("not null ");
762 Write_Str_With_Col_Check_Sloc
("access ");
764 if Protected_Present
(Node
) then
765 Write_Str_With_Col_Check
("protected ");
768 Write_Str_With_Col_Check
("procedure");
769 Write_Param_Specs
(Node
);
771 when N_Access_To_Object_Definition
=>
772 Write_Str_With_Col_Check_Sloc
("access ");
774 if All_Present
(Node
) then
775 Write_Str_With_Col_Check
("all ");
776 elsif Constant_Present
(Node
) then
777 Write_Str_With_Col_Check
("constant ");
782 if Null_Exclusion_Present
(Node
) then
783 Write_Str
("not null ");
786 Sprint_Node
(Subtype_Indication
(Node
));
789 if Null_Record_Present
(Node
) then
790 Write_Str_With_Col_Check_Sloc
("(null record)");
793 Write_Str_With_Col_Check_Sloc
("(");
795 if Present
(Expressions
(Node
)) then
796 Sprint_Comma_List
(Expressions
(Node
));
798 if Present
(Component_Associations
(Node
)) then
803 if Present
(Component_Associations
(Node
)) then
810 Nd
:= First
(Component_Associations
(Node
));
818 if not Is_Rewrite_Insertion
(Nd
)
819 or else not Dump_Original_Only
833 Write_Str_With_Col_Check_Sloc
("new ");
837 if Null_Exclusion_Present
(Node
) then
838 Write_Str
("not null ");
841 Sprint_Node
(Expression
(Node
));
843 if Present
(Storage_Pool
(Node
)) then
844 Write_Str_With_Col_Check
("[storage_pool = ");
845 Sprint_Node
(Storage_Pool
(Node
));
850 Sprint_Left_Opnd
(Node
);
851 Write_Str_Sloc
(" and then ");
852 Sprint_Right_Opnd
(Node
);
855 Write_Indent_Str_Sloc
("for ");
856 Write_Id
(Identifier
(Node
));
857 Write_Str_With_Col_Check
(" use at ");
858 Sprint_Node
(Expression
(Node
));
861 when N_Assignment_Statement
=>
863 Sprint_Node
(Name
(Node
));
864 Write_Str_Sloc
(" := ");
865 Sprint_Node
(Expression
(Node
));
868 when N_Asynchronous_Select
=>
869 Write_Indent_Str_Sloc
("select");
871 Sprint_Node
(Triggering_Alternative
(Node
));
874 -- Note: let the printing of Abortable_Part handle outputting
875 -- the ABORT keyword, so that the Slco can be set correctly.
877 Write_Indent_Str
("then ");
878 Sprint_Node
(Abortable_Part
(Node
));
879 Write_Indent_Str
("end select;");
881 when N_Attribute_Definition_Clause
=>
882 Write_Indent_Str_Sloc
("for ");
883 Sprint_Node
(Name
(Node
));
885 Write_Name_With_Col_Check
(Chars
(Node
));
886 Write_Str_With_Col_Check
(" use ");
887 Sprint_Node
(Expression
(Node
));
890 when N_Attribute_Reference
=>
891 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
895 Sprint_Node
(Prefix
(Node
));
896 Write_Char_Sloc
(''');
897 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
898 Sprint_Paren_Comma_List
(Expressions
(Node
));
900 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
904 when N_Block_Statement
=>
907 if Present
(Identifier
(Node
))
908 and then (not Has_Created_Identifier
(Node
)
909 or else not Dump_Original_Only
)
911 Write_Rewrite_Str
("<<<");
912 Write_Id
(Identifier
(Node
));
914 Write_Rewrite_Str
(">>>");
917 if Present
(Declarations
(Node
)) then
918 Write_Str_With_Col_Check_Sloc
("declare");
919 Sprint_Indented_List
(Declarations
(Node
));
923 Write_Str_With_Col_Check_Sloc
("begin");
924 Sprint_Node
(Handled_Statement_Sequence
(Node
));
925 Write_Indent_Str
("end");
927 if Present
(Identifier
(Node
))
928 and then (not Has_Created_Identifier
(Node
)
929 or else not Dump_Original_Only
)
931 Write_Rewrite_Str
("<<<");
933 Write_Id
(Identifier
(Node
));
934 Write_Rewrite_Str
(">>>");
939 when N_Case_Statement
=>
940 Write_Indent_Str_Sloc
("case ");
941 Sprint_Node
(Expression
(Node
));
943 Sprint_Indented_List
(Alternatives
(Node
));
944 Write_Indent_Str
("end case;");
946 when N_Case_Statement_Alternative
=>
947 Write_Indent_Str_Sloc
("when ");
948 Sprint_Bar_List
(Discrete_Choices
(Node
));
950 Sprint_Indented_List
(Statements
(Node
));
952 when N_Character_Literal
=>
954 Write_Indent_Str
(" ");
957 Write_Char_Sloc
(''');
958 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
961 when N_Code_Statement
=>
964 Sprint_Node
(Expression
(Node
));
967 when N_Compilation_Unit
=>
968 Sprint_Node_List
(Context_Items
(Node
));
969 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
971 if Private_Present
(Node
) then
972 Write_Indent_Str
("private ");
976 Sprint_Node_Sloc
(Unit
(Node
));
978 if Present
(Actions
(Aux_Decls_Node
(Node
)))
980 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
985 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
986 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
988 when N_Compilation_Unit_Aux
=>
989 null; -- nothing to do, never used, see above
991 when N_Component_Association
=>
993 Sprint_Bar_List
(Choices
(Node
));
996 -- Ada 2005 (AI-287): Print the mbox if present
998 if Box_Present
(Node
) then
999 Write_Str_With_Col_Check
("<>");
1001 Sprint_Node
(Expression
(Node
));
1004 when N_Component_Clause
=>
1006 Sprint_Node
(Component_Name
(Node
));
1007 Write_Str_Sloc
(" at ");
1008 Sprint_Node
(Position
(Node
));
1010 Write_Str_With_Col_Check
("range ");
1011 Sprint_Node
(First_Bit
(Node
));
1013 Sprint_Node
(Last_Bit
(Node
));
1016 when N_Component_Definition
=>
1019 -- Ada 2005 (AI-230): Access definition components
1021 if Present
(Access_Definition
(Node
)) then
1022 Sprint_Node
(Access_Definition
(Node
));
1024 elsif Present
(Subtype_Indication
(Node
)) then
1025 if Aliased_Present
(Node
) then
1026 Write_Str_With_Col_Check
("aliased ");
1029 -- Ada 2005 (AI-231)
1031 if Null_Exclusion_Present
(Node
) then
1032 Write_Str
(" not null ");
1035 Sprint_Node
(Subtype_Indication
(Node
));
1038 Write_Str
(" ??? ");
1041 when N_Component_Declaration
=>
1042 if Write_Indent_Identifiers_Sloc
(Node
) then
1044 Sprint_Node
(Component_Definition
(Node
));
1046 if Present
(Expression
(Node
)) then
1048 Sprint_Node
(Expression
(Node
));
1054 when N_Component_List
=>
1055 if Null_Present
(Node
) then
1057 Write_Indent_Str_Sloc
("null");
1063 Sprint_Indented_List
(Component_Items
(Node
));
1064 Sprint_Node
(Variant_Part
(Node
));
1067 when N_Conditional_Entry_Call
=>
1068 Write_Indent_Str_Sloc
("select");
1070 Sprint_Node
(Entry_Call_Alternative
(Node
));
1072 Write_Indent_Str
("else");
1073 Sprint_Indented_List
(Else_Statements
(Node
));
1074 Write_Indent_Str
("end select;");
1076 when N_Conditional_Expression
=>
1078 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
1079 Then_Expr
: constant Node_Id
:= Next
(Condition
);
1080 Else_Expr
: constant Node_Id
:= Next
(Then_Expr
);
1083 Write_Str_With_Col_Check_Sloc
("(if ");
1084 Sprint_Node
(Condition
);
1085 Write_Str_With_Col_Check
(" then ");
1086 Sprint_Node
(Then_Expr
);
1087 Write_Str_With_Col_Check
(" else ");
1088 Sprint_Node
(Else_Expr
);
1092 when N_Constrained_Array_Definition
=>
1093 Write_Str_With_Col_Check_Sloc
("array ");
1094 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1097 Sprint_Node
(Component_Definition
(Node
));
1099 when N_Decimal_Fixed_Point_Definition
=>
1100 Write_Str_With_Col_Check_Sloc
(" delta ");
1101 Sprint_Node
(Delta_Expression
(Node
));
1102 Write_Str_With_Col_Check
("digits ");
1103 Sprint_Node
(Digits_Expression
(Node
));
1104 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1106 when N_Defining_Character_Literal
=>
1107 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1109 when N_Defining_Identifier
=>
1113 when N_Defining_Operator_Symbol
=>
1114 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1116 when N_Defining_Program_Unit_Name
=>
1118 Sprint_Node
(Name
(Node
));
1120 Write_Id
(Defining_Identifier
(Node
));
1122 when N_Delay_Alternative
=>
1123 Sprint_Node_List
(Pragmas_Before
(Node
));
1125 if Present
(Condition
(Node
)) then
1127 Write_Str_With_Col_Check
("when ");
1128 Sprint_Node
(Condition
(Node
));
1133 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1134 Sprint_Node_List
(Statements
(Node
));
1136 when N_Delay_Relative_Statement
=>
1137 Write_Indent_Str_Sloc
("delay ");
1138 Sprint_Node
(Expression
(Node
));
1141 when N_Delay_Until_Statement
=>
1142 Write_Indent_Str_Sloc
("delay until ");
1143 Sprint_Node
(Expression
(Node
));
1146 when N_Delta_Constraint
=>
1147 Write_Str_With_Col_Check_Sloc
("delta ");
1148 Sprint_Node
(Delta_Expression
(Node
));
1149 Sprint_Opt_Node
(Range_Constraint
(Node
));
1151 when N_Derived_Type_Definition
=>
1152 if Abstract_Present
(Node
) then
1153 Write_Str_With_Col_Check
("abstract ");
1156 Write_Str_With_Col_Check_Sloc
("new ");
1158 -- Ada 2005 (AI-231)
1160 if Null_Exclusion_Present
(Node
) then
1161 Write_Str_With_Col_Check
("not null ");
1164 Sprint_Node
(Subtype_Indication
(Node
));
1166 if Present
(Interface_List
(Node
)) then
1167 Sprint_And_List
(Interface_List
(Node
));
1168 Write_Str_With_Col_Check
(" with ");
1171 if Present
(Record_Extension_Part
(Node
)) then
1172 if No
(Interface_List
(Node
)) then
1173 Write_Str_With_Col_Check
(" with ");
1176 Sprint_Node
(Record_Extension_Part
(Node
));
1179 when N_Designator
=>
1180 Sprint_Node
(Name
(Node
));
1181 Write_Char_Sloc
('.');
1182 Write_Id
(Identifier
(Node
));
1184 when N_Digits_Constraint
=>
1185 Write_Str_With_Col_Check_Sloc
("digits ");
1186 Sprint_Node
(Digits_Expression
(Node
));
1187 Sprint_Opt_Node
(Range_Constraint
(Node
));
1189 when N_Discriminant_Association
=>
1192 if Present
(Selector_Names
(Node
)) then
1193 Sprint_Bar_List
(Selector_Names
(Node
));
1198 Sprint_Node
(Expression
(Node
));
1200 when N_Discriminant_Specification
=>
1203 if Write_Identifiers
(Node
) then
1206 if Null_Exclusion_Present
(Node
) then
1207 Write_Str
("not null ");
1210 Sprint_Node
(Discriminant_Type
(Node
));
1212 if Present
(Expression
(Node
)) then
1214 Sprint_Node
(Expression
(Node
));
1220 when N_Elsif_Part
=>
1221 Write_Indent_Str_Sloc
("elsif ");
1222 Sprint_Node
(Condition
(Node
));
1223 Write_Str_With_Col_Check
(" then");
1224 Sprint_Indented_List
(Then_Statements
(Node
));
1229 when N_Entry_Body
=>
1230 Write_Indent_Str_Sloc
("entry ");
1231 Write_Id
(Defining_Identifier
(Node
));
1232 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1233 Write_Str_With_Col_Check
(" is");
1234 Sprint_Indented_List
(Declarations
(Node
));
1235 Write_Indent_Str
("begin");
1236 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1237 Write_Indent_Str
("end ");
1238 Write_Id
(Defining_Identifier
(Node
));
1241 when N_Entry_Body_Formal_Part
=>
1242 if Present
(Entry_Index_Specification
(Node
)) then
1243 Write_Str_With_Col_Check_Sloc
(" (");
1244 Sprint_Node
(Entry_Index_Specification
(Node
));
1248 Write_Param_Specs
(Node
);
1249 Write_Str_With_Col_Check_Sloc
(" when ");
1250 Sprint_Node
(Condition
(Node
));
1252 when N_Entry_Call_Alternative
=>
1253 Sprint_Node_List
(Pragmas_Before
(Node
));
1254 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1255 Sprint_Node_List
(Statements
(Node
));
1257 when N_Entry_Call_Statement
=>
1259 Sprint_Node_Sloc
(Name
(Node
));
1260 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1263 when N_Entry_Declaration
=>
1264 Write_Indent_Str_Sloc
("entry ");
1265 Write_Id
(Defining_Identifier
(Node
));
1267 if Present
(Discrete_Subtype_Definition
(Node
)) then
1268 Write_Str_With_Col_Check
(" (");
1269 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1273 Write_Param_Specs
(Node
);
1276 when N_Entry_Index_Specification
=>
1277 Write_Str_With_Col_Check_Sloc
("for ");
1278 Write_Id
(Defining_Identifier
(Node
));
1279 Write_Str_With_Col_Check
(" in ");
1280 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1282 when N_Enumeration_Representation_Clause
=>
1283 Write_Indent_Str_Sloc
("for ");
1284 Write_Id
(Identifier
(Node
));
1285 Write_Str_With_Col_Check
(" use ");
1286 Sprint_Node
(Array_Aggregate
(Node
));
1289 when N_Enumeration_Type_Definition
=>
1292 -- Skip attempt to print Literals field if it's not there and
1293 -- we are in package Standard (case of Character, which is
1294 -- handled specially (without an explicit literals list).
1296 if Sloc
(Node
) > Standard_Location
1297 or else Present
(Literals
(Node
))
1299 Sprint_Paren_Comma_List
(Literals
(Node
));
1303 Write_Str_With_Col_Check_Sloc
("<error>");
1305 when N_Exception_Declaration
=>
1306 if Write_Indent_Identifiers
(Node
) then
1307 Write_Str_With_Col_Check
(" : ");
1308 Write_Str_Sloc
("exception;");
1311 when N_Exception_Handler
=>
1312 Write_Indent_Str_Sloc
("when ");
1314 if Present
(Choice_Parameter
(Node
)) then
1315 Sprint_Node
(Choice_Parameter
(Node
));
1319 Sprint_Bar_List
(Exception_Choices
(Node
));
1321 Sprint_Indented_List
(Statements
(Node
));
1323 when N_Exception_Renaming_Declaration
=>
1326 Sprint_Node
(Defining_Identifier
(Node
));
1327 Write_Str_With_Col_Check
(" : exception renames ");
1328 Sprint_Node
(Name
(Node
));
1331 when N_Exit_Statement
=>
1332 Write_Indent_Str_Sloc
("exit");
1333 Sprint_Opt_Node
(Name
(Node
));
1335 if Present
(Condition
(Node
)) then
1336 Write_Str_With_Col_Check
(" when ");
1337 Sprint_Node
(Condition
(Node
));
1342 when N_Expanded_Name
=>
1343 Sprint_Node
(Prefix
(Node
));
1344 Write_Char_Sloc
('.');
1345 Sprint_Node
(Selector_Name
(Node
));
1347 when N_Explicit_Dereference
=>
1348 Sprint_Node
(Prefix
(Node
));
1349 Write_Char_Sloc
('.');
1350 Write_Str_Sloc
("all");
1352 when N_Extension_Aggregate
=>
1353 Write_Str_With_Col_Check_Sloc
("(");
1354 Sprint_Node
(Ancestor_Part
(Node
));
1355 Write_Str_With_Col_Check
(" with ");
1357 if Null_Record_Present
(Node
) then
1358 Write_Str_With_Col_Check
("null record");
1360 if Present
(Expressions
(Node
)) then
1361 Sprint_Comma_List
(Expressions
(Node
));
1363 if Present
(Component_Associations
(Node
)) then
1368 if Present
(Component_Associations
(Node
)) then
1369 Sprint_Comma_List
(Component_Associations
(Node
));
1375 when N_Floating_Point_Definition
=>
1376 Write_Str_With_Col_Check_Sloc
("digits ");
1377 Sprint_Node
(Digits_Expression
(Node
));
1378 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1380 when N_Formal_Decimal_Fixed_Point_Definition
=>
1381 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1383 when N_Formal_Derived_Type_Definition
=>
1384 Write_Str_With_Col_Check_Sloc
("new ");
1385 Sprint_Node
(Subtype_Mark
(Node
));
1387 if Private_Present
(Node
) then
1388 Write_Str_With_Col_Check
(" with private");
1391 when N_Formal_Abstract_Subprogram_Declaration
=>
1392 Write_Indent_Str_Sloc
("with ");
1393 Sprint_Node
(Specification
(Node
));
1395 Write_Str_With_Col_Check
(" is abstract");
1397 if Box_Present
(Node
) then
1398 Write_Str_With_Col_Check
(" <>");
1399 elsif Present
(Default_Name
(Node
)) then
1400 Write_Str_With_Col_Check
(" ");
1401 Sprint_Node
(Default_Name
(Node
));
1406 when N_Formal_Concrete_Subprogram_Declaration
=>
1407 Write_Indent_Str_Sloc
("with ");
1408 Sprint_Node
(Specification
(Node
));
1410 if Box_Present
(Node
) then
1411 Write_Str_With_Col_Check
(" is <>");
1412 elsif Present
(Default_Name
(Node
)) then
1413 Write_Str_With_Col_Check
(" is ");
1414 Sprint_Node
(Default_Name
(Node
));
1419 when N_Formal_Discrete_Type_Definition
=>
1420 Write_Str_With_Col_Check_Sloc
("<>");
1422 when N_Formal_Floating_Point_Definition
=>
1423 Write_Str_With_Col_Check_Sloc
("digits <>");
1425 when N_Formal_Modular_Type_Definition
=>
1426 Write_Str_With_Col_Check_Sloc
("mod <>");
1428 when N_Formal_Object_Declaration
=>
1431 if Write_Indent_Identifiers
(Node
) then
1434 if In_Present
(Node
) then
1435 Write_Str_With_Col_Check
("in ");
1438 if Out_Present
(Node
) then
1439 Write_Str_With_Col_Check
("out ");
1442 Sprint_Node
(Subtype_Mark
(Node
));
1444 if Present
(Expression
(Node
)) then
1446 Sprint_Node
(Expression
(Node
));
1452 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1453 Write_Str_With_Col_Check_Sloc
("delta <>");
1455 when N_Formal_Package_Declaration
=>
1456 Write_Indent_Str_Sloc
("with package ");
1457 Write_Id
(Defining_Identifier
(Node
));
1458 Write_Str_With_Col_Check
(" is new ");
1459 Sprint_Node
(Name
(Node
));
1460 Write_Str_With_Col_Check
(" (<>);");
1462 when N_Formal_Private_Type_Definition
=>
1463 if Abstract_Present
(Node
) then
1464 Write_Str_With_Col_Check
("abstract ");
1467 if Tagged_Present
(Node
) then
1468 Write_Str_With_Col_Check
("tagged ");
1471 if Limited_Present
(Node
) then
1472 Write_Str_With_Col_Check
("limited ");
1475 Write_Str_With_Col_Check_Sloc
("private");
1477 when N_Formal_Signed_Integer_Type_Definition
=>
1478 Write_Str_With_Col_Check_Sloc
("range <>");
1480 when N_Formal_Type_Declaration
=>
1481 Write_Indent_Str_Sloc
("type ");
1482 Write_Id
(Defining_Identifier
(Node
));
1484 if Present
(Discriminant_Specifications
(Node
)) then
1485 Write_Discr_Specs
(Node
);
1486 elsif Unknown_Discriminants_Present
(Node
) then
1487 Write_Str_With_Col_Check
("(<>)");
1490 Write_Str_With_Col_Check
(" is ");
1491 Sprint_Node
(Formal_Type_Definition
(Node
));
1494 when N_Free_Statement
=>
1495 Write_Indent_Str_Sloc
("free ");
1496 Sprint_Node
(Expression
(Node
));
1499 when N_Freeze_Entity
=>
1500 if Dump_Original_Only
then
1503 elsif Present
(Actions
(Node
)) or else Dump_Freeze_Null
then
1505 Write_Rewrite_Str
("<<<");
1506 Write_Str_With_Col_Check_Sloc
("freeze ");
1507 Write_Id
(Entity
(Node
));
1510 if No
(Actions
(Node
)) then
1514 Freeze_Indent
:= Freeze_Indent
+ 1;
1515 Sprint_Indented_List
(Actions
(Node
));
1516 Freeze_Indent
:= Freeze_Indent
- 1;
1517 Write_Indent_Str
("]");
1520 Write_Rewrite_Str
(">>>");
1523 when N_Full_Type_Declaration
=>
1524 Write_Indent_Str_Sloc
("type ");
1525 Write_Id
(Defining_Identifier
(Node
));
1526 Write_Discr_Specs
(Node
);
1527 Write_Str_With_Col_Check
(" is ");
1528 Sprint_Node
(Type_Definition
(Node
));
1531 when N_Function_Call
=>
1533 Sprint_Node
(Name
(Node
));
1534 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1536 when N_Function_Instantiation
=>
1537 Write_Indent_Str_Sloc
("function ");
1538 Sprint_Node
(Defining_Unit_Name
(Node
));
1539 Write_Str_With_Col_Check
(" is new ");
1540 Sprint_Node
(Name
(Node
));
1541 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1544 when N_Function_Specification
=>
1545 Write_Str_With_Col_Check_Sloc
("function ");
1546 Sprint_Node
(Defining_Unit_Name
(Node
));
1547 Write_Param_Specs
(Node
);
1548 Write_Str_With_Col_Check
(" return ");
1550 -- Ada 2005 (AI-231)
1552 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
1553 and then Null_Exclusion_Present
(Node
)
1555 Write_Str
(" not null ");
1558 Sprint_Node
(Result_Definition
(Node
));
1560 when N_Generic_Association
=>
1563 if Present
(Selector_Name
(Node
)) then
1564 Sprint_Node
(Selector_Name
(Node
));
1568 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
1570 when N_Generic_Function_Renaming_Declaration
=>
1571 Write_Indent_Str_Sloc
("generic function ");
1572 Sprint_Node
(Defining_Unit_Name
(Node
));
1573 Write_Str_With_Col_Check
(" renames ");
1574 Sprint_Node
(Name
(Node
));
1577 when N_Generic_Package_Declaration
=>
1579 Write_Indent_Str_Sloc
("generic ");
1580 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1582 Sprint_Node
(Specification
(Node
));
1585 when N_Generic_Package_Renaming_Declaration
=>
1586 Write_Indent_Str_Sloc
("generic package ");
1587 Sprint_Node
(Defining_Unit_Name
(Node
));
1588 Write_Str_With_Col_Check
(" renames ");
1589 Sprint_Node
(Name
(Node
));
1592 when N_Generic_Procedure_Renaming_Declaration
=>
1593 Write_Indent_Str_Sloc
("generic procedure ");
1594 Sprint_Node
(Defining_Unit_Name
(Node
));
1595 Write_Str_With_Col_Check
(" renames ");
1596 Sprint_Node
(Name
(Node
));
1599 when N_Generic_Subprogram_Declaration
=>
1601 Write_Indent_Str_Sloc
("generic ");
1602 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1604 Sprint_Node
(Specification
(Node
));
1607 when N_Goto_Statement
=>
1608 Write_Indent_Str_Sloc
("goto ");
1609 Sprint_Node
(Name
(Node
));
1612 if Nkind
(Next
(Node
)) = N_Label
then
1616 when N_Handled_Sequence_Of_Statements
=>
1618 Sprint_Indented_List
(Statements
(Node
));
1620 if Present
(Exception_Handlers
(Node
)) then
1621 Write_Indent_Str
("exception");
1623 Sprint_Node_List
(Exception_Handlers
(Node
));
1627 if Present
(At_End_Proc
(Node
)) then
1628 Write_Indent_Str
("at end");
1631 Sprint_Node
(At_End_Proc
(Node
));
1636 when N_Identifier
=>
1640 when N_If_Statement
=>
1641 Write_Indent_Str_Sloc
("if ");
1642 Sprint_Node
(Condition
(Node
));
1643 Write_Str_With_Col_Check
(" then");
1644 Sprint_Indented_List
(Then_Statements
(Node
));
1645 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
1647 if Present
(Else_Statements
(Node
)) then
1648 Write_Indent_Str
("else");
1649 Sprint_Indented_List
(Else_Statements
(Node
));
1652 Write_Indent_Str
("end if;");
1654 when N_Implicit_Label_Declaration
=>
1655 if not Dump_Original_Only
then
1657 Write_Rewrite_Str
("<<<");
1659 Write_Id
(Defining_Identifier
(Node
));
1661 Write_Str_With_Col_Check
("label");
1662 Write_Rewrite_Str
(">>>");
1666 Sprint_Left_Opnd
(Node
);
1667 Write_Str_Sloc
(" in ");
1668 Sprint_Right_Opnd
(Node
);
1670 when N_Incomplete_Type_Declaration
=>
1671 Write_Indent_Str_Sloc
("type ");
1672 Write_Id
(Defining_Identifier
(Node
));
1674 if Present
(Discriminant_Specifications
(Node
)) then
1675 Write_Discr_Specs
(Node
);
1676 elsif Unknown_Discriminants_Present
(Node
) then
1677 Write_Str_With_Col_Check
("(<>)");
1682 when N_Index_Or_Discriminant_Constraint
=>
1684 Sprint_Paren_Comma_List
(Constraints
(Node
));
1686 when N_Indexed_Component
=>
1687 Sprint_Node_Sloc
(Prefix
(Node
));
1688 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
1690 when N_Integer_Literal
=>
1691 if Print_In_Hex
(Node
) then
1692 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
1694 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
1697 when N_Iteration_Scheme
=>
1698 if Present
(Condition
(Node
)) then
1699 Write_Str_With_Col_Check_Sloc
("while ");
1700 Sprint_Node
(Condition
(Node
));
1702 Write_Str_With_Col_Check_Sloc
("for ");
1703 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1708 when N_Itype_Reference
=>
1709 Write_Indent_Str_Sloc
("reference ");
1710 Write_Id
(Itype
(Node
));
1713 Write_Indent_Str_Sloc
("<<");
1714 Write_Id
(Identifier
(Node
));
1717 when N_Loop_Parameter_Specification
=>
1719 Write_Id
(Defining_Identifier
(Node
));
1720 Write_Str_With_Col_Check
(" in ");
1722 if Reverse_Present
(Node
) then
1723 Write_Str_With_Col_Check
("reverse ");
1726 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1728 when N_Loop_Statement
=>
1731 if Present
(Identifier
(Node
))
1732 and then (not Has_Created_Identifier
(Node
)
1733 or else not Dump_Original_Only
)
1735 Write_Rewrite_Str
("<<<");
1736 Write_Id
(Identifier
(Node
));
1738 Write_Rewrite_Str
(">>>");
1739 Sprint_Node
(Iteration_Scheme
(Node
));
1740 Write_Str_With_Col_Check_Sloc
("loop");
1741 Sprint_Indented_List
(Statements
(Node
));
1742 Write_Indent_Str
("end loop ");
1743 Write_Rewrite_Str
("<<<");
1744 Write_Id
(Identifier
(Node
));
1745 Write_Rewrite_Str
(">>>");
1749 Sprint_Node
(Iteration_Scheme
(Node
));
1750 Write_Str_With_Col_Check_Sloc
("loop");
1751 Sprint_Indented_List
(Statements
(Node
));
1752 Write_Indent_Str
("end loop;");
1755 when N_Mod_Clause
=>
1756 Sprint_Node_List
(Pragmas_Before
(Node
));
1757 Write_Str_With_Col_Check_Sloc
("at mod ");
1758 Sprint_Node
(Expression
(Node
));
1760 when N_Modular_Type_Definition
=>
1761 Write_Str_With_Col_Check_Sloc
("mod ");
1762 Sprint_Node
(Expression
(Node
));
1765 Sprint_Left_Opnd
(Node
);
1766 Write_Str_Sloc
(" not in ");
1767 Sprint_Right_Opnd
(Node
);
1770 Write_Str_With_Col_Check_Sloc
("null");
1772 when N_Null_Statement
=>
1773 if Comes_From_Source
(Node
)
1774 or else Dump_Freeze_Null
1775 or else not Is_List_Member
(Node
)
1776 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
1778 Write_Indent_Str_Sloc
("null;");
1781 when N_Number_Declaration
=>
1784 if Write_Indent_Identifiers
(Node
) then
1785 Write_Str_With_Col_Check
(" : constant ");
1787 Sprint_Node
(Expression
(Node
));
1791 when N_Object_Declaration
=>
1794 if Write_Indent_Identifiers
(Node
) then
1797 if Aliased_Present
(Node
) then
1798 Write_Str_With_Col_Check
("aliased ");
1801 if Constant_Present
(Node
) then
1802 Write_Str_With_Col_Check
("constant ");
1805 -- Ada 2005 (AI-231)
1807 if Null_Exclusion_Present
(Node
) then
1808 Write_Str_With_Col_Check
("not null ");
1811 Sprint_Node
(Object_Definition
(Node
));
1813 if Present
(Expression
(Node
)) then
1815 Sprint_Node
(Expression
(Node
));
1821 when N_Object_Renaming_Declaration
=>
1824 Sprint_Node
(Defining_Identifier
(Node
));
1827 -- Ada 2005 (AI-230): Access renamings
1829 if Present
(Access_Definition
(Node
)) then
1830 Sprint_Node
(Access_Definition
(Node
));
1832 elsif Present
(Subtype_Mark
(Node
)) then
1833 Sprint_Node
(Subtype_Mark
(Node
));
1836 Write_Str
(" ??? ");
1839 Write_Str_With_Col_Check
(" renames ");
1840 Sprint_Node
(Name
(Node
));
1844 Write_Operator
(Node
, "abs ");
1845 Sprint_Right_Opnd
(Node
);
1848 Sprint_Left_Opnd
(Node
);
1849 Write_Operator
(Node
, " + ");
1850 Sprint_Right_Opnd
(Node
);
1853 Sprint_Left_Opnd
(Node
);
1854 Write_Operator
(Node
, " and ");
1855 Sprint_Right_Opnd
(Node
);
1858 Sprint_Left_Opnd
(Node
);
1859 Write_Operator
(Node
, " & ");
1860 Sprint_Right_Opnd
(Node
);
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 Sprint_Left_Opnd
(Node
);
1876 Write_Operator
(Node
, " ** ");
1877 Sprint_Right_Opnd
(Node
);
1880 Sprint_Left_Opnd
(Node
);
1881 Write_Operator
(Node
, " >= ");
1882 Sprint_Right_Opnd
(Node
);
1885 Sprint_Left_Opnd
(Node
);
1886 Write_Operator
(Node
, " > ");
1887 Sprint_Right_Opnd
(Node
);
1890 Sprint_Left_Opnd
(Node
);
1891 Write_Operator
(Node
, " <= ");
1892 Sprint_Right_Opnd
(Node
);
1895 Sprint_Left_Opnd
(Node
);
1896 Write_Operator
(Node
, " < ");
1897 Sprint_Right_Opnd
(Node
);
1900 Write_Operator
(Node
, "-");
1901 Sprint_Right_Opnd
(Node
);
1904 Sprint_Left_Opnd
(Node
);
1906 if Treat_Fixed_As_Integer
(Node
) then
1910 Write_Operator
(Node
, " mod ");
1911 Sprint_Right_Opnd
(Node
);
1913 when N_Op_Multiply
=>
1914 Sprint_Left_Opnd
(Node
);
1916 Process_TFAI_RR_Flags
(Node
);
1917 Write_Operator
(Node
, "* ");
1918 Sprint_Right_Opnd
(Node
);
1921 Sprint_Left_Opnd
(Node
);
1922 Write_Operator
(Node
, " /= ");
1923 Sprint_Right_Opnd
(Node
);
1926 Write_Operator
(Node
, "not ");
1927 Sprint_Right_Opnd
(Node
);
1930 Sprint_Left_Opnd
(Node
);
1931 Write_Operator
(Node
, " or ");
1932 Sprint_Right_Opnd
(Node
);
1935 Write_Operator
(Node
, "+");
1936 Sprint_Right_Opnd
(Node
);
1939 Sprint_Left_Opnd
(Node
);
1941 if Treat_Fixed_As_Integer
(Node
) then
1945 Write_Operator
(Node
, " rem ");
1946 Sprint_Right_Opnd
(Node
);
1952 Write_Str_With_Col_Check
("(");
1953 Sprint_Node
(Left_Opnd
(Node
));
1955 Sprint_Node
(Right_Opnd
(Node
));
1958 when N_Op_Subtract
=>
1959 Sprint_Left_Opnd
(Node
);
1960 Write_Operator
(Node
, " - ");
1961 Sprint_Right_Opnd
(Node
);
1964 Sprint_Left_Opnd
(Node
);
1965 Write_Operator
(Node
, " xor ");
1966 Sprint_Right_Opnd
(Node
);
1968 when N_Operator_Symbol
=>
1969 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1971 when N_Ordinary_Fixed_Point_Definition
=>
1972 Write_Str_With_Col_Check_Sloc
("delta ");
1973 Sprint_Node
(Delta_Expression
(Node
));
1974 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1977 Sprint_Left_Opnd
(Node
);
1978 Write_Str_Sloc
(" or else ");
1979 Sprint_Right_Opnd
(Node
);
1981 when N_Others_Choice
=>
1982 if All_Others
(Node
) then
1983 Write_Str_With_Col_Check
("all ");
1986 Write_Str_With_Col_Check_Sloc
("others");
1988 when N_Package_Body
=>
1990 Write_Indent_Str_Sloc
("package body ");
1991 Sprint_Node
(Defining_Unit_Name
(Node
));
1993 Sprint_Indented_List
(Declarations
(Node
));
1995 if Present
(Handled_Statement_Sequence
(Node
)) then
1996 Write_Indent_Str
("begin");
1997 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2000 Write_Indent_Str
("end ");
2001 Sprint_Node
(Defining_Unit_Name
(Node
));
2004 when N_Package_Body_Stub
=>
2005 Write_Indent_Str_Sloc
("package body ");
2006 Sprint_Node
(Defining_Identifier
(Node
));
2007 Write_Str_With_Col_Check
(" is separate;");
2009 when N_Package_Declaration
=>
2012 Sprint_Node_Sloc
(Specification
(Node
));
2015 when N_Package_Instantiation
=>
2017 Write_Indent_Str_Sloc
("package ");
2018 Sprint_Node
(Defining_Unit_Name
(Node
));
2019 Write_Str
(" is new ");
2020 Sprint_Node
(Name
(Node
));
2021 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2024 when N_Package_Renaming_Declaration
=>
2025 Write_Indent_Str_Sloc
("package ");
2026 Sprint_Node
(Defining_Unit_Name
(Node
));
2027 Write_Str_With_Col_Check
(" renames ");
2028 Sprint_Node
(Name
(Node
));
2031 when N_Package_Specification
=>
2032 Write_Str_With_Col_Check_Sloc
("package ");
2033 Sprint_Node
(Defining_Unit_Name
(Node
));
2035 Sprint_Indented_List
(Visible_Declarations
(Node
));
2037 if Present
(Private_Declarations
(Node
)) then
2038 Write_Indent_Str
("private");
2039 Sprint_Indented_List
(Private_Declarations
(Node
));
2042 Write_Indent_Str
("end ");
2043 Sprint_Node
(Defining_Unit_Name
(Node
));
2045 when N_Parameter_Association
=>
2046 Sprint_Node_Sloc
(Selector_Name
(Node
));
2048 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2050 when N_Parameter_Specification
=>
2053 if Write_Identifiers
(Node
) then
2056 if In_Present
(Node
) then
2057 Write_Str_With_Col_Check
("in ");
2060 if Out_Present
(Node
) then
2061 Write_Str_With_Col_Check
("out ");
2064 -- Ada 2005 (AI-231)
2066 if Null_Exclusion_Present
(Node
) then
2067 Write_Str
("not null ");
2070 Sprint_Node
(Parameter_Type
(Node
));
2072 if Present
(Expression
(Node
)) then
2074 Sprint_Node
(Expression
(Node
));
2081 Write_Indent_Str_Sloc
("pragma ");
2082 Write_Name_With_Col_Check
(Chars
(Node
));
2084 if Present
(Pragma_Argument_Associations
(Node
)) then
2085 Sprint_Opt_Paren_Comma_List
2086 (Pragma_Argument_Associations
(Node
));
2091 when N_Pragma_Argument_Association
=>
2094 if Chars
(Node
) /= No_Name
then
2095 Write_Name_With_Col_Check
(Chars
(Node
));
2099 Sprint_Node
(Expression
(Node
));
2101 when N_Private_Type_Declaration
=>
2102 Write_Indent_Str_Sloc
("type ");
2103 Write_Id
(Defining_Identifier
(Node
));
2105 if Present
(Discriminant_Specifications
(Node
)) then
2106 Write_Discr_Specs
(Node
);
2107 elsif Unknown_Discriminants_Present
(Node
) then
2108 Write_Str_With_Col_Check
("(<>)");
2113 if Tagged_Present
(Node
) then
2114 Write_Str_With_Col_Check
("tagged ");
2117 if Limited_Present
(Node
) then
2118 Write_Str_With_Col_Check
("limited ");
2121 Write_Str_With_Col_Check
("private;");
2123 when N_Private_Extension_Declaration
=>
2124 Write_Indent_Str_Sloc
("type ");
2125 Write_Id
(Defining_Identifier
(Node
));
2127 if Present
(Discriminant_Specifications
(Node
)) then
2128 Write_Discr_Specs
(Node
);
2129 elsif Unknown_Discriminants_Present
(Node
) then
2130 Write_Str_With_Col_Check
("(<>)");
2133 Write_Str_With_Col_Check
(" is new ");
2134 Sprint_Node
(Subtype_Indication
(Node
));
2135 Write_Str_With_Col_Check
(" with private;");
2137 when N_Procedure_Call_Statement
=>
2140 Sprint_Node
(Name
(Node
));
2141 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2144 when N_Procedure_Instantiation
=>
2145 Write_Indent_Str_Sloc
("procedure ");
2146 Sprint_Node
(Defining_Unit_Name
(Node
));
2147 Write_Str_With_Col_Check
(" is new ");
2148 Sprint_Node
(Name
(Node
));
2149 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2152 when N_Procedure_Specification
=>
2153 Write_Str_With_Col_Check_Sloc
("procedure ");
2154 Sprint_Node
(Defining_Unit_Name
(Node
));
2155 Write_Param_Specs
(Node
);
2157 when N_Protected_Body
=>
2158 Write_Indent_Str_Sloc
("protected body ");
2159 Write_Id
(Defining_Identifier
(Node
));
2161 Sprint_Indented_List
(Declarations
(Node
));
2162 Write_Indent_Str
("end ");
2163 Write_Id
(Defining_Identifier
(Node
));
2166 when N_Protected_Body_Stub
=>
2167 Write_Indent_Str_Sloc
("protected body ");
2168 Write_Id
(Defining_Identifier
(Node
));
2169 Write_Str_With_Col_Check
(" is separate;");
2171 when N_Protected_Definition
=>
2173 Sprint_Indented_List
(Visible_Declarations
(Node
));
2175 if Present
(Private_Declarations
(Node
)) then
2176 Write_Indent_Str
("private");
2177 Sprint_Indented_List
(Private_Declarations
(Node
));
2180 Write_Indent_Str
("end ");
2182 when N_Protected_Type_Declaration
=>
2183 Write_Indent_Str_Sloc
("protected type ");
2184 Write_Id
(Defining_Identifier
(Node
));
2185 Write_Discr_Specs
(Node
);
2187 if Present
(Interface_List
(Node
)) then
2188 Write_Str
(" is new ");
2189 Sprint_And_List
(Interface_List
(Node
));
2190 Write_Str
(" with ");
2195 Sprint_Node
(Protected_Definition
(Node
));
2196 Write_Id
(Defining_Identifier
(Node
));
2199 when N_Qualified_Expression
=>
2200 Sprint_Node
(Subtype_Mark
(Node
));
2201 Write_Char_Sloc
(''');
2203 -- Print expression, make sure we have at least one level of
2204 -- parentheses around the expression. For cases of qualified
2205 -- expressions in the source, this is always the case, but
2206 -- for generated qualifications, there may be no explicit
2207 -- parentheses present.
2209 if Paren_Count
(Expression
(Node
)) /= 0 then
2210 Sprint_Node
(Expression
(Node
));
2213 Sprint_Node
(Expression
(Node
));
2217 when N_Raise_Constraint_Error
=>
2219 -- This node can be used either as a subexpression or as a
2220 -- statement form. The following test is a reasonably reliable
2221 -- way to distinguish the two cases.
2223 if Is_List_Member
(Node
)
2224 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2229 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2230 Write_Condition_And_Reason
(Node
);
2232 when N_Raise_Program_Error
=>
2234 -- This node can be used either as a subexpression or as a
2235 -- statement form. The following test is a reasonably reliable
2236 -- way to distinguish the two cases.
2238 if Is_List_Member
(Node
)
2239 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2244 Write_Str_With_Col_Check_Sloc
("[program_error");
2245 Write_Condition_And_Reason
(Node
);
2247 when N_Raise_Storage_Error
=>
2249 -- This node can be used either as a subexpression or as a
2250 -- statement form. The following test is a reasonably reliable
2251 -- way to distinguish the two cases.
2253 if Is_List_Member
(Node
)
2254 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2259 Write_Str_With_Col_Check_Sloc
("[storage_error");
2260 Write_Condition_And_Reason
(Node
);
2262 when N_Raise_Statement
=>
2263 Write_Indent_Str_Sloc
("raise ");
2264 Sprint_Node
(Name
(Node
));
2268 Sprint_Node
(Low_Bound
(Node
));
2269 Write_Str_Sloc
(" .. ");
2270 Sprint_Node
(High_Bound
(Node
));
2272 when N_Range_Constraint
=>
2273 Write_Str_With_Col_Check_Sloc
("range ");
2274 Sprint_Node
(Range_Expression
(Node
));
2276 when N_Real_Literal
=>
2277 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
2279 when N_Real_Range_Specification
=>
2280 Write_Str_With_Col_Check_Sloc
("range ");
2281 Sprint_Node
(Low_Bound
(Node
));
2283 Sprint_Node
(High_Bound
(Node
));
2285 when N_Record_Definition
=>
2286 if Abstract_Present
(Node
) then
2287 Write_Str_With_Col_Check
("abstract ");
2290 if Tagged_Present
(Node
) then
2291 Write_Str_With_Col_Check
("tagged ");
2294 if Limited_Present
(Node
) then
2295 Write_Str_With_Col_Check
("limited ");
2298 if Null_Present
(Node
) then
2299 Write_Str_With_Col_Check_Sloc
("null record");
2302 Write_Str_With_Col_Check_Sloc
("record");
2303 Sprint_Node
(Component_List
(Node
));
2304 Write_Indent_Str
("end record");
2307 when N_Record_Representation_Clause
=>
2308 Write_Indent_Str_Sloc
("for ");
2309 Sprint_Node
(Identifier
(Node
));
2310 Write_Str_With_Col_Check
(" use record ");
2312 if Present
(Mod_Clause
(Node
)) then
2313 Sprint_Node
(Mod_Clause
(Node
));
2316 Sprint_Indented_List
(Component_Clauses
(Node
));
2317 Write_Indent_Str
("end record;");
2320 Sprint_Node
(Prefix
(Node
));
2321 Write_Str_With_Col_Check_Sloc
("'reference");
2323 when N_Requeue_Statement
=>
2324 Write_Indent_Str_Sloc
("requeue ");
2325 Sprint_Node
(Name
(Node
));
2327 if Abort_Present
(Node
) then
2328 Write_Str_With_Col_Check
(" with abort");
2333 when N_Return_Statement
=>
2334 if Present
(Expression
(Node
)) then
2335 Write_Indent_Str_Sloc
("return ");
2336 Sprint_Node
(Expression
(Node
));
2339 Write_Indent_Str_Sloc
("return;");
2342 when N_Selective_Accept
=>
2343 Write_Indent_Str_Sloc
("select");
2349 Alt_Node
:= First
(Select_Alternatives
(Node
));
2352 Sprint_Node
(Alt_Node
);
2355 exit when No
(Alt_Node
);
2356 Write_Indent_Str
("or");
2360 if Present
(Else_Statements
(Node
)) then
2361 Write_Indent_Str
("else");
2362 Sprint_Indented_List
(Else_Statements
(Node
));
2365 Write_Indent_Str
("end select;");
2367 when N_Signed_Integer_Type_Definition
=>
2368 Write_Str_With_Col_Check_Sloc
("range ");
2369 Sprint_Node
(Low_Bound
(Node
));
2371 Sprint_Node
(High_Bound
(Node
));
2373 when N_Single_Protected_Declaration
=>
2374 Write_Indent_Str_Sloc
("protected ");
2375 Write_Id
(Defining_Identifier
(Node
));
2377 Sprint_Node
(Protected_Definition
(Node
));
2378 Write_Id
(Defining_Identifier
(Node
));
2381 when N_Single_Task_Declaration
=>
2382 Write_Indent_Str_Sloc
("task ");
2383 Write_Id
(Defining_Identifier
(Node
));
2385 if Present
(Task_Definition
(Node
)) then
2387 Sprint_Node
(Task_Definition
(Node
));
2388 Write_Id
(Defining_Identifier
(Node
));
2393 when N_Selected_Component
=>
2394 Sprint_Node
(Prefix
(Node
));
2395 Write_Char_Sloc
('.');
2396 Sprint_Node
(Selector_Name
(Node
));
2400 Sprint_Node
(Prefix
(Node
));
2401 Write_Str_With_Col_Check
(" (");
2402 Sprint_Node
(Discrete_Range
(Node
));
2405 when N_String_Literal
=>
2406 if String_Length
(Strval
(Node
)) + Column
> 75 then
2407 Write_Indent_Str
(" ");
2411 Write_String_Table_Entry
(Strval
(Node
));
2413 when N_Subprogram_Body
=>
2414 if Freeze_Indent
= 0 then
2419 Sprint_Node_Sloc
(Specification
(Node
));
2422 Sprint_Indented_List
(Declarations
(Node
));
2423 Write_Indent_Str
("begin");
2424 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2426 Write_Indent_Str
("end ");
2427 Sprint_Node
(Defining_Unit_Name
(Specification
(Node
)));
2430 if Is_List_Member
(Node
)
2431 and then Present
(Next
(Node
))
2432 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
2437 when N_Subprogram_Body_Stub
=>
2439 Sprint_Node_Sloc
(Specification
(Node
));
2440 Write_Str_With_Col_Check
(" is separate;");
2442 when N_Subprogram_Declaration
=>
2444 Sprint_Node_Sloc
(Specification
(Node
));
2446 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
2447 and then Null_Present
(Specification
(Node
))
2449 Write_Str_With_Col_Check
(" is null");
2454 when N_Subprogram_Info
=>
2455 Sprint_Node
(Identifier
(Node
));
2456 Write_Str_With_Col_Check_Sloc
("'subprogram_info");
2458 when N_Subprogram_Renaming_Declaration
=>
2460 Sprint_Node
(Specification
(Node
));
2461 Write_Str_With_Col_Check_Sloc
(" renames ");
2462 Sprint_Node
(Name
(Node
));
2465 when N_Subtype_Declaration
=>
2466 Write_Indent_Str_Sloc
("subtype ");
2467 Write_Id
(Defining_Identifier
(Node
));
2470 -- Ada 2005 (AI-231)
2472 if Null_Exclusion_Present
(Node
) then
2473 Write_Str
("not null ");
2476 Sprint_Node
(Subtype_Indication
(Node
));
2479 when N_Subtype_Indication
=>
2480 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
2482 Sprint_Node
(Constraint
(Node
));
2485 Write_Indent_Str_Sloc
("separate (");
2486 Sprint_Node
(Name
(Node
));
2489 Sprint_Node
(Proper_Body
(Node
));
2492 Write_Indent_Str_Sloc
("task body ");
2493 Write_Id
(Defining_Identifier
(Node
));
2495 Sprint_Indented_List
(Declarations
(Node
));
2496 Write_Indent_Str
("begin");
2497 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2498 Write_Indent_Str
("end ");
2499 Write_Id
(Defining_Identifier
(Node
));
2502 when N_Task_Body_Stub
=>
2503 Write_Indent_Str_Sloc
("task body ");
2504 Write_Id
(Defining_Identifier
(Node
));
2505 Write_Str_With_Col_Check
(" is separate;");
2507 when N_Task_Definition
=>
2509 Sprint_Indented_List
(Visible_Declarations
(Node
));
2511 if Present
(Private_Declarations
(Node
)) then
2512 Write_Indent_Str
("private");
2513 Sprint_Indented_List
(Private_Declarations
(Node
));
2516 Write_Indent_Str
("end ");
2518 when N_Task_Type_Declaration
=>
2519 Write_Indent_Str_Sloc
("task type ");
2520 Write_Id
(Defining_Identifier
(Node
));
2521 Write_Discr_Specs
(Node
);
2523 if Present
(Interface_List
(Node
)) then
2524 Write_Str
(" is new ");
2525 Sprint_And_List
(Interface_List
(Node
));
2528 if Present
(Task_Definition
(Node
)) then
2529 if No
(Interface_List
(Node
)) then
2532 Write_Str
(" with ");
2535 Sprint_Node
(Task_Definition
(Node
));
2536 Write_Id
(Defining_Identifier
(Node
));
2541 when N_Terminate_Alternative
=>
2542 Sprint_Node_List
(Pragmas_Before
(Node
));
2546 if Present
(Condition
(Node
)) then
2547 Write_Str_With_Col_Check
("when ");
2548 Sprint_Node
(Condition
(Node
));
2552 Write_Str_With_Col_Check_Sloc
("terminate;");
2553 Sprint_Node_List
(Pragmas_After
(Node
));
2555 when N_Timed_Entry_Call
=>
2556 Write_Indent_Str_Sloc
("select");
2558 Sprint_Node
(Entry_Call_Alternative
(Node
));
2560 Write_Indent_Str
("or");
2562 Sprint_Node
(Delay_Alternative
(Node
));
2564 Write_Indent_Str
("end select;");
2566 when N_Triggering_Alternative
=>
2567 Sprint_Node_List
(Pragmas_Before
(Node
));
2568 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
2569 Sprint_Node_List
(Statements
(Node
));
2571 when N_Type_Conversion
=>
2573 Sprint_Node
(Subtype_Mark
(Node
));
2576 if Conversion_OK
(Node
) then
2580 if Float_Truncate
(Node
) then
2584 if Rounded_Result
(Node
) then
2589 Sprint_Node
(Expression
(Node
));
2592 when N_Unchecked_Expression
=>
2595 Sprint_Node_Sloc
(Expression
(Node
));
2598 when N_Unchecked_Type_Conversion
=>
2599 Sprint_Node
(Subtype_Mark
(Node
));
2601 Write_Str_With_Col_Check
("(");
2602 Sprint_Node_Sloc
(Expression
(Node
));
2605 when N_Unconstrained_Array_Definition
=>
2606 Write_Str_With_Col_Check_Sloc
("array (");
2612 Node1
:= First
(Subtype_Marks
(Node
));
2614 Sprint_Node
(Node1
);
2615 Write_Str_With_Col_Check
(" range <>");
2617 exit when Node1
= Empty
;
2622 Write_Str
(") of ");
2623 Sprint_Node
(Component_Definition
(Node
));
2625 when N_Unused_At_Start | N_Unused_At_End
=>
2626 Write_Indent_Str
("***** Error, unused node encountered *****");
2629 when N_Use_Package_Clause
=>
2630 Write_Indent_Str_Sloc
("use ");
2631 Sprint_Comma_List
(Names
(Node
));
2634 when N_Use_Type_Clause
=>
2635 Write_Indent_Str_Sloc
("use type ");
2636 Sprint_Comma_List
(Subtype_Marks
(Node
));
2639 when N_Validate_Unchecked_Conversion
=>
2640 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
2641 Sprint_Node
(Source_Type
(Node
));
2643 Sprint_Node
(Target_Type
(Node
));
2647 Write_Indent_Str_Sloc
("when ");
2648 Sprint_Bar_List
(Discrete_Choices
(Node
));
2650 Sprint_Node
(Component_List
(Node
));
2652 when N_Variant_Part
=>
2654 Write_Indent_Str_Sloc
("case ");
2655 Sprint_Node
(Name
(Node
));
2657 Sprint_Indented_List
(Variants
(Node
));
2658 Write_Indent_Str
("end case");
2661 when N_With_Clause
=>
2663 -- Special test, if we are dumping the original tree only,
2664 -- then we want to eliminate the bogus with clauses that
2665 -- correspond to the non-existent children of Text_IO.
2667 if Dump_Original_Only
2668 and then Is_Text_IO_Kludge_Unit
(Name
(Node
))
2672 -- Normal case, output the with clause
2675 if First_Name
(Node
) or else not Dump_Original_Only
then
2677 -- Ada 2005 (AI-50217): Print limited with_clauses
2679 if Private_Present
(Node
) and Limited_Present
(Node
) then
2680 Write_Indent_Str
("limited private with ");
2682 elsif Private_Present
(Node
) then
2683 Write_Indent_Str
("private with ");
2685 elsif Limited_Present
(Node
) then
2686 Write_Indent_Str
("limited with ");
2689 Write_Indent_Str
("with ");
2696 Sprint_Node_Sloc
(Name
(Node
));
2698 if Last_Name
(Node
) or else not Dump_Original_Only
then
2703 when N_With_Type_Clause
=>
2704 Write_Indent_Str
("with type ");
2705 Sprint_Node_Sloc
(Name
(Node
));
2707 if Tagged_Present
(Node
) then
2708 Write_Str
(" is tagged;");
2710 Write_Str
(" is access;");
2715 if Nkind
(Node
) in N_Subexpr
2716 and then Do_Range_Check
(Node
)
2721 for J
in 1 .. Paren_Count
(Node
) loop
2725 pragma Assert
(No
(Debug_Node
));
2726 Debug_Node
:= Save_Debug_Node
;
2727 end Sprint_Node_Actual
;
2729 ----------------------
2730 -- Sprint_Node_List --
2731 ----------------------
2733 procedure Sprint_Node_List
(List
: List_Id
) is
2737 if Is_Non_Empty_List
(List
) then
2738 Node
:= First
(List
);
2743 exit when Node
= Empty
;
2746 end Sprint_Node_List
;
2748 ----------------------
2749 -- Sprint_Node_Sloc --
2750 ----------------------
2752 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
2756 if Present
(Debug_Node
) then
2757 Set_Sloc
(Debug_Node
, Sloc
(Node
));
2758 Debug_Node
:= Empty
;
2760 end Sprint_Node_Sloc
;
2762 ---------------------
2763 -- Sprint_Opt_Node --
2764 ---------------------
2766 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
2768 if Present
(Node
) then
2772 end Sprint_Opt_Node
;
2774 --------------------------
2775 -- Sprint_Opt_Node_List --
2776 --------------------------
2778 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
2780 if Present
(List
) then
2781 Sprint_Node_List
(List
);
2783 end Sprint_Opt_Node_List
;
2785 ---------------------------------
2786 -- Sprint_Opt_Paren_Comma_List --
2787 ---------------------------------
2789 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
2791 if Is_Non_Empty_List
(List
) then
2793 Sprint_Paren_Comma_List
(List
);
2795 end Sprint_Opt_Paren_Comma_List
;
2797 -----------------------------
2798 -- Sprint_Paren_Comma_List --
2799 -----------------------------
2801 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
2803 Node_Exists
: Boolean := False;
2807 if Is_Non_Empty_List
(List
) then
2809 if Dump_Original_Only
then
2812 while Present
(N
) loop
2814 if not Is_Rewrite_Insertion
(N
) then
2815 Node_Exists
:= True;
2822 if not Node_Exists
then
2827 Write_Str_With_Col_Check
("(");
2828 Sprint_Comma_List
(List
);
2831 end Sprint_Paren_Comma_List
;
2833 ----------------------
2834 -- Sprint_Right_Opnd --
2835 ----------------------
2837 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
2838 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
2841 if Paren_Count
(Opnd
) /= 0
2842 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
2851 end Sprint_Right_Opnd
;
2853 ---------------------
2854 -- Write_Char_Sloc --
2855 ---------------------
2857 procedure Write_Char_Sloc
(C
: Character) is
2859 if Debug_Generated_Code
and then C
/= ' ' then
2864 end Write_Char_Sloc
;
2866 --------------------------------
2867 -- Write_Condition_And_Reason --
2868 --------------------------------
2870 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
2871 Image
: constant String := RT_Exception_Code
'Image
2872 (RT_Exception_Code
'Val
2873 (UI_To_Int
(Reason
(Node
))));
2876 if Present
(Condition
(Node
)) then
2877 Write_Str_With_Col_Check
(" when ");
2878 Sprint_Node
(Condition
(Node
));
2883 for J
in 4 .. Image
'Last loop
2884 if Image
(J
) = '_' then
2887 Write_Char
(Fold_Lower
(Image
(J
)));
2892 end Write_Condition_And_Reason
;
2894 -----------------------
2895 -- Write_Discr_Specs --
2896 -----------------------
2898 procedure Write_Discr_Specs
(N
: Node_Id
) is
2903 Specs
:= Discriminant_Specifications
(N
);
2905 if Present
(Specs
) then
2906 Write_Str_With_Col_Check
(" (");
2907 Spec
:= First
(Specs
);
2912 exit when Spec
= Empty
;
2914 -- Add semicolon, unless we are printing original tree and the
2915 -- next specification is part of a list (but not the first
2916 -- element of that list)
2918 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
2925 end Write_Discr_Specs
;
2931 procedure Write_Ekind
(E
: Entity_Id
) is
2932 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
2935 Name_Len
:= S
'Length;
2936 Name_Buffer
(1 .. Name_Len
) := S
;
2937 Set_Casing
(Mixed_Case
);
2938 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2945 procedure Write_Id
(N
: Node_Id
) is
2947 -- Case of a defining identifier
2949 if Nkind
(N
) = N_Defining_Identifier
then
2951 -- If defining identifier has an interface name (and no
2952 -- address clause), then we output the interface name.
2954 if (Is_Imported
(N
) or else Is_Exported
(N
))
2955 and then Present
(Interface_Name
(N
))
2956 and then No
(Address_Clause
(N
))
2958 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
2959 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2961 -- If no interface name (or inactive because there was
2962 -- an address clause), then just output the Chars name.
2965 Write_Name_With_Col_Check
(Chars
(N
));
2968 -- Case of selector of an expanded name where the expanded name
2969 -- has an associated entity, output this entity.
2971 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
2972 and then Selector_Name
(Parent
(N
)) = N
2973 and then Present
(Entity
(Parent
(N
)))
2975 Write_Id
(Entity
(Parent
(N
)));
2977 -- For any other node with an associated entity, output it
2979 elsif Nkind
(N
) in N_Has_Entity
2980 and then Present
(Entity_Or_Associated_Node
(N
))
2981 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
2983 Write_Id
(Entity
(N
));
2985 -- All other cases, we just print the Chars field
2988 Write_Name_With_Col_Check
(Chars
(N
));
2992 -----------------------
2993 -- Write_Identifiers --
2994 -----------------------
2996 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
2998 Sprint_Node
(Defining_Identifier
(Node
));
3000 -- The remainder of the declaration must be printed unless we are
3001 -- printing the original tree and this is not the last identifier
3004 not Dump_Original_Only
or else not More_Ids
(Node
);
3006 end Write_Identifiers
;
3008 ------------------------
3009 -- Write_Implicit_Def --
3010 ------------------------
3012 procedure Write_Implicit_Def
(E
: Entity_Id
) is
3017 when E_Array_Subtype
=>
3018 Write_Str_With_Col_Check
("subtype ");
3020 Write_Str_With_Col_Check
(" is ");
3021 Write_Id
(Base_Type
(E
));
3022 Write_Str_With_Col_Check
(" (");
3024 Ind
:= First_Index
(E
);
3026 while Present
(Ind
) loop
3030 if Present
(Ind
) then
3037 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
3038 Write_Str_With_Col_Check
("subtype ");
3041 Write_Id
(Etype
(E
));
3042 Write_Str_With_Col_Check
(" range ");
3043 Sprint_Node
(Scalar_Range
(E
));
3047 Write_Str_With_Col_Check
("type ");
3049 Write_Str_With_Col_Check
(" is <");
3054 end Write_Implicit_Def
;
3060 procedure Write_Indent
is
3062 if Indent_Annull_Flag
then
3063 Indent_Annull_Flag
:= False;
3067 for J
in 1 .. Indent
loop
3073 ------------------------------
3074 -- Write_Indent_Identifiers --
3075 ------------------------------
3077 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
3079 -- We need to start a new line for every node, except in the case
3080 -- where we are printing the original tree and this is not the first
3081 -- defining identifier in the list.
3083 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3086 -- If printing original tree and this is not the first defining
3087 -- identifier in the list, then the previous call to this procedure
3088 -- printed only the name, and we add a comma to separate the names.
3094 Sprint_Node
(Defining_Identifier
(Node
));
3096 -- The remainder of the declaration must be printed unless we are
3097 -- printing the original tree and this is not the last identifier
3100 not Dump_Original_Only
or else not More_Ids
(Node
);
3102 end Write_Indent_Identifiers
;
3104 -----------------------------------
3105 -- Write_Indent_Identifiers_Sloc --
3106 -----------------------------------
3108 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
3110 -- We need to start a new line for every node, except in the case
3111 -- where we are printing the original tree and this is not the first
3112 -- defining identifier in the list.
3114 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3117 -- If printing original tree and this is not the first defining
3118 -- identifier in the list, then the previous call to this procedure
3119 -- printed only the name, and we add a comma to separate the names.
3126 Sprint_Node
(Defining_Identifier
(Node
));
3128 -- The remainder of the declaration must be printed unless we are
3129 -- printing the original tree and this is not the last identifier
3132 not Dump_Original_Only
or else not More_Ids
(Node
);
3134 end Write_Indent_Identifiers_Sloc
;
3136 ----------------------
3137 -- Write_Indent_Str --
3138 ----------------------
3140 procedure Write_Indent_Str
(S
: String) is
3144 end Write_Indent_Str
;
3146 ---------------------------
3147 -- Write_Indent_Str_Sloc --
3148 ---------------------------
3150 procedure Write_Indent_Str_Sloc
(S
: String) is
3154 end Write_Indent_Str_Sloc
;
3156 -------------------------------
3157 -- Write_Name_With_Col_Check --
3158 -------------------------------
3160 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
3164 Get_Name_String
(N
);
3166 -- Deal with -gnatI which replaces digits in an internal
3167 -- name by three dots (e.g. R7b becomes R...b).
3169 if Debug_Flag_II
and then Name_Buffer
(1) in 'A' .. 'Z' then
3172 while J
< Name_Len
loop
3173 exit when Name_Buffer
(J
) not in 'A' .. 'Z';
3177 if Name_Buffer
(J
) in '0' .. '9' then
3178 Write_Str_With_Col_Check
(Name_Buffer
(1 .. J
- 1));
3181 while J
<= Name_Len
loop
3182 if Name_Buffer
(J
) not in '0' .. '9' then
3183 Write_Str
(Name_Buffer
(J
.. Name_Len
));
3195 -- Fall through for normal case
3197 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3198 end Write_Name_With_Col_Check
;
3200 ------------------------------------
3201 -- Write_Name_With_Col_Check_Sloc --
3202 ------------------------------------
3204 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
3206 Get_Name_String
(N
);
3207 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
3208 end Write_Name_With_Col_Check_Sloc
;
3210 --------------------
3211 -- Write_Operator --
3212 --------------------
3214 procedure Write_Operator
(N
: Node_Id
; S
: String) is
3215 F
: Natural := S
'First;
3216 T
: Natural := S
'Last;
3219 -- If no overflow check, just write string out, and we are done
3221 if not Do_Overflow_Check
(N
) then
3224 -- If overflow check, we want to surround the operator with curly
3225 -- brackets, but not include spaces within the brackets.
3238 Write_Str_Sloc
(S
(F
.. T
));
3241 if S
(S
'Last) = ' ' then
3247 -----------------------
3248 -- Write_Param_Specs --
3249 -----------------------
3251 procedure Write_Param_Specs
(N
: Node_Id
) is
3257 Specs
:= Parameter_Specifications
(N
);
3259 if Is_Non_Empty_List
(Specs
) then
3260 Write_Str_With_Col_Check
(" (");
3261 Spec
:= First
(Specs
);
3265 Formal
:= Defining_Identifier
(Spec
);
3267 exit when Spec
= Empty
;
3269 -- Add semicolon, unless we are printing original tree and the
3270 -- next specification is part of a list (but not the first
3271 -- element of that list)
3273 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3278 -- Write out any extra formals
3280 while Present
(Extra_Formal
(Formal
)) loop
3281 Formal
:= Extra_Formal
(Formal
);
3283 Write_Name_With_Col_Check
(Chars
(Formal
));
3285 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
3290 end Write_Param_Specs
;
3292 --------------------------
3293 -- Write_Rewrite_Str --
3294 --------------------------
3296 procedure Write_Rewrite_Str
(S
: String) is
3298 if not Dump_Generated_Only
then
3299 if S
'Length = 3 and then S
= ">>>" then
3302 Write_Str_With_Col_Check
(S
);
3305 end Write_Rewrite_Str
;
3307 --------------------
3308 -- Write_Str_Sloc --
3309 --------------------
3311 procedure Write_Str_Sloc
(S
: String) is
3313 for J
in S
'Range loop
3314 Write_Char_Sloc
(S
(J
));
3318 ------------------------------
3319 -- Write_Str_With_Col_Check --
3320 ------------------------------
3322 procedure Write_Str_With_Col_Check
(S
: String) is
3324 if Int
(S
'Last) + Column
> Line_Limit
then
3325 Write_Indent_Str
(" ");
3328 Write_Str
(S
(2 .. S
'Length));
3336 end Write_Str_With_Col_Check
;
3338 -----------------------------------
3339 -- Write_Str_With_Col_Check_Sloc --
3340 -----------------------------------
3342 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
3344 if Int
(S
'Last) + Column
> Line_Limit
then
3345 Write_Indent_Str
(" ");
3348 Write_Str_Sloc
(S
(2 .. S
'Length));
3356 end Write_Str_With_Col_Check_Sloc
;
3358 ------------------------------------
3359 -- Write_Uint_With_Col_Check_Sloc --
3360 ------------------------------------
3362 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
3364 Col_Check
(UI_Decimal_Digits_Hi
(U
));
3366 UI_Write
(U
, Format
);
3367 end Write_Uint_With_Col_Check_Sloc
;
3369 -------------------------------------
3370 -- Write_Ureal_With_Col_Check_Sloc --
3371 -------------------------------------
3373 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
3374 D
: constant Uint
:= Denominator
(U
);
3375 N
: constant Uint
:= Numerator
(U
);
3379 (UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
3382 end Write_Ureal_With_Col_Check_Sloc
;