1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2006, 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
;
32 with Fname
; use Fname
;
34 with Namet
; use Namet
;
35 with Nlists
; use Nlists
;
37 with Output
; use Output
;
38 with Rtsfind
; use Rtsfind
;
39 with 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_Generated_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
: constant 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 Note_Implicit_Run_Time_Call
(N
: Node_Id
);
155 -- N is the Name field of a function call or procedure statement call.
156 -- The effect of the call is to output a $ if the call is identified as
157 -- an implicit call to a run time routine.
159 procedure Print_Debug_Line
(S
: String);
160 -- Used to print output lines in Debug_Generated_Code mode (this is used
161 -- as the argument for a call to Set_Special_Output in package Output).
163 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
);
164 -- Given a divide, multiplication or division node, check the flags
165 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
166 -- appropriate special syntax characters (# and @).
168 procedure Set_Debug_Sloc
;
169 -- If Debug_Node is non-empty, this routine sets the appropriate value
170 -- in its Sloc field, from the current location in the debug source file
171 -- that is currently being written. Note that Debug_Node is always empty
172 -- if a debug source file is not being written.
174 procedure Sprint_And_List
(List
: List_Id
);
175 -- Print the given list with items separated by vertical "and"
177 procedure Sprint_Bar_List
(List
: List_Id
);
178 -- Print the given list with items separated by vertical bars
180 procedure Sprint_Node_Actual
(Node
: Node_Id
);
181 -- This routine prints its node argument. It is a lower level routine than
182 -- Sprint_Node, in that it does not bother about rewritten trees.
184 procedure Sprint_Node_Sloc
(Node
: Node_Id
);
185 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
186 -- sets the Sloc of the current debug node to be a copy of the Sloc
187 -- of the sprinted node Node. Note that this is done after printing
188 -- Node, so that the Sloc is the proper updated value for the debug file.
190 procedure Write_Char_Sloc
(C
: Character);
191 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
192 -- called to ensure that the current node has a proper Sloc set.
194 procedure Write_Condition_And_Reason
(Node
: Node_Id
);
195 -- Write Condition and Reason codes of Raise_xxx_Error node
197 procedure Write_Discr_Specs
(N
: Node_Id
);
198 -- Ouput discriminant specification for node, which is any of the type
199 -- declarations that can have discriminants.
201 procedure Write_Ekind
(E
: Entity_Id
);
202 -- Write the String corresponding to the Ekind without "E_"
204 procedure Write_Id
(N
: Node_Id
);
205 -- N is a node with a Chars field. This procedure writes the name that
206 -- will be used in the generated code associated with the name. For a
207 -- node with no associated entity, this is simply the Chars field. For
208 -- the case where there is an entity associated with the node, we print
209 -- the name associated with the entity (since it may have been encoded).
210 -- One other special case is that an entity has an active external name
211 -- (i.e. an external name present with no address clause), then this
212 -- external name is output. This procedure also deals with outputting
213 -- declarations of referenced itypes, if not output earlier.
215 function Write_Identifiers
(Node
: Node_Id
) return Boolean;
216 -- Handle node where the grammar has a list of defining identifiers, but
217 -- the tree has a separate declaration for each identifier. Handles the
218 -- printing of the defining identifier, and returns True if the type and
219 -- initialization information is to be printed, False if it is to be
220 -- skipped (the latter case happens when printing defining identifiers
221 -- other than the first in the original tree output case).
223 procedure Write_Implicit_Def
(E
: Entity_Id
);
224 pragma Warnings
(Off
, Write_Implicit_Def
);
225 -- Write the definition of the implicit type E according to its Ekind
226 -- For now a debugging procedure, but might be used in the future.
228 procedure Write_Indent
;
229 -- Start a new line and write indentation spacing
231 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean;
232 -- Like Write_Identifiers except that each new printed declaration
233 -- is at the start of a new line.
235 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean;
236 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
237 -- mode, the Sloc of the current debug node is set to point ot the
238 -- first output identifier.
240 procedure Write_Indent_Str
(S
: String);
241 -- Start a new line and write indent spacing followed by given string
243 procedure Write_Indent_Str_Sloc
(S
: String);
244 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
245 -- the Sloc of the current node is set to the first non-blank character
248 procedure Write_Itype
(Typ
: Entity_Id
);
249 -- If Typ is an Itype that has not been written yet, write it. If Typ is
250 -- any other kind of entity or tree node, the call is ignored.
252 procedure Write_Name_With_Col_Check
(N
: Name_Id
);
253 -- Write name (using Write_Name) with initial column check, and possible
254 -- initial Write_Indent (to get new line) if current line is too full.
256 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
);
257 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
258 -- mode, sets Sloc of current debug node to first character of name.
260 procedure Write_Operator
(N
: Node_Id
; S
: String);
261 -- Like Write_Str_Sloc, used for operators, encloses the string in
262 -- characters {} if the Do_Overflow flag is set on the node N.
264 procedure Write_Param_Specs
(N
: Node_Id
);
265 -- Output parameter specifications for node (which is either a function
266 -- or procedure specification with a Parameter_Specifications field)
268 procedure Write_Rewrite_Str
(S
: String);
269 -- Writes out a string (typically containing <<< or >>>}) for a node
270 -- created by rewriting the tree. Suppressed if we are outputting the
271 -- generated code only, since in this case we don't specially mark nodes
272 -- created by rewriting).
274 procedure Write_Str_Sloc
(S
: String);
275 -- Like Write_Str, but sets debug Sloc of current debug node to first
276 -- non-blank character if a current debug node is active.
278 procedure Write_Str_With_Col_Check
(S
: String);
279 -- Write string (using Write_Str) with initial column check, and possible
280 -- initial Write_Indent (to get new line) if current line is too full.
282 procedure Write_Str_With_Col_Check_Sloc
(S
: String);
283 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
284 -- node to first non-blank character if a current debug node is active.
286 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
);
287 -- Write Uint (using UI_Write) with initial column check, and possible
288 -- initial Write_Indent (to get new line) if current line is too full.
289 -- The format parameter determines the output format (see UI_Write).
291 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
);
292 -- Write Uint (using UI_Write) with initial column check, and possible
293 -- initial Write_Indent (to get new line) if current line is too full.
294 -- The format parameter determines the output format (see UI_Write).
295 -- In addition, in Debug_Generated_Code mode, sets the current node
296 -- Sloc to the first character of the output value.
298 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
);
299 -- Write Ureal (using same output format as UR_Write) with column checks
300 -- and a possible initial Write_Indent (to get new line) if current line
301 -- is too full. In addition, in Debug_Generated_Code mode, sets the
302 -- current node Sloc to the first character of the output value.
308 procedure Col_Check
(N
: Nat
) is
310 if N
+ Column
> Line_Limit
then
311 Write_Indent_Str
(" ");
319 procedure Indent_Annull
is
321 Indent_Annull_Flag
:= True;
328 procedure Indent_Begin
is
330 Indent
:= Indent
+ 3;
337 procedure Indent_End
is
339 Indent
:= Indent
- 3;
342 ---------------------------------
343 -- Note_Implicit_Run_Time_Call --
344 ---------------------------------
346 procedure Note_Implicit_Run_Time_Call
(N
: Node_Id
) is
348 if not Comes_From_Source
(N
)
349 and then Is_Entity_Name
(N
)
352 Ent
: constant Entity_Id
:= Entity
(N
);
354 if not In_Extended_Main_Source_Unit
(Ent
)
356 Is_Predefined_File_Name
357 (Unit_File_Name
(Get_Source_Unit
(Ent
)))
359 Col_Check
(Length_Of_Name
(Chars
(Ent
)));
364 end Note_Implicit_Run_Time_Call
;
370 procedure pg
(Node
: Node_Id
) is
372 Dump_Generated_Only
:= True;
373 Dump_Original_Only
:= False;
382 procedure po
(Node
: Node_Id
) is
384 Dump_Generated_Only
:= False;
385 Dump_Original_Only
:= True;
390 ----------------------
391 -- Print_Debug_Line --
392 ----------------------
394 procedure Print_Debug_Line
(S
: String) is
396 Write_Debug_Line
(S
, Debug_Sloc
);
397 end Print_Debug_Line
;
399 ---------------------------
400 -- Process_TFAI_RR_Flags --
401 ---------------------------
403 procedure Process_TFAI_RR_Flags
(Nod
: Node_Id
) is
405 if Treat_Fixed_As_Integer
(Nod
) then
409 if Rounded_Result
(Nod
) then
412 end Process_TFAI_RR_Flags
;
418 procedure ps
(Node
: Node_Id
) is
420 Dump_Generated_Only
:= False;
421 Dump_Original_Only
:= False;
430 procedure Set_Debug_Sloc
is
432 if Present
(Debug_Node
) then
433 Set_Sloc
(Debug_Node
, Debug_Sloc
+ Source_Ptr
(Column
- 1));
442 procedure Source_Dump
is
445 -- Put underline under string we just printed
447 procedure Underline
is
448 Col
: constant Int
:= Column
;
453 while Col
> Column
loop
460 -- Start of processing for Tree_Dump
463 Dump_Generated_Only
:= Debug_Flag_G
or
464 Print_Generated_Code
or
465 Debug_Generated_Code
;
466 Dump_Original_Only
:= Debug_Flag_O
;
467 Dump_Freeze_Null
:= Debug_Flag_S
or Debug_Flag_G
;
469 -- Note that we turn off the tree dump flags immediately, before
470 -- starting the dump. This avoids generating two copies of the dump
471 -- if an abort occurs after printing the dump, and more importantly,
472 -- avoids an infinite loop if an abort occurs during the dump.
475 Debug_Flag_Z
:= False;
478 Write_Str
("Source recreated from tree of Standard (spec)");
480 Sprint_Node
(Standard_Package_Node
);
485 if Debug_Flag_S
or Dump_Generated_Only
or Dump_Original_Only
then
486 Debug_Flag_G
:= False;
487 Debug_Flag_O
:= False;
488 Debug_Flag_S
:= False;
490 -- Dump requested units
492 for U
in Main_Unit
.. Last_Unit
loop
494 -- Dump all units if -gnatdf set, otherwise we dump only
495 -- the source files that are in the extended main source.
498 or else In_Extended_Main_Source_Unit
(Cunit_Entity
(U
))
500 -- If we are generating debug files, setup to write them
502 if Debug_Generated_Code
then
503 Set_Special_Output
(Print_Debug_Line
'Access);
504 Create_Debug_Source
(Source_Index
(U
), Debug_Sloc
);
505 Sprint_Node
(Cunit
(U
));
508 Set_Special_Output
(null);
510 -- Normal output to standard output file
513 Write_Str
("Source recreated from tree for ");
514 Write_Unit_Name
(Unit_Name
(U
));
516 Sprint_Node
(Cunit
(U
));
525 ---------------------
526 -- Sprint_And_List --
527 ---------------------
529 procedure Sprint_And_List
(List
: List_Id
) is
532 if Is_Non_Empty_List
(List
) then
533 Node
:= First
(List
);
537 exit when Node
= Empty
;
543 ---------------------
544 -- Sprint_Bar_List --
545 ---------------------
547 procedure Sprint_Bar_List
(List
: List_Id
) is
550 if Is_Non_Empty_List
(List
) then
551 Node
:= First
(List
);
555 exit when Node
= Empty
;
561 -----------------------
562 -- Sprint_Comma_List --
563 -----------------------
565 procedure Sprint_Comma_List
(List
: List_Id
) is
569 if Is_Non_Empty_List
(List
) then
570 Node
:= First
(List
);
574 exit when Node
= Empty
;
576 if not Is_Rewrite_Insertion
(Node
)
577 or else not Dump_Original_Only
583 end Sprint_Comma_List
;
585 --------------------------
586 -- Sprint_Indented_List --
587 --------------------------
589 procedure Sprint_Indented_List
(List
: List_Id
) is
592 Sprint_Node_List
(List
);
594 end Sprint_Indented_List
;
596 ---------------------
597 -- Sprint_Left_Opnd --
598 ---------------------
600 procedure Sprint_Left_Opnd
(N
: Node_Id
) is
601 Opnd
: constant Node_Id
:= Left_Opnd
(N
);
604 if Paren_Count
(Opnd
) /= 0
605 or else Op_Prec
(Nkind
(Opnd
)) >= Op_Prec
(Nkind
(N
))
614 end Sprint_Left_Opnd
;
620 procedure Sprint_Node
(Node
: Node_Id
) is
622 if Is_Rewrite_Insertion
(Node
) then
623 if not Dump_Original_Only
then
625 -- For special cases of nodes that always output <<< >>>
626 -- do not duplicate the output at this point.
628 if Nkind
(Node
) = N_Freeze_Entity
629 or else Nkind
(Node
) = N_Implicit_Label_Declaration
631 Sprint_Node_Actual
(Node
);
633 -- Normal case where <<< >>> may be required
636 Write_Rewrite_Str
("<<<");
637 Sprint_Node_Actual
(Node
);
638 Write_Rewrite_Str
(">>>");
642 elsif Is_Rewrite_Substitution
(Node
) then
644 -- Case of dump generated only
646 if Dump_Generated_Only
then
647 Sprint_Node_Actual
(Node
);
649 -- Case of dump original only
651 elsif Dump_Original_Only
then
652 Sprint_Node_Actual
(Original_Node
(Node
));
654 -- Case of both being dumped
657 Sprint_Node_Actual
(Original_Node
(Node
));
658 Write_Rewrite_Str
("<<<");
659 Sprint_Node_Actual
(Node
);
660 Write_Rewrite_Str
(">>>");
664 Sprint_Node_Actual
(Node
);
668 ------------------------
669 -- Sprint_Node_Actual --
670 ------------------------
672 procedure Sprint_Node_Actual
(Node
: Node_Id
) is
673 Save_Debug_Node
: constant Node_Id
:= Debug_Node
;
680 for J
in 1 .. Paren_Count
(Node
) loop
681 Write_Str_With_Col_Check
("(");
684 -- Setup node for Sloc fixup if writing a debug source file. Note
685 -- that we take care of any previous node not yet properly set.
687 if Debug_Generated_Code
then
691 if Nkind
(Node
) in N_Subexpr
692 and then Do_Range_Check
(Node
)
694 Write_Str_With_Col_Check
("{");
697 -- Select print circuit based on node kind
701 when N_Abort_Statement
=>
702 Write_Indent_Str_Sloc
("abort ");
703 Sprint_Comma_List
(Names
(Node
));
706 when N_Abortable_Part
=>
708 Write_Str_Sloc
("abort ");
709 Sprint_Indented_List
(Statements
(Node
));
711 when N_Abstract_Subprogram_Declaration
=>
713 Sprint_Node
(Specification
(Node
));
714 Write_Str_With_Col_Check
(" is ");
715 Write_Str_Sloc
("abstract;");
717 when N_Accept_Alternative
=>
718 Sprint_Node_List
(Pragmas_Before
(Node
));
720 if Present
(Condition
(Node
)) then
721 Write_Indent_Str
("when ");
722 Sprint_Node
(Condition
(Node
));
727 Sprint_Node_Sloc
(Accept_Statement
(Node
));
728 Sprint_Node_List
(Statements
(Node
));
730 when N_Accept_Statement
=>
731 Write_Indent_Str_Sloc
("accept ");
732 Write_Id
(Entry_Direct_Name
(Node
));
734 if Present
(Entry_Index
(Node
)) then
735 Write_Str_With_Col_Check
(" (");
736 Sprint_Node
(Entry_Index
(Node
));
740 Write_Param_Specs
(Node
);
742 if Present
(Handled_Statement_Sequence
(Node
)) then
743 Write_Str_With_Col_Check
(" do");
744 Sprint_Node
(Handled_Statement_Sequence
(Node
));
745 Write_Indent_Str
("end ");
746 Write_Id
(Entry_Direct_Name
(Node
));
751 when N_Access_Definition
=>
755 if Present
(Access_To_Subprogram_Definition
(Node
)) then
756 Sprint_Node
(Access_To_Subprogram_Definition
(Node
));
760 if Null_Exclusion_Present
(Node
) then
761 Write_Str
("not null ");
764 Write_Str_With_Col_Check_Sloc
("access ");
766 if All_Present
(Node
) then
768 elsif Constant_Present
(Node
) then
769 Write_Str
("constant ");
772 Sprint_Node
(Subtype_Mark
(Node
));
775 when N_Access_Function_Definition
=>
779 if Null_Exclusion_Present
(Node
) then
780 Write_Str
("not null ");
783 Write_Str_With_Col_Check_Sloc
("access ");
785 if Protected_Present
(Node
) then
786 Write_Str_With_Col_Check
("protected ");
789 Write_Str_With_Col_Check
("function");
790 Write_Param_Specs
(Node
);
791 Write_Str_With_Col_Check
(" return ");
792 Sprint_Node
(Result_Definition
(Node
));
794 when N_Access_Procedure_Definition
=>
798 if Null_Exclusion_Present
(Node
) then
799 Write_Str
("not null ");
802 Write_Str_With_Col_Check_Sloc
("access ");
804 if Protected_Present
(Node
) then
805 Write_Str_With_Col_Check
("protected ");
808 Write_Str_With_Col_Check
("procedure");
809 Write_Param_Specs
(Node
);
811 when N_Access_To_Object_Definition
=>
812 Write_Str_With_Col_Check_Sloc
("access ");
814 if All_Present
(Node
) then
815 Write_Str_With_Col_Check
("all ");
816 elsif Constant_Present
(Node
) then
817 Write_Str_With_Col_Check
("constant ");
822 if Null_Exclusion_Present
(Node
) then
823 Write_Str
("not null ");
826 Sprint_Node
(Subtype_Indication
(Node
));
829 if Null_Record_Present
(Node
) then
830 Write_Str_With_Col_Check_Sloc
("(null record)");
833 Write_Str_With_Col_Check_Sloc
("(");
835 if Present
(Expressions
(Node
)) then
836 Sprint_Comma_List
(Expressions
(Node
));
838 if Present
(Component_Associations
(Node
)) then
843 if Present
(Component_Associations
(Node
)) then
850 Nd
:= First
(Component_Associations
(Node
));
858 if not Is_Rewrite_Insertion
(Nd
)
859 or else not Dump_Original_Only
873 Write_Str_With_Col_Check_Sloc
("new ");
877 if Null_Exclusion_Present
(Node
) then
878 Write_Str
("not null ");
881 Sprint_Node
(Expression
(Node
));
883 if Present
(Storage_Pool
(Node
)) then
884 Write_Str_With_Col_Check
("[storage_pool = ");
885 Sprint_Node
(Storage_Pool
(Node
));
890 Sprint_Left_Opnd
(Node
);
891 Write_Str_Sloc
(" and then ");
892 Sprint_Right_Opnd
(Node
);
895 Write_Indent_Str_Sloc
("for ");
896 Write_Id
(Identifier
(Node
));
897 Write_Str_With_Col_Check
(" use at ");
898 Sprint_Node
(Expression
(Node
));
901 when N_Assignment_Statement
=>
903 Sprint_Node
(Name
(Node
));
904 Write_Str_Sloc
(" := ");
905 Sprint_Node
(Expression
(Node
));
908 when N_Asynchronous_Select
=>
909 Write_Indent_Str_Sloc
("select");
911 Sprint_Node
(Triggering_Alternative
(Node
));
914 -- Note: let the printing of Abortable_Part handle outputting
915 -- the ABORT keyword, so that the Slco can be set correctly.
917 Write_Indent_Str
("then ");
918 Sprint_Node
(Abortable_Part
(Node
));
919 Write_Indent_Str
("end select;");
921 when N_Attribute_Definition_Clause
=>
922 Write_Indent_Str_Sloc
("for ");
923 Sprint_Node
(Name
(Node
));
925 Write_Name_With_Col_Check
(Chars
(Node
));
926 Write_Str_With_Col_Check
(" use ");
927 Sprint_Node
(Expression
(Node
));
930 when N_Attribute_Reference
=>
931 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
935 Sprint_Node
(Prefix
(Node
));
936 Write_Char_Sloc
(''');
937 Write_Name_With_Col_Check
(Attribute_Name
(Node
));
938 Sprint_Paren_Comma_List
(Expressions
(Node
));
940 if Is_Procedure_Attribute_Name
(Attribute_Name
(Node
)) then
944 when N_Block_Statement
=>
947 if Present
(Identifier
(Node
))
948 and then (not Has_Created_Identifier
(Node
)
949 or else not Dump_Original_Only
)
951 Write_Rewrite_Str
("<<<");
952 Write_Id
(Identifier
(Node
));
954 Write_Rewrite_Str
(">>>");
957 if Present
(Declarations
(Node
)) then
958 Write_Str_With_Col_Check_Sloc
("declare");
959 Sprint_Indented_List
(Declarations
(Node
));
963 Write_Str_With_Col_Check_Sloc
("begin");
964 Sprint_Node
(Handled_Statement_Sequence
(Node
));
965 Write_Indent_Str
("end");
967 if Present
(Identifier
(Node
))
968 and then (not Has_Created_Identifier
(Node
)
969 or else not Dump_Original_Only
)
971 Write_Rewrite_Str
("<<<");
973 Write_Id
(Identifier
(Node
));
974 Write_Rewrite_Str
(">>>");
979 when N_Case_Statement
=>
980 Write_Indent_Str_Sloc
("case ");
981 Sprint_Node
(Expression
(Node
));
983 Sprint_Indented_List
(Alternatives
(Node
));
984 Write_Indent_Str
("end case;");
986 when N_Case_Statement_Alternative
=>
987 Write_Indent_Str_Sloc
("when ");
988 Sprint_Bar_List
(Discrete_Choices
(Node
));
990 Sprint_Indented_List
(Statements
(Node
));
992 when N_Character_Literal
=>
994 Write_Indent_Str
(" ");
997 Write_Char_Sloc
(''');
998 Write_Char_Code
(UI_To_CC
(Char_Literal_Value
(Node
)));
1001 when N_Code_Statement
=>
1004 Sprint_Node
(Expression
(Node
));
1007 when N_Compilation_Unit
=>
1008 Sprint_Node_List
(Context_Items
(Node
));
1009 Sprint_Opt_Node_List
(Declarations
(Aux_Decls_Node
(Node
)));
1011 if Private_Present
(Node
) then
1012 Write_Indent_Str
("private ");
1016 Sprint_Node_Sloc
(Unit
(Node
));
1018 if Present
(Actions
(Aux_Decls_Node
(Node
)))
1020 Present
(Pragmas_After
(Aux_Decls_Node
(Node
)))
1025 Sprint_Opt_Node_List
(Actions
(Aux_Decls_Node
(Node
)));
1026 Sprint_Opt_Node_List
(Pragmas_After
(Aux_Decls_Node
(Node
)));
1028 when N_Compilation_Unit_Aux
=>
1029 null; -- nothing to do, never used, see above
1031 when N_Component_Association
=>
1033 Sprint_Bar_List
(Choices
(Node
));
1036 -- Ada 2005 (AI-287): Print the box if present
1038 if Box_Present
(Node
) then
1039 Write_Str_With_Col_Check
("<>");
1041 Sprint_Node
(Expression
(Node
));
1044 when N_Component_Clause
=>
1046 Sprint_Node
(Component_Name
(Node
));
1047 Write_Str_Sloc
(" at ");
1048 Sprint_Node
(Position
(Node
));
1050 Write_Str_With_Col_Check
("range ");
1051 Sprint_Node
(First_Bit
(Node
));
1053 Sprint_Node
(Last_Bit
(Node
));
1056 when N_Component_Definition
=>
1059 -- Ada 2005 (AI-230): Access definition components
1061 if Present
(Access_Definition
(Node
)) then
1062 Sprint_Node
(Access_Definition
(Node
));
1064 elsif Present
(Subtype_Indication
(Node
)) then
1065 if Aliased_Present
(Node
) then
1066 Write_Str_With_Col_Check
("aliased ");
1069 -- Ada 2005 (AI-231)
1071 if Null_Exclusion_Present
(Node
) then
1072 Write_Str
(" not null ");
1075 Sprint_Node
(Subtype_Indication
(Node
));
1078 Write_Str
(" ??? ");
1081 when N_Component_Declaration
=>
1082 if Write_Indent_Identifiers_Sloc
(Node
) then
1084 Sprint_Node
(Component_Definition
(Node
));
1086 if Present
(Expression
(Node
)) then
1088 Sprint_Node
(Expression
(Node
));
1094 when N_Component_List
=>
1095 if Null_Present
(Node
) then
1097 Write_Indent_Str_Sloc
("null");
1103 Sprint_Indented_List
(Component_Items
(Node
));
1104 Sprint_Node
(Variant_Part
(Node
));
1107 when N_Conditional_Entry_Call
=>
1108 Write_Indent_Str_Sloc
("select");
1110 Sprint_Node
(Entry_Call_Alternative
(Node
));
1112 Write_Indent_Str
("else");
1113 Sprint_Indented_List
(Else_Statements
(Node
));
1114 Write_Indent_Str
("end select;");
1116 when N_Conditional_Expression
=>
1118 Condition
: constant Node_Id
:= First
(Expressions
(Node
));
1119 Then_Expr
: constant Node_Id
:= Next
(Condition
);
1120 Else_Expr
: constant Node_Id
:= Next
(Then_Expr
);
1122 Write_Str_With_Col_Check_Sloc
("(if ");
1123 Sprint_Node
(Condition
);
1124 Write_Str_With_Col_Check
(" then ");
1125 Sprint_Node
(Then_Expr
);
1126 Write_Str_With_Col_Check
(" else ");
1127 Sprint_Node
(Else_Expr
);
1131 when N_Constrained_Array_Definition
=>
1132 Write_Str_With_Col_Check_Sloc
("array ");
1133 Sprint_Paren_Comma_List
(Discrete_Subtype_Definitions
(Node
));
1136 Sprint_Node
(Component_Definition
(Node
));
1138 when N_Decimal_Fixed_Point_Definition
=>
1139 Write_Str_With_Col_Check_Sloc
(" delta ");
1140 Sprint_Node
(Delta_Expression
(Node
));
1141 Write_Str_With_Col_Check
("digits ");
1142 Sprint_Node
(Digits_Expression
(Node
));
1143 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1145 when N_Defining_Character_Literal
=>
1146 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1148 when N_Defining_Identifier
=>
1152 when N_Defining_Operator_Symbol
=>
1153 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
1155 when N_Defining_Program_Unit_Name
=>
1157 Sprint_Node
(Name
(Node
));
1159 Write_Id
(Defining_Identifier
(Node
));
1161 when N_Delay_Alternative
=>
1162 Sprint_Node_List
(Pragmas_Before
(Node
));
1164 if Present
(Condition
(Node
)) then
1166 Write_Str_With_Col_Check
("when ");
1167 Sprint_Node
(Condition
(Node
));
1172 Sprint_Node_Sloc
(Delay_Statement
(Node
));
1173 Sprint_Node_List
(Statements
(Node
));
1175 when N_Delay_Relative_Statement
=>
1176 Write_Indent_Str_Sloc
("delay ");
1177 Sprint_Node
(Expression
(Node
));
1180 when N_Delay_Until_Statement
=>
1181 Write_Indent_Str_Sloc
("delay until ");
1182 Sprint_Node
(Expression
(Node
));
1185 when N_Delta_Constraint
=>
1186 Write_Str_With_Col_Check_Sloc
("delta ");
1187 Sprint_Node
(Delta_Expression
(Node
));
1188 Sprint_Opt_Node
(Range_Constraint
(Node
));
1190 when N_Derived_Type_Definition
=>
1191 if Abstract_Present
(Node
) then
1192 Write_Str_With_Col_Check
("abstract ");
1195 Write_Str_With_Col_Check_Sloc
("new ");
1197 -- Ada 2005 (AI-231)
1199 if Null_Exclusion_Present
(Node
) then
1200 Write_Str_With_Col_Check
("not null ");
1203 Sprint_Node
(Subtype_Indication
(Node
));
1205 if Present
(Interface_List
(Node
)) then
1206 Sprint_And_List
(Interface_List
(Node
));
1207 Write_Str_With_Col_Check
(" with ");
1210 if Present
(Record_Extension_Part
(Node
)) then
1211 if No
(Interface_List
(Node
)) then
1212 Write_Str_With_Col_Check
(" with ");
1215 Sprint_Node
(Record_Extension_Part
(Node
));
1218 when N_Designator
=>
1219 Sprint_Node
(Name
(Node
));
1220 Write_Char_Sloc
('.');
1221 Write_Id
(Identifier
(Node
));
1223 when N_Digits_Constraint
=>
1224 Write_Str_With_Col_Check_Sloc
("digits ");
1225 Sprint_Node
(Digits_Expression
(Node
));
1226 Sprint_Opt_Node
(Range_Constraint
(Node
));
1228 when N_Discriminant_Association
=>
1231 if Present
(Selector_Names
(Node
)) then
1232 Sprint_Bar_List
(Selector_Names
(Node
));
1237 Sprint_Node
(Expression
(Node
));
1239 when N_Discriminant_Specification
=>
1242 if Write_Identifiers
(Node
) then
1245 if Null_Exclusion_Present
(Node
) then
1246 Write_Str
("not null ");
1249 Sprint_Node
(Discriminant_Type
(Node
));
1251 if Present
(Expression
(Node
)) then
1253 Sprint_Node
(Expression
(Node
));
1259 when N_Elsif_Part
=>
1260 Write_Indent_Str_Sloc
("elsif ");
1261 Sprint_Node
(Condition
(Node
));
1262 Write_Str_With_Col_Check
(" then");
1263 Sprint_Indented_List
(Then_Statements
(Node
));
1268 when N_Entry_Body
=>
1269 Write_Indent_Str_Sloc
("entry ");
1270 Write_Id
(Defining_Identifier
(Node
));
1271 Sprint_Node
(Entry_Body_Formal_Part
(Node
));
1272 Write_Str_With_Col_Check
(" is");
1273 Sprint_Indented_List
(Declarations
(Node
));
1274 Write_Indent_Str
("begin");
1275 Sprint_Node
(Handled_Statement_Sequence
(Node
));
1276 Write_Indent_Str
("end ");
1277 Write_Id
(Defining_Identifier
(Node
));
1280 when N_Entry_Body_Formal_Part
=>
1281 if Present
(Entry_Index_Specification
(Node
)) then
1282 Write_Str_With_Col_Check_Sloc
(" (");
1283 Sprint_Node
(Entry_Index_Specification
(Node
));
1287 Write_Param_Specs
(Node
);
1288 Write_Str_With_Col_Check_Sloc
(" when ");
1289 Sprint_Node
(Condition
(Node
));
1291 when N_Entry_Call_Alternative
=>
1292 Sprint_Node_List
(Pragmas_Before
(Node
));
1293 Sprint_Node_Sloc
(Entry_Call_Statement
(Node
));
1294 Sprint_Node_List
(Statements
(Node
));
1296 when N_Entry_Call_Statement
=>
1298 Sprint_Node_Sloc
(Name
(Node
));
1299 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1302 when N_Entry_Declaration
=>
1303 Write_Indent_Str_Sloc
("entry ");
1304 Write_Id
(Defining_Identifier
(Node
));
1306 if Present
(Discrete_Subtype_Definition
(Node
)) then
1307 Write_Str_With_Col_Check
(" (");
1308 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1312 Write_Param_Specs
(Node
);
1315 when N_Entry_Index_Specification
=>
1316 Write_Str_With_Col_Check_Sloc
("for ");
1317 Write_Id
(Defining_Identifier
(Node
));
1318 Write_Str_With_Col_Check
(" in ");
1319 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1321 when N_Enumeration_Representation_Clause
=>
1322 Write_Indent_Str_Sloc
("for ");
1323 Write_Id
(Identifier
(Node
));
1324 Write_Str_With_Col_Check
(" use ");
1325 Sprint_Node
(Array_Aggregate
(Node
));
1328 when N_Enumeration_Type_Definition
=>
1331 -- Skip attempt to print Literals field if it's not there and
1332 -- we are in package Standard (case of Character, which is
1333 -- handled specially (without an explicit literals list).
1335 if Sloc
(Node
) > Standard_Location
1336 or else Present
(Literals
(Node
))
1338 Sprint_Paren_Comma_List
(Literals
(Node
));
1342 Write_Str_With_Col_Check_Sloc
("<error>");
1344 when N_Exception_Declaration
=>
1345 if Write_Indent_Identifiers
(Node
) then
1346 Write_Str_With_Col_Check
(" : ");
1347 Write_Str_Sloc
("exception;");
1350 when N_Exception_Handler
=>
1351 Write_Indent_Str_Sloc
("when ");
1353 if Present
(Choice_Parameter
(Node
)) then
1354 Sprint_Node
(Choice_Parameter
(Node
));
1358 Sprint_Bar_List
(Exception_Choices
(Node
));
1360 Sprint_Indented_List
(Statements
(Node
));
1362 when N_Exception_Renaming_Declaration
=>
1365 Sprint_Node
(Defining_Identifier
(Node
));
1366 Write_Str_With_Col_Check
(" : exception renames ");
1367 Sprint_Node
(Name
(Node
));
1370 when N_Exit_Statement
=>
1371 Write_Indent_Str_Sloc
("exit");
1372 Sprint_Opt_Node
(Name
(Node
));
1374 if Present
(Condition
(Node
)) then
1375 Write_Str_With_Col_Check
(" when ");
1376 Sprint_Node
(Condition
(Node
));
1381 when N_Expanded_Name
=>
1382 Sprint_Node
(Prefix
(Node
));
1383 Write_Char_Sloc
('.');
1384 Sprint_Node
(Selector_Name
(Node
));
1386 when N_Explicit_Dereference
=>
1387 Sprint_Node
(Prefix
(Node
));
1388 Write_Char_Sloc
('.');
1389 Write_Str_Sloc
("all");
1391 when N_Extension_Aggregate
=>
1392 Write_Str_With_Col_Check_Sloc
("(");
1393 Sprint_Node
(Ancestor_Part
(Node
));
1394 Write_Str_With_Col_Check
(" with ");
1396 if Null_Record_Present
(Node
) then
1397 Write_Str_With_Col_Check
("null record");
1399 if Present
(Expressions
(Node
)) then
1400 Sprint_Comma_List
(Expressions
(Node
));
1402 if Present
(Component_Associations
(Node
)) then
1407 if Present
(Component_Associations
(Node
)) then
1408 Sprint_Comma_List
(Component_Associations
(Node
));
1414 when N_Floating_Point_Definition
=>
1415 Write_Str_With_Col_Check_Sloc
("digits ");
1416 Sprint_Node
(Digits_Expression
(Node
));
1417 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
1419 when N_Formal_Decimal_Fixed_Point_Definition
=>
1420 Write_Str_With_Col_Check_Sloc
("delta <> digits <>");
1422 when N_Formal_Derived_Type_Definition
=>
1423 Write_Str_With_Col_Check_Sloc
("new ");
1424 Sprint_Node
(Subtype_Mark
(Node
));
1426 if Private_Present
(Node
) then
1427 Write_Str_With_Col_Check
(" with private");
1430 when N_Formal_Abstract_Subprogram_Declaration
=>
1431 Write_Indent_Str_Sloc
("with ");
1432 Sprint_Node
(Specification
(Node
));
1434 Write_Str_With_Col_Check
(" is abstract");
1436 if Box_Present
(Node
) then
1437 Write_Str_With_Col_Check
(" <>");
1438 elsif Present
(Default_Name
(Node
)) then
1439 Write_Str_With_Col_Check
(" ");
1440 Sprint_Node
(Default_Name
(Node
));
1445 when N_Formal_Concrete_Subprogram_Declaration
=>
1446 Write_Indent_Str_Sloc
("with ");
1447 Sprint_Node
(Specification
(Node
));
1449 if Box_Present
(Node
) then
1450 Write_Str_With_Col_Check
(" is <>");
1451 elsif Present
(Default_Name
(Node
)) then
1452 Write_Str_With_Col_Check
(" is ");
1453 Sprint_Node
(Default_Name
(Node
));
1458 when N_Formal_Discrete_Type_Definition
=>
1459 Write_Str_With_Col_Check_Sloc
("<>");
1461 when N_Formal_Floating_Point_Definition
=>
1462 Write_Str_With_Col_Check_Sloc
("digits <>");
1464 when N_Formal_Modular_Type_Definition
=>
1465 Write_Str_With_Col_Check_Sloc
("mod <>");
1467 when N_Formal_Object_Declaration
=>
1470 if Write_Indent_Identifiers
(Node
) then
1473 if In_Present
(Node
) then
1474 Write_Str_With_Col_Check
("in ");
1477 if Out_Present
(Node
) then
1478 Write_Str_With_Col_Check
("out ");
1481 Sprint_Node
(Subtype_Mark
(Node
));
1483 if Present
(Expression
(Node
)) then
1485 Sprint_Node
(Expression
(Node
));
1491 when N_Formal_Ordinary_Fixed_Point_Definition
=>
1492 Write_Str_With_Col_Check_Sloc
("delta <>");
1494 when N_Formal_Package_Declaration
=>
1495 Write_Indent_Str_Sloc
("with package ");
1496 Write_Id
(Defining_Identifier
(Node
));
1497 Write_Str_With_Col_Check
(" is new ");
1498 Sprint_Node
(Name
(Node
));
1499 Write_Str_With_Col_Check
(" (<>);");
1501 when N_Formal_Private_Type_Definition
=>
1502 if Abstract_Present
(Node
) then
1503 Write_Str_With_Col_Check
("abstract ");
1506 if Tagged_Present
(Node
) then
1507 Write_Str_With_Col_Check
("tagged ");
1510 if Limited_Present
(Node
) then
1511 Write_Str_With_Col_Check
("limited ");
1514 Write_Str_With_Col_Check_Sloc
("private");
1516 when N_Formal_Signed_Integer_Type_Definition
=>
1517 Write_Str_With_Col_Check_Sloc
("range <>");
1519 when N_Formal_Type_Declaration
=>
1520 Write_Indent_Str_Sloc
("type ");
1521 Write_Id
(Defining_Identifier
(Node
));
1523 if Present
(Discriminant_Specifications
(Node
)) then
1524 Write_Discr_Specs
(Node
);
1525 elsif Unknown_Discriminants_Present
(Node
) then
1526 Write_Str_With_Col_Check
("(<>)");
1529 Write_Str_With_Col_Check
(" is ");
1530 Sprint_Node
(Formal_Type_Definition
(Node
));
1533 when N_Free_Statement
=>
1534 Write_Indent_Str_Sloc
("free ");
1535 Sprint_Node
(Expression
(Node
));
1538 when N_Freeze_Entity
=>
1539 if Dump_Original_Only
then
1542 elsif Present
(Actions
(Node
)) or else Dump_Freeze_Null
then
1544 Write_Rewrite_Str
("<<<");
1545 Write_Str_With_Col_Check_Sloc
("freeze ");
1546 Write_Id
(Entity
(Node
));
1549 if No
(Actions
(Node
)) then
1553 Freeze_Indent
:= Freeze_Indent
+ 1;
1554 Sprint_Indented_List
(Actions
(Node
));
1555 Freeze_Indent
:= Freeze_Indent
- 1;
1556 Write_Indent_Str
("]");
1559 Write_Rewrite_Str
(">>>");
1562 when N_Full_Type_Declaration
=>
1563 Write_Indent_Str_Sloc
("type ");
1564 Write_Id
(Defining_Identifier
(Node
));
1565 Write_Discr_Specs
(Node
);
1566 Write_Str_With_Col_Check
(" is ");
1567 Sprint_Node
(Type_Definition
(Node
));
1570 when N_Function_Call
=>
1572 Note_Implicit_Run_Time_Call
(Name
(Node
));
1573 Sprint_Node
(Name
(Node
));
1574 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
1576 when N_Function_Instantiation
=>
1577 Write_Indent_Str_Sloc
("function ");
1578 Sprint_Node
(Defining_Unit_Name
(Node
));
1579 Write_Str_With_Col_Check
(" is new ");
1580 Sprint_Node
(Name
(Node
));
1581 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
1584 when N_Function_Specification
=>
1585 Write_Str_With_Col_Check_Sloc
("function ");
1586 Sprint_Node
(Defining_Unit_Name
(Node
));
1587 Write_Param_Specs
(Node
);
1588 Write_Str_With_Col_Check
(" return ");
1590 -- Ada 2005 (AI-231)
1592 if Nkind
(Result_Definition
(Node
)) /= N_Access_Definition
1593 and then Null_Exclusion_Present
(Node
)
1595 Write_Str
(" not null ");
1598 Sprint_Node
(Result_Definition
(Node
));
1600 when N_Generic_Association
=>
1603 if Present
(Selector_Name
(Node
)) then
1604 Sprint_Node
(Selector_Name
(Node
));
1608 Sprint_Node
(Explicit_Generic_Actual_Parameter
(Node
));
1610 when N_Generic_Function_Renaming_Declaration
=>
1611 Write_Indent_Str_Sloc
("generic function ");
1612 Sprint_Node
(Defining_Unit_Name
(Node
));
1613 Write_Str_With_Col_Check
(" renames ");
1614 Sprint_Node
(Name
(Node
));
1617 when N_Generic_Package_Declaration
=>
1619 Write_Indent_Str_Sloc
("generic ");
1620 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1622 Sprint_Node
(Specification
(Node
));
1625 when N_Generic_Package_Renaming_Declaration
=>
1626 Write_Indent_Str_Sloc
("generic package ");
1627 Sprint_Node
(Defining_Unit_Name
(Node
));
1628 Write_Str_With_Col_Check
(" renames ");
1629 Sprint_Node
(Name
(Node
));
1632 when N_Generic_Procedure_Renaming_Declaration
=>
1633 Write_Indent_Str_Sloc
("generic procedure ");
1634 Sprint_Node
(Defining_Unit_Name
(Node
));
1635 Write_Str_With_Col_Check
(" renames ");
1636 Sprint_Node
(Name
(Node
));
1639 when N_Generic_Subprogram_Declaration
=>
1641 Write_Indent_Str_Sloc
("generic ");
1642 Sprint_Indented_List
(Generic_Formal_Declarations
(Node
));
1644 Sprint_Node
(Specification
(Node
));
1647 when N_Goto_Statement
=>
1648 Write_Indent_Str_Sloc
("goto ");
1649 Sprint_Node
(Name
(Node
));
1652 if Nkind
(Next
(Node
)) = N_Label
then
1656 when N_Handled_Sequence_Of_Statements
=>
1658 Sprint_Indented_List
(Statements
(Node
));
1660 if Present
(Exception_Handlers
(Node
)) then
1661 Write_Indent_Str
("exception");
1663 Sprint_Node_List
(Exception_Handlers
(Node
));
1667 if Present
(At_End_Proc
(Node
)) then
1668 Write_Indent_Str
("at end");
1671 Sprint_Node
(At_End_Proc
(Node
));
1676 when N_Identifier
=>
1680 when N_If_Statement
=>
1681 Write_Indent_Str_Sloc
("if ");
1682 Sprint_Node
(Condition
(Node
));
1683 Write_Str_With_Col_Check
(" then");
1684 Sprint_Indented_List
(Then_Statements
(Node
));
1685 Sprint_Opt_Node_List
(Elsif_Parts
(Node
));
1687 if Present
(Else_Statements
(Node
)) then
1688 Write_Indent_Str
("else");
1689 Sprint_Indented_List
(Else_Statements
(Node
));
1692 Write_Indent_Str
("end if;");
1694 when N_Implicit_Label_Declaration
=>
1695 if not Dump_Original_Only
then
1697 Write_Rewrite_Str
("<<<");
1699 Write_Id
(Defining_Identifier
(Node
));
1701 Write_Str_With_Col_Check
("label");
1702 Write_Rewrite_Str
(">>>");
1706 Sprint_Left_Opnd
(Node
);
1707 Write_Str_Sloc
(" in ");
1708 Sprint_Right_Opnd
(Node
);
1710 when N_Incomplete_Type_Declaration
=>
1711 Write_Indent_Str_Sloc
("type ");
1712 Write_Id
(Defining_Identifier
(Node
));
1714 if Present
(Discriminant_Specifications
(Node
)) then
1715 Write_Discr_Specs
(Node
);
1716 elsif Unknown_Discriminants_Present
(Node
) then
1717 Write_Str_With_Col_Check
("(<>)");
1722 when N_Index_Or_Discriminant_Constraint
=>
1724 Sprint_Paren_Comma_List
(Constraints
(Node
));
1726 when N_Indexed_Component
=>
1727 Sprint_Node_Sloc
(Prefix
(Node
));
1728 Sprint_Opt_Paren_Comma_List
(Expressions
(Node
));
1730 when N_Integer_Literal
=>
1731 if Print_In_Hex
(Node
) then
1732 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Hex
);
1734 Write_Uint_With_Col_Check_Sloc
(Intval
(Node
), Auto
);
1737 when N_Iteration_Scheme
=>
1738 if Present
(Condition
(Node
)) then
1739 Write_Str_With_Col_Check_Sloc
("while ");
1740 Sprint_Node
(Condition
(Node
));
1742 Write_Str_With_Col_Check_Sloc
("for ");
1743 Sprint_Node
(Loop_Parameter_Specification
(Node
));
1748 when N_Itype_Reference
=>
1749 Write_Indent_Str_Sloc
("reference ");
1750 Write_Id
(Itype
(Node
));
1753 Write_Indent_Str_Sloc
("<<");
1754 Write_Id
(Identifier
(Node
));
1757 when N_Loop_Parameter_Specification
=>
1759 Write_Id
(Defining_Identifier
(Node
));
1760 Write_Str_With_Col_Check
(" in ");
1762 if Reverse_Present
(Node
) then
1763 Write_Str_With_Col_Check
("reverse ");
1766 Sprint_Node
(Discrete_Subtype_Definition
(Node
));
1768 when N_Loop_Statement
=>
1771 if Present
(Identifier
(Node
))
1772 and then (not Has_Created_Identifier
(Node
)
1773 or else not Dump_Original_Only
)
1775 Write_Rewrite_Str
("<<<");
1776 Write_Id
(Identifier
(Node
));
1778 Write_Rewrite_Str
(">>>");
1779 Sprint_Node
(Iteration_Scheme
(Node
));
1780 Write_Str_With_Col_Check_Sloc
("loop");
1781 Sprint_Indented_List
(Statements
(Node
));
1782 Write_Indent_Str
("end loop ");
1783 Write_Rewrite_Str
("<<<");
1784 Write_Id
(Identifier
(Node
));
1785 Write_Rewrite_Str
(">>>");
1789 Sprint_Node
(Iteration_Scheme
(Node
));
1790 Write_Str_With_Col_Check_Sloc
("loop");
1791 Sprint_Indented_List
(Statements
(Node
));
1792 Write_Indent_Str
("end loop;");
1795 when N_Mod_Clause
=>
1796 Sprint_Node_List
(Pragmas_Before
(Node
));
1797 Write_Str_With_Col_Check_Sloc
("at mod ");
1798 Sprint_Node
(Expression
(Node
));
1800 when N_Modular_Type_Definition
=>
1801 Write_Str_With_Col_Check_Sloc
("mod ");
1802 Sprint_Node
(Expression
(Node
));
1805 Sprint_Left_Opnd
(Node
);
1806 Write_Str_Sloc
(" not in ");
1807 Sprint_Right_Opnd
(Node
);
1810 Write_Str_With_Col_Check_Sloc
("null");
1812 when N_Null_Statement
=>
1813 if Comes_From_Source
(Node
)
1814 or else Dump_Freeze_Null
1815 or else not Is_List_Member
(Node
)
1816 or else (No
(Prev
(Node
)) and then No
(Next
(Node
)))
1818 Write_Indent_Str_Sloc
("null;");
1821 when N_Number_Declaration
=>
1824 if Write_Indent_Identifiers
(Node
) then
1825 Write_Str_With_Col_Check
(" : constant ");
1827 Sprint_Node
(Expression
(Node
));
1831 when N_Object_Declaration
=>
1834 if Write_Indent_Identifiers
(Node
) then
1837 if Aliased_Present
(Node
) then
1838 Write_Str_With_Col_Check
("aliased ");
1841 if Constant_Present
(Node
) then
1842 Write_Str_With_Col_Check
("constant ");
1845 -- Ada 2005 (AI-231)
1847 if Null_Exclusion_Present
(Node
) then
1848 Write_Str_With_Col_Check
("not null ");
1851 Sprint_Node
(Object_Definition
(Node
));
1853 if Present
(Expression
(Node
)) then
1855 Sprint_Node
(Expression
(Node
));
1861 when N_Object_Renaming_Declaration
=>
1864 Sprint_Node
(Defining_Identifier
(Node
));
1867 -- Ada 2005 (AI-230): Access renamings
1869 if Present
(Access_Definition
(Node
)) then
1870 Sprint_Node
(Access_Definition
(Node
));
1872 elsif Present
(Subtype_Mark
(Node
)) then
1873 Sprint_Node
(Subtype_Mark
(Node
));
1876 Write_Str
(" ??? ");
1879 Write_Str_With_Col_Check
(" renames ");
1880 Sprint_Node
(Name
(Node
));
1884 Write_Operator
(Node
, "abs ");
1885 Sprint_Right_Opnd
(Node
);
1888 Sprint_Left_Opnd
(Node
);
1889 Write_Operator
(Node
, " + ");
1890 Sprint_Right_Opnd
(Node
);
1893 Sprint_Left_Opnd
(Node
);
1894 Write_Operator
(Node
, " and ");
1895 Sprint_Right_Opnd
(Node
);
1898 Sprint_Left_Opnd
(Node
);
1899 Write_Operator
(Node
, " & ");
1900 Sprint_Right_Opnd
(Node
);
1903 Sprint_Left_Opnd
(Node
);
1905 Process_TFAI_RR_Flags
(Node
);
1906 Write_Operator
(Node
, "/ ");
1907 Sprint_Right_Opnd
(Node
);
1910 Sprint_Left_Opnd
(Node
);
1911 Write_Operator
(Node
, " = ");
1912 Sprint_Right_Opnd
(Node
);
1915 Sprint_Left_Opnd
(Node
);
1916 Write_Operator
(Node
, " ** ");
1917 Sprint_Right_Opnd
(Node
);
1920 Sprint_Left_Opnd
(Node
);
1921 Write_Operator
(Node
, " >= ");
1922 Sprint_Right_Opnd
(Node
);
1925 Sprint_Left_Opnd
(Node
);
1926 Write_Operator
(Node
, " > ");
1927 Sprint_Right_Opnd
(Node
);
1930 Sprint_Left_Opnd
(Node
);
1931 Write_Operator
(Node
, " <= ");
1932 Sprint_Right_Opnd
(Node
);
1935 Sprint_Left_Opnd
(Node
);
1936 Write_Operator
(Node
, " < ");
1937 Sprint_Right_Opnd
(Node
);
1940 Write_Operator
(Node
, "-");
1941 Sprint_Right_Opnd
(Node
);
1944 Sprint_Left_Opnd
(Node
);
1946 if Treat_Fixed_As_Integer
(Node
) then
1950 Write_Operator
(Node
, " mod ");
1951 Sprint_Right_Opnd
(Node
);
1953 when N_Op_Multiply
=>
1954 Sprint_Left_Opnd
(Node
);
1956 Process_TFAI_RR_Flags
(Node
);
1957 Write_Operator
(Node
, "* ");
1958 Sprint_Right_Opnd
(Node
);
1961 Sprint_Left_Opnd
(Node
);
1962 Write_Operator
(Node
, " /= ");
1963 Sprint_Right_Opnd
(Node
);
1966 Write_Operator
(Node
, "not ");
1967 Sprint_Right_Opnd
(Node
);
1970 Sprint_Left_Opnd
(Node
);
1971 Write_Operator
(Node
, " or ");
1972 Sprint_Right_Opnd
(Node
);
1975 Write_Operator
(Node
, "+");
1976 Sprint_Right_Opnd
(Node
);
1979 Sprint_Left_Opnd
(Node
);
1981 if Treat_Fixed_As_Integer
(Node
) then
1985 Write_Operator
(Node
, " rem ");
1986 Sprint_Right_Opnd
(Node
);
1992 Write_Str_With_Col_Check
("(");
1993 Sprint_Node
(Left_Opnd
(Node
));
1995 Sprint_Node
(Right_Opnd
(Node
));
1998 when N_Op_Subtract
=>
1999 Sprint_Left_Opnd
(Node
);
2000 Write_Operator
(Node
, " - ");
2001 Sprint_Right_Opnd
(Node
);
2004 Sprint_Left_Opnd
(Node
);
2005 Write_Operator
(Node
, " xor ");
2006 Sprint_Right_Opnd
(Node
);
2008 when N_Operator_Symbol
=>
2009 Write_Name_With_Col_Check_Sloc
(Chars
(Node
));
2011 when N_Ordinary_Fixed_Point_Definition
=>
2012 Write_Str_With_Col_Check_Sloc
("delta ");
2013 Sprint_Node
(Delta_Expression
(Node
));
2014 Sprint_Opt_Node
(Real_Range_Specification
(Node
));
2017 Sprint_Left_Opnd
(Node
);
2018 Write_Str_Sloc
(" or else ");
2019 Sprint_Right_Opnd
(Node
);
2021 when N_Others_Choice
=>
2022 if All_Others
(Node
) then
2023 Write_Str_With_Col_Check
("all ");
2026 Write_Str_With_Col_Check_Sloc
("others");
2028 when N_Package_Body
=>
2030 Write_Indent_Str_Sloc
("package body ");
2031 Sprint_Node
(Defining_Unit_Name
(Node
));
2033 Sprint_Indented_List
(Declarations
(Node
));
2035 if Present
(Handled_Statement_Sequence
(Node
)) then
2036 Write_Indent_Str
("begin");
2037 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2040 Write_Indent_Str
("end ");
2041 Sprint_Node
(Defining_Unit_Name
(Node
));
2044 when N_Package_Body_Stub
=>
2045 Write_Indent_Str_Sloc
("package body ");
2046 Sprint_Node
(Defining_Identifier
(Node
));
2047 Write_Str_With_Col_Check
(" is separate;");
2049 when N_Package_Declaration
=>
2052 Sprint_Node_Sloc
(Specification
(Node
));
2055 when N_Package_Instantiation
=>
2057 Write_Indent_Str_Sloc
("package ");
2058 Sprint_Node
(Defining_Unit_Name
(Node
));
2059 Write_Str
(" is new ");
2060 Sprint_Node
(Name
(Node
));
2061 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2064 when N_Package_Renaming_Declaration
=>
2065 Write_Indent_Str_Sloc
("package ");
2066 Sprint_Node
(Defining_Unit_Name
(Node
));
2067 Write_Str_With_Col_Check
(" renames ");
2068 Sprint_Node
(Name
(Node
));
2071 when N_Package_Specification
=>
2072 Write_Str_With_Col_Check_Sloc
("package ");
2073 Sprint_Node
(Defining_Unit_Name
(Node
));
2075 Sprint_Indented_List
(Visible_Declarations
(Node
));
2077 if Present
(Private_Declarations
(Node
)) then
2078 Write_Indent_Str
("private");
2079 Sprint_Indented_List
(Private_Declarations
(Node
));
2082 Write_Indent_Str
("end ");
2083 Sprint_Node
(Defining_Unit_Name
(Node
));
2085 when N_Parameter_Association
=>
2086 Sprint_Node_Sloc
(Selector_Name
(Node
));
2088 Sprint_Node
(Explicit_Actual_Parameter
(Node
));
2090 when N_Parameter_Specification
=>
2093 if Write_Identifiers
(Node
) then
2096 if In_Present
(Node
) then
2097 Write_Str_With_Col_Check
("in ");
2100 if Out_Present
(Node
) then
2101 Write_Str_With_Col_Check
("out ");
2104 -- Ada 2005 (AI-231)
2106 if Null_Exclusion_Present
(Node
) then
2107 Write_Str
("not null ");
2110 Sprint_Node
(Parameter_Type
(Node
));
2112 if Present
(Expression
(Node
)) then
2114 Sprint_Node
(Expression
(Node
));
2121 Write_Indent_Str_Sloc
("pragma ");
2122 Write_Name_With_Col_Check
(Chars
(Node
));
2124 if Present
(Pragma_Argument_Associations
(Node
)) then
2125 Sprint_Opt_Paren_Comma_List
2126 (Pragma_Argument_Associations
(Node
));
2131 when N_Pragma_Argument_Association
=>
2134 if Chars
(Node
) /= No_Name
then
2135 Write_Name_With_Col_Check
(Chars
(Node
));
2139 Sprint_Node
(Expression
(Node
));
2141 when N_Private_Type_Declaration
=>
2142 Write_Indent_Str_Sloc
("type ");
2143 Write_Id
(Defining_Identifier
(Node
));
2145 if Present
(Discriminant_Specifications
(Node
)) then
2146 Write_Discr_Specs
(Node
);
2147 elsif Unknown_Discriminants_Present
(Node
) then
2148 Write_Str_With_Col_Check
("(<>)");
2153 if Tagged_Present
(Node
) then
2154 Write_Str_With_Col_Check
("tagged ");
2157 if Limited_Present
(Node
) then
2158 Write_Str_With_Col_Check
("limited ");
2161 Write_Str_With_Col_Check
("private;");
2163 when N_Private_Extension_Declaration
=>
2164 Write_Indent_Str_Sloc
("type ");
2165 Write_Id
(Defining_Identifier
(Node
));
2167 if Present
(Discriminant_Specifications
(Node
)) then
2168 Write_Discr_Specs
(Node
);
2169 elsif Unknown_Discriminants_Present
(Node
) then
2170 Write_Str_With_Col_Check
("(<>)");
2173 Write_Str_With_Col_Check
(" is new ");
2174 Sprint_Node
(Subtype_Indication
(Node
));
2175 Write_Str_With_Col_Check
(" with private;");
2177 when N_Procedure_Call_Statement
=>
2180 Note_Implicit_Run_Time_Call
(Name
(Node
));
2181 Sprint_Node
(Name
(Node
));
2182 Sprint_Opt_Paren_Comma_List
(Parameter_Associations
(Node
));
2185 when N_Procedure_Instantiation
=>
2186 Write_Indent_Str_Sloc
("procedure ");
2187 Sprint_Node
(Defining_Unit_Name
(Node
));
2188 Write_Str_With_Col_Check
(" is new ");
2189 Sprint_Node
(Name
(Node
));
2190 Sprint_Opt_Paren_Comma_List
(Generic_Associations
(Node
));
2193 when N_Procedure_Specification
=>
2194 Write_Str_With_Col_Check_Sloc
("procedure ");
2195 Sprint_Node
(Defining_Unit_Name
(Node
));
2196 Write_Param_Specs
(Node
);
2198 when N_Protected_Body
=>
2199 Write_Indent_Str_Sloc
("protected body ");
2200 Write_Id
(Defining_Identifier
(Node
));
2202 Sprint_Indented_List
(Declarations
(Node
));
2203 Write_Indent_Str
("end ");
2204 Write_Id
(Defining_Identifier
(Node
));
2207 when N_Protected_Body_Stub
=>
2208 Write_Indent_Str_Sloc
("protected body ");
2209 Write_Id
(Defining_Identifier
(Node
));
2210 Write_Str_With_Col_Check
(" is separate;");
2212 when N_Protected_Definition
=>
2214 Sprint_Indented_List
(Visible_Declarations
(Node
));
2216 if Present
(Private_Declarations
(Node
)) then
2217 Write_Indent_Str
("private");
2218 Sprint_Indented_List
(Private_Declarations
(Node
));
2221 Write_Indent_Str
("end ");
2223 when N_Protected_Type_Declaration
=>
2224 Write_Indent_Str_Sloc
("protected type ");
2225 Write_Id
(Defining_Identifier
(Node
));
2226 Write_Discr_Specs
(Node
);
2228 if Present
(Interface_List
(Node
)) then
2229 Write_Str
(" is new ");
2230 Sprint_And_List
(Interface_List
(Node
));
2231 Write_Str
(" with ");
2236 Sprint_Node
(Protected_Definition
(Node
));
2237 Write_Id
(Defining_Identifier
(Node
));
2240 when N_Qualified_Expression
=>
2241 Sprint_Node
(Subtype_Mark
(Node
));
2242 Write_Char_Sloc
(''');
2244 -- Print expression, make sure we have at least one level of
2245 -- parentheses around the expression. For cases of qualified
2246 -- expressions in the source, this is always the case, but
2247 -- for generated qualifications, there may be no explicit
2248 -- parentheses present.
2250 if Paren_Count
(Expression
(Node
)) /= 0 then
2251 Sprint_Node
(Expression
(Node
));
2254 Sprint_Node
(Expression
(Node
));
2258 when N_Raise_Constraint_Error
=>
2260 -- This node can be used either as a subexpression or as a
2261 -- statement form. The following test is a reasonably reliable
2262 -- way to distinguish the two cases.
2264 if Is_List_Member
(Node
)
2265 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2270 Write_Str_With_Col_Check_Sloc
("[constraint_error");
2271 Write_Condition_And_Reason
(Node
);
2273 when N_Raise_Program_Error
=>
2275 -- This node can be used either as a subexpression or as a
2276 -- statement form. The following test is a reasonably reliable
2277 -- way to distinguish the two cases.
2279 if Is_List_Member
(Node
)
2280 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2285 Write_Str_With_Col_Check_Sloc
("[program_error");
2286 Write_Condition_And_Reason
(Node
);
2288 when N_Raise_Storage_Error
=>
2290 -- This node can be used either as a subexpression or as a
2291 -- statement form. The following test is a reasonably reliable
2292 -- way to distinguish the two cases.
2294 if Is_List_Member
(Node
)
2295 and then Nkind
(Parent
(Node
)) not in N_Subexpr
2300 Write_Str_With_Col_Check_Sloc
("[storage_error");
2301 Write_Condition_And_Reason
(Node
);
2303 when N_Raise_Statement
=>
2304 Write_Indent_Str_Sloc
("raise ");
2305 Sprint_Node
(Name
(Node
));
2309 Sprint_Node
(Low_Bound
(Node
));
2310 Write_Str_Sloc
(" .. ");
2311 Sprint_Node
(High_Bound
(Node
));
2313 when N_Range_Constraint
=>
2314 Write_Str_With_Col_Check_Sloc
("range ");
2315 Sprint_Node
(Range_Expression
(Node
));
2317 when N_Real_Literal
=>
2318 Write_Ureal_With_Col_Check_Sloc
(Realval
(Node
));
2320 when N_Real_Range_Specification
=>
2321 Write_Str_With_Col_Check_Sloc
("range ");
2322 Sprint_Node
(Low_Bound
(Node
));
2324 Sprint_Node
(High_Bound
(Node
));
2326 when N_Record_Definition
=>
2327 if Abstract_Present
(Node
) then
2328 Write_Str_With_Col_Check
("abstract ");
2331 if Tagged_Present
(Node
) then
2332 Write_Str_With_Col_Check
("tagged ");
2335 if Limited_Present
(Node
) then
2336 Write_Str_With_Col_Check
("limited ");
2339 if Null_Present
(Node
) then
2340 Write_Str_With_Col_Check_Sloc
("null record");
2343 Write_Str_With_Col_Check_Sloc
("record");
2344 Sprint_Node
(Component_List
(Node
));
2345 Write_Indent_Str
("end record");
2348 when N_Record_Representation_Clause
=>
2349 Write_Indent_Str_Sloc
("for ");
2350 Sprint_Node
(Identifier
(Node
));
2351 Write_Str_With_Col_Check
(" use record ");
2353 if Present
(Mod_Clause
(Node
)) then
2354 Sprint_Node
(Mod_Clause
(Node
));
2357 Sprint_Indented_List
(Component_Clauses
(Node
));
2358 Write_Indent_Str
("end record;");
2361 Sprint_Node
(Prefix
(Node
));
2362 Write_Str_With_Col_Check_Sloc
("'reference");
2364 when N_Requeue_Statement
=>
2365 Write_Indent_Str_Sloc
("requeue ");
2366 Sprint_Node
(Name
(Node
));
2368 if Abort_Present
(Node
) then
2369 Write_Str_With_Col_Check
(" with abort");
2374 when N_Return_Statement
=>
2375 if Present
(Expression
(Node
)) then
2376 Write_Indent_Str_Sloc
("return ");
2377 Sprint_Node
(Expression
(Node
));
2380 Write_Indent_Str_Sloc
("return;");
2383 when N_Selective_Accept
=>
2384 Write_Indent_Str_Sloc
("select");
2389 Alt_Node
:= First
(Select_Alternatives
(Node
));
2392 Sprint_Node
(Alt_Node
);
2395 exit when No
(Alt_Node
);
2396 Write_Indent_Str
("or");
2400 if Present
(Else_Statements
(Node
)) then
2401 Write_Indent_Str
("else");
2402 Sprint_Indented_List
(Else_Statements
(Node
));
2405 Write_Indent_Str
("end select;");
2407 when N_Signed_Integer_Type_Definition
=>
2408 Write_Str_With_Col_Check_Sloc
("range ");
2409 Sprint_Node
(Low_Bound
(Node
));
2411 Sprint_Node
(High_Bound
(Node
));
2413 when N_Single_Protected_Declaration
=>
2414 Write_Indent_Str_Sloc
("protected ");
2415 Write_Id
(Defining_Identifier
(Node
));
2417 Sprint_Node
(Protected_Definition
(Node
));
2418 Write_Id
(Defining_Identifier
(Node
));
2421 when N_Single_Task_Declaration
=>
2422 Write_Indent_Str_Sloc
("task ");
2423 Write_Id
(Defining_Identifier
(Node
));
2425 if Present
(Task_Definition
(Node
)) then
2427 Sprint_Node
(Task_Definition
(Node
));
2428 Write_Id
(Defining_Identifier
(Node
));
2433 when N_Selected_Component
=>
2434 Sprint_Node
(Prefix
(Node
));
2435 Write_Char_Sloc
('.');
2436 Sprint_Node
(Selector_Name
(Node
));
2440 Sprint_Node
(Prefix
(Node
));
2441 Write_Str_With_Col_Check
(" (");
2442 Sprint_Node
(Discrete_Range
(Node
));
2445 when N_String_Literal
=>
2446 if String_Length
(Strval
(Node
)) + Column
> 75 then
2447 Write_Indent_Str
(" ");
2451 Write_String_Table_Entry
(Strval
(Node
));
2453 when N_Subprogram_Body
=>
2454 if Freeze_Indent
= 0 then
2459 Sprint_Node_Sloc
(Specification
(Node
));
2462 Sprint_Indented_List
(Declarations
(Node
));
2463 Write_Indent_Str
("begin");
2464 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2466 Write_Indent_Str
("end ");
2467 Sprint_Node
(Defining_Unit_Name
(Specification
(Node
)));
2470 if Is_List_Member
(Node
)
2471 and then Present
(Next
(Node
))
2472 and then Nkind
(Next
(Node
)) /= N_Subprogram_Body
2477 when N_Subprogram_Body_Stub
=>
2479 Sprint_Node_Sloc
(Specification
(Node
));
2480 Write_Str_With_Col_Check
(" is separate;");
2482 when N_Subprogram_Declaration
=>
2484 Sprint_Node_Sloc
(Specification
(Node
));
2486 if Nkind
(Specification
(Node
)) = N_Procedure_Specification
2487 and then Null_Present
(Specification
(Node
))
2489 Write_Str_With_Col_Check
(" is null");
2494 when N_Subprogram_Info
=>
2495 Sprint_Node
(Identifier
(Node
));
2496 Write_Str_With_Col_Check_Sloc
("'subprogram_info");
2498 when N_Subprogram_Renaming_Declaration
=>
2500 Sprint_Node
(Specification
(Node
));
2501 Write_Str_With_Col_Check_Sloc
(" renames ");
2502 Sprint_Node
(Name
(Node
));
2505 when N_Subtype_Declaration
=>
2506 Write_Indent_Str_Sloc
("subtype ");
2507 Write_Id
(Defining_Identifier
(Node
));
2510 -- Ada 2005 (AI-231)
2512 if Null_Exclusion_Present
(Node
) then
2513 Write_Str
("not null ");
2516 Sprint_Node
(Subtype_Indication
(Node
));
2519 when N_Subtype_Indication
=>
2520 Sprint_Node_Sloc
(Subtype_Mark
(Node
));
2522 Sprint_Node
(Constraint
(Node
));
2525 Write_Indent_Str_Sloc
("separate (");
2526 Sprint_Node
(Name
(Node
));
2529 Sprint_Node
(Proper_Body
(Node
));
2532 Write_Indent_Str_Sloc
("task body ");
2533 Write_Id
(Defining_Identifier
(Node
));
2535 Sprint_Indented_List
(Declarations
(Node
));
2536 Write_Indent_Str
("begin");
2537 Sprint_Node
(Handled_Statement_Sequence
(Node
));
2538 Write_Indent_Str
("end ");
2539 Write_Id
(Defining_Identifier
(Node
));
2542 when N_Task_Body_Stub
=>
2543 Write_Indent_Str_Sloc
("task body ");
2544 Write_Id
(Defining_Identifier
(Node
));
2545 Write_Str_With_Col_Check
(" is separate;");
2547 when N_Task_Definition
=>
2549 Sprint_Indented_List
(Visible_Declarations
(Node
));
2551 if Present
(Private_Declarations
(Node
)) then
2552 Write_Indent_Str
("private");
2553 Sprint_Indented_List
(Private_Declarations
(Node
));
2556 Write_Indent_Str
("end ");
2558 when N_Task_Type_Declaration
=>
2559 Write_Indent_Str_Sloc
("task type ");
2560 Write_Id
(Defining_Identifier
(Node
));
2561 Write_Discr_Specs
(Node
);
2563 if Present
(Interface_List
(Node
)) then
2564 Write_Str
(" is new ");
2565 Sprint_And_List
(Interface_List
(Node
));
2568 if Present
(Task_Definition
(Node
)) then
2569 if No
(Interface_List
(Node
)) then
2572 Write_Str
(" with ");
2575 Sprint_Node
(Task_Definition
(Node
));
2576 Write_Id
(Defining_Identifier
(Node
));
2581 when N_Terminate_Alternative
=>
2582 Sprint_Node_List
(Pragmas_Before
(Node
));
2586 if Present
(Condition
(Node
)) then
2587 Write_Str_With_Col_Check
("when ");
2588 Sprint_Node
(Condition
(Node
));
2592 Write_Str_With_Col_Check_Sloc
("terminate;");
2593 Sprint_Node_List
(Pragmas_After
(Node
));
2595 when N_Timed_Entry_Call
=>
2596 Write_Indent_Str_Sloc
("select");
2598 Sprint_Node
(Entry_Call_Alternative
(Node
));
2600 Write_Indent_Str
("or");
2602 Sprint_Node
(Delay_Alternative
(Node
));
2604 Write_Indent_Str
("end select;");
2606 when N_Triggering_Alternative
=>
2607 Sprint_Node_List
(Pragmas_Before
(Node
));
2608 Sprint_Node_Sloc
(Triggering_Statement
(Node
));
2609 Sprint_Node_List
(Statements
(Node
));
2611 when N_Type_Conversion
=>
2613 Sprint_Node
(Subtype_Mark
(Node
));
2616 if Conversion_OK
(Node
) then
2620 if Float_Truncate
(Node
) then
2624 if Rounded_Result
(Node
) then
2629 Sprint_Node
(Expression
(Node
));
2632 when N_Unchecked_Expression
=>
2635 Sprint_Node_Sloc
(Expression
(Node
));
2638 when N_Unchecked_Type_Conversion
=>
2639 Sprint_Node
(Subtype_Mark
(Node
));
2641 Write_Str_With_Col_Check
("(");
2642 Sprint_Node_Sloc
(Expression
(Node
));
2645 when N_Unconstrained_Array_Definition
=>
2646 Write_Str_With_Col_Check_Sloc
("array (");
2651 Node1
:= First
(Subtype_Marks
(Node
));
2653 Sprint_Node
(Node1
);
2654 Write_Str_With_Col_Check
(" range <>");
2656 exit when Node1
= Empty
;
2661 Write_Str
(") of ");
2662 Sprint_Node
(Component_Definition
(Node
));
2664 when N_Unused_At_Start | N_Unused_At_End
=>
2665 Write_Indent_Str
("***** Error, unused node encountered *****");
2668 when N_Use_Package_Clause
=>
2669 Write_Indent_Str_Sloc
("use ");
2670 Sprint_Comma_List
(Names
(Node
));
2673 when N_Use_Type_Clause
=>
2674 Write_Indent_Str_Sloc
("use type ");
2675 Sprint_Comma_List
(Subtype_Marks
(Node
));
2678 when N_Validate_Unchecked_Conversion
=>
2679 Write_Indent_Str_Sloc
("validate unchecked_conversion (");
2680 Sprint_Node
(Source_Type
(Node
));
2682 Sprint_Node
(Target_Type
(Node
));
2686 Write_Indent_Str_Sloc
("when ");
2687 Sprint_Bar_List
(Discrete_Choices
(Node
));
2689 Sprint_Node
(Component_List
(Node
));
2691 when N_Variant_Part
=>
2693 Write_Indent_Str_Sloc
("case ");
2694 Sprint_Node
(Name
(Node
));
2696 Sprint_Indented_List
(Variants
(Node
));
2697 Write_Indent_Str
("end case");
2700 when N_With_Clause
=>
2702 -- Special test, if we are dumping the original tree only,
2703 -- then we want to eliminate the bogus with clauses that
2704 -- correspond to the non-existent children of Text_IO.
2706 if Dump_Original_Only
2707 and then Is_Text_IO_Kludge_Unit
(Name
(Node
))
2711 -- Normal case, output the with clause
2714 if First_Name
(Node
) or else not Dump_Original_Only
then
2716 -- Ada 2005 (AI-50217): Print limited with_clauses
2718 if Private_Present
(Node
) and Limited_Present
(Node
) then
2719 Write_Indent_Str
("limited private with ");
2721 elsif Private_Present
(Node
) then
2722 Write_Indent_Str
("private with ");
2724 elsif Limited_Present
(Node
) then
2725 Write_Indent_Str
("limited with ");
2728 Write_Indent_Str
("with ");
2735 Sprint_Node_Sloc
(Name
(Node
));
2737 if Last_Name
(Node
) or else not Dump_Original_Only
then
2742 when N_With_Type_Clause
=>
2743 Write_Indent_Str
("with type ");
2744 Sprint_Node_Sloc
(Name
(Node
));
2746 if Tagged_Present
(Node
) then
2747 Write_Str
(" is tagged;");
2749 Write_Str
(" is access;");
2754 if Nkind
(Node
) in N_Subexpr
2755 and then Do_Range_Check
(Node
)
2760 for J
in 1 .. Paren_Count
(Node
) loop
2764 pragma Assert
(No
(Debug_Node
));
2765 Debug_Node
:= Save_Debug_Node
;
2766 end Sprint_Node_Actual
;
2768 ----------------------
2769 -- Sprint_Node_List --
2770 ----------------------
2772 procedure Sprint_Node_List
(List
: List_Id
) is
2776 if Is_Non_Empty_List
(List
) then
2777 Node
:= First
(List
);
2782 exit when Node
= Empty
;
2785 end Sprint_Node_List
;
2787 ----------------------
2788 -- Sprint_Node_Sloc --
2789 ----------------------
2791 procedure Sprint_Node_Sloc
(Node
: Node_Id
) is
2795 if Present
(Debug_Node
) then
2796 Set_Sloc
(Debug_Node
, Sloc
(Node
));
2797 Debug_Node
:= Empty
;
2799 end Sprint_Node_Sloc
;
2801 ---------------------
2802 -- Sprint_Opt_Node --
2803 ---------------------
2805 procedure Sprint_Opt_Node
(Node
: Node_Id
) is
2807 if Present
(Node
) then
2811 end Sprint_Opt_Node
;
2813 --------------------------
2814 -- Sprint_Opt_Node_List --
2815 --------------------------
2817 procedure Sprint_Opt_Node_List
(List
: List_Id
) is
2819 if Present
(List
) then
2820 Sprint_Node_List
(List
);
2822 end Sprint_Opt_Node_List
;
2824 ---------------------------------
2825 -- Sprint_Opt_Paren_Comma_List --
2826 ---------------------------------
2828 procedure Sprint_Opt_Paren_Comma_List
(List
: List_Id
) is
2830 if Is_Non_Empty_List
(List
) then
2832 Sprint_Paren_Comma_List
(List
);
2834 end Sprint_Opt_Paren_Comma_List
;
2836 -----------------------------
2837 -- Sprint_Paren_Comma_List --
2838 -----------------------------
2840 procedure Sprint_Paren_Comma_List
(List
: List_Id
) is
2842 Node_Exists
: Boolean := False;
2846 if Is_Non_Empty_List
(List
) then
2848 if Dump_Original_Only
then
2850 while Present
(N
) loop
2851 if not Is_Rewrite_Insertion
(N
) then
2852 Node_Exists
:= True;
2859 if not Node_Exists
then
2864 Write_Str_With_Col_Check
("(");
2865 Sprint_Comma_List
(List
);
2868 end Sprint_Paren_Comma_List
;
2870 ----------------------
2871 -- Sprint_Right_Opnd --
2872 ----------------------
2874 procedure Sprint_Right_Opnd
(N
: Node_Id
) is
2875 Opnd
: constant Node_Id
:= Right_Opnd
(N
);
2878 if Paren_Count
(Opnd
) /= 0
2879 or else Op_Prec
(Nkind
(Opnd
)) > Op_Prec
(Nkind
(N
))
2888 end Sprint_Right_Opnd
;
2890 ---------------------
2891 -- Write_Char_Sloc --
2892 ---------------------
2894 procedure Write_Char_Sloc
(C
: Character) is
2896 if Debug_Generated_Code
and then C
/= ' ' then
2901 end Write_Char_Sloc
;
2903 --------------------------------
2904 -- Write_Condition_And_Reason --
2905 --------------------------------
2907 procedure Write_Condition_And_Reason
(Node
: Node_Id
) is
2908 Image
: constant String := RT_Exception_Code
'Image
2909 (RT_Exception_Code
'Val
2910 (UI_To_Int
(Reason
(Node
))));
2913 if Present
(Condition
(Node
)) then
2914 Write_Str_With_Col_Check
(" when ");
2915 Sprint_Node
(Condition
(Node
));
2920 for J
in 4 .. Image
'Last loop
2921 if Image
(J
) = '_' then
2924 Write_Char
(Fold_Lower
(Image
(J
)));
2929 end Write_Condition_And_Reason
;
2931 -----------------------
2932 -- Write_Discr_Specs --
2933 -----------------------
2935 procedure Write_Discr_Specs
(N
: Node_Id
) is
2940 Specs
:= Discriminant_Specifications
(N
);
2942 if Present
(Specs
) then
2943 Write_Str_With_Col_Check
(" (");
2944 Spec
:= First
(Specs
);
2949 exit when Spec
= Empty
;
2951 -- Add semicolon, unless we are printing original tree and the
2952 -- next specification is part of a list (but not the first
2953 -- element of that list)
2955 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
2962 end Write_Discr_Specs
;
2968 procedure Write_Ekind
(E
: Entity_Id
) is
2969 S
: constant String := Entity_Kind
'Image (Ekind
(E
));
2972 Name_Len
:= S
'Length;
2973 Name_Buffer
(1 .. Name_Len
) := S
;
2974 Set_Casing
(Mixed_Case
);
2975 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
2982 procedure Write_Id
(N
: Node_Id
) is
2984 -- Deal with outputting Itype
2986 -- Note: if we are printing the full tree with -gnatds, then we may
2987 -- end up picking up the Associated_Node link from a generic template
2988 -- here which overlaps the Entity field, but as documented, Write_Itype
2989 -- is defended against junk calls.
2991 if Nkind
(N
) in N_Entity
then
2993 elsif Nkind
(N
) in N_Has_Entity
then
2994 Write_Itype
(Entity
(N
));
2997 -- Case of a defining identifier
2999 if Nkind
(N
) = N_Defining_Identifier
then
3001 -- If defining identifier has an interface name (and no
3002 -- address clause), then we output the interface name.
3004 if (Is_Imported
(N
) or else Is_Exported
(N
))
3005 and then Present
(Interface_Name
(N
))
3006 and then No
(Address_Clause
(N
))
3008 String_To_Name_Buffer
(Strval
(Interface_Name
(N
)));
3009 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3011 -- If no interface name (or inactive because there was
3012 -- an address clause), then just output the Chars name.
3015 Write_Name_With_Col_Check
(Chars
(N
));
3018 -- Case of selector of an expanded name where the expanded name
3019 -- has an associated entity, output this entity.
3021 elsif Nkind
(Parent
(N
)) = N_Expanded_Name
3022 and then Selector_Name
(Parent
(N
)) = N
3023 and then Present
(Entity
(Parent
(N
)))
3025 Write_Id
(Entity
(Parent
(N
)));
3027 -- For any other node with an associated entity, output it
3029 elsif Nkind
(N
) in N_Has_Entity
3030 and then Present
(Entity_Or_Associated_Node
(N
))
3031 and then Nkind
(Entity_Or_Associated_Node
(N
)) in N_Entity
3033 Write_Id
(Entity
(N
));
3035 -- All other cases, we just print the Chars field
3038 Write_Name_With_Col_Check
(Chars
(N
));
3042 -----------------------
3043 -- Write_Identifiers --
3044 -----------------------
3046 function Write_Identifiers
(Node
: Node_Id
) return Boolean is
3048 Sprint_Node
(Defining_Identifier
(Node
));
3050 -- The remainder of the declaration must be printed unless we are
3051 -- printing the original tree and this is not the last identifier
3054 not Dump_Original_Only
or else not More_Ids
(Node
);
3056 end Write_Identifiers
;
3058 ------------------------
3059 -- Write_Implicit_Def --
3060 ------------------------
3062 procedure Write_Implicit_Def
(E
: Entity_Id
) is
3067 when E_Array_Subtype
=>
3068 Write_Str_With_Col_Check
("subtype ");
3070 Write_Str_With_Col_Check
(" is ");
3071 Write_Id
(Base_Type
(E
));
3072 Write_Str_With_Col_Check
(" (");
3074 Ind
:= First_Index
(E
);
3075 while Present
(Ind
) loop
3079 if Present
(Ind
) then
3086 when E_Signed_Integer_Subtype | E_Enumeration_Subtype
=>
3087 Write_Str_With_Col_Check
("subtype ");
3090 Write_Id
(Etype
(E
));
3091 Write_Str_With_Col_Check
(" range ");
3092 Sprint_Node
(Scalar_Range
(E
));
3096 Write_Str_With_Col_Check
("type ");
3098 Write_Str_With_Col_Check
(" is <");
3103 end Write_Implicit_Def
;
3109 procedure Write_Indent
is
3111 if Indent_Annull_Flag
then
3112 Indent_Annull_Flag
:= False;
3116 for J
in 1 .. Indent
loop
3122 ------------------------------
3123 -- Write_Indent_Identifiers --
3124 ------------------------------
3126 function Write_Indent_Identifiers
(Node
: Node_Id
) return Boolean is
3128 -- We need to start a new line for every node, except in the case
3129 -- where we are printing the original tree and this is not the first
3130 -- defining identifier in the list.
3132 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3135 -- If printing original tree and this is not the first defining
3136 -- identifier in the list, then the previous call to this procedure
3137 -- printed only the name, and we add a comma to separate the names.
3143 Sprint_Node
(Defining_Identifier
(Node
));
3145 -- The remainder of the declaration must be printed unless we are
3146 -- printing the original tree and this is not the last identifier
3149 not Dump_Original_Only
or else not More_Ids
(Node
);
3151 end Write_Indent_Identifiers
;
3153 -----------------------------------
3154 -- Write_Indent_Identifiers_Sloc --
3155 -----------------------------------
3157 function Write_Indent_Identifiers_Sloc
(Node
: Node_Id
) return Boolean is
3159 -- We need to start a new line for every node, except in the case
3160 -- where we are printing the original tree and this is not the first
3161 -- defining identifier in the list.
3163 if not Dump_Original_Only
or else not Prev_Ids
(Node
) then
3166 -- If printing original tree and this is not the first defining
3167 -- identifier in the list, then the previous call to this procedure
3168 -- printed only the name, and we add a comma to separate the names.
3175 Sprint_Node
(Defining_Identifier
(Node
));
3177 -- The remainder of the declaration must be printed unless we are
3178 -- printing the original tree and this is not the last identifier
3181 not Dump_Original_Only
or else not More_Ids
(Node
);
3183 end Write_Indent_Identifiers_Sloc
;
3185 ----------------------
3186 -- Write_Indent_Str --
3187 ----------------------
3189 procedure Write_Indent_Str
(S
: String) is
3193 end Write_Indent_Str
;
3195 ---------------------------
3196 -- Write_Indent_Str_Sloc --
3197 ---------------------------
3199 procedure Write_Indent_Str_Sloc
(S
: String) is
3203 end Write_Indent_Str_Sloc
;
3209 procedure Write_Itype
(Typ
: Entity_Id
) is
3211 procedure Write_Header
(T
: Boolean := True);
3212 -- Write type if T is True, subtype if T is false
3218 procedure Write_Header
(T
: Boolean := True) is
3221 Write_Str
("[type ");
3223 Write_Str
("[subtype ");
3226 Write_Name_With_Col_Check
(Chars
(Typ
));
3230 -- Start of processing for Write_Itype
3233 if Nkind
(Typ
) in N_Entity
3234 and then Is_Itype
(Typ
)
3235 and then not Itype_Printed
(Typ
)
3237 -- Itype to be printed
3240 B
: constant Node_Id
:= Etype
(Typ
);
3242 P
: constant Node_Id
:= Parent
(Typ
);
3244 S
: constant Saved_Output_Buffer
:= Save_Output_Buffer
;
3245 -- Save current output buffer
3247 Old_Sloc
: Source_Ptr
;
3248 -- Save sloc of related node, so it is not modified when
3249 -- printing with -gnatD.
3252 -- Write indentation at start of line
3254 for J
in 1 .. Indent
loop
3258 -- If we have a constructed declaration, print it
3260 if Present
(P
) and then Nkind
(P
) in N_Declaration
then
3262 -- We must set Itype_Printed true before the recursive call to
3263 -- print the node, otherwise we get an infinite recursion!
3265 Set_Itype_Printed
(Typ
, True);
3267 -- Write the declaration enclosed in [], avoiding new line
3268 -- at start of declaration, and semicolon at end.
3270 -- Note: The itype may be imported from another unit, in which
3271 -- case we do not want to modify the Sloc of the declaration.
3272 -- Otherwise the itype may appear to be in the current unit,
3273 -- and the back-end will reject a reference out of scope.
3276 Indent_Annull_Flag
:= True;
3277 Old_Sloc
:= Sloc
(P
);
3279 Set_Sloc
(P
, Old_Sloc
);
3280 Write_Erase_Char
(';');
3282 -- If no constructed declaration, then we have to concoct the
3283 -- source corresponding to the type entity that we have at hand.
3288 -- Access types and subtypes
3291 Write_Header
(Ekind
(Typ
) = E_Access_Type
);
3292 Write_Str
("access ");
3294 if Is_Access_Constant
(Typ
) then
3295 Write_Str
("constant ");
3296 elsif Can_Never_Be_Null
(Typ
) then
3297 Write_Str
("not null ");
3300 Write_Id
(Directly_Designated_Type
(Typ
));
3302 -- Array types and string types
3304 when E_Array_Type | E_String_Type
=>
3306 Write_Str
("array (");
3308 X
:= First_Index
(Typ
);
3312 if not Is_Constrained
(Typ
) then
3313 Write_Str
(" range <>");
3321 Write_Str
(") of ");
3322 Sprint_Node
(Component_Type
(Typ
));
3324 -- Array subtypes and string subtypes
3326 when E_Array_Subtype | E_String_Subtype
=>
3327 Write_Header
(False);
3328 Write_Id
(Etype
(Typ
));
3331 X
:= First_Index
(Typ
);
3341 -- Signed integer types, and modular integer subtypes
3343 when E_Signed_Integer_Type |
3344 E_Signed_Integer_Subtype |
3345 E_Modular_Integer_Subtype
=>
3347 Write_Header
(Ekind
(Typ
) = E_Signed_Integer_Type
);
3349 if Ekind
(Typ
) = E_Signed_Integer_Type
then
3355 -- Print bounds if not different from base type
3358 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
3359 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
3360 LE
: constant Node_Id
:= Type_Low_Bound
(B
);
3361 HE
: constant Node_Id
:= Type_High_Bound
(B
);
3364 if Nkind
(L
) = N_Integer_Literal
3365 and then Nkind
(H
) = N_Integer_Literal
3366 and then Nkind
(LE
) = N_Integer_Literal
3367 and then Nkind
(HE
) = N_Integer_Literal
3368 and then UI_Eq
(Intval
(L
), Intval
(LE
))
3369 and then UI_Eq
(Intval
(H
), Intval
(HE
))
3374 Write_Str
(" range ");
3375 Sprint_Node
(Type_Low_Bound
(Typ
));
3377 Sprint_Node
(Type_High_Bound
(Typ
));
3381 -- Modular integer types
3383 when E_Modular_Integer_Type
=>
3385 Write_Str
(" mod ");
3386 Write_Uint_With_Col_Check
(Modulus
(Typ
), Auto
);
3388 -- Floating point types and subtypes
3390 when E_Floating_Point_Type |
3391 E_Floating_Point_Subtype
=>
3393 Write_Header
(Ekind
(Typ
) = E_Floating_Point_Type
);
3395 if Ekind
(Typ
) = E_Floating_Point_Type
then
3399 Write_Id
(Etype
(Typ
));
3401 if Digits_Value
(Typ
) /= Digits_Value
(Etype
(Typ
)) then
3402 Write_Str
(" digits ");
3403 Write_Uint_With_Col_Check
3404 (Digits_Value
(Typ
), Decimal
);
3407 -- Print bounds if not different from base type
3410 L
: constant Node_Id
:= Type_Low_Bound
(Typ
);
3411 H
: constant Node_Id
:= Type_High_Bound
(Typ
);
3412 LE
: constant Node_Id
:= Type_Low_Bound
(B
);
3413 HE
: constant Node_Id
:= Type_High_Bound
(B
);
3416 if Nkind
(L
) = N_Real_Literal
3417 and then Nkind
(H
) = N_Real_Literal
3418 and then Nkind
(LE
) = N_Real_Literal
3419 and then Nkind
(HE
) = N_Real_Literal
3420 and then UR_Eq
(Realval
(L
), Realval
(LE
))
3421 and then UR_Eq
(Realval
(H
), Realval
(HE
))
3426 Write_Str
(" range ");
3427 Sprint_Node
(Type_Low_Bound
(Typ
));
3429 Sprint_Node
(Type_High_Bound
(Typ
));
3435 when E_Record_Subtype
=>
3436 Write_Header
(False);
3437 Write_Str
("record");
3443 C
:= First_Entity
(Typ
);
3444 while Present
(C
) loop
3448 Write_Id
(Etype
(C
));
3454 Write_Indent_Str
(" end record");
3458 when E_Class_Wide_Type
=>
3460 Write_Name_With_Col_Check
(Chars
(Etype
(Typ
)));
3461 Write_Str
("'Class");
3465 when E_Subprogram_Type
=>
3468 if Etype
(Typ
) = Standard_Void_Type
then
3469 Write_Str
("procedure");
3471 Write_Str
("function");
3474 if Present
(First_Entity
(Typ
)) then
3481 Param
:= First_Entity
(Typ
);
3486 if Ekind
(Param
) = E_In_Out_Parameter
then
3487 Write_Str
("in out ");
3488 elsif Ekind
(Param
) = E_Out_Parameter
then
3492 Write_Id
(Etype
(Param
));
3493 Next_Entity
(Param
);
3494 exit when No
(Param
);
3502 if Etype
(Typ
) /= Standard_Void_Type
then
3503 Write_Str
(" return ");
3504 Write_Id
(Etype
(Typ
));
3507 -- For all other Itypes, print ??? (fill in later)
3510 Write_Header
(True);
3516 -- Add terminating bracket and restore output buffer
3520 Restore_Output_Buffer
(S
);
3523 Set_Itype_Printed
(Typ
);
3527 -------------------------------
3528 -- Write_Name_With_Col_Check --
3529 -------------------------------
3531 procedure Write_Name_With_Col_Check
(N
: Name_Id
) is
3535 Get_Name_String
(N
);
3537 -- Deal with -gnatI which replaces digits in an internal
3538 -- name by three dots (e.g. R7b becomes R...b).
3540 if Debug_Flag_II
and then Name_Buffer
(1) in 'A' .. 'Z' then
3542 while J
< Name_Len
loop
3543 exit when Name_Buffer
(J
) not in 'A' .. 'Z';
3547 if Name_Buffer
(J
) in '0' .. '9' then
3548 Write_Str_With_Col_Check
(Name_Buffer
(1 .. J
- 1));
3551 while J
<= Name_Len
loop
3552 if Name_Buffer
(J
) not in '0' .. '9' then
3553 Write_Str
(Name_Buffer
(J
.. Name_Len
));
3565 -- Fall through for normal case
3567 Write_Str_With_Col_Check
(Name_Buffer
(1 .. Name_Len
));
3568 end Write_Name_With_Col_Check
;
3570 ------------------------------------
3571 -- Write_Name_With_Col_Check_Sloc --
3572 ------------------------------------
3574 procedure Write_Name_With_Col_Check_Sloc
(N
: Name_Id
) is
3576 Get_Name_String
(N
);
3577 Write_Str_With_Col_Check_Sloc
(Name_Buffer
(1 .. Name_Len
));
3578 end Write_Name_With_Col_Check_Sloc
;
3580 --------------------
3581 -- Write_Operator --
3582 --------------------
3584 procedure Write_Operator
(N
: Node_Id
; S
: String) is
3585 F
: Natural := S
'First;
3586 T
: Natural := S
'Last;
3589 -- If no overflow check, just write string out, and we are done
3591 if not Do_Overflow_Check
(N
) then
3594 -- If overflow check, we want to surround the operator with curly
3595 -- brackets, but not include spaces within the brackets.
3608 Write_Str_Sloc
(S
(F
.. T
));
3611 if S
(S
'Last) = ' ' then
3617 -----------------------
3618 -- Write_Param_Specs --
3619 -----------------------
3621 procedure Write_Param_Specs
(N
: Node_Id
) is
3627 Specs
:= Parameter_Specifications
(N
);
3629 if Is_Non_Empty_List
(Specs
) then
3630 Write_Str_With_Col_Check
(" (");
3631 Spec
:= First
(Specs
);
3635 Formal
:= Defining_Identifier
(Spec
);
3637 exit when Spec
= Empty
;
3639 -- Add semicolon, unless we are printing original tree and the
3640 -- next specification is part of a list (but not the first
3641 -- element of that list)
3643 if not Dump_Original_Only
or else not Prev_Ids
(Spec
) then
3648 -- Write out any extra formals
3650 while Present
(Extra_Formal
(Formal
)) loop
3651 Formal
:= Extra_Formal
(Formal
);
3653 Write_Name_With_Col_Check
(Chars
(Formal
));
3655 Write_Name_With_Col_Check
(Chars
(Etype
(Formal
)));
3660 end Write_Param_Specs
;
3662 --------------------------
3663 -- Write_Rewrite_Str --
3664 --------------------------
3666 procedure Write_Rewrite_Str
(S
: String) is
3668 if not Dump_Generated_Only
then
3669 if S
'Length = 3 and then S
= ">>>" then
3672 Write_Str_With_Col_Check
(S
);
3675 end Write_Rewrite_Str
;
3677 --------------------
3678 -- Write_Str_Sloc --
3679 --------------------
3681 procedure Write_Str_Sloc
(S
: String) is
3683 for J
in S
'Range loop
3684 Write_Char_Sloc
(S
(J
));
3688 ------------------------------
3689 -- Write_Str_With_Col_Check --
3690 ------------------------------
3692 procedure Write_Str_With_Col_Check
(S
: String) is
3694 if Int
(S
'Last) + Column
> Line_Limit
then
3695 Write_Indent_Str
(" ");
3698 Write_Str
(S
(2 .. S
'Length));
3706 end Write_Str_With_Col_Check
;
3708 -----------------------------------
3709 -- Write_Str_With_Col_Check_Sloc --
3710 -----------------------------------
3712 procedure Write_Str_With_Col_Check_Sloc
(S
: String) is
3714 if Int
(S
'Last) + Column
> Line_Limit
then
3715 Write_Indent_Str
(" ");
3718 Write_Str_Sloc
(S
(2 .. S
'Length));
3726 end Write_Str_With_Col_Check_Sloc
;
3728 -------------------------------
3729 -- Write_Uint_With_Col_Check --
3730 -------------------------------
3732 procedure Write_Uint_With_Col_Check
(U
: Uint
; Format
: UI_Format
) is
3734 Col_Check
(UI_Decimal_Digits_Hi
(U
));
3735 UI_Write
(U
, Format
);
3736 end Write_Uint_With_Col_Check
;
3738 ------------------------------------
3739 -- Write_Uint_With_Col_Check_Sloc --
3740 ------------------------------------
3742 procedure Write_Uint_With_Col_Check_Sloc
(U
: Uint
; Format
: UI_Format
) is
3744 Col_Check
(UI_Decimal_Digits_Hi
(U
));
3746 UI_Write
(U
, Format
);
3747 end Write_Uint_With_Col_Check_Sloc
;
3749 -------------------------------------
3750 -- Write_Ureal_With_Col_Check_Sloc --
3751 -------------------------------------
3753 procedure Write_Ureal_With_Col_Check_Sloc
(U
: Ureal
) is
3754 D
: constant Uint
:= Denominator
(U
);
3755 N
: constant Uint
:= Numerator
(U
);
3759 (UI_Decimal_Digits_Hi
(D
) + UI_Decimal_Digits_Hi
(N
) + 4);
3762 end Write_Ureal_With_Col_Check_Sloc
;