1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, 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 =>
698 if Present (Access_To_Subprogram_Definition (Node)) then
699 Sprint_Node (Access_To_Subprogram_Definition (Node));
703 if Null_Exclusion_Present (Node) then
704 Write_Str ("not null ");
707 Write_Str_With_Col_Check_Sloc ("access ");
709 if All_Present (Node) then
711 elsif Constant_Present (Node) then
712 Write_Str ("constant ");
715 Sprint_Node (Subtype_Mark (Node));
718 when N_Access_Function_Definition =>
722 if Null_Exclusion_Present (Node) then
723 Write_Str ("not null ");
726 Write_Str_With_Col_Check_Sloc ("access ");
728 if Protected_Present (Node) then
729 Write_Str_With_Col_Check ("protected ");
732 Write_Str_With_Col_Check ("function");
733 Write_Param_Specs (Node);
734 Write_Str_With_Col_Check (" return ");
735 Sprint_Node (Subtype_Mark (Node));
737 when N_Access_Procedure_Definition =>
741 if Null_Exclusion_Present (Node) then
742 Write_Str ("not null ");
745 Write_Str_With_Col_Check_Sloc ("access ");
747 if Protected_Present (Node) then
748 Write_Str_With_Col_Check ("protected ");
751 Write_Str_With_Col_Check ("procedure");
752 Write_Param_Specs (Node);
754 when N_Access_To_Object_Definition =>
755 Write_Str_With_Col_Check_Sloc ("access ");
757 if All_Present (Node) then
758 Write_Str_With_Col_Check ("all ");
759 elsif Constant_Present (Node) then
760 Write_Str_With_Col_Check ("constant ");
765 if Null_Exclusion_Present (Node) then
766 Write_Str ("not null ");
769 Sprint_Node (Subtype_Indication (Node));
772 if Null_Record_Present (Node) then
773 Write_Str_With_Col_Check_Sloc ("(null record)");
776 Write_Str_With_Col_Check_Sloc ("(");
778 if Present (Expressions (Node)) then
779 Sprint_Comma_List (Expressions (Node));
781 if Present (Component_Associations (Node)) then
786 if Present (Component_Associations (Node)) then
793 Nd := First (Component_Associations (Node));
801 if not Is_Rewrite_Insertion (Nd)
802 or else not Dump_Original_Only
816 Write_Str_With_Col_Check_Sloc ("new ");
820 if Null_Exclusion_Present (Node) then
821 Write_Str ("not null ");
824 Sprint_Node (Expression (Node));
826 if Present (Storage_Pool (Node)) then
827 Write_Str_With_Col_Check ("[storage_pool = ");
828 Sprint_Node (Storage_Pool (Node));
833 Sprint_Left_Opnd (Node);
834 Write_Str_Sloc (" and then ");
835 Sprint_Right_Opnd (Node);
838 Write_Indent_Str_Sloc ("for ");
839 Write_Id (Identifier (Node));
840 Write_Str_With_Col_Check (" use at ");
841 Sprint_Node (Expression (Node));
844 when N_Assignment_Statement =>
846 Sprint_Node (Name (Node));
847 Write_Str_Sloc (" := ");
848 Sprint_Node (Expression (Node));
851 when N_Asynchronous_Select =>
852 Write_Indent_Str_Sloc ("select");
854 Sprint_Node (Triggering_Alternative (Node));
857 -- Note: let the printing of Abortable_Part handle outputting
858 -- the ABORT keyword, so that the Slco can be set correctly.
860 Write_Indent_Str ("then ");
861 Sprint_Node (Abortable_Part (Node));
862 Write_Indent_Str ("end select;");
864 when N_Attribute_Definition_Clause =>
865 Write_Indent_Str_Sloc ("for ");
866 Sprint_Node (Name (Node));
868 Write_Name_With_Col_Check (Chars (Node));
869 Write_Str_With_Col_Check (" use ");
870 Sprint_Node (Expression (Node));
873 when N_Attribute_Reference =>
874 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
878 Sprint_Node (Prefix (Node));
879 Write_Char_Sloc (''');
880 Write_Name_With_Col_Check (Attribute_Name (Node));
881 Sprint_Paren_Comma_List (Expressions (Node));
883 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
887 when N_Block_Statement =>
890 if Present (Identifier (Node))
891 and then (not Has_Created_Identifier (Node)
892 or else not Dump_Original_Only)
894 Write_Rewrite_Str ("<<<");
895 Write_Id (Identifier (Node));
897 Write_Rewrite_Str (">>>");
900 if Present (Declarations (Node)) then
901 Write_Str_With_Col_Check_Sloc ("declare");
902 Sprint_Indented_List (Declarations (Node));
906 Write_Str_With_Col_Check_Sloc ("begin");
907 Sprint_Node (Handled_Statement_Sequence (Node));
908 Write_Indent_Str ("end");
910 if Present (Identifier (Node))
911 and then (not Has_Created_Identifier (Node)
912 or else not Dump_Original_Only)
914 Write_Rewrite_Str ("<<<");
916 Write_Id (Identifier (Node));
917 Write_Rewrite_Str (">>>");
922 when N_Case_Statement =>
923 Write_Indent_Str_Sloc ("case ");
924 Sprint_Node (Expression (Node));
926 Sprint_Indented_List (Alternatives (Node));
927 Write_Indent_Str ("end case;");
929 when N_Case_Statement_Alternative =>
930 Write_Indent_Str_Sloc ("when ");
931 Sprint_Bar_List (Discrete_Choices (Node));
933 Sprint_Indented_List (Statements (Node));
935 when N_Character_Literal =>
937 Write_Indent_Str (" ");
940 Write_Char_Sloc (''');
941 Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
944 when N_Code_Statement =>
947 Sprint_Node (Expression (Node));
950 when N_Compilation_Unit =>
951 Sprint_Node_List (Context_Items (Node));
952 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
954 if Private_Present (Node) then
955 Write_Indent_Str ("private ");
959 Sprint_Node_Sloc (Unit (Node));
961 if Present (Actions (Aux_Decls_Node (Node)))
963 Present (Pragmas_After (Aux_Decls_Node (Node)))
968 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
969 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
971 when N_Compilation_Unit_Aux =>
972 null; -- nothing to do, never used, see above
974 when N_Component_Association =>
976 Sprint_Bar_List (Choices (Node));
979 -- Ada 2005 (AI-287): Print the mbox if present
981 if Box_Present (Node) then
982 Write_Str_With_Col_Check ("<>");
984 Sprint_Node (Expression (Node));
987 when N_Component_Clause =>
989 Sprint_Node (Component_Name (Node));
990 Write_Str_Sloc (" at ");
991 Sprint_Node (Position (Node));
993 Write_Str_With_Col_Check ("range ");
994 Sprint_Node (First_Bit (Node));
996 Sprint_Node (Last_Bit (Node));
999 when N_Component_Definition =>
1002 -- Ada 2005 (AI-230): Access definition components
1004 if Present (Access_Definition (Node)) then
1005 Sprint_Node (Access_Definition (Node));
1007 elsif Present (Subtype_Indication (Node)) then
1008 if Aliased_Present (Node) then
1009 Write_Str_With_Col_Check ("aliased ");
1012 -- Ada 2005 (AI-231)
1014 if Null_Exclusion_Present (Node) then
1015 Write_Str (" not null ");
1018 Sprint_Node (Subtype_Indication (Node));
1021 Write_Str (" ??? ");
1024 when N_Component_Declaration =>
1025 if Write_Indent_Identifiers_Sloc (Node) then
1027 Sprint_Node (Component_Definition (Node));
1029 if Present (Expression (Node)) then
1031 Sprint_Node (Expression (Node));
1037 when N_Component_List =>
1038 if Null_Present (Node) then
1040 Write_Indent_Str_Sloc ("null");
1046 Sprint_Indented_List (Component_Items (Node));
1047 Sprint_Node (Variant_Part (Node));
1050 when N_Conditional_Entry_Call =>
1051 Write_Indent_Str_Sloc ("select");
1053 Sprint_Node (Entry_Call_Alternative (Node));
1055 Write_Indent_Str ("else");
1056 Sprint_Indented_List (Else_Statements (Node));
1057 Write_Indent_Str ("end select;");
1059 when N_Conditional_Expression =>
1061 Condition : constant Node_Id := First (Expressions (Node));
1062 Then_Expr : constant Node_Id := Next (Condition);
1063 Else_Expr : constant Node_Id := Next (Then_Expr);
1066 Write_Str_With_Col_Check_Sloc ("(if ");
1067 Sprint_Node (Condition);
1068 Write_Str_With_Col_Check (" then ");
1069 Sprint_Node (Then_Expr);
1070 Write_Str_With_Col_Check (" else ");
1071 Sprint_Node (Else_Expr);
1075 when N_Constrained_Array_Definition =>
1076 Write_Str_With_Col_Check_Sloc ("array ");
1077 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1080 Sprint_Node (Component_Definition (Node));
1082 when N_Decimal_Fixed_Point_Definition =>
1083 Write_Str_With_Col_Check_Sloc (" delta ");
1084 Sprint_Node (Delta_Expression (Node));
1085 Write_Str_With_Col_Check ("digits ");
1086 Sprint_Node (Digits_Expression (Node));
1087 Sprint_Opt_Node (Real_Range_Specification (Node));
1089 when N_Defining_Character_Literal =>
1090 Write_Name_With_Col_Check_Sloc (Chars (Node));
1092 when N_Defining_Identifier =>
1096 when N_Defining_Operator_Symbol =>
1097 Write_Name_With_Col_Check_Sloc (Chars (Node));
1099 when N_Defining_Program_Unit_Name =>
1101 Sprint_Node (Name (Node));
1103 Write_Id (Defining_Identifier (Node));
1105 when N_Delay_Alternative =>
1106 Sprint_Node_List (Pragmas_Before (Node));
1108 if Present (Condition (Node)) then
1110 Write_Str_With_Col_Check ("when ");
1111 Sprint_Node (Condition (Node));
1116 Sprint_Node_Sloc (Delay_Statement (Node));
1117 Sprint_Node_List (Statements (Node));
1119 when N_Delay_Relative_Statement =>
1120 Write_Indent_Str_Sloc ("delay ");
1121 Sprint_Node (Expression (Node));
1124 when N_Delay_Until_Statement =>
1125 Write_Indent_Str_Sloc ("delay until ");
1126 Sprint_Node (Expression (Node));
1129 when N_Delta_Constraint =>
1130 Write_Str_With_Col_Check_Sloc ("delta ");
1131 Sprint_Node (Delta_Expression (Node));
1132 Sprint_Opt_Node (Range_Constraint (Node));
1134 when N_Derived_Type_Definition =>
1135 if Abstract_Present (Node) then
1136 Write_Str_With_Col_Check ("abstract ");
1139 Write_Str_With_Col_Check_Sloc ("new ");
1141 -- Ada 2005 (AI-231)
1143 if Null_Exclusion_Present (Node) then
1144 Write_Str_With_Col_Check ("not null ");
1147 Sprint_Node (Subtype_Indication (Node));
1149 if Present (Record_Extension_Part (Node)) then
1150 Write_Str_With_Col_Check (" with ");
1151 Sprint_Node (Record_Extension_Part (Node));
1154 when N_Designator =>
1155 Sprint_Node (Name (Node));
1156 Write_Char_Sloc ('.');
1157 Write_Id (Identifier (Node));
1159 when N_Digits_Constraint =>
1160 Write_Str_With_Col_Check_Sloc ("digits ");
1161 Sprint_Node (Digits_Expression (Node));
1162 Sprint_Opt_Node (Range_Constraint (Node));
1164 when N_Discriminant_Association =>
1167 if Present (Selector_Names (Node)) then
1168 Sprint_Bar_List (Selector_Names (Node));
1173 Sprint_Node (Expression (Node));
1175 when N_Discriminant_Specification =>
1178 if Write_Identifiers (Node) then
1181 if Null_Exclusion_Present (Node) then
1182 Write_Str ("not null ");
1185 Sprint_Node (Discriminant_Type (Node));
1187 if Present (Expression (Node)) then
1189 Sprint_Node (Expression (Node));
1195 when N_Elsif_Part =>
1196 Write_Indent_Str_Sloc ("elsif ");
1197 Sprint_Node (Condition (Node));
1198 Write_Str_With_Col_Check (" then");
1199 Sprint_Indented_List (Then_Statements (Node));
1204 when N_Entry_Body =>
1205 Write_Indent_Str_Sloc ("entry ");
1206 Write_Id (Defining_Identifier (Node));
1207 Sprint_Node (Entry_Body_Formal_Part (Node));
1208 Write_Str_With_Col_Check (" is");
1209 Sprint_Indented_List (Declarations (Node));
1210 Write_Indent_Str ("begin");
1211 Sprint_Node (Handled_Statement_Sequence (Node));
1212 Write_Indent_Str ("end ");
1213 Write_Id (Defining_Identifier (Node));
1216 when N_Entry_Body_Formal_Part =>
1217 if Present (Entry_Index_Specification (Node)) then
1218 Write_Str_With_Col_Check_Sloc (" (");
1219 Sprint_Node (Entry_Index_Specification (Node));
1223 Write_Param_Specs (Node);
1224 Write_Str_With_Col_Check_Sloc (" when ");
1225 Sprint_Node (Condition (Node));
1227 when N_Entry_Call_Alternative =>
1228 Sprint_Node_List (Pragmas_Before (Node));
1229 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1230 Sprint_Node_List (Statements (Node));
1232 when N_Entry_Call_Statement =>
1234 Sprint_Node_Sloc (Name (Node));
1235 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1238 when N_Entry_Declaration =>
1239 Write_Indent_Str_Sloc ("entry ");
1240 Write_Id (Defining_Identifier (Node));
1242 if Present (Discrete_Subtype_Definition (Node)) then
1243 Write_Str_With_Col_Check (" (");
1244 Sprint_Node (Discrete_Subtype_Definition (Node));
1248 Write_Param_Specs (Node);
1251 when N_Entry_Index_Specification =>
1252 Write_Str_With_Col_Check_Sloc ("for ");
1253 Write_Id (Defining_Identifier (Node));
1254 Write_Str_With_Col_Check (" in ");
1255 Sprint_Node (Discrete_Subtype_Definition (Node));
1257 when N_Enumeration_Representation_Clause =>
1258 Write_Indent_Str_Sloc ("for ");
1259 Write_Id (Identifier (Node));
1260 Write_Str_With_Col_Check (" use ");
1261 Sprint_Node (Array_Aggregate (Node));
1264 when N_Enumeration_Type_Definition =>
1267 -- Skip attempt to print Literals field if it's not there and
1268 -- we are in package Standard (case of Character, which is
1269 -- handled specially (without an explicit literals list).
1271 if Sloc (Node) > Standard_Location
1272 or else Present (Literals (Node))
1274 Sprint_Paren_Comma_List (Literals (Node));
1278 Write_Str_With_Col_Check_Sloc ("<error>");
1280 when N_Exception_Declaration =>
1281 if Write_Indent_Identifiers (Node) then
1282 Write_Str_With_Col_Check (" : ");
1283 Write_Str_Sloc ("exception;");
1286 when N_Exception_Handler =>
1287 Write_Indent_Str_Sloc ("when ");
1289 if Present (Choice_Parameter (Node)) then
1290 Sprint_Node (Choice_Parameter (Node));
1294 Sprint_Bar_List (Exception_Choices (Node));
1296 Sprint_Indented_List (Statements (Node));
1298 when N_Exception_Renaming_Declaration =>
1301 Sprint_Node (Defining_Identifier (Node));
1302 Write_Str_With_Col_Check (" : exception renames ");
1303 Sprint_Node (Name (Node));
1306 when N_Exit_Statement =>
1307 Write_Indent_Str_Sloc ("exit");
1308 Sprint_Opt_Node (Name (Node));
1310 if Present (Condition (Node)) then
1311 Write_Str_With_Col_Check (" when ");
1312 Sprint_Node (Condition (Node));
1317 when N_Expanded_Name =>
1318 Sprint_Node (Prefix (Node));
1319 Write_Char_Sloc ('.');
1320 Sprint_Node (Selector_Name (Node));
1322 when N_Explicit_Dereference =>
1323 Sprint_Node (Prefix (Node));
1324 Write_Char_Sloc ('.');
1325 Write_Str_Sloc ("all");
1327 when N_Extension_Aggregate =>
1328 Write_Str_With_Col_Check_Sloc ("(");
1329 Sprint_Node (Ancestor_Part (Node));
1330 Write_Str_With_Col_Check (" with ");
1332 if Null_Record_Present (Node) then
1333 Write_Str_With_Col_Check ("null record");
1335 if Present (Expressions (Node)) then
1336 Sprint_Comma_List (Expressions (Node));
1338 if Present (Component_Associations (Node)) then
1343 if Present (Component_Associations (Node)) then
1344 Sprint_Comma_List (Component_Associations (Node));
1350 when N_Floating_Point_Definition =>
1351 Write_Str_With_Col_Check_Sloc ("digits ");
1352 Sprint_Node (Digits_Expression (Node));
1353 Sprint_Opt_Node (Real_Range_Specification (Node));
1355 when N_Formal_Decimal_Fixed_Point_Definition =>
1356 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1358 when N_Formal_Derived_Type_Definition =>
1359 Write_Str_With_Col_Check_Sloc ("new ");
1360 Sprint_Node (Subtype_Mark (Node));
1362 if Private_Present (Node) then
1363 Write_Str_With_Col_Check (" with private");
1366 when N_Formal_Abstract_Subprogram_Declaration =>
1367 Write_Indent_Str_Sloc ("with ");
1368 Sprint_Node (Specification (Node));
1370 Write_Str_With_Col_Check (" is abstract");
1372 if Box_Present (Node) then
1373 Write_Str_With_Col_Check (" <>");
1374 elsif Present (Default_Name (Node)) then
1375 Write_Str_With_Col_Check (" ");
1376 Sprint_Node (Default_Name (Node));
1381 when N_Formal_Concrete_Subprogram_Declaration =>
1382 Write_Indent_Str_Sloc ("with ");
1383 Sprint_Node (Specification (Node));
1385 if Box_Present (Node) then
1386 Write_Str_With_Col_Check (" is <>");
1387 elsif Present (Default_Name (Node)) then
1388 Write_Str_With_Col_Check (" is ");
1389 Sprint_Node (Default_Name (Node));
1394 when N_Formal_Discrete_Type_Definition =>
1395 Write_Str_With_Col_Check_Sloc ("<>");
1397 when N_Formal_Floating_Point_Definition =>
1398 Write_Str_With_Col_Check_Sloc ("digits <>");
1400 when N_Formal_Modular_Type_Definition =>
1401 Write_Str_With_Col_Check_Sloc ("mod <>");
1403 when N_Formal_Object_Declaration =>
1406 if Write_Indent_Identifiers (Node) then
1409 if In_Present (Node) then
1410 Write_Str_With_Col_Check ("in ");
1413 if Out_Present (Node) then
1414 Write_Str_With_Col_Check ("out ");
1417 Sprint_Node (Subtype_Mark (Node));
1419 if Present (Expression (Node)) then
1421 Sprint_Node (Expression (Node));
1427 when N_Formal_Ordinary_Fixed_Point_Definition =>
1428 Write_Str_With_Col_Check_Sloc ("delta <>");
1430 when N_Formal_Package_Declaration =>
1431 Write_Indent_Str_Sloc ("with package ");
1432 Write_Id (Defining_Identifier (Node));
1433 Write_Str_With_Col_Check (" is new ");
1434 Sprint_Node (Name (Node));
1435 Write_Str_With_Col_Check (" (<>);");
1437 when N_Formal_Private_Type_Definition =>
1438 if Abstract_Present (Node) then
1439 Write_Str_With_Col_Check ("abstract ");
1442 if Tagged_Present (Node) then
1443 Write_Str_With_Col_Check ("tagged ");
1446 if Limited_Present (Node) then
1447 Write_Str_With_Col_Check ("limited ");
1450 Write_Str_With_Col_Check_Sloc ("private");
1452 when N_Formal_Signed_Integer_Type_Definition =>
1453 Write_Str_With_Col_Check_Sloc ("range <>");
1455 when N_Formal_Type_Declaration =>
1456 Write_Indent_Str_Sloc ("type ");
1457 Write_Id (Defining_Identifier (Node));
1459 if Present (Discriminant_Specifications (Node)) then
1460 Write_Discr_Specs (Node);
1461 elsif Unknown_Discriminants_Present (Node) then
1462 Write_Str_With_Col_Check ("(<>)");
1465 Write_Str_With_Col_Check (" is ");
1466 Sprint_Node (Formal_Type_Definition (Node));
1469 when N_Free_Statement =>
1470 Write_Indent_Str_Sloc ("free ");
1471 Sprint_Node (Expression (Node));
1474 when N_Freeze_Entity =>
1475 if Dump_Original_Only then
1478 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1480 Write_Rewrite_Str ("<<<");
1481 Write_Str_With_Col_Check_Sloc ("freeze ");
1482 Write_Id (Entity (Node));
1485 if No (Actions (Node)) then
1489 Freeze_Indent := Freeze_Indent + 1;
1490 Sprint_Indented_List (Actions (Node));
1491 Freeze_Indent := Freeze_Indent - 1;
1492 Write_Indent_Str ("]");
1495 Write_Rewrite_Str (">>>");
1498 when N_Full_Type_Declaration =>
1499 Write_Indent_Str_Sloc ("type ");
1500 Write_Id (Defining_Identifier (Node));
1501 Write_Discr_Specs (Node);
1502 Write_Str_With_Col_Check (" is ");
1503 Sprint_Node (Type_Definition (Node));
1506 when N_Function_Call =>
1508 Sprint_Node (Name (Node));
1509 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1511 when N_Function_Instantiation =>
1512 Write_Indent_Str_Sloc ("function ");
1513 Sprint_Node (Defining_Unit_Name (Node));
1514 Write_Str_With_Col_Check (" is new ");
1515 Sprint_Node (Name (Node));
1516 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1519 when N_Function_Specification =>
1520 Write_Str_With_Col_Check_Sloc ("function ");
1521 Sprint_Node (Defining_Unit_Name (Node));
1522 Write_Param_Specs (Node);
1523 Write_Str_With_Col_Check (" return ");
1524 Sprint_Node (Subtype_Mark (Node));
1526 when N_Generic_Association =>
1529 if Present (Selector_Name (Node)) then
1530 Sprint_Node (Selector_Name (Node));
1534 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1536 when N_Generic_Function_Renaming_Declaration =>
1537 Write_Indent_Str_Sloc ("generic function ");
1538 Sprint_Node (Defining_Unit_Name (Node));
1539 Write_Str_With_Col_Check (" renames ");
1540 Sprint_Node (Name (Node));
1543 when N_Generic_Package_Declaration =>
1545 Write_Indent_Str_Sloc ("generic ");
1546 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1548 Sprint_Node (Specification (Node));
1551 when N_Generic_Package_Renaming_Declaration =>
1552 Write_Indent_Str_Sloc ("generic package ");
1553 Sprint_Node (Defining_Unit_Name (Node));
1554 Write_Str_With_Col_Check (" renames ");
1555 Sprint_Node (Name (Node));
1558 when N_Generic_Procedure_Renaming_Declaration =>
1559 Write_Indent_Str_Sloc ("generic procedure ");
1560 Sprint_Node (Defining_Unit_Name (Node));
1561 Write_Str_With_Col_Check (" renames ");
1562 Sprint_Node (Name (Node));
1565 when N_Generic_Subprogram_Declaration =>
1567 Write_Indent_Str_Sloc ("generic ");
1568 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1570 Sprint_Node (Specification (Node));
1573 when N_Goto_Statement =>
1574 Write_Indent_Str_Sloc ("goto ");
1575 Sprint_Node (Name (Node));
1578 if Nkind (Next (Node)) = N_Label then
1582 when N_Handled_Sequence_Of_Statements =>
1584 Sprint_Indented_List (Statements (Node));
1586 if Present (Exception_Handlers (Node)) then
1587 Write_Indent_Str ("exception");
1589 Sprint_Node_List (Exception_Handlers (Node));
1593 if Present (At_End_Proc (Node)) then
1594 Write_Indent_Str ("at end");
1597 Sprint_Node (At_End_Proc (Node));
1602 when N_Identifier =>
1606 when N_If_Statement =>
1607 Write_Indent_Str_Sloc ("if ");
1608 Sprint_Node (Condition (Node));
1609 Write_Str_With_Col_Check (" then");
1610 Sprint_Indented_List (Then_Statements (Node));
1611 Sprint_Opt_Node_List (Elsif_Parts (Node));
1613 if Present (Else_Statements (Node)) then
1614 Write_Indent_Str ("else");
1615 Sprint_Indented_List (Else_Statements (Node));
1618 Write_Indent_Str ("end if;");
1620 when N_Implicit_Label_Declaration =>
1621 if not Dump_Original_Only then
1623 Write_Rewrite_Str ("<<<");
1625 Write_Id (Defining_Identifier (Node));
1627 Write_Str_With_Col_Check ("label");
1628 Write_Rewrite_Str (">>>");
1632 Sprint_Left_Opnd (Node);
1633 Write_Str_Sloc (" in ");
1634 Sprint_Right_Opnd (Node);
1636 when N_Incomplete_Type_Declaration =>
1637 Write_Indent_Str_Sloc ("type ");
1638 Write_Id (Defining_Identifier (Node));
1640 if Present (Discriminant_Specifications (Node)) then
1641 Write_Discr_Specs (Node);
1642 elsif Unknown_Discriminants_Present (Node) then
1643 Write_Str_With_Col_Check ("(<>)");
1648 when N_Index_Or_Discriminant_Constraint =>
1650 Sprint_Paren_Comma_List (Constraints (Node));
1652 when N_Indexed_Component =>
1653 Sprint_Node_Sloc (Prefix (Node));
1654 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1656 when N_Integer_Literal =>
1657 if Print_In_Hex (Node) then
1658 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1660 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1663 when N_Iteration_Scheme =>
1664 if Present (Condition (Node)) then
1665 Write_Str_With_Col_Check_Sloc ("while ");
1666 Sprint_Node (Condition (Node));
1668 Write_Str_With_Col_Check_Sloc ("for ");
1669 Sprint_Node (Loop_Parameter_Specification (Node));
1674 when N_Itype_Reference =>
1675 Write_Indent_Str_Sloc ("reference ");
1676 Write_Id (Itype (Node));
1679 Write_Indent_Str_Sloc ("<<");
1680 Write_Id (Identifier (Node));
1683 when N_Loop_Parameter_Specification =>
1685 Write_Id (Defining_Identifier (Node));
1686 Write_Str_With_Col_Check (" in ");
1688 if Reverse_Present (Node) then
1689 Write_Str_With_Col_Check ("reverse ");
1692 Sprint_Node (Discrete_Subtype_Definition (Node));
1694 when N_Loop_Statement =>
1697 if Present (Identifier (Node))
1698 and then (not Has_Created_Identifier (Node)
1699 or else not Dump_Original_Only)
1701 Write_Rewrite_Str ("<<<");
1702 Write_Id (Identifier (Node));
1704 Write_Rewrite_Str (">>>");
1705 Sprint_Node (Iteration_Scheme (Node));
1706 Write_Str_With_Col_Check_Sloc ("loop");
1707 Sprint_Indented_List (Statements (Node));
1708 Write_Indent_Str ("end loop ");
1709 Write_Rewrite_Str ("<<<");
1710 Write_Id (Identifier (Node));
1711 Write_Rewrite_Str (">>>");
1715 Sprint_Node (Iteration_Scheme (Node));
1716 Write_Str_With_Col_Check_Sloc ("loop");
1717 Sprint_Indented_List (Statements (Node));
1718 Write_Indent_Str ("end loop;");
1721 when N_Mod_Clause =>
1722 Sprint_Node_List (Pragmas_Before (Node));
1723 Write_Str_With_Col_Check_Sloc ("at mod ");
1724 Sprint_Node (Expression (Node));
1726 when N_Modular_Type_Definition =>
1727 Write_Str_With_Col_Check_Sloc ("mod ");
1728 Sprint_Node (Expression (Node));
1731 Sprint_Left_Opnd (Node);
1732 Write_Str_Sloc (" not in ");
1733 Sprint_Right_Opnd (Node);
1736 Write_Str_With_Col_Check_Sloc ("null");
1738 when N_Null_Statement =>
1739 if Comes_From_Source (Node)
1740 or else Dump_Freeze_Null
1741 or else not Is_List_Member (Node)
1742 or else (No (Prev (Node)) and then No (Next (Node)))
1744 Write_Indent_Str_Sloc ("null;");
1747 when N_Number_Declaration =>
1750 if Write_Indent_Identifiers (Node) then
1751 Write_Str_With_Col_Check (" : constant ");
1753 Sprint_Node (Expression (Node));
1757 when N_Object_Declaration =>
1760 if Write_Indent_Identifiers (Node) then
1763 if Aliased_Present (Node) then
1764 Write_Str_With_Col_Check ("aliased ");
1767 if Constant_Present (Node) then
1768 Write_Str_With_Col_Check ("constant ");
1771 -- Ada 2005 (AI-231)
1773 if Null_Exclusion_Present (Node) then
1774 Write_Str_With_Col_Check ("not null ");
1777 Sprint_Node (Object_Definition (Node));
1779 if Present (Expression (Node)) then
1781 Sprint_Node (Expression (Node));
1787 when N_Object_Renaming_Declaration =>
1790 Sprint_Node (Defining_Identifier (Node));
1793 -- Ada 2005 (AI-230): Access renamings
1795 if Present (Access_Definition (Node)) then
1796 Sprint_Node (Access_Definition (Node));
1798 elsif Present (Subtype_Mark (Node)) then
1799 Sprint_Node (Subtype_Mark (Node));
1802 Write_Str (" ??? ");
1805 Write_Str_With_Col_Check (" renames ");
1806 Sprint_Node (Name (Node));
1810 Write_Operator (Node, "abs ");
1811 Sprint_Right_Opnd (Node);
1814 Sprint_Left_Opnd (Node);
1815 Write_Operator (Node, " + ");
1816 Sprint_Right_Opnd (Node);
1819 Sprint_Left_Opnd (Node);
1820 Write_Operator (Node, " and ");
1821 Sprint_Right_Opnd (Node);
1824 Sprint_Left_Opnd (Node);
1825 Write_Operator (Node, " & ");
1826 Sprint_Right_Opnd (Node);
1829 Sprint_Left_Opnd (Node);
1831 Process_TFAI_RR_Flags (Node);
1832 Write_Operator (Node, "/ ");
1833 Sprint_Right_Opnd (Node);
1836 Sprint_Left_Opnd (Node);
1837 Write_Operator (Node, " = ");
1838 Sprint_Right_Opnd (Node);
1841 Sprint_Left_Opnd (Node);
1842 Write_Operator (Node, " ** ");
1843 Sprint_Right_Opnd (Node);
1846 Sprint_Left_Opnd (Node);
1847 Write_Operator (Node, " >= ");
1848 Sprint_Right_Opnd (Node);
1851 Sprint_Left_Opnd (Node);
1852 Write_Operator (Node, " > ");
1853 Sprint_Right_Opnd (Node);
1856 Sprint_Left_Opnd (Node);
1857 Write_Operator (Node, " <= ");
1858 Sprint_Right_Opnd (Node);
1861 Sprint_Left_Opnd (Node);
1862 Write_Operator (Node, " < ");
1863 Sprint_Right_Opnd (Node);
1866 Write_Operator (Node, "-");
1867 Sprint_Right_Opnd (Node);
1870 Sprint_Left_Opnd (Node);
1872 if Treat_Fixed_As_Integer (Node) then
1876 Write_Operator (Node, " mod ");
1877 Sprint_Right_Opnd (Node);
1879 when N_Op_Multiply =>
1880 Sprint_Left_Opnd (Node);
1882 Process_TFAI_RR_Flags (Node);
1883 Write_Operator (Node, "* ");
1884 Sprint_Right_Opnd (Node);
1887 Sprint_Left_Opnd (Node);
1888 Write_Operator (Node, " /= ");
1889 Sprint_Right_Opnd (Node);
1892 Write_Operator (Node, "not ");
1893 Sprint_Right_Opnd (Node);
1896 Sprint_Left_Opnd (Node);
1897 Write_Operator (Node, " or ");
1898 Sprint_Right_Opnd (Node);
1901 Write_Operator (Node, "+");
1902 Sprint_Right_Opnd (Node);
1905 Sprint_Left_Opnd (Node);
1907 if Treat_Fixed_As_Integer (Node) then
1911 Write_Operator (Node, " rem ");
1912 Sprint_Right_Opnd (Node);
1918 Write_Str_With_Col_Check ("(");
1919 Sprint_Node (Left_Opnd (Node));
1921 Sprint_Node (Right_Opnd (Node));
1924 when N_Op_Subtract =>
1925 Sprint_Left_Opnd (Node);
1926 Write_Operator (Node, " - ");
1927 Sprint_Right_Opnd (Node);
1930 Sprint_Left_Opnd (Node);
1931 Write_Operator (Node, " xor ");
1932 Sprint_Right_Opnd (Node);
1934 when N_Operator_Symbol =>
1935 Write_Name_With_Col_Check_Sloc (Chars (Node));
1937 when N_Ordinary_Fixed_Point_Definition =>
1938 Write_Str_With_Col_Check_Sloc ("delta ");
1939 Sprint_Node (Delta_Expression (Node));
1940 Sprint_Opt_Node (Real_Range_Specification (Node));
1943 Sprint_Left_Opnd (Node);
1944 Write_Str_Sloc (" or else ");
1945 Sprint_Right_Opnd (Node);
1947 when N_Others_Choice =>
1948 if All_Others (Node) then
1949 Write_Str_With_Col_Check ("all ");
1952 Write_Str_With_Col_Check_Sloc ("others");
1954 when N_Package_Body =>
1956 Write_Indent_Str_Sloc ("package body ");
1957 Sprint_Node (Defining_Unit_Name (Node));
1959 Sprint_Indented_List (Declarations (Node));
1961 if Present (Handled_Statement_Sequence (Node)) then
1962 Write_Indent_Str ("begin");
1963 Sprint_Node (Handled_Statement_Sequence (Node));
1966 Write_Indent_Str ("end ");
1967 Sprint_Node (Defining_Unit_Name (Node));
1970 when N_Package_Body_Stub =>
1971 Write_Indent_Str_Sloc ("package body ");
1972 Sprint_Node (Defining_Identifier (Node));
1973 Write_Str_With_Col_Check (" is separate;");
1975 when N_Package_Declaration =>
1978 Sprint_Node_Sloc (Specification (Node));
1981 when N_Package_Instantiation =>
1983 Write_Indent_Str_Sloc ("package ");
1984 Sprint_Node (Defining_Unit_Name (Node));
1985 Write_Str (" is new ");
1986 Sprint_Node (Name (Node));
1987 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1990 when N_Package_Renaming_Declaration =>
1991 Write_Indent_Str_Sloc ("package ");
1992 Sprint_Node (Defining_Unit_Name (Node));
1993 Write_Str_With_Col_Check (" renames ");
1994 Sprint_Node (Name (Node));
1997 when N_Package_Specification =>
1998 Write_Str_With_Col_Check_Sloc ("package ");
1999 Sprint_Node (Defining_Unit_Name (Node));
2001 Sprint_Indented_List (Visible_Declarations (Node));
2003 if Present (Private_Declarations (Node)) then
2004 Write_Indent_Str ("private");
2005 Sprint_Indented_List (Private_Declarations (Node));
2008 Write_Indent_Str ("end ");
2009 Sprint_Node (Defining_Unit_Name (Node));
2011 when N_Parameter_Association =>
2012 Sprint_Node_Sloc (Selector_Name (Node));
2014 Sprint_Node (Explicit_Actual_Parameter (Node));
2016 when N_Parameter_Specification =>
2019 if Write_Identifiers (Node) then
2022 if In_Present (Node) then
2023 Write_Str_With_Col_Check ("in ");
2026 if Out_Present (Node) then
2027 Write_Str_With_Col_Check ("out ");
2030 -- Ada 2005 (AI-231)
2032 if Null_Exclusion_Present (Node) then
2033 Write_Str ("not null ");
2036 Sprint_Node (Parameter_Type (Node));
2038 if Present (Expression (Node)) then
2040 Sprint_Node (Expression (Node));
2047 Write_Indent_Str_Sloc ("pragma ");
2048 Write_Name_With_Col_Check (Chars (Node));
2050 if Present (Pragma_Argument_Associations (Node)) then
2051 Sprint_Opt_Paren_Comma_List
2052 (Pragma_Argument_Associations (Node));
2057 when N_Pragma_Argument_Association =>
2060 if Chars (Node) /= No_Name then
2061 Write_Name_With_Col_Check (Chars (Node));
2065 Sprint_Node (Expression (Node));
2067 when N_Private_Type_Declaration =>
2068 Write_Indent_Str_Sloc ("type ");
2069 Write_Id (Defining_Identifier (Node));
2071 if Present (Discriminant_Specifications (Node)) then
2072 Write_Discr_Specs (Node);
2073 elsif Unknown_Discriminants_Present (Node) then
2074 Write_Str_With_Col_Check ("(<>)");
2079 if Tagged_Present (Node) then
2080 Write_Str_With_Col_Check ("tagged ");
2083 if Limited_Present (Node) then
2084 Write_Str_With_Col_Check ("limited ");
2087 Write_Str_With_Col_Check ("private;");
2089 when N_Private_Extension_Declaration =>
2090 Write_Indent_Str_Sloc ("type ");
2091 Write_Id (Defining_Identifier (Node));
2093 if Present (Discriminant_Specifications (Node)) then
2094 Write_Discr_Specs (Node);
2095 elsif Unknown_Discriminants_Present (Node) then
2096 Write_Str_With_Col_Check ("(<>)");
2099 Write_Str_With_Col_Check (" is new ");
2100 Sprint_Node (Subtype_Indication (Node));
2101 Write_Str_With_Col_Check (" with private;");
2103 when N_Procedure_Call_Statement =>
2106 Sprint_Node (Name (Node));
2107 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2110 when N_Procedure_Instantiation =>
2111 Write_Indent_Str_Sloc ("procedure ");
2112 Sprint_Node (Defining_Unit_Name (Node));
2113 Write_Str_With_Col_Check (" is new ");
2114 Sprint_Node (Name (Node));
2115 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2118 when N_Procedure_Specification =>
2119 Write_Str_With_Col_Check_Sloc ("procedure ");
2120 Sprint_Node (Defining_Unit_Name (Node));
2121 Write_Param_Specs (Node);
2123 when N_Protected_Body =>
2124 Write_Indent_Str_Sloc ("protected body ");
2125 Write_Id (Defining_Identifier (Node));
2127 Sprint_Indented_List (Declarations (Node));
2128 Write_Indent_Str ("end ");
2129 Write_Id (Defining_Identifier (Node));
2132 when N_Protected_Body_Stub =>
2133 Write_Indent_Str_Sloc ("protected body ");
2134 Write_Id (Defining_Identifier (Node));
2135 Write_Str_With_Col_Check (" is separate;");
2137 when N_Protected_Definition =>
2139 Sprint_Indented_List (Visible_Declarations (Node));
2141 if Present (Private_Declarations (Node)) then
2142 Write_Indent_Str ("private");
2143 Sprint_Indented_List (Private_Declarations (Node));
2146 Write_Indent_Str ("end ");
2148 when N_Protected_Type_Declaration =>
2149 Write_Indent_Str_Sloc ("protected type ");
2150 Write_Id (Defining_Identifier (Node));
2151 Write_Discr_Specs (Node);
2153 Sprint_Node (Protected_Definition (Node));
2154 Write_Id (Defining_Identifier (Node));
2157 when N_Qualified_Expression =>
2158 Sprint_Node (Subtype_Mark (Node));
2159 Write_Char_Sloc (''');
2161 -- Print expression, make sure we have at least one level of
2162 -- parentheses around the expression. For cases of qualified
2163 -- expressions in the source, this is always the case, but
2164 -- for generated qualifications, there may be no explicit
2165 -- parentheses present.
2167 if Paren_Count (Expression (Node)) /= 0 then
2168 Sprint_Node (Expression (Node));
2171 Sprint_Node (Expression (Node));
2175 when N_Raise_Constraint_Error =>
2177 -- This node can be used either as a subexpression or as a
2178 -- statement form. The following test is a reasonably reliable
2179 -- way to distinguish the two cases.
2181 if Is_List_Member (Node)
2182 and then Nkind (Parent (Node)) not in N_Subexpr
2187 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2188 Write_Condition_And_Reason (Node);
2190 when N_Raise_Program_Error =>
2192 -- This node can be used either as a subexpression or as a
2193 -- statement form. The following test is a reasonably reliable
2194 -- way to distinguish the two cases.
2196 if Is_List_Member (Node)
2197 and then Nkind (Parent (Node)) not in N_Subexpr
2202 Write_Str_With_Col_Check_Sloc ("[program_error");
2203 Write_Condition_And_Reason (Node);
2205 when N_Raise_Storage_Error =>
2207 -- This node can be used either as a subexpression or as a
2208 -- statement form. The following test is a reasonably reliable
2209 -- way to distinguish the two cases.
2211 if Is_List_Member (Node)
2212 and then Nkind (Parent (Node)) not in N_Subexpr
2217 Write_Str_With_Col_Check_Sloc ("[storage_error");
2218 Write_Condition_And_Reason (Node);
2220 when N_Raise_Statement =>
2221 Write_Indent_Str_Sloc ("raise ");
2222 Sprint_Node (Name (Node));
2226 Sprint_Node (Low_Bound (Node));
2227 Write_Str_Sloc (" .. ");
2228 Sprint_Node (High_Bound (Node));
2230 when N_Range_Constraint =>
2231 Write_Str_With_Col_Check_Sloc ("range ");
2232 Sprint_Node (Range_Expression (Node));
2234 when N_Real_Literal =>
2235 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2237 when N_Real_Range_Specification =>
2238 Write_Str_With_Col_Check_Sloc ("range ");
2239 Sprint_Node (Low_Bound (Node));
2241 Sprint_Node (High_Bound (Node));
2243 when N_Record_Definition =>
2244 if Abstract_Present (Node) then
2245 Write_Str_With_Col_Check ("abstract ");
2248 if Tagged_Present (Node) then
2249 Write_Str_With_Col_Check ("tagged ");
2252 if Limited_Present (Node) then
2253 Write_Str_With_Col_Check ("limited ");
2256 if Null_Present (Node) then
2257 Write_Str_With_Col_Check_Sloc ("null record");
2260 Write_Str_With_Col_Check_Sloc ("record");
2261 Sprint_Node (Component_List (Node));
2262 Write_Indent_Str ("end record");
2265 when N_Record_Representation_Clause =>
2266 Write_Indent_Str_Sloc ("for ");
2267 Sprint_Node (Identifier (Node));
2268 Write_Str_With_Col_Check (" use record ");
2270 if Present (Mod_Clause (Node)) then
2271 Sprint_Node (Mod_Clause (Node));
2274 Sprint_Indented_List (Component_Clauses (Node));
2275 Write_Indent_Str ("end record;");
2278 Sprint_Node (Prefix (Node));
2279 Write_Str_With_Col_Check_Sloc ("'reference");
2281 when N_Requeue_Statement =>
2282 Write_Indent_Str_Sloc ("requeue ");
2283 Sprint_Node (Name (Node));
2285 if Abort_Present (Node) then
2286 Write_Str_With_Col_Check (" with abort");
2291 when N_Return_Statement =>
2292 if Present (Expression (Node)) then
2293 Write_Indent_Str_Sloc ("return ");
2294 Sprint_Node (Expression (Node));
2297 Write_Indent_Str_Sloc ("return;");
2300 when N_Selective_Accept =>
2301 Write_Indent_Str_Sloc ("select");
2307 Alt_Node := First (Select_Alternatives (Node));
2310 Sprint_Node (Alt_Node);
2313 exit when No (Alt_Node);
2314 Write_Indent_Str ("or");
2318 if Present (Else_Statements (Node)) then
2319 Write_Indent_Str ("else");
2320 Sprint_Indented_List (Else_Statements (Node));
2323 Write_Indent_Str ("end select;");
2325 when N_Signed_Integer_Type_Definition =>
2326 Write_Str_With_Col_Check_Sloc ("range ");
2327 Sprint_Node (Low_Bound (Node));
2329 Sprint_Node (High_Bound (Node));
2331 when N_Single_Protected_Declaration =>
2332 Write_Indent_Str_Sloc ("protected ");
2333 Write_Id (Defining_Identifier (Node));
2335 Sprint_Node (Protected_Definition (Node));
2336 Write_Id (Defining_Identifier (Node));
2339 when N_Single_Task_Declaration =>
2340 Write_Indent_Str_Sloc ("task ");
2341 Write_Id (Defining_Identifier (Node));
2343 if Present (Task_Definition (Node)) then
2345 Sprint_Node (Task_Definition (Node));
2346 Write_Id (Defining_Identifier (Node));
2351 when N_Selected_Component =>
2352 Sprint_Node (Prefix (Node));
2353 Write_Char_Sloc ('.');
2354 Sprint_Node (Selector_Name (Node));
2358 Sprint_Node (Prefix (Node));
2359 Write_Str_With_Col_Check (" (");
2360 Sprint_Node (Discrete_Range (Node));
2363 when N_String_Literal =>
2364 if String_Length (Strval (Node)) + Column > 75 then
2365 Write_Indent_Str (" ");
2369 Write_String_Table_Entry (Strval (Node));
2371 when N_Subprogram_Body =>
2372 if Freeze_Indent = 0 then
2377 Sprint_Node_Sloc (Specification (Node));
2380 Sprint_Indented_List (Declarations (Node));
2381 Write_Indent_Str ("begin");
2382 Sprint_Node (Handled_Statement_Sequence (Node));
2384 Write_Indent_Str ("end ");
2385 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2388 if Is_List_Member (Node)
2389 and then Present (Next (Node))
2390 and then Nkind (Next (Node)) /= N_Subprogram_Body
2395 when N_Subprogram_Body_Stub =>
2397 Sprint_Node_Sloc (Specification (Node));
2398 Write_Str_With_Col_Check (" is separate;");
2400 when N_Subprogram_Declaration =>
2402 Sprint_Node_Sloc (Specification (Node));
2405 when N_Subprogram_Info =>
2406 Sprint_Node (Identifier (Node));
2407 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2409 when N_Subprogram_Renaming_Declaration =>
2411 Sprint_Node (Specification (Node));
2412 Write_Str_With_Col_Check_Sloc (" renames ");
2413 Sprint_Node (Name (Node));
2416 when N_Subtype_Declaration =>
2417 Write_Indent_Str_Sloc ("subtype ");
2418 Write_Id (Defining_Identifier (Node));
2421 -- Ada 2005 (AI-231)
2423 if Null_Exclusion_Present (Node) then
2424 Write_Str ("not null ");
2427 Sprint_Node (Subtype_Indication (Node));
2430 when N_Subtype_Indication =>
2431 Sprint_Node_Sloc (Subtype_Mark (Node));
2433 Sprint_Node (Constraint (Node));
2436 Write_Indent_Str_Sloc ("separate (");
2437 Sprint_Node (Name (Node));
2440 Sprint_Node (Proper_Body (Node));
2443 Write_Indent_Str_Sloc ("task body ");
2444 Write_Id (Defining_Identifier (Node));
2446 Sprint_Indented_List (Declarations (Node));
2447 Write_Indent_Str ("begin");
2448 Sprint_Node (Handled_Statement_Sequence (Node));
2449 Write_Indent_Str ("end ");
2450 Write_Id (Defining_Identifier (Node));
2453 when N_Task_Body_Stub =>
2454 Write_Indent_Str_Sloc ("task body ");
2455 Write_Id (Defining_Identifier (Node));
2456 Write_Str_With_Col_Check (" is separate;");
2458 when N_Task_Definition =>
2460 Sprint_Indented_List (Visible_Declarations (Node));
2462 if Present (Private_Declarations (Node)) then
2463 Write_Indent_Str ("private");
2464 Sprint_Indented_List (Private_Declarations (Node));
2467 Write_Indent_Str ("end ");
2469 when N_Task_Type_Declaration =>
2470 Write_Indent_Str_Sloc ("task type ");
2471 Write_Id (Defining_Identifier (Node));
2472 Write_Discr_Specs (Node);
2474 if Present (Task_Definition (Node)) then
2476 Sprint_Node (Task_Definition (Node));
2477 Write_Id (Defining_Identifier (Node));
2482 when N_Terminate_Alternative =>
2483 Sprint_Node_List (Pragmas_Before (Node));
2487 if Present (Condition (Node)) then
2488 Write_Str_With_Col_Check ("when ");
2489 Sprint_Node (Condition (Node));
2493 Write_Str_With_Col_Check_Sloc ("terminate;");
2494 Sprint_Node_List (Pragmas_After (Node));
2496 when N_Timed_Entry_Call =>
2497 Write_Indent_Str_Sloc ("select");
2499 Sprint_Node (Entry_Call_Alternative (Node));
2501 Write_Indent_Str ("or");
2503 Sprint_Node (Delay_Alternative (Node));
2505 Write_Indent_Str ("end select;");
2507 when N_Triggering_Alternative =>
2508 Sprint_Node_List (Pragmas_Before (Node));
2509 Sprint_Node_Sloc (Triggering_Statement (Node));
2510 Sprint_Node_List (Statements (Node));
2512 when N_Type_Conversion =>
2514 Sprint_Node (Subtype_Mark (Node));
2517 if Conversion_OK (Node) then
2521 if Float_Truncate (Node) then
2525 if Rounded_Result (Node) then
2530 Sprint_Node (Expression (Node));
2533 when N_Unchecked_Expression =>
2536 Sprint_Node_Sloc (Expression (Node));
2539 when N_Unchecked_Type_Conversion =>
2540 Sprint_Node (Subtype_Mark (Node));
2542 Write_Str_With_Col_Check ("(");
2543 Sprint_Node_Sloc (Expression (Node));
2546 when N_Unconstrained_Array_Definition =>
2547 Write_Str_With_Col_Check_Sloc ("array (");
2553 Node1 := First (Subtype_Marks (Node));
2555 Sprint_Node (Node1);
2556 Write_Str_With_Col_Check (" range <>");
2558 exit when Node1 = Empty;
2563 Write_Str (") of ");
2564 Sprint_Node (Component_Definition (Node));
2566 when N_Unused_At_Start | N_Unused_At_End =>
2567 Write_Indent_Str ("***** Error, unused node encountered *****");
2570 when N_Use_Package_Clause =>
2571 Write_Indent_Str_Sloc ("use ");
2572 Sprint_Comma_List (Names (Node));
2575 when N_Use_Type_Clause =>
2576 Write_Indent_Str_Sloc ("use type ");
2577 Sprint_Comma_List (Subtype_Marks (Node));
2580 when N_Validate_Unchecked_Conversion =>
2581 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2582 Sprint_Node (Source_Type (Node));
2584 Sprint_Node (Target_Type (Node));
2588 Write_Indent_Str_Sloc ("when ");
2589 Sprint_Bar_List (Discrete_Choices (Node));
2591 Sprint_Node (Component_List (Node));
2593 when N_Variant_Part =>
2595 Write_Indent_Str_Sloc ("case ");
2596 Sprint_Node (Name (Node));
2598 Sprint_Indented_List (Variants (Node));
2599 Write_Indent_Str ("end case");
2602 when N_With_Clause =>
2604 -- Special test, if we are dumping the original tree only,
2605 -- then we want to eliminate the bogus with clauses that
2606 -- correspond to the non-existent children of Text_IO.
2608 if Dump_Original_Only
2609 and then Is_Text_IO_Kludge_Unit (Name (Node))
2613 -- Normal case, output the with clause
2616 if First_Name (Node) or else not Dump_Original_Only then
2618 -- Ada 2005 (AI-50217): Print limited with_clauses
2620 if Private_Present (Node) and Limited_Present (Node) then
2621 Write_Indent_Str ("limited private with ");
2623 elsif Private_Present (Node) then
2624 Write_Indent_Str ("private with ");
2626 elsif Limited_Present (Node) then
2627 Write_Indent_Str ("limited with ");
2630 Write_Indent_Str ("with ");
2637 Sprint_Node_Sloc (Name (Node));
2639 if Last_Name (Node) or else not Dump_Original_Only then
2644 when N_With_Type_Clause =>
2645 Write_Indent_Str ("with type ");
2646 Sprint_Node_Sloc (Name (Node));
2648 if Tagged_Present (Node) then
2649 Write_Str (" is tagged;");
2651 Write_Str (" is access;");
2656 if Nkind (Node) in N_Subexpr
2657 and then Do_Range_Check (Node)
2662 for J in 1 .. Paren_Count (Node) loop
2666 pragma Assert (No (Debug_Node));
2667 Debug_Node := Save_Debug_Node;
2668 end Sprint_Node_Actual;
2670 ----------------------
2671 -- Sprint_Node_List --
2672 ----------------------
2674 procedure Sprint_Node_List (List : List_Id) is
2678 if Is_Non_Empty_List (List) then
2679 Node := First (List);
2684 exit when Node = Empty;
2687 end Sprint_Node_List;
2689 ----------------------
2690 -- Sprint_Node_Sloc --
2691 ----------------------
2693 procedure Sprint_Node_Sloc (Node : Node_Id) is
2697 if Present (Debug_Node) then
2698 Set_Sloc (Debug_Node, Sloc (Node));
2699 Debug_Node := Empty;
2701 end Sprint_Node_Sloc;
2703 ---------------------
2704 -- Sprint_Opt_Node --
2705 ---------------------
2707 procedure Sprint_Opt_Node (Node : Node_Id) is
2709 if Present (Node) then
2713 end Sprint_Opt_Node;
2715 --------------------------
2716 -- Sprint_Opt_Node_List --
2717 --------------------------
2719 procedure Sprint_Opt_Node_List (List : List_Id) is
2721 if Present (List) then
2722 Sprint_Node_List (List);
2724 end Sprint_Opt_Node_List;
2726 ---------------------------------
2727 -- Sprint_Opt_Paren_Comma_List --
2728 ---------------------------------
2730 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2732 if Is_Non_Empty_List (List) then
2734 Sprint_Paren_Comma_List (List);
2736 end Sprint_Opt_Paren_Comma_List;
2738 -----------------------------
2739 -- Sprint_Paren_Comma_List --
2740 -----------------------------
2742 procedure Sprint_Paren_Comma_List (List : List_Id) is
2744 Node_Exists : Boolean := False;
2748 if Is_Non_Empty_List (List) then
2750 if Dump_Original_Only then
2753 while Present (N) loop
2755 if not Is_Rewrite_Insertion (N) then
2756 Node_Exists := True;
2763 if not Node_Exists then
2768 Write_Str_With_Col_Check ("(");
2769 Sprint_Comma_List (List);
2772 end Sprint_Paren_Comma_List;
2774 ----------------------
2775 -- Sprint_Right_Opnd --
2776 ----------------------
2778 procedure Sprint_Right_Opnd (N : Node_Id) is
2779 Opnd : constant Node_Id := Right_Opnd (N);
2782 if Paren_Count (Opnd) /= 0
2783 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2792 end Sprint_Right_Opnd;
2794 ---------------------
2795 -- Write_Char_Sloc --
2796 ---------------------
2798 procedure Write_Char_Sloc (C : Character) is
2800 if Debug_Generated_Code and then C /= ' ' then
2805 end Write_Char_Sloc;
2807 --------------------------------
2808 -- Write_Condition_And_Reason --
2809 --------------------------------
2811 procedure Write_Condition_And_Reason (Node : Node_Id) is
2812 Image : constant String := RT_Exception_Code'Image
2813 (RT_Exception_Code'Val
2814 (UI_To_Int (Reason (Node))));
2817 if Present (Condition (Node)) then
2818 Write_Str_With_Col_Check (" when ");
2819 Sprint_Node (Condition (Node));
2824 for J in 4 .. Image'Last loop
2825 if Image (J) = '_' then
2828 Write_Char (Fold_Lower (Image (J)));
2833 end Write_Condition_And_Reason;
2835 -----------------------
2836 -- Write_Discr_Specs --
2837 -----------------------
2839 procedure Write_Discr_Specs (N : Node_Id) is
2844 Specs := Discriminant_Specifications (N);
2846 if Present (Specs) then
2847 Write_Str_With_Col_Check (" (");
2848 Spec := First (Specs);
2853 exit when Spec = Empty;
2855 -- Add semicolon, unless we are printing original tree and the
2856 -- next specification is part of a list (but not the first
2857 -- element of that list)
2859 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2866 end Write_Discr_Specs;
2872 procedure Write_Ekind (E : Entity_Id) is
2873 S : constant String := Entity_Kind'Image (Ekind (E));
2876 Name_Len := S'Length;
2877 Name_Buffer (1 .. Name_Len) := S;
2878 Set_Casing (Mixed_Case);
2879 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2886 procedure Write_Id (N : Node_Id) is
2888 -- Case of a defining identifier
2890 if Nkind (N) = N_Defining_Identifier then
2892 -- If defining identifier has an interface name (and no
2893 -- address clause), then we output the interface name.
2895 if (Is_Imported (N) or else Is_Exported (N))
2896 and then Present (Interface_Name (N))
2897 and then No (Address_Clause (N))
2899 String_To_Name_Buffer (Strval (Interface_Name (N)));
2900 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2902 -- If no interface name (or inactive because there was
2903 -- an address clause), then just output the Chars name.
2906 Write_Name_With_Col_Check (Chars (N));
2909 -- Case of selector of an expanded name where the expanded name
2910 -- has an associated entity, output this entity.
2912 elsif Nkind (Parent (N)) = N_Expanded_Name
2913 and then Selector_Name (Parent (N)) = N
2914 and then Present (Entity (Parent (N)))
2916 Write_Id (Entity (Parent (N)));
2918 -- For any other node with an associated entity, output it
2920 elsif Nkind (N) in N_Has_Entity
2921 and then Present (Entity_Or_Associated_Node (N))
2922 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2924 Write_Id (Entity (N));
2926 -- All other cases, we just print the Chars field
2929 Write_Name_With_Col_Check (Chars (N));
2933 -----------------------
2934 -- Write_Identifiers --
2935 -----------------------
2937 function Write_Identifiers (Node : Node_Id) return Boolean is
2939 Sprint_Node (Defining_Identifier (Node));
2941 -- The remainder of the declaration must be printed unless we are
2942 -- printing the original tree and this is not the last identifier
2945 not Dump_Original_Only or else not More_Ids (Node);
2947 end Write_Identifiers;
2949 ------------------------
2950 -- Write_Implicit_Def --
2951 ------------------------
2953 procedure Write_Implicit_Def (E : Entity_Id) is
2958 when E_Array_Subtype =>
2959 Write_Str_With_Col_Check ("subtype ");
2961 Write_Str_With_Col_Check (" is ");
2962 Write_Id (Base_Type (E));
2963 Write_Str_With_Col_Check (" (");
2965 Ind := First_Index (E);
2967 while Present (Ind) loop
2971 if Present (Ind) then
2978 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2979 Write_Str_With_Col_Check ("subtype ");
2982 Write_Id (Etype (E));
2983 Write_Str_With_Col_Check (" range ");
2984 Sprint_Node (Scalar_Range (E));
2988 Write_Str_With_Col_Check ("type ");
2990 Write_Str_With_Col_Check (" is <");
2995 end Write_Implicit_Def;
3001 procedure Write_Indent is
3003 if Indent_Annull_Flag then
3004 Indent_Annull_Flag := False;
3008 for J in 1 .. Indent loop
3014 ------------------------------
3015 -- Write_Indent_Identifiers --
3016 ------------------------------
3018 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3020 -- We need to start a new line for every node, except in the case
3021 -- where we are printing the original tree and this is not the first
3022 -- defining identifier in the list.
3024 if not Dump_Original_Only or else not Prev_Ids (Node) then
3027 -- If printing original tree and this is not the first defining
3028 -- identifier in the list, then the previous call to this procedure
3029 -- printed only the name, and we add a comma to separate the names.
3035 Sprint_Node (Defining_Identifier (Node));
3037 -- The remainder of the declaration must be printed unless we are
3038 -- printing the original tree and this is not the last identifier
3041 not Dump_Original_Only or else not More_Ids (Node);
3043 end Write_Indent_Identifiers;
3045 -----------------------------------
3046 -- Write_Indent_Identifiers_Sloc --
3047 -----------------------------------
3049 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3051 -- We need to start a new line for every node, except in the case
3052 -- where we are printing the original tree and this is not the first
3053 -- defining identifier in the list.
3055 if not Dump_Original_Only or else not Prev_Ids (Node) then
3058 -- If printing original tree and this is not the first defining
3059 -- identifier in the list, then the previous call to this procedure
3060 -- printed only the name, and we add a comma to separate the names.
3067 Sprint_Node (Defining_Identifier (Node));
3069 -- The remainder of the declaration must be printed unless we are
3070 -- printing the original tree and this is not the last identifier
3073 not Dump_Original_Only or else not More_Ids (Node);
3075 end Write_Indent_Identifiers_Sloc;
3077 ----------------------
3078 -- Write_Indent_Str --
3079 ----------------------
3081 procedure Write_Indent_Str (S : String) is
3085 end Write_Indent_Str;
3087 ---------------------------
3088 -- Write_Indent_Str_Sloc --
3089 ---------------------------
3091 procedure Write_Indent_Str_Sloc (S : String) is
3095 end Write_Indent_Str_Sloc;
3097 -------------------------------
3098 -- Write_Name_With_Col_Check --
3099 -------------------------------
3101 procedure Write_Name_With_Col_Check (N : Name_Id) is
3105 Get_Name_String (N);
3107 -- Deal with -gnatI which replaces digits in an internal
3108 -- name by three dots (e.g. R7b becomes R...b).
3110 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3113 while J < Name_Len loop
3114 exit when Name_Buffer (J) not in 'A' .. 'Z';
3118 if Name_Buffer (J) in '0' .. '9' then
3119 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3122 while J <= Name_Len loop
3123 if Name_Buffer (J) not in '0' .. '9' then
3124 Write_Str (Name_Buffer (J .. Name_Len));
3136 -- Fall through for normal case
3138 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3139 end Write_Name_With_Col_Check;
3141 ------------------------------------
3142 -- Write_Name_With_Col_Check_Sloc --
3143 ------------------------------------
3145 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3147 Get_Name_String (N);
3148 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3149 end Write_Name_With_Col_Check_Sloc;
3151 --------------------
3152 -- Write_Operator --
3153 --------------------
3155 procedure Write_Operator (N : Node_Id; S : String) is
3156 F : Natural := S'First;
3157 T : Natural := S'Last;
3160 -- If no overflow check, just write string out, and we are done
3162 if not Do_Overflow_Check (N) then
3165 -- If overflow check, we want to surround the operator with curly
3166 -- brackets, but not include spaces within the brackets.
3179 Write_Str_Sloc (S (F .. T));
3182 if S (S'Last) = ' ' then
3188 -----------------------
3189 -- Write_Param_Specs --
3190 -----------------------
3192 procedure Write_Param_Specs (N : Node_Id) is
3198 Specs := Parameter_Specifications (N);
3200 if Is_Non_Empty_List (Specs) then
3201 Write_Str_With_Col_Check (" (");
3202 Spec := First (Specs);
3206 Formal := Defining_Identifier (Spec);
3208 exit when Spec = Empty;
3210 -- Add semicolon, unless we are printing original tree and the
3211 -- next specification is part of a list (but not the first
3212 -- element of that list)
3214 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3219 -- Write out any extra formals
3221 while Present (Extra_Formal (Formal)) loop
3222 Formal := Extra_Formal (Formal);
3224 Write_Name_With_Col_Check (Chars (Formal));
3226 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3231 end Write_Param_Specs;
3233 --------------------------
3234 -- Write_Rewrite_Str --
3235 --------------------------
3237 procedure Write_Rewrite_Str (S : String) is
3239 if not Dump_Generated_Only then
3240 if S'Length = 3 and then S = ">>>" then
3243 Write_Str_With_Col_Check (S);
3246 end Write_Rewrite_Str;
3248 --------------------
3249 -- Write_Str_Sloc --
3250 --------------------
3252 procedure Write_Str_Sloc (S : String) is
3254 for J in S'Range loop
3255 Write_Char_Sloc (S (J));
3259 ------------------------------
3260 -- Write_Str_With_Col_Check --
3261 ------------------------------
3263 procedure Write_Str_With_Col_Check (S : String) is
3265 if Int (S'Last) + Column > Line_Limit then
3266 Write_Indent_Str (" ");
3269 Write_Str (S (2 .. S'Length));
3277 end Write_Str_With_Col_Check;
3279 -----------------------------------
3280 -- Write_Str_With_Col_Check_Sloc --
3281 -----------------------------------
3283 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3285 if Int (S'Last) + Column > Line_Limit then
3286 Write_Indent_Str (" ");
3289 Write_Str_Sloc (S (2 .. S'Length));
3297 end Write_Str_With_Col_Check_Sloc;
3299 ------------------------------------
3300 -- Write_Uint_With_Col_Check_Sloc --
3301 ------------------------------------
3303 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3305 Col_Check (UI_Decimal_Digits_Hi (U));
3307 UI_Write (U, Format);
3308 end Write_Uint_With_Col_Check_Sloc;
3310 -------------------------------------
3311 -- Write_Ureal_With_Col_Check_Sloc --
3312 -------------------------------------
3314 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3315 D : constant Uint := Denominator (U);
3316 N : constant Uint := Numerator (U);
3320 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3323 end Write_Ureal_With_Col_Check_Sloc;