1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Atree; use Atree;
28 with Casing; use Casing;
29 with Csets; use Csets;
30 with Debug; use Debug;
31 with Einfo; use Einfo;
33 with Namet; use Namet;
34 with Nlists; use Nlists;
36 with Output; use Output;
37 with Rtsfind; use Rtsfind;
38 with Sinfo; use Sinfo;
39 with Sinput; use Sinput;
40 with Sinput.D; use Sinput.D;
41 with Snames; use Snames;
42 with Stand; use Stand;
43 with Stringt; use Stringt;
44 with Uintp; use Uintp;
45 with Uname; use Uname;
46 with Urealp; use Urealp;
48 package body Sprint is
50 Debug_Node : Node_Id := Empty;
51 -- If we are in Debug_Generated_Code mode, then this location is set
52 -- to the current node requiring Sloc fixup, until Set_Debug_Sloc is
53 -- called to set the proper value. The call clears it back to Empty.
55 Debug_Sloc : Source_Ptr;
56 -- Sloc of first byte of line currently being written if we are
57 -- generating a source debug file.
59 Dump_Original_Only : Boolean;
60 -- Set True if the -gnatdo (dump original tree) flag is set
62 Dump_Generated_Only : Boolean;
63 -- Set True if the -gnatG (dump generated tree) debug flag is set
64 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
66 Dump_Freeze_Null : Boolean;
67 -- Set True if freeze nodes and non-source null statements output
70 -- Number of columns for current line output indentation
72 Indent_Annull_Flag : Boolean := False;
73 -- Set True if subsequent Write_Indent call to be ignored, gets reset
74 -- by this call, so it is only active to suppress a single indent call.
76 Line_Limit : constant := 72;
77 -- Limit value for chopping long lines
79 Freeze_Indent : Int := 0;
80 -- Keep track of freeze indent level (controls blank lines before
81 -- procedures within expression freeze actions)
83 -------------------------------
84 -- Operator Precedence Table --
85 -------------------------------
87 -- This table is used to decide whether a subexpression needs to be
88 -- parenthesized. The rule is that if an operand of an operator (which
89 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
90 -- with a lower precedence than the operator (or equal precedence if
91 -- appearing as the right operand), then parentheses are required.
93 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
126 procedure Sprint_Left_Opnd (N : Node_Id);
127 -- Print left operand of operator, parenthesizing if necessary
129 procedure Sprint_Right_Opnd (N : Node_Id);
130 -- Print right operand of operator, parenthesizing if necessary
132 -----------------------
133 -- Local Subprograms --
134 -----------------------
136 procedure Col_Check (N : Nat);
137 -- Check that at least N characters remain on current line, and if not,
138 -- then start an extra line with two characters extra indentation for
139 -- continuing text on the next line.
141 procedure Indent_Annull;
142 -- Causes following call to Write_Indent to be ignored. This is used when
143 -- a higher level node wants to stop a lower level node from starting a
144 -- new line, when it would otherwise be inclined to do so (e.g. the case
145 -- of an accept statement called from an accept alternative with a guard)
147 procedure Indent_Begin;
148 -- Increase indentation level
150 procedure Indent_End;
151 -- Decrease indentation level
153 procedure Print_Debug_Line (S : String);
154 -- Used to print output lines in Debug_Generated_Code mode (this is used
155 -- as the argument for a call to Set_Special_Output in package Output).
157 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
158 -- Given a divide, multiplication or division node, check the flags
159 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
160 -- appropriate special syntax characters (# and @).
162 procedure Set_Debug_Sloc;
163 -- If Debug_Node is non-empty, this routine sets the appropriate value
164 -- in its Sloc field, from the current location in the debug source file
165 -- that is currently being written. Note that Debug_Node is always empty
166 -- if a debug source file is not being written.
168 procedure Sprint_Bar_List (List : List_Id);
169 -- Print the given list with items separated by vertical bars
171 procedure Sprint_Node_Actual (Node : Node_Id);
172 -- This routine prints its node argument. It is a lower level routine than
173 -- Sprint_Node, in that it does not bother about rewritten trees.
175 procedure Sprint_Node_Sloc (Node : Node_Id);
176 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
177 -- sets the Sloc of the current debug node to be a copy of the Sloc
178 -- of the sprinted node Node. Note that this is done after printing
179 -- Node, so that the Sloc is the proper updated value for the debug file.
181 procedure Write_Char_Sloc (C : Character);
182 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
183 -- called to ensure that the current node has a proper Sloc set.
185 procedure Write_Condition_And_Reason (Node : Node_Id);
186 -- Write Condition and Reason codes of Raise_xxx_Error node
188 procedure Write_Discr_Specs (N : Node_Id);
189 -- Ouput discriminant specification for node, which is any of the type
190 -- declarations that can have discriminants.
192 procedure Write_Ekind (E : Entity_Id);
193 -- Write the String corresponding to the Ekind without "E_".
195 procedure Write_Id (N : Node_Id);
196 -- N is a node with a Chars field. This procedure writes the name that
197 -- will be used in the generated code associated with the name. For a
198 -- node with no associated entity, this is simply the Chars field. For
199 -- the case where there is an entity associated with the node, we print
200 -- the name associated with the entity (since it may have been encoded).
201 -- One other special case is that an entity has an active external name
202 -- (i.e. an external name present with no address clause), then this
203 -- external name is output.
205 function Write_Identifiers (Node : Node_Id) return Boolean;
206 -- Handle node where the grammar has a list of defining identifiers, but
207 -- the tree has a separate declaration for each identifier. Handles the
208 -- printing of the defining identifier, and returns True if the type and
209 -- initialization information is to be printed, False if it is to be
210 -- skipped (the latter case happens when printing defining identifiers
211 -- other than the first in the original tree output case).
213 procedure Write_Implicit_Def (E : Entity_Id);
214 pragma Warnings (Off, Write_Implicit_Def);
215 -- Write the definition of the implicit type E according to its Ekind
216 -- For now a debugging procedure, but might be used in the future.
218 procedure Write_Indent;
219 -- Start a new line and write indentation spacing
221 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
222 -- Like Write_Identifiers except that each new printed declaration
223 -- is at the start of a new line.
225 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
226 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
227 -- mode, the Sloc of the current debug node is set to point ot the
228 -- first output identifier.
230 procedure Write_Indent_Str (S : String);
231 -- Start a new line and write indent spacing followed by given string
233 procedure Write_Indent_Str_Sloc (S : String);
234 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
235 -- the Sloc of the current node is set to the first non-blank character
238 procedure Write_Name_With_Col_Check (N : Name_Id);
239 -- Write name (using Write_Name) with initial column check, and possible
240 -- initial Write_Indent (to get new line) if current line is too full.
242 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
243 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
244 -- mode, sets Sloc of current debug node to first character of name.
246 procedure Write_Operator (N : Node_Id; S : String);
247 -- Like Write_Str_Sloc, used for operators, encloses the string in
248 -- characters {} if the Do_Overflow flag is set on the node N.
250 procedure Write_Param_Specs (N : Node_Id);
251 -- Output parameter specifications for node (which is either a function
252 -- or procedure specification with a Parameter_Specifications field)
254 procedure Write_Rewrite_Str (S : String);
255 -- Writes out a string (typically containing <<< or >>>}) for a node
256 -- created by rewriting the tree. Suppressed if we are outputting the
257 -- generated code only, since in this case we don't specially mark nodes
258 -- created by rewriting).
260 procedure Write_Str_Sloc (S : String);
261 -- Like Write_Str, but sets debug Sloc of current debug node to first
262 -- non-blank character if a current debug node is active.
264 procedure Write_Str_With_Col_Check (S : String);
265 -- Write string (using Write_Str) with initial column check, and possible
266 -- initial Write_Indent (to get new line) if current line is too full.
268 procedure Write_Str_With_Col_Check_Sloc (S : String);
269 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
270 -- node to first non-blank character if a current debug node is active.
272 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
273 -- Write Uint (using UI_Write) with initial column check, and possible
274 -- initial Write_Indent (to get new line) if current line is too full.
275 -- The format parameter determines the output format (see UI_Write).
276 -- In addition, in Debug_Generated_Code mode, sets the current node
277 -- Sloc to the first character of the output value.
279 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
280 -- Write Ureal (using same output format as UR_Write) with column checks
281 -- and a possible initial Write_Indent (to get new line) if current line
282 -- is too full. In addition, in Debug_Generated_Code mode, sets the
283 -- current node Sloc to the first character of the output value.
289 procedure Col_Check (N : Nat) is
291 if N + Column > Line_Limit then
292 Write_Indent_Str (" ");
300 procedure Indent_Annull is
302 Indent_Annull_Flag := True;
309 procedure Indent_Begin is
311 Indent := Indent + 3;
318 procedure Indent_End is
320 Indent := Indent - 3;
327 procedure pg (Node : Node_Id) is
329 Dump_Generated_Only := True;
330 Dump_Original_Only := False;
339 procedure po (Node : Node_Id) is
341 Dump_Generated_Only := False;
342 Dump_Original_Only := True;
347 ----------------------
348 -- Print_Debug_Line --
349 ----------------------
351 procedure Print_Debug_Line (S : String) is
353 Write_Debug_Line (S, Debug_Sloc);
354 end Print_Debug_Line;
356 ---------------------------
357 -- Process_TFAI_RR_Flags --
358 ---------------------------
360 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
362 if Treat_Fixed_As_Integer (Nod) then
366 if Rounded_Result (Nod) then
369 end Process_TFAI_RR_Flags;
375 procedure ps (Node : Node_Id) is
377 Dump_Generated_Only := False;
378 Dump_Original_Only := False;
387 procedure Set_Debug_Sloc is
389 if Present (Debug_Node) then
390 Set_Sloc (Debug_Node, Debug_Sloc + Source_Ptr (Column - 1));
399 procedure Source_Dump is
402 -- Put underline under string we just printed
404 procedure Underline is
405 Col : constant Int := Column;
410 while Col > Column loop
417 -- Start of processing for Tree_Dump.
420 Dump_Generated_Only := Debug_Flag_G or
421 Print_Generated_Code or
422 Debug_Generated_Code;
423 Dump_Original_Only := Debug_Flag_O;
424 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
426 -- Note that we turn off the tree dump flags immediately, before
427 -- starting the dump. This avoids generating two copies of the dump
428 -- if an abort occurs after printing the dump, and more importantly,
429 -- avoids an infinite loop if an abort occurs during the dump.
432 Debug_Flag_Z := False;
435 Write_Str ("Source recreated from tree of Standard (spec)");
437 Sprint_Node (Standard_Package_Node);
442 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
443 Debug_Flag_G := False;
444 Debug_Flag_O := False;
445 Debug_Flag_S := False;
447 -- Dump requested units
449 for U in Main_Unit .. Last_Unit loop
451 -- Dump all units if -gnatdf set, otherwise we dump only
452 -- the source files that are in the extended main source.
455 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
457 -- If we are generating debug files, setup to write them
459 if Debug_Generated_Code then
460 Set_Special_Output (Print_Debug_Line'Access);
461 Create_Debug_Source (Source_Index (U), Debug_Sloc);
462 Sprint_Node (Cunit (U));
465 Set_Special_Output (null);
467 -- Normal output to standard output file
470 Write_Str ("Source recreated from tree for ");
471 Write_Unit_Name (Unit_Name (U));
473 Sprint_Node (Cunit (U));
482 ---------------------
483 -- Sprint_Bar_List --
484 ---------------------
486 procedure Sprint_Bar_List (List : List_Id) is
490 if Is_Non_Empty_List (List) then
491 Node := First (List);
496 exit when Node = Empty;
502 -----------------------
503 -- Sprint_Comma_List --
504 -----------------------
506 procedure Sprint_Comma_List (List : List_Id) is
510 if Is_Non_Empty_List (List) then
511 Node := First (List);
516 exit when Node = Empty;
518 if not Is_Rewrite_Insertion (Node)
519 or else not Dump_Original_Only
526 end Sprint_Comma_List;
528 --------------------------
529 -- Sprint_Indented_List --
530 --------------------------
532 procedure Sprint_Indented_List (List : List_Id) is
535 Sprint_Node_List (List);
537 end Sprint_Indented_List;
539 ---------------------
540 -- Sprint_Left_Opnd --
541 ---------------------
543 procedure Sprint_Left_Opnd (N : Node_Id) is
544 Opnd : constant Node_Id := Left_Opnd (N);
547 if Paren_Count (Opnd) /= 0
548 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
557 end Sprint_Left_Opnd;
563 procedure Sprint_Node (Node : Node_Id) is
565 if Is_Rewrite_Insertion (Node) then
566 if not Dump_Original_Only then
568 -- For special cases of nodes that always output <<< >>>
569 -- do not duplicate the output at this point.
571 if Nkind (Node) = N_Freeze_Entity
572 or else Nkind (Node) = N_Implicit_Label_Declaration
574 Sprint_Node_Actual (Node);
576 -- Normal case where <<< >>> may be required
579 Write_Rewrite_Str ("<<<");
580 Sprint_Node_Actual (Node);
581 Write_Rewrite_Str (">>>");
585 elsif Is_Rewrite_Substitution (Node) then
587 -- Case of dump generated only
589 if Dump_Generated_Only then
590 Sprint_Node_Actual (Node);
592 -- Case of dump original only
594 elsif Dump_Original_Only then
595 Sprint_Node_Actual (Original_Node (Node));
597 -- Case of both being dumped
600 Sprint_Node_Actual (Original_Node (Node));
601 Write_Rewrite_Str ("<<<");
602 Sprint_Node_Actual (Node);
603 Write_Rewrite_Str (">>>");
607 Sprint_Node_Actual (Node);
611 ------------------------
612 -- Sprint_Node_Actual --
613 ------------------------
615 procedure Sprint_Node_Actual (Node : Node_Id) is
616 Save_Debug_Node : constant Node_Id := Debug_Node;
623 for J in 1 .. Paren_Count (Node) loop
624 Write_Str_With_Col_Check ("(");
627 -- Setup node for Sloc fixup if writing a debug source file. Note
628 -- that we take care of any previous node not yet properly set.
630 if Debug_Generated_Code then
634 if Nkind (Node) in N_Subexpr
635 and then Do_Range_Check (Node)
637 Write_Str_With_Col_Check ("{");
640 -- Select print circuit based on node kind
644 when N_Abort_Statement =>
645 Write_Indent_Str_Sloc ("abort ");
646 Sprint_Comma_List (Names (Node));
649 when N_Abortable_Part =>
651 Write_Str_Sloc ("abort ");
652 Sprint_Indented_List (Statements (Node));
654 when N_Abstract_Subprogram_Declaration =>
656 Sprint_Node (Specification (Node));
657 Write_Str_With_Col_Check (" is ");
658 Write_Str_Sloc ("abstract;");
660 when N_Accept_Alternative =>
661 Sprint_Node_List (Pragmas_Before (Node));
663 if Present (Condition (Node)) then
664 Write_Indent_Str ("when ");
665 Sprint_Node (Condition (Node));
670 Sprint_Node_Sloc (Accept_Statement (Node));
671 Sprint_Node_List (Statements (Node));
673 when N_Accept_Statement =>
674 Write_Indent_Str_Sloc ("accept ");
675 Write_Id (Entry_Direct_Name (Node));
677 if Present (Entry_Index (Node)) then
678 Write_Str_With_Col_Check (" (");
679 Sprint_Node (Entry_Index (Node));
683 Write_Param_Specs (Node);
685 if Present (Handled_Statement_Sequence (Node)) then
686 Write_Str_With_Col_Check (" do");
687 Sprint_Node (Handled_Statement_Sequence (Node));
688 Write_Indent_Str ("end ");
689 Write_Id (Entry_Direct_Name (Node));
694 when N_Access_Definition =>
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));
932 -- Ada0Y (AI-287): Print the mbox if present
934 if Box_Present (Node) then
935 Write_Str_With_Col_Check ("<>");
937 Sprint_Node (Expression (Node));
940 when N_Component_Clause =>
942 Sprint_Node (Component_Name (Node));
943 Write_Str_Sloc (" at ");
944 Sprint_Node (Position (Node));
946 Write_Str_With_Col_Check ("range ");
947 Sprint_Node (First_Bit (Node));
949 Sprint_Node (Last_Bit (Node));
952 when N_Component_Definition =>
955 if Aliased_Present (Node) then
956 Write_Str_With_Col_Check ("aliased ");
959 Sprint_Node (Subtype_Indication (Node));
961 when N_Component_Declaration =>
962 if Write_Indent_Identifiers_Sloc (Node) then
964 Sprint_Node (Component_Definition (Node));
966 if Present (Expression (Node)) then
968 Sprint_Node (Expression (Node));
974 when N_Component_List =>
975 if Null_Present (Node) then
977 Write_Indent_Str_Sloc ("null");
983 Sprint_Indented_List (Component_Items (Node));
984 Sprint_Node (Variant_Part (Node));
987 when N_Conditional_Entry_Call =>
988 Write_Indent_Str_Sloc ("select");
990 Sprint_Node (Entry_Call_Alternative (Node));
992 Write_Indent_Str ("else");
993 Sprint_Indented_List (Else_Statements (Node));
994 Write_Indent_Str ("end select;");
996 when N_Conditional_Expression =>
998 Condition : constant Node_Id := First (Expressions (Node));
999 Then_Expr : constant Node_Id := Next (Condition);
1000 Else_Expr : constant Node_Id := Next (Then_Expr);
1003 Write_Str_With_Col_Check_Sloc ("(if ");
1004 Sprint_Node (Condition);
1005 Write_Str_With_Col_Check (" then ");
1006 Sprint_Node (Then_Expr);
1007 Write_Str_With_Col_Check (" else ");
1008 Sprint_Node (Else_Expr);
1012 when N_Constrained_Array_Definition =>
1013 Write_Str_With_Col_Check_Sloc ("array ");
1014 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1017 Sprint_Node (Component_Definition (Node));
1019 when N_Decimal_Fixed_Point_Definition =>
1020 Write_Str_With_Col_Check_Sloc (" delta ");
1021 Sprint_Node (Delta_Expression (Node));
1022 Write_Str_With_Col_Check ("digits ");
1023 Sprint_Node (Digits_Expression (Node));
1024 Sprint_Opt_Node (Real_Range_Specification (Node));
1026 when N_Defining_Character_Literal =>
1027 Write_Name_With_Col_Check_Sloc (Chars (Node));
1029 when N_Defining_Identifier =>
1033 when N_Defining_Operator_Symbol =>
1034 Write_Name_With_Col_Check_Sloc (Chars (Node));
1036 when N_Defining_Program_Unit_Name =>
1038 Sprint_Node (Name (Node));
1040 Write_Id (Defining_Identifier (Node));
1042 when N_Delay_Alternative =>
1043 Sprint_Node_List (Pragmas_Before (Node));
1045 if Present (Condition (Node)) then
1047 Write_Str_With_Col_Check ("when ");
1048 Sprint_Node (Condition (Node));
1053 Sprint_Node_Sloc (Delay_Statement (Node));
1054 Sprint_Node_List (Statements (Node));
1056 when N_Delay_Relative_Statement =>
1057 Write_Indent_Str_Sloc ("delay ");
1058 Sprint_Node (Expression (Node));
1061 when N_Delay_Until_Statement =>
1062 Write_Indent_Str_Sloc ("delay until ");
1063 Sprint_Node (Expression (Node));
1066 when N_Delta_Constraint =>
1067 Write_Str_With_Col_Check_Sloc ("delta ");
1068 Sprint_Node (Delta_Expression (Node));
1069 Sprint_Opt_Node (Range_Constraint (Node));
1071 when N_Derived_Type_Definition =>
1072 if Abstract_Present (Node) then
1073 Write_Str_With_Col_Check ("abstract ");
1076 Write_Str_With_Col_Check_Sloc ("new ");
1077 Sprint_Node (Subtype_Indication (Node));
1079 if Present (Record_Extension_Part (Node)) then
1080 Write_Str_With_Col_Check (" with ");
1081 Sprint_Node (Record_Extension_Part (Node));
1084 when N_Designator =>
1085 Sprint_Node (Name (Node));
1086 Write_Char_Sloc ('.');
1087 Write_Id (Identifier (Node));
1089 when N_Digits_Constraint =>
1090 Write_Str_With_Col_Check_Sloc ("digits ");
1091 Sprint_Node (Digits_Expression (Node));
1092 Sprint_Opt_Node (Range_Constraint (Node));
1094 when N_Discriminant_Association =>
1097 if Present (Selector_Names (Node)) then
1098 Sprint_Bar_List (Selector_Names (Node));
1103 Sprint_Node (Expression (Node));
1105 when N_Discriminant_Specification =>
1108 if Write_Identifiers (Node) then
1110 Sprint_Node (Discriminant_Type (Node));
1112 if Present (Expression (Node)) then
1114 Sprint_Node (Expression (Node));
1120 when N_Elsif_Part =>
1121 Write_Indent_Str_Sloc ("elsif ");
1122 Sprint_Node (Condition (Node));
1123 Write_Str_With_Col_Check (" then");
1124 Sprint_Indented_List (Then_Statements (Node));
1129 when N_Entry_Body =>
1130 Write_Indent_Str_Sloc ("entry ");
1131 Write_Id (Defining_Identifier (Node));
1132 Sprint_Node (Entry_Body_Formal_Part (Node));
1133 Write_Str_With_Col_Check (" is");
1134 Sprint_Indented_List (Declarations (Node));
1135 Write_Indent_Str ("begin");
1136 Sprint_Node (Handled_Statement_Sequence (Node));
1137 Write_Indent_Str ("end ");
1138 Write_Id (Defining_Identifier (Node));
1141 when N_Entry_Body_Formal_Part =>
1142 if Present (Entry_Index_Specification (Node)) then
1143 Write_Str_With_Col_Check_Sloc (" (");
1144 Sprint_Node (Entry_Index_Specification (Node));
1148 Write_Param_Specs (Node);
1149 Write_Str_With_Col_Check_Sloc (" when ");
1150 Sprint_Node (Condition (Node));
1152 when N_Entry_Call_Alternative =>
1153 Sprint_Node_List (Pragmas_Before (Node));
1154 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1155 Sprint_Node_List (Statements (Node));
1157 when N_Entry_Call_Statement =>
1159 Sprint_Node_Sloc (Name (Node));
1160 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1163 when N_Entry_Declaration =>
1164 Write_Indent_Str_Sloc ("entry ");
1165 Write_Id (Defining_Identifier (Node));
1167 if Present (Discrete_Subtype_Definition (Node)) then
1168 Write_Str_With_Col_Check (" (");
1169 Sprint_Node (Discrete_Subtype_Definition (Node));
1173 Write_Param_Specs (Node);
1176 when N_Entry_Index_Specification =>
1177 Write_Str_With_Col_Check_Sloc ("for ");
1178 Write_Id (Defining_Identifier (Node));
1179 Write_Str_With_Col_Check (" in ");
1180 Sprint_Node (Discrete_Subtype_Definition (Node));
1182 when N_Enumeration_Representation_Clause =>
1183 Write_Indent_Str_Sloc ("for ");
1184 Write_Id (Identifier (Node));
1185 Write_Str_With_Col_Check (" use ");
1186 Sprint_Node (Array_Aggregate (Node));
1189 when N_Enumeration_Type_Definition =>
1192 -- Skip attempt to print Literals field if it's not there and
1193 -- we are in package Standard (case of Character, which is
1194 -- handled specially (without an explicit literals list).
1196 if Sloc (Node) > Standard_Location
1197 or else Present (Literals (Node))
1199 Sprint_Paren_Comma_List (Literals (Node));
1203 Write_Str_With_Col_Check_Sloc ("<error>");
1205 when N_Exception_Declaration =>
1206 if Write_Indent_Identifiers (Node) then
1207 Write_Str_With_Col_Check (" : ");
1208 Write_Str_Sloc ("exception;");
1211 when N_Exception_Handler =>
1212 Write_Indent_Str_Sloc ("when ");
1214 if Present (Choice_Parameter (Node)) then
1215 Sprint_Node (Choice_Parameter (Node));
1219 Sprint_Bar_List (Exception_Choices (Node));
1221 Sprint_Indented_List (Statements (Node));
1223 when N_Exception_Renaming_Declaration =>
1226 Sprint_Node (Defining_Identifier (Node));
1227 Write_Str_With_Col_Check (" : exception renames ");
1228 Sprint_Node (Name (Node));
1231 when N_Exit_Statement =>
1232 Write_Indent_Str_Sloc ("exit");
1233 Sprint_Opt_Node (Name (Node));
1235 if Present (Condition (Node)) then
1236 Write_Str_With_Col_Check (" when ");
1237 Sprint_Node (Condition (Node));
1242 when N_Expanded_Name =>
1243 Sprint_Node (Prefix (Node));
1244 Write_Char_Sloc ('.');
1245 Sprint_Node (Selector_Name (Node));
1247 when N_Explicit_Dereference =>
1248 Sprint_Node (Prefix (Node));
1249 Write_Char_Sloc ('.');
1250 Write_Str_Sloc ("all");
1252 when N_Extension_Aggregate =>
1253 Write_Str_With_Col_Check_Sloc ("(");
1254 Sprint_Node (Ancestor_Part (Node));
1255 Write_Str_With_Col_Check (" with ");
1257 if Null_Record_Present (Node) then
1258 Write_Str_With_Col_Check ("null record");
1260 if Present (Expressions (Node)) then
1261 Sprint_Comma_List (Expressions (Node));
1263 if Present (Component_Associations (Node)) then
1268 if Present (Component_Associations (Node)) then
1269 Sprint_Comma_List (Component_Associations (Node));
1275 when N_Floating_Point_Definition =>
1276 Write_Str_With_Col_Check_Sloc ("digits ");
1277 Sprint_Node (Digits_Expression (Node));
1278 Sprint_Opt_Node (Real_Range_Specification (Node));
1280 when N_Formal_Decimal_Fixed_Point_Definition =>
1281 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1283 when N_Formal_Derived_Type_Definition =>
1284 Write_Str_With_Col_Check_Sloc ("new ");
1285 Sprint_Node (Subtype_Mark (Node));
1287 if Private_Present (Node) then
1288 Write_Str_With_Col_Check (" with private");
1291 when N_Formal_Discrete_Type_Definition =>
1292 Write_Str_With_Col_Check_Sloc ("<>");
1294 when N_Formal_Floating_Point_Definition =>
1295 Write_Str_With_Col_Check_Sloc ("digits <>");
1297 when N_Formal_Modular_Type_Definition =>
1298 Write_Str_With_Col_Check_Sloc ("mod <>");
1300 when N_Formal_Object_Declaration =>
1303 if Write_Indent_Identifiers (Node) then
1306 if In_Present (Node) then
1307 Write_Str_With_Col_Check ("in ");
1310 if Out_Present (Node) then
1311 Write_Str_With_Col_Check ("out ");
1314 Sprint_Node (Subtype_Mark (Node));
1316 if Present (Expression (Node)) then
1318 Sprint_Node (Expression (Node));
1324 when N_Formal_Ordinary_Fixed_Point_Definition =>
1325 Write_Str_With_Col_Check_Sloc ("delta <>");
1327 when N_Formal_Package_Declaration =>
1328 Write_Indent_Str_Sloc ("with package ");
1329 Write_Id (Defining_Identifier (Node));
1330 Write_Str_With_Col_Check (" is new ");
1331 Sprint_Node (Name (Node));
1332 Write_Str_With_Col_Check (" (<>);");
1334 when N_Formal_Private_Type_Definition =>
1335 if Abstract_Present (Node) then
1336 Write_Str_With_Col_Check ("abstract ");
1339 if Tagged_Present (Node) then
1340 Write_Str_With_Col_Check ("tagged ");
1343 if Limited_Present (Node) then
1344 Write_Str_With_Col_Check ("limited ");
1347 Write_Str_With_Col_Check_Sloc ("private");
1349 when N_Formal_Signed_Integer_Type_Definition =>
1350 Write_Str_With_Col_Check_Sloc ("range <>");
1352 when N_Formal_Subprogram_Declaration =>
1353 Write_Indent_Str_Sloc ("with ");
1354 Sprint_Node (Specification (Node));
1356 if Box_Present (Node) then
1357 Write_Str_With_Col_Check (" is <>");
1358 elsif Present (Default_Name (Node)) then
1359 Write_Str_With_Col_Check (" is ");
1360 Sprint_Node (Default_Name (Node));
1365 when N_Formal_Type_Declaration =>
1366 Write_Indent_Str_Sloc ("type ");
1367 Write_Id (Defining_Identifier (Node));
1369 if Present (Discriminant_Specifications (Node)) then
1370 Write_Discr_Specs (Node);
1371 elsif Unknown_Discriminants_Present (Node) then
1372 Write_Str_With_Col_Check ("(<>)");
1375 Write_Str_With_Col_Check (" is ");
1376 Sprint_Node (Formal_Type_Definition (Node));
1379 when N_Free_Statement =>
1380 Write_Indent_Str_Sloc ("free ");
1381 Sprint_Node (Expression (Node));
1384 when N_Freeze_Entity =>
1385 if Dump_Original_Only then
1388 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1390 Write_Rewrite_Str ("<<<");
1391 Write_Str_With_Col_Check_Sloc ("freeze ");
1392 Write_Id (Entity (Node));
1395 if No (Actions (Node)) then
1399 Freeze_Indent := Freeze_Indent + 1;
1400 Sprint_Indented_List (Actions (Node));
1401 Freeze_Indent := Freeze_Indent - 1;
1402 Write_Indent_Str ("]");
1405 Write_Rewrite_Str (">>>");
1408 when N_Full_Type_Declaration =>
1409 Write_Indent_Str_Sloc ("type ");
1410 Write_Id (Defining_Identifier (Node));
1411 Write_Discr_Specs (Node);
1412 Write_Str_With_Col_Check (" is ");
1413 Sprint_Node (Type_Definition (Node));
1416 when N_Function_Call =>
1418 Sprint_Node (Name (Node));
1419 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1421 when N_Function_Instantiation =>
1422 Write_Indent_Str_Sloc ("function ");
1423 Sprint_Node (Defining_Unit_Name (Node));
1424 Write_Str_With_Col_Check (" is new ");
1425 Sprint_Node (Name (Node));
1426 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1429 when N_Function_Specification =>
1430 Write_Str_With_Col_Check_Sloc ("function ");
1431 Sprint_Node (Defining_Unit_Name (Node));
1432 Write_Param_Specs (Node);
1433 Write_Str_With_Col_Check (" return ");
1434 Sprint_Node (Subtype_Mark (Node));
1436 when N_Generic_Association =>
1439 if Present (Selector_Name (Node)) then
1440 Sprint_Node (Selector_Name (Node));
1444 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1446 when N_Generic_Function_Renaming_Declaration =>
1447 Write_Indent_Str_Sloc ("generic function ");
1448 Sprint_Node (Defining_Unit_Name (Node));
1449 Write_Str_With_Col_Check (" renames ");
1450 Sprint_Node (Name (Node));
1453 when N_Generic_Package_Declaration =>
1455 Write_Indent_Str_Sloc ("generic ");
1456 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1458 Sprint_Node (Specification (Node));
1461 when N_Generic_Package_Renaming_Declaration =>
1462 Write_Indent_Str_Sloc ("generic package ");
1463 Sprint_Node (Defining_Unit_Name (Node));
1464 Write_Str_With_Col_Check (" renames ");
1465 Sprint_Node (Name (Node));
1468 when N_Generic_Procedure_Renaming_Declaration =>
1469 Write_Indent_Str_Sloc ("generic procedure ");
1470 Sprint_Node (Defining_Unit_Name (Node));
1471 Write_Str_With_Col_Check (" renames ");
1472 Sprint_Node (Name (Node));
1475 when N_Generic_Subprogram_Declaration =>
1477 Write_Indent_Str_Sloc ("generic ");
1478 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1480 Sprint_Node (Specification (Node));
1483 when N_Goto_Statement =>
1484 Write_Indent_Str_Sloc ("goto ");
1485 Sprint_Node (Name (Node));
1488 if Nkind (Next (Node)) = N_Label then
1492 when N_Handled_Sequence_Of_Statements =>
1494 Sprint_Indented_List (Statements (Node));
1496 if Present (Exception_Handlers (Node)) then
1497 Write_Indent_Str ("exception");
1499 Sprint_Node_List (Exception_Handlers (Node));
1503 if Present (At_End_Proc (Node)) then
1504 Write_Indent_Str ("at end");
1507 Sprint_Node (At_End_Proc (Node));
1512 when N_Identifier =>
1516 when N_If_Statement =>
1517 Write_Indent_Str_Sloc ("if ");
1518 Sprint_Node (Condition (Node));
1519 Write_Str_With_Col_Check (" then");
1520 Sprint_Indented_List (Then_Statements (Node));
1521 Sprint_Opt_Node_List (Elsif_Parts (Node));
1523 if Present (Else_Statements (Node)) then
1524 Write_Indent_Str ("else");
1525 Sprint_Indented_List (Else_Statements (Node));
1528 Write_Indent_Str ("end if;");
1530 when N_Implicit_Label_Declaration =>
1531 if not Dump_Original_Only then
1533 Write_Rewrite_Str ("<<<");
1535 Write_Id (Defining_Identifier (Node));
1537 Write_Str_With_Col_Check ("label");
1538 Write_Rewrite_Str (">>>");
1542 Sprint_Left_Opnd (Node);
1543 Write_Str_Sloc (" in ");
1544 Sprint_Right_Opnd (Node);
1546 when N_Incomplete_Type_Declaration =>
1547 Write_Indent_Str_Sloc ("type ");
1548 Write_Id (Defining_Identifier (Node));
1550 if Present (Discriminant_Specifications (Node)) then
1551 Write_Discr_Specs (Node);
1552 elsif Unknown_Discriminants_Present (Node) then
1553 Write_Str_With_Col_Check ("(<>)");
1558 when N_Index_Or_Discriminant_Constraint =>
1560 Sprint_Paren_Comma_List (Constraints (Node));
1562 when N_Indexed_Component =>
1563 Sprint_Node_Sloc (Prefix (Node));
1564 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1566 when N_Integer_Literal =>
1567 if Print_In_Hex (Node) then
1568 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1570 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1573 when N_Iteration_Scheme =>
1574 if Present (Condition (Node)) then
1575 Write_Str_With_Col_Check_Sloc ("while ");
1576 Sprint_Node (Condition (Node));
1578 Write_Str_With_Col_Check_Sloc ("for ");
1579 Sprint_Node (Loop_Parameter_Specification (Node));
1584 when N_Itype_Reference =>
1585 Write_Indent_Str_Sloc ("reference ");
1586 Write_Id (Itype (Node));
1589 Write_Indent_Str_Sloc ("<<");
1590 Write_Id (Identifier (Node));
1593 when N_Loop_Parameter_Specification =>
1595 Write_Id (Defining_Identifier (Node));
1596 Write_Str_With_Col_Check (" in ");
1598 if Reverse_Present (Node) then
1599 Write_Str_With_Col_Check ("reverse ");
1602 Sprint_Node (Discrete_Subtype_Definition (Node));
1604 when N_Loop_Statement =>
1607 if Present (Identifier (Node))
1608 and then (not Has_Created_Identifier (Node)
1609 or else not Dump_Original_Only)
1611 Write_Rewrite_Str ("<<<");
1612 Write_Id (Identifier (Node));
1614 Write_Rewrite_Str (">>>");
1615 Sprint_Node (Iteration_Scheme (Node));
1616 Write_Str_With_Col_Check_Sloc ("loop");
1617 Sprint_Indented_List (Statements (Node));
1618 Write_Indent_Str ("end loop ");
1619 Write_Rewrite_Str ("<<<");
1620 Write_Id (Identifier (Node));
1621 Write_Rewrite_Str (">>>");
1625 Sprint_Node (Iteration_Scheme (Node));
1626 Write_Str_With_Col_Check_Sloc ("loop");
1627 Sprint_Indented_List (Statements (Node));
1628 Write_Indent_Str ("end loop;");
1631 when N_Mod_Clause =>
1632 Sprint_Node_List (Pragmas_Before (Node));
1633 Write_Str_With_Col_Check_Sloc ("at mod ");
1634 Sprint_Node (Expression (Node));
1636 when N_Modular_Type_Definition =>
1637 Write_Str_With_Col_Check_Sloc ("mod ");
1638 Sprint_Node (Expression (Node));
1641 Sprint_Left_Opnd (Node);
1642 Write_Str_Sloc (" not in ");
1643 Sprint_Right_Opnd (Node);
1646 Write_Str_With_Col_Check_Sloc ("null");
1648 when N_Null_Statement =>
1649 if Comes_From_Source (Node)
1650 or else Dump_Freeze_Null
1651 or else not Is_List_Member (Node)
1652 or else (No (Prev (Node)) and then No (Next (Node)))
1654 Write_Indent_Str_Sloc ("null;");
1657 when N_Number_Declaration =>
1660 if Write_Indent_Identifiers (Node) then
1661 Write_Str_With_Col_Check (" : constant ");
1663 Sprint_Node (Expression (Node));
1667 when N_Object_Declaration =>
1670 if Write_Indent_Identifiers (Node) then
1673 if Aliased_Present (Node) then
1674 Write_Str_With_Col_Check ("aliased ");
1677 if Constant_Present (Node) then
1678 Write_Str_With_Col_Check ("constant ");
1681 Sprint_Node (Object_Definition (Node));
1683 if Present (Expression (Node)) then
1685 Sprint_Node (Expression (Node));
1691 when N_Object_Renaming_Declaration =>
1694 Sprint_Node (Defining_Identifier (Node));
1696 Sprint_Node (Subtype_Mark (Node));
1697 Write_Str_With_Col_Check (" renames ");
1698 Sprint_Node (Name (Node));
1702 Write_Operator (Node, "abs ");
1703 Sprint_Right_Opnd (Node);
1706 Sprint_Left_Opnd (Node);
1707 Write_Operator (Node, " + ");
1708 Sprint_Right_Opnd (Node);
1711 Sprint_Left_Opnd (Node);
1712 Write_Operator (Node, " and ");
1713 Sprint_Right_Opnd (Node);
1716 Sprint_Left_Opnd (Node);
1717 Write_Operator (Node, " & ");
1718 Sprint_Right_Opnd (Node);
1721 Sprint_Left_Opnd (Node);
1723 Process_TFAI_RR_Flags (Node);
1724 Write_Operator (Node, "/ ");
1725 Sprint_Right_Opnd (Node);
1728 Sprint_Left_Opnd (Node);
1729 Write_Operator (Node, " = ");
1730 Sprint_Right_Opnd (Node);
1733 Sprint_Left_Opnd (Node);
1734 Write_Operator (Node, " ** ");
1735 Sprint_Right_Opnd (Node);
1738 Sprint_Left_Opnd (Node);
1739 Write_Operator (Node, " >= ");
1740 Sprint_Right_Opnd (Node);
1743 Sprint_Left_Opnd (Node);
1744 Write_Operator (Node, " > ");
1745 Sprint_Right_Opnd (Node);
1748 Sprint_Left_Opnd (Node);
1749 Write_Operator (Node, " <= ");
1750 Sprint_Right_Opnd (Node);
1753 Sprint_Left_Opnd (Node);
1754 Write_Operator (Node, " < ");
1755 Sprint_Right_Opnd (Node);
1758 Write_Operator (Node, "-");
1759 Sprint_Right_Opnd (Node);
1762 Sprint_Left_Opnd (Node);
1764 if Treat_Fixed_As_Integer (Node) then
1768 Write_Operator (Node, " mod ");
1769 Sprint_Right_Opnd (Node);
1771 when N_Op_Multiply =>
1772 Sprint_Left_Opnd (Node);
1774 Process_TFAI_RR_Flags (Node);
1775 Write_Operator (Node, "* ");
1776 Sprint_Right_Opnd (Node);
1779 Sprint_Left_Opnd (Node);
1780 Write_Operator (Node, " /= ");
1781 Sprint_Right_Opnd (Node);
1784 Write_Operator (Node, "not ");
1785 Sprint_Right_Opnd (Node);
1788 Sprint_Left_Opnd (Node);
1789 Write_Operator (Node, " or ");
1790 Sprint_Right_Opnd (Node);
1793 Write_Operator (Node, "+");
1794 Sprint_Right_Opnd (Node);
1797 Sprint_Left_Opnd (Node);
1799 if Treat_Fixed_As_Integer (Node) then
1803 Write_Operator (Node, " rem ");
1804 Sprint_Right_Opnd (Node);
1810 Write_Str_With_Col_Check ("(");
1811 Sprint_Node (Left_Opnd (Node));
1813 Sprint_Node (Right_Opnd (Node));
1816 when N_Op_Subtract =>
1817 Sprint_Left_Opnd (Node);
1818 Write_Operator (Node, " - ");
1819 Sprint_Right_Opnd (Node);
1822 Sprint_Left_Opnd (Node);
1823 Write_Operator (Node, " xor ");
1824 Sprint_Right_Opnd (Node);
1826 when N_Operator_Symbol =>
1827 Write_Name_With_Col_Check_Sloc (Chars (Node));
1829 when N_Ordinary_Fixed_Point_Definition =>
1830 Write_Str_With_Col_Check_Sloc ("delta ");
1831 Sprint_Node (Delta_Expression (Node));
1832 Sprint_Opt_Node (Real_Range_Specification (Node));
1835 Sprint_Left_Opnd (Node);
1836 Write_Str_Sloc (" or else ");
1837 Sprint_Right_Opnd (Node);
1839 when N_Others_Choice =>
1840 if All_Others (Node) then
1841 Write_Str_With_Col_Check ("all ");
1844 Write_Str_With_Col_Check_Sloc ("others");
1846 when N_Package_Body =>
1848 Write_Indent_Str_Sloc ("package body ");
1849 Sprint_Node (Defining_Unit_Name (Node));
1851 Sprint_Indented_List (Declarations (Node));
1853 if Present (Handled_Statement_Sequence (Node)) then
1854 Write_Indent_Str ("begin");
1855 Sprint_Node (Handled_Statement_Sequence (Node));
1858 Write_Indent_Str ("end ");
1859 Sprint_Node (Defining_Unit_Name (Node));
1862 when N_Package_Body_Stub =>
1863 Write_Indent_Str_Sloc ("package body ");
1864 Sprint_Node (Defining_Identifier (Node));
1865 Write_Str_With_Col_Check (" is separate;");
1867 when N_Package_Declaration =>
1870 Sprint_Node_Sloc (Specification (Node));
1873 when N_Package_Instantiation =>
1875 Write_Indent_Str_Sloc ("package ");
1876 Sprint_Node (Defining_Unit_Name (Node));
1877 Write_Str (" is new ");
1878 Sprint_Node (Name (Node));
1879 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1882 when N_Package_Renaming_Declaration =>
1883 Write_Indent_Str_Sloc ("package ");
1884 Sprint_Node (Defining_Unit_Name (Node));
1885 Write_Str_With_Col_Check (" renames ");
1886 Sprint_Node (Name (Node));
1889 when N_Package_Specification =>
1890 Write_Str_With_Col_Check_Sloc ("package ");
1891 Sprint_Node (Defining_Unit_Name (Node));
1893 Sprint_Indented_List (Visible_Declarations (Node));
1895 if Present (Private_Declarations (Node)) then
1896 Write_Indent_Str ("private");
1897 Sprint_Indented_List (Private_Declarations (Node));
1900 Write_Indent_Str ("end ");
1901 Sprint_Node (Defining_Unit_Name (Node));
1903 when N_Parameter_Association =>
1904 Sprint_Node_Sloc (Selector_Name (Node));
1906 Sprint_Node (Explicit_Actual_Parameter (Node));
1908 when N_Parameter_Specification =>
1911 if Write_Identifiers (Node) then
1914 if In_Present (Node) then
1915 Write_Str_With_Col_Check ("in ");
1918 if Out_Present (Node) then
1919 Write_Str_With_Col_Check ("out ");
1922 Sprint_Node (Parameter_Type (Node));
1924 if Present (Expression (Node)) then
1926 Sprint_Node (Expression (Node));
1933 Write_Indent_Str_Sloc ("pragma ");
1934 Write_Name_With_Col_Check (Chars (Node));
1936 if Present (Pragma_Argument_Associations (Node)) then
1937 Sprint_Opt_Paren_Comma_List
1938 (Pragma_Argument_Associations (Node));
1943 when N_Pragma_Argument_Association =>
1946 if Chars (Node) /= No_Name then
1947 Write_Name_With_Col_Check (Chars (Node));
1951 Sprint_Node (Expression (Node));
1953 when N_Private_Type_Declaration =>
1954 Write_Indent_Str_Sloc ("type ");
1955 Write_Id (Defining_Identifier (Node));
1957 if Present (Discriminant_Specifications (Node)) then
1958 Write_Discr_Specs (Node);
1959 elsif Unknown_Discriminants_Present (Node) then
1960 Write_Str_With_Col_Check ("(<>)");
1965 if Tagged_Present (Node) then
1966 Write_Str_With_Col_Check ("tagged ");
1969 if Limited_Present (Node) then
1970 Write_Str_With_Col_Check ("limited ");
1973 Write_Str_With_Col_Check ("private;");
1975 when N_Private_Extension_Declaration =>
1976 Write_Indent_Str_Sloc ("type ");
1977 Write_Id (Defining_Identifier (Node));
1979 if Present (Discriminant_Specifications (Node)) then
1980 Write_Discr_Specs (Node);
1981 elsif Unknown_Discriminants_Present (Node) then
1982 Write_Str_With_Col_Check ("(<>)");
1985 Write_Str_With_Col_Check (" is new ");
1986 Sprint_Node (Subtype_Indication (Node));
1987 Write_Str_With_Col_Check (" with private;");
1989 when N_Procedure_Call_Statement =>
1992 Sprint_Node (Name (Node));
1993 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1996 when N_Procedure_Instantiation =>
1997 Write_Indent_Str_Sloc ("procedure ");
1998 Sprint_Node (Defining_Unit_Name (Node));
1999 Write_Str_With_Col_Check (" is new ");
2000 Sprint_Node (Name (Node));
2001 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2004 when N_Procedure_Specification =>
2005 Write_Str_With_Col_Check_Sloc ("procedure ");
2006 Sprint_Node (Defining_Unit_Name (Node));
2007 Write_Param_Specs (Node);
2009 when N_Protected_Body =>
2010 Write_Indent_Str_Sloc ("protected body ");
2011 Write_Id (Defining_Identifier (Node));
2013 Sprint_Indented_List (Declarations (Node));
2014 Write_Indent_Str ("end ");
2015 Write_Id (Defining_Identifier (Node));
2018 when N_Protected_Body_Stub =>
2019 Write_Indent_Str_Sloc ("protected body ");
2020 Write_Id (Defining_Identifier (Node));
2021 Write_Str_With_Col_Check (" is separate;");
2023 when N_Protected_Definition =>
2025 Sprint_Indented_List (Visible_Declarations (Node));
2027 if Present (Private_Declarations (Node)) then
2028 Write_Indent_Str ("private");
2029 Sprint_Indented_List (Private_Declarations (Node));
2032 Write_Indent_Str ("end ");
2034 when N_Protected_Type_Declaration =>
2035 Write_Indent_Str_Sloc ("protected type ");
2036 Write_Id (Defining_Identifier (Node));
2037 Write_Discr_Specs (Node);
2039 Sprint_Node (Protected_Definition (Node));
2040 Write_Id (Defining_Identifier (Node));
2043 when N_Qualified_Expression =>
2044 Sprint_Node (Subtype_Mark (Node));
2045 Write_Char_Sloc (''');
2047 -- Print expression, make sure we have at least one level of
2048 -- parentheses around the expression. For cases of qualified
2049 -- expressions in the source, this is always the case, but
2050 -- for generated qualifications, there may be no explicit
2051 -- parentheses present.
2053 if Paren_Count (Expression (Node)) /= 0 then
2054 Sprint_Node (Expression (Node));
2057 Sprint_Node (Expression (Node));
2061 when N_Raise_Constraint_Error =>
2063 -- This node can be used either as a subexpression or as a
2064 -- statement form. The following test is a reasonably reliable
2065 -- way to distinguish the two cases.
2067 if Is_List_Member (Node)
2068 and then Nkind (Parent (Node)) not in N_Subexpr
2073 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2074 Write_Condition_And_Reason (Node);
2076 when N_Raise_Program_Error =>
2078 -- This node can be used either as a subexpression or as a
2079 -- statement form. The following test is a reasonably reliable
2080 -- way to distinguish the two cases.
2082 if Is_List_Member (Node)
2083 and then Nkind (Parent (Node)) not in N_Subexpr
2088 Write_Str_With_Col_Check_Sloc ("[program_error");
2089 Write_Condition_And_Reason (Node);
2091 when N_Raise_Storage_Error =>
2093 -- This node can be used either as a subexpression or as a
2094 -- statement form. The following test is a reasonably reliable
2095 -- way to distinguish the two cases.
2097 if Is_List_Member (Node)
2098 and then Nkind (Parent (Node)) not in N_Subexpr
2103 Write_Str_With_Col_Check_Sloc ("[storage_error");
2104 Write_Condition_And_Reason (Node);
2106 when N_Raise_Statement =>
2107 Write_Indent_Str_Sloc ("raise ");
2108 Sprint_Node (Name (Node));
2112 Sprint_Node (Low_Bound (Node));
2113 Write_Str_Sloc (" .. ");
2114 Sprint_Node (High_Bound (Node));
2116 when N_Range_Constraint =>
2117 Write_Str_With_Col_Check_Sloc ("range ");
2118 Sprint_Node (Range_Expression (Node));
2120 when N_Real_Literal =>
2121 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2123 when N_Real_Range_Specification =>
2124 Write_Str_With_Col_Check_Sloc ("range ");
2125 Sprint_Node (Low_Bound (Node));
2127 Sprint_Node (High_Bound (Node));
2129 when N_Record_Definition =>
2130 if Abstract_Present (Node) then
2131 Write_Str_With_Col_Check ("abstract ");
2134 if Tagged_Present (Node) then
2135 Write_Str_With_Col_Check ("tagged ");
2138 if Limited_Present (Node) then
2139 Write_Str_With_Col_Check ("limited ");
2142 if Null_Present (Node) then
2143 Write_Str_With_Col_Check_Sloc ("null record");
2146 Write_Str_With_Col_Check_Sloc ("record");
2147 Sprint_Node (Component_List (Node));
2148 Write_Indent_Str ("end record");
2151 when N_Record_Representation_Clause =>
2152 Write_Indent_Str_Sloc ("for ");
2153 Sprint_Node (Identifier (Node));
2154 Write_Str_With_Col_Check (" use record ");
2156 if Present (Mod_Clause (Node)) then
2157 Sprint_Node (Mod_Clause (Node));
2160 Sprint_Indented_List (Component_Clauses (Node));
2161 Write_Indent_Str ("end record;");
2164 Sprint_Node (Prefix (Node));
2165 Write_Str_With_Col_Check_Sloc ("'reference");
2167 when N_Requeue_Statement =>
2168 Write_Indent_Str_Sloc ("requeue ");
2169 Sprint_Node (Name (Node));
2171 if Abort_Present (Node) then
2172 Write_Str_With_Col_Check (" with abort");
2177 when N_Return_Statement =>
2178 if Present (Expression (Node)) then
2179 Write_Indent_Str_Sloc ("return ");
2180 Sprint_Node (Expression (Node));
2183 Write_Indent_Str_Sloc ("return;");
2186 when N_Selective_Accept =>
2187 Write_Indent_Str_Sloc ("select");
2193 Alt_Node := First (Select_Alternatives (Node));
2196 Sprint_Node (Alt_Node);
2199 exit when No (Alt_Node);
2200 Write_Indent_Str ("or");
2204 if Present (Else_Statements (Node)) then
2205 Write_Indent_Str ("else");
2206 Sprint_Indented_List (Else_Statements (Node));
2209 Write_Indent_Str ("end select;");
2211 when N_Signed_Integer_Type_Definition =>
2212 Write_Str_With_Col_Check_Sloc ("range ");
2213 Sprint_Node (Low_Bound (Node));
2215 Sprint_Node (High_Bound (Node));
2217 when N_Single_Protected_Declaration =>
2218 Write_Indent_Str_Sloc ("protected ");
2219 Write_Id (Defining_Identifier (Node));
2221 Sprint_Node (Protected_Definition (Node));
2222 Write_Id (Defining_Identifier (Node));
2225 when N_Single_Task_Declaration =>
2226 Write_Indent_Str_Sloc ("task ");
2227 Write_Id (Defining_Identifier (Node));
2229 if Present (Task_Definition (Node)) then
2231 Sprint_Node (Task_Definition (Node));
2232 Write_Id (Defining_Identifier (Node));
2237 when N_Selected_Component =>
2238 Sprint_Node (Prefix (Node));
2239 Write_Char_Sloc ('.');
2240 Sprint_Node (Selector_Name (Node));
2244 Sprint_Node (Prefix (Node));
2245 Write_Str_With_Col_Check (" (");
2246 Sprint_Node (Discrete_Range (Node));
2249 when N_String_Literal =>
2250 if String_Length (Strval (Node)) + Column > 75 then
2251 Write_Indent_Str (" ");
2255 Write_String_Table_Entry (Strval (Node));
2257 when N_Subprogram_Body =>
2258 if Freeze_Indent = 0 then
2263 Sprint_Node_Sloc (Specification (Node));
2266 Sprint_Indented_List (Declarations (Node));
2267 Write_Indent_Str ("begin");
2268 Sprint_Node (Handled_Statement_Sequence (Node));
2270 Write_Indent_Str ("end ");
2271 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2274 if Is_List_Member (Node)
2275 and then Present (Next (Node))
2276 and then Nkind (Next (Node)) /= N_Subprogram_Body
2281 when N_Subprogram_Body_Stub =>
2283 Sprint_Node_Sloc (Specification (Node));
2284 Write_Str_With_Col_Check (" is separate;");
2286 when N_Subprogram_Declaration =>
2288 Sprint_Node_Sloc (Specification (Node));
2291 when N_Subprogram_Info =>
2292 Sprint_Node (Identifier (Node));
2293 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2295 when N_Subprogram_Renaming_Declaration =>
2297 Sprint_Node (Specification (Node));
2298 Write_Str_With_Col_Check_Sloc (" renames ");
2299 Sprint_Node (Name (Node));
2302 when N_Subtype_Declaration =>
2303 Write_Indent_Str_Sloc ("subtype ");
2304 Write_Id (Defining_Identifier (Node));
2306 Sprint_Node (Subtype_Indication (Node));
2309 when N_Subtype_Indication =>
2310 Sprint_Node_Sloc (Subtype_Mark (Node));
2312 Sprint_Node (Constraint (Node));
2315 Write_Indent_Str_Sloc ("separate (");
2316 Sprint_Node (Name (Node));
2319 Sprint_Node (Proper_Body (Node));
2322 Write_Indent_Str_Sloc ("task body ");
2323 Write_Id (Defining_Identifier (Node));
2325 Sprint_Indented_List (Declarations (Node));
2326 Write_Indent_Str ("begin");
2327 Sprint_Node (Handled_Statement_Sequence (Node));
2328 Write_Indent_Str ("end ");
2329 Write_Id (Defining_Identifier (Node));
2332 when N_Task_Body_Stub =>
2333 Write_Indent_Str_Sloc ("task body ");
2334 Write_Id (Defining_Identifier (Node));
2335 Write_Str_With_Col_Check (" is separate;");
2337 when N_Task_Definition =>
2339 Sprint_Indented_List (Visible_Declarations (Node));
2341 if Present (Private_Declarations (Node)) then
2342 Write_Indent_Str ("private");
2343 Sprint_Indented_List (Private_Declarations (Node));
2346 Write_Indent_Str ("end ");
2348 when N_Task_Type_Declaration =>
2349 Write_Indent_Str_Sloc ("task type ");
2350 Write_Id (Defining_Identifier (Node));
2351 Write_Discr_Specs (Node);
2352 if Present (Task_Definition (Node)) then
2354 Sprint_Node (Task_Definition (Node));
2355 Write_Id (Defining_Identifier (Node));
2360 when N_Terminate_Alternative =>
2361 Sprint_Node_List (Pragmas_Before (Node));
2365 if Present (Condition (Node)) then
2366 Write_Str_With_Col_Check ("when ");
2367 Sprint_Node (Condition (Node));
2371 Write_Str_With_Col_Check_Sloc ("terminate;");
2372 Sprint_Node_List (Pragmas_After (Node));
2374 when N_Timed_Entry_Call =>
2375 Write_Indent_Str_Sloc ("select");
2377 Sprint_Node (Entry_Call_Alternative (Node));
2379 Write_Indent_Str ("or");
2381 Sprint_Node (Delay_Alternative (Node));
2383 Write_Indent_Str ("end select;");
2385 when N_Triggering_Alternative =>
2386 Sprint_Node_List (Pragmas_Before (Node));
2387 Sprint_Node_Sloc (Triggering_Statement (Node));
2388 Sprint_Node_List (Statements (Node));
2390 when N_Type_Conversion =>
2392 Sprint_Node (Subtype_Mark (Node));
2395 if Conversion_OK (Node) then
2399 if Float_Truncate (Node) then
2403 if Rounded_Result (Node) then
2408 Sprint_Node (Expression (Node));
2411 when N_Unchecked_Expression =>
2414 Sprint_Node_Sloc (Expression (Node));
2417 when N_Unchecked_Type_Conversion =>
2418 Sprint_Node (Subtype_Mark (Node));
2420 Write_Str_With_Col_Check ("(");
2421 Sprint_Node_Sloc (Expression (Node));
2424 when N_Unconstrained_Array_Definition =>
2425 Write_Str_With_Col_Check_Sloc ("array (");
2431 Node1 := First (Subtype_Marks (Node));
2433 Sprint_Node (Node1);
2434 Write_Str_With_Col_Check (" range <>");
2436 exit when Node1 = Empty;
2441 Write_Str (") of ");
2442 Sprint_Node (Component_Definition (Node));
2444 when N_Unused_At_Start | N_Unused_At_End =>
2445 Write_Indent_Str ("***** Error, unused node encountered *****");
2448 when N_Use_Package_Clause =>
2449 Write_Indent_Str_Sloc ("use ");
2450 Sprint_Comma_List (Names (Node));
2453 when N_Use_Type_Clause =>
2454 Write_Indent_Str_Sloc ("use type ");
2455 Sprint_Comma_List (Subtype_Marks (Node));
2458 when N_Validate_Unchecked_Conversion =>
2459 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2460 Sprint_Node (Source_Type (Node));
2462 Sprint_Node (Target_Type (Node));
2466 Write_Indent_Str_Sloc ("when ");
2467 Sprint_Bar_List (Discrete_Choices (Node));
2469 Sprint_Node (Component_List (Node));
2471 when N_Variant_Part =>
2473 Write_Indent_Str_Sloc ("case ");
2474 Sprint_Node (Name (Node));
2476 Sprint_Indented_List (Variants (Node));
2477 Write_Indent_Str ("end case");
2480 when N_With_Clause =>
2482 -- Special test, if we are dumping the original tree only,
2483 -- then we want to eliminate the bogus with clauses that
2484 -- correspond to the non-existent children of Text_IO.
2486 if Dump_Original_Only
2487 and then Is_Text_IO_Kludge_Unit (Name (Node))
2491 -- Normal case, output the with clause
2494 if First_Name (Node) or else not Dump_Original_Only then
2496 -- Ada0Y (AI-50217): Print limited with_clauses
2498 if Limited_Present (Node) then
2499 Write_Indent_Str ("limited with ");
2501 Write_Indent_Str ("with ");
2508 Sprint_Node_Sloc (Name (Node));
2510 if Last_Name (Node) or else not Dump_Original_Only then
2515 when N_With_Type_Clause =>
2516 Write_Indent_Str ("with type ");
2517 Sprint_Node_Sloc (Name (Node));
2519 if Tagged_Present (Node) then
2520 Write_Str (" is tagged;");
2522 Write_Str (" is access;");
2527 if Nkind (Node) in N_Subexpr
2528 and then Do_Range_Check (Node)
2533 for J in 1 .. Paren_Count (Node) loop
2537 pragma Assert (No (Debug_Node));
2538 Debug_Node := Save_Debug_Node;
2539 end Sprint_Node_Actual;
2541 ----------------------
2542 -- Sprint_Node_List --
2543 ----------------------
2545 procedure Sprint_Node_List (List : List_Id) is
2549 if Is_Non_Empty_List (List) then
2550 Node := First (List);
2555 exit when Node = Empty;
2558 end Sprint_Node_List;
2560 ----------------------
2561 -- Sprint_Node_Sloc --
2562 ----------------------
2564 procedure Sprint_Node_Sloc (Node : Node_Id) is
2568 if Present (Debug_Node) then
2569 Set_Sloc (Debug_Node, Sloc (Node));
2570 Debug_Node := Empty;
2572 end Sprint_Node_Sloc;
2574 ---------------------
2575 -- Sprint_Opt_Node --
2576 ---------------------
2578 procedure Sprint_Opt_Node (Node : Node_Id) is
2580 if Present (Node) then
2584 end Sprint_Opt_Node;
2586 --------------------------
2587 -- Sprint_Opt_Node_List --
2588 --------------------------
2590 procedure Sprint_Opt_Node_List (List : List_Id) is
2592 if Present (List) then
2593 Sprint_Node_List (List);
2595 end Sprint_Opt_Node_List;
2597 ---------------------------------
2598 -- Sprint_Opt_Paren_Comma_List --
2599 ---------------------------------
2601 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2603 if Is_Non_Empty_List (List) then
2605 Sprint_Paren_Comma_List (List);
2607 end Sprint_Opt_Paren_Comma_List;
2609 -----------------------------
2610 -- Sprint_Paren_Comma_List --
2611 -----------------------------
2613 procedure Sprint_Paren_Comma_List (List : List_Id) is
2615 Node_Exists : Boolean := False;
2619 if Is_Non_Empty_List (List) then
2621 if Dump_Original_Only then
2624 while Present (N) loop
2626 if not Is_Rewrite_Insertion (N) then
2627 Node_Exists := True;
2634 if not Node_Exists then
2639 Write_Str_With_Col_Check ("(");
2640 Sprint_Comma_List (List);
2643 end Sprint_Paren_Comma_List;
2645 ----------------------
2646 -- Sprint_Right_Opnd --
2647 ----------------------
2649 procedure Sprint_Right_Opnd (N : Node_Id) is
2650 Opnd : constant Node_Id := Right_Opnd (N);
2653 if Paren_Count (Opnd) /= 0
2654 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2663 end Sprint_Right_Opnd;
2665 ---------------------
2666 -- Write_Char_Sloc --
2667 ---------------------
2669 procedure Write_Char_Sloc (C : Character) is
2671 if Debug_Generated_Code and then C /= ' ' then
2676 end Write_Char_Sloc;
2678 --------------------------------
2679 -- Write_Condition_And_Reason --
2680 --------------------------------
2682 procedure Write_Condition_And_Reason (Node : Node_Id) is
2683 Image : constant String := RT_Exception_Code'Image
2684 (RT_Exception_Code'Val
2685 (UI_To_Int (Reason (Node))));
2688 if Present (Condition (Node)) then
2689 Write_Str_With_Col_Check (" when ");
2690 Sprint_Node (Condition (Node));
2695 for J in 4 .. Image'Last loop
2696 if Image (J) = '_' then
2699 Write_Char (Fold_Lower (Image (J)));
2704 end Write_Condition_And_Reason;
2706 ------------------------
2707 -- Write_Discr_Specs --
2708 ------------------------
2710 procedure Write_Discr_Specs (N : Node_Id) is
2715 Specs := Discriminant_Specifications (N);
2717 if Present (Specs) then
2718 Write_Str_With_Col_Check (" (");
2719 Spec := First (Specs);
2724 exit when Spec = Empty;
2726 -- Add semicolon, unless we are printing original tree and the
2727 -- next specification is part of a list (but not the first
2728 -- element of that list)
2730 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2737 end Write_Discr_Specs;
2743 procedure Write_Ekind (E : Entity_Id) is
2744 S : constant String := Entity_Kind'Image (Ekind (E));
2747 Name_Len := S'Length;
2748 Name_Buffer (1 .. Name_Len) := S;
2749 Set_Casing (Mixed_Case);
2750 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2757 procedure Write_Id (N : Node_Id) is
2759 -- Case of a defining identifier
2761 if Nkind (N) = N_Defining_Identifier then
2763 -- If defining identifier has an interface name (and no
2764 -- address clause), then we output the interface name.
2766 if (Is_Imported (N) or else Is_Exported (N))
2767 and then Present (Interface_Name (N))
2768 and then No (Address_Clause (N))
2770 String_To_Name_Buffer (Strval (Interface_Name (N)));
2771 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2773 -- If no interface name (or inactive because there was
2774 -- an address clause), then just output the Chars name.
2777 Write_Name_With_Col_Check (Chars (N));
2780 -- Case of selector of an expanded name where the expanded name
2781 -- has an associated entity, output this entity.
2783 elsif Nkind (Parent (N)) = N_Expanded_Name
2784 and then Selector_Name (Parent (N)) = N
2785 and then Present (Entity (Parent (N)))
2787 Write_Id (Entity (Parent (N)));
2789 -- For any other node with an associated entity, output it
2791 elsif Nkind (N) in N_Has_Entity
2792 and then Present (Entity_Or_Associated_Node (N))
2793 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2795 Write_Id (Entity (N));
2797 -- All other cases, we just print the Chars field
2800 Write_Name_With_Col_Check (Chars (N));
2804 -----------------------
2805 -- Write_Identifiers --
2806 -----------------------
2808 function Write_Identifiers (Node : Node_Id) return Boolean is
2810 Sprint_Node (Defining_Identifier (Node));
2812 -- The remainder of the declaration must be printed unless we are
2813 -- printing the original tree and this is not the last identifier
2816 not Dump_Original_Only or else not More_Ids (Node);
2818 end Write_Identifiers;
2820 ------------------------
2821 -- Write_Implicit_Def --
2822 ------------------------
2824 procedure Write_Implicit_Def (E : Entity_Id) is
2829 when E_Array_Subtype =>
2830 Write_Str_With_Col_Check ("subtype ");
2832 Write_Str_With_Col_Check (" is ");
2833 Write_Id (Base_Type (E));
2834 Write_Str_With_Col_Check (" (");
2836 Ind := First_Index (E);
2838 while Present (Ind) loop
2842 if Present (Ind) then
2849 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2850 Write_Str_With_Col_Check ("subtype ");
2853 Write_Id (Etype (E));
2854 Write_Str_With_Col_Check (" range ");
2855 Sprint_Node (Scalar_Range (E));
2859 Write_Str_With_Col_Check ("type ");
2861 Write_Str_With_Col_Check (" is <");
2866 end Write_Implicit_Def;
2872 procedure Write_Indent is
2874 if Indent_Annull_Flag then
2875 Indent_Annull_Flag := False;
2879 for J in 1 .. Indent loop
2885 ------------------------------
2886 -- Write_Indent_Identifiers --
2887 ------------------------------
2889 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
2891 -- We need to start a new line for every node, except in the case
2892 -- where we are printing the original tree and this is not the first
2893 -- defining identifier in the list.
2895 if not Dump_Original_Only or else not Prev_Ids (Node) then
2898 -- If printing original tree and this is not the first defining
2899 -- identifier in the list, then the previous call to this procedure
2900 -- printed only the name, and we add a comma to separate the names.
2906 Sprint_Node (Defining_Identifier (Node));
2908 -- The remainder of the declaration must be printed unless we are
2909 -- printing the original tree and this is not the last identifier
2912 not Dump_Original_Only or else not More_Ids (Node);
2914 end Write_Indent_Identifiers;
2916 -----------------------------------
2917 -- Write_Indent_Identifiers_Sloc --
2918 -----------------------------------
2920 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
2922 -- We need to start a new line for every node, except in the case
2923 -- where we are printing the original tree and this is not the first
2924 -- defining identifier in the list.
2926 if not Dump_Original_Only or else not Prev_Ids (Node) then
2929 -- If printing original tree and this is not the first defining
2930 -- identifier in the list, then the previous call to this procedure
2931 -- printed only the name, and we add a comma to separate the names.
2938 Sprint_Node (Defining_Identifier (Node));
2940 -- The remainder of the declaration must be printed unless we are
2941 -- printing the original tree and this is not the last identifier
2944 not Dump_Original_Only or else not More_Ids (Node);
2946 end Write_Indent_Identifiers_Sloc;
2948 ----------------------
2949 -- Write_Indent_Str --
2950 ----------------------
2952 procedure Write_Indent_Str (S : String) is
2956 end Write_Indent_Str;
2958 ---------------------------
2959 -- Write_Indent_Str_Sloc --
2960 ---------------------------
2962 procedure Write_Indent_Str_Sloc (S : String) is
2966 end Write_Indent_Str_Sloc;
2968 -------------------------------
2969 -- Write_Name_With_Col_Check --
2970 -------------------------------
2972 procedure Write_Name_With_Col_Check (N : Name_Id) is
2976 Get_Name_String (N);
2978 -- Deal with -gnatI which replaces digits in an internal
2979 -- name by three dots (e.g. R7b becomes R...b).
2981 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
2984 while J < Name_Len loop
2985 exit when Name_Buffer (J) not in 'A' .. 'Z';
2989 if Name_Buffer (J) in '0' .. '9' then
2990 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
2993 while J <= Name_Len loop
2994 if Name_Buffer (J) not in '0' .. '9' then
2995 Write_Str (Name_Buffer (J .. Name_Len));
3007 -- Fall through for normal case
3009 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3010 end Write_Name_With_Col_Check;
3012 ------------------------------------
3013 -- Write_Name_With_Col_Check_Sloc --
3014 ------------------------------------
3016 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3018 Get_Name_String (N);
3019 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3020 end Write_Name_With_Col_Check_Sloc;
3022 --------------------
3023 -- Write_Operator --
3024 --------------------
3026 procedure Write_Operator (N : Node_Id; S : String) is
3027 F : Natural := S'First;
3028 T : Natural := S'Last;
3031 -- If no overflow check, just write string out, and we are done
3033 if not Do_Overflow_Check (N) then
3036 -- If overflow check, we want to surround the operator with curly
3037 -- brackets, but not include spaces within the brackets.
3050 Write_Str_Sloc (S (F .. T));
3053 if S (S'Last) = ' ' then
3059 -----------------------
3060 -- Write_Param_Specs --
3061 -----------------------
3063 procedure Write_Param_Specs (N : Node_Id) is
3069 Specs := Parameter_Specifications (N);
3071 if Is_Non_Empty_List (Specs) then
3072 Write_Str_With_Col_Check (" (");
3073 Spec := First (Specs);
3077 Formal := Defining_Identifier (Spec);
3079 exit when Spec = Empty;
3081 -- Add semicolon, unless we are printing original tree and the
3082 -- next specification is part of a list (but not the first
3083 -- element of that list)
3085 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3090 -- Write out any extra formals
3092 while Present (Extra_Formal (Formal)) loop
3093 Formal := Extra_Formal (Formal);
3095 Write_Name_With_Col_Check (Chars (Formal));
3097 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3102 end Write_Param_Specs;
3104 --------------------------
3105 -- Write_Rewrite_Str --
3106 --------------------------
3108 procedure Write_Rewrite_Str (S : String) is
3110 if not Dump_Generated_Only then
3111 if S'Length = 3 and then S = ">>>" then
3114 Write_Str_With_Col_Check (S);
3117 end Write_Rewrite_Str;
3119 --------------------
3120 -- Write_Str_Sloc --
3121 --------------------
3123 procedure Write_Str_Sloc (S : String) is
3125 for J in S'Range loop
3126 Write_Char_Sloc (S (J));
3130 ------------------------------
3131 -- Write_Str_With_Col_Check --
3132 ------------------------------
3134 procedure Write_Str_With_Col_Check (S : String) is
3136 if Int (S'Last) + Column > Line_Limit then
3137 Write_Indent_Str (" ");
3140 Write_Str (S (2 .. S'Length));
3148 end Write_Str_With_Col_Check;
3150 -----------------------------------
3151 -- Write_Str_With_Col_Check_Sloc --
3152 -----------------------------------
3154 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3156 if Int (S'Last) + Column > Line_Limit then
3157 Write_Indent_Str (" ");
3160 Write_Str_Sloc (S (2 .. S'Length));
3168 end Write_Str_With_Col_Check_Sloc;
3170 ------------------------------------
3171 -- Write_Uint_With_Col_Check_Sloc --
3172 ------------------------------------
3174 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3176 Col_Check (UI_Decimal_Digits_Hi (U));
3178 UI_Write (U, Format);
3179 end Write_Uint_With_Col_Check_Sloc;
3181 -------------------------------------
3182 -- Write_Ureal_With_Col_Check_Sloc --
3183 -------------------------------------
3185 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3186 D : constant Uint := Denominator (U);
3187 N : constant Uint := Numerator (U);
3191 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3194 end Write_Ureal_With_Col_Check_Sloc;