1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2002, Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 with Atree
; use Atree
;
29 with Casing
; use Casing
;
30 with Csets
; use Csets
;
31 with Debug
; use Debug
;
32 with Einfo
; use Einfo
;
34 with Namet
; use Namet
;
35 with Nlists
; use Nlists
;
37 with Output
; use Output
;
38 with Rtsfind
; use Rtsfind
;
39 with Sinfo
; use Sinfo
;
40 with Sinput
; use Sinput
;
41 with Sinput
.D
; use Sinput
.D
;
42 with Snames
; use Snames
;
43 with Stand
; use Stand
;
44 with Stringt
; use Stringt
;
45 with Uintp
; use Uintp
;
46 with Uname
; use Uname
;
47 with Urealp
; use Urealp
;
49 package body Sprint
is
51 Debug_Node
: Node_Id
:= Empty
;
52 -- If we are in Debug_Generated_Code mode, then this location is set
53 -- to the current node requiring Sloc fixup, until Set_Debug_Sloc is
54 -- called to set the proper value. The call clears it back to Empty.
56 Debug_Sloc
: Source_Ptr
;
57 -- Sloc of first byte of line currently being written if we are
58 -- generating a source debug file.
60 Dump_Original_Only
: Boolean;
61 -- Set True if the -gnatdo (dump original tree) flag is set
63 Dump_Generated_Only
: Boolean;
64 -- Set True if the -gnatG (dump generated tree) debug flag is set
65 -- or for Print_Generated_Code (-gnatG) or Dump_Gnerated_Code (-gnatD).
67 Dump_Freeze_Null
: Boolean;
68 -- Set True if freeze nodes and non-source null statements output
71 -- Number of columns for current line output indentation
73 Indent_Annull_Flag
: Boolean := False;
74 -- Set True if subsequent Write_Indent call to be ignored, gets reset
75 -- by this call, so it is only active to suppress a single indent call.
77 Line_Limit
: constant := 72;
78 -- Limit value for chopping long lines
80 Freeze_Indent
: Int
:= 0;
81 -- Keep track of freeze indent level (controls blank lines before
82 -- procedures within expression freeze actions)
84 -------------------------------
85 -- Operator Precedence Table --
86 -------------------------------
88 -- This table is used to decide whether a subexpression needs to be
89 -- parenthesized. The rule is that if an operand of an operator (which
90 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
91 -- with a lower precedence than the operator (or equal precedence if
92 -- appearing as the right operand), then parentheses are required.
94 Op_Prec
: array (N_Subexpr
) of Short_Short_Integer :=
127 procedure Sprint_Left_Opnd
(N
: Node_Id
);
128 -- Print left operand of operator, parenthesizing if necessary
130 procedure Sprint_Right_Opnd
(N
: Node_Id
);
131 -- Print right operand of operator, parenthesizing if necessary
133 -----------------------
134 -- Local Subprograms --
135 -----------------------
137 procedure Col_Check
(N
: Nat
);
138 -- Check that at least N characters remain on current line, and if not,
139 -- then start an extra line with two characters extra indentation for
140 -- continuing text on the next line.
142 procedure Indent_Annull
;
143 -- Causes following call to Write_Indent to be ignored. This is used when
144 -- a higher level node wants to stop a lower level node from starting a
145 -- new line, when it would otherwise be inclined to do so (e.g. the case
146 -- of an accept statement called from an accept alternative with a guard)
148 procedure Indent_Begin
;
149 -- Increase indentation level
151 procedure Indent_End
;
152 -- Decrease indentation level
154 procedure Print_Debug_Line
(S
: String);
155 -- Used to print output lines in Debug_Generated_Code mode (this is used
156 -- as the argument for a call to Set_Special_Output in package Output).
158 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
);
159 -- Given a divide, multiplication or division node, check the flags
160 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
161 -- appropriate special syntax characters (# and @).
163 procedure Set_Debug_Sloc
;
164 -- If Debug_Node is non-empty, this routine sets the appropriate value
165 -- in its Sloc field, from the current location in the debug source file
166 -- that is currently being written. Note that Debug_Node is always empty
167 -- if a debug source file is not being written.
169 procedure Sprint_Bar_List
(List
: List_Id
);
170 -- Print the given list with items separated by vertical bars
172 procedure Sprint_Node_Actual
(Node
: Node_Id
);
173 -- This routine prints its node argument. It is a lower level routine than
174 -- Sprint_Node, in that it does not bother about rewritten trees.
176 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
177 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
178 -- sets the Sloc of the current debug node to be a copy of the Sloc
179 -- of the sprinted node Node. Note that this is done after printing
180 -- Node, so that the Sloc is the proper updated value for the debug file.
182 procedure Write_Char_Sloc
(C
: Character);
183 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
184 -- called to ensure that the current node has a proper Sloc set.
186 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
187 -- Write Condition and Reason codes of Raise_xxx_Error node
189 procedure Write_Discr_Specs
(N
: Node_Id
);
190 -- Output discriminant specification for node, which is any of the type
191 -- declarations that can have discriminants.
193 procedure Write_Ekind
(E
: Entity_Id
);
194 -- Write the String corresponding to the Ekind without "E_".
196 procedure Write_Id
(N
: Node_Id
);
197 -- N is a node with a Chars field. This procedure writes the name that
198 -- will be used in the generated code associated with the name. For a
199 -- node with no associated entity, this is simply the Chars field. For
200 -- the case where there is an entity associated with the node, we print
201 -- the name associated with the entity (since it may have been encoded).
202 -- One other special case is that an entity has an active external name
203 -- (i.e. an external name present with no address clause), then this
204 -- external name is output.
206 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
207 -- Handle node where the grammar has a list of defining identifiers, but
208 -- the tree has a separate declaration for each identifier. Handles the
209 -- printing of the defining identifier, and returns True if the type and
210 -- initialization information is to be printed, False if it is to be
211 -- skipped (the latter case happens when printing defining identifiers
212 -- other than the first in the original tree output case).
214 procedure Write_Implicit_Def
(E
: Entity_Id
);
215 pragma Warnings
(Off
, Write_Implicit_Def
);
216 -- Write the definition of the implicit type E according to its Ekind
217 -- For now a debugging procedure, but might be used in the future.
219 procedure Write_Indent
;
220 -- Start a new line and write indentation spacing
222 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
223 -- Like Write_Identifiers except that each new printed declaration
224 -- is at the start of a new line.
226 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
227 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
228 -- mode, the Sloc of the current debug node is set to point ot the
229 -- first output identifier.
231 procedure Write_Indent_Str
(S
: String);
232 -- Start a new line and write indent spacing followed by given string
234 procedure Write_Indent_Str_Sloc
(S
: String);
235 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
236 -- the Sloc of the current node is set to the first non-blank character
239 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
240 -- Write name (using Write_Name) with initial column check, and possible
241 -- initial Write_Indent (to get new line) if current line is too full.
243 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
244 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
245 -- mode, sets Sloc of current debug node to first character of name.
247 procedure Write_Operator
(N
: Node_Id
; S
: String);
248 -- Like Write_Str_Sloc, used for operators, encloses the string in
249 -- characters {} if the Do_Overflow flag is set on the node N.
251 procedure Write_Param_Specs
(N
: Node_Id
);
252 -- Output parameter specifications for node (which is either a function
253 -- or procedure specification with a Parameter_Specifications field)
255 procedure Write_Rewrite_Str
(S
: String);
256 -- Writes out a string (typically containing <<< or >>>}) for a node
257 -- created by rewriting the tree. Suppressed if we are outputting the
258 -- generated code only, since in this case we don't specially mark nodes
259 -- created by rewriting).
261 procedure Write_Str_Sloc
(S
: String);
262 -- Like Write_Str, but sets debug Sloc of current debug node to first
263 -- non-blank character if a current debug node is active.
265 procedure Write_Str_With_Col_Check
(S
: String);
266 -- Write string (using Write_Str) with initial column check, and possible
267 -- initial Write_Indent (to get new line) if current line is too full.
269 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
270 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
271 -- node to first non-blank character if a current debug node is active.
273 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
274 -- Write Uint (using UI_Write) with initial column check, and possible
275 -- initial Write_Indent (to get new line) if current line is too full.
276 -- The format parameter determines the output format (see UI_Write).
277 -- In addition, in Debug_Generated_Code mode, sets the current node
278 -- Sloc to the first character of the output value.
280 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
281 -- Write Ureal (using same output format as UR_Write) with column checks
282 -- and a possible initial Write_Indent (to get new line) if current line
283 -- is too full. In addition, in Debug_Generated_Code mode, sets the
284 -- current node Sloc to the first character of the output value.
290 procedure Col_Check
(N
: Nat
) is
292 if N
+ Column
> Line_Limit
then
293 Write_Indent_Str
(" ");
301 procedure Indent_Annull
is
303 Indent_Annull_Flag
:= True;
310 procedure Indent_Begin
is
312 Indent
:= Indent
+ 3;
319 procedure Indent_End
is
321 Indent
:= Indent
- 3;
328 procedure pg
(Node
: Node_Id
) is
330 Dump_Generated_Only
:= True;
331 Dump_Original_Only
:= False;
340 procedure po
(Node
: Node_Id
) is
342 Dump_Generated_Only
:= False;
343 Dump_Original_Only
:= True;
348 ----------------------
349 -- Print_Debug_Line --
350 ----------------------
352 procedure Print_Debug_Line
(S
: String) is
354 Write_Debug_Line
(S
, Debug_Sloc
);
355 end Print_Debug_Line
;
357 ---------------------------
358 -- Process_TFAI_RR_Flags --
359 ---------------------------
361 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
363 if Treat_Fixed_As_Integer
(Nod
) then
367 if Rounded_Result
(Nod
) then
370 end Process_TFAI_RR_Flags
;
376 procedure ps
(Node
: Node_Id
) is
378 Dump_Generated_Only
:= False;
379 Dump_Original_Only
:= False;
388 procedure Set_Debug_Sloc
is
390 if Present
(Debug_Node
) then
391 Set_Sloc
(Debug_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
400 procedure Source_Dump
is
403 -- Put underline under string we just printed
405 procedure Underline
is
406 Col
: constant Int
:= Column
;
411 while Col
> Column
loop
418 -- Start of processing for Tree_Dump.
421 Dump_Generated_Only
:= Debug_Flag_G
or
422 Print_Generated_Code
or
423 Debug_Generated_Code
;
424 Dump_Original_Only
:= Debug_Flag_O
;
425 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
427 -- Note that we turn off the tree dump flags immediately, before
428 -- starting the dump. This avoids generating two copies of the dump
429 -- if an abort occurs after printing the dump, and more importantly,
430 -- avoids an infinite loop if an abort occurs during the dump.
433 Debug_Flag_Z
:= False;
436 Write_Str
("Source recreated from tree of Standard (spec)");
438 Sprint_Node
(Standard_Package_Node
);
443 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
444 Debug_Flag_G
:= False;
445 Debug_Flag_O
:= False;
446 Debug_Flag_S
:= False;
448 -- Dump requested units
450 for U
in Main_Unit
.. Last_Unit
loop
452 -- Dump all units if -gnatdf set, otherwise we dump only
453 -- the source files that are in the extended main source.
456 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
458 -- If we are generating debug files, setup to write them
460 if Debug_Generated_Code
then
461 Set_Special_Output
(Print_Debug_Line
'Access);
462 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
463 Sprint_Node
(Cunit
(U
));
466 Set_Special_Output
(null);
468 -- Normal output to standard output file
471 Write_Str
("Source recreated from tree for ");
472 Write_Unit_Name
(Unit_Name
(U
));
474 Sprint_Node
(Cunit
(U
));
483 ---------------------
484 -- Sprint_Bar_List --
485 ---------------------
487 procedure Sprint_Bar_List
(List
: List_Id
) is
491 if Is_Non_Empty_List
(List
) then
492 Node
:= First
(List
);
497 exit when Node
= Empty
;
503 -----------------------
504 -- Sprint_Comma_List --
505 -----------------------
507 procedure Sprint_Comma_List
(List
: List_Id
) is
511 if Is_Non_Empty_List
(List
) then
512 Node
:= First
(List
);
517 exit when Node
= Empty
;
519 if not Is_Rewrite_Insertion
(Node
)
520 or else not Dump_Original_Only
527 end Sprint_Comma_List
;
529 --------------------------
530 -- Sprint_Indented_List --
531 --------------------------
533 procedure Sprint_Indented_List
(List
: List_Id
) is
536 Sprint_Node_List
(List
);
538 end Sprint_Indented_List
;
540 ---------------------
541 -- Sprint_Left_Opnd --
542 ---------------------
544 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
545 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
548 if Paren_Count
(Opnd
) /= 0
549 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
558 end Sprint_Left_Opnd
;
564 procedure Sprint_Node
(Node
: Node_Id
) is
566 if Is_Rewrite_Insertion
(Node
) then
567 if not Dump_Original_Only
then
569 -- For special cases of nodes that always output <<< >>>
570 -- do not duplicate the output at this point.
572 if Nkind
(Node
) = N_Freeze_Entity
573 or else Nkind
(Node
) = N_Implicit_Label_Declaration
575 Sprint_Node_Actual
(Node
);
577 -- Normal case where <<< >>> may be required
580 Write_Rewrite_Str
("<<<");
581 Sprint_Node_Actual
(Node
);
582 Write_Rewrite_Str
(">>>");
586 elsif Is_Rewrite_Substitution
(Node
) then
588 -- Case of dump generated only
590 if Dump_Generated_Only
then
591 Sprint_Node_Actual
(Node
);
593 -- Case of dump original only
595 elsif Dump_Original_Only
then
596 Sprint_Node_Actual
(Original_Node
(Node
));
598 -- Case of both being dumped
601 Sprint_Node_Actual
(Original_Node
(Node
));
602 Write_Rewrite_Str
("<<<");
603 Sprint_Node_Actual
(Node
);
604 Write_Rewrite_Str
(">>>");
608 Sprint_Node_Actual
(Node
);
612 ------------------------
613 -- Sprint_Node_Actual --
614 ------------------------
616 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
617 Save_Debug_Node
: constant Node_Id
:= Debug_Node
;
624 for J
in 1 .. Paren_Count
(Node
) loop
625 Write_Str_With_Col_Check
("(");
628 -- Setup node for Sloc fixup if writing a debug source file. Note
629 -- that we take care of any previous node not yet properly set.
631 if Debug_Generated_Code
then
635 if Nkind
(Node
) in N_Subexpr
636 and then Do_Range_Check
(Node
)
638 Write_Str_With_Col_Check
("{");
641 -- Select print circuit based on node kind
645 when N_Abort_Statement
=>
646 Write_Indent_Str_Sloc
("abort ");
647 Sprint_Comma_List
(Names
(Node
));
650 when N_Abortable_Part
=>
652 Write_Str_Sloc
("abort ");
653 Sprint_Indented_List
(Statements
(Node
));
655 when N_Abstract_Subprogram_Declaration
=>
657 Sprint_Node
(Specification
(Node
));
658 Write_Str_With_Col_Check
(" is ");
659 Write_Str_Sloc
("abstract;");
661 when N_Accept_Alternative
=>
662 Sprint_Node_List
(Pragmas_Before
(Node
));
664 if Present
(Condition
(Node
)) then
665 Write_Indent_Str
("when ");
666 Sprint_Node
(Condition
(Node
));
671 Sprint_Node_Sloc
(Accept_Statement
(Node
));
672 Sprint_Node_List
(Statements
(Node
));
674 when N_Accept_Statement
=>
675 Write_Indent_Str_Sloc
("accept ");
676 Write_Id
(Entry_Direct_Name
(Node
));
678 if Present
(Entry_Index
(Node
)) then
679 Write_Str_With_Col_Check
(" (");
680 Sprint_Node
(Entry_Index
(Node
));
684 Write_Param_Specs
(Node
);
686 if Present
(Handled_Statement_Sequence
(Node
)) then
687 Write_Str_With_Col_Check
(" do");
688 Sprint_Node
(Handled_Statement_Sequence
(Node
));
689 Write_Indent_Str
("end ");
690 Write_Id
(Entry_Direct_Name
(Node
));
695 when N_Access_Definition
=>
696 Write_Str_With_Col_Check_Sloc
("access ");
697 Sprint_Node
(Subtype_Mark
(Node
));
699 when N_Access_Function_Definition
=>
700 Write_Str_With_Col_Check_Sloc
("access ");
702 if Protected_Present
(Node
) then
703 Write_Str_With_Col_Check
("protected ");
706 Write_Str_With_Col_Check
("function");
707 Write_Param_Specs
(Node
);
708 Write_Str_With_Col_Check
(" return ");
709 Sprint_Node
(Subtype_Mark
(Node
));
711 when N_Access_Procedure_Definition
=>
712 Write_Str_With_Col_Check_Sloc
("access ");
714 if Protected_Present
(Node
) then
715 Write_Str_With_Col_Check
("protected ");
718 Write_Str_With_Col_Check
("procedure");
719 Write_Param_Specs
(Node
);
721 when N_Access_To_Object_Definition
=>
722 Write_Str_With_Col_Check_Sloc
("access ");
724 if All_Present
(Node
) then
725 Write_Str_With_Col_Check
("all ");
726 elsif Constant_Present
(Node
) then
727 Write_Str_With_Col_Check
("constant ");
730 Sprint_Node
(Subtype_Indication
(Node
));
733 if Null_Record_Present
(Node
) then
734 Write_Str_With_Col_Check_Sloc
("(null record)");
737 Write_Str_With_Col_Check_Sloc
("(");
739 if Present
(Expressions
(Node
)) then
740 Sprint_Comma_List
(Expressions
(Node
));
742 if Present
(Component_Associations
(Node
)) then
747 if Present
(Component_Associations
(Node
)) then
754 Nd
:= First
(Component_Associations
(Node
));
762 if not Is_Rewrite_Insertion
(Nd
)
763 or else not Dump_Original_Only
777 Write_Str_With_Col_Check_Sloc
("new ");
778 Sprint_Node
(Expression
(Node
));
780 if Present
(Storage_Pool
(Node
)) then
781 Write_Str_With_Col_Check
("[storage_pool = ");
782 Sprint_Node
(Storage_Pool
(Node
));
787 Sprint_Left_Opnd
(Node
);
788 Write_Str_Sloc
(" and then ");
789 Sprint_Right_Opnd
(Node
);
792 Write_Indent_Str_Sloc
("for ");
793 Write_Id
(Identifier
(Node
));
794 Write_Str_With_Col_Check
(" use at ");
795 Sprint_Node
(Expression
(Node
));
798 when N_Assignment_Statement
=>
800 Sprint_Node
(Name
(Node
));
801 Write_Str_Sloc
(" := ");
802 Sprint_Node
(Expression
(Node
));
805 when N_Asynchronous_Select
=>
806 Write_Indent_Str_Sloc
("select");
808 Sprint_Node
(Triggering_Alternative
(Node
));
811 -- Note: let the printing of Abortable_Part handle outputting
812 -- the ABORT keyword, so that the Slco can be set correctly.
814 Write_Indent_Str
("then ");
815 Sprint_Node
(Abortable_Part
(Node
));
816 Write_Indent_Str
("end select;");
818 when N_Attribute_Definition_Clause
=>
819 Write_Indent_Str_Sloc
("for ");
820 Sprint_Node
(Name
(Node
));
822 Write_Name_With_Col_Check
(Chars
(Node
));
823 Write_Str_With_Col_Check
(" use ");
824 Sprint_Node
(Expression
(Node
));
827 when N_Attribute_Reference
=>
828 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
832 Sprint_Node
(Prefix
(Node
));
833 Write_Char_Sloc
(''');
834 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
835 Sprint_Paren_Comma_List
(Expressions
(Node
));
837 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
841 when N_Block_Statement
=>
844 if Present
(Identifier
(Node
))
845 and then (not Has_Created_Identifier
(Node
)
846 or else not Dump_Original_Only
)
848 Write_Rewrite_Str
("<<<");
849 Write_Id
(Identifier
(Node
));
851 Write_Rewrite_Str
(">>>");
854 if Present
(Declarations
(Node
)) then
855 Write_Str_With_Col_Check_Sloc
("declare");
856 Sprint_Indented_List
(Declarations
(Node
));
860 Write_Str_With_Col_Check_Sloc
("begin");
861 Sprint_Node
(Handled_Statement_Sequence
(Node
));
862 Write_Indent_Str
("end");
864 if Present
(Identifier
(Node
))
865 and then (not Has_Created_Identifier
(Node
)
866 or else not Dump_Original_Only
)
868 Write_Rewrite_Str
("<<<");
870 Write_Id
(Identifier
(Node
));
871 Write_Rewrite_Str
(">>>");
876 when N_Case_Statement
=>
877 Write_Indent_Str_Sloc
("case ");
878 Sprint_Node
(Expression
(Node
));
880 Sprint_Indented_List
(Alternatives
(Node
));
881 Write_Indent_Str
("end case;");
883 when N_Case_Statement_Alternative
=>
884 Write_Indent_Str_Sloc
("when ");
885 Sprint_Bar_List
(Discrete_Choices
(Node
));
887 Sprint_Indented_List
(Statements
(Node
));
889 when N_Character_Literal
=>
891 Write_Indent_Str
(" ");
894 Write_Char_Sloc
(''');
895 Write_Char_Code
(Char_Literal_Value
(Node
));
898 when N_Code_Statement
=>
901 Sprint_Node
(Expression
(Node
));
904 when N_Compilation_Unit
=>
905 Sprint_Node_List
(Context_Items
(Node
));
906 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
908 if Private_Present
(Node
) then
909 Write_Indent_Str
("private ");
913 Sprint_Node_Sloc
(Unit
(Node
));
915 if Present
(Actions
(Aux_Decls_Node
(Node
)))
917 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
922 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
923 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
925 when N_Compilation_Unit_Aux
=>
926 null; -- nothing to do, never used, see above
928 when N_Component_Association
=>
930 Sprint_Bar_List
(Choices
(Node
));
932 Sprint_Node
(Expression
(Node
));
934 when N_Component_Clause
=>
936 Sprint_Node
(Component_Name
(Node
));
937 Write_Str_Sloc
(" at ");
938 Sprint_Node
(Position
(Node
));
940 Write_Str_With_Col_Check
("range ");
941 Sprint_Node
(First_Bit
(Node
));
943 Sprint_Node
(Last_Bit
(Node
));
946 when N_Component_Declaration
=>
947 if Write_Indent_Identifiers_Sloc
(Node
) then
950 if Aliased_Present
(Node
) then
951 Write_Str_With_Col_Check
("aliased ");
954 Sprint_Node
(Subtype_Indication
(Node
));
956 if Present
(Expression
(Node
)) then
958 Sprint_Node
(Expression
(Node
));
964 when N_Component_List
=>
965 if Null_Present
(Node
) then
967 Write_Indent_Str_Sloc
("null");
973 Sprint_Indented_List
(Component_Items
(Node
));
974 Sprint_Node
(Variant_Part
(Node
));
977 when N_Conditional_Entry_Call
=>
978 Write_Indent_Str_Sloc
("select");
980 Sprint_Node
(Entry_Call_Alternative
(Node
));
982 Write_Indent_Str
("else");
983 Sprint_Indented_List
(Else_Statements
(Node
));
984 Write_Indent_Str
("end select;");
986 when N_Conditional_Expression
=>
988 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
989 Then_Expr
: constant Node_Id
:= Next
(Condition
);
990 Else_Expr
: constant Node_Id
:= Next
(Then_Expr
);
993 Write_Str_With_Col_Check_Sloc
("(if ");
994 Sprint_Node
(Condition
);
995 Write_Str_With_Col_Check
(" then ");
996 Sprint_Node
(Then_Expr
);
997 Write_Str_With_Col_Check
(" else ");
998 Sprint_Node
(Else_Expr
);
1002 when N_Constrained_Array_Definition
=>
1003 Write_Str_With_Col_Check_Sloc
("array ");
1004 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1007 if Aliased_Present
(Node
) then
1008 Write_Str_With_Col_Check
("aliased ");
1011 Sprint_Node
(Subtype_Indication
(Node
));
1013 when N_Decimal_Fixed_Point_Definition
=>
1014 Write_Str_With_Col_Check_Sloc
(" delta ");
1015 Sprint_Node
(Delta_Expression
(Node
));
1016 Write_Str_With_Col_Check
("digits ");
1017 Sprint_Node
(Digits_Expression
(Node
));
1018 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1020 when N_Defining_Character_Literal
=>
1021 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1023 when N_Defining_Identifier
=>
1027 when N_Defining_Operator_Symbol
=>
1028 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1030 when N_Defining_Program_Unit_Name
=>
1032 Sprint_Node
(Name
(Node
));
1034 Write_Id
(Defining_Identifier
(Node
));
1036 when N_Delay_Alternative
=>
1037 Sprint_Node_List
(Pragmas_Before
(Node
));
1039 if Present
(Condition
(Node
)) then
1041 Write_Str_With_Col_Check
("when ");
1042 Sprint_Node
(Condition
(Node
));
1047 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1048 Sprint_Node_List
(Statements
(Node
));
1050 when N_Delay_Relative_Statement
=>
1051 Write_Indent_Str_Sloc
("delay ");
1052 Sprint_Node
(Expression
(Node
));
1055 when N_Delay_Until_Statement
=>
1056 Write_Indent_Str_Sloc
("delay until ");
1057 Sprint_Node
(Expression
(Node
));
1060 when N_Delta_Constraint
=>
1061 Write_Str_With_Col_Check_Sloc
("delta ");
1062 Sprint_Node
(Delta_Expression
(Node
));
1063 Sprint_Opt_Node
(Range_Constraint
(Node
));
1065 when N_Derived_Type_Definition
=>
1066 if Abstract_Present
(Node
) then
1067 Write_Str_With_Col_Check
("abstract ");
1070 Write_Str_With_Col_Check_Sloc
("new ");
1071 Sprint_Node
(Subtype_Indication
(Node
));
1073 if Present
(Record_Extension_Part
(Node
)) then
1074 Write_Str_With_Col_Check
(" with ");
1075 Sprint_Node
(Record_Extension_Part
(Node
));
1078 when N_Designator
=>
1079 Sprint_Node
(Name
(Node
));
1080 Write_Char_Sloc
('.');
1081 Write_Id
(Identifier
(Node
));
1083 when N_Digits_Constraint
=>
1084 Write_Str_With_Col_Check_Sloc
("digits ");
1085 Sprint_Node
(Digits_Expression
(Node
));
1086 Sprint_Opt_Node
(Range_Constraint
(Node
));
1088 when N_Discriminant_Association
=>
1091 if Present
(Selector_Names
(Node
)) then
1092 Sprint_Bar_List
(Selector_Names
(Node
));
1097 Sprint_Node
(Expression
(Node
));
1099 when N_Discriminant_Specification
=>
1102 if Write_Identifiers
(Node
) then
1104 Sprint_Node
(Discriminant_Type
(Node
));
1106 if Present
(Expression
(Node
)) then
1108 Sprint_Node
(Expression
(Node
));
1114 when N_Elsif_Part
=>
1115 Write_Indent_Str_Sloc
("elsif ");
1116 Sprint_Node
(Condition
(Node
));
1117 Write_Str_With_Col_Check
(" then");
1118 Sprint_Indented_List
(Then_Statements
(Node
));
1123 when N_Entry_Body
=>
1124 Write_Indent_Str_Sloc
("entry ");
1125 Write_Id
(Defining_Identifier
(Node
));
1126 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1127 Write_Str_With_Col_Check
(" is");
1128 Sprint_Indented_List
(Declarations
(Node
));
1129 Write_Indent_Str
("begin");
1130 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1131 Write_Indent_Str
("end ");
1132 Write_Id
(Defining_Identifier
(Node
));
1135 when N_Entry_Body_Formal_Part
=>
1136 if Present
(Entry_Index_Specification
(Node
)) then
1137 Write_Str_With_Col_Check_Sloc
(" (");
1138 Sprint_Node
(Entry_Index_Specification
(Node
));
1142 Write_Param_Specs
(Node
);
1143 Write_Str_With_Col_Check_Sloc
(" when ");
1144 Sprint_Node
(Condition
(Node
));
1146 when N_Entry_Call_Alternative
=>
1147 Sprint_Node_List
(Pragmas_Before
(Node
));
1148 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1149 Sprint_Node_List
(Statements
(Node
));
1151 when N_Entry_Call_Statement
=>
1153 Sprint_Node_Sloc
(Name
(Node
));
1154 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1157 when N_Entry_Declaration
=>
1158 Write_Indent_Str_Sloc
("entry ");
1159 Write_Id
(Defining_Identifier
(Node
));
1161 if Present
(Discrete_Subtype_Definition
(Node
)) then
1162 Write_Str_With_Col_Check
(" (");
1163 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1167 Write_Param_Specs
(Node
);
1170 when N_Entry_Index_Specification
=>
1171 Write_Str_With_Col_Check_Sloc
("for ");
1172 Write_Id
(Defining_Identifier
(Node
));
1173 Write_Str_With_Col_Check
(" in ");
1174 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1176 when N_Enumeration_Representation_Clause
=>
1177 Write_Indent_Str_Sloc
("for ");
1178 Write_Id
(Identifier
(Node
));
1179 Write_Str_With_Col_Check
(" use ");
1180 Sprint_Node
(Array_Aggregate
(Node
));
1183 when N_Enumeration_Type_Definition
=>
1186 -- Skip attempt to print Literals field if it's not there and
1187 -- we are in package Standard (case of Character, which is
1188 -- handled specially (without an explicit literals list).
1190 if Sloc
(Node
) > Standard_Location
1191 or else Present
(Literals
(Node
))
1193 Sprint_Paren_Comma_List
(Literals
(Node
));
1197 Write_Str_With_Col_Check_Sloc
("<error>");
1199 when N_Exception_Declaration
=>
1200 if Write_Indent_Identifiers
(Node
) then
1201 Write_Str_With_Col_Check
(" : ");
1202 Write_Str_Sloc
("exception;");
1205 when N_Exception_Handler
=>
1206 Write_Indent_Str_Sloc
("when ");
1208 if Present
(Choice_Parameter
(Node
)) then
1209 Sprint_Node
(Choice_Parameter
(Node
));
1213 Sprint_Bar_List
(Exception_Choices
(Node
));
1215 Sprint_Indented_List
(Statements
(Node
));
1217 when N_Exception_Renaming_Declaration
=>
1220 Sprint_Node
(Defining_Identifier
(Node
));
1221 Write_Str_With_Col_Check
(" : exception renames ");
1222 Sprint_Node
(Name
(Node
));
1225 when N_Exit_Statement
=>
1226 Write_Indent_Str_Sloc
("exit");
1227 Sprint_Opt_Node
(Name
(Node
));
1229 if Present
(Condition
(Node
)) then
1230 Write_Str_With_Col_Check
(" when ");
1231 Sprint_Node
(Condition
(Node
));
1236 when N_Explicit_Dereference
=>
1237 Sprint_Node
(Prefix
(Node
));
1239 Write_Str_Sloc
("all");
1241 when N_Extension_Aggregate
=>
1242 Write_Str_With_Col_Check_Sloc
("(");
1243 Sprint_Node
(Ancestor_Part
(Node
));
1244 Write_Str_With_Col_Check
(" with ");
1246 if Null_Record_Present
(Node
) then
1247 Write_Str_With_Col_Check
("null record");
1249 if Present
(Expressions
(Node
)) then
1250 Sprint_Comma_List
(Expressions
(Node
));
1252 if Present
(Component_Associations
(Node
)) then
1257 if Present
(Component_Associations
(Node
)) then
1258 Sprint_Comma_List
(Component_Associations
(Node
));
1264 when N_Floating_Point_Definition
=>
1265 Write_Str_With_Col_Check_Sloc
("digits ");
1266 Sprint_Node
(Digits_Expression
(Node
));
1267 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1269 when N_Formal_Decimal_Fixed_Point_Definition
=>
1270 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1272 when N_Formal_Derived_Type_Definition
=>
1273 Write_Str_With_Col_Check_Sloc
("new ");
1274 Sprint_Node
(Subtype_Mark
(Node
));
1276 if Private_Present
(Node
) then
1277 Write_Str_With_Col_Check
(" with private");
1280 when N_Formal_Discrete_Type_Definition
=>
1281 Write_Str_With_Col_Check_Sloc
("<>");
1283 when N_Formal_Floating_Point_Definition
=>
1284 Write_Str_With_Col_Check_Sloc
("digits <>");
1286 when N_Formal_Modular_Type_Definition
=>
1287 Write_Str_With_Col_Check_Sloc
("mod <>");
1289 when N_Formal_Object_Declaration
=>
1292 if Write_Indent_Identifiers
(Node
) then
1295 if In_Present
(Node
) then
1296 Write_Str_With_Col_Check
("in ");
1299 if Out_Present
(Node
) then
1300 Write_Str_With_Col_Check
("out ");
1303 Sprint_Node
(Subtype_Mark
(Node
));
1305 if Present
(Expression
(Node
)) then
1307 Sprint_Node
(Expression
(Node
));
1313 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1314 Write_Str_With_Col_Check_Sloc
("delta <>");
1316 when N_Formal_Package_Declaration
=>
1317 Write_Indent_Str_Sloc
("with package ");
1318 Write_Id
(Defining_Identifier
(Node
));
1319 Write_Str_With_Col_Check
(" is new ");
1320 Sprint_Node
(Name
(Node
));
1321 Write_Str_With_Col_Check
(" (<>);");
1323 when N_Formal_Private_Type_Definition
=>
1324 if Abstract_Present
(Node
) then
1325 Write_Str_With_Col_Check
("abstract ");
1328 if Tagged_Present
(Node
) then
1329 Write_Str_With_Col_Check
("tagged ");
1332 if Limited_Present
(Node
) then
1333 Write_Str_With_Col_Check
("limited ");
1336 Write_Str_With_Col_Check_Sloc
("private");
1338 when N_Formal_Signed_Integer_Type_Definition
=>
1339 Write_Str_With_Col_Check_Sloc
("range <>");
1341 when N_Formal_Subprogram_Declaration
=>
1342 Write_Indent_Str_Sloc
("with ");
1343 Sprint_Node
(Specification
(Node
));
1345 if Box_Present
(Node
) then
1346 Write_Str_With_Col_Check
(" is <>");
1347 elsif Present
(Default_Name
(Node
)) then
1348 Write_Str_With_Col_Check
(" is ");
1349 Sprint_Node
(Default_Name
(Node
));
1354 when N_Formal_Type_Declaration
=>
1355 Write_Indent_Str_Sloc
("type ");
1356 Write_Id
(Defining_Identifier
(Node
));
1358 if Present
(Discriminant_Specifications
(Node
)) then
1359 Write_Discr_Specs
(Node
);
1360 elsif Unknown_Discriminants_Present
(Node
) then
1361 Write_Str_With_Col_Check
("(<>)");
1364 Write_Str_With_Col_Check
(" is ");
1365 Sprint_Node
(Formal_Type_Definition
(Node
));
1368 when N_Free_Statement
=>
1369 Write_Indent_Str_Sloc
("free ");
1370 Sprint_Node
(Expression
(Node
));
1373 when N_Freeze_Entity
=>
1374 if Dump_Original_Only
then
1377 elsif Present
(Actions
(Node
)) or else Dump_Freeze_Null
then
1379 Write_Rewrite_Str
("<<<");
1380 Write_Str_With_Col_Check_Sloc
("freeze ");
1381 Write_Id
(Entity
(Node
));
1384 if No
(Actions
(Node
)) then
1388 Freeze_Indent
:= Freeze_Indent
+ 1;
1389 Sprint_Indented_List
(Actions
(Node
));
1390 Freeze_Indent
:= Freeze_Indent
- 1;
1391 Write_Indent_Str
("]");
1394 Write_Rewrite_Str
(">>>");
1397 when N_Full_Type_Declaration
=>
1398 Write_Indent_Str_Sloc
("type ");
1399 Write_Id
(Defining_Identifier
(Node
));
1400 Write_Discr_Specs
(Node
);
1401 Write_Str_With_Col_Check
(" is ");
1402 Sprint_Node
(Type_Definition
(Node
));
1405 when N_Function_Call
=>
1407 Sprint_Node
(Name
(Node
));
1408 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1410 when N_Function_Instantiation
=>
1411 Write_Indent_Str_Sloc
("function ");
1412 Sprint_Node
(Defining_Unit_Name
(Node
));
1413 Write_Str_With_Col_Check
(" is new ");
1414 Sprint_Node
(Name
(Node
));
1415 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1418 when N_Function_Specification
=>
1419 Write_Str_With_Col_Check_Sloc
("function ");
1420 Sprint_Node
(Defining_Unit_Name
(Node
));
1421 Write_Param_Specs
(Node
);
1422 Write_Str_With_Col_Check
(" return ");
1423 Sprint_Node
(Subtype_Mark
(Node
));
1425 when N_Generic_Association
=>
1428 if Present
(Selector_Name
(Node
)) then
1429 Sprint_Node
(Selector_Name
(Node
));
1433 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
1435 when N_Generic_Function_Renaming_Declaration
=>
1436 Write_Indent_Str_Sloc
("generic function ");
1437 Sprint_Node
(Defining_Unit_Name
(Node
));
1438 Write_Str_With_Col_Check
(" renames ");
1439 Sprint_Node
(Name
(Node
));
1442 when N_Generic_Package_Declaration
=>
1444 Write_Indent_Str_Sloc
("generic ");
1445 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1447 Sprint_Node
(Specification
(Node
));
1450 when N_Generic_Package_Renaming_Declaration
=>
1451 Write_Indent_Str_Sloc
("generic package ");
1452 Sprint_Node
(Defining_Unit_Name
(Node
));
1453 Write_Str_With_Col_Check
(" renames ");
1454 Sprint_Node
(Name
(Node
));
1457 when N_Generic_Procedure_Renaming_Declaration
=>
1458 Write_Indent_Str_Sloc
("generic procedure ");
1459 Sprint_Node
(Defining_Unit_Name
(Node
));
1460 Write_Str_With_Col_Check
(" renames ");
1461 Sprint_Node
(Name
(Node
));
1464 when N_Generic_Subprogram_Declaration
=>
1466 Write_Indent_Str_Sloc
("generic ");
1467 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1469 Sprint_Node
(Specification
(Node
));
1472 when N_Goto_Statement
=>
1473 Write_Indent_Str_Sloc
("goto ");
1474 Sprint_Node
(Name
(Node
));
1477 if Nkind
(Next
(Node
)) = N_Label
then
1481 when N_Handled_Sequence_Of_Statements
=>
1483 Sprint_Indented_List
(Statements
(Node
));
1485 if Present
(Exception_Handlers
(Node
)) then
1486 Write_Indent_Str
("exception");
1488 Sprint_Node_List
(Exception_Handlers
(Node
));
1492 if Present
(At_End_Proc
(Node
)) then
1493 Write_Indent_Str
("at end");
1496 Sprint_Node
(At_End_Proc
(Node
));
1501 when N_Identifier
=>
1505 when N_If_Statement
=>
1506 Write_Indent_Str_Sloc
("if ");
1507 Sprint_Node
(Condition
(Node
));
1508 Write_Str_With_Col_Check
(" then");
1509 Sprint_Indented_List
(Then_Statements
(Node
));
1510 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
1512 if Present
(Else_Statements
(Node
)) then
1513 Write_Indent_Str
("else");
1514 Sprint_Indented_List
(Else_Statements
(Node
));
1517 Write_Indent_Str
("end if;");
1519 when N_Implicit_Label_Declaration
=>
1520 if not Dump_Original_Only
then
1522 Write_Rewrite_Str
("<<<");
1524 Write_Id
(Defining_Identifier
(Node
));
1526 Write_Str_With_Col_Check
("label");
1527 Write_Rewrite_Str
(">>>");
1531 Sprint_Left_Opnd
(Node
);
1532 Write_Str_Sloc
(" in ");
1533 Sprint_Right_Opnd
(Node
);
1535 when N_Incomplete_Type_Declaration
=>
1536 Write_Indent_Str_Sloc
("type ");
1537 Write_Id
(Defining_Identifier
(Node
));
1539 if Present
(Discriminant_Specifications
(Node
)) then
1540 Write_Discr_Specs
(Node
);
1541 elsif Unknown_Discriminants_Present
(Node
) then
1542 Write_Str_With_Col_Check
("(<>)");
1547 when N_Index_Or_Discriminant_Constraint
=>
1549 Sprint_Paren_Comma_List
(Constraints
(Node
));
1551 when N_Indexed_Component
=>
1552 Sprint_Node_Sloc
(Prefix
(Node
));
1553 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
1555 when N_Integer_Literal
=>
1556 if Print_In_Hex
(Node
) then
1557 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
1559 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
1562 when N_Iteration_Scheme
=>
1563 if Present
(Condition
(Node
)) then
1564 Write_Str_With_Col_Check_Sloc
("while ");
1565 Sprint_Node
(Condition
(Node
));
1567 Write_Str_With_Col_Check_Sloc
("for ");
1568 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1573 when N_Itype_Reference
=>
1574 Write_Indent_Str_Sloc
("reference ");
1575 Write_Id
(Itype
(Node
));
1578 Write_Indent_Str_Sloc
("<<");
1579 Write_Id
(Identifier
(Node
));
1582 when N_Loop_Parameter_Specification
=>
1584 Write_Id
(Defining_Identifier
(Node
));
1585 Write_Str_With_Col_Check
(" in ");
1587 if Reverse_Present
(Node
) then
1588 Write_Str_With_Col_Check
("reverse ");
1591 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1593 when N_Loop_Statement
=>
1596 if Present
(Identifier
(Node
))
1597 and then (not Has_Created_Identifier
(Node
)
1598 or else not Dump_Original_Only
)
1600 Write_Rewrite_Str
("<<<");
1601 Write_Id
(Identifier
(Node
));
1603 Write_Rewrite_Str
(">>>");
1604 Sprint_Node
(Iteration_Scheme
(Node
));
1605 Write_Str_With_Col_Check_Sloc
("loop");
1606 Sprint_Indented_List
(Statements
(Node
));
1607 Write_Indent_Str
("end loop ");
1608 Write_Rewrite_Str
("<<<");
1609 Write_Id
(Identifier
(Node
));
1610 Write_Rewrite_Str
(">>>");
1614 Sprint_Node
(Iteration_Scheme
(Node
));
1615 Write_Str_With_Col_Check_Sloc
("loop");
1616 Sprint_Indented_List
(Statements
(Node
));
1617 Write_Indent_Str
("end loop;");
1620 when N_Mod_Clause
=>
1621 Sprint_Node_List
(Pragmas_Before
(Node
));
1622 Write_Str_With_Col_Check_Sloc
("at mod ");
1623 Sprint_Node
(Expression
(Node
));
1625 when N_Modular_Type_Definition
=>
1626 Write_Str_With_Col_Check_Sloc
("mod ");
1627 Sprint_Node
(Expression
(Node
));
1630 Sprint_Left_Opnd
(Node
);
1631 Write_Str_Sloc
(" not in ");
1632 Sprint_Right_Opnd
(Node
);
1635 Write_Str_With_Col_Check_Sloc
("null");
1637 when N_Null_Statement
=>
1638 if Comes_From_Source
(Node
)
1639 or else Dump_Freeze_Null
1640 or else not Is_List_Member
(Node
)
1641 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
1643 Write_Indent_Str_Sloc
("null;");
1646 when N_Number_Declaration
=>
1649 if Write_Indent_Identifiers
(Node
) then
1650 Write_Str_With_Col_Check
(" : constant ");
1652 Sprint_Node
(Expression
(Node
));
1656 when N_Object_Declaration
=>
1658 -- Put extra blank line before and after if this is a handler
1659 -- record or a subprogram descriptor.
1662 Typ
: constant Entity_Id
:= Etype
(Defining_Identifier
(Node
));
1663 Exc
: constant Boolean :=
1664 Is_RTE
(Typ
, RE_Handler_Record
)
1666 Is_RTE
(Typ
, RE_Subprogram_Descriptor
);
1675 if Write_Indent_Identifiers
(Node
) then
1678 if Aliased_Present
(Node
) then
1679 Write_Str_With_Col_Check
("aliased ");
1682 if Constant_Present
(Node
) then
1683 Write_Str_With_Col_Check
("constant ");
1686 Sprint_Node
(Object_Definition
(Node
));
1688 if Present
(Expression
(Node
)) then
1690 Sprint_Node
(Expression
(Node
));
1701 when N_Object_Renaming_Declaration
=>
1704 Sprint_Node
(Defining_Identifier
(Node
));
1706 Sprint_Node
(Subtype_Mark
(Node
));
1707 Write_Str_With_Col_Check
(" renames ");
1708 Sprint_Node
(Name
(Node
));
1712 Write_Operator
(Node
, "abs ");
1713 Sprint_Right_Opnd
(Node
);
1716 Sprint_Left_Opnd
(Node
);
1717 Write_Operator
(Node
, " + ");
1718 Sprint_Right_Opnd
(Node
);
1721 Sprint_Left_Opnd
(Node
);
1722 Write_Operator
(Node
, " and ");
1723 Sprint_Right_Opnd
(Node
);
1726 Sprint_Left_Opnd
(Node
);
1727 Write_Operator
(Node
, " & ");
1728 Sprint_Right_Opnd
(Node
);
1731 Sprint_Left_Opnd
(Node
);
1733 Process_TFAI_RR_Flags
(Node
);
1734 Write_Operator
(Node
, "/ ");
1735 Sprint_Right_Opnd
(Node
);
1738 Sprint_Left_Opnd
(Node
);
1739 Write_Operator
(Node
, " = ");
1740 Sprint_Right_Opnd
(Node
);
1743 Sprint_Left_Opnd
(Node
);
1744 Write_Operator
(Node
, " ** ");
1745 Sprint_Right_Opnd
(Node
);
1748 Sprint_Left_Opnd
(Node
);
1749 Write_Operator
(Node
, " >= ");
1750 Sprint_Right_Opnd
(Node
);
1753 Sprint_Left_Opnd
(Node
);
1754 Write_Operator
(Node
, " > ");
1755 Sprint_Right_Opnd
(Node
);
1758 Sprint_Left_Opnd
(Node
);
1759 Write_Operator
(Node
, " <= ");
1760 Sprint_Right_Opnd
(Node
);
1763 Sprint_Left_Opnd
(Node
);
1764 Write_Operator
(Node
, " < ");
1765 Sprint_Right_Opnd
(Node
);
1768 Write_Operator
(Node
, "-");
1769 Sprint_Right_Opnd
(Node
);
1772 Sprint_Left_Opnd
(Node
);
1774 if Treat_Fixed_As_Integer
(Node
) then
1778 Write_Operator
(Node
, " mod ");
1779 Sprint_Right_Opnd
(Node
);
1781 when N_Op_Multiply
=>
1782 Sprint_Left_Opnd
(Node
);
1784 Process_TFAI_RR_Flags
(Node
);
1785 Write_Operator
(Node
, "* ");
1786 Sprint_Right_Opnd
(Node
);
1789 Sprint_Left_Opnd
(Node
);
1790 Write_Operator
(Node
, " /= ");
1791 Sprint_Right_Opnd
(Node
);
1794 Write_Operator
(Node
, "not ");
1795 Sprint_Right_Opnd
(Node
);
1798 Sprint_Left_Opnd
(Node
);
1799 Write_Operator
(Node
, " or ");
1800 Sprint_Right_Opnd
(Node
);
1803 Write_Operator
(Node
, "+");
1804 Sprint_Right_Opnd
(Node
);
1807 Sprint_Left_Opnd
(Node
);
1809 if Treat_Fixed_As_Integer
(Node
) then
1813 Write_Operator
(Node
, " rem ");
1814 Sprint_Right_Opnd
(Node
);
1820 Write_Str_With_Col_Check
("(");
1821 Sprint_Node
(Left_Opnd
(Node
));
1823 Sprint_Node
(Right_Opnd
(Node
));
1826 when N_Op_Subtract
=>
1827 Sprint_Left_Opnd
(Node
);
1828 Write_Operator
(Node
, " - ");
1829 Sprint_Right_Opnd
(Node
);
1832 Sprint_Left_Opnd
(Node
);
1833 Write_Operator
(Node
, " xor ");
1834 Sprint_Right_Opnd
(Node
);
1836 when N_Operator_Symbol
=>
1837 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1839 when N_Ordinary_Fixed_Point_Definition
=>
1840 Write_Str_With_Col_Check_Sloc
("delta ");
1841 Sprint_Node
(Delta_Expression
(Node
));
1842 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1845 Sprint_Left_Opnd
(Node
);
1846 Write_Str_Sloc
(" or else ");
1847 Sprint_Right_Opnd
(Node
);
1849 when N_Others_Choice
=>
1850 if All_Others
(Node
) then
1851 Write_Str_With_Col_Check
("all ");
1854 Write_Str_With_Col_Check_Sloc
("others");
1856 when N_Package_Body
=>
1858 Write_Indent_Str_Sloc
("package body ");
1859 Sprint_Node
(Defining_Unit_Name
(Node
));
1861 Sprint_Indented_List
(Declarations
(Node
));
1863 if Present
(Handled_Statement_Sequence
(Node
)) then
1864 Write_Indent_Str
("begin");
1865 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1868 Write_Indent_Str
("end ");
1869 Sprint_Node
(Defining_Unit_Name
(Node
));
1872 when N_Package_Body_Stub
=>
1873 Write_Indent_Str_Sloc
("package body ");
1874 Sprint_Node
(Defining_Identifier
(Node
));
1875 Write_Str_With_Col_Check
(" is separate;");
1877 when N_Package_Declaration
=>
1880 Sprint_Node_Sloc
(Specification
(Node
));
1883 when N_Package_Instantiation
=>
1885 Write_Indent_Str_Sloc
("package ");
1886 Sprint_Node
(Defining_Unit_Name
(Node
));
1887 Write_Str
(" is new ");
1888 Sprint_Node
(Name
(Node
));
1889 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1892 when N_Package_Renaming_Declaration
=>
1893 Write_Indent_Str_Sloc
("package ");
1894 Sprint_Node
(Defining_Unit_Name
(Node
));
1895 Write_Str_With_Col_Check
(" renames ");
1896 Sprint_Node
(Name
(Node
));
1899 when N_Package_Specification
=>
1900 Write_Str_With_Col_Check_Sloc
("package ");
1901 Sprint_Node
(Defining_Unit_Name
(Node
));
1903 Sprint_Indented_List
(Visible_Declarations
(Node
));
1905 if Present
(Private_Declarations
(Node
)) then
1906 Write_Indent_Str
("private");
1907 Sprint_Indented_List
(Private_Declarations
(Node
));
1910 Write_Indent_Str
("end ");
1911 Sprint_Node
(Defining_Unit_Name
(Node
));
1913 when N_Parameter_Association
=>
1914 Sprint_Node_Sloc
(Selector_Name
(Node
));
1916 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
1918 when N_Parameter_Specification
=>
1921 if Write_Identifiers
(Node
) then
1924 if In_Present
(Node
) then
1925 Write_Str_With_Col_Check
("in ");
1928 if Out_Present
(Node
) then
1929 Write_Str_With_Col_Check
("out ");
1932 Sprint_Node
(Parameter_Type
(Node
));
1934 if Present
(Expression
(Node
)) then
1936 Sprint_Node
(Expression
(Node
));
1943 Write_Indent_Str_Sloc
("pragma ");
1944 Write_Name_With_Col_Check
(Chars
(Node
));
1946 if Present
(Pragma_Argument_Associations
(Node
)) then
1947 Sprint_Opt_Paren_Comma_List
1948 (Pragma_Argument_Associations
(Node
));
1953 when N_Pragma_Argument_Association
=>
1956 if Chars
(Node
) /= No_Name
then
1957 Write_Name_With_Col_Check
(Chars
(Node
));
1961 Sprint_Node
(Expression
(Node
));
1963 when N_Private_Type_Declaration
=>
1964 Write_Indent_Str_Sloc
("type ");
1965 Write_Id
(Defining_Identifier
(Node
));
1967 if Present
(Discriminant_Specifications
(Node
)) then
1968 Write_Discr_Specs
(Node
);
1969 elsif Unknown_Discriminants_Present
(Node
) then
1970 Write_Str_With_Col_Check
("(<>)");
1975 if Tagged_Present
(Node
) then
1976 Write_Str_With_Col_Check
("tagged ");
1979 if Limited_Present
(Node
) then
1980 Write_Str_With_Col_Check
("limited ");
1983 Write_Str_With_Col_Check
("private;");
1985 when N_Private_Extension_Declaration
=>
1986 Write_Indent_Str_Sloc
("type ");
1987 Write_Id
(Defining_Identifier
(Node
));
1989 if Present
(Discriminant_Specifications
(Node
)) then
1990 Write_Discr_Specs
(Node
);
1991 elsif Unknown_Discriminants_Present
(Node
) then
1992 Write_Str_With_Col_Check
("(<>)");
1995 Write_Str_With_Col_Check
(" is new ");
1996 Sprint_Node
(Subtype_Indication
(Node
));
1997 Write_Str_With_Col_Check
(" with private;");
1999 when N_Procedure_Call_Statement
=>
2002 Sprint_Node
(Name
(Node
));
2003 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2006 when N_Procedure_Instantiation
=>
2007 Write_Indent_Str_Sloc
("procedure ");
2008 Sprint_Node
(Defining_Unit_Name
(Node
));
2009 Write_Str_With_Col_Check
(" is new ");
2010 Sprint_Node
(Name
(Node
));
2011 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2014 when N_Procedure_Specification
=>
2015 Write_Str_With_Col_Check_Sloc
("procedure ");
2016 Sprint_Node
(Defining_Unit_Name
(Node
));
2017 Write_Param_Specs
(Node
);
2019 when N_Protected_Body
=>
2020 Write_Indent_Str_Sloc
("protected body ");
2021 Write_Id
(Defining_Identifier
(Node
));
2023 Sprint_Indented_List
(Declarations
(Node
));
2024 Write_Indent_Str
("end ");
2025 Write_Id
(Defining_Identifier
(Node
));
2028 when N_Protected_Body_Stub
=>
2029 Write_Indent_Str_Sloc
("protected body ");
2030 Write_Id
(Defining_Identifier
(Node
));
2031 Write_Str_With_Col_Check
(" is separate;");
2033 when N_Protected_Definition
=>
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 ");
2044 when N_Protected_Type_Declaration
=>
2045 Write_Indent_Str_Sloc
("protected type ");
2046 Write_Id
(Defining_Identifier
(Node
));
2047 Write_Discr_Specs
(Node
);
2049 Sprint_Node
(Protected_Definition
(Node
));
2050 Write_Id
(Defining_Identifier
(Node
));
2053 when N_Qualified_Expression
=>
2054 Sprint_Node
(Subtype_Mark
(Node
));
2055 Write_Char_Sloc
(''');
2057 -- Print expression, make sure we have at least one level of
2058 -- parentheses around the expression. For cases of qualified
2059 -- expressions in the source, this is always the case, but
2060 -- for generated qualifications, there may be no explicit
2061 -- parentheses present.
2063 if Paren_Count
(Expression
(Node
)) /= 0 then
2064 Sprint_Node
(Expression
(Node
));
2067 Sprint_Node
(Expression
(Node
));
2071 when N_Raise_Constraint_Error
=>
2073 -- This node can be used either as a subexpression or as a
2074 -- statement form. The following test is a reasonably reliable
2075 -- way to distinguish the two cases.
2077 if Is_List_Member
(Node
)
2078 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2083 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2084 Write_Condition_And_Reason
(Node
);
2086 when N_Raise_Program_Error
=>
2088 -- This node can be used either as a subexpression or as a
2089 -- statement form. The following test is a reasonably reliable
2090 -- way to distinguish the two cases.
2092 if Is_List_Member
(Node
)
2093 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2098 Write_Str_With_Col_Check_Sloc
("[program_error");
2099 Write_Condition_And_Reason
(Node
);
2101 when N_Raise_Storage_Error
=>
2103 -- This node can be used either as a subexpression or as a
2104 -- statement form. The following test is a reasonably reliable
2105 -- way to distinguish the two cases.
2107 if Is_List_Member
(Node
)
2108 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2113 Write_Str_With_Col_Check_Sloc
("[storage_error");
2114 Write_Condition_And_Reason
(Node
);
2116 when N_Raise_Statement
=>
2117 Write_Indent_Str_Sloc
("raise ");
2118 Sprint_Node
(Name
(Node
));
2122 Sprint_Node
(Low_Bound
(Node
));
2123 Write_Str_Sloc
(" .. ");
2124 Sprint_Node
(High_Bound
(Node
));
2126 when N_Range_Constraint
=>
2127 Write_Str_With_Col_Check_Sloc
("range ");
2128 Sprint_Node
(Range_Expression
(Node
));
2130 when N_Real_Literal
=>
2131 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
2133 when N_Real_Range_Specification
=>
2134 Write_Str_With_Col_Check_Sloc
("range ");
2135 Sprint_Node
(Low_Bound
(Node
));
2137 Sprint_Node
(High_Bound
(Node
));
2139 when N_Record_Definition
=>
2140 if Abstract_Present
(Node
) then
2141 Write_Str_With_Col_Check
("abstract ");
2144 if Tagged_Present
(Node
) then
2145 Write_Str_With_Col_Check
("tagged ");
2148 if Limited_Present
(Node
) then
2149 Write_Str_With_Col_Check
("limited ");
2152 if Null_Present
(Node
) then
2153 Write_Str_With_Col_Check_Sloc
("null record");
2156 Write_Str_With_Col_Check_Sloc
("record");
2157 Sprint_Node
(Component_List
(Node
));
2158 Write_Indent_Str
("end record");
2161 when N_Record_Representation_Clause
=>
2162 Write_Indent_Str_Sloc
("for ");
2163 Sprint_Node
(Identifier
(Node
));
2164 Write_Str_With_Col_Check
(" use record ");
2166 if Present
(Mod_Clause
(Node
)) then
2167 Sprint_Node
(Mod_Clause
(Node
));
2170 Sprint_Indented_List
(Component_Clauses
(Node
));
2171 Write_Indent_Str
("end record;");
2174 Sprint_Node
(Prefix
(Node
));
2175 Write_Str_With_Col_Check_Sloc
("'reference");
2177 when N_Requeue_Statement
=>
2178 Write_Indent_Str_Sloc
("requeue ");
2179 Sprint_Node
(Name
(Node
));
2181 if Abort_Present
(Node
) then
2182 Write_Str_With_Col_Check
(" with abort");
2187 when N_Return_Statement
=>
2188 if Present
(Expression
(Node
)) then
2189 Write_Indent_Str_Sloc
("return ");
2190 Sprint_Node
(Expression
(Node
));
2193 Write_Indent_Str_Sloc
("return;");
2196 when N_Selective_Accept
=>
2197 Write_Indent_Str_Sloc
("select");
2203 Alt_Node
:= First
(Select_Alternatives
(Node
));
2206 Sprint_Node
(Alt_Node
);
2209 exit when No
(Alt_Node
);
2210 Write_Indent_Str
("or");
2214 if Present
(Else_Statements
(Node
)) then
2215 Write_Indent_Str
("else");
2216 Sprint_Indented_List
(Else_Statements
(Node
));
2219 Write_Indent_Str
("end select;");
2221 when N_Signed_Integer_Type_Definition
=>
2222 Write_Str_With_Col_Check_Sloc
("range ");
2223 Sprint_Node
(Low_Bound
(Node
));
2225 Sprint_Node
(High_Bound
(Node
));
2227 when N_Single_Protected_Declaration
=>
2228 Write_Indent_Str_Sloc
("protected ");
2229 Write_Id
(Defining_Identifier
(Node
));
2231 Sprint_Node
(Protected_Definition
(Node
));
2232 Write_Id
(Defining_Identifier
(Node
));
2235 when N_Single_Task_Declaration
=>
2236 Write_Indent_Str_Sloc
("task ");
2237 Write_Id
(Defining_Identifier
(Node
));
2239 if Present
(Task_Definition
(Node
)) then
2241 Sprint_Node
(Task_Definition
(Node
));
2242 Write_Id
(Defining_Identifier
(Node
));
2247 when N_Selected_Component | N_Expanded_Name
=>
2248 Sprint_Node
(Prefix
(Node
));
2249 Write_Char_Sloc
('.');
2250 Sprint_Node
(Selector_Name
(Node
));
2254 Sprint_Node
(Prefix
(Node
));
2255 Write_Str_With_Col_Check
(" (");
2256 Sprint_Node
(Discrete_Range
(Node
));
2259 when N_String_Literal
=>
2260 if String_Length
(Strval
(Node
)) + Column
> 75 then
2261 Write_Indent_Str
(" ");
2265 Write_String_Table_Entry
(Strval
(Node
));
2267 when N_Subprogram_Body
=>
2268 if Freeze_Indent
= 0 then
2273 Sprint_Node_Sloc
(Specification
(Node
));
2276 Sprint_Indented_List
(Declarations
(Node
));
2277 Write_Indent_Str
("begin");
2278 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2280 Write_Indent_Str
("end ");
2281 Sprint_Node
(Defining_Unit_Name
(Specification
(Node
)));
2284 if Is_List_Member
(Node
)
2285 and then Present
(Next
(Node
))
2286 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
2291 when N_Subprogram_Body_Stub
=>
2293 Sprint_Node_Sloc
(Specification
(Node
));
2294 Write_Str_With_Col_Check
(" is separate;");
2296 when N_Subprogram_Declaration
=>
2298 Sprint_Node_Sloc
(Specification
(Node
));
2301 when N_Subprogram_Info
=>
2302 Sprint_Node
(Identifier
(Node
));
2303 Write_Str_With_Col_Check_Sloc
("'subprogram_info");
2305 when N_Subprogram_Renaming_Declaration
=>
2307 Sprint_Node
(Specification
(Node
));
2308 Write_Str_With_Col_Check_Sloc
(" renames ");
2309 Sprint_Node
(Name
(Node
));
2312 when N_Subtype_Declaration
=>
2313 Write_Indent_Str_Sloc
("subtype ");
2314 Write_Id
(Defining_Identifier
(Node
));
2316 Sprint_Node
(Subtype_Indication
(Node
));
2319 when N_Subtype_Indication
=>
2320 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
2322 Sprint_Node
(Constraint
(Node
));
2325 Write_Indent_Str_Sloc
("separate (");
2326 Sprint_Node
(Name
(Node
));
2329 Sprint_Node
(Proper_Body
(Node
));
2332 Write_Indent_Str_Sloc
("task body ");
2333 Write_Id
(Defining_Identifier
(Node
));
2335 Sprint_Indented_List
(Declarations
(Node
));
2336 Write_Indent_Str
("begin");
2337 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2338 Write_Indent_Str
("end ");
2339 Write_Id
(Defining_Identifier
(Node
));
2342 when N_Task_Body_Stub
=>
2343 Write_Indent_Str_Sloc
("task body ");
2344 Write_Id
(Defining_Identifier
(Node
));
2345 Write_Str_With_Col_Check
(" is separate;");
2347 when N_Task_Definition
=>
2349 Sprint_Indented_List
(Visible_Declarations
(Node
));
2351 if Present
(Private_Declarations
(Node
)) then
2352 Write_Indent_Str
("private");
2353 Sprint_Indented_List
(Private_Declarations
(Node
));
2356 Write_Indent_Str
("end ");
2358 when N_Task_Type_Declaration
=>
2359 Write_Indent_Str_Sloc
("task type ");
2360 Write_Id
(Defining_Identifier
(Node
));
2361 Write_Discr_Specs
(Node
);
2362 if Present
(Task_Definition
(Node
)) then
2364 Sprint_Node
(Task_Definition
(Node
));
2365 Write_Id
(Defining_Identifier
(Node
));
2370 when N_Terminate_Alternative
=>
2371 Sprint_Node_List
(Pragmas_Before
(Node
));
2375 if Present
(Condition
(Node
)) then
2376 Write_Str_With_Col_Check
("when ");
2377 Sprint_Node
(Condition
(Node
));
2381 Write_Str_With_Col_Check_Sloc
("terminate;");
2382 Sprint_Node_List
(Pragmas_After
(Node
));
2384 when N_Timed_Entry_Call
=>
2385 Write_Indent_Str_Sloc
("select");
2387 Sprint_Node
(Entry_Call_Alternative
(Node
));
2389 Write_Indent_Str
("or");
2391 Sprint_Node
(Delay_Alternative
(Node
));
2393 Write_Indent_Str
("end select;");
2395 when N_Triggering_Alternative
=>
2396 Sprint_Node_List
(Pragmas_Before
(Node
));
2397 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
2398 Sprint_Node_List
(Statements
(Node
));
2400 when N_Type_Conversion
=>
2402 Sprint_Node
(Subtype_Mark
(Node
));
2405 if Conversion_OK
(Node
) then
2409 if Float_Truncate
(Node
) then
2413 if Rounded_Result
(Node
) then
2418 Sprint_Node
(Expression
(Node
));
2421 when N_Unchecked_Expression
=>
2424 Sprint_Node_Sloc
(Expression
(Node
));
2427 when N_Unchecked_Type_Conversion
=>
2428 Sprint_Node
(Subtype_Mark
(Node
));
2430 Write_Str_With_Col_Check
("(");
2431 Sprint_Node_Sloc
(Expression
(Node
));
2434 when N_Unconstrained_Array_Definition
=>
2435 Write_Str_With_Col_Check_Sloc
("array (");
2441 Node1
:= First
(Subtype_Marks
(Node
));
2443 Sprint_Node
(Node1
);
2444 Write_Str_With_Col_Check
(" range <>");
2446 exit when Node1
= Empty
;
2451 Write_Str
(") of ");
2453 if Aliased_Present
(Node
) then
2454 Write_Str_With_Col_Check
("aliased ");
2457 Sprint_Node
(Subtype_Indication
(Node
));
2459 when N_Unused_At_Start | N_Unused_At_End
=>
2460 Write_Indent_Str
("***** Error, unused node encountered *****");
2463 when N_Use_Package_Clause
=>
2464 Write_Indent_Str_Sloc
("use ");
2465 Sprint_Comma_List
(Names
(Node
));
2468 when N_Use_Type_Clause
=>
2469 Write_Indent_Str_Sloc
("use type ");
2470 Sprint_Comma_List
(Subtype_Marks
(Node
));
2473 when N_Validate_Unchecked_Conversion
=>
2474 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
2475 Sprint_Node
(Source_Type
(Node
));
2477 Sprint_Node
(Target_Type
(Node
));
2481 Write_Indent_Str_Sloc
("when ");
2482 Sprint_Bar_List
(Discrete_Choices
(Node
));
2484 Sprint_Node
(Component_List
(Node
));
2486 when N_Variant_Part
=>
2488 Write_Indent_Str_Sloc
("case ");
2489 Sprint_Node
(Name
(Node
));
2491 Sprint_Indented_List
(Variants
(Node
));
2492 Write_Indent_Str
("end case");
2495 when N_With_Clause
=>
2497 -- Special test, if we are dumping the original tree only,
2498 -- then we want to eliminate the bogus with clauses that
2499 -- correspond to the non-existent children of Text_IO.
2501 if Dump_Original_Only
2502 and then Is_Text_IO_Kludge_Unit
(Name
(Node
))
2506 -- Normal case, output the with clause
2509 if First_Name
(Node
) or else not Dump_Original_Only
then
2510 Write_Indent_Str
("with ");
2515 Sprint_Node_Sloc
(Name
(Node
));
2517 if Last_Name
(Node
) or else not Dump_Original_Only
then
2522 when N_With_Type_Clause
=>
2524 Write_Indent_Str
("with type ");
2525 Sprint_Node_Sloc
(Name
(Node
));
2527 if Tagged_Present
(Node
) then
2528 Write_Str
(" is tagged;");
2530 Write_Str
(" is access;");
2535 if Nkind
(Node
) in N_Subexpr
2536 and then Do_Range_Check
(Node
)
2541 for J
in 1 .. Paren_Count
(Node
) loop
2545 pragma Assert
(No
(Debug_Node
));
2546 Debug_Node
:= Save_Debug_Node
;
2547 end Sprint_Node_Actual
;
2549 ----------------------
2550 -- Sprint_Node_List --
2551 ----------------------
2553 procedure Sprint_Node_List
(List
: List_Id
) is
2557 if Is_Non_Empty_List
(List
) then
2558 Node
:= First
(List
);
2563 exit when Node
= Empty
;
2566 end Sprint_Node_List
;
2568 ----------------------
2569 -- Sprint_Node_Sloc --
2570 ----------------------
2572 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
2576 if Present
(Debug_Node
) then
2577 Set_Sloc
(Debug_Node
, Sloc
(Node
));
2578 Debug_Node
:= Empty
;
2580 end Sprint_Node_Sloc
;
2582 ---------------------
2583 -- Sprint_Opt_Node --
2584 ---------------------
2586 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
2588 if Present
(Node
) then
2592 end Sprint_Opt_Node
;
2594 --------------------------
2595 -- Sprint_Opt_Node_List --
2596 --------------------------
2598 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
2600 if Present
(List
) then
2601 Sprint_Node_List
(List
);
2603 end Sprint_Opt_Node_List
;
2605 ---------------------------------
2606 -- Sprint_Opt_Paren_Comma_List --
2607 ---------------------------------
2609 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
2611 if Is_Non_Empty_List
(List
) then
2613 Sprint_Paren_Comma_List
(List
);
2615 end Sprint_Opt_Paren_Comma_List
;
2617 -----------------------------
2618 -- Sprint_Paren_Comma_List --
2619 -----------------------------
2621 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
2623 Node_Exists
: Boolean := False;
2627 if Is_Non_Empty_List
(List
) then
2629 if Dump_Original_Only
then
2632 while Present
(N
) loop
2634 if not Is_Rewrite_Insertion
(N
) then
2635 Node_Exists
:= True;
2642 if not Node_Exists
then
2647 Write_Str_With_Col_Check
("(");
2648 Sprint_Comma_List
(List
);
2651 end Sprint_Paren_Comma_List
;
2653 ----------------------
2654 -- Sprint_Right_Opnd --
2655 ----------------------
2657 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
2658 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
2661 if Paren_Count
(Opnd
) /= 0
2662 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
2671 end Sprint_Right_Opnd
;
2673 ---------------------
2674 -- Write_Char_Sloc --
2675 ---------------------
2677 procedure Write_Char_Sloc
(C
: Character) is
2679 if Debug_Generated_Code
and then C
/= ' ' then
2684 end Write_Char_Sloc
;
2686 --------------------------------
2687 -- Write_Condition_And_Reason --
2688 --------------------------------
2690 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
2691 Image
: constant String := RT_Exception_Code
'Image
2692 (RT_Exception_Code
'Val
2693 (UI_To_Int
(Reason
(Node
))));
2696 if Present
(Condition
(Node
)) then
2697 Write_Str_With_Col_Check
(" when ");
2698 Sprint_Node
(Condition
(Node
));
2703 for J
in 4 .. Image
'Last loop
2704 if Image
(J
) = '_' then
2707 Write_Char
(Fold_Lower
(Image
(J
)));
2712 end Write_Condition_And_Reason
;
2714 ------------------------
2715 -- Write_Discr_Specs --
2716 ------------------------
2718 procedure Write_Discr_Specs
(N
: Node_Id
) is
2723 Specs
:= Discriminant_Specifications
(N
);
2725 if Present
(Specs
) then
2726 Write_Str_With_Col_Check
(" (");
2727 Spec
:= First
(Specs
);
2732 exit when Spec
= Empty
;
2734 -- Add semicolon, unless we are printing original tree and the
2735 -- next specification is part of a list (but not the first
2736 -- element of that list)
2738 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
2745 end Write_Discr_Specs
;
2751 procedure Write_Ekind
(E
: Entity_Id
) is
2752 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
2755 Name_Len
:= S
'Length;
2756 Name_Buffer
(1 .. Name_Len
) := S
;
2757 Set_Casing
(Mixed_Case
);
2758 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2765 procedure Write_Id
(N
: Node_Id
) is
2767 -- Case of a defining identifier
2769 if Nkind
(N
) = N_Defining_Identifier
then
2771 -- If defining identifier has an interface name (and no
2772 -- address clause), then we output the interface name.
2774 if (Is_Imported
(N
) or else Is_Exported
(N
))
2775 and then Present
(Interface_Name
(N
))
2776 and then No
(Address_Clause
(N
))
2778 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
2779 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2781 -- If no interface name (or inactive because there was
2782 -- an address clause), then just output the Chars name.
2785 Write_Name_With_Col_Check
(Chars
(N
));
2788 -- Case of selector of an expanded name where the expanded name
2789 -- has an associated entity, output this entity.
2791 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
2792 and then Selector_Name
(Parent
(N
)) = N
2793 and then Present
(Entity
(Parent
(N
)))
2795 Write_Id
(Entity
(Parent
(N
)));
2797 -- For any other kind of node with an associated entity, output it.
2799 elsif Nkind
(N
) in N_Has_Entity
2800 and then Present
(Entity
(N
))
2802 Write_Id
(Entity
(N
));
2804 -- All other cases, we just print the Chars field
2807 Write_Name_With_Col_Check
(Chars
(N
));
2811 -----------------------
2812 -- Write_Identifiers --
2813 -----------------------
2815 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
2817 Sprint_Node
(Defining_Identifier
(Node
));
2819 -- The remainder of the declaration must be printed unless we are
2820 -- printing the original tree and this is not the last identifier
2823 not Dump_Original_Only
or else not More_Ids
(Node
);
2825 end Write_Identifiers
;
2827 ------------------------
2828 -- Write_Implicit_Def --
2829 ------------------------
2831 procedure Write_Implicit_Def
(E
: Entity_Id
) is
2836 when E_Array_Subtype
=>
2837 Write_Str_With_Col_Check
("subtype ");
2839 Write_Str_With_Col_Check
(" is ");
2840 Write_Id
(Base_Type
(E
));
2841 Write_Str_With_Col_Check
(" (");
2843 Ind
:= First_Index
(E
);
2845 while Present
(Ind
) loop
2849 if Present
(Ind
) then
2856 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
2857 Write_Str_With_Col_Check
("subtype ");
2860 Write_Id
(Etype
(E
));
2861 Write_Str_With_Col_Check
(" range ");
2862 Sprint_Node
(Scalar_Range
(E
));
2866 Write_Str_With_Col_Check
("type ");
2868 Write_Str_With_Col_Check
(" is <");
2873 end Write_Implicit_Def
;
2879 procedure Write_Indent
is
2881 if Indent_Annull_Flag
then
2882 Indent_Annull_Flag
:= False;
2886 for J
in 1 .. Indent
loop
2892 ------------------------------
2893 -- Write_Indent_Identifiers --
2894 ------------------------------
2896 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
2898 -- We need to start a new line for every node, except in the case
2899 -- where we are printing the original tree and this is not the first
2900 -- defining identifier in the list.
2902 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
2905 -- If printing original tree and this is not the first defining
2906 -- identifier in the list, then the previous call to this procedure
2907 -- printed only the name, and we add a comma to separate the names.
2913 Sprint_Node
(Defining_Identifier
(Node
));
2915 -- The remainder of the declaration must be printed unless we are
2916 -- printing the original tree and this is not the last identifier
2919 not Dump_Original_Only
or else not More_Ids
(Node
);
2921 end Write_Indent_Identifiers
;
2923 -----------------------------------
2924 -- Write_Indent_Identifiers_Sloc --
2925 -----------------------------------
2927 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
2929 -- We need to start a new line for every node, except in the case
2930 -- where we are printing the original tree and this is not the first
2931 -- defining identifier in the list.
2933 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
2936 -- If printing original tree and this is not the first defining
2937 -- identifier in the list, then the previous call to this procedure
2938 -- printed only the name, and we add a comma to separate the names.
2945 Sprint_Node
(Defining_Identifier
(Node
));
2947 -- The remainder of the declaration must be printed unless we are
2948 -- printing the original tree and this is not the last identifier
2951 not Dump_Original_Only
or else not More_Ids
(Node
);
2953 end Write_Indent_Identifiers_Sloc
;
2955 ----------------------
2956 -- Write_Indent_Str --
2957 ----------------------
2959 procedure Write_Indent_Str
(S
: String) is
2963 end Write_Indent_Str
;
2965 ---------------------------
2966 -- Write_Indent_Str_Sloc --
2967 ---------------------------
2969 procedure Write_Indent_Str_Sloc
(S
: String) is
2973 end Write_Indent_Str_Sloc
;
2975 -------------------------------
2976 -- Write_Name_With_Col_Check --
2977 -------------------------------
2979 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
2983 Get_Name_String
(N
);
2985 -- Deal with -gnatI which replaces digits in an internal
2986 -- name by three dots (e.g. R7b becomes R...b).
2988 if Debug_Flag_II
and then Name_Buffer
(1) in 'A' .. 'Z' then
2991 while J
< Name_Len
loop
2992 exit when Name_Buffer
(J
) not in 'A' .. 'Z';
2996 if Name_Buffer
(J
) in '0' .. '9' then
2997 Write_Str_With_Col_Check
(Name_Buffer
(1 .. J
- 1));
3000 while J
<= Name_Len
loop
3001 if Name_Buffer
(J
) not in '0' .. '9' then
3002 Write_Str
(Name_Buffer
(J
.. Name_Len
));
3014 -- Fall through for normal case
3016 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3017 end Write_Name_With_Col_Check
;
3019 ------------------------------------
3020 -- Write_Name_With_Col_Check_Sloc --
3021 ------------------------------------
3023 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
3025 Get_Name_String
(N
);
3026 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
3027 end Write_Name_With_Col_Check_Sloc
;
3029 --------------------
3030 -- Write_Operator --
3031 --------------------
3033 procedure Write_Operator
(N
: Node_Id
; S
: String) is
3034 F
: Natural := S
'First;
3035 T
: Natural := S
'Last;
3038 -- If no overflow check, just write string out, and we are done
3040 if not Do_Overflow_Check
(N
) then
3043 -- If overflow check, we want to surround the operator with curly
3044 -- brackets, but not include spaces within the brackets.
3057 Write_Str_Sloc
(S
(F
.. T
));
3060 if S
(S
'Last) = ' ' then
3066 -----------------------
3067 -- Write_Param_Specs --
3068 -----------------------
3070 procedure Write_Param_Specs
(N
: Node_Id
) is
3076 Specs
:= Parameter_Specifications
(N
);
3078 if Is_Non_Empty_List
(Specs
) then
3079 Write_Str_With_Col_Check
(" (");
3080 Spec
:= First
(Specs
);
3084 Formal
:= Defining_Identifier
(Spec
);
3086 exit when Spec
= Empty
;
3088 -- Add semicolon, unless we are printing original tree and the
3089 -- next specification is part of a list (but not the first
3090 -- element of that list)
3092 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3097 -- Write out any extra formals
3099 while Present
(Extra_Formal
(Formal
)) loop
3100 Formal
:= Extra_Formal
(Formal
);
3102 Write_Name_With_Col_Check
(Chars
(Formal
));
3104 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
3109 end Write_Param_Specs
;
3111 --------------------------
3112 -- Write_Rewrite_Str --
3113 --------------------------
3115 procedure Write_Rewrite_Str
(S
: String) is
3117 if not Dump_Generated_Only
then
3118 if S
'Length = 3 and then S
= ">>>" then
3121 Write_Str_With_Col_Check
(S
);
3124 end Write_Rewrite_Str
;
3126 --------------------
3127 -- Write_Str_Sloc --
3128 --------------------
3130 procedure Write_Str_Sloc
(S
: String) is
3132 for J
in S
'Range loop
3133 Write_Char_Sloc
(S
(J
));
3137 ------------------------------
3138 -- Write_Str_With_Col_Check --
3139 ------------------------------
3141 procedure Write_Str_With_Col_Check
(S
: String) is
3143 if Int
(S
'Last) + Column
> Line_Limit
then
3144 Write_Indent_Str
(" ");
3147 Write_Str
(S
(2 .. S
'Length));
3155 end Write_Str_With_Col_Check
;
3157 -----------------------------------
3158 -- Write_Str_With_Col_Check_Sloc --
3159 -----------------------------------
3161 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
3163 if Int
(S
'Last) + Column
> Line_Limit
then
3164 Write_Indent_Str
(" ");
3167 Write_Str_Sloc
(S
(2 .. S
'Length));
3175 end Write_Str_With_Col_Check_Sloc
;
3177 ------------------------------------
3178 -- Write_Uint_With_Col_Check_Sloc --
3179 ------------------------------------
3181 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
3183 Col_Check
(UI_Decimal_Digits_Hi
(U
));
3185 UI_Write
(U
, Format
);
3186 end Write_Uint_With_Col_Check_Sloc
;
3188 -------------------------------------
3189 -- Write_Ureal_With_Col_Check_Sloc --
3190 -------------------------------------
3192 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
3193 D
: constant Uint
:= Denominator
(U
);
3194 N
: constant Uint
:= Numerator
(U
);
3198 (UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
3201 end Write_Ureal_With_Col_Check_Sloc
;