1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2002, 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 -- Output 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_Explicit_Dereference =>
1236 Sprint_Node (Prefix (Node));
1238 Write_Str_Sloc ("all");
1240 when N_Extension_Aggregate =>
1241 Write_Str_With_Col_Check_Sloc ("(");
1242 Sprint_Node (Ancestor_Part (Node));
1243 Write_Str_With_Col_Check (" with ");
1245 if Null_Record_Present (Node) then
1246 Write_Str_With_Col_Check ("null record");
1248 if Present (Expressions (Node)) then
1249 Sprint_Comma_List (Expressions (Node));
1251 if Present (Component_Associations (Node)) then
1256 if Present (Component_Associations (Node)) then
1257 Sprint_Comma_List (Component_Associations (Node));
1263 when N_Floating_Point_Definition =>
1264 Write_Str_With_Col_Check_Sloc ("digits ");
1265 Sprint_Node (Digits_Expression (Node));
1266 Sprint_Opt_Node (Real_Range_Specification (Node));
1268 when N_Formal_Decimal_Fixed_Point_Definition =>
1269 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1271 when N_Formal_Derived_Type_Definition =>
1272 Write_Str_With_Col_Check_Sloc ("new ");
1273 Sprint_Node (Subtype_Mark (Node));
1275 if Private_Present (Node) then
1276 Write_Str_With_Col_Check (" with private");
1279 when N_Formal_Discrete_Type_Definition =>
1280 Write_Str_With_Col_Check_Sloc ("<>");
1282 when N_Formal_Floating_Point_Definition =>
1283 Write_Str_With_Col_Check_Sloc ("digits <>");
1285 when N_Formal_Modular_Type_Definition =>
1286 Write_Str_With_Col_Check_Sloc ("mod <>");
1288 when N_Formal_Object_Declaration =>
1291 if Write_Indent_Identifiers (Node) then
1294 if In_Present (Node) then
1295 Write_Str_With_Col_Check ("in ");
1298 if Out_Present (Node) then
1299 Write_Str_With_Col_Check ("out ");
1302 Sprint_Node (Subtype_Mark (Node));
1304 if Present (Expression (Node)) then
1306 Sprint_Node (Expression (Node));
1312 when N_Formal_Ordinary_Fixed_Point_Definition =>
1313 Write_Str_With_Col_Check_Sloc ("delta <>");
1315 when N_Formal_Package_Declaration =>
1316 Write_Indent_Str_Sloc ("with package ");
1317 Write_Id (Defining_Identifier (Node));
1318 Write_Str_With_Col_Check (" is new ");
1319 Sprint_Node (Name (Node));
1320 Write_Str_With_Col_Check (" (<>);");
1322 when N_Formal_Private_Type_Definition =>
1323 if Abstract_Present (Node) then
1324 Write_Str_With_Col_Check ("abstract ");
1327 if Tagged_Present (Node) then
1328 Write_Str_With_Col_Check ("tagged ");
1331 if Limited_Present (Node) then
1332 Write_Str_With_Col_Check ("limited ");
1335 Write_Str_With_Col_Check_Sloc ("private");
1337 when N_Formal_Signed_Integer_Type_Definition =>
1338 Write_Str_With_Col_Check_Sloc ("range <>");
1340 when N_Formal_Subprogram_Declaration =>
1341 Write_Indent_Str_Sloc ("with ");
1342 Sprint_Node (Specification (Node));
1344 if Box_Present (Node) then
1345 Write_Str_With_Col_Check (" is <>");
1346 elsif Present (Default_Name (Node)) then
1347 Write_Str_With_Col_Check (" is ");
1348 Sprint_Node (Default_Name (Node));
1353 when N_Formal_Type_Declaration =>
1354 Write_Indent_Str_Sloc ("type ");
1355 Write_Id (Defining_Identifier (Node));
1357 if Present (Discriminant_Specifications (Node)) then
1358 Write_Discr_Specs (Node);
1359 elsif Unknown_Discriminants_Present (Node) then
1360 Write_Str_With_Col_Check ("(<>)");
1363 Write_Str_With_Col_Check (" is ");
1364 Sprint_Node (Formal_Type_Definition (Node));
1367 when N_Free_Statement =>
1368 Write_Indent_Str_Sloc ("free ");
1369 Sprint_Node (Expression (Node));
1372 when N_Freeze_Entity =>
1373 if Dump_Original_Only then
1376 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1378 Write_Rewrite_Str ("<<<");
1379 Write_Str_With_Col_Check_Sloc ("freeze ");
1380 Write_Id (Entity (Node));
1383 if No (Actions (Node)) then
1387 Freeze_Indent := Freeze_Indent + 1;
1388 Sprint_Indented_List (Actions (Node));
1389 Freeze_Indent := Freeze_Indent - 1;
1390 Write_Indent_Str ("]");
1393 Write_Rewrite_Str (">>>");
1396 when N_Full_Type_Declaration =>
1397 Write_Indent_Str_Sloc ("type ");
1398 Write_Id (Defining_Identifier (Node));
1399 Write_Discr_Specs (Node);
1400 Write_Str_With_Col_Check (" is ");
1401 Sprint_Node (Type_Definition (Node));
1404 when N_Function_Call =>
1406 Sprint_Node (Name (Node));
1407 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1409 when N_Function_Instantiation =>
1410 Write_Indent_Str_Sloc ("function ");
1411 Sprint_Node (Defining_Unit_Name (Node));
1412 Write_Str_With_Col_Check (" is new ");
1413 Sprint_Node (Name (Node));
1414 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1417 when N_Function_Specification =>
1418 Write_Str_With_Col_Check_Sloc ("function ");
1419 Sprint_Node (Defining_Unit_Name (Node));
1420 Write_Param_Specs (Node);
1421 Write_Str_With_Col_Check (" return ");
1422 Sprint_Node (Subtype_Mark (Node));
1424 when N_Generic_Association =>
1427 if Present (Selector_Name (Node)) then
1428 Sprint_Node (Selector_Name (Node));
1432 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1434 when N_Generic_Function_Renaming_Declaration =>
1435 Write_Indent_Str_Sloc ("generic function ");
1436 Sprint_Node (Defining_Unit_Name (Node));
1437 Write_Str_With_Col_Check (" renames ");
1438 Sprint_Node (Name (Node));
1441 when N_Generic_Package_Declaration =>
1443 Write_Indent_Str_Sloc ("generic ");
1444 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1446 Sprint_Node (Specification (Node));
1449 when N_Generic_Package_Renaming_Declaration =>
1450 Write_Indent_Str_Sloc ("generic package ");
1451 Sprint_Node (Defining_Unit_Name (Node));
1452 Write_Str_With_Col_Check (" renames ");
1453 Sprint_Node (Name (Node));
1456 when N_Generic_Procedure_Renaming_Declaration =>
1457 Write_Indent_Str_Sloc ("generic procedure ");
1458 Sprint_Node (Defining_Unit_Name (Node));
1459 Write_Str_With_Col_Check (" renames ");
1460 Sprint_Node (Name (Node));
1463 when N_Generic_Subprogram_Declaration =>
1465 Write_Indent_Str_Sloc ("generic ");
1466 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1468 Sprint_Node (Specification (Node));
1471 when N_Goto_Statement =>
1472 Write_Indent_Str_Sloc ("goto ");
1473 Sprint_Node (Name (Node));
1476 if Nkind (Next (Node)) = N_Label then
1480 when N_Handled_Sequence_Of_Statements =>
1482 Sprint_Indented_List (Statements (Node));
1484 if Present (Exception_Handlers (Node)) then
1485 Write_Indent_Str ("exception");
1487 Sprint_Node_List (Exception_Handlers (Node));
1491 if Present (At_End_Proc (Node)) then
1492 Write_Indent_Str ("at end");
1495 Sprint_Node (At_End_Proc (Node));
1500 when N_Identifier =>
1504 when N_If_Statement =>
1505 Write_Indent_Str_Sloc ("if ");
1506 Sprint_Node (Condition (Node));
1507 Write_Str_With_Col_Check (" then");
1508 Sprint_Indented_List (Then_Statements (Node));
1509 Sprint_Opt_Node_List (Elsif_Parts (Node));
1511 if Present (Else_Statements (Node)) then
1512 Write_Indent_Str ("else");
1513 Sprint_Indented_List (Else_Statements (Node));
1516 Write_Indent_Str ("end if;");
1518 when N_Implicit_Label_Declaration =>
1519 if not Dump_Original_Only then
1521 Write_Rewrite_Str ("<<<");
1523 Write_Id (Defining_Identifier (Node));
1525 Write_Str_With_Col_Check ("label");
1526 Write_Rewrite_Str (">>>");
1530 Sprint_Left_Opnd (Node);
1531 Write_Str_Sloc (" in ");
1532 Sprint_Right_Opnd (Node);
1534 when N_Incomplete_Type_Declaration =>
1535 Write_Indent_Str_Sloc ("type ");
1536 Write_Id (Defining_Identifier (Node));
1538 if Present (Discriminant_Specifications (Node)) then
1539 Write_Discr_Specs (Node);
1540 elsif Unknown_Discriminants_Present (Node) then
1541 Write_Str_With_Col_Check ("(<>)");
1546 when N_Index_Or_Discriminant_Constraint =>
1548 Sprint_Paren_Comma_List (Constraints (Node));
1550 when N_Indexed_Component =>
1551 Sprint_Node_Sloc (Prefix (Node));
1552 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1554 when N_Integer_Literal =>
1555 if Print_In_Hex (Node) then
1556 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1558 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1561 when N_Iteration_Scheme =>
1562 if Present (Condition (Node)) then
1563 Write_Str_With_Col_Check_Sloc ("while ");
1564 Sprint_Node (Condition (Node));
1566 Write_Str_With_Col_Check_Sloc ("for ");
1567 Sprint_Node (Loop_Parameter_Specification (Node));
1572 when N_Itype_Reference =>
1573 Write_Indent_Str_Sloc ("reference ");
1574 Write_Id (Itype (Node));
1577 Write_Indent_Str_Sloc ("<<");
1578 Write_Id (Identifier (Node));
1581 when N_Loop_Parameter_Specification =>
1583 Write_Id (Defining_Identifier (Node));
1584 Write_Str_With_Col_Check (" in ");
1586 if Reverse_Present (Node) then
1587 Write_Str_With_Col_Check ("reverse ");
1590 Sprint_Node (Discrete_Subtype_Definition (Node));
1592 when N_Loop_Statement =>
1595 if Present (Identifier (Node))
1596 and then (not Has_Created_Identifier (Node)
1597 or else not Dump_Original_Only)
1599 Write_Rewrite_Str ("<<<");
1600 Write_Id (Identifier (Node));
1602 Write_Rewrite_Str (">>>");
1603 Sprint_Node (Iteration_Scheme (Node));
1604 Write_Str_With_Col_Check_Sloc ("loop");
1605 Sprint_Indented_List (Statements (Node));
1606 Write_Indent_Str ("end loop ");
1607 Write_Rewrite_Str ("<<<");
1608 Write_Id (Identifier (Node));
1609 Write_Rewrite_Str (">>>");
1613 Sprint_Node (Iteration_Scheme (Node));
1614 Write_Str_With_Col_Check_Sloc ("loop");
1615 Sprint_Indented_List (Statements (Node));
1616 Write_Indent_Str ("end loop;");
1619 when N_Mod_Clause =>
1620 Sprint_Node_List (Pragmas_Before (Node));
1621 Write_Str_With_Col_Check_Sloc ("at mod ");
1622 Sprint_Node (Expression (Node));
1624 when N_Modular_Type_Definition =>
1625 Write_Str_With_Col_Check_Sloc ("mod ");
1626 Sprint_Node (Expression (Node));
1629 Sprint_Left_Opnd (Node);
1630 Write_Str_Sloc (" not in ");
1631 Sprint_Right_Opnd (Node);
1634 Write_Str_With_Col_Check_Sloc ("null");
1636 when N_Null_Statement =>
1637 if Comes_From_Source (Node)
1638 or else Dump_Freeze_Null
1639 or else not Is_List_Member (Node)
1640 or else (No (Prev (Node)) and then No (Next (Node)))
1642 Write_Indent_Str_Sloc ("null;");
1645 when N_Number_Declaration =>
1648 if Write_Indent_Identifiers (Node) then
1649 Write_Str_With_Col_Check (" : constant ");
1651 Sprint_Node (Expression (Node));
1655 when N_Object_Declaration =>
1657 -- Put extra blank line before and after if this is a handler
1658 -- record or a subprogram descriptor.
1661 Typ : constant Entity_Id := Etype (Defining_Identifier (Node));
1662 Exc : constant Boolean :=
1663 Is_RTE (Typ, RE_Handler_Record)
1665 Is_RTE (Typ, RE_Subprogram_Descriptor);
1674 if Write_Indent_Identifiers (Node) then
1677 if Aliased_Present (Node) then
1678 Write_Str_With_Col_Check ("aliased ");
1681 if Constant_Present (Node) then
1682 Write_Str_With_Col_Check ("constant ");
1685 Sprint_Node (Object_Definition (Node));
1687 if Present (Expression (Node)) then
1689 Sprint_Node (Expression (Node));
1700 when N_Object_Renaming_Declaration =>
1703 Sprint_Node (Defining_Identifier (Node));
1705 Sprint_Node (Subtype_Mark (Node));
1706 Write_Str_With_Col_Check (" renames ");
1707 Sprint_Node (Name (Node));
1711 Write_Operator (Node, "abs ");
1712 Sprint_Right_Opnd (Node);
1715 Sprint_Left_Opnd (Node);
1716 Write_Operator (Node, " + ");
1717 Sprint_Right_Opnd (Node);
1720 Sprint_Left_Opnd (Node);
1721 Write_Operator (Node, " and ");
1722 Sprint_Right_Opnd (Node);
1725 Sprint_Left_Opnd (Node);
1726 Write_Operator (Node, " & ");
1727 Sprint_Right_Opnd (Node);
1730 Sprint_Left_Opnd (Node);
1732 Process_TFAI_RR_Flags (Node);
1733 Write_Operator (Node, "/ ");
1734 Sprint_Right_Opnd (Node);
1737 Sprint_Left_Opnd (Node);
1738 Write_Operator (Node, " = ");
1739 Sprint_Right_Opnd (Node);
1742 Sprint_Left_Opnd (Node);
1743 Write_Operator (Node, " ** ");
1744 Sprint_Right_Opnd (Node);
1747 Sprint_Left_Opnd (Node);
1748 Write_Operator (Node, " >= ");
1749 Sprint_Right_Opnd (Node);
1752 Sprint_Left_Opnd (Node);
1753 Write_Operator (Node, " > ");
1754 Sprint_Right_Opnd (Node);
1757 Sprint_Left_Opnd (Node);
1758 Write_Operator (Node, " <= ");
1759 Sprint_Right_Opnd (Node);
1762 Sprint_Left_Opnd (Node);
1763 Write_Operator (Node, " < ");
1764 Sprint_Right_Opnd (Node);
1767 Write_Operator (Node, "-");
1768 Sprint_Right_Opnd (Node);
1771 Sprint_Left_Opnd (Node);
1773 if Treat_Fixed_As_Integer (Node) then
1777 Write_Operator (Node, " mod ");
1778 Sprint_Right_Opnd (Node);
1780 when N_Op_Multiply =>
1781 Sprint_Left_Opnd (Node);
1783 Process_TFAI_RR_Flags (Node);
1784 Write_Operator (Node, "* ");
1785 Sprint_Right_Opnd (Node);
1788 Sprint_Left_Opnd (Node);
1789 Write_Operator (Node, " /= ");
1790 Sprint_Right_Opnd (Node);
1793 Write_Operator (Node, "not ");
1794 Sprint_Right_Opnd (Node);
1797 Sprint_Left_Opnd (Node);
1798 Write_Operator (Node, " or ");
1799 Sprint_Right_Opnd (Node);
1802 Write_Operator (Node, "+");
1803 Sprint_Right_Opnd (Node);
1806 Sprint_Left_Opnd (Node);
1808 if Treat_Fixed_As_Integer (Node) then
1812 Write_Operator (Node, " rem ");
1813 Sprint_Right_Opnd (Node);
1819 Write_Str_With_Col_Check ("(");
1820 Sprint_Node (Left_Opnd (Node));
1822 Sprint_Node (Right_Opnd (Node));
1825 when N_Op_Subtract =>
1826 Sprint_Left_Opnd (Node);
1827 Write_Operator (Node, " - ");
1828 Sprint_Right_Opnd (Node);
1831 Sprint_Left_Opnd (Node);
1832 Write_Operator (Node, " xor ");
1833 Sprint_Right_Opnd (Node);
1835 when N_Operator_Symbol =>
1836 Write_Name_With_Col_Check_Sloc (Chars (Node));
1838 when N_Ordinary_Fixed_Point_Definition =>
1839 Write_Str_With_Col_Check_Sloc ("delta ");
1840 Sprint_Node (Delta_Expression (Node));
1841 Sprint_Opt_Node (Real_Range_Specification (Node));
1844 Sprint_Left_Opnd (Node);
1845 Write_Str_Sloc (" or else ");
1846 Sprint_Right_Opnd (Node);
1848 when N_Others_Choice =>
1849 if All_Others (Node) then
1850 Write_Str_With_Col_Check ("all ");
1853 Write_Str_With_Col_Check_Sloc ("others");
1855 when N_Package_Body =>
1857 Write_Indent_Str_Sloc ("package body ");
1858 Sprint_Node (Defining_Unit_Name (Node));
1860 Sprint_Indented_List (Declarations (Node));
1862 if Present (Handled_Statement_Sequence (Node)) then
1863 Write_Indent_Str ("begin");
1864 Sprint_Node (Handled_Statement_Sequence (Node));
1867 Write_Indent_Str ("end ");
1868 Sprint_Node (Defining_Unit_Name (Node));
1871 when N_Package_Body_Stub =>
1872 Write_Indent_Str_Sloc ("package body ");
1873 Sprint_Node (Defining_Identifier (Node));
1874 Write_Str_With_Col_Check (" is separate;");
1876 when N_Package_Declaration =>
1879 Sprint_Node_Sloc (Specification (Node));
1882 when N_Package_Instantiation =>
1884 Write_Indent_Str_Sloc ("package ");
1885 Sprint_Node (Defining_Unit_Name (Node));
1886 Write_Str (" is new ");
1887 Sprint_Node (Name (Node));
1888 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1891 when N_Package_Renaming_Declaration =>
1892 Write_Indent_Str_Sloc ("package ");
1893 Sprint_Node (Defining_Unit_Name (Node));
1894 Write_Str_With_Col_Check (" renames ");
1895 Sprint_Node (Name (Node));
1898 when N_Package_Specification =>
1899 Write_Str_With_Col_Check_Sloc ("package ");
1900 Sprint_Node (Defining_Unit_Name (Node));
1902 Sprint_Indented_List (Visible_Declarations (Node));
1904 if Present (Private_Declarations (Node)) then
1905 Write_Indent_Str ("private");
1906 Sprint_Indented_List (Private_Declarations (Node));
1909 Write_Indent_Str ("end ");
1910 Sprint_Node (Defining_Unit_Name (Node));
1912 when N_Parameter_Association =>
1913 Sprint_Node_Sloc (Selector_Name (Node));
1915 Sprint_Node (Explicit_Actual_Parameter (Node));
1917 when N_Parameter_Specification =>
1920 if Write_Identifiers (Node) then
1923 if In_Present (Node) then
1924 Write_Str_With_Col_Check ("in ");
1927 if Out_Present (Node) then
1928 Write_Str_With_Col_Check ("out ");
1931 Sprint_Node (Parameter_Type (Node));
1933 if Present (Expression (Node)) then
1935 Sprint_Node (Expression (Node));
1942 Write_Indent_Str_Sloc ("pragma ");
1943 Write_Name_With_Col_Check (Chars (Node));
1945 if Present (Pragma_Argument_Associations (Node)) then
1946 Sprint_Opt_Paren_Comma_List
1947 (Pragma_Argument_Associations (Node));
1952 when N_Pragma_Argument_Association =>
1955 if Chars (Node) /= No_Name then
1956 Write_Name_With_Col_Check (Chars (Node));
1960 Sprint_Node (Expression (Node));
1962 when N_Private_Type_Declaration =>
1963 Write_Indent_Str_Sloc ("type ");
1964 Write_Id (Defining_Identifier (Node));
1966 if Present (Discriminant_Specifications (Node)) then
1967 Write_Discr_Specs (Node);
1968 elsif Unknown_Discriminants_Present (Node) then
1969 Write_Str_With_Col_Check ("(<>)");
1974 if Tagged_Present (Node) then
1975 Write_Str_With_Col_Check ("tagged ");
1978 if Limited_Present (Node) then
1979 Write_Str_With_Col_Check ("limited ");
1982 Write_Str_With_Col_Check ("private;");
1984 when N_Private_Extension_Declaration =>
1985 Write_Indent_Str_Sloc ("type ");
1986 Write_Id (Defining_Identifier (Node));
1988 if Present (Discriminant_Specifications (Node)) then
1989 Write_Discr_Specs (Node);
1990 elsif Unknown_Discriminants_Present (Node) then
1991 Write_Str_With_Col_Check ("(<>)");
1994 Write_Str_With_Col_Check (" is new ");
1995 Sprint_Node (Subtype_Indication (Node));
1996 Write_Str_With_Col_Check (" with private;");
1998 when N_Procedure_Call_Statement =>
2001 Sprint_Node (Name (Node));
2002 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2005 when N_Procedure_Instantiation =>
2006 Write_Indent_Str_Sloc ("procedure ");
2007 Sprint_Node (Defining_Unit_Name (Node));
2008 Write_Str_With_Col_Check (" is new ");
2009 Sprint_Node (Name (Node));
2010 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2013 when N_Procedure_Specification =>
2014 Write_Str_With_Col_Check_Sloc ("procedure ");
2015 Sprint_Node (Defining_Unit_Name (Node));
2016 Write_Param_Specs (Node);
2018 when N_Protected_Body =>
2019 Write_Indent_Str_Sloc ("protected body ");
2020 Write_Id (Defining_Identifier (Node));
2022 Sprint_Indented_List (Declarations (Node));
2023 Write_Indent_Str ("end ");
2024 Write_Id (Defining_Identifier (Node));
2027 when N_Protected_Body_Stub =>
2028 Write_Indent_Str_Sloc ("protected body ");
2029 Write_Id (Defining_Identifier (Node));
2030 Write_Str_With_Col_Check (" is separate;");
2032 when N_Protected_Definition =>
2034 Sprint_Indented_List (Visible_Declarations (Node));
2036 if Present (Private_Declarations (Node)) then
2037 Write_Indent_Str ("private");
2038 Sprint_Indented_List (Private_Declarations (Node));
2041 Write_Indent_Str ("end ");
2043 when N_Protected_Type_Declaration =>
2044 Write_Indent_Str_Sloc ("protected type ");
2045 Write_Id (Defining_Identifier (Node));
2046 Write_Discr_Specs (Node);
2048 Sprint_Node (Protected_Definition (Node));
2049 Write_Id (Defining_Identifier (Node));
2052 when N_Qualified_Expression =>
2053 Sprint_Node (Subtype_Mark (Node));
2054 Write_Char_Sloc (''');
2056 -- Print expression, make sure we have at least one level of
2057 -- parentheses around the expression. For cases of qualified
2058 -- expressions in the source, this is always the case, but
2059 -- for generated qualifications, there may be no explicit
2060 -- parentheses present.
2062 if Paren_Count (Expression (Node)) /= 0 then
2063 Sprint_Node (Expression (Node));
2066 Sprint_Node (Expression (Node));
2070 when N_Raise_Constraint_Error =>
2072 -- This node can be used either as a subexpression or as a
2073 -- statement form. The following test is a reasonably reliable
2074 -- way to distinguish the two cases.
2076 if Is_List_Member (Node)
2077 and then Nkind (Parent (Node)) not in N_Subexpr
2082 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2083 Write_Condition_And_Reason (Node);
2085 when N_Raise_Program_Error =>
2087 -- This node can be used either as a subexpression or as a
2088 -- statement form. The following test is a reasonably reliable
2089 -- way to distinguish the two cases.
2091 if Is_List_Member (Node)
2092 and then Nkind (Parent (Node)) not in N_Subexpr
2097 Write_Str_With_Col_Check_Sloc ("[program_error");
2098 Write_Condition_And_Reason (Node);
2100 when N_Raise_Storage_Error =>
2102 -- This node can be used either as a subexpression or as a
2103 -- statement form. The following test is a reasonably reliable
2104 -- way to distinguish the two cases.
2106 if Is_List_Member (Node)
2107 and then Nkind (Parent (Node)) not in N_Subexpr
2112 Write_Str_With_Col_Check_Sloc ("[storage_error");
2113 Write_Condition_And_Reason (Node);
2115 when N_Raise_Statement =>
2116 Write_Indent_Str_Sloc ("raise ");
2117 Sprint_Node (Name (Node));
2121 Sprint_Node (Low_Bound (Node));
2122 Write_Str_Sloc (" .. ");
2123 Sprint_Node (High_Bound (Node));
2125 when N_Range_Constraint =>
2126 Write_Str_With_Col_Check_Sloc ("range ");
2127 Sprint_Node (Range_Expression (Node));
2129 when N_Real_Literal =>
2130 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2132 when N_Real_Range_Specification =>
2133 Write_Str_With_Col_Check_Sloc ("range ");
2134 Sprint_Node (Low_Bound (Node));
2136 Sprint_Node (High_Bound (Node));
2138 when N_Record_Definition =>
2139 if Abstract_Present (Node) then
2140 Write_Str_With_Col_Check ("abstract ");
2143 if Tagged_Present (Node) then
2144 Write_Str_With_Col_Check ("tagged ");
2147 if Limited_Present (Node) then
2148 Write_Str_With_Col_Check ("limited ");
2151 if Null_Present (Node) then
2152 Write_Str_With_Col_Check_Sloc ("null record");
2155 Write_Str_With_Col_Check_Sloc ("record");
2156 Sprint_Node (Component_List (Node));
2157 Write_Indent_Str ("end record");
2160 when N_Record_Representation_Clause =>
2161 Write_Indent_Str_Sloc ("for ");
2162 Sprint_Node (Identifier (Node));
2163 Write_Str_With_Col_Check (" use record ");
2165 if Present (Mod_Clause (Node)) then
2166 Sprint_Node (Mod_Clause (Node));
2169 Sprint_Indented_List (Component_Clauses (Node));
2170 Write_Indent_Str ("end record;");
2173 Sprint_Node (Prefix (Node));
2174 Write_Str_With_Col_Check_Sloc ("'reference");
2176 when N_Requeue_Statement =>
2177 Write_Indent_Str_Sloc ("requeue ");
2178 Sprint_Node (Name (Node));
2180 if Abort_Present (Node) then
2181 Write_Str_With_Col_Check (" with abort");
2186 when N_Return_Statement =>
2187 if Present (Expression (Node)) then
2188 Write_Indent_Str_Sloc ("return ");
2189 Sprint_Node (Expression (Node));
2192 Write_Indent_Str_Sloc ("return;");
2195 when N_Selective_Accept =>
2196 Write_Indent_Str_Sloc ("select");
2202 Alt_Node := First (Select_Alternatives (Node));
2205 Sprint_Node (Alt_Node);
2208 exit when No (Alt_Node);
2209 Write_Indent_Str ("or");
2213 if Present (Else_Statements (Node)) then
2214 Write_Indent_Str ("else");
2215 Sprint_Indented_List (Else_Statements (Node));
2218 Write_Indent_Str ("end select;");
2220 when N_Signed_Integer_Type_Definition =>
2221 Write_Str_With_Col_Check_Sloc ("range ");
2222 Sprint_Node (Low_Bound (Node));
2224 Sprint_Node (High_Bound (Node));
2226 when N_Single_Protected_Declaration =>
2227 Write_Indent_Str_Sloc ("protected ");
2228 Write_Id (Defining_Identifier (Node));
2230 Sprint_Node (Protected_Definition (Node));
2231 Write_Id (Defining_Identifier (Node));
2234 when N_Single_Task_Declaration =>
2235 Write_Indent_Str_Sloc ("task ");
2236 Write_Id (Defining_Identifier (Node));
2238 if Present (Task_Definition (Node)) then
2240 Sprint_Node (Task_Definition (Node));
2241 Write_Id (Defining_Identifier (Node));
2246 when N_Selected_Component | N_Expanded_Name =>
2247 Sprint_Node (Prefix (Node));
2248 Write_Char_Sloc ('.');
2249 Sprint_Node (Selector_Name (Node));
2253 Sprint_Node (Prefix (Node));
2254 Write_Str_With_Col_Check (" (");
2255 Sprint_Node (Discrete_Range (Node));
2258 when N_String_Literal =>
2259 if String_Length (Strval (Node)) + Column > 75 then
2260 Write_Indent_Str (" ");
2264 Write_String_Table_Entry (Strval (Node));
2266 when N_Subprogram_Body =>
2267 if Freeze_Indent = 0 then
2272 Sprint_Node_Sloc (Specification (Node));
2275 Sprint_Indented_List (Declarations (Node));
2276 Write_Indent_Str ("begin");
2277 Sprint_Node (Handled_Statement_Sequence (Node));
2279 Write_Indent_Str ("end ");
2280 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2283 if Is_List_Member (Node)
2284 and then Present (Next (Node))
2285 and then Nkind (Next (Node)) /= N_Subprogram_Body
2290 when N_Subprogram_Body_Stub =>
2292 Sprint_Node_Sloc (Specification (Node));
2293 Write_Str_With_Col_Check (" is separate;");
2295 when N_Subprogram_Declaration =>
2297 Sprint_Node_Sloc (Specification (Node));
2300 when N_Subprogram_Info =>
2301 Sprint_Node (Identifier (Node));
2302 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2304 when N_Subprogram_Renaming_Declaration =>
2306 Sprint_Node (Specification (Node));
2307 Write_Str_With_Col_Check_Sloc (" renames ");
2308 Sprint_Node (Name (Node));
2311 when N_Subtype_Declaration =>
2312 Write_Indent_Str_Sloc ("subtype ");
2313 Write_Id (Defining_Identifier (Node));
2315 Sprint_Node (Subtype_Indication (Node));
2318 when N_Subtype_Indication =>
2319 Sprint_Node_Sloc (Subtype_Mark (Node));
2321 Sprint_Node (Constraint (Node));
2324 Write_Indent_Str_Sloc ("separate (");
2325 Sprint_Node (Name (Node));
2328 Sprint_Node (Proper_Body (Node));
2331 Write_Indent_Str_Sloc ("task body ");
2332 Write_Id (Defining_Identifier (Node));
2334 Sprint_Indented_List (Declarations (Node));
2335 Write_Indent_Str ("begin");
2336 Sprint_Node (Handled_Statement_Sequence (Node));
2337 Write_Indent_Str ("end ");
2338 Write_Id (Defining_Identifier (Node));
2341 when N_Task_Body_Stub =>
2342 Write_Indent_Str_Sloc ("task body ");
2343 Write_Id (Defining_Identifier (Node));
2344 Write_Str_With_Col_Check (" is separate;");
2346 when N_Task_Definition =>
2348 Sprint_Indented_List (Visible_Declarations (Node));
2350 if Present (Private_Declarations (Node)) then
2351 Write_Indent_Str ("private");
2352 Sprint_Indented_List (Private_Declarations (Node));
2355 Write_Indent_Str ("end ");
2357 when N_Task_Type_Declaration =>
2358 Write_Indent_Str_Sloc ("task type ");
2359 Write_Id (Defining_Identifier (Node));
2360 Write_Discr_Specs (Node);
2361 if Present (Task_Definition (Node)) then
2363 Sprint_Node (Task_Definition (Node));
2364 Write_Id (Defining_Identifier (Node));
2369 when N_Terminate_Alternative =>
2370 Sprint_Node_List (Pragmas_Before (Node));
2374 if Present (Condition (Node)) then
2375 Write_Str_With_Col_Check ("when ");
2376 Sprint_Node (Condition (Node));
2380 Write_Str_With_Col_Check_Sloc ("terminate;");
2381 Sprint_Node_List (Pragmas_After (Node));
2383 when N_Timed_Entry_Call =>
2384 Write_Indent_Str_Sloc ("select");
2386 Sprint_Node (Entry_Call_Alternative (Node));
2388 Write_Indent_Str ("or");
2390 Sprint_Node (Delay_Alternative (Node));
2392 Write_Indent_Str ("end select;");
2394 when N_Triggering_Alternative =>
2395 Sprint_Node_List (Pragmas_Before (Node));
2396 Sprint_Node_Sloc (Triggering_Statement (Node));
2397 Sprint_Node_List (Statements (Node));
2399 when N_Type_Conversion =>
2401 Sprint_Node (Subtype_Mark (Node));
2404 if Conversion_OK (Node) then
2408 if Float_Truncate (Node) then
2412 if Rounded_Result (Node) then
2417 Sprint_Node (Expression (Node));
2420 when N_Unchecked_Expression =>
2423 Sprint_Node_Sloc (Expression (Node));
2426 when N_Unchecked_Type_Conversion =>
2427 Sprint_Node (Subtype_Mark (Node));
2429 Write_Str_With_Col_Check ("(");
2430 Sprint_Node_Sloc (Expression (Node));
2433 when N_Unconstrained_Array_Definition =>
2434 Write_Str_With_Col_Check_Sloc ("array (");
2440 Node1 := First (Subtype_Marks (Node));
2442 Sprint_Node (Node1);
2443 Write_Str_With_Col_Check (" range <>");
2445 exit when Node1 = Empty;
2450 Write_Str (") of ");
2452 if Aliased_Present (Node) then
2453 Write_Str_With_Col_Check ("aliased ");
2456 Sprint_Node (Subtype_Indication (Node));
2458 when N_Unused_At_Start | N_Unused_At_End =>
2459 Write_Indent_Str ("***** Error, unused node encountered *****");
2462 when N_Use_Package_Clause =>
2463 Write_Indent_Str_Sloc ("use ");
2464 Sprint_Comma_List (Names (Node));
2467 when N_Use_Type_Clause =>
2468 Write_Indent_Str_Sloc ("use type ");
2469 Sprint_Comma_List (Subtype_Marks (Node));
2472 when N_Validate_Unchecked_Conversion =>
2473 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2474 Sprint_Node (Source_Type (Node));
2476 Sprint_Node (Target_Type (Node));
2480 Write_Indent_Str_Sloc ("when ");
2481 Sprint_Bar_List (Discrete_Choices (Node));
2483 Sprint_Node (Component_List (Node));
2485 when N_Variant_Part =>
2487 Write_Indent_Str_Sloc ("case ");
2488 Sprint_Node (Name (Node));
2490 Sprint_Indented_List (Variants (Node));
2491 Write_Indent_Str ("end case");
2494 when N_With_Clause =>
2496 -- Special test, if we are dumping the original tree only,
2497 -- then we want to eliminate the bogus with clauses that
2498 -- correspond to the non-existent children of Text_IO.
2500 if Dump_Original_Only
2501 and then Is_Text_IO_Kludge_Unit (Name (Node))
2505 -- Normal case, output the with clause
2508 if First_Name (Node) or else not Dump_Original_Only then
2509 Write_Indent_Str ("with ");
2514 Sprint_Node_Sloc (Name (Node));
2516 if Last_Name (Node) or else not Dump_Original_Only then
2521 when N_With_Type_Clause =>
2523 Write_Indent_Str ("with type ");
2524 Sprint_Node_Sloc (Name (Node));
2526 if Tagged_Present (Node) then
2527 Write_Str (" is tagged;");
2529 Write_Str (" is access;");
2534 if Nkind (Node) in N_Subexpr
2535 and then Do_Range_Check (Node)
2540 for J in 1 .. Paren_Count (Node) loop
2544 pragma Assert (No (Debug_Node));
2545 Debug_Node := Save_Debug_Node;
2546 end Sprint_Node_Actual;
2548 ----------------------
2549 -- Sprint_Node_List --
2550 ----------------------
2552 procedure Sprint_Node_List (List : List_Id) is
2556 if Is_Non_Empty_List (List) then
2557 Node := First (List);
2562 exit when Node = Empty;
2565 end Sprint_Node_List;
2567 ----------------------
2568 -- Sprint_Node_Sloc --
2569 ----------------------
2571 procedure Sprint_Node_Sloc (Node : Node_Id) is
2575 if Present (Debug_Node) then
2576 Set_Sloc (Debug_Node, Sloc (Node));
2577 Debug_Node := Empty;
2579 end Sprint_Node_Sloc;
2581 ---------------------
2582 -- Sprint_Opt_Node --
2583 ---------------------
2585 procedure Sprint_Opt_Node (Node : Node_Id) is
2587 if Present (Node) then
2591 end Sprint_Opt_Node;
2593 --------------------------
2594 -- Sprint_Opt_Node_List --
2595 --------------------------
2597 procedure Sprint_Opt_Node_List (List : List_Id) is
2599 if Present (List) then
2600 Sprint_Node_List (List);
2602 end Sprint_Opt_Node_List;
2604 ---------------------------------
2605 -- Sprint_Opt_Paren_Comma_List --
2606 ---------------------------------
2608 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2610 if Is_Non_Empty_List (List) then
2612 Sprint_Paren_Comma_List (List);
2614 end Sprint_Opt_Paren_Comma_List;
2616 -----------------------------
2617 -- Sprint_Paren_Comma_List --
2618 -----------------------------
2620 procedure Sprint_Paren_Comma_List (List : List_Id) is
2622 Node_Exists : Boolean := False;
2626 if Is_Non_Empty_List (List) then
2628 if Dump_Original_Only then
2631 while Present (N) loop
2633 if not Is_Rewrite_Insertion (N) then
2634 Node_Exists := True;
2641 if not Node_Exists then
2646 Write_Str_With_Col_Check ("(");
2647 Sprint_Comma_List (List);
2650 end Sprint_Paren_Comma_List;
2652 ----------------------
2653 -- Sprint_Right_Opnd --
2654 ----------------------
2656 procedure Sprint_Right_Opnd (N : Node_Id) is
2657 Opnd : constant Node_Id := Right_Opnd (N);
2660 if Paren_Count (Opnd) /= 0
2661 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2670 end Sprint_Right_Opnd;
2672 ---------------------
2673 -- Write_Char_Sloc --
2674 ---------------------
2676 procedure Write_Char_Sloc (C : Character) is
2678 if Debug_Generated_Code and then C /= ' ' then
2683 end Write_Char_Sloc;
2685 --------------------------------
2686 -- Write_Condition_And_Reason --
2687 --------------------------------
2689 procedure Write_Condition_And_Reason (Node : Node_Id) is
2690 Image : constant String := RT_Exception_Code'Image
2691 (RT_Exception_Code'Val
2692 (UI_To_Int (Reason (Node))));
2695 if Present (Condition (Node)) then
2696 Write_Str_With_Col_Check (" when ");
2697 Sprint_Node (Condition (Node));
2702 for J in 4 .. Image'Last loop
2703 if Image (J) = '_' then
2706 Write_Char (Fold_Lower (Image (J)));
2711 end Write_Condition_And_Reason;
2713 ------------------------
2714 -- Write_Discr_Specs --
2715 ------------------------
2717 procedure Write_Discr_Specs (N : Node_Id) is
2722 Specs := Discriminant_Specifications (N);
2724 if Present (Specs) then
2725 Write_Str_With_Col_Check (" (");
2726 Spec := First (Specs);
2731 exit when Spec = Empty;
2733 -- Add semicolon, unless we are printing original tree and the
2734 -- next specification is part of a list (but not the first
2735 -- element of that list)
2737 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2744 end Write_Discr_Specs;
2750 procedure Write_Ekind (E : Entity_Id) is
2751 S : constant String := Entity_Kind'Image (Ekind (E));
2754 Name_Len := S'Length;
2755 Name_Buffer (1 .. Name_Len) := S;
2756 Set_Casing (Mixed_Case);
2757 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2764 procedure Write_Id (N : Node_Id) is
2766 -- Case of a defining identifier
2768 if Nkind (N) = N_Defining_Identifier then
2770 -- If defining identifier has an interface name (and no
2771 -- address clause), then we output the interface name.
2773 if (Is_Imported (N) or else Is_Exported (N))
2774 and then Present (Interface_Name (N))
2775 and then No (Address_Clause (N))
2777 String_To_Name_Buffer (Strval (Interface_Name (N)));
2778 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2780 -- If no interface name (or inactive because there was
2781 -- an address clause), then just output the Chars name.
2784 Write_Name_With_Col_Check (Chars (N));
2787 -- Case of selector of an expanded name where the expanded name
2788 -- has an associated entity, output this entity.
2790 elsif Nkind (Parent (N)) = N_Expanded_Name
2791 and then Selector_Name (Parent (N)) = N
2792 and then Present (Entity (Parent (N)))
2794 Write_Id (Entity (Parent (N)));
2796 -- For any other kind of node with an associated entity, output it.
2798 elsif Nkind (N) in N_Has_Entity
2799 and then Present (Entity (N))
2801 Write_Id (Entity (N));
2803 -- All other cases, we just print the Chars field
2806 Write_Name_With_Col_Check (Chars (N));
2810 -----------------------
2811 -- Write_Identifiers --
2812 -----------------------
2814 function Write_Identifiers (Node : Node_Id) return Boolean is
2816 Sprint_Node (Defining_Identifier (Node));
2818 -- The remainder of the declaration must be printed unless we are
2819 -- printing the original tree and this is not the last identifier
2822 not Dump_Original_Only or else not More_Ids (Node);
2824 end Write_Identifiers;
2826 ------------------------
2827 -- Write_Implicit_Def --
2828 ------------------------
2830 procedure Write_Implicit_Def (E : Entity_Id) is
2835 when E_Array_Subtype =>
2836 Write_Str_With_Col_Check ("subtype ");
2838 Write_Str_With_Col_Check (" is ");
2839 Write_Id (Base_Type (E));
2840 Write_Str_With_Col_Check (" (");
2842 Ind := First_Index (E);
2844 while Present (Ind) loop
2848 if Present (Ind) then
2855 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2856 Write_Str_With_Col_Check ("subtype ");
2859 Write_Id (Etype (E));
2860 Write_Str_With_Col_Check (" range ");
2861 Sprint_Node (Scalar_Range (E));
2865 Write_Str_With_Col_Check ("type ");
2867 Write_Str_With_Col_Check (" is <");
2872 end Write_Implicit_Def;
2878 procedure Write_Indent is
2880 if Indent_Annull_Flag then
2881 Indent_Annull_Flag := False;
2885 for J in 1 .. Indent loop
2891 ------------------------------
2892 -- Write_Indent_Identifiers --
2893 ------------------------------
2895 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
2897 -- We need to start a new line for every node, except in the case
2898 -- where we are printing the original tree and this is not the first
2899 -- defining identifier in the list.
2901 if not Dump_Original_Only or else not Prev_Ids (Node) then
2904 -- If printing original tree and this is not the first defining
2905 -- identifier in the list, then the previous call to this procedure
2906 -- printed only the name, and we add a comma to separate the names.
2912 Sprint_Node (Defining_Identifier (Node));
2914 -- The remainder of the declaration must be printed unless we are
2915 -- printing the original tree and this is not the last identifier
2918 not Dump_Original_Only or else not More_Ids (Node);
2920 end Write_Indent_Identifiers;
2922 -----------------------------------
2923 -- Write_Indent_Identifiers_Sloc --
2924 -----------------------------------
2926 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
2928 -- We need to start a new line for every node, except in the case
2929 -- where we are printing the original tree and this is not the first
2930 -- defining identifier in the list.
2932 if not Dump_Original_Only or else not Prev_Ids (Node) then
2935 -- If printing original tree and this is not the first defining
2936 -- identifier in the list, then the previous call to this procedure
2937 -- printed only the name, and we add a comma to separate the names.
2944 Sprint_Node (Defining_Identifier (Node));
2946 -- The remainder of the declaration must be printed unless we are
2947 -- printing the original tree and this is not the last identifier
2950 not Dump_Original_Only or else not More_Ids (Node);
2952 end Write_Indent_Identifiers_Sloc;
2954 ----------------------
2955 -- Write_Indent_Str --
2956 ----------------------
2958 procedure Write_Indent_Str (S : String) is
2962 end Write_Indent_Str;
2964 ---------------------------
2965 -- Write_Indent_Str_Sloc --
2966 ---------------------------
2968 procedure Write_Indent_Str_Sloc (S : String) is
2972 end Write_Indent_Str_Sloc;
2974 -------------------------------
2975 -- Write_Name_With_Col_Check --
2976 -------------------------------
2978 procedure Write_Name_With_Col_Check (N : Name_Id) is
2982 Get_Name_String (N);
2984 -- Deal with -gnatI which replaces digits in an internal
2985 -- name by three dots (e.g. R7b becomes R...b).
2987 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
2990 while J < Name_Len loop
2991 exit when Name_Buffer (J) not in 'A' .. 'Z';
2995 if Name_Buffer (J) in '0' .. '9' then
2996 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
2999 while J <= Name_Len loop
3000 if Name_Buffer (J) not in '0' .. '9' then
3001 Write_Str (Name_Buffer (J .. Name_Len));
3013 -- Fall through for normal case
3015 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3016 end Write_Name_With_Col_Check;
3018 ------------------------------------
3019 -- Write_Name_With_Col_Check_Sloc --
3020 ------------------------------------
3022 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3024 Get_Name_String (N);
3025 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3026 end Write_Name_With_Col_Check_Sloc;
3028 --------------------
3029 -- Write_Operator --
3030 --------------------
3032 procedure Write_Operator (N : Node_Id; S : String) is
3033 F : Natural := S'First;
3034 T : Natural := S'Last;
3037 -- If no overflow check, just write string out, and we are done
3039 if not Do_Overflow_Check (N) then
3042 -- If overflow check, we want to surround the operator with curly
3043 -- brackets, but not include spaces within the brackets.
3056 Write_Str_Sloc (S (F .. T));
3059 if S (S'Last) = ' ' then
3065 -----------------------
3066 -- Write_Param_Specs --
3067 -----------------------
3069 procedure Write_Param_Specs (N : Node_Id) is
3075 Specs := Parameter_Specifications (N);
3077 if Is_Non_Empty_List (Specs) then
3078 Write_Str_With_Col_Check (" (");
3079 Spec := First (Specs);
3083 Formal := Defining_Identifier (Spec);
3085 exit when Spec = Empty;
3087 -- Add semicolon, unless we are printing original tree and the
3088 -- next specification is part of a list (but not the first
3089 -- element of that list)
3091 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3096 -- Write out any extra formals
3098 while Present (Extra_Formal (Formal)) loop
3099 Formal := Extra_Formal (Formal);
3101 Write_Name_With_Col_Check (Chars (Formal));
3103 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3108 end Write_Param_Specs;
3110 --------------------------
3111 -- Write_Rewrite_Str --
3112 --------------------------
3114 procedure Write_Rewrite_Str (S : String) is
3116 if not Dump_Generated_Only then
3117 if S'Length = 3 and then S = ">>>" then
3120 Write_Str_With_Col_Check (S);
3123 end Write_Rewrite_Str;
3125 --------------------
3126 -- Write_Str_Sloc --
3127 --------------------
3129 procedure Write_Str_Sloc (S : String) is
3131 for J in S'Range loop
3132 Write_Char_Sloc (S (J));
3136 ------------------------------
3137 -- Write_Str_With_Col_Check --
3138 ------------------------------
3140 procedure Write_Str_With_Col_Check (S : String) is
3142 if Int (S'Last) + Column > Line_Limit then
3143 Write_Indent_Str (" ");
3146 Write_Str (S (2 .. S'Length));
3154 end Write_Str_With_Col_Check;
3156 -----------------------------------
3157 -- Write_Str_With_Col_Check_Sloc --
3158 -----------------------------------
3160 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3162 if Int (S'Last) + Column > Line_Limit then
3163 Write_Indent_Str (" ");
3166 Write_Str_Sloc (S (2 .. S'Length));
3174 end Write_Str_With_Col_Check_Sloc;
3176 ------------------------------------
3177 -- Write_Uint_With_Col_Check_Sloc --
3178 ------------------------------------
3180 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3182 Col_Check (UI_Decimal_Digits_Hi (U));
3184 UI_Write (U, Format);
3185 end Write_Uint_With_Col_Check_Sloc;
3187 -------------------------------------
3188 -- Write_Ureal_With_Col_Check_Sloc --
3189 -------------------------------------
3191 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3192 D : constant Uint := Denominator (U);
3193 N : constant Uint := Numerator (U);
3197 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3200 end Write_Ureal_With_Col_Check_Sloc;