1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2003, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Atree; use Atree;
28 with Casing; use Casing;
29 with Csets; use Csets;
30 with Debug; use Debug;
31 with Einfo; use Einfo;
33 with Namet; use Namet;
34 with Nlists; use Nlists;
36 with Output; use Output;
37 with Rtsfind; use Rtsfind;
38 with Sinfo; use Sinfo;
39 with Sinput; use Sinput;
40 with Sinput.D; use Sinput.D;
41 with Snames; use Snames;
42 with Stand; use Stand;
43 with Stringt; use Stringt;
44 with Uintp; use Uintp;
45 with Uname; use Uname;
46 with Urealp; use Urealp;
48 package body Sprint is
50 Debug_Node : Node_Id := Empty;
51 -- If we are in Debug_Generated_Code mode, then this location is set
52 -- to the current node requiring Sloc fixup, until Set_Debug_Sloc is
53 -- called to set the proper value. The call clears it back to Empty.
55 Debug_Sloc : Source_Ptr;
56 -- Sloc of first byte of line currently being written if we are
57 -- generating a source debug file.
59 Dump_Original_Only : Boolean;
60 -- Set True if the -gnatdo (dump original tree) flag is set
62 Dump_Generated_Only : Boolean;
63 -- Set True if the -gnatG (dump generated tree) debug flag is set
64 -- or for Print_Generated_Code (-gnatG) or Dump_Gnerated_Code (-gnatD).
66 Dump_Freeze_Null : Boolean;
67 -- Set True if freeze nodes and non-source null statements output
70 -- Number of columns for current line output indentation
72 Indent_Annull_Flag : Boolean := False;
73 -- Set True if subsequent Write_Indent call to be ignored, gets reset
74 -- by this call, so it is only active to suppress a single indent call.
76 Line_Limit : constant := 72;
77 -- Limit value for chopping long lines
79 Freeze_Indent : Int := 0;
80 -- Keep track of freeze indent level (controls blank lines before
81 -- procedures within expression freeze actions)
83 -------------------------------
84 -- Operator Precedence Table --
85 -------------------------------
87 -- This table is used to decide whether a subexpression needs to be
88 -- parenthesized. The rule is that if an operand of an operator (which
89 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
90 -- with a lower precedence than the operator (or equal precedence if
91 -- appearing as the right operand), then parentheses are required.
93 Op_Prec : array (N_Subexpr) of Short_Short_Integer :=
126 procedure Sprint_Left_Opnd (N : Node_Id);
127 -- Print left operand of operator, parenthesizing if necessary
129 procedure Sprint_Right_Opnd (N : Node_Id);
130 -- Print right operand of operator, parenthesizing if necessary
132 -----------------------
133 -- Local Subprograms --
134 -----------------------
136 procedure Col_Check (N : Nat);
137 -- Check that at least N characters remain on current line, and if not,
138 -- then start an extra line with two characters extra indentation for
139 -- continuing text on the next line.
141 procedure Indent_Annull;
142 -- Causes following call to Write_Indent to be ignored. This is used when
143 -- a higher level node wants to stop a lower level node from starting a
144 -- new line, when it would otherwise be inclined to do so (e.g. the case
145 -- of an accept statement called from an accept alternative with a guard)
147 procedure Indent_Begin;
148 -- Increase indentation level
150 procedure Indent_End;
151 -- Decrease indentation level
153 procedure Print_Debug_Line (S : String);
154 -- Used to print output lines in Debug_Generated_Code mode (this is used
155 -- as the argument for a call to Set_Special_Output in package Output).
157 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
158 -- Given a divide, multiplication or division node, check the flags
159 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
160 -- appropriate special syntax characters (# and @).
162 procedure Set_Debug_Sloc;
163 -- If Debug_Node is non-empty, this routine sets the appropriate value
164 -- in its Sloc field, from the current location in the debug source file
165 -- that is currently being written. Note that Debug_Node is always empty
166 -- if a debug source file is not being written.
168 procedure Sprint_Bar_List (List : List_Id);
169 -- Print the given list with items separated by vertical bars
171 procedure Sprint_Node_Actual (Node : Node_Id);
172 -- This routine prints its node argument. It is a lower level routine than
173 -- Sprint_Node, in that it does not bother about rewritten trees.
175 procedure Sprint_Node_Sloc (Node : Node_Id);
176 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
177 -- sets the Sloc of the current debug node to be a copy of the Sloc
178 -- of the sprinted node Node. Note that this is done after printing
179 -- Node, so that the Sloc is the proper updated value for the debug file.
181 procedure Write_Char_Sloc (C : Character);
182 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
183 -- called to ensure that the current node has a proper Sloc set.
185 procedure Write_Condition_And_Reason (Node : Node_Id);
186 -- Write Condition and Reason codes of Raise_xxx_Error node
188 procedure Write_Discr_Specs (N : Node_Id);
189 -- Ouput discriminant specification for node, which is any of the type
190 -- declarations that can have discriminants.
192 procedure Write_Ekind (E : Entity_Id);
193 -- Write the String corresponding to the Ekind without "E_".
195 procedure Write_Id (N : Node_Id);
196 -- N is a node with a Chars field. This procedure writes the name that
197 -- will be used in the generated code associated with the name. For a
198 -- node with no associated entity, this is simply the Chars field. For
199 -- the case where there is an entity associated with the node, we print
200 -- the name associated with the entity (since it may have been encoded).
201 -- One other special case is that an entity has an active external name
202 -- (i.e. an external name present with no address clause), then this
203 -- external name is output.
205 function Write_Identifiers (Node : Node_Id) return Boolean;
206 -- Handle node where the grammar has a list of defining identifiers, but
207 -- the tree has a separate declaration for each identifier. Handles the
208 -- printing of the defining identifier, and returns True if the type and
209 -- initialization information is to be printed, False if it is to be
210 -- skipped (the latter case happens when printing defining identifiers
211 -- other than the first in the original tree output case).
213 procedure Write_Implicit_Def (E : Entity_Id);
214 pragma Warnings (Off, Write_Implicit_Def);
215 -- Write the definition of the implicit type E according to its Ekind
216 -- For now a debugging procedure, but might be used in the future.
218 procedure Write_Indent;
219 -- Start a new line and write indentation spacing
221 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
222 -- Like Write_Identifiers except that each new printed declaration
223 -- is at the start of a new line.
225 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
226 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
227 -- mode, the Sloc of the current debug node is set to point ot the
228 -- first output identifier.
230 procedure Write_Indent_Str (S : String);
231 -- Start a new line and write indent spacing followed by given string
233 procedure Write_Indent_Str_Sloc (S : String);
234 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
235 -- the Sloc of the current node is set to the first non-blank character
238 procedure Write_Name_With_Col_Check (N : Name_Id);
239 -- Write name (using Write_Name) with initial column check, and possible
240 -- initial Write_Indent (to get new line) if current line is too full.
242 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
243 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
244 -- mode, sets Sloc of current debug node to first character of name.
246 procedure Write_Operator (N : Node_Id; S : String);
247 -- Like Write_Str_Sloc, used for operators, encloses the string in
248 -- characters {} if the Do_Overflow flag is set on the node N.
250 procedure Write_Param_Specs (N : Node_Id);
251 -- Output parameter specifications for node (which is either a function
252 -- or procedure specification with a Parameter_Specifications field)
254 procedure Write_Rewrite_Str (S : String);
255 -- Writes out a string (typically containing <<< or >>>}) for a node
256 -- created by rewriting the tree. Suppressed if we are outputting the
257 -- generated code only, since in this case we don't specially mark nodes
258 -- created by rewriting).
260 procedure Write_Str_Sloc (S : String);
261 -- Like Write_Str, but sets debug Sloc of current debug node to first
262 -- non-blank character if a current debug node is active.
264 procedure Write_Str_With_Col_Check (S : String);
265 -- Write string (using Write_Str) with initial column check, and possible
266 -- initial Write_Indent (to get new line) if current line is too full.
268 procedure Write_Str_With_Col_Check_Sloc (S : String);
269 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
270 -- node to first non-blank character if a current debug node is active.
272 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
273 -- Write Uint (using UI_Write) with initial column check, and possible
274 -- initial Write_Indent (to get new line) if current line is too full.
275 -- The format parameter determines the output format (see UI_Write).
276 -- In addition, in Debug_Generated_Code mode, sets the current node
277 -- Sloc to the first character of the output value.
279 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
280 -- Write Ureal (using same output format as UR_Write) with column checks
281 -- and a possible initial Write_Indent (to get new line) if current line
282 -- is too full. In addition, in Debug_Generated_Code mode, sets the
283 -- current node Sloc to the first character of the output value.
289 procedure Col_Check (N : Nat) is
291 if N + Column > Line_Limit then
292 Write_Indent_Str (" ");
300 procedure Indent_Annull is
302 Indent_Annull_Flag := True;
309 procedure Indent_Begin is
311 Indent := Indent + 3;
318 procedure Indent_End is
320 Indent := Indent - 3;
327 procedure pg (Node : Node_Id) is
329 Dump_Generated_Only := True;
330 Dump_Original_Only := False;
339 procedure po (Node : Node_Id) is
341 Dump_Generated_Only := False;
342 Dump_Original_Only := True;
347 ----------------------
348 -- Print_Debug_Line --
349 ----------------------
351 procedure Print_Debug_Line (S : String) is
353 Write_Debug_Line (S, Debug_Sloc);
354 end Print_Debug_Line;
356 ---------------------------
357 -- Process_TFAI_RR_Flags --
358 ---------------------------
360 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
362 if Treat_Fixed_As_Integer (Nod) then
366 if Rounded_Result (Nod) then
369 end Process_TFAI_RR_Flags;
375 procedure ps (Node : Node_Id) is
377 Dump_Generated_Only := False;
378 Dump_Original_Only := False;
387 procedure Set_Debug_Sloc is
389 if Present (Debug_Node) then
390 Set_Sloc (Debug_Node, Debug_Sloc + Source_Ptr (Column - 1));
399 procedure Source_Dump is
402 -- Put underline under string we just printed
404 procedure Underline is
405 Col : constant Int := Column;
410 while Col > Column loop
417 -- Start of processing for Tree_Dump.
420 Dump_Generated_Only := Debug_Flag_G or
421 Print_Generated_Code or
422 Debug_Generated_Code;
423 Dump_Original_Only := Debug_Flag_O;
424 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
426 -- Note that we turn off the tree dump flags immediately, before
427 -- starting the dump. This avoids generating two copies of the dump
428 -- if an abort occurs after printing the dump, and more importantly,
429 -- avoids an infinite loop if an abort occurs during the dump.
432 Debug_Flag_Z := False;
435 Write_Str ("Source recreated from tree of Standard (spec)");
437 Sprint_Node (Standard_Package_Node);
442 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
443 Debug_Flag_G := False;
444 Debug_Flag_O := False;
445 Debug_Flag_S := False;
447 -- Dump requested units
449 for U in Main_Unit .. Last_Unit loop
451 -- Dump all units if -gnatdf set, otherwise we dump only
452 -- the source files that are in the extended main source.
455 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
457 -- If we are generating debug files, setup to write them
459 if Debug_Generated_Code then
460 Set_Special_Output (Print_Debug_Line'Access);
461 Create_Debug_Source (Source_Index (U), Debug_Sloc);
462 Sprint_Node (Cunit (U));
465 Set_Special_Output (null);
467 -- Normal output to standard output file
470 Write_Str ("Source recreated from tree for ");
471 Write_Unit_Name (Unit_Name (U));
473 Sprint_Node (Cunit (U));
482 ---------------------
483 -- Sprint_Bar_List --
484 ---------------------
486 procedure Sprint_Bar_List (List : List_Id) is
490 if Is_Non_Empty_List (List) then
491 Node := First (List);
496 exit when Node = Empty;
502 -----------------------
503 -- Sprint_Comma_List --
504 -----------------------
506 procedure Sprint_Comma_List (List : List_Id) is
510 if Is_Non_Empty_List (List) then
511 Node := First (List);
516 exit when Node = Empty;
518 if not Is_Rewrite_Insertion (Node)
519 or else not Dump_Original_Only
526 end Sprint_Comma_List;
528 --------------------------
529 -- Sprint_Indented_List --
530 --------------------------
532 procedure Sprint_Indented_List (List : List_Id) is
535 Sprint_Node_List (List);
537 end Sprint_Indented_List;
539 ---------------------
540 -- Sprint_Left_Opnd --
541 ---------------------
543 procedure Sprint_Left_Opnd (N : Node_Id) is
544 Opnd : constant Node_Id := Left_Opnd (N);
547 if Paren_Count (Opnd) /= 0
548 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
557 end Sprint_Left_Opnd;
563 procedure Sprint_Node (Node : Node_Id) is
565 if Is_Rewrite_Insertion (Node) then
566 if not Dump_Original_Only then
568 -- For special cases of nodes that always output <<< >>>
569 -- do not duplicate the output at this point.
571 if Nkind (Node) = N_Freeze_Entity
572 or else Nkind (Node) = N_Implicit_Label_Declaration
574 Sprint_Node_Actual (Node);
576 -- Normal case where <<< >>> may be required
579 Write_Rewrite_Str ("<<<");
580 Sprint_Node_Actual (Node);
581 Write_Rewrite_Str (">>>");
585 elsif Is_Rewrite_Substitution (Node) then
587 -- Case of dump generated only
589 if Dump_Generated_Only then
590 Sprint_Node_Actual (Node);
592 -- Case of dump original only
594 elsif Dump_Original_Only then
595 Sprint_Node_Actual (Original_Node (Node));
597 -- Case of both being dumped
600 Sprint_Node_Actual (Original_Node (Node));
601 Write_Rewrite_Str ("<<<");
602 Sprint_Node_Actual (Node);
603 Write_Rewrite_Str (">>>");
607 Sprint_Node_Actual (Node);
611 ------------------------
612 -- Sprint_Node_Actual --
613 ------------------------
615 procedure Sprint_Node_Actual (Node : Node_Id) is
616 Save_Debug_Node : constant Node_Id := Debug_Node;
623 for J in 1 .. Paren_Count (Node) loop
624 Write_Str_With_Col_Check ("(");
627 -- Setup node for Sloc fixup if writing a debug source file. Note
628 -- that we take care of any previous node not yet properly set.
630 if Debug_Generated_Code then
634 if Nkind (Node) in N_Subexpr
635 and then Do_Range_Check (Node)
637 Write_Str_With_Col_Check ("{");
640 -- Select print circuit based on node kind
644 when N_Abort_Statement =>
645 Write_Indent_Str_Sloc ("abort ");
646 Sprint_Comma_List (Names (Node));
649 when N_Abortable_Part =>
651 Write_Str_Sloc ("abort ");
652 Sprint_Indented_List (Statements (Node));
654 when N_Abstract_Subprogram_Declaration =>
656 Sprint_Node (Specification (Node));
657 Write_Str_With_Col_Check (" is ");
658 Write_Str_Sloc ("abstract;");
660 when N_Accept_Alternative =>
661 Sprint_Node_List (Pragmas_Before (Node));
663 if Present (Condition (Node)) then
664 Write_Indent_Str ("when ");
665 Sprint_Node (Condition (Node));
670 Sprint_Node_Sloc (Accept_Statement (Node));
671 Sprint_Node_List (Statements (Node));
673 when N_Accept_Statement =>
674 Write_Indent_Str_Sloc ("accept ");
675 Write_Id (Entry_Direct_Name (Node));
677 if Present (Entry_Index (Node)) then
678 Write_Str_With_Col_Check (" (");
679 Sprint_Node (Entry_Index (Node));
683 Write_Param_Specs (Node);
685 if Present (Handled_Statement_Sequence (Node)) then
686 Write_Str_With_Col_Check (" do");
687 Sprint_Node (Handled_Statement_Sequence (Node));
688 Write_Indent_Str ("end ");
689 Write_Id (Entry_Direct_Name (Node));
694 when N_Access_Definition =>
695 Write_Str_With_Col_Check_Sloc ("access ");
696 Sprint_Node (Subtype_Mark (Node));
698 when N_Access_Function_Definition =>
699 Write_Str_With_Col_Check_Sloc ("access ");
701 if Protected_Present (Node) then
702 Write_Str_With_Col_Check ("protected ");
705 Write_Str_With_Col_Check ("function");
706 Write_Param_Specs (Node);
707 Write_Str_With_Col_Check (" return ");
708 Sprint_Node (Subtype_Mark (Node));
710 when N_Access_Procedure_Definition =>
711 Write_Str_With_Col_Check_Sloc ("access ");
713 if Protected_Present (Node) then
714 Write_Str_With_Col_Check ("protected ");
717 Write_Str_With_Col_Check ("procedure");
718 Write_Param_Specs (Node);
720 when N_Access_To_Object_Definition =>
721 Write_Str_With_Col_Check_Sloc ("access ");
723 if All_Present (Node) then
724 Write_Str_With_Col_Check ("all ");
725 elsif Constant_Present (Node) then
726 Write_Str_With_Col_Check ("constant ");
729 Sprint_Node (Subtype_Indication (Node));
732 if Null_Record_Present (Node) then
733 Write_Str_With_Col_Check_Sloc ("(null record)");
736 Write_Str_With_Col_Check_Sloc ("(");
738 if Present (Expressions (Node)) then
739 Sprint_Comma_List (Expressions (Node));
741 if Present (Component_Associations (Node)) then
746 if Present (Component_Associations (Node)) then
753 Nd := First (Component_Associations (Node));
761 if not Is_Rewrite_Insertion (Nd)
762 or else not Dump_Original_Only
776 Write_Str_With_Col_Check_Sloc ("new ");
777 Sprint_Node (Expression (Node));
779 if Present (Storage_Pool (Node)) then
780 Write_Str_With_Col_Check ("[storage_pool = ");
781 Sprint_Node (Storage_Pool (Node));
786 Sprint_Left_Opnd (Node);
787 Write_Str_Sloc (" and then ");
788 Sprint_Right_Opnd (Node);
791 Write_Indent_Str_Sloc ("for ");
792 Write_Id (Identifier (Node));
793 Write_Str_With_Col_Check (" use at ");
794 Sprint_Node (Expression (Node));
797 when N_Assignment_Statement =>
799 Sprint_Node (Name (Node));
800 Write_Str_Sloc (" := ");
801 Sprint_Node (Expression (Node));
804 when N_Asynchronous_Select =>
805 Write_Indent_Str_Sloc ("select");
807 Sprint_Node (Triggering_Alternative (Node));
810 -- Note: let the printing of Abortable_Part handle outputting
811 -- the ABORT keyword, so that the Slco can be set correctly.
813 Write_Indent_Str ("then ");
814 Sprint_Node (Abortable_Part (Node));
815 Write_Indent_Str ("end select;");
817 when N_Attribute_Definition_Clause =>
818 Write_Indent_Str_Sloc ("for ");
819 Sprint_Node (Name (Node));
821 Write_Name_With_Col_Check (Chars (Node));
822 Write_Str_With_Col_Check (" use ");
823 Sprint_Node (Expression (Node));
826 when N_Attribute_Reference =>
827 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
831 Sprint_Node (Prefix (Node));
832 Write_Char_Sloc (''');
833 Write_Name_With_Col_Check (Attribute_Name (Node));
834 Sprint_Paren_Comma_List (Expressions (Node));
836 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
840 when N_Block_Statement =>
843 if Present (Identifier (Node))
844 and then (not Has_Created_Identifier (Node)
845 or else not Dump_Original_Only)
847 Write_Rewrite_Str ("<<<");
848 Write_Id (Identifier (Node));
850 Write_Rewrite_Str (">>>");
853 if Present (Declarations (Node)) then
854 Write_Str_With_Col_Check_Sloc ("declare");
855 Sprint_Indented_List (Declarations (Node));
859 Write_Str_With_Col_Check_Sloc ("begin");
860 Sprint_Node (Handled_Statement_Sequence (Node));
861 Write_Indent_Str ("end");
863 if Present (Identifier (Node))
864 and then (not Has_Created_Identifier (Node)
865 or else not Dump_Original_Only)
867 Write_Rewrite_Str ("<<<");
869 Write_Id (Identifier (Node));
870 Write_Rewrite_Str (">>>");
875 when N_Case_Statement =>
876 Write_Indent_Str_Sloc ("case ");
877 Sprint_Node (Expression (Node));
879 Sprint_Indented_List (Alternatives (Node));
880 Write_Indent_Str ("end case;");
882 when N_Case_Statement_Alternative =>
883 Write_Indent_Str_Sloc ("when ");
884 Sprint_Bar_List (Discrete_Choices (Node));
886 Sprint_Indented_List (Statements (Node));
888 when N_Character_Literal =>
890 Write_Indent_Str (" ");
893 Write_Char_Sloc (''');
894 Write_Char_Code (Char_Literal_Value (Node));
897 when N_Code_Statement =>
900 Sprint_Node (Expression (Node));
903 when N_Compilation_Unit =>
904 Sprint_Node_List (Context_Items (Node));
905 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
907 if Private_Present (Node) then
908 Write_Indent_Str ("private ");
912 Sprint_Node_Sloc (Unit (Node));
914 if Present (Actions (Aux_Decls_Node (Node)))
916 Present (Pragmas_After (Aux_Decls_Node (Node)))
921 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
922 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
924 when N_Compilation_Unit_Aux =>
925 null; -- nothing to do, never used, see above
927 when N_Component_Association =>
929 Sprint_Bar_List (Choices (Node));
931 Sprint_Node (Expression (Node));
933 when N_Component_Clause =>
935 Sprint_Node (Component_Name (Node));
936 Write_Str_Sloc (" at ");
937 Sprint_Node (Position (Node));
939 Write_Str_With_Col_Check ("range ");
940 Sprint_Node (First_Bit (Node));
942 Sprint_Node (Last_Bit (Node));
945 when N_Component_Declaration =>
946 if Write_Indent_Identifiers_Sloc (Node) then
949 if Aliased_Present (Node) then
950 Write_Str_With_Col_Check ("aliased ");
953 Sprint_Node (Subtype_Indication (Node));
955 if Present (Expression (Node)) then
957 Sprint_Node (Expression (Node));
963 when N_Component_List =>
964 if Null_Present (Node) then
966 Write_Indent_Str_Sloc ("null");
972 Sprint_Indented_List (Component_Items (Node));
973 Sprint_Node (Variant_Part (Node));
976 when N_Conditional_Entry_Call =>
977 Write_Indent_Str_Sloc ("select");
979 Sprint_Node (Entry_Call_Alternative (Node));
981 Write_Indent_Str ("else");
982 Sprint_Indented_List (Else_Statements (Node));
983 Write_Indent_Str ("end select;");
985 when N_Conditional_Expression =>
987 Condition : constant Node_Id := First (Expressions (Node));
988 Then_Expr : constant Node_Id := Next (Condition);
989 Else_Expr : constant Node_Id := Next (Then_Expr);
992 Write_Str_With_Col_Check_Sloc ("(if ");
993 Sprint_Node (Condition);
994 Write_Str_With_Col_Check (" then ");
995 Sprint_Node (Then_Expr);
996 Write_Str_With_Col_Check (" else ");
997 Sprint_Node (Else_Expr);
1001 when N_Constrained_Array_Definition =>
1002 Write_Str_With_Col_Check_Sloc ("array ");
1003 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1006 if Aliased_Present (Node) then
1007 Write_Str_With_Col_Check ("aliased ");
1010 Sprint_Node (Subtype_Indication (Node));
1012 when N_Decimal_Fixed_Point_Definition =>
1013 Write_Str_With_Col_Check_Sloc (" delta ");
1014 Sprint_Node (Delta_Expression (Node));
1015 Write_Str_With_Col_Check ("digits ");
1016 Sprint_Node (Digits_Expression (Node));
1017 Sprint_Opt_Node (Real_Range_Specification (Node));
1019 when N_Defining_Character_Literal =>
1020 Write_Name_With_Col_Check_Sloc (Chars (Node));
1022 when N_Defining_Identifier =>
1026 when N_Defining_Operator_Symbol =>
1027 Write_Name_With_Col_Check_Sloc (Chars (Node));
1029 when N_Defining_Program_Unit_Name =>
1031 Sprint_Node (Name (Node));
1033 Write_Id (Defining_Identifier (Node));
1035 when N_Delay_Alternative =>
1036 Sprint_Node_List (Pragmas_Before (Node));
1038 if Present (Condition (Node)) then
1040 Write_Str_With_Col_Check ("when ");
1041 Sprint_Node (Condition (Node));
1046 Sprint_Node_Sloc (Delay_Statement (Node));
1047 Sprint_Node_List (Statements (Node));
1049 when N_Delay_Relative_Statement =>
1050 Write_Indent_Str_Sloc ("delay ");
1051 Sprint_Node (Expression (Node));
1054 when N_Delay_Until_Statement =>
1055 Write_Indent_Str_Sloc ("delay until ");
1056 Sprint_Node (Expression (Node));
1059 when N_Delta_Constraint =>
1060 Write_Str_With_Col_Check_Sloc ("delta ");
1061 Sprint_Node (Delta_Expression (Node));
1062 Sprint_Opt_Node (Range_Constraint (Node));
1064 when N_Derived_Type_Definition =>
1065 if Abstract_Present (Node) then
1066 Write_Str_With_Col_Check ("abstract ");
1069 Write_Str_With_Col_Check_Sloc ("new ");
1070 Sprint_Node (Subtype_Indication (Node));
1072 if Present (Record_Extension_Part (Node)) then
1073 Write_Str_With_Col_Check (" with ");
1074 Sprint_Node (Record_Extension_Part (Node));
1077 when N_Designator =>
1078 Sprint_Node (Name (Node));
1079 Write_Char_Sloc ('.');
1080 Write_Id (Identifier (Node));
1082 when N_Digits_Constraint =>
1083 Write_Str_With_Col_Check_Sloc ("digits ");
1084 Sprint_Node (Digits_Expression (Node));
1085 Sprint_Opt_Node (Range_Constraint (Node));
1087 when N_Discriminant_Association =>
1090 if Present (Selector_Names (Node)) then
1091 Sprint_Bar_List (Selector_Names (Node));
1096 Sprint_Node (Expression (Node));
1098 when N_Discriminant_Specification =>
1101 if Write_Identifiers (Node) then
1103 Sprint_Node (Discriminant_Type (Node));
1105 if Present (Expression (Node)) then
1107 Sprint_Node (Expression (Node));
1113 when N_Elsif_Part =>
1114 Write_Indent_Str_Sloc ("elsif ");
1115 Sprint_Node (Condition (Node));
1116 Write_Str_With_Col_Check (" then");
1117 Sprint_Indented_List (Then_Statements (Node));
1122 when N_Entry_Body =>
1123 Write_Indent_Str_Sloc ("entry ");
1124 Write_Id (Defining_Identifier (Node));
1125 Sprint_Node (Entry_Body_Formal_Part (Node));
1126 Write_Str_With_Col_Check (" is");
1127 Sprint_Indented_List (Declarations (Node));
1128 Write_Indent_Str ("begin");
1129 Sprint_Node (Handled_Statement_Sequence (Node));
1130 Write_Indent_Str ("end ");
1131 Write_Id (Defining_Identifier (Node));
1134 when N_Entry_Body_Formal_Part =>
1135 if Present (Entry_Index_Specification (Node)) then
1136 Write_Str_With_Col_Check_Sloc (" (");
1137 Sprint_Node (Entry_Index_Specification (Node));
1141 Write_Param_Specs (Node);
1142 Write_Str_With_Col_Check_Sloc (" when ");
1143 Sprint_Node (Condition (Node));
1145 when N_Entry_Call_Alternative =>
1146 Sprint_Node_List (Pragmas_Before (Node));
1147 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1148 Sprint_Node_List (Statements (Node));
1150 when N_Entry_Call_Statement =>
1152 Sprint_Node_Sloc (Name (Node));
1153 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1156 when N_Entry_Declaration =>
1157 Write_Indent_Str_Sloc ("entry ");
1158 Write_Id (Defining_Identifier (Node));
1160 if Present (Discrete_Subtype_Definition (Node)) then
1161 Write_Str_With_Col_Check (" (");
1162 Sprint_Node (Discrete_Subtype_Definition (Node));
1166 Write_Param_Specs (Node);
1169 when N_Entry_Index_Specification =>
1170 Write_Str_With_Col_Check_Sloc ("for ");
1171 Write_Id (Defining_Identifier (Node));
1172 Write_Str_With_Col_Check (" in ");
1173 Sprint_Node (Discrete_Subtype_Definition (Node));
1175 when N_Enumeration_Representation_Clause =>
1176 Write_Indent_Str_Sloc ("for ");
1177 Write_Id (Identifier (Node));
1178 Write_Str_With_Col_Check (" use ");
1179 Sprint_Node (Array_Aggregate (Node));
1182 when N_Enumeration_Type_Definition =>
1185 -- Skip attempt to print Literals field if it's not there and
1186 -- we are in package Standard (case of Character, which is
1187 -- handled specially (without an explicit literals list).
1189 if Sloc (Node) > Standard_Location
1190 or else Present (Literals (Node))
1192 Sprint_Paren_Comma_List (Literals (Node));
1196 Write_Str_With_Col_Check_Sloc ("<error>");
1198 when N_Exception_Declaration =>
1199 if Write_Indent_Identifiers (Node) then
1200 Write_Str_With_Col_Check (" : ");
1201 Write_Str_Sloc ("exception;");
1204 when N_Exception_Handler =>
1205 Write_Indent_Str_Sloc ("when ");
1207 if Present (Choice_Parameter (Node)) then
1208 Sprint_Node (Choice_Parameter (Node));
1212 Sprint_Bar_List (Exception_Choices (Node));
1214 Sprint_Indented_List (Statements (Node));
1216 when N_Exception_Renaming_Declaration =>
1219 Sprint_Node (Defining_Identifier (Node));
1220 Write_Str_With_Col_Check (" : exception renames ");
1221 Sprint_Node (Name (Node));
1224 when N_Exit_Statement =>
1225 Write_Indent_Str_Sloc ("exit");
1226 Sprint_Opt_Node (Name (Node));
1228 if Present (Condition (Node)) then
1229 Write_Str_With_Col_Check (" when ");
1230 Sprint_Node (Condition (Node));
1235 when N_Expanded_Name =>
1236 Sprint_Node (Prefix (Node));
1237 Write_Char_Sloc ('.');
1238 Sprint_Node (Selector_Name (Node));
1240 when N_Explicit_Dereference =>
1241 Sprint_Node (Prefix (Node));
1242 Write_Char_Sloc ('.');
1243 Write_Str_Sloc ("all");
1245 when N_Extension_Aggregate =>
1246 Write_Str_With_Col_Check_Sloc ("(");
1247 Sprint_Node (Ancestor_Part (Node));
1248 Write_Str_With_Col_Check (" with ");
1250 if Null_Record_Present (Node) then
1251 Write_Str_With_Col_Check ("null record");
1253 if Present (Expressions (Node)) then
1254 Sprint_Comma_List (Expressions (Node));
1256 if Present (Component_Associations (Node)) then
1261 if Present (Component_Associations (Node)) then
1262 Sprint_Comma_List (Component_Associations (Node));
1268 when N_Floating_Point_Definition =>
1269 Write_Str_With_Col_Check_Sloc ("digits ");
1270 Sprint_Node (Digits_Expression (Node));
1271 Sprint_Opt_Node (Real_Range_Specification (Node));
1273 when N_Formal_Decimal_Fixed_Point_Definition =>
1274 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1276 when N_Formal_Derived_Type_Definition =>
1277 Write_Str_With_Col_Check_Sloc ("new ");
1278 Sprint_Node (Subtype_Mark (Node));
1280 if Private_Present (Node) then
1281 Write_Str_With_Col_Check (" with private");
1284 when N_Formal_Discrete_Type_Definition =>
1285 Write_Str_With_Col_Check_Sloc ("<>");
1287 when N_Formal_Floating_Point_Definition =>
1288 Write_Str_With_Col_Check_Sloc ("digits <>");
1290 when N_Formal_Modular_Type_Definition =>
1291 Write_Str_With_Col_Check_Sloc ("mod <>");
1293 when N_Formal_Object_Declaration =>
1296 if Write_Indent_Identifiers (Node) then
1299 if In_Present (Node) then
1300 Write_Str_With_Col_Check ("in ");
1303 if Out_Present (Node) then
1304 Write_Str_With_Col_Check ("out ");
1307 Sprint_Node (Subtype_Mark (Node));
1309 if Present (Expression (Node)) then
1311 Sprint_Node (Expression (Node));
1317 when N_Formal_Ordinary_Fixed_Point_Definition =>
1318 Write_Str_With_Col_Check_Sloc ("delta <>");
1320 when N_Formal_Package_Declaration =>
1321 Write_Indent_Str_Sloc ("with package ");
1322 Write_Id (Defining_Identifier (Node));
1323 Write_Str_With_Col_Check (" is new ");
1324 Sprint_Node (Name (Node));
1325 Write_Str_With_Col_Check (" (<>);");
1327 when N_Formal_Private_Type_Definition =>
1328 if Abstract_Present (Node) then
1329 Write_Str_With_Col_Check ("abstract ");
1332 if Tagged_Present (Node) then
1333 Write_Str_With_Col_Check ("tagged ");
1336 if Limited_Present (Node) then
1337 Write_Str_With_Col_Check ("limited ");
1340 Write_Str_With_Col_Check_Sloc ("private");
1342 when N_Formal_Signed_Integer_Type_Definition =>
1343 Write_Str_With_Col_Check_Sloc ("range <>");
1345 when N_Formal_Subprogram_Declaration =>
1346 Write_Indent_Str_Sloc ("with ");
1347 Sprint_Node (Specification (Node));
1349 if Box_Present (Node) then
1350 Write_Str_With_Col_Check (" is <>");
1351 elsif Present (Default_Name (Node)) then
1352 Write_Str_With_Col_Check (" is ");
1353 Sprint_Node (Default_Name (Node));
1358 when N_Formal_Type_Declaration =>
1359 Write_Indent_Str_Sloc ("type ");
1360 Write_Id (Defining_Identifier (Node));
1362 if Present (Discriminant_Specifications (Node)) then
1363 Write_Discr_Specs (Node);
1364 elsif Unknown_Discriminants_Present (Node) then
1365 Write_Str_With_Col_Check ("(<>)");
1368 Write_Str_With_Col_Check (" is ");
1369 Sprint_Node (Formal_Type_Definition (Node));
1372 when N_Free_Statement =>
1373 Write_Indent_Str_Sloc ("free ");
1374 Sprint_Node (Expression (Node));
1377 when N_Freeze_Entity =>
1378 if Dump_Original_Only then
1381 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1383 Write_Rewrite_Str ("<<<");
1384 Write_Str_With_Col_Check_Sloc ("freeze ");
1385 Write_Id (Entity (Node));
1388 if No (Actions (Node)) then
1392 Freeze_Indent := Freeze_Indent + 1;
1393 Sprint_Indented_List (Actions (Node));
1394 Freeze_Indent := Freeze_Indent - 1;
1395 Write_Indent_Str ("]");
1398 Write_Rewrite_Str (">>>");
1401 when N_Full_Type_Declaration =>
1402 Write_Indent_Str_Sloc ("type ");
1403 Write_Id (Defining_Identifier (Node));
1404 Write_Discr_Specs (Node);
1405 Write_Str_With_Col_Check (" is ");
1406 Sprint_Node (Type_Definition (Node));
1409 when N_Function_Call =>
1411 Sprint_Node (Name (Node));
1412 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1414 when N_Function_Instantiation =>
1415 Write_Indent_Str_Sloc ("function ");
1416 Sprint_Node (Defining_Unit_Name (Node));
1417 Write_Str_With_Col_Check (" is new ");
1418 Sprint_Node (Name (Node));
1419 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1422 when N_Function_Specification =>
1423 Write_Str_With_Col_Check_Sloc ("function ");
1424 Sprint_Node (Defining_Unit_Name (Node));
1425 Write_Param_Specs (Node);
1426 Write_Str_With_Col_Check (" return ");
1427 Sprint_Node (Subtype_Mark (Node));
1429 when N_Generic_Association =>
1432 if Present (Selector_Name (Node)) then
1433 Sprint_Node (Selector_Name (Node));
1437 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1439 when N_Generic_Function_Renaming_Declaration =>
1440 Write_Indent_Str_Sloc ("generic function ");
1441 Sprint_Node (Defining_Unit_Name (Node));
1442 Write_Str_With_Col_Check (" renames ");
1443 Sprint_Node (Name (Node));
1446 when N_Generic_Package_Declaration =>
1448 Write_Indent_Str_Sloc ("generic ");
1449 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1451 Sprint_Node (Specification (Node));
1454 when N_Generic_Package_Renaming_Declaration =>
1455 Write_Indent_Str_Sloc ("generic package ");
1456 Sprint_Node (Defining_Unit_Name (Node));
1457 Write_Str_With_Col_Check (" renames ");
1458 Sprint_Node (Name (Node));
1461 when N_Generic_Procedure_Renaming_Declaration =>
1462 Write_Indent_Str_Sloc ("generic procedure ");
1463 Sprint_Node (Defining_Unit_Name (Node));
1464 Write_Str_With_Col_Check (" renames ");
1465 Sprint_Node (Name (Node));
1468 when N_Generic_Subprogram_Declaration =>
1470 Write_Indent_Str_Sloc ("generic ");
1471 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1473 Sprint_Node (Specification (Node));
1476 when N_Goto_Statement =>
1477 Write_Indent_Str_Sloc ("goto ");
1478 Sprint_Node (Name (Node));
1481 if Nkind (Next (Node)) = N_Label then
1485 when N_Handled_Sequence_Of_Statements =>
1487 Sprint_Indented_List (Statements (Node));
1489 if Present (Exception_Handlers (Node)) then
1490 Write_Indent_Str ("exception");
1492 Sprint_Node_List (Exception_Handlers (Node));
1496 if Present (At_End_Proc (Node)) then
1497 Write_Indent_Str ("at end");
1500 Sprint_Node (At_End_Proc (Node));
1505 when N_Identifier =>
1509 when N_If_Statement =>
1510 Write_Indent_Str_Sloc ("if ");
1511 Sprint_Node (Condition (Node));
1512 Write_Str_With_Col_Check (" then");
1513 Sprint_Indented_List (Then_Statements (Node));
1514 Sprint_Opt_Node_List (Elsif_Parts (Node));
1516 if Present (Else_Statements (Node)) then
1517 Write_Indent_Str ("else");
1518 Sprint_Indented_List (Else_Statements (Node));
1521 Write_Indent_Str ("end if;");
1523 when N_Implicit_Label_Declaration =>
1524 if not Dump_Original_Only then
1526 Write_Rewrite_Str ("<<<");
1528 Write_Id (Defining_Identifier (Node));
1530 Write_Str_With_Col_Check ("label");
1531 Write_Rewrite_Str (">>>");
1535 Sprint_Left_Opnd (Node);
1536 Write_Str_Sloc (" in ");
1537 Sprint_Right_Opnd (Node);
1539 when N_Incomplete_Type_Declaration =>
1540 Write_Indent_Str_Sloc ("type ");
1541 Write_Id (Defining_Identifier (Node));
1543 if Present (Discriminant_Specifications (Node)) then
1544 Write_Discr_Specs (Node);
1545 elsif Unknown_Discriminants_Present (Node) then
1546 Write_Str_With_Col_Check ("(<>)");
1551 when N_Index_Or_Discriminant_Constraint =>
1553 Sprint_Paren_Comma_List (Constraints (Node));
1555 when N_Indexed_Component =>
1556 Sprint_Node_Sloc (Prefix (Node));
1557 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1559 when N_Integer_Literal =>
1560 if Print_In_Hex (Node) then
1561 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1563 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1566 when N_Iteration_Scheme =>
1567 if Present (Condition (Node)) then
1568 Write_Str_With_Col_Check_Sloc ("while ");
1569 Sprint_Node (Condition (Node));
1571 Write_Str_With_Col_Check_Sloc ("for ");
1572 Sprint_Node (Loop_Parameter_Specification (Node));
1577 when N_Itype_Reference =>
1578 Write_Indent_Str_Sloc ("reference ");
1579 Write_Id (Itype (Node));
1582 Write_Indent_Str_Sloc ("<<");
1583 Write_Id (Identifier (Node));
1586 when N_Loop_Parameter_Specification =>
1588 Write_Id (Defining_Identifier (Node));
1589 Write_Str_With_Col_Check (" in ");
1591 if Reverse_Present (Node) then
1592 Write_Str_With_Col_Check ("reverse ");
1595 Sprint_Node (Discrete_Subtype_Definition (Node));
1597 when N_Loop_Statement =>
1600 if Present (Identifier (Node))
1601 and then (not Has_Created_Identifier (Node)
1602 or else not Dump_Original_Only)
1604 Write_Rewrite_Str ("<<<");
1605 Write_Id (Identifier (Node));
1607 Write_Rewrite_Str (">>>");
1608 Sprint_Node (Iteration_Scheme (Node));
1609 Write_Str_With_Col_Check_Sloc ("loop");
1610 Sprint_Indented_List (Statements (Node));
1611 Write_Indent_Str ("end loop ");
1612 Write_Rewrite_Str ("<<<");
1613 Write_Id (Identifier (Node));
1614 Write_Rewrite_Str (">>>");
1618 Sprint_Node (Iteration_Scheme (Node));
1619 Write_Str_With_Col_Check_Sloc ("loop");
1620 Sprint_Indented_List (Statements (Node));
1621 Write_Indent_Str ("end loop;");
1624 when N_Mod_Clause =>
1625 Sprint_Node_List (Pragmas_Before (Node));
1626 Write_Str_With_Col_Check_Sloc ("at mod ");
1627 Sprint_Node (Expression (Node));
1629 when N_Modular_Type_Definition =>
1630 Write_Str_With_Col_Check_Sloc ("mod ");
1631 Sprint_Node (Expression (Node));
1634 Sprint_Left_Opnd (Node);
1635 Write_Str_Sloc (" not in ");
1636 Sprint_Right_Opnd (Node);
1639 Write_Str_With_Col_Check_Sloc ("null");
1641 when N_Null_Statement =>
1642 if Comes_From_Source (Node)
1643 or else Dump_Freeze_Null
1644 or else not Is_List_Member (Node)
1645 or else (No (Prev (Node)) and then No (Next (Node)))
1647 Write_Indent_Str_Sloc ("null;");
1650 when N_Number_Declaration =>
1653 if Write_Indent_Identifiers (Node) then
1654 Write_Str_With_Col_Check (" : constant ");
1656 Sprint_Node (Expression (Node));
1660 when N_Object_Declaration =>
1663 if Write_Indent_Identifiers (Node) then
1666 if Aliased_Present (Node) then
1667 Write_Str_With_Col_Check ("aliased ");
1670 if Constant_Present (Node) then
1671 Write_Str_With_Col_Check ("constant ");
1674 Sprint_Node (Object_Definition (Node));
1676 if Present (Expression (Node)) then
1678 Sprint_Node (Expression (Node));
1684 when N_Object_Renaming_Declaration =>
1687 Sprint_Node (Defining_Identifier (Node));
1689 Sprint_Node (Subtype_Mark (Node));
1690 Write_Str_With_Col_Check (" renames ");
1691 Sprint_Node (Name (Node));
1695 Write_Operator (Node, "abs ");
1696 Sprint_Right_Opnd (Node);
1699 Sprint_Left_Opnd (Node);
1700 Write_Operator (Node, " + ");
1701 Sprint_Right_Opnd (Node);
1704 Sprint_Left_Opnd (Node);
1705 Write_Operator (Node, " and ");
1706 Sprint_Right_Opnd (Node);
1709 Sprint_Left_Opnd (Node);
1710 Write_Operator (Node, " & ");
1711 Sprint_Right_Opnd (Node);
1714 Sprint_Left_Opnd (Node);
1716 Process_TFAI_RR_Flags (Node);
1717 Write_Operator (Node, "/ ");
1718 Sprint_Right_Opnd (Node);
1721 Sprint_Left_Opnd (Node);
1722 Write_Operator (Node, " = ");
1723 Sprint_Right_Opnd (Node);
1726 Sprint_Left_Opnd (Node);
1727 Write_Operator (Node, " ** ");
1728 Sprint_Right_Opnd (Node);
1731 Sprint_Left_Opnd (Node);
1732 Write_Operator (Node, " >= ");
1733 Sprint_Right_Opnd (Node);
1736 Sprint_Left_Opnd (Node);
1737 Write_Operator (Node, " > ");
1738 Sprint_Right_Opnd (Node);
1741 Sprint_Left_Opnd (Node);
1742 Write_Operator (Node, " <= ");
1743 Sprint_Right_Opnd (Node);
1746 Sprint_Left_Opnd (Node);
1747 Write_Operator (Node, " < ");
1748 Sprint_Right_Opnd (Node);
1751 Write_Operator (Node, "-");
1752 Sprint_Right_Opnd (Node);
1755 Sprint_Left_Opnd (Node);
1757 if Treat_Fixed_As_Integer (Node) then
1761 Write_Operator (Node, " mod ");
1762 Sprint_Right_Opnd (Node);
1764 when N_Op_Multiply =>
1765 Sprint_Left_Opnd (Node);
1767 Process_TFAI_RR_Flags (Node);
1768 Write_Operator (Node, "* ");
1769 Sprint_Right_Opnd (Node);
1772 Sprint_Left_Opnd (Node);
1773 Write_Operator (Node, " /= ");
1774 Sprint_Right_Opnd (Node);
1777 Write_Operator (Node, "not ");
1778 Sprint_Right_Opnd (Node);
1781 Sprint_Left_Opnd (Node);
1782 Write_Operator (Node, " or ");
1783 Sprint_Right_Opnd (Node);
1786 Write_Operator (Node, "+");
1787 Sprint_Right_Opnd (Node);
1790 Sprint_Left_Opnd (Node);
1792 if Treat_Fixed_As_Integer (Node) then
1796 Write_Operator (Node, " rem ");
1797 Sprint_Right_Opnd (Node);
1803 Write_Str_With_Col_Check ("(");
1804 Sprint_Node (Left_Opnd (Node));
1806 Sprint_Node (Right_Opnd (Node));
1809 when N_Op_Subtract =>
1810 Sprint_Left_Opnd (Node);
1811 Write_Operator (Node, " - ");
1812 Sprint_Right_Opnd (Node);
1815 Sprint_Left_Opnd (Node);
1816 Write_Operator (Node, " xor ");
1817 Sprint_Right_Opnd (Node);
1819 when N_Operator_Symbol =>
1820 Write_Name_With_Col_Check_Sloc (Chars (Node));
1822 when N_Ordinary_Fixed_Point_Definition =>
1823 Write_Str_With_Col_Check_Sloc ("delta ");
1824 Sprint_Node (Delta_Expression (Node));
1825 Sprint_Opt_Node (Real_Range_Specification (Node));
1828 Sprint_Left_Opnd (Node);
1829 Write_Str_Sloc (" or else ");
1830 Sprint_Right_Opnd (Node);
1832 when N_Others_Choice =>
1833 if All_Others (Node) then
1834 Write_Str_With_Col_Check ("all ");
1837 Write_Str_With_Col_Check_Sloc ("others");
1839 when N_Package_Body =>
1841 Write_Indent_Str_Sloc ("package body ");
1842 Sprint_Node (Defining_Unit_Name (Node));
1844 Sprint_Indented_List (Declarations (Node));
1846 if Present (Handled_Statement_Sequence (Node)) then
1847 Write_Indent_Str ("begin");
1848 Sprint_Node (Handled_Statement_Sequence (Node));
1851 Write_Indent_Str ("end ");
1852 Sprint_Node (Defining_Unit_Name (Node));
1855 when N_Package_Body_Stub =>
1856 Write_Indent_Str_Sloc ("package body ");
1857 Sprint_Node (Defining_Identifier (Node));
1858 Write_Str_With_Col_Check (" is separate;");
1860 when N_Package_Declaration =>
1863 Sprint_Node_Sloc (Specification (Node));
1866 when N_Package_Instantiation =>
1868 Write_Indent_Str_Sloc ("package ");
1869 Sprint_Node (Defining_Unit_Name (Node));
1870 Write_Str (" is new ");
1871 Sprint_Node (Name (Node));
1872 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1875 when N_Package_Renaming_Declaration =>
1876 Write_Indent_Str_Sloc ("package ");
1877 Sprint_Node (Defining_Unit_Name (Node));
1878 Write_Str_With_Col_Check (" renames ");
1879 Sprint_Node (Name (Node));
1882 when N_Package_Specification =>
1883 Write_Str_With_Col_Check_Sloc ("package ");
1884 Sprint_Node (Defining_Unit_Name (Node));
1886 Sprint_Indented_List (Visible_Declarations (Node));
1888 if Present (Private_Declarations (Node)) then
1889 Write_Indent_Str ("private");
1890 Sprint_Indented_List (Private_Declarations (Node));
1893 Write_Indent_Str ("end ");
1894 Sprint_Node (Defining_Unit_Name (Node));
1896 when N_Parameter_Association =>
1897 Sprint_Node_Sloc (Selector_Name (Node));
1899 Sprint_Node (Explicit_Actual_Parameter (Node));
1901 when N_Parameter_Specification =>
1904 if Write_Identifiers (Node) then
1907 if In_Present (Node) then
1908 Write_Str_With_Col_Check ("in ");
1911 if Out_Present (Node) then
1912 Write_Str_With_Col_Check ("out ");
1915 Sprint_Node (Parameter_Type (Node));
1917 if Present (Expression (Node)) then
1919 Sprint_Node (Expression (Node));
1926 Write_Indent_Str_Sloc ("pragma ");
1927 Write_Name_With_Col_Check (Chars (Node));
1929 if Present (Pragma_Argument_Associations (Node)) then
1930 Sprint_Opt_Paren_Comma_List
1931 (Pragma_Argument_Associations (Node));
1936 when N_Pragma_Argument_Association =>
1939 if Chars (Node) /= No_Name then
1940 Write_Name_With_Col_Check (Chars (Node));
1944 Sprint_Node (Expression (Node));
1946 when N_Private_Type_Declaration =>
1947 Write_Indent_Str_Sloc ("type ");
1948 Write_Id (Defining_Identifier (Node));
1950 if Present (Discriminant_Specifications (Node)) then
1951 Write_Discr_Specs (Node);
1952 elsif Unknown_Discriminants_Present (Node) then
1953 Write_Str_With_Col_Check ("(<>)");
1958 if Tagged_Present (Node) then
1959 Write_Str_With_Col_Check ("tagged ");
1962 if Limited_Present (Node) then
1963 Write_Str_With_Col_Check ("limited ");
1966 Write_Str_With_Col_Check ("private;");
1968 when N_Private_Extension_Declaration =>
1969 Write_Indent_Str_Sloc ("type ");
1970 Write_Id (Defining_Identifier (Node));
1972 if Present (Discriminant_Specifications (Node)) then
1973 Write_Discr_Specs (Node);
1974 elsif Unknown_Discriminants_Present (Node) then
1975 Write_Str_With_Col_Check ("(<>)");
1978 Write_Str_With_Col_Check (" is new ");
1979 Sprint_Node (Subtype_Indication (Node));
1980 Write_Str_With_Col_Check (" with private;");
1982 when N_Procedure_Call_Statement =>
1985 Sprint_Node (Name (Node));
1986 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1989 when N_Procedure_Instantiation =>
1990 Write_Indent_Str_Sloc ("procedure ");
1991 Sprint_Node (Defining_Unit_Name (Node));
1992 Write_Str_With_Col_Check (" is new ");
1993 Sprint_Node (Name (Node));
1994 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1997 when N_Procedure_Specification =>
1998 Write_Str_With_Col_Check_Sloc ("procedure ");
1999 Sprint_Node (Defining_Unit_Name (Node));
2000 Write_Param_Specs (Node);
2002 when N_Protected_Body =>
2003 Write_Indent_Str_Sloc ("protected body ");
2004 Write_Id (Defining_Identifier (Node));
2006 Sprint_Indented_List (Declarations (Node));
2007 Write_Indent_Str ("end ");
2008 Write_Id (Defining_Identifier (Node));
2011 when N_Protected_Body_Stub =>
2012 Write_Indent_Str_Sloc ("protected body ");
2013 Write_Id (Defining_Identifier (Node));
2014 Write_Str_With_Col_Check (" is separate;");
2016 when N_Protected_Definition =>
2018 Sprint_Indented_List (Visible_Declarations (Node));
2020 if Present (Private_Declarations (Node)) then
2021 Write_Indent_Str ("private");
2022 Sprint_Indented_List (Private_Declarations (Node));
2025 Write_Indent_Str ("end ");
2027 when N_Protected_Type_Declaration =>
2028 Write_Indent_Str_Sloc ("protected type ");
2029 Write_Id (Defining_Identifier (Node));
2030 Write_Discr_Specs (Node);
2032 Sprint_Node (Protected_Definition (Node));
2033 Write_Id (Defining_Identifier (Node));
2036 when N_Qualified_Expression =>
2037 Sprint_Node (Subtype_Mark (Node));
2038 Write_Char_Sloc (''');
2040 -- Print expression, make sure we have at least one level of
2041 -- parentheses around the expression. For cases of qualified
2042 -- expressions in the source, this is always the case, but
2043 -- for generated qualifications, there may be no explicit
2044 -- parentheses present.
2046 if Paren_Count (Expression (Node)) /= 0 then
2047 Sprint_Node (Expression (Node));
2050 Sprint_Node (Expression (Node));
2054 when N_Raise_Constraint_Error =>
2056 -- This node can be used either as a subexpression or as a
2057 -- statement form. The following test is a reasonably reliable
2058 -- way to distinguish the two cases.
2060 if Is_List_Member (Node)
2061 and then Nkind (Parent (Node)) not in N_Subexpr
2066 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2067 Write_Condition_And_Reason (Node);
2069 when N_Raise_Program_Error =>
2071 -- This node can be used either as a subexpression or as a
2072 -- statement form. The following test is a reasonably reliable
2073 -- way to distinguish the two cases.
2075 if Is_List_Member (Node)
2076 and then Nkind (Parent (Node)) not in N_Subexpr
2081 Write_Str_With_Col_Check_Sloc ("[program_error");
2082 Write_Condition_And_Reason (Node);
2084 when N_Raise_Storage_Error =>
2086 -- This node can be used either as a subexpression or as a
2087 -- statement form. The following test is a reasonably reliable
2088 -- way to distinguish the two cases.
2090 if Is_List_Member (Node)
2091 and then Nkind (Parent (Node)) not in N_Subexpr
2096 Write_Str_With_Col_Check_Sloc ("[storage_error");
2097 Write_Condition_And_Reason (Node);
2099 when N_Raise_Statement =>
2100 Write_Indent_Str_Sloc ("raise ");
2101 Sprint_Node (Name (Node));
2105 Sprint_Node (Low_Bound (Node));
2106 Write_Str_Sloc (" .. ");
2107 Sprint_Node (High_Bound (Node));
2109 when N_Range_Constraint =>
2110 Write_Str_With_Col_Check_Sloc ("range ");
2111 Sprint_Node (Range_Expression (Node));
2113 when N_Real_Literal =>
2114 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2116 when N_Real_Range_Specification =>
2117 Write_Str_With_Col_Check_Sloc ("range ");
2118 Sprint_Node (Low_Bound (Node));
2120 Sprint_Node (High_Bound (Node));
2122 when N_Record_Definition =>
2123 if Abstract_Present (Node) then
2124 Write_Str_With_Col_Check ("abstract ");
2127 if Tagged_Present (Node) then
2128 Write_Str_With_Col_Check ("tagged ");
2131 if Limited_Present (Node) then
2132 Write_Str_With_Col_Check ("limited ");
2135 if Null_Present (Node) then
2136 Write_Str_With_Col_Check_Sloc ("null record");
2139 Write_Str_With_Col_Check_Sloc ("record");
2140 Sprint_Node (Component_List (Node));
2141 Write_Indent_Str ("end record");
2144 when N_Record_Representation_Clause =>
2145 Write_Indent_Str_Sloc ("for ");
2146 Sprint_Node (Identifier (Node));
2147 Write_Str_With_Col_Check (" use record ");
2149 if Present (Mod_Clause (Node)) then
2150 Sprint_Node (Mod_Clause (Node));
2153 Sprint_Indented_List (Component_Clauses (Node));
2154 Write_Indent_Str ("end record;");
2157 Sprint_Node (Prefix (Node));
2158 Write_Str_With_Col_Check_Sloc ("'reference");
2160 when N_Requeue_Statement =>
2161 Write_Indent_Str_Sloc ("requeue ");
2162 Sprint_Node (Name (Node));
2164 if Abort_Present (Node) then
2165 Write_Str_With_Col_Check (" with abort");
2170 when N_Return_Statement =>
2171 if Present (Expression (Node)) then
2172 Write_Indent_Str_Sloc ("return ");
2173 Sprint_Node (Expression (Node));
2176 Write_Indent_Str_Sloc ("return;");
2179 when N_Selective_Accept =>
2180 Write_Indent_Str_Sloc ("select");
2186 Alt_Node := First (Select_Alternatives (Node));
2189 Sprint_Node (Alt_Node);
2192 exit when No (Alt_Node);
2193 Write_Indent_Str ("or");
2197 if Present (Else_Statements (Node)) then
2198 Write_Indent_Str ("else");
2199 Sprint_Indented_List (Else_Statements (Node));
2202 Write_Indent_Str ("end select;");
2204 when N_Signed_Integer_Type_Definition =>
2205 Write_Str_With_Col_Check_Sloc ("range ");
2206 Sprint_Node (Low_Bound (Node));
2208 Sprint_Node (High_Bound (Node));
2210 when N_Single_Protected_Declaration =>
2211 Write_Indent_Str_Sloc ("protected ");
2212 Write_Id (Defining_Identifier (Node));
2214 Sprint_Node (Protected_Definition (Node));
2215 Write_Id (Defining_Identifier (Node));
2218 when N_Single_Task_Declaration =>
2219 Write_Indent_Str_Sloc ("task ");
2220 Write_Id (Defining_Identifier (Node));
2222 if Present (Task_Definition (Node)) then
2224 Sprint_Node (Task_Definition (Node));
2225 Write_Id (Defining_Identifier (Node));
2230 when N_Selected_Component =>
2231 Sprint_Node (Prefix (Node));
2232 Write_Char_Sloc ('.');
2233 Sprint_Node (Selector_Name (Node));
2237 Sprint_Node (Prefix (Node));
2238 Write_Str_With_Col_Check (" (");
2239 Sprint_Node (Discrete_Range (Node));
2242 when N_String_Literal =>
2243 if String_Length (Strval (Node)) + Column > 75 then
2244 Write_Indent_Str (" ");
2248 Write_String_Table_Entry (Strval (Node));
2250 when N_Subprogram_Body =>
2251 if Freeze_Indent = 0 then
2256 Sprint_Node_Sloc (Specification (Node));
2259 Sprint_Indented_List (Declarations (Node));
2260 Write_Indent_Str ("begin");
2261 Sprint_Node (Handled_Statement_Sequence (Node));
2263 Write_Indent_Str ("end ");
2264 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2267 if Is_List_Member (Node)
2268 and then Present (Next (Node))
2269 and then Nkind (Next (Node)) /= N_Subprogram_Body
2274 when N_Subprogram_Body_Stub =>
2276 Sprint_Node_Sloc (Specification (Node));
2277 Write_Str_With_Col_Check (" is separate;");
2279 when N_Subprogram_Declaration =>
2281 Sprint_Node_Sloc (Specification (Node));
2284 when N_Subprogram_Info =>
2285 Sprint_Node (Identifier (Node));
2286 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2288 when N_Subprogram_Renaming_Declaration =>
2290 Sprint_Node (Specification (Node));
2291 Write_Str_With_Col_Check_Sloc (" renames ");
2292 Sprint_Node (Name (Node));
2295 when N_Subtype_Declaration =>
2296 Write_Indent_Str_Sloc ("subtype ");
2297 Write_Id (Defining_Identifier (Node));
2299 Sprint_Node (Subtype_Indication (Node));
2302 when N_Subtype_Indication =>
2303 Sprint_Node_Sloc (Subtype_Mark (Node));
2305 Sprint_Node (Constraint (Node));
2308 Write_Indent_Str_Sloc ("separate (");
2309 Sprint_Node (Name (Node));
2312 Sprint_Node (Proper_Body (Node));
2315 Write_Indent_Str_Sloc ("task body ");
2316 Write_Id (Defining_Identifier (Node));
2318 Sprint_Indented_List (Declarations (Node));
2319 Write_Indent_Str ("begin");
2320 Sprint_Node (Handled_Statement_Sequence (Node));
2321 Write_Indent_Str ("end ");
2322 Write_Id (Defining_Identifier (Node));
2325 when N_Task_Body_Stub =>
2326 Write_Indent_Str_Sloc ("task body ");
2327 Write_Id (Defining_Identifier (Node));
2328 Write_Str_With_Col_Check (" is separate;");
2330 when N_Task_Definition =>
2332 Sprint_Indented_List (Visible_Declarations (Node));
2334 if Present (Private_Declarations (Node)) then
2335 Write_Indent_Str ("private");
2336 Sprint_Indented_List (Private_Declarations (Node));
2339 Write_Indent_Str ("end ");
2341 when N_Task_Type_Declaration =>
2342 Write_Indent_Str_Sloc ("task type ");
2343 Write_Id (Defining_Identifier (Node));
2344 Write_Discr_Specs (Node);
2345 if Present (Task_Definition (Node)) then
2347 Sprint_Node (Task_Definition (Node));
2348 Write_Id (Defining_Identifier (Node));
2353 when N_Terminate_Alternative =>
2354 Sprint_Node_List (Pragmas_Before (Node));
2358 if Present (Condition (Node)) then
2359 Write_Str_With_Col_Check ("when ");
2360 Sprint_Node (Condition (Node));
2364 Write_Str_With_Col_Check_Sloc ("terminate;");
2365 Sprint_Node_List (Pragmas_After (Node));
2367 when N_Timed_Entry_Call =>
2368 Write_Indent_Str_Sloc ("select");
2370 Sprint_Node (Entry_Call_Alternative (Node));
2372 Write_Indent_Str ("or");
2374 Sprint_Node (Delay_Alternative (Node));
2376 Write_Indent_Str ("end select;");
2378 when N_Triggering_Alternative =>
2379 Sprint_Node_List (Pragmas_Before (Node));
2380 Sprint_Node_Sloc (Triggering_Statement (Node));
2381 Sprint_Node_List (Statements (Node));
2383 when N_Type_Conversion =>
2385 Sprint_Node (Subtype_Mark (Node));
2388 if Conversion_OK (Node) then
2392 if Float_Truncate (Node) then
2396 if Rounded_Result (Node) then
2401 Sprint_Node (Expression (Node));
2404 when N_Unchecked_Expression =>
2407 Sprint_Node_Sloc (Expression (Node));
2410 when N_Unchecked_Type_Conversion =>
2411 Sprint_Node (Subtype_Mark (Node));
2413 Write_Str_With_Col_Check ("(");
2414 Sprint_Node_Sloc (Expression (Node));
2417 when N_Unconstrained_Array_Definition =>
2418 Write_Str_With_Col_Check_Sloc ("array (");
2424 Node1 := First (Subtype_Marks (Node));
2426 Sprint_Node (Node1);
2427 Write_Str_With_Col_Check (" range <>");
2429 exit when Node1 = Empty;
2434 Write_Str (") of ");
2436 if Aliased_Present (Node) then
2437 Write_Str_With_Col_Check ("aliased ");
2440 Sprint_Node (Subtype_Indication (Node));
2442 when N_Unused_At_Start | N_Unused_At_End =>
2443 Write_Indent_Str ("***** Error, unused node encountered *****");
2446 when N_Use_Package_Clause =>
2447 Write_Indent_Str_Sloc ("use ");
2448 Sprint_Comma_List (Names (Node));
2451 when N_Use_Type_Clause =>
2452 Write_Indent_Str_Sloc ("use type ");
2453 Sprint_Comma_List (Subtype_Marks (Node));
2456 when N_Validate_Unchecked_Conversion =>
2457 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2458 Sprint_Node (Source_Type (Node));
2460 Sprint_Node (Target_Type (Node));
2464 Write_Indent_Str_Sloc ("when ");
2465 Sprint_Bar_List (Discrete_Choices (Node));
2467 Sprint_Node (Component_List (Node));
2469 when N_Variant_Part =>
2471 Write_Indent_Str_Sloc ("case ");
2472 Sprint_Node (Name (Node));
2474 Sprint_Indented_List (Variants (Node));
2475 Write_Indent_Str ("end case");
2478 when N_With_Clause =>
2480 -- Special test, if we are dumping the original tree only,
2481 -- then we want to eliminate the bogus with clauses that
2482 -- correspond to the non-existent children of Text_IO.
2484 if Dump_Original_Only
2485 and then Is_Text_IO_Kludge_Unit (Name (Node))
2489 -- Normal case, output the with clause
2492 if First_Name (Node) or else not Dump_Original_Only then
2493 if Limited_Present (Node) then
2494 Write_Indent_Str ("limited with ");
2496 Write_Indent_Str ("with ");
2503 Sprint_Node_Sloc (Name (Node));
2505 if Last_Name (Node) or else not Dump_Original_Only then
2510 when N_With_Type_Clause =>
2512 Write_Indent_Str ("with type ");
2513 Sprint_Node_Sloc (Name (Node));
2515 if Tagged_Present (Node) then
2516 Write_Str (" is tagged;");
2518 Write_Str (" is access;");
2523 if Nkind (Node) in N_Subexpr
2524 and then Do_Range_Check (Node)
2529 for J in 1 .. Paren_Count (Node) loop
2533 pragma Assert (No (Debug_Node));
2534 Debug_Node := Save_Debug_Node;
2535 end Sprint_Node_Actual;
2537 ----------------------
2538 -- Sprint_Node_List --
2539 ----------------------
2541 procedure Sprint_Node_List (List : List_Id) is
2545 if Is_Non_Empty_List (List) then
2546 Node := First (List);
2551 exit when Node = Empty;
2554 end Sprint_Node_List;
2556 ----------------------
2557 -- Sprint_Node_Sloc --
2558 ----------------------
2560 procedure Sprint_Node_Sloc (Node : Node_Id) is
2564 if Present (Debug_Node) then
2565 Set_Sloc (Debug_Node, Sloc (Node));
2566 Debug_Node := Empty;
2568 end Sprint_Node_Sloc;
2570 ---------------------
2571 -- Sprint_Opt_Node --
2572 ---------------------
2574 procedure Sprint_Opt_Node (Node : Node_Id) is
2576 if Present (Node) then
2580 end Sprint_Opt_Node;
2582 --------------------------
2583 -- Sprint_Opt_Node_List --
2584 --------------------------
2586 procedure Sprint_Opt_Node_List (List : List_Id) is
2588 if Present (List) then
2589 Sprint_Node_List (List);
2591 end Sprint_Opt_Node_List;
2593 ---------------------------------
2594 -- Sprint_Opt_Paren_Comma_List --
2595 ---------------------------------
2597 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2599 if Is_Non_Empty_List (List) then
2601 Sprint_Paren_Comma_List (List);
2603 end Sprint_Opt_Paren_Comma_List;
2605 -----------------------------
2606 -- Sprint_Paren_Comma_List --
2607 -----------------------------
2609 procedure Sprint_Paren_Comma_List (List : List_Id) is
2611 Node_Exists : Boolean := False;
2615 if Is_Non_Empty_List (List) then
2617 if Dump_Original_Only then
2620 while Present (N) loop
2622 if not Is_Rewrite_Insertion (N) then
2623 Node_Exists := True;
2630 if not Node_Exists then
2635 Write_Str_With_Col_Check ("(");
2636 Sprint_Comma_List (List);
2639 end Sprint_Paren_Comma_List;
2641 ----------------------
2642 -- Sprint_Right_Opnd --
2643 ----------------------
2645 procedure Sprint_Right_Opnd (N : Node_Id) is
2646 Opnd : constant Node_Id := Right_Opnd (N);
2649 if Paren_Count (Opnd) /= 0
2650 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2659 end Sprint_Right_Opnd;
2661 ---------------------
2662 -- Write_Char_Sloc --
2663 ---------------------
2665 procedure Write_Char_Sloc (C : Character) is
2667 if Debug_Generated_Code and then C /= ' ' then
2672 end Write_Char_Sloc;
2674 --------------------------------
2675 -- Write_Condition_And_Reason --
2676 --------------------------------
2678 procedure Write_Condition_And_Reason (Node : Node_Id) is
2679 Image : constant String := RT_Exception_Code'Image
2680 (RT_Exception_Code'Val
2681 (UI_To_Int (Reason (Node))));
2684 if Present (Condition (Node)) then
2685 Write_Str_With_Col_Check (" when ");
2686 Sprint_Node (Condition (Node));
2691 for J in 4 .. Image'Last loop
2692 if Image (J) = '_' then
2695 Write_Char (Fold_Lower (Image (J)));
2700 end Write_Condition_And_Reason;
2702 ------------------------
2703 -- Write_Discr_Specs --
2704 ------------------------
2706 procedure Write_Discr_Specs (N : Node_Id) is
2711 Specs := Discriminant_Specifications (N);
2713 if Present (Specs) then
2714 Write_Str_With_Col_Check (" (");
2715 Spec := First (Specs);
2720 exit when Spec = Empty;
2722 -- Add semicolon, unless we are printing original tree and the
2723 -- next specification is part of a list (but not the first
2724 -- element of that list)
2726 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2733 end Write_Discr_Specs;
2739 procedure Write_Ekind (E : Entity_Id) is
2740 S : constant String := Entity_Kind'Image (Ekind (E));
2743 Name_Len := S'Length;
2744 Name_Buffer (1 .. Name_Len) := S;
2745 Set_Casing (Mixed_Case);
2746 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2753 procedure Write_Id (N : Node_Id) is
2755 -- Case of a defining identifier
2757 if Nkind (N) = N_Defining_Identifier then
2759 -- If defining identifier has an interface name (and no
2760 -- address clause), then we output the interface name.
2762 if (Is_Imported (N) or else Is_Exported (N))
2763 and then Present (Interface_Name (N))
2764 and then No (Address_Clause (N))
2766 String_To_Name_Buffer (Strval (Interface_Name (N)));
2767 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2769 -- If no interface name (or inactive because there was
2770 -- an address clause), then just output the Chars name.
2773 Write_Name_With_Col_Check (Chars (N));
2776 -- Case of selector of an expanded name where the expanded name
2777 -- has an associated entity, output this entity.
2779 elsif Nkind (Parent (N)) = N_Expanded_Name
2780 and then Selector_Name (Parent (N)) = N
2781 and then Present (Entity (Parent (N)))
2783 Write_Id (Entity (Parent (N)));
2785 -- For any other kind of node with an associated entity, output it.
2787 elsif Nkind (N) in N_Has_Entity
2788 and then Present (Entity (N))
2790 Write_Id (Entity (N));
2792 -- All other cases, we just print the Chars field
2795 Write_Name_With_Col_Check (Chars (N));
2799 -----------------------
2800 -- Write_Identifiers --
2801 -----------------------
2803 function Write_Identifiers (Node : Node_Id) return Boolean is
2805 Sprint_Node (Defining_Identifier (Node));
2807 -- The remainder of the declaration must be printed unless we are
2808 -- printing the original tree and this is not the last identifier
2811 not Dump_Original_Only or else not More_Ids (Node);
2813 end Write_Identifiers;
2815 ------------------------
2816 -- Write_Implicit_Def --
2817 ------------------------
2819 procedure Write_Implicit_Def (E : Entity_Id) is
2824 when E_Array_Subtype =>
2825 Write_Str_With_Col_Check ("subtype ");
2827 Write_Str_With_Col_Check (" is ");
2828 Write_Id (Base_Type (E));
2829 Write_Str_With_Col_Check (" (");
2831 Ind := First_Index (E);
2833 while Present (Ind) loop
2837 if Present (Ind) then
2844 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2845 Write_Str_With_Col_Check ("subtype ");
2848 Write_Id (Etype (E));
2849 Write_Str_With_Col_Check (" range ");
2850 Sprint_Node (Scalar_Range (E));
2854 Write_Str_With_Col_Check ("type ");
2856 Write_Str_With_Col_Check (" is <");
2861 end Write_Implicit_Def;
2867 procedure Write_Indent is
2869 if Indent_Annull_Flag then
2870 Indent_Annull_Flag := False;
2874 for J in 1 .. Indent loop
2880 ------------------------------
2881 -- Write_Indent_Identifiers --
2882 ------------------------------
2884 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
2886 -- We need to start a new line for every node, except in the case
2887 -- where we are printing the original tree and this is not the first
2888 -- defining identifier in the list.
2890 if not Dump_Original_Only or else not Prev_Ids (Node) then
2893 -- If printing original tree and this is not the first defining
2894 -- identifier in the list, then the previous call to this procedure
2895 -- printed only the name, and we add a comma to separate the names.
2901 Sprint_Node (Defining_Identifier (Node));
2903 -- The remainder of the declaration must be printed unless we are
2904 -- printing the original tree and this is not the last identifier
2907 not Dump_Original_Only or else not More_Ids (Node);
2909 end Write_Indent_Identifiers;
2911 -----------------------------------
2912 -- Write_Indent_Identifiers_Sloc --
2913 -----------------------------------
2915 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
2917 -- We need to start a new line for every node, except in the case
2918 -- where we are printing the original tree and this is not the first
2919 -- defining identifier in the list.
2921 if not Dump_Original_Only or else not Prev_Ids (Node) then
2924 -- If printing original tree and this is not the first defining
2925 -- identifier in the list, then the previous call to this procedure
2926 -- printed only the name, and we add a comma to separate the names.
2933 Sprint_Node (Defining_Identifier (Node));
2935 -- The remainder of the declaration must be printed unless we are
2936 -- printing the original tree and this is not the last identifier
2939 not Dump_Original_Only or else not More_Ids (Node);
2941 end Write_Indent_Identifiers_Sloc;
2943 ----------------------
2944 -- Write_Indent_Str --
2945 ----------------------
2947 procedure Write_Indent_Str (S : String) is
2951 end Write_Indent_Str;
2953 ---------------------------
2954 -- Write_Indent_Str_Sloc --
2955 ---------------------------
2957 procedure Write_Indent_Str_Sloc (S : String) is
2961 end Write_Indent_Str_Sloc;
2963 -------------------------------
2964 -- Write_Name_With_Col_Check --
2965 -------------------------------
2967 procedure Write_Name_With_Col_Check (N : Name_Id) is
2971 Get_Name_String (N);
2973 -- Deal with -gnatI which replaces digits in an internal
2974 -- name by three dots (e.g. R7b becomes R...b).
2976 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
2979 while J < Name_Len loop
2980 exit when Name_Buffer (J) not in 'A' .. 'Z';
2984 if Name_Buffer (J) in '0' .. '9' then
2985 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
2988 while J <= Name_Len loop
2989 if Name_Buffer (J) not in '0' .. '9' then
2990 Write_Str (Name_Buffer (J .. Name_Len));
3002 -- Fall through for normal case
3004 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3005 end Write_Name_With_Col_Check;
3007 ------------------------------------
3008 -- Write_Name_With_Col_Check_Sloc --
3009 ------------------------------------
3011 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3013 Get_Name_String (N);
3014 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3015 end Write_Name_With_Col_Check_Sloc;
3017 --------------------
3018 -- Write_Operator --
3019 --------------------
3021 procedure Write_Operator (N : Node_Id; S : String) is
3022 F : Natural := S'First;
3023 T : Natural := S'Last;
3026 -- If no overflow check, just write string out, and we are done
3028 if not Do_Overflow_Check (N) then
3031 -- If overflow check, we want to surround the operator with curly
3032 -- brackets, but not include spaces within the brackets.
3045 Write_Str_Sloc (S (F .. T));
3048 if S (S'Last) = ' ' then
3054 -----------------------
3055 -- Write_Param_Specs --
3056 -----------------------
3058 procedure Write_Param_Specs (N : Node_Id) is
3064 Specs := Parameter_Specifications (N);
3066 if Is_Non_Empty_List (Specs) then
3067 Write_Str_With_Col_Check (" (");
3068 Spec := First (Specs);
3072 Formal := Defining_Identifier (Spec);
3074 exit when Spec = Empty;
3076 -- Add semicolon, unless we are printing original tree and the
3077 -- next specification is part of a list (but not the first
3078 -- element of that list)
3080 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3085 -- Write out any extra formals
3087 while Present (Extra_Formal (Formal)) loop
3088 Formal := Extra_Formal (Formal);
3090 Write_Name_With_Col_Check (Chars (Formal));
3092 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3097 end Write_Param_Specs;
3099 --------------------------
3100 -- Write_Rewrite_Str --
3101 --------------------------
3103 procedure Write_Rewrite_Str (S : String) is
3105 if not Dump_Generated_Only then
3106 if S'Length = 3 and then S = ">>>" then
3109 Write_Str_With_Col_Check (S);
3112 end Write_Rewrite_Str;
3114 --------------------
3115 -- Write_Str_Sloc --
3116 --------------------
3118 procedure Write_Str_Sloc (S : String) is
3120 for J in S'Range loop
3121 Write_Char_Sloc (S (J));
3125 ------------------------------
3126 -- Write_Str_With_Col_Check --
3127 ------------------------------
3129 procedure Write_Str_With_Col_Check (S : String) is
3131 if Int (S'Last) + Column > Line_Limit then
3132 Write_Indent_Str (" ");
3135 Write_Str (S (2 .. S'Length));
3143 end Write_Str_With_Col_Check;
3145 -----------------------------------
3146 -- Write_Str_With_Col_Check_Sloc --
3147 -----------------------------------
3149 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3151 if Int (S'Last) + Column > Line_Limit then
3152 Write_Indent_Str (" ");
3155 Write_Str_Sloc (S (2 .. S'Length));
3163 end Write_Str_With_Col_Check_Sloc;
3165 ------------------------------------
3166 -- Write_Uint_With_Col_Check_Sloc --
3167 ------------------------------------
3169 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3171 Col_Check (UI_Decimal_Digits_Hi (U));
3173 UI_Write (U, Format);
3174 end Write_Uint_With_Col_Check_Sloc;
3176 -------------------------------------
3177 -- Write_Ureal_With_Col_Check_Sloc --
3178 -------------------------------------
3180 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3181 D : constant Uint := Denominator (U);
3182 N : constant Uint := Numerator (U);
3186 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3189 end Write_Ureal_With_Col_Check_Sloc;