1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Atree; use Atree;
28 with Casing; use Casing;
29 with Csets; use Csets;
30 with Debug; use Debug;
31 with Einfo; use Einfo;
33 with Namet; use Namet;
34 with Nlists; use Nlists;
36 with Output; use Output;
37 with Rtsfind; use Rtsfind;
38 with Sinfo; use Sinfo;
39 with Sinput; use Sinput;
40 with Sinput.D; use Sinput.D;
41 with Snames; use Snames;
42 with Stand; use Stand;
43 with Stringt; use Stringt;
44 with Uintp; use Uintp;
45 with Uname; use Uname;
46 with Urealp; use Urealp;
48 package body Sprint is
50 Debug_Node : Node_Id := Empty;
51 -- If we are in Debug_Generated_Code mode, then this location is set
52 -- to the current node requiring Sloc fixup, until Set_Debug_Sloc is
53 -- called to set the proper value. The call clears it back to Empty.
55 Debug_Sloc : Source_Ptr;
56 -- Sloc of first byte of line currently being written if we are
57 -- generating a source debug file.
59 Dump_Original_Only : Boolean;
60 -- Set True if the -gnatdo (dump original tree) flag is set
62 Dump_Generated_Only : Boolean;
63 -- Set True if the -gnatG (dump generated tree) debug flag is set
64 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
66 Dump_Freeze_Null : Boolean;
67 -- Set True if freeze nodes and non-source null statements output
70 -- Number of columns for current line output indentation
72 Indent_Annull_Flag : Boolean := False;
73 -- Set True if subsequent Write_Indent call to be ignored, gets reset
74 -- by this call, so it is only active to suppress a single indent call.
76 Line_Limit : constant := 72;
77 -- Limit value for chopping long lines
79 Freeze_Indent : Int := 0;
80 -- Keep track of freeze indent level (controls blank lines before
81 -- procedures within expression freeze actions)
83 -------------------------------
84 -- Operator Precedence Table --
85 -------------------------------
87 -- This table is used to decide whether a subexpression needs to be
88 -- parenthesized. The rule is that if an operand of an operator (which
89 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
90 -- with a lower precedence than the operator (or equal precedence if
91 -- appearing as the right operand), then parentheses are required.
93 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
126 procedure Sprint_Left_Opnd (N : Node_Id);
127 -- Print left operand of operator, parenthesizing if necessary
129 procedure Sprint_Right_Opnd (N : Node_Id);
130 -- Print right operand of operator, parenthesizing if necessary
132 -----------------------
133 -- Local Subprograms --
134 -----------------------
136 procedure Col_Check (N : Nat);
137 -- Check that at least N characters remain on current line, and if not,
138 -- then start an extra line with two characters extra indentation for
139 -- continuing text on the next line.
141 procedure Indent_Annull;
142 -- Causes following call to Write_Indent to be ignored. This is used when
143 -- a higher level node wants to stop a lower level node from starting a
144 -- new line, when it would otherwise be inclined to do so (e.g. the case
145 -- of an accept statement called from an accept alternative with a guard)
147 procedure Indent_Begin;
148 -- Increase indentation level
150 procedure Indent_End;
151 -- Decrease indentation level
153 procedure Print_Debug_Line (S : String);
154 -- Used to print output lines in Debug_Generated_Code mode (this is used
155 -- as the argument for a call to Set_Special_Output in package Output).
157 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
158 -- Given a divide, multiplication or division node, check the flags
159 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
160 -- appropriate special syntax characters (# and @).
162 procedure Set_Debug_Sloc;
163 -- If Debug_Node is non-empty, this routine sets the appropriate value
164 -- in its Sloc field, from the current location in the debug source file
165 -- that is currently being written. Note that Debug_Node is always empty
166 -- if a debug source file is not being written.
168 procedure Sprint_Bar_List (List : List_Id);
169 -- Print the given list with items separated by vertical bars
171 procedure Sprint_Node_Actual (Node : Node_Id);
172 -- This routine prints its node argument. It is a lower level routine than
173 -- Sprint_Node, in that it does not bother about rewritten trees.
175 procedure Sprint_Node_Sloc (Node : Node_Id);
176 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
177 -- sets the Sloc of the current debug node to be a copy of the Sloc
178 -- of the sprinted node Node. Note that this is done after printing
179 -- Node, so that the Sloc is the proper updated value for the debug file.
181 procedure Write_Char_Sloc (C : Character);
182 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
183 -- called to ensure that the current node has a proper Sloc set.
185 procedure Write_Condition_And_Reason (Node : Node_Id);
186 -- Write Condition and Reason codes of Raise_xxx_Error node
188 procedure Write_Discr_Specs (N : Node_Id);
189 -- Ouput discriminant specification for node, which is any of the type
190 -- declarations that can have discriminants.
192 procedure Write_Ekind (E : Entity_Id);
193 -- Write the String corresponding to the Ekind without "E_".
195 procedure Write_Id (N : Node_Id);
196 -- N is a node with a Chars field. This procedure writes the name that
197 -- will be used in the generated code associated with the name. For a
198 -- node with no associated entity, this is simply the Chars field. For
199 -- the case where there is an entity associated with the node, we print
200 -- the name associated with the entity (since it may have been encoded).
201 -- One other special case is that an entity has an active external name
202 -- (i.e. an external name present with no address clause), then this
203 -- external name is output.
205 function Write_Identifiers (Node : Node_Id) return Boolean;
206 -- Handle node where the grammar has a list of defining identifiers, but
207 -- the tree has a separate declaration for each identifier. Handles the
208 -- printing of the defining identifier, and returns True if the type and
209 -- initialization information is to be printed, False if it is to be
210 -- skipped (the latter case happens when printing defining identifiers
211 -- other than the first in the original tree output case).
213 procedure Write_Implicit_Def (E : Entity_Id);
214 pragma Warnings (Off, Write_Implicit_Def);
215 -- Write the definition of the implicit type E according to its Ekind
216 -- For now a debugging procedure, but might be used in the future.
218 procedure Write_Indent;
219 -- Start a new line and write indentation spacing
221 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
222 -- Like Write_Identifiers except that each new printed declaration
223 -- is at the start of a new line.
225 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
226 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
227 -- mode, the Sloc of the current debug node is set to point ot the
228 -- first output identifier.
230 procedure Write_Indent_Str (S : String);
231 -- Start a new line and write indent spacing followed by given string
233 procedure Write_Indent_Str_Sloc (S : String);
234 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
235 -- the Sloc of the current node is set to the first non-blank character
238 procedure Write_Name_With_Col_Check (N : Name_Id);
239 -- Write name (using Write_Name) with initial column check, and possible
240 -- initial Write_Indent (to get new line) if current line is too full.
242 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
243 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
244 -- mode, sets Sloc of current debug node to first character of name.
246 procedure Write_Operator (N : Node_Id; S : String);
247 -- Like Write_Str_Sloc, used for operators, encloses the string in
248 -- characters {} if the Do_Overflow flag is set on the node N.
250 procedure Write_Param_Specs (N : Node_Id);
251 -- Output parameter specifications for node (which is either a function
252 -- or procedure specification with a Parameter_Specifications field)
254 procedure Write_Rewrite_Str (S : String);
255 -- Writes out a string (typically containing <<< or >>>}) for a node
256 -- created by rewriting the tree. Suppressed if we are outputting the
257 -- generated code only, since in this case we don't specially mark nodes
258 -- created by rewriting).
260 procedure Write_Str_Sloc (S : String);
261 -- Like Write_Str, but sets debug Sloc of current debug node to first
262 -- non-blank character if a current debug node is active.
264 procedure Write_Str_With_Col_Check (S : String);
265 -- Write string (using Write_Str) with initial column check, and possible
266 -- initial Write_Indent (to get new line) if current line is too full.
268 procedure Write_Str_With_Col_Check_Sloc (S : String);
269 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
270 -- node to first non-blank character if a current debug node is active.
272 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
273 -- Write Uint (using UI_Write) with initial column check, and possible
274 -- initial Write_Indent (to get new line) if current line is too full.
275 -- The format parameter determines the output format (see UI_Write).
276 -- In addition, in Debug_Generated_Code mode, sets the current node
277 -- Sloc to the first character of the output value.
279 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
280 -- Write Ureal (using same output format as UR_Write) with column checks
281 -- and a possible initial Write_Indent (to get new line) if current line
282 -- is too full. In addition, in Debug_Generated_Code mode, sets the
283 -- current node Sloc to the first character of the output value.
289 procedure Col_Check (N : Nat) is
291 if N + Column > Line_Limit then
292 Write_Indent_Str (" ");
300 procedure Indent_Annull is
302 Indent_Annull_Flag := True;
309 procedure Indent_Begin is
311 Indent := Indent + 3;
318 procedure Indent_End is
320 Indent := Indent - 3;
327 procedure pg (Node : Node_Id) is
329 Dump_Generated_Only := True;
330 Dump_Original_Only := False;
339 procedure po (Node : Node_Id) is
341 Dump_Generated_Only := False;
342 Dump_Original_Only := True;
347 ----------------------
348 -- Print_Debug_Line --
349 ----------------------
351 procedure Print_Debug_Line (S : String) is
353 Write_Debug_Line (S, Debug_Sloc);
354 end Print_Debug_Line;
356 ---------------------------
357 -- Process_TFAI_RR_Flags --
358 ---------------------------
360 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
362 if Treat_Fixed_As_Integer (Nod) then
366 if Rounded_Result (Nod) then
369 end Process_TFAI_RR_Flags;
375 procedure ps (Node : Node_Id) is
377 Dump_Generated_Only := False;
378 Dump_Original_Only := False;
387 procedure Set_Debug_Sloc is
389 if Present (Debug_Node) then
390 Set_Sloc (Debug_Node, Debug_Sloc + Source_Ptr (Column - 1));
399 procedure Source_Dump is
402 -- Put underline under string we just printed
404 procedure Underline is
405 Col : constant Int := Column;
410 while Col > Column loop
417 -- Start of processing for Tree_Dump.
420 Dump_Generated_Only := Debug_Flag_G or
421 Print_Generated_Code or
422 Debug_Generated_Code;
423 Dump_Original_Only := Debug_Flag_O;
424 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
426 -- Note that we turn off the tree dump flags immediately, before
427 -- starting the dump. This avoids generating two copies of the dump
428 -- if an abort occurs after printing the dump, and more importantly,
429 -- avoids an infinite loop if an abort occurs during the dump.
432 Debug_Flag_Z := False;
435 Write_Str ("Source recreated from tree of Standard (spec)");
437 Sprint_Node (Standard_Package_Node);
442 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
443 Debug_Flag_G := False;
444 Debug_Flag_O := False;
445 Debug_Flag_S := False;
447 -- Dump requested units
449 for U in Main_Unit .. Last_Unit loop
451 -- Dump all units if -gnatdf set, otherwise we dump only
452 -- the source files that are in the extended main source.
455 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
457 -- If we are generating debug files, setup to write them
459 if Debug_Generated_Code then
460 Set_Special_Output (Print_Debug_Line'Access);
461 Create_Debug_Source (Source_Index (U), Debug_Sloc);
462 Sprint_Node (Cunit (U));
465 Set_Special_Output (null);
467 -- Normal output to standard output file
470 Write_Str ("Source recreated from tree for ");
471 Write_Unit_Name (Unit_Name (U));
473 Sprint_Node (Cunit (U));
482 ---------------------
483 -- Sprint_Bar_List --
484 ---------------------
486 procedure Sprint_Bar_List (List : List_Id) is
490 if Is_Non_Empty_List (List) then
491 Node := First (List);
496 exit when Node = Empty;
502 -----------------------
503 -- Sprint_Comma_List --
504 -----------------------
506 procedure Sprint_Comma_List (List : List_Id) is
510 if Is_Non_Empty_List (List) then
511 Node := First (List);
516 exit when Node = Empty;
518 if not Is_Rewrite_Insertion (Node)
519 or else not Dump_Original_Only
526 end Sprint_Comma_List;
528 --------------------------
529 -- Sprint_Indented_List --
530 --------------------------
532 procedure Sprint_Indented_List (List : List_Id) is
535 Sprint_Node_List (List);
537 end Sprint_Indented_List;
539 ---------------------
540 -- Sprint_Left_Opnd --
541 ---------------------
543 procedure Sprint_Left_Opnd (N : Node_Id) is
544 Opnd : constant Node_Id := Left_Opnd (N);
547 if Paren_Count (Opnd) /= 0
548 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
557 end Sprint_Left_Opnd;
563 procedure Sprint_Node (Node : Node_Id) is
565 if Is_Rewrite_Insertion (Node) then
566 if not Dump_Original_Only then
568 -- For special cases of nodes that always output <<< >>>
569 -- do not duplicate the output at this point.
571 if Nkind (Node) = N_Freeze_Entity
572 or else Nkind (Node) = N_Implicit_Label_Declaration
574 Sprint_Node_Actual (Node);
576 -- Normal case where <<< >>> may be required
579 Write_Rewrite_Str ("<<<");
580 Sprint_Node_Actual (Node);
581 Write_Rewrite_Str (">>>");
585 elsif Is_Rewrite_Substitution (Node) then
587 -- Case of dump generated only
589 if Dump_Generated_Only then
590 Sprint_Node_Actual (Node);
592 -- Case of dump original only
594 elsif Dump_Original_Only then
595 Sprint_Node_Actual (Original_Node (Node));
597 -- Case of both being dumped
600 Sprint_Node_Actual (Original_Node (Node));
601 Write_Rewrite_Str ("<<<");
602 Sprint_Node_Actual (Node);
603 Write_Rewrite_Str (">>>");
607 Sprint_Node_Actual (Node);
611 ------------------------
612 -- Sprint_Node_Actual --
613 ------------------------
615 procedure Sprint_Node_Actual (Node : Node_Id) is
616 Save_Debug_Node : constant Node_Id := Debug_Node;
623 for J in 1 .. Paren_Count (Node) loop
624 Write_Str_With_Col_Check ("(");
627 -- Setup node for Sloc fixup if writing a debug source file. Note
628 -- that we take care of any previous node not yet properly set.
630 if Debug_Generated_Code then
634 if Nkind (Node) in N_Subexpr
635 and then Do_Range_Check (Node)
637 Write_Str_With_Col_Check ("{");
640 -- Select print circuit based on node kind
644 when N_Abort_Statement =>
645 Write_Indent_Str_Sloc ("abort ");
646 Sprint_Comma_List (Names (Node));
649 when N_Abortable_Part =>
651 Write_Str_Sloc ("abort ");
652 Sprint_Indented_List (Statements (Node));
654 when N_Abstract_Subprogram_Declaration =>
656 Sprint_Node (Specification (Node));
657 Write_Str_With_Col_Check (" is ");
658 Write_Str_Sloc ("abstract;");
660 when N_Accept_Alternative =>
661 Sprint_Node_List (Pragmas_Before (Node));
663 if Present (Condition (Node)) then
664 Write_Indent_Str ("when ");
665 Sprint_Node (Condition (Node));
670 Sprint_Node_Sloc (Accept_Statement (Node));
671 Sprint_Node_List (Statements (Node));
673 when N_Accept_Statement =>
674 Write_Indent_Str_Sloc ("accept ");
675 Write_Id (Entry_Direct_Name (Node));
677 if Present (Entry_Index (Node)) then
678 Write_Str_With_Col_Check (" (");
679 Sprint_Node (Entry_Index (Node));
683 Write_Param_Specs (Node);
685 if Present (Handled_Statement_Sequence (Node)) then
686 Write_Str_With_Col_Check (" do");
687 Sprint_Node (Handled_Statement_Sequence (Node));
688 Write_Indent_Str ("end ");
689 Write_Id (Entry_Direct_Name (Node));
694 when N_Access_Definition =>
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 (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_Discrete_Type_Definition =>
1367 Write_Str_With_Col_Check_Sloc ("<>");
1369 when N_Formal_Floating_Point_Definition =>
1370 Write_Str_With_Col_Check_Sloc ("digits <>");
1372 when N_Formal_Modular_Type_Definition =>
1373 Write_Str_With_Col_Check_Sloc ("mod <>");
1375 when N_Formal_Object_Declaration =>
1378 if Write_Indent_Identifiers (Node) then
1381 if In_Present (Node) then
1382 Write_Str_With_Col_Check ("in ");
1385 if Out_Present (Node) then
1386 Write_Str_With_Col_Check ("out ");
1389 Sprint_Node (Subtype_Mark (Node));
1391 if Present (Expression (Node)) then
1393 Sprint_Node (Expression (Node));
1399 when N_Formal_Ordinary_Fixed_Point_Definition =>
1400 Write_Str_With_Col_Check_Sloc ("delta <>");
1402 when N_Formal_Package_Declaration =>
1403 Write_Indent_Str_Sloc ("with package ");
1404 Write_Id (Defining_Identifier (Node));
1405 Write_Str_With_Col_Check (" is new ");
1406 Sprint_Node (Name (Node));
1407 Write_Str_With_Col_Check (" (<>);");
1409 when N_Formal_Private_Type_Definition =>
1410 if Abstract_Present (Node) then
1411 Write_Str_With_Col_Check ("abstract ");
1414 if Tagged_Present (Node) then
1415 Write_Str_With_Col_Check ("tagged ");
1418 if Limited_Present (Node) then
1419 Write_Str_With_Col_Check ("limited ");
1422 Write_Str_With_Col_Check_Sloc ("private");
1424 when N_Formal_Signed_Integer_Type_Definition =>
1425 Write_Str_With_Col_Check_Sloc ("range <>");
1427 when N_Formal_Subprogram_Declaration =>
1428 Write_Indent_Str_Sloc ("with ");
1429 Sprint_Node (Specification (Node));
1431 if Box_Present (Node) then
1432 Write_Str_With_Col_Check (" is <>");
1433 elsif Present (Default_Name (Node)) then
1434 Write_Str_With_Col_Check (" is ");
1435 Sprint_Node (Default_Name (Node));
1440 when N_Formal_Type_Declaration =>
1441 Write_Indent_Str_Sloc ("type ");
1442 Write_Id (Defining_Identifier (Node));
1444 if Present (Discriminant_Specifications (Node)) then
1445 Write_Discr_Specs (Node);
1446 elsif Unknown_Discriminants_Present (Node) then
1447 Write_Str_With_Col_Check ("(<>)");
1450 Write_Str_With_Col_Check (" is ");
1451 Sprint_Node (Formal_Type_Definition (Node));
1454 when N_Free_Statement =>
1455 Write_Indent_Str_Sloc ("free ");
1456 Sprint_Node (Expression (Node));
1459 when N_Freeze_Entity =>
1460 if Dump_Original_Only then
1463 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1465 Write_Rewrite_Str ("<<<");
1466 Write_Str_With_Col_Check_Sloc ("freeze ");
1467 Write_Id (Entity (Node));
1470 if No (Actions (Node)) then
1474 Freeze_Indent := Freeze_Indent + 1;
1475 Sprint_Indented_List (Actions (Node));
1476 Freeze_Indent := Freeze_Indent - 1;
1477 Write_Indent_Str ("]");
1480 Write_Rewrite_Str (">>>");
1483 when N_Full_Type_Declaration =>
1484 Write_Indent_Str_Sloc ("type ");
1485 Write_Id (Defining_Identifier (Node));
1486 Write_Discr_Specs (Node);
1487 Write_Str_With_Col_Check (" is ");
1488 Sprint_Node (Type_Definition (Node));
1491 when N_Function_Call =>
1493 Sprint_Node (Name (Node));
1494 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1496 when N_Function_Instantiation =>
1497 Write_Indent_Str_Sloc ("function ");
1498 Sprint_Node (Defining_Unit_Name (Node));
1499 Write_Str_With_Col_Check (" is new ");
1500 Sprint_Node (Name (Node));
1501 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1504 when N_Function_Specification =>
1505 Write_Str_With_Col_Check_Sloc ("function ");
1506 Sprint_Node (Defining_Unit_Name (Node));
1507 Write_Param_Specs (Node);
1508 Write_Str_With_Col_Check (" return ");
1509 Sprint_Node (Subtype_Mark (Node));
1511 when N_Generic_Association =>
1514 if Present (Selector_Name (Node)) then
1515 Sprint_Node (Selector_Name (Node));
1519 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1521 when N_Generic_Function_Renaming_Declaration =>
1522 Write_Indent_Str_Sloc ("generic function ");
1523 Sprint_Node (Defining_Unit_Name (Node));
1524 Write_Str_With_Col_Check (" renames ");
1525 Sprint_Node (Name (Node));
1528 when N_Generic_Package_Declaration =>
1530 Write_Indent_Str_Sloc ("generic ");
1531 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1533 Sprint_Node (Specification (Node));
1536 when N_Generic_Package_Renaming_Declaration =>
1537 Write_Indent_Str_Sloc ("generic package ");
1538 Sprint_Node (Defining_Unit_Name (Node));
1539 Write_Str_With_Col_Check (" renames ");
1540 Sprint_Node (Name (Node));
1543 when N_Generic_Procedure_Renaming_Declaration =>
1544 Write_Indent_Str_Sloc ("generic procedure ");
1545 Sprint_Node (Defining_Unit_Name (Node));
1546 Write_Str_With_Col_Check (" renames ");
1547 Sprint_Node (Name (Node));
1550 when N_Generic_Subprogram_Declaration =>
1552 Write_Indent_Str_Sloc ("generic ");
1553 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1555 Sprint_Node (Specification (Node));
1558 when N_Goto_Statement =>
1559 Write_Indent_Str_Sloc ("goto ");
1560 Sprint_Node (Name (Node));
1563 if Nkind (Next (Node)) = N_Label then
1567 when N_Handled_Sequence_Of_Statements =>
1569 Sprint_Indented_List (Statements (Node));
1571 if Present (Exception_Handlers (Node)) then
1572 Write_Indent_Str ("exception");
1574 Sprint_Node_List (Exception_Handlers (Node));
1578 if Present (At_End_Proc (Node)) then
1579 Write_Indent_Str ("at end");
1582 Sprint_Node (At_End_Proc (Node));
1587 when N_Identifier =>
1591 when N_If_Statement =>
1592 Write_Indent_Str_Sloc ("if ");
1593 Sprint_Node (Condition (Node));
1594 Write_Str_With_Col_Check (" then");
1595 Sprint_Indented_List (Then_Statements (Node));
1596 Sprint_Opt_Node_List (Elsif_Parts (Node));
1598 if Present (Else_Statements (Node)) then
1599 Write_Indent_Str ("else");
1600 Sprint_Indented_List (Else_Statements (Node));
1603 Write_Indent_Str ("end if;");
1605 when N_Implicit_Label_Declaration =>
1606 if not Dump_Original_Only then
1608 Write_Rewrite_Str ("<<<");
1610 Write_Id (Defining_Identifier (Node));
1612 Write_Str_With_Col_Check ("label");
1613 Write_Rewrite_Str (">>>");
1617 Sprint_Left_Opnd (Node);
1618 Write_Str_Sloc (" in ");
1619 Sprint_Right_Opnd (Node);
1621 when N_Incomplete_Type_Declaration =>
1622 Write_Indent_Str_Sloc ("type ");
1623 Write_Id (Defining_Identifier (Node));
1625 if Present (Discriminant_Specifications (Node)) then
1626 Write_Discr_Specs (Node);
1627 elsif Unknown_Discriminants_Present (Node) then
1628 Write_Str_With_Col_Check ("(<>)");
1633 when N_Index_Or_Discriminant_Constraint =>
1635 Sprint_Paren_Comma_List (Constraints (Node));
1637 when N_Indexed_Component =>
1638 Sprint_Node_Sloc (Prefix (Node));
1639 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1641 when N_Integer_Literal =>
1642 if Print_In_Hex (Node) then
1643 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1645 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1648 when N_Iteration_Scheme =>
1649 if Present (Condition (Node)) then
1650 Write_Str_With_Col_Check_Sloc ("while ");
1651 Sprint_Node (Condition (Node));
1653 Write_Str_With_Col_Check_Sloc ("for ");
1654 Sprint_Node (Loop_Parameter_Specification (Node));
1659 when N_Itype_Reference =>
1660 Write_Indent_Str_Sloc ("reference ");
1661 Write_Id (Itype (Node));
1664 Write_Indent_Str_Sloc ("<<");
1665 Write_Id (Identifier (Node));
1668 when N_Loop_Parameter_Specification =>
1670 Write_Id (Defining_Identifier (Node));
1671 Write_Str_With_Col_Check (" in ");
1673 if Reverse_Present (Node) then
1674 Write_Str_With_Col_Check ("reverse ");
1677 Sprint_Node (Discrete_Subtype_Definition (Node));
1679 when N_Loop_Statement =>
1682 if Present (Identifier (Node))
1683 and then (not Has_Created_Identifier (Node)
1684 or else not Dump_Original_Only)
1686 Write_Rewrite_Str ("<<<");
1687 Write_Id (Identifier (Node));
1689 Write_Rewrite_Str (">>>");
1690 Sprint_Node (Iteration_Scheme (Node));
1691 Write_Str_With_Col_Check_Sloc ("loop");
1692 Sprint_Indented_List (Statements (Node));
1693 Write_Indent_Str ("end loop ");
1694 Write_Rewrite_Str ("<<<");
1695 Write_Id (Identifier (Node));
1696 Write_Rewrite_Str (">>>");
1700 Sprint_Node (Iteration_Scheme (Node));
1701 Write_Str_With_Col_Check_Sloc ("loop");
1702 Sprint_Indented_List (Statements (Node));
1703 Write_Indent_Str ("end loop;");
1706 when N_Mod_Clause =>
1707 Sprint_Node_List (Pragmas_Before (Node));
1708 Write_Str_With_Col_Check_Sloc ("at mod ");
1709 Sprint_Node (Expression (Node));
1711 when N_Modular_Type_Definition =>
1712 Write_Str_With_Col_Check_Sloc ("mod ");
1713 Sprint_Node (Expression (Node));
1716 Sprint_Left_Opnd (Node);
1717 Write_Str_Sloc (" not in ");
1718 Sprint_Right_Opnd (Node);
1721 Write_Str_With_Col_Check_Sloc ("null");
1723 when N_Null_Statement =>
1724 if Comes_From_Source (Node)
1725 or else Dump_Freeze_Null
1726 or else not Is_List_Member (Node)
1727 or else (No (Prev (Node)) and then No (Next (Node)))
1729 Write_Indent_Str_Sloc ("null;");
1732 when N_Number_Declaration =>
1735 if Write_Indent_Identifiers (Node) then
1736 Write_Str_With_Col_Check (" : constant ");
1738 Sprint_Node (Expression (Node));
1742 when N_Object_Declaration =>
1745 if Write_Indent_Identifiers (Node) then
1748 if Aliased_Present (Node) then
1749 Write_Str_With_Col_Check ("aliased ");
1752 if Constant_Present (Node) then
1753 Write_Str_With_Col_Check ("constant ");
1756 -- Ada 2005 (AI-231)
1758 if Null_Exclusion_Present (Node) then
1759 Write_Str_With_Col_Check ("not null ");
1762 Sprint_Node (Object_Definition (Node));
1764 if Present (Expression (Node)) then
1766 Sprint_Node (Expression (Node));
1772 when N_Object_Renaming_Declaration =>
1775 Sprint_Node (Defining_Identifier (Node));
1778 -- Ada 2005 (AI-230): Access renamings
1780 if Present (Access_Definition (Node)) then
1781 Sprint_Node (Access_Definition (Node));
1783 elsif Present (Subtype_Mark (Node)) then
1784 Sprint_Node (Subtype_Mark (Node));
1787 Write_Str (" ??? ");
1790 Write_Str_With_Col_Check (" renames ");
1791 Sprint_Node (Name (Node));
1795 Write_Operator (Node, "abs ");
1796 Sprint_Right_Opnd (Node);
1799 Sprint_Left_Opnd (Node);
1800 Write_Operator (Node, " + ");
1801 Sprint_Right_Opnd (Node);
1804 Sprint_Left_Opnd (Node);
1805 Write_Operator (Node, " and ");
1806 Sprint_Right_Opnd (Node);
1809 Sprint_Left_Opnd (Node);
1810 Write_Operator (Node, " & ");
1811 Sprint_Right_Opnd (Node);
1814 Sprint_Left_Opnd (Node);
1816 Process_TFAI_RR_Flags (Node);
1817 Write_Operator (Node, "/ ");
1818 Sprint_Right_Opnd (Node);
1821 Sprint_Left_Opnd (Node);
1822 Write_Operator (Node, " = ");
1823 Sprint_Right_Opnd (Node);
1826 Sprint_Left_Opnd (Node);
1827 Write_Operator (Node, " ** ");
1828 Sprint_Right_Opnd (Node);
1831 Sprint_Left_Opnd (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 Write_Operator (Node, "-");
1852 Sprint_Right_Opnd (Node);
1855 Sprint_Left_Opnd (Node);
1857 if Treat_Fixed_As_Integer (Node) then
1861 Write_Operator (Node, " mod ");
1862 Sprint_Right_Opnd (Node);
1864 when N_Op_Multiply =>
1865 Sprint_Left_Opnd (Node);
1867 Process_TFAI_RR_Flags (Node);
1868 Write_Operator (Node, "* ");
1869 Sprint_Right_Opnd (Node);
1872 Sprint_Left_Opnd (Node);
1873 Write_Operator (Node, " /= ");
1874 Sprint_Right_Opnd (Node);
1877 Write_Operator (Node, "not ");
1878 Sprint_Right_Opnd (Node);
1881 Sprint_Left_Opnd (Node);
1882 Write_Operator (Node, " or ");
1883 Sprint_Right_Opnd (Node);
1886 Write_Operator (Node, "+");
1887 Sprint_Right_Opnd (Node);
1890 Sprint_Left_Opnd (Node);
1892 if Treat_Fixed_As_Integer (Node) then
1896 Write_Operator (Node, " rem ");
1897 Sprint_Right_Opnd (Node);
1903 Write_Str_With_Col_Check ("(");
1904 Sprint_Node (Left_Opnd (Node));
1906 Sprint_Node (Right_Opnd (Node));
1909 when N_Op_Subtract =>
1910 Sprint_Left_Opnd (Node);
1911 Write_Operator (Node, " - ");
1912 Sprint_Right_Opnd (Node);
1915 Sprint_Left_Opnd (Node);
1916 Write_Operator (Node, " xor ");
1917 Sprint_Right_Opnd (Node);
1919 when N_Operator_Symbol =>
1920 Write_Name_With_Col_Check_Sloc (Chars (Node));
1922 when N_Ordinary_Fixed_Point_Definition =>
1923 Write_Str_With_Col_Check_Sloc ("delta ");
1924 Sprint_Node (Delta_Expression (Node));
1925 Sprint_Opt_Node (Real_Range_Specification (Node));
1928 Sprint_Left_Opnd (Node);
1929 Write_Str_Sloc (" or else ");
1930 Sprint_Right_Opnd (Node);
1932 when N_Others_Choice =>
1933 if All_Others (Node) then
1934 Write_Str_With_Col_Check ("all ");
1937 Write_Str_With_Col_Check_Sloc ("others");
1939 when N_Package_Body =>
1941 Write_Indent_Str_Sloc ("package body ");
1942 Sprint_Node (Defining_Unit_Name (Node));
1944 Sprint_Indented_List (Declarations (Node));
1946 if Present (Handled_Statement_Sequence (Node)) then
1947 Write_Indent_Str ("begin");
1948 Sprint_Node (Handled_Statement_Sequence (Node));
1951 Write_Indent_Str ("end ");
1952 Sprint_Node (Defining_Unit_Name (Node));
1955 when N_Package_Body_Stub =>
1956 Write_Indent_Str_Sloc ("package body ");
1957 Sprint_Node (Defining_Identifier (Node));
1958 Write_Str_With_Col_Check (" is separate;");
1960 when N_Package_Declaration =>
1963 Sprint_Node_Sloc (Specification (Node));
1966 when N_Package_Instantiation =>
1968 Write_Indent_Str_Sloc ("package ");
1969 Sprint_Node (Defining_Unit_Name (Node));
1970 Write_Str (" is new ");
1971 Sprint_Node (Name (Node));
1972 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1975 when N_Package_Renaming_Declaration =>
1976 Write_Indent_Str_Sloc ("package ");
1977 Sprint_Node (Defining_Unit_Name (Node));
1978 Write_Str_With_Col_Check (" renames ");
1979 Sprint_Node (Name (Node));
1982 when N_Package_Specification =>
1983 Write_Str_With_Col_Check_Sloc ("package ");
1984 Sprint_Node (Defining_Unit_Name (Node));
1986 Sprint_Indented_List (Visible_Declarations (Node));
1988 if Present (Private_Declarations (Node)) then
1989 Write_Indent_Str ("private");
1990 Sprint_Indented_List (Private_Declarations (Node));
1993 Write_Indent_Str ("end ");
1994 Sprint_Node (Defining_Unit_Name (Node));
1996 when N_Parameter_Association =>
1997 Sprint_Node_Sloc (Selector_Name (Node));
1999 Sprint_Node (Explicit_Actual_Parameter (Node));
2001 when N_Parameter_Specification =>
2004 if Write_Identifiers (Node) then
2007 if In_Present (Node) then
2008 Write_Str_With_Col_Check ("in ");
2011 if Out_Present (Node) then
2012 Write_Str_With_Col_Check ("out ");
2015 -- Ada 2005 (AI-231)
2017 if Null_Exclusion_Present (Node) then
2018 Write_Str ("not null ");
2021 Sprint_Node (Parameter_Type (Node));
2023 if Present (Expression (Node)) then
2025 Sprint_Node (Expression (Node));
2032 Write_Indent_Str_Sloc ("pragma ");
2033 Write_Name_With_Col_Check (Chars (Node));
2035 if Present (Pragma_Argument_Associations (Node)) then
2036 Sprint_Opt_Paren_Comma_List
2037 (Pragma_Argument_Associations (Node));
2042 when N_Pragma_Argument_Association =>
2045 if Chars (Node) /= No_Name then
2046 Write_Name_With_Col_Check (Chars (Node));
2050 Sprint_Node (Expression (Node));
2052 when N_Private_Type_Declaration =>
2053 Write_Indent_Str_Sloc ("type ");
2054 Write_Id (Defining_Identifier (Node));
2056 if Present (Discriminant_Specifications (Node)) then
2057 Write_Discr_Specs (Node);
2058 elsif Unknown_Discriminants_Present (Node) then
2059 Write_Str_With_Col_Check ("(<>)");
2064 if Tagged_Present (Node) then
2065 Write_Str_With_Col_Check ("tagged ");
2068 if Limited_Present (Node) then
2069 Write_Str_With_Col_Check ("limited ");
2072 Write_Str_With_Col_Check ("private;");
2074 when N_Private_Extension_Declaration =>
2075 Write_Indent_Str_Sloc ("type ");
2076 Write_Id (Defining_Identifier (Node));
2078 if Present (Discriminant_Specifications (Node)) then
2079 Write_Discr_Specs (Node);
2080 elsif Unknown_Discriminants_Present (Node) then
2081 Write_Str_With_Col_Check ("(<>)");
2084 Write_Str_With_Col_Check (" is new ");
2085 Sprint_Node (Subtype_Indication (Node));
2086 Write_Str_With_Col_Check (" with private;");
2088 when N_Procedure_Call_Statement =>
2091 Sprint_Node (Name (Node));
2092 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2095 when N_Procedure_Instantiation =>
2096 Write_Indent_Str_Sloc ("procedure ");
2097 Sprint_Node (Defining_Unit_Name (Node));
2098 Write_Str_With_Col_Check (" is new ");
2099 Sprint_Node (Name (Node));
2100 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2103 when N_Procedure_Specification =>
2104 Write_Str_With_Col_Check_Sloc ("procedure ");
2105 Sprint_Node (Defining_Unit_Name (Node));
2106 Write_Param_Specs (Node);
2108 when N_Protected_Body =>
2109 Write_Indent_Str_Sloc ("protected body ");
2110 Write_Id (Defining_Identifier (Node));
2112 Sprint_Indented_List (Declarations (Node));
2113 Write_Indent_Str ("end ");
2114 Write_Id (Defining_Identifier (Node));
2117 when N_Protected_Body_Stub =>
2118 Write_Indent_Str_Sloc ("protected body ");
2119 Write_Id (Defining_Identifier (Node));
2120 Write_Str_With_Col_Check (" is separate;");
2122 when N_Protected_Definition =>
2124 Sprint_Indented_List (Visible_Declarations (Node));
2126 if Present (Private_Declarations (Node)) then
2127 Write_Indent_Str ("private");
2128 Sprint_Indented_List (Private_Declarations (Node));
2131 Write_Indent_Str ("end ");
2133 when N_Protected_Type_Declaration =>
2134 Write_Indent_Str_Sloc ("protected type ");
2135 Write_Id (Defining_Identifier (Node));
2136 Write_Discr_Specs (Node);
2138 Sprint_Node (Protected_Definition (Node));
2139 Write_Id (Defining_Identifier (Node));
2142 when N_Qualified_Expression =>
2143 Sprint_Node (Subtype_Mark (Node));
2144 Write_Char_Sloc (''');
2146 -- Print expression, make sure we have at least one level of
2147 -- parentheses around the expression. For cases of qualified
2148 -- expressions in the source, this is always the case, but
2149 -- for generated qualifications, there may be no explicit
2150 -- parentheses present.
2152 if Paren_Count (Expression (Node)) /= 0 then
2153 Sprint_Node (Expression (Node));
2156 Sprint_Node (Expression (Node));
2160 when N_Raise_Constraint_Error =>
2162 -- This node can be used either as a subexpression or as a
2163 -- statement form. The following test is a reasonably reliable
2164 -- way to distinguish the two cases.
2166 if Is_List_Member (Node)
2167 and then Nkind (Parent (Node)) not in N_Subexpr
2172 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2173 Write_Condition_And_Reason (Node);
2175 when N_Raise_Program_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 ("[program_error");
2188 Write_Condition_And_Reason (Node);
2190 when N_Raise_Storage_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 ("[storage_error");
2203 Write_Condition_And_Reason (Node);
2205 when N_Raise_Statement =>
2206 Write_Indent_Str_Sloc ("raise ");
2207 Sprint_Node (Name (Node));
2211 Sprint_Node (Low_Bound (Node));
2212 Write_Str_Sloc (" .. ");
2213 Sprint_Node (High_Bound (Node));
2215 when N_Range_Constraint =>
2216 Write_Str_With_Col_Check_Sloc ("range ");
2217 Sprint_Node (Range_Expression (Node));
2219 when N_Real_Literal =>
2220 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2222 when N_Real_Range_Specification =>
2223 Write_Str_With_Col_Check_Sloc ("range ");
2224 Sprint_Node (Low_Bound (Node));
2226 Sprint_Node (High_Bound (Node));
2228 when N_Record_Definition =>
2229 if Abstract_Present (Node) then
2230 Write_Str_With_Col_Check ("abstract ");
2233 if Tagged_Present (Node) then
2234 Write_Str_With_Col_Check ("tagged ");
2237 if Limited_Present (Node) then
2238 Write_Str_With_Col_Check ("limited ");
2241 if Null_Present (Node) then
2242 Write_Str_With_Col_Check_Sloc ("null record");
2245 Write_Str_With_Col_Check_Sloc ("record");
2246 Sprint_Node (Component_List (Node));
2247 Write_Indent_Str ("end record");
2250 when N_Record_Representation_Clause =>
2251 Write_Indent_Str_Sloc ("for ");
2252 Sprint_Node (Identifier (Node));
2253 Write_Str_With_Col_Check (" use record ");
2255 if Present (Mod_Clause (Node)) then
2256 Sprint_Node (Mod_Clause (Node));
2259 Sprint_Indented_List (Component_Clauses (Node));
2260 Write_Indent_Str ("end record;");
2263 Sprint_Node (Prefix (Node));
2264 Write_Str_With_Col_Check_Sloc ("'reference");
2266 when N_Requeue_Statement =>
2267 Write_Indent_Str_Sloc ("requeue ");
2268 Sprint_Node (Name (Node));
2270 if Abort_Present (Node) then
2271 Write_Str_With_Col_Check (" with abort");
2276 when N_Return_Statement =>
2277 if Present (Expression (Node)) then
2278 Write_Indent_Str_Sloc ("return ");
2279 Sprint_Node (Expression (Node));
2282 Write_Indent_Str_Sloc ("return;");
2285 when N_Selective_Accept =>
2286 Write_Indent_Str_Sloc ("select");
2292 Alt_Node := First (Select_Alternatives (Node));
2295 Sprint_Node (Alt_Node);
2298 exit when No (Alt_Node);
2299 Write_Indent_Str ("or");
2303 if Present (Else_Statements (Node)) then
2304 Write_Indent_Str ("else");
2305 Sprint_Indented_List (Else_Statements (Node));
2308 Write_Indent_Str ("end select;");
2310 when N_Signed_Integer_Type_Definition =>
2311 Write_Str_With_Col_Check_Sloc ("range ");
2312 Sprint_Node (Low_Bound (Node));
2314 Sprint_Node (High_Bound (Node));
2316 when N_Single_Protected_Declaration =>
2317 Write_Indent_Str_Sloc ("protected ");
2318 Write_Id (Defining_Identifier (Node));
2320 Sprint_Node (Protected_Definition (Node));
2321 Write_Id (Defining_Identifier (Node));
2324 when N_Single_Task_Declaration =>
2325 Write_Indent_Str_Sloc ("task ");
2326 Write_Id (Defining_Identifier (Node));
2328 if Present (Task_Definition (Node)) then
2330 Sprint_Node (Task_Definition (Node));
2331 Write_Id (Defining_Identifier (Node));
2336 when N_Selected_Component =>
2337 Sprint_Node (Prefix (Node));
2338 Write_Char_Sloc ('.');
2339 Sprint_Node (Selector_Name (Node));
2343 Sprint_Node (Prefix (Node));
2344 Write_Str_With_Col_Check (" (");
2345 Sprint_Node (Discrete_Range (Node));
2348 when N_String_Literal =>
2349 if String_Length (Strval (Node)) + Column > 75 then
2350 Write_Indent_Str (" ");
2354 Write_String_Table_Entry (Strval (Node));
2356 when N_Subprogram_Body =>
2357 if Freeze_Indent = 0 then
2362 Sprint_Node_Sloc (Specification (Node));
2365 Sprint_Indented_List (Declarations (Node));
2366 Write_Indent_Str ("begin");
2367 Sprint_Node (Handled_Statement_Sequence (Node));
2369 Write_Indent_Str ("end ");
2370 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2373 if Is_List_Member (Node)
2374 and then Present (Next (Node))
2375 and then Nkind (Next (Node)) /= N_Subprogram_Body
2380 when N_Subprogram_Body_Stub =>
2382 Sprint_Node_Sloc (Specification (Node));
2383 Write_Str_With_Col_Check (" is separate;");
2385 when N_Subprogram_Declaration =>
2387 Sprint_Node_Sloc (Specification (Node));
2390 when N_Subprogram_Info =>
2391 Sprint_Node (Identifier (Node));
2392 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2394 when N_Subprogram_Renaming_Declaration =>
2396 Sprint_Node (Specification (Node));
2397 Write_Str_With_Col_Check_Sloc (" renames ");
2398 Sprint_Node (Name (Node));
2401 when N_Subtype_Declaration =>
2402 Write_Indent_Str_Sloc ("subtype ");
2403 Write_Id (Defining_Identifier (Node));
2406 -- Ada 2005 (AI-231)
2408 if Null_Exclusion_Present (Node) then
2409 Write_Str ("not null ");
2412 Sprint_Node (Subtype_Indication (Node));
2415 when N_Subtype_Indication =>
2416 Sprint_Node_Sloc (Subtype_Mark (Node));
2418 Sprint_Node (Constraint (Node));
2421 Write_Indent_Str_Sloc ("separate (");
2422 Sprint_Node (Name (Node));
2425 Sprint_Node (Proper_Body (Node));
2428 Write_Indent_Str_Sloc ("task body ");
2429 Write_Id (Defining_Identifier (Node));
2431 Sprint_Indented_List (Declarations (Node));
2432 Write_Indent_Str ("begin");
2433 Sprint_Node (Handled_Statement_Sequence (Node));
2434 Write_Indent_Str ("end ");
2435 Write_Id (Defining_Identifier (Node));
2438 when N_Task_Body_Stub =>
2439 Write_Indent_Str_Sloc ("task body ");
2440 Write_Id (Defining_Identifier (Node));
2441 Write_Str_With_Col_Check (" is separate;");
2443 when N_Task_Definition =>
2445 Sprint_Indented_List (Visible_Declarations (Node));
2447 if Present (Private_Declarations (Node)) then
2448 Write_Indent_Str ("private");
2449 Sprint_Indented_List (Private_Declarations (Node));
2452 Write_Indent_Str ("end ");
2454 when N_Task_Type_Declaration =>
2455 Write_Indent_Str_Sloc ("task type ");
2456 Write_Id (Defining_Identifier (Node));
2457 Write_Discr_Specs (Node);
2459 if Present (Task_Definition (Node)) then
2461 Sprint_Node (Task_Definition (Node));
2462 Write_Id (Defining_Identifier (Node));
2467 when N_Terminate_Alternative =>
2468 Sprint_Node_List (Pragmas_Before (Node));
2472 if Present (Condition (Node)) then
2473 Write_Str_With_Col_Check ("when ");
2474 Sprint_Node (Condition (Node));
2478 Write_Str_With_Col_Check_Sloc ("terminate;");
2479 Sprint_Node_List (Pragmas_After (Node));
2481 when N_Timed_Entry_Call =>
2482 Write_Indent_Str_Sloc ("select");
2484 Sprint_Node (Entry_Call_Alternative (Node));
2486 Write_Indent_Str ("or");
2488 Sprint_Node (Delay_Alternative (Node));
2490 Write_Indent_Str ("end select;");
2492 when N_Triggering_Alternative =>
2493 Sprint_Node_List (Pragmas_Before (Node));
2494 Sprint_Node_Sloc (Triggering_Statement (Node));
2495 Sprint_Node_List (Statements (Node));
2497 when N_Type_Conversion =>
2499 Sprint_Node (Subtype_Mark (Node));
2502 if Conversion_OK (Node) then
2506 if Float_Truncate (Node) then
2510 if Rounded_Result (Node) then
2515 Sprint_Node (Expression (Node));
2518 when N_Unchecked_Expression =>
2521 Sprint_Node_Sloc (Expression (Node));
2524 when N_Unchecked_Type_Conversion =>
2525 Sprint_Node (Subtype_Mark (Node));
2527 Write_Str_With_Col_Check ("(");
2528 Sprint_Node_Sloc (Expression (Node));
2531 when N_Unconstrained_Array_Definition =>
2532 Write_Str_With_Col_Check_Sloc ("array (");
2538 Node1 := First (Subtype_Marks (Node));
2540 Sprint_Node (Node1);
2541 Write_Str_With_Col_Check (" range <>");
2543 exit when Node1 = Empty;
2548 Write_Str (") of ");
2549 Sprint_Node (Component_Definition (Node));
2551 when N_Unused_At_Start | N_Unused_At_End =>
2552 Write_Indent_Str ("***** Error, unused node encountered *****");
2555 when N_Use_Package_Clause =>
2556 Write_Indent_Str_Sloc ("use ");
2557 Sprint_Comma_List (Names (Node));
2560 when N_Use_Type_Clause =>
2561 Write_Indent_Str_Sloc ("use type ");
2562 Sprint_Comma_List (Subtype_Marks (Node));
2565 when N_Validate_Unchecked_Conversion =>
2566 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2567 Sprint_Node (Source_Type (Node));
2569 Sprint_Node (Target_Type (Node));
2573 Write_Indent_Str_Sloc ("when ");
2574 Sprint_Bar_List (Discrete_Choices (Node));
2576 Sprint_Node (Component_List (Node));
2578 when N_Variant_Part =>
2580 Write_Indent_Str_Sloc ("case ");
2581 Sprint_Node (Name (Node));
2583 Sprint_Indented_List (Variants (Node));
2584 Write_Indent_Str ("end case");
2587 when N_With_Clause =>
2589 -- Special test, if we are dumping the original tree only,
2590 -- then we want to eliminate the bogus with clauses that
2591 -- correspond to the non-existent children of Text_IO.
2593 if Dump_Original_Only
2594 and then Is_Text_IO_Kludge_Unit (Name (Node))
2598 -- Normal case, output the with clause
2601 if First_Name (Node) or else not Dump_Original_Only then
2603 -- Ada 2005 (AI-50217): Print limited with_clauses
2605 if Private_Present (Node) and Limited_Present (Node) then
2606 Write_Indent_Str ("limited private with ");
2608 elsif Private_Present (Node) then
2609 Write_Indent_Str ("private with ");
2611 elsif Limited_Present (Node) then
2612 Write_Indent_Str ("limited with ");
2615 Write_Indent_Str ("with ");
2622 Sprint_Node_Sloc (Name (Node));
2624 if Last_Name (Node) or else not Dump_Original_Only then
2629 when N_With_Type_Clause =>
2630 Write_Indent_Str ("with type ");
2631 Sprint_Node_Sloc (Name (Node));
2633 if Tagged_Present (Node) then
2634 Write_Str (" is tagged;");
2636 Write_Str (" is access;");
2641 if Nkind (Node) in N_Subexpr
2642 and then Do_Range_Check (Node)
2647 for J in 1 .. Paren_Count (Node) loop
2651 pragma Assert (No (Debug_Node));
2652 Debug_Node := Save_Debug_Node;
2653 end Sprint_Node_Actual;
2655 ----------------------
2656 -- Sprint_Node_List --
2657 ----------------------
2659 procedure Sprint_Node_List (List : List_Id) is
2663 if Is_Non_Empty_List (List) then
2664 Node := First (List);
2669 exit when Node = Empty;
2672 end Sprint_Node_List;
2674 ----------------------
2675 -- Sprint_Node_Sloc --
2676 ----------------------
2678 procedure Sprint_Node_Sloc (Node : Node_Id) is
2682 if Present (Debug_Node) then
2683 Set_Sloc (Debug_Node, Sloc (Node));
2684 Debug_Node := Empty;
2686 end Sprint_Node_Sloc;
2688 ---------------------
2689 -- Sprint_Opt_Node --
2690 ---------------------
2692 procedure Sprint_Opt_Node (Node : Node_Id) is
2694 if Present (Node) then
2698 end Sprint_Opt_Node;
2700 --------------------------
2701 -- Sprint_Opt_Node_List --
2702 --------------------------
2704 procedure Sprint_Opt_Node_List (List : List_Id) is
2706 if Present (List) then
2707 Sprint_Node_List (List);
2709 end Sprint_Opt_Node_List;
2711 ---------------------------------
2712 -- Sprint_Opt_Paren_Comma_List --
2713 ---------------------------------
2715 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2717 if Is_Non_Empty_List (List) then
2719 Sprint_Paren_Comma_List (List);
2721 end Sprint_Opt_Paren_Comma_List;
2723 -----------------------------
2724 -- Sprint_Paren_Comma_List --
2725 -----------------------------
2727 procedure Sprint_Paren_Comma_List (List : List_Id) is
2729 Node_Exists : Boolean := False;
2733 if Is_Non_Empty_List (List) then
2735 if Dump_Original_Only then
2738 while Present (N) loop
2740 if not Is_Rewrite_Insertion (N) then
2741 Node_Exists := True;
2748 if not Node_Exists then
2753 Write_Str_With_Col_Check ("(");
2754 Sprint_Comma_List (List);
2757 end Sprint_Paren_Comma_List;
2759 ----------------------
2760 -- Sprint_Right_Opnd --
2761 ----------------------
2763 procedure Sprint_Right_Opnd (N : Node_Id) is
2764 Opnd : constant Node_Id := Right_Opnd (N);
2767 if Paren_Count (Opnd) /= 0
2768 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2777 end Sprint_Right_Opnd;
2779 ---------------------
2780 -- Write_Char_Sloc --
2781 ---------------------
2783 procedure Write_Char_Sloc (C : Character) is
2785 if Debug_Generated_Code and then C /= ' ' then
2790 end Write_Char_Sloc;
2792 --------------------------------
2793 -- Write_Condition_And_Reason --
2794 --------------------------------
2796 procedure Write_Condition_And_Reason (Node : Node_Id) is
2797 Image : constant String := RT_Exception_Code'Image
2798 (RT_Exception_Code'Val
2799 (UI_To_Int (Reason (Node))));
2802 if Present (Condition (Node)) then
2803 Write_Str_With_Col_Check (" when ");
2804 Sprint_Node (Condition (Node));
2809 for J in 4 .. Image'Last loop
2810 if Image (J) = '_' then
2813 Write_Char (Fold_Lower (Image (J)));
2818 end Write_Condition_And_Reason;
2820 -----------------------
2821 -- Write_Discr_Specs --
2822 -----------------------
2824 procedure Write_Discr_Specs (N : Node_Id) is
2829 Specs := Discriminant_Specifications (N);
2831 if Present (Specs) then
2832 Write_Str_With_Col_Check (" (");
2833 Spec := First (Specs);
2838 exit when Spec = Empty;
2840 -- Add semicolon, unless we are printing original tree and the
2841 -- next specification is part of a list (but not the first
2842 -- element of that list)
2844 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2851 end Write_Discr_Specs;
2857 procedure Write_Ekind (E : Entity_Id) is
2858 S : constant String := Entity_Kind'Image (Ekind (E));
2861 Name_Len := S'Length;
2862 Name_Buffer (1 .. Name_Len) := S;
2863 Set_Casing (Mixed_Case);
2864 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2871 procedure Write_Id (N : Node_Id) is
2873 -- Case of a defining identifier
2875 if Nkind (N) = N_Defining_Identifier then
2877 -- If defining identifier has an interface name (and no
2878 -- address clause), then we output the interface name.
2880 if (Is_Imported (N) or else Is_Exported (N))
2881 and then Present (Interface_Name (N))
2882 and then No (Address_Clause (N))
2884 String_To_Name_Buffer (Strval (Interface_Name (N)));
2885 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2887 -- If no interface name (or inactive because there was
2888 -- an address clause), then just output the Chars name.
2891 Write_Name_With_Col_Check (Chars (N));
2894 -- Case of selector of an expanded name where the expanded name
2895 -- has an associated entity, output this entity.
2897 elsif Nkind (Parent (N)) = N_Expanded_Name
2898 and then Selector_Name (Parent (N)) = N
2899 and then Present (Entity (Parent (N)))
2901 Write_Id (Entity (Parent (N)));
2903 -- For any other node with an associated entity, output it
2905 elsif Nkind (N) in N_Has_Entity
2906 and then Present (Entity_Or_Associated_Node (N))
2907 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2909 Write_Id (Entity (N));
2911 -- All other cases, we just print the Chars field
2914 Write_Name_With_Col_Check (Chars (N));
2918 -----------------------
2919 -- Write_Identifiers --
2920 -----------------------
2922 function Write_Identifiers (Node : Node_Id) return Boolean is
2924 Sprint_Node (Defining_Identifier (Node));
2926 -- The remainder of the declaration must be printed unless we are
2927 -- printing the original tree and this is not the last identifier
2930 not Dump_Original_Only or else not More_Ids (Node);
2932 end Write_Identifiers;
2934 ------------------------
2935 -- Write_Implicit_Def --
2936 ------------------------
2938 procedure Write_Implicit_Def (E : Entity_Id) is
2943 when E_Array_Subtype =>
2944 Write_Str_With_Col_Check ("subtype ");
2946 Write_Str_With_Col_Check (" is ");
2947 Write_Id (Base_Type (E));
2948 Write_Str_With_Col_Check (" (");
2950 Ind := First_Index (E);
2952 while Present (Ind) loop
2956 if Present (Ind) then
2963 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2964 Write_Str_With_Col_Check ("subtype ");
2967 Write_Id (Etype (E));
2968 Write_Str_With_Col_Check (" range ");
2969 Sprint_Node (Scalar_Range (E));
2973 Write_Str_With_Col_Check ("type ");
2975 Write_Str_With_Col_Check (" is <");
2980 end Write_Implicit_Def;
2986 procedure Write_Indent is
2988 if Indent_Annull_Flag then
2989 Indent_Annull_Flag := False;
2993 for J in 1 .. Indent loop
2999 ------------------------------
3000 -- Write_Indent_Identifiers --
3001 ------------------------------
3003 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3005 -- We need to start a new line for every node, except in the case
3006 -- where we are printing the original tree and this is not the first
3007 -- defining identifier in the list.
3009 if not Dump_Original_Only or else not Prev_Ids (Node) then
3012 -- If printing original tree and this is not the first defining
3013 -- identifier in the list, then the previous call to this procedure
3014 -- printed only the name, and we add a comma to separate the names.
3020 Sprint_Node (Defining_Identifier (Node));
3022 -- The remainder of the declaration must be printed unless we are
3023 -- printing the original tree and this is not the last identifier
3026 not Dump_Original_Only or else not More_Ids (Node);
3028 end Write_Indent_Identifiers;
3030 -----------------------------------
3031 -- Write_Indent_Identifiers_Sloc --
3032 -----------------------------------
3034 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3036 -- We need to start a new line for every node, except in the case
3037 -- where we are printing the original tree and this is not the first
3038 -- defining identifier in the list.
3040 if not Dump_Original_Only or else not Prev_Ids (Node) then
3043 -- If printing original tree and this is not the first defining
3044 -- identifier in the list, then the previous call to this procedure
3045 -- printed only the name, and we add a comma to separate the names.
3052 Sprint_Node (Defining_Identifier (Node));
3054 -- The remainder of the declaration must be printed unless we are
3055 -- printing the original tree and this is not the last identifier
3058 not Dump_Original_Only or else not More_Ids (Node);
3060 end Write_Indent_Identifiers_Sloc;
3062 ----------------------
3063 -- Write_Indent_Str --
3064 ----------------------
3066 procedure Write_Indent_Str (S : String) is
3070 end Write_Indent_Str;
3072 ---------------------------
3073 -- Write_Indent_Str_Sloc --
3074 ---------------------------
3076 procedure Write_Indent_Str_Sloc (S : String) is
3080 end Write_Indent_Str_Sloc;
3082 -------------------------------
3083 -- Write_Name_With_Col_Check --
3084 -------------------------------
3086 procedure Write_Name_With_Col_Check (N : Name_Id) is
3090 Get_Name_String (N);
3092 -- Deal with -gnatI which replaces digits in an internal
3093 -- name by three dots (e.g. R7b becomes R...b).
3095 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3098 while J < Name_Len loop
3099 exit when Name_Buffer (J) not in 'A' .. 'Z';
3103 if Name_Buffer (J) in '0' .. '9' then
3104 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3107 while J <= Name_Len loop
3108 if Name_Buffer (J) not in '0' .. '9' then
3109 Write_Str (Name_Buffer (J .. Name_Len));
3121 -- Fall through for normal case
3123 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3124 end Write_Name_With_Col_Check;
3126 ------------------------------------
3127 -- Write_Name_With_Col_Check_Sloc --
3128 ------------------------------------
3130 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3132 Get_Name_String (N);
3133 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3134 end Write_Name_With_Col_Check_Sloc;
3136 --------------------
3137 -- Write_Operator --
3138 --------------------
3140 procedure Write_Operator (N : Node_Id; S : String) is
3141 F : Natural := S'First;
3142 T : Natural := S'Last;
3145 -- If no overflow check, just write string out, and we are done
3147 if not Do_Overflow_Check (N) then
3150 -- If overflow check, we want to surround the operator with curly
3151 -- brackets, but not include spaces within the brackets.
3164 Write_Str_Sloc (S (F .. T));
3167 if S (S'Last) = ' ' then
3173 -----------------------
3174 -- Write_Param_Specs --
3175 -----------------------
3177 procedure Write_Param_Specs (N : Node_Id) is
3183 Specs := Parameter_Specifications (N);
3185 if Is_Non_Empty_List (Specs) then
3186 Write_Str_With_Col_Check (" (");
3187 Spec := First (Specs);
3191 Formal := Defining_Identifier (Spec);
3193 exit when Spec = Empty;
3195 -- Add semicolon, unless we are printing original tree and the
3196 -- next specification is part of a list (but not the first
3197 -- element of that list)
3199 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3204 -- Write out any extra formals
3206 while Present (Extra_Formal (Formal)) loop
3207 Formal := Extra_Formal (Formal);
3209 Write_Name_With_Col_Check (Chars (Formal));
3211 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3216 end Write_Param_Specs;
3218 --------------------------
3219 -- Write_Rewrite_Str --
3220 --------------------------
3222 procedure Write_Rewrite_Str (S : String) is
3224 if not Dump_Generated_Only then
3225 if S'Length = 3 and then S = ">>>" then
3228 Write_Str_With_Col_Check (S);
3231 end Write_Rewrite_Str;
3233 --------------------
3234 -- Write_Str_Sloc --
3235 --------------------
3237 procedure Write_Str_Sloc (S : String) is
3239 for J in S'Range loop
3240 Write_Char_Sloc (S (J));
3244 ------------------------------
3245 -- Write_Str_With_Col_Check --
3246 ------------------------------
3248 procedure Write_Str_With_Col_Check (S : String) is
3250 if Int (S'Last) + Column > Line_Limit then
3251 Write_Indent_Str (" ");
3254 Write_Str (S (2 .. S'Length));
3262 end Write_Str_With_Col_Check;
3264 -----------------------------------
3265 -- Write_Str_With_Col_Check_Sloc --
3266 -----------------------------------
3268 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3270 if Int (S'Last) + Column > Line_Limit then
3271 Write_Indent_Str (" ");
3274 Write_Str_Sloc (S (2 .. S'Length));
3282 end Write_Str_With_Col_Check_Sloc;
3284 ------------------------------------
3285 -- Write_Uint_With_Col_Check_Sloc --
3286 ------------------------------------
3288 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3290 Col_Check (UI_Decimal_Digits_Hi (U));
3292 UI_Write (U, Format);
3293 end Write_Uint_With_Col_Check_Sloc;
3295 -------------------------------------
3296 -- Write_Ureal_With_Col_Check_Sloc --
3297 -------------------------------------
3299 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3300 D : constant Uint := Denominator (U);
3301 N : constant Uint := Numerator (U);
3305 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3308 end Write_Ureal_With_Col_Check_Sloc;