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 =>
740 if Null_Exclusion_Present (Node) then
741 Write_Str ("not null ");
744 Write_Str_With_Col_Check_Sloc ("access ");
746 if Protected_Present (Node) then
747 Write_Str_With_Col_Check ("protected ");
750 Write_Str_With_Col_Check ("procedure");
751 Write_Param_Specs (Node);
753 when N_Access_To_Object_Definition =>
754 Write_Str_With_Col_Check_Sloc ("access ");
756 if All_Present (Node) then
757 Write_Str_With_Col_Check ("all ");
758 elsif Constant_Present (Node) then
759 Write_Str_With_Col_Check ("constant ");
764 if Null_Exclusion_Present (Node) then
765 Write_Str ("not null ");
768 Sprint_Node (Subtype_Indication (Node));
771 if Null_Record_Present (Node) then
772 Write_Str_With_Col_Check_Sloc ("(null record)");
775 Write_Str_With_Col_Check_Sloc ("(");
777 if Present (Expressions (Node)) then
778 Sprint_Comma_List (Expressions (Node));
780 if Present (Component_Associations (Node)) then
785 if Present (Component_Associations (Node)) then
792 Nd := First (Component_Associations (Node));
800 if not Is_Rewrite_Insertion (Nd)
801 or else not Dump_Original_Only
815 Write_Str_With_Col_Check_Sloc ("new ");
818 if Null_Exclusion_Present (Node) then
819 Write_Str ("not null ");
822 Sprint_Node (Expression (Node));
824 if Present (Storage_Pool (Node)) then
825 Write_Str_With_Col_Check ("[storage_pool = ");
826 Sprint_Node (Storage_Pool (Node));
831 Sprint_Left_Opnd (Node);
832 Write_Str_Sloc (" and then ");
833 Sprint_Right_Opnd (Node);
836 Write_Indent_Str_Sloc ("for ");
837 Write_Id (Identifier (Node));
838 Write_Str_With_Col_Check (" use at ");
839 Sprint_Node (Expression (Node));
842 when N_Assignment_Statement =>
844 Sprint_Node (Name (Node));
845 Write_Str_Sloc (" := ");
846 Sprint_Node (Expression (Node));
849 when N_Asynchronous_Select =>
850 Write_Indent_Str_Sloc ("select");
852 Sprint_Node (Triggering_Alternative (Node));
855 -- Note: let the printing of Abortable_Part handle outputting
856 -- the ABORT keyword, so that the Slco can be set correctly.
858 Write_Indent_Str ("then ");
859 Sprint_Node (Abortable_Part (Node));
860 Write_Indent_Str ("end select;");
862 when N_Attribute_Definition_Clause =>
863 Write_Indent_Str_Sloc ("for ");
864 Sprint_Node (Name (Node));
866 Write_Name_With_Col_Check (Chars (Node));
867 Write_Str_With_Col_Check (" use ");
868 Sprint_Node (Expression (Node));
871 when N_Attribute_Reference =>
872 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
876 Sprint_Node (Prefix (Node));
877 Write_Char_Sloc (''');
878 Write_Name_With_Col_Check (Attribute_Name (Node));
879 Sprint_Paren_Comma_List (Expressions (Node));
881 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
885 when N_Block_Statement =>
888 if Present (Identifier (Node))
889 and then (not Has_Created_Identifier (Node)
890 or else not Dump_Original_Only)
892 Write_Rewrite_Str ("<<<");
893 Write_Id (Identifier (Node));
895 Write_Rewrite_Str (">>>");
898 if Present (Declarations (Node)) then
899 Write_Str_With_Col_Check_Sloc ("declare");
900 Sprint_Indented_List (Declarations (Node));
904 Write_Str_With_Col_Check_Sloc ("begin");
905 Sprint_Node (Handled_Statement_Sequence (Node));
906 Write_Indent_Str ("end");
908 if Present (Identifier (Node))
909 and then (not Has_Created_Identifier (Node)
910 or else not Dump_Original_Only)
912 Write_Rewrite_Str ("<<<");
914 Write_Id (Identifier (Node));
915 Write_Rewrite_Str (">>>");
920 when N_Case_Statement =>
921 Write_Indent_Str_Sloc ("case ");
922 Sprint_Node (Expression (Node));
924 Sprint_Indented_List (Alternatives (Node));
925 Write_Indent_Str ("end case;");
927 when N_Case_Statement_Alternative =>
928 Write_Indent_Str_Sloc ("when ");
929 Sprint_Bar_List (Discrete_Choices (Node));
931 Sprint_Indented_List (Statements (Node));
933 when N_Character_Literal =>
935 Write_Indent_Str (" ");
938 Write_Char_Sloc (''');
939 Write_Char_Code (Char_Literal_Value (Node));
942 when N_Code_Statement =>
945 Sprint_Node (Expression (Node));
948 when N_Compilation_Unit =>
949 Sprint_Node_List (Context_Items (Node));
950 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
952 if Private_Present (Node) then
953 Write_Indent_Str ("private ");
957 Sprint_Node_Sloc (Unit (Node));
959 if Present (Actions (Aux_Decls_Node (Node)))
961 Present (Pragmas_After (Aux_Decls_Node (Node)))
966 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
967 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
969 when N_Compilation_Unit_Aux =>
970 null; -- nothing to do, never used, see above
972 when N_Component_Association =>
974 Sprint_Bar_List (Choices (Node));
977 -- Ada 0Y (AI-287): Print the mbox if present
979 if Box_Present (Node) then
980 Write_Str_With_Col_Check ("<>");
982 Sprint_Node (Expression (Node));
985 when N_Component_Clause =>
987 Sprint_Node (Component_Name (Node));
988 Write_Str_Sloc (" at ");
989 Sprint_Node (Position (Node));
991 Write_Str_With_Col_Check ("range ");
992 Sprint_Node (First_Bit (Node));
994 Sprint_Node (Last_Bit (Node));
997 when N_Component_Definition =>
1000 -- Ada 0Y (AI-230): Access definition components
1002 if Present (Access_Definition (Node)) then
1003 Sprint_Node (Access_Definition (Node));
1005 elsif Present (Subtype_Indication (Node)) then
1006 if Aliased_Present (Node) then
1007 Write_Str_With_Col_Check ("aliased ");
1012 if Null_Exclusion_Present (Node) then
1013 Write_Str (" not null ");
1016 Sprint_Node (Subtype_Indication (Node));
1018 pragma Assert (False);
1022 when N_Component_Declaration =>
1023 if Write_Indent_Identifiers_Sloc (Node) then
1025 Sprint_Node (Component_Definition (Node));
1027 if Present (Expression (Node)) then
1029 Sprint_Node (Expression (Node));
1035 when N_Component_List =>
1036 if Null_Present (Node) then
1038 Write_Indent_Str_Sloc ("null");
1044 Sprint_Indented_List (Component_Items (Node));
1045 Sprint_Node (Variant_Part (Node));
1048 when N_Conditional_Entry_Call =>
1049 Write_Indent_Str_Sloc ("select");
1051 Sprint_Node (Entry_Call_Alternative (Node));
1053 Write_Indent_Str ("else");
1054 Sprint_Indented_List (Else_Statements (Node));
1055 Write_Indent_Str ("end select;");
1057 when N_Conditional_Expression =>
1059 Condition : constant Node_Id := First (Expressions (Node));
1060 Then_Expr : constant Node_Id := Next (Condition);
1061 Else_Expr : constant Node_Id := Next (Then_Expr);
1064 Write_Str_With_Col_Check_Sloc ("(if ");
1065 Sprint_Node (Condition);
1066 Write_Str_With_Col_Check (" then ");
1067 Sprint_Node (Then_Expr);
1068 Write_Str_With_Col_Check (" else ");
1069 Sprint_Node (Else_Expr);
1073 when N_Constrained_Array_Definition =>
1074 Write_Str_With_Col_Check_Sloc ("array ");
1075 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1078 Sprint_Node (Component_Definition (Node));
1080 when N_Decimal_Fixed_Point_Definition =>
1081 Write_Str_With_Col_Check_Sloc (" delta ");
1082 Sprint_Node (Delta_Expression (Node));
1083 Write_Str_With_Col_Check ("digits ");
1084 Sprint_Node (Digits_Expression (Node));
1085 Sprint_Opt_Node (Real_Range_Specification (Node));
1087 when N_Defining_Character_Literal =>
1088 Write_Name_With_Col_Check_Sloc (Chars (Node));
1090 when N_Defining_Identifier =>
1094 when N_Defining_Operator_Symbol =>
1095 Write_Name_With_Col_Check_Sloc (Chars (Node));
1097 when N_Defining_Program_Unit_Name =>
1099 Sprint_Node (Name (Node));
1101 Write_Id (Defining_Identifier (Node));
1103 when N_Delay_Alternative =>
1104 Sprint_Node_List (Pragmas_Before (Node));
1106 if Present (Condition (Node)) then
1108 Write_Str_With_Col_Check ("when ");
1109 Sprint_Node (Condition (Node));
1114 Sprint_Node_Sloc (Delay_Statement (Node));
1115 Sprint_Node_List (Statements (Node));
1117 when N_Delay_Relative_Statement =>
1118 Write_Indent_Str_Sloc ("delay ");
1119 Sprint_Node (Expression (Node));
1122 when N_Delay_Until_Statement =>
1123 Write_Indent_Str_Sloc ("delay until ");
1124 Sprint_Node (Expression (Node));
1127 when N_Delta_Constraint =>
1128 Write_Str_With_Col_Check_Sloc ("delta ");
1129 Sprint_Node (Delta_Expression (Node));
1130 Sprint_Opt_Node (Range_Constraint (Node));
1132 when N_Derived_Type_Definition =>
1133 if Abstract_Present (Node) then
1134 Write_Str_With_Col_Check ("abstract ");
1137 Write_Str_With_Col_Check_Sloc ("new ");
1141 if Null_Exclusion_Present (Node) then
1142 Write_Str_With_Col_Check ("not null ");
1145 Sprint_Node (Subtype_Indication (Node));
1147 if Present (Record_Extension_Part (Node)) then
1148 Write_Str_With_Col_Check (" with ");
1149 Sprint_Node (Record_Extension_Part (Node));
1152 when N_Designator =>
1153 Sprint_Node (Name (Node));
1154 Write_Char_Sloc ('.');
1155 Write_Id (Identifier (Node));
1157 when N_Digits_Constraint =>
1158 Write_Str_With_Col_Check_Sloc ("digits ");
1159 Sprint_Node (Digits_Expression (Node));
1160 Sprint_Opt_Node (Range_Constraint (Node));
1162 when N_Discriminant_Association =>
1165 if Present (Selector_Names (Node)) then
1166 Sprint_Bar_List (Selector_Names (Node));
1171 Sprint_Node (Expression (Node));
1173 when N_Discriminant_Specification =>
1176 if Write_Identifiers (Node) then
1179 if Null_Exclusion_Present (Node) then
1180 Write_Str ("not null ");
1183 Sprint_Node (Discriminant_Type (Node));
1185 if Present (Expression (Node)) then
1187 Sprint_Node (Expression (Node));
1193 when N_Elsif_Part =>
1194 Write_Indent_Str_Sloc ("elsif ");
1195 Sprint_Node (Condition (Node));
1196 Write_Str_With_Col_Check (" then");
1197 Sprint_Indented_List (Then_Statements (Node));
1202 when N_Entry_Body =>
1203 Write_Indent_Str_Sloc ("entry ");
1204 Write_Id (Defining_Identifier (Node));
1205 Sprint_Node (Entry_Body_Formal_Part (Node));
1206 Write_Str_With_Col_Check (" is");
1207 Sprint_Indented_List (Declarations (Node));
1208 Write_Indent_Str ("begin");
1209 Sprint_Node (Handled_Statement_Sequence (Node));
1210 Write_Indent_Str ("end ");
1211 Write_Id (Defining_Identifier (Node));
1214 when N_Entry_Body_Formal_Part =>
1215 if Present (Entry_Index_Specification (Node)) then
1216 Write_Str_With_Col_Check_Sloc (" (");
1217 Sprint_Node (Entry_Index_Specification (Node));
1221 Write_Param_Specs (Node);
1222 Write_Str_With_Col_Check_Sloc (" when ");
1223 Sprint_Node (Condition (Node));
1225 when N_Entry_Call_Alternative =>
1226 Sprint_Node_List (Pragmas_Before (Node));
1227 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1228 Sprint_Node_List (Statements (Node));
1230 when N_Entry_Call_Statement =>
1232 Sprint_Node_Sloc (Name (Node));
1233 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1236 when N_Entry_Declaration =>
1237 Write_Indent_Str_Sloc ("entry ");
1238 Write_Id (Defining_Identifier (Node));
1240 if Present (Discrete_Subtype_Definition (Node)) then
1241 Write_Str_With_Col_Check (" (");
1242 Sprint_Node (Discrete_Subtype_Definition (Node));
1246 Write_Param_Specs (Node);
1249 when N_Entry_Index_Specification =>
1250 Write_Str_With_Col_Check_Sloc ("for ");
1251 Write_Id (Defining_Identifier (Node));
1252 Write_Str_With_Col_Check (" in ");
1253 Sprint_Node (Discrete_Subtype_Definition (Node));
1255 when N_Enumeration_Representation_Clause =>
1256 Write_Indent_Str_Sloc ("for ");
1257 Write_Id (Identifier (Node));
1258 Write_Str_With_Col_Check (" use ");
1259 Sprint_Node (Array_Aggregate (Node));
1262 when N_Enumeration_Type_Definition =>
1265 -- Skip attempt to print Literals field if it's not there and
1266 -- we are in package Standard (case of Character, which is
1267 -- handled specially (without an explicit literals list).
1269 if Sloc (Node) > Standard_Location
1270 or else Present (Literals (Node))
1272 Sprint_Paren_Comma_List (Literals (Node));
1276 Write_Str_With_Col_Check_Sloc ("<error>");
1278 when N_Exception_Declaration =>
1279 if Write_Indent_Identifiers (Node) then
1280 Write_Str_With_Col_Check (" : ");
1281 Write_Str_Sloc ("exception;");
1284 when N_Exception_Handler =>
1285 Write_Indent_Str_Sloc ("when ");
1287 if Present (Choice_Parameter (Node)) then
1288 Sprint_Node (Choice_Parameter (Node));
1292 Sprint_Bar_List (Exception_Choices (Node));
1294 Sprint_Indented_List (Statements (Node));
1296 when N_Exception_Renaming_Declaration =>
1299 Sprint_Node (Defining_Identifier (Node));
1300 Write_Str_With_Col_Check (" : exception renames ");
1301 Sprint_Node (Name (Node));
1304 when N_Exit_Statement =>
1305 Write_Indent_Str_Sloc ("exit");
1306 Sprint_Opt_Node (Name (Node));
1308 if Present (Condition (Node)) then
1309 Write_Str_With_Col_Check (" when ");
1310 Sprint_Node (Condition (Node));
1315 when N_Expanded_Name =>
1316 Sprint_Node (Prefix (Node));
1317 Write_Char_Sloc ('.');
1318 Sprint_Node (Selector_Name (Node));
1320 when N_Explicit_Dereference =>
1321 Sprint_Node (Prefix (Node));
1322 Write_Char_Sloc ('.');
1323 Write_Str_Sloc ("all");
1325 when N_Extension_Aggregate =>
1326 Write_Str_With_Col_Check_Sloc ("(");
1327 Sprint_Node (Ancestor_Part (Node));
1328 Write_Str_With_Col_Check (" with ");
1330 if Null_Record_Present (Node) then
1331 Write_Str_With_Col_Check ("null record");
1333 if Present (Expressions (Node)) then
1334 Sprint_Comma_List (Expressions (Node));
1336 if Present (Component_Associations (Node)) then
1341 if Present (Component_Associations (Node)) then
1342 Sprint_Comma_List (Component_Associations (Node));
1348 when N_Floating_Point_Definition =>
1349 Write_Str_With_Col_Check_Sloc ("digits ");
1350 Sprint_Node (Digits_Expression (Node));
1351 Sprint_Opt_Node (Real_Range_Specification (Node));
1353 when N_Formal_Decimal_Fixed_Point_Definition =>
1354 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1356 when N_Formal_Derived_Type_Definition =>
1357 Write_Str_With_Col_Check_Sloc ("new ");
1358 Sprint_Node (Subtype_Mark (Node));
1360 if Private_Present (Node) then
1361 Write_Str_With_Col_Check (" with private");
1364 when N_Formal_Discrete_Type_Definition =>
1365 Write_Str_With_Col_Check_Sloc ("<>");
1367 when N_Formal_Floating_Point_Definition =>
1368 Write_Str_With_Col_Check_Sloc ("digits <>");
1370 when N_Formal_Modular_Type_Definition =>
1371 Write_Str_With_Col_Check_Sloc ("mod <>");
1373 when N_Formal_Object_Declaration =>
1376 if Write_Indent_Identifiers (Node) then
1379 if In_Present (Node) then
1380 Write_Str_With_Col_Check ("in ");
1383 if Out_Present (Node) then
1384 Write_Str_With_Col_Check ("out ");
1387 Sprint_Node (Subtype_Mark (Node));
1389 if Present (Expression (Node)) then
1391 Sprint_Node (Expression (Node));
1397 when N_Formal_Ordinary_Fixed_Point_Definition =>
1398 Write_Str_With_Col_Check_Sloc ("delta <>");
1400 when N_Formal_Package_Declaration =>
1401 Write_Indent_Str_Sloc ("with package ");
1402 Write_Id (Defining_Identifier (Node));
1403 Write_Str_With_Col_Check (" is new ");
1404 Sprint_Node (Name (Node));
1405 Write_Str_With_Col_Check (" (<>);");
1407 when N_Formal_Private_Type_Definition =>
1408 if Abstract_Present (Node) then
1409 Write_Str_With_Col_Check ("abstract ");
1412 if Tagged_Present (Node) then
1413 Write_Str_With_Col_Check ("tagged ");
1416 if Limited_Present (Node) then
1417 Write_Str_With_Col_Check ("limited ");
1420 Write_Str_With_Col_Check_Sloc ("private");
1422 when N_Formal_Signed_Integer_Type_Definition =>
1423 Write_Str_With_Col_Check_Sloc ("range <>");
1425 when N_Formal_Subprogram_Declaration =>
1426 Write_Indent_Str_Sloc ("with ");
1427 Sprint_Node (Specification (Node));
1429 if Box_Present (Node) then
1430 Write_Str_With_Col_Check (" is <>");
1431 elsif Present (Default_Name (Node)) then
1432 Write_Str_With_Col_Check (" is ");
1433 Sprint_Node (Default_Name (Node));
1438 when N_Formal_Type_Declaration =>
1439 Write_Indent_Str_Sloc ("type ");
1440 Write_Id (Defining_Identifier (Node));
1442 if Present (Discriminant_Specifications (Node)) then
1443 Write_Discr_Specs (Node);
1444 elsif Unknown_Discriminants_Present (Node) then
1445 Write_Str_With_Col_Check ("(<>)");
1448 Write_Str_With_Col_Check (" is ");
1449 Sprint_Node (Formal_Type_Definition (Node));
1452 when N_Free_Statement =>
1453 Write_Indent_Str_Sloc ("free ");
1454 Sprint_Node (Expression (Node));
1457 when N_Freeze_Entity =>
1458 if Dump_Original_Only then
1461 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1463 Write_Rewrite_Str ("<<<");
1464 Write_Str_With_Col_Check_Sloc ("freeze ");
1465 Write_Id (Entity (Node));
1468 if No (Actions (Node)) then
1472 Freeze_Indent := Freeze_Indent + 1;
1473 Sprint_Indented_List (Actions (Node));
1474 Freeze_Indent := Freeze_Indent - 1;
1475 Write_Indent_Str ("]");
1478 Write_Rewrite_Str (">>>");
1481 when N_Full_Type_Declaration =>
1482 Write_Indent_Str_Sloc ("type ");
1483 Write_Id (Defining_Identifier (Node));
1484 Write_Discr_Specs (Node);
1485 Write_Str_With_Col_Check (" is ");
1486 Sprint_Node (Type_Definition (Node));
1489 when N_Function_Call =>
1491 Sprint_Node (Name (Node));
1492 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1494 when N_Function_Instantiation =>
1495 Write_Indent_Str_Sloc ("function ");
1496 Sprint_Node (Defining_Unit_Name (Node));
1497 Write_Str_With_Col_Check (" is new ");
1498 Sprint_Node (Name (Node));
1499 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1502 when N_Function_Specification =>
1503 Write_Str_With_Col_Check_Sloc ("function ");
1504 Sprint_Node (Defining_Unit_Name (Node));
1505 Write_Param_Specs (Node);
1506 Write_Str_With_Col_Check (" return ");
1507 Sprint_Node (Subtype_Mark (Node));
1509 when N_Generic_Association =>
1512 if Present (Selector_Name (Node)) then
1513 Sprint_Node (Selector_Name (Node));
1517 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1519 when N_Generic_Function_Renaming_Declaration =>
1520 Write_Indent_Str_Sloc ("generic function ");
1521 Sprint_Node (Defining_Unit_Name (Node));
1522 Write_Str_With_Col_Check (" renames ");
1523 Sprint_Node (Name (Node));
1526 when N_Generic_Package_Declaration =>
1528 Write_Indent_Str_Sloc ("generic ");
1529 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1531 Sprint_Node (Specification (Node));
1534 when N_Generic_Package_Renaming_Declaration =>
1535 Write_Indent_Str_Sloc ("generic package ");
1536 Sprint_Node (Defining_Unit_Name (Node));
1537 Write_Str_With_Col_Check (" renames ");
1538 Sprint_Node (Name (Node));
1541 when N_Generic_Procedure_Renaming_Declaration =>
1542 Write_Indent_Str_Sloc ("generic procedure ");
1543 Sprint_Node (Defining_Unit_Name (Node));
1544 Write_Str_With_Col_Check (" renames ");
1545 Sprint_Node (Name (Node));
1548 when N_Generic_Subprogram_Declaration =>
1550 Write_Indent_Str_Sloc ("generic ");
1551 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1553 Sprint_Node (Specification (Node));
1556 when N_Goto_Statement =>
1557 Write_Indent_Str_Sloc ("goto ");
1558 Sprint_Node (Name (Node));
1561 if Nkind (Next (Node)) = N_Label then
1565 when N_Handled_Sequence_Of_Statements =>
1567 Sprint_Indented_List (Statements (Node));
1569 if Present (Exception_Handlers (Node)) then
1570 Write_Indent_Str ("exception");
1572 Sprint_Node_List (Exception_Handlers (Node));
1576 if Present (At_End_Proc (Node)) then
1577 Write_Indent_Str ("at end");
1580 Sprint_Node (At_End_Proc (Node));
1585 when N_Identifier =>
1589 when N_If_Statement =>
1590 Write_Indent_Str_Sloc ("if ");
1591 Sprint_Node (Condition (Node));
1592 Write_Str_With_Col_Check (" then");
1593 Sprint_Indented_List (Then_Statements (Node));
1594 Sprint_Opt_Node_List (Elsif_Parts (Node));
1596 if Present (Else_Statements (Node)) then
1597 Write_Indent_Str ("else");
1598 Sprint_Indented_List (Else_Statements (Node));
1601 Write_Indent_Str ("end if;");
1603 when N_Implicit_Label_Declaration =>
1604 if not Dump_Original_Only then
1606 Write_Rewrite_Str ("<<<");
1608 Write_Id (Defining_Identifier (Node));
1610 Write_Str_With_Col_Check ("label");
1611 Write_Rewrite_Str (">>>");
1615 Sprint_Left_Opnd (Node);
1616 Write_Str_Sloc (" in ");
1617 Sprint_Right_Opnd (Node);
1619 when N_Incomplete_Type_Declaration =>
1620 Write_Indent_Str_Sloc ("type ");
1621 Write_Id (Defining_Identifier (Node));
1623 if Present (Discriminant_Specifications (Node)) then
1624 Write_Discr_Specs (Node);
1625 elsif Unknown_Discriminants_Present (Node) then
1626 Write_Str_With_Col_Check ("(<>)");
1631 when N_Index_Or_Discriminant_Constraint =>
1633 Sprint_Paren_Comma_List (Constraints (Node));
1635 when N_Indexed_Component =>
1636 Sprint_Node_Sloc (Prefix (Node));
1637 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1639 when N_Integer_Literal =>
1640 if Print_In_Hex (Node) then
1641 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1643 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1646 when N_Iteration_Scheme =>
1647 if Present (Condition (Node)) then
1648 Write_Str_With_Col_Check_Sloc ("while ");
1649 Sprint_Node (Condition (Node));
1651 Write_Str_With_Col_Check_Sloc ("for ");
1652 Sprint_Node (Loop_Parameter_Specification (Node));
1657 when N_Itype_Reference =>
1658 Write_Indent_Str_Sloc ("reference ");
1659 Write_Id (Itype (Node));
1662 Write_Indent_Str_Sloc ("<<");
1663 Write_Id (Identifier (Node));
1666 when N_Loop_Parameter_Specification =>
1668 Write_Id (Defining_Identifier (Node));
1669 Write_Str_With_Col_Check (" in ");
1671 if Reverse_Present (Node) then
1672 Write_Str_With_Col_Check ("reverse ");
1675 Sprint_Node (Discrete_Subtype_Definition (Node));
1677 when N_Loop_Statement =>
1680 if Present (Identifier (Node))
1681 and then (not Has_Created_Identifier (Node)
1682 or else not Dump_Original_Only)
1684 Write_Rewrite_Str ("<<<");
1685 Write_Id (Identifier (Node));
1687 Write_Rewrite_Str (">>>");
1688 Sprint_Node (Iteration_Scheme (Node));
1689 Write_Str_With_Col_Check_Sloc ("loop");
1690 Sprint_Indented_List (Statements (Node));
1691 Write_Indent_Str ("end loop ");
1692 Write_Rewrite_Str ("<<<");
1693 Write_Id (Identifier (Node));
1694 Write_Rewrite_Str (">>>");
1698 Sprint_Node (Iteration_Scheme (Node));
1699 Write_Str_With_Col_Check_Sloc ("loop");
1700 Sprint_Indented_List (Statements (Node));
1701 Write_Indent_Str ("end loop;");
1704 when N_Mod_Clause =>
1705 Sprint_Node_List (Pragmas_Before (Node));
1706 Write_Str_With_Col_Check_Sloc ("at mod ");
1707 Sprint_Node (Expression (Node));
1709 when N_Modular_Type_Definition =>
1710 Write_Str_With_Col_Check_Sloc ("mod ");
1711 Sprint_Node (Expression (Node));
1714 Sprint_Left_Opnd (Node);
1715 Write_Str_Sloc (" not in ");
1716 Sprint_Right_Opnd (Node);
1719 Write_Str_With_Col_Check_Sloc ("null");
1721 when N_Null_Statement =>
1722 if Comes_From_Source (Node)
1723 or else Dump_Freeze_Null
1724 or else not Is_List_Member (Node)
1725 or else (No (Prev (Node)) and then No (Next (Node)))
1727 Write_Indent_Str_Sloc ("null;");
1730 when N_Number_Declaration =>
1733 if Write_Indent_Identifiers (Node) then
1734 Write_Str_With_Col_Check (" : constant ");
1736 Sprint_Node (Expression (Node));
1740 when N_Object_Declaration =>
1743 if Write_Indent_Identifiers (Node) then
1746 if Aliased_Present (Node) then
1747 Write_Str_With_Col_Check ("aliased ");
1750 if Constant_Present (Node) then
1751 Write_Str_With_Col_Check ("constant ");
1756 if Null_Exclusion_Present (Node) then
1757 Write_Str_With_Col_Check ("not null ");
1760 Sprint_Node (Object_Definition (Node));
1762 if Present (Expression (Node)) then
1764 Sprint_Node (Expression (Node));
1770 when N_Object_Renaming_Declaration =>
1773 Sprint_Node (Defining_Identifier (Node));
1776 -- Ada 0Y (AI-230): Access renamings
1778 if Present (Access_Definition (Node)) then
1779 Sprint_Node (Access_Definition (Node));
1781 elsif Present (Subtype_Mark (Node)) then
1782 Sprint_Node (Subtype_Mark (Node));
1785 pragma Assert (False);
1789 Write_Str_With_Col_Check (" renames ");
1790 Sprint_Node (Name (Node));
1794 Write_Operator (Node, "abs ");
1795 Sprint_Right_Opnd (Node);
1798 Sprint_Left_Opnd (Node);
1799 Write_Operator (Node, " + ");
1800 Sprint_Right_Opnd (Node);
1803 Sprint_Left_Opnd (Node);
1804 Write_Operator (Node, " and ");
1805 Sprint_Right_Opnd (Node);
1808 Sprint_Left_Opnd (Node);
1809 Write_Operator (Node, " & ");
1810 Sprint_Right_Opnd (Node);
1813 Sprint_Left_Opnd (Node);
1815 Process_TFAI_RR_Flags (Node);
1816 Write_Operator (Node, "/ ");
1817 Sprint_Right_Opnd (Node);
1820 Sprint_Left_Opnd (Node);
1821 Write_Operator (Node, " = ");
1822 Sprint_Right_Opnd (Node);
1825 Sprint_Left_Opnd (Node);
1826 Write_Operator (Node, " ** ");
1827 Sprint_Right_Opnd (Node);
1830 Sprint_Left_Opnd (Node);
1831 Write_Operator (Node, " >= ");
1832 Sprint_Right_Opnd (Node);
1835 Sprint_Left_Opnd (Node);
1836 Write_Operator (Node, " > ");
1837 Sprint_Right_Opnd (Node);
1840 Sprint_Left_Opnd (Node);
1841 Write_Operator (Node, " <= ");
1842 Sprint_Right_Opnd (Node);
1845 Sprint_Left_Opnd (Node);
1846 Write_Operator (Node, " < ");
1847 Sprint_Right_Opnd (Node);
1850 Write_Operator (Node, "-");
1851 Sprint_Right_Opnd (Node);
1854 Sprint_Left_Opnd (Node);
1856 if Treat_Fixed_As_Integer (Node) then
1860 Write_Operator (Node, " mod ");
1861 Sprint_Right_Opnd (Node);
1863 when N_Op_Multiply =>
1864 Sprint_Left_Opnd (Node);
1866 Process_TFAI_RR_Flags (Node);
1867 Write_Operator (Node, "* ");
1868 Sprint_Right_Opnd (Node);
1871 Sprint_Left_Opnd (Node);
1872 Write_Operator (Node, " /= ");
1873 Sprint_Right_Opnd (Node);
1876 Write_Operator (Node, "not ");
1877 Sprint_Right_Opnd (Node);
1880 Sprint_Left_Opnd (Node);
1881 Write_Operator (Node, " or ");
1882 Sprint_Right_Opnd (Node);
1885 Write_Operator (Node, "+");
1886 Sprint_Right_Opnd (Node);
1889 Sprint_Left_Opnd (Node);
1891 if Treat_Fixed_As_Integer (Node) then
1895 Write_Operator (Node, " rem ");
1896 Sprint_Right_Opnd (Node);
1902 Write_Str_With_Col_Check ("(");
1903 Sprint_Node (Left_Opnd (Node));
1905 Sprint_Node (Right_Opnd (Node));
1908 when N_Op_Subtract =>
1909 Sprint_Left_Opnd (Node);
1910 Write_Operator (Node, " - ");
1911 Sprint_Right_Opnd (Node);
1914 Sprint_Left_Opnd (Node);
1915 Write_Operator (Node, " xor ");
1916 Sprint_Right_Opnd (Node);
1918 when N_Operator_Symbol =>
1919 Write_Name_With_Col_Check_Sloc (Chars (Node));
1921 when N_Ordinary_Fixed_Point_Definition =>
1922 Write_Str_With_Col_Check_Sloc ("delta ");
1923 Sprint_Node (Delta_Expression (Node));
1924 Sprint_Opt_Node (Real_Range_Specification (Node));
1927 Sprint_Left_Opnd (Node);
1928 Write_Str_Sloc (" or else ");
1929 Sprint_Right_Opnd (Node);
1931 when N_Others_Choice =>
1932 if All_Others (Node) then
1933 Write_Str_With_Col_Check ("all ");
1936 Write_Str_With_Col_Check_Sloc ("others");
1938 when N_Package_Body =>
1940 Write_Indent_Str_Sloc ("package body ");
1941 Sprint_Node (Defining_Unit_Name (Node));
1943 Sprint_Indented_List (Declarations (Node));
1945 if Present (Handled_Statement_Sequence (Node)) then
1946 Write_Indent_Str ("begin");
1947 Sprint_Node (Handled_Statement_Sequence (Node));
1950 Write_Indent_Str ("end ");
1951 Sprint_Node (Defining_Unit_Name (Node));
1954 when N_Package_Body_Stub =>
1955 Write_Indent_Str_Sloc ("package body ");
1956 Sprint_Node (Defining_Identifier (Node));
1957 Write_Str_With_Col_Check (" is separate;");
1959 when N_Package_Declaration =>
1962 Sprint_Node_Sloc (Specification (Node));
1965 when N_Package_Instantiation =>
1967 Write_Indent_Str_Sloc ("package ");
1968 Sprint_Node (Defining_Unit_Name (Node));
1969 Write_Str (" is new ");
1970 Sprint_Node (Name (Node));
1971 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1974 when N_Package_Renaming_Declaration =>
1975 Write_Indent_Str_Sloc ("package ");
1976 Sprint_Node (Defining_Unit_Name (Node));
1977 Write_Str_With_Col_Check (" renames ");
1978 Sprint_Node (Name (Node));
1981 when N_Package_Specification =>
1982 Write_Str_With_Col_Check_Sloc ("package ");
1983 Sprint_Node (Defining_Unit_Name (Node));
1985 Sprint_Indented_List (Visible_Declarations (Node));
1987 if Present (Private_Declarations (Node)) then
1988 Write_Indent_Str ("private");
1989 Sprint_Indented_List (Private_Declarations (Node));
1992 Write_Indent_Str ("end ");
1993 Sprint_Node (Defining_Unit_Name (Node));
1995 when N_Parameter_Association =>
1996 Sprint_Node_Sloc (Selector_Name (Node));
1998 Sprint_Node (Explicit_Actual_Parameter (Node));
2000 when N_Parameter_Specification =>
2003 if Write_Identifiers (Node) then
2006 if In_Present (Node) then
2007 Write_Str_With_Col_Check ("in ");
2010 if Out_Present (Node) then
2011 Write_Str_With_Col_Check ("out ");
2016 if Null_Exclusion_Present (Node) then
2017 Write_Str ("not null ");
2020 Sprint_Node (Parameter_Type (Node));
2022 if Present (Expression (Node)) then
2024 Sprint_Node (Expression (Node));
2031 Write_Indent_Str_Sloc ("pragma ");
2032 Write_Name_With_Col_Check (Chars (Node));
2034 if Present (Pragma_Argument_Associations (Node)) then
2035 Sprint_Opt_Paren_Comma_List
2036 (Pragma_Argument_Associations (Node));
2041 when N_Pragma_Argument_Association =>
2044 if Chars (Node) /= No_Name then
2045 Write_Name_With_Col_Check (Chars (Node));
2049 Sprint_Node (Expression (Node));
2051 when N_Private_Type_Declaration =>
2052 Write_Indent_Str_Sloc ("type ");
2053 Write_Id (Defining_Identifier (Node));
2055 if Present (Discriminant_Specifications (Node)) then
2056 Write_Discr_Specs (Node);
2057 elsif Unknown_Discriminants_Present (Node) then
2058 Write_Str_With_Col_Check ("(<>)");
2063 if Tagged_Present (Node) then
2064 Write_Str_With_Col_Check ("tagged ");
2067 if Limited_Present (Node) then
2068 Write_Str_With_Col_Check ("limited ");
2071 Write_Str_With_Col_Check ("private;");
2073 when N_Private_Extension_Declaration =>
2074 Write_Indent_Str_Sloc ("type ");
2075 Write_Id (Defining_Identifier (Node));
2077 if Present (Discriminant_Specifications (Node)) then
2078 Write_Discr_Specs (Node);
2079 elsif Unknown_Discriminants_Present (Node) then
2080 Write_Str_With_Col_Check ("(<>)");
2083 Write_Str_With_Col_Check (" is new ");
2084 Sprint_Node (Subtype_Indication (Node));
2085 Write_Str_With_Col_Check (" with private;");
2087 when N_Procedure_Call_Statement =>
2090 Sprint_Node (Name (Node));
2091 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2094 when N_Procedure_Instantiation =>
2095 Write_Indent_Str_Sloc ("procedure ");
2096 Sprint_Node (Defining_Unit_Name (Node));
2097 Write_Str_With_Col_Check (" is new ");
2098 Sprint_Node (Name (Node));
2099 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2102 when N_Procedure_Specification =>
2103 Write_Str_With_Col_Check_Sloc ("procedure ");
2104 Sprint_Node (Defining_Unit_Name (Node));
2105 Write_Param_Specs (Node);
2107 when N_Protected_Body =>
2108 Write_Indent_Str_Sloc ("protected body ");
2109 Write_Id (Defining_Identifier (Node));
2111 Sprint_Indented_List (Declarations (Node));
2112 Write_Indent_Str ("end ");
2113 Write_Id (Defining_Identifier (Node));
2116 when N_Protected_Body_Stub =>
2117 Write_Indent_Str_Sloc ("protected body ");
2118 Write_Id (Defining_Identifier (Node));
2119 Write_Str_With_Col_Check (" is separate;");
2121 when N_Protected_Definition =>
2123 Sprint_Indented_List (Visible_Declarations (Node));
2125 if Present (Private_Declarations (Node)) then
2126 Write_Indent_Str ("private");
2127 Sprint_Indented_List (Private_Declarations (Node));
2130 Write_Indent_Str ("end ");
2132 when N_Protected_Type_Declaration =>
2133 Write_Indent_Str_Sloc ("protected type ");
2134 Write_Id (Defining_Identifier (Node));
2135 Write_Discr_Specs (Node);
2137 Sprint_Node (Protected_Definition (Node));
2138 Write_Id (Defining_Identifier (Node));
2141 when N_Qualified_Expression =>
2142 Sprint_Node (Subtype_Mark (Node));
2143 Write_Char_Sloc (''');
2145 -- Print expression, make sure we have at least one level of
2146 -- parentheses around the expression. For cases of qualified
2147 -- expressions in the source, this is always the case, but
2148 -- for generated qualifications, there may be no explicit
2149 -- parentheses present.
2151 if Paren_Count (Expression (Node)) /= 0 then
2152 Sprint_Node (Expression (Node));
2155 Sprint_Node (Expression (Node));
2159 when N_Raise_Constraint_Error =>
2161 -- This node can be used either as a subexpression or as a
2162 -- statement form. The following test is a reasonably reliable
2163 -- way to distinguish the two cases.
2165 if Is_List_Member (Node)
2166 and then Nkind (Parent (Node)) not in N_Subexpr
2171 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2172 Write_Condition_And_Reason (Node);
2174 when N_Raise_Program_Error =>
2176 -- This node can be used either as a subexpression or as a
2177 -- statement form. The following test is a reasonably reliable
2178 -- way to distinguish the two cases.
2180 if Is_List_Member (Node)
2181 and then Nkind (Parent (Node)) not in N_Subexpr
2186 Write_Str_With_Col_Check_Sloc ("[program_error");
2187 Write_Condition_And_Reason (Node);
2189 when N_Raise_Storage_Error =>
2191 -- This node can be used either as a subexpression or as a
2192 -- statement form. The following test is a reasonably reliable
2193 -- way to distinguish the two cases.
2195 if Is_List_Member (Node)
2196 and then Nkind (Parent (Node)) not in N_Subexpr
2201 Write_Str_With_Col_Check_Sloc ("[storage_error");
2202 Write_Condition_And_Reason (Node);
2204 when N_Raise_Statement =>
2205 Write_Indent_Str_Sloc ("raise ");
2206 Sprint_Node (Name (Node));
2210 Sprint_Node (Low_Bound (Node));
2211 Write_Str_Sloc (" .. ");
2212 Sprint_Node (High_Bound (Node));
2214 when N_Range_Constraint =>
2215 Write_Str_With_Col_Check_Sloc ("range ");
2216 Sprint_Node (Range_Expression (Node));
2218 when N_Real_Literal =>
2219 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2221 when N_Real_Range_Specification =>
2222 Write_Str_With_Col_Check_Sloc ("range ");
2223 Sprint_Node (Low_Bound (Node));
2225 Sprint_Node (High_Bound (Node));
2227 when N_Record_Definition =>
2228 if Abstract_Present (Node) then
2229 Write_Str_With_Col_Check ("abstract ");
2232 if Tagged_Present (Node) then
2233 Write_Str_With_Col_Check ("tagged ");
2236 if Limited_Present (Node) then
2237 Write_Str_With_Col_Check ("limited ");
2240 if Null_Present (Node) then
2241 Write_Str_With_Col_Check_Sloc ("null record");
2244 Write_Str_With_Col_Check_Sloc ("record");
2245 Sprint_Node (Component_List (Node));
2246 Write_Indent_Str ("end record");
2249 when N_Record_Representation_Clause =>
2250 Write_Indent_Str_Sloc ("for ");
2251 Sprint_Node (Identifier (Node));
2252 Write_Str_With_Col_Check (" use record ");
2254 if Present (Mod_Clause (Node)) then
2255 Sprint_Node (Mod_Clause (Node));
2258 Sprint_Indented_List (Component_Clauses (Node));
2259 Write_Indent_Str ("end record;");
2262 Sprint_Node (Prefix (Node));
2263 Write_Str_With_Col_Check_Sloc ("'reference");
2265 when N_Requeue_Statement =>
2266 Write_Indent_Str_Sloc ("requeue ");
2267 Sprint_Node (Name (Node));
2269 if Abort_Present (Node) then
2270 Write_Str_With_Col_Check (" with abort");
2275 when N_Return_Statement =>
2276 if Present (Expression (Node)) then
2277 Write_Indent_Str_Sloc ("return ");
2278 Sprint_Node (Expression (Node));
2281 Write_Indent_Str_Sloc ("return;");
2284 when N_Selective_Accept =>
2285 Write_Indent_Str_Sloc ("select");
2291 Alt_Node := First (Select_Alternatives (Node));
2294 Sprint_Node (Alt_Node);
2297 exit when No (Alt_Node);
2298 Write_Indent_Str ("or");
2302 if Present (Else_Statements (Node)) then
2303 Write_Indent_Str ("else");
2304 Sprint_Indented_List (Else_Statements (Node));
2307 Write_Indent_Str ("end select;");
2309 when N_Signed_Integer_Type_Definition =>
2310 Write_Str_With_Col_Check_Sloc ("range ");
2311 Sprint_Node (Low_Bound (Node));
2313 Sprint_Node (High_Bound (Node));
2315 when N_Single_Protected_Declaration =>
2316 Write_Indent_Str_Sloc ("protected ");
2317 Write_Id (Defining_Identifier (Node));
2319 Sprint_Node (Protected_Definition (Node));
2320 Write_Id (Defining_Identifier (Node));
2323 when N_Single_Task_Declaration =>
2324 Write_Indent_Str_Sloc ("task ");
2325 Write_Id (Defining_Identifier (Node));
2327 if Present (Task_Definition (Node)) then
2329 Sprint_Node (Task_Definition (Node));
2330 Write_Id (Defining_Identifier (Node));
2335 when N_Selected_Component =>
2336 Sprint_Node (Prefix (Node));
2337 Write_Char_Sloc ('.');
2338 Sprint_Node (Selector_Name (Node));
2342 Sprint_Node (Prefix (Node));
2343 Write_Str_With_Col_Check (" (");
2344 Sprint_Node (Discrete_Range (Node));
2347 when N_String_Literal =>
2348 if String_Length (Strval (Node)) + Column > 75 then
2349 Write_Indent_Str (" ");
2353 Write_String_Table_Entry (Strval (Node));
2355 when N_Subprogram_Body =>
2356 if Freeze_Indent = 0 then
2361 Sprint_Node_Sloc (Specification (Node));
2364 Sprint_Indented_List (Declarations (Node));
2365 Write_Indent_Str ("begin");
2366 Sprint_Node (Handled_Statement_Sequence (Node));
2368 Write_Indent_Str ("end ");
2369 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2372 if Is_List_Member (Node)
2373 and then Present (Next (Node))
2374 and then Nkind (Next (Node)) /= N_Subprogram_Body
2379 when N_Subprogram_Body_Stub =>
2381 Sprint_Node_Sloc (Specification (Node));
2382 Write_Str_With_Col_Check (" is separate;");
2384 when N_Subprogram_Declaration =>
2386 Sprint_Node_Sloc (Specification (Node));
2389 when N_Subprogram_Info =>
2390 Sprint_Node (Identifier (Node));
2391 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2393 when N_Subprogram_Renaming_Declaration =>
2395 Sprint_Node (Specification (Node));
2396 Write_Str_With_Col_Check_Sloc (" renames ");
2397 Sprint_Node (Name (Node));
2400 when N_Subtype_Declaration =>
2401 Write_Indent_Str_Sloc ("subtype ");
2402 Write_Id (Defining_Identifier (Node));
2407 if Null_Exclusion_Present (Node) then
2408 Write_Str ("not null ");
2411 Sprint_Node (Subtype_Indication (Node));
2414 when N_Subtype_Indication =>
2415 Sprint_Node_Sloc (Subtype_Mark (Node));
2417 Sprint_Node (Constraint (Node));
2420 Write_Indent_Str_Sloc ("separate (");
2421 Sprint_Node (Name (Node));
2424 Sprint_Node (Proper_Body (Node));
2427 Write_Indent_Str_Sloc ("task body ");
2428 Write_Id (Defining_Identifier (Node));
2430 Sprint_Indented_List (Declarations (Node));
2431 Write_Indent_Str ("begin");
2432 Sprint_Node (Handled_Statement_Sequence (Node));
2433 Write_Indent_Str ("end ");
2434 Write_Id (Defining_Identifier (Node));
2437 when N_Task_Body_Stub =>
2438 Write_Indent_Str_Sloc ("task body ");
2439 Write_Id (Defining_Identifier (Node));
2440 Write_Str_With_Col_Check (" is separate;");
2442 when N_Task_Definition =>
2444 Sprint_Indented_List (Visible_Declarations (Node));
2446 if Present (Private_Declarations (Node)) then
2447 Write_Indent_Str ("private");
2448 Sprint_Indented_List (Private_Declarations (Node));
2451 Write_Indent_Str ("end ");
2453 when N_Task_Type_Declaration =>
2454 Write_Indent_Str_Sloc ("task type ");
2455 Write_Id (Defining_Identifier (Node));
2456 Write_Discr_Specs (Node);
2458 if Present (Task_Definition (Node)) then
2460 Sprint_Node (Task_Definition (Node));
2461 Write_Id (Defining_Identifier (Node));
2466 when N_Terminate_Alternative =>
2467 Sprint_Node_List (Pragmas_Before (Node));
2471 if Present (Condition (Node)) then
2472 Write_Str_With_Col_Check ("when ");
2473 Sprint_Node (Condition (Node));
2477 Write_Str_With_Col_Check_Sloc ("terminate;");
2478 Sprint_Node_List (Pragmas_After (Node));
2480 when N_Timed_Entry_Call =>
2481 Write_Indent_Str_Sloc ("select");
2483 Sprint_Node (Entry_Call_Alternative (Node));
2485 Write_Indent_Str ("or");
2487 Sprint_Node (Delay_Alternative (Node));
2489 Write_Indent_Str ("end select;");
2491 when N_Triggering_Alternative =>
2492 Sprint_Node_List (Pragmas_Before (Node));
2493 Sprint_Node_Sloc (Triggering_Statement (Node));
2494 Sprint_Node_List (Statements (Node));
2496 when N_Type_Conversion =>
2498 Sprint_Node (Subtype_Mark (Node));
2501 if Conversion_OK (Node) then
2505 if Float_Truncate (Node) then
2509 if Rounded_Result (Node) then
2514 Sprint_Node (Expression (Node));
2517 when N_Unchecked_Expression =>
2520 Sprint_Node_Sloc (Expression (Node));
2523 when N_Unchecked_Type_Conversion =>
2524 Sprint_Node (Subtype_Mark (Node));
2526 Write_Str_With_Col_Check ("(");
2527 Sprint_Node_Sloc (Expression (Node));
2530 when N_Unconstrained_Array_Definition =>
2531 Write_Str_With_Col_Check_Sloc ("array (");
2537 Node1 := First (Subtype_Marks (Node));
2539 Sprint_Node (Node1);
2540 Write_Str_With_Col_Check (" range <>");
2542 exit when Node1 = Empty;
2547 Write_Str (") of ");
2548 Sprint_Node (Component_Definition (Node));
2550 when N_Unused_At_Start | N_Unused_At_End =>
2551 Write_Indent_Str ("***** Error, unused node encountered *****");
2554 when N_Use_Package_Clause =>
2555 Write_Indent_Str_Sloc ("use ");
2556 Sprint_Comma_List (Names (Node));
2559 when N_Use_Type_Clause =>
2560 Write_Indent_Str_Sloc ("use type ");
2561 Sprint_Comma_List (Subtype_Marks (Node));
2564 when N_Validate_Unchecked_Conversion =>
2565 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2566 Sprint_Node (Source_Type (Node));
2568 Sprint_Node (Target_Type (Node));
2572 Write_Indent_Str_Sloc ("when ");
2573 Sprint_Bar_List (Discrete_Choices (Node));
2575 Sprint_Node (Component_List (Node));
2577 when N_Variant_Part =>
2579 Write_Indent_Str_Sloc ("case ");
2580 Sprint_Node (Name (Node));
2582 Sprint_Indented_List (Variants (Node));
2583 Write_Indent_Str ("end case");
2586 when N_With_Clause =>
2588 -- Special test, if we are dumping the original tree only,
2589 -- then we want to eliminate the bogus with clauses that
2590 -- correspond to the non-existent children of Text_IO.
2592 if Dump_Original_Only
2593 and then Is_Text_IO_Kludge_Unit (Name (Node))
2597 -- Normal case, output the with clause
2600 if First_Name (Node) or else not Dump_Original_Only then
2602 -- Ada 0Y (AI-50217): Print limited with_clauses
2604 if Limited_Present (Node) then
2605 Write_Indent_Str ("limited with ");
2607 Write_Indent_Str ("with ");
2614 Sprint_Node_Sloc (Name (Node));
2616 if Last_Name (Node) or else not Dump_Original_Only then
2621 when N_With_Type_Clause =>
2622 Write_Indent_Str ("with type ");
2623 Sprint_Node_Sloc (Name (Node));
2625 if Tagged_Present (Node) then
2626 Write_Str (" is tagged;");
2628 Write_Str (" is access;");
2633 if Nkind (Node) in N_Subexpr
2634 and then Do_Range_Check (Node)
2639 for J in 1 .. Paren_Count (Node) loop
2643 pragma Assert (No (Debug_Node));
2644 Debug_Node := Save_Debug_Node;
2645 end Sprint_Node_Actual;
2647 ----------------------
2648 -- Sprint_Node_List --
2649 ----------------------
2651 procedure Sprint_Node_List (List : List_Id) is
2655 if Is_Non_Empty_List (List) then
2656 Node := First (List);
2661 exit when Node = Empty;
2664 end Sprint_Node_List;
2666 ----------------------
2667 -- Sprint_Node_Sloc --
2668 ----------------------
2670 procedure Sprint_Node_Sloc (Node : Node_Id) is
2674 if Present (Debug_Node) then
2675 Set_Sloc (Debug_Node, Sloc (Node));
2676 Debug_Node := Empty;
2678 end Sprint_Node_Sloc;
2680 ---------------------
2681 -- Sprint_Opt_Node --
2682 ---------------------
2684 procedure Sprint_Opt_Node (Node : Node_Id) is
2686 if Present (Node) then
2690 end Sprint_Opt_Node;
2692 --------------------------
2693 -- Sprint_Opt_Node_List --
2694 --------------------------
2696 procedure Sprint_Opt_Node_List (List : List_Id) is
2698 if Present (List) then
2699 Sprint_Node_List (List);
2701 end Sprint_Opt_Node_List;
2703 ---------------------------------
2704 -- Sprint_Opt_Paren_Comma_List --
2705 ---------------------------------
2707 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2709 if Is_Non_Empty_List (List) then
2711 Sprint_Paren_Comma_List (List);
2713 end Sprint_Opt_Paren_Comma_List;
2715 -----------------------------
2716 -- Sprint_Paren_Comma_List --
2717 -----------------------------
2719 procedure Sprint_Paren_Comma_List (List : List_Id) is
2721 Node_Exists : Boolean := False;
2725 if Is_Non_Empty_List (List) then
2727 if Dump_Original_Only then
2730 while Present (N) loop
2732 if not Is_Rewrite_Insertion (N) then
2733 Node_Exists := True;
2740 if not Node_Exists then
2745 Write_Str_With_Col_Check ("(");
2746 Sprint_Comma_List (List);
2749 end Sprint_Paren_Comma_List;
2751 ----------------------
2752 -- Sprint_Right_Opnd --
2753 ----------------------
2755 procedure Sprint_Right_Opnd (N : Node_Id) is
2756 Opnd : constant Node_Id := Right_Opnd (N);
2759 if Paren_Count (Opnd) /= 0
2760 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2769 end Sprint_Right_Opnd;
2771 ---------------------
2772 -- Write_Char_Sloc --
2773 ---------------------
2775 procedure Write_Char_Sloc (C : Character) is
2777 if Debug_Generated_Code and then C /= ' ' then
2782 end Write_Char_Sloc;
2784 --------------------------------
2785 -- Write_Condition_And_Reason --
2786 --------------------------------
2788 procedure Write_Condition_And_Reason (Node : Node_Id) is
2789 Image : constant String := RT_Exception_Code'Image
2790 (RT_Exception_Code'Val
2791 (UI_To_Int (Reason (Node))));
2794 if Present (Condition (Node)) then
2795 Write_Str_With_Col_Check (" when ");
2796 Sprint_Node (Condition (Node));
2801 for J in 4 .. Image'Last loop
2802 if Image (J) = '_' then
2805 Write_Char (Fold_Lower (Image (J)));
2810 end Write_Condition_And_Reason;
2812 ------------------------
2813 -- Write_Discr_Specs --
2814 ------------------------
2816 procedure Write_Discr_Specs (N : Node_Id) is
2821 Specs := Discriminant_Specifications (N);
2823 if Present (Specs) then
2824 Write_Str_With_Col_Check (" (");
2825 Spec := First (Specs);
2830 exit when Spec = Empty;
2832 -- Add semicolon, unless we are printing original tree and the
2833 -- next specification is part of a list (but not the first
2834 -- element of that list)
2836 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2843 end Write_Discr_Specs;
2849 procedure Write_Ekind (E : Entity_Id) is
2850 S : constant String := Entity_Kind'Image (Ekind (E));
2853 Name_Len := S'Length;
2854 Name_Buffer (1 .. Name_Len) := S;
2855 Set_Casing (Mixed_Case);
2856 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2863 procedure Write_Id (N : Node_Id) is
2865 -- Case of a defining identifier
2867 if Nkind (N) = N_Defining_Identifier then
2869 -- If defining identifier has an interface name (and no
2870 -- address clause), then we output the interface name.
2872 if (Is_Imported (N) or else Is_Exported (N))
2873 and then Present (Interface_Name (N))
2874 and then No (Address_Clause (N))
2876 String_To_Name_Buffer (Strval (Interface_Name (N)));
2877 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2879 -- If no interface name (or inactive because there was
2880 -- an address clause), then just output the Chars name.
2883 Write_Name_With_Col_Check (Chars (N));
2886 -- Case of selector of an expanded name where the expanded name
2887 -- has an associated entity, output this entity.
2889 elsif Nkind (Parent (N)) = N_Expanded_Name
2890 and then Selector_Name (Parent (N)) = N
2891 and then Present (Entity (Parent (N)))
2893 Write_Id (Entity (Parent (N)));
2895 -- For any other node with an associated entity, output it
2897 elsif Nkind (N) in N_Has_Entity
2898 and then Present (Entity_Or_Associated_Node (N))
2899 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2901 Write_Id (Entity (N));
2903 -- All other cases, we just print the Chars field
2906 Write_Name_With_Col_Check (Chars (N));
2910 -----------------------
2911 -- Write_Identifiers --
2912 -----------------------
2914 function Write_Identifiers (Node : Node_Id) return Boolean is
2916 Sprint_Node (Defining_Identifier (Node));
2918 -- The remainder of the declaration must be printed unless we are
2919 -- printing the original tree and this is not the last identifier
2922 not Dump_Original_Only or else not More_Ids (Node);
2924 end Write_Identifiers;
2926 ------------------------
2927 -- Write_Implicit_Def --
2928 ------------------------
2930 procedure Write_Implicit_Def (E : Entity_Id) is
2935 when E_Array_Subtype =>
2936 Write_Str_With_Col_Check ("subtype ");
2938 Write_Str_With_Col_Check (" is ");
2939 Write_Id (Base_Type (E));
2940 Write_Str_With_Col_Check (" (");
2942 Ind := First_Index (E);
2944 while Present (Ind) loop
2948 if Present (Ind) then
2955 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2956 Write_Str_With_Col_Check ("subtype ");
2959 Write_Id (Etype (E));
2960 Write_Str_With_Col_Check (" range ");
2961 Sprint_Node (Scalar_Range (E));
2965 Write_Str_With_Col_Check ("type ");
2967 Write_Str_With_Col_Check (" is <");
2972 end Write_Implicit_Def;
2978 procedure Write_Indent is
2980 if Indent_Annull_Flag then
2981 Indent_Annull_Flag := False;
2985 for J in 1 .. Indent loop
2991 ------------------------------
2992 -- Write_Indent_Identifiers --
2993 ------------------------------
2995 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
2997 -- We need to start a new line for every node, except in the case
2998 -- where we are printing the original tree and this is not the first
2999 -- defining identifier in the list.
3001 if not Dump_Original_Only or else not Prev_Ids (Node) then
3004 -- If printing original tree and this is not the first defining
3005 -- identifier in the list, then the previous call to this procedure
3006 -- printed only the name, and we add a comma to separate the names.
3012 Sprint_Node (Defining_Identifier (Node));
3014 -- The remainder of the declaration must be printed unless we are
3015 -- printing the original tree and this is not the last identifier
3018 not Dump_Original_Only or else not More_Ids (Node);
3020 end Write_Indent_Identifiers;
3022 -----------------------------------
3023 -- Write_Indent_Identifiers_Sloc --
3024 -----------------------------------
3026 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3028 -- We need to start a new line for every node, except in the case
3029 -- where we are printing the original tree and this is not the first
3030 -- defining identifier in the list.
3032 if not Dump_Original_Only or else not Prev_Ids (Node) then
3035 -- If printing original tree and this is not the first defining
3036 -- identifier in the list, then the previous call to this procedure
3037 -- printed only the name, and we add a comma to separate the names.
3044 Sprint_Node (Defining_Identifier (Node));
3046 -- The remainder of the declaration must be printed unless we are
3047 -- printing the original tree and this is not the last identifier
3050 not Dump_Original_Only or else not More_Ids (Node);
3052 end Write_Indent_Identifiers_Sloc;
3054 ----------------------
3055 -- Write_Indent_Str --
3056 ----------------------
3058 procedure Write_Indent_Str (S : String) is
3062 end Write_Indent_Str;
3064 ---------------------------
3065 -- Write_Indent_Str_Sloc --
3066 ---------------------------
3068 procedure Write_Indent_Str_Sloc (S : String) is
3072 end Write_Indent_Str_Sloc;
3074 -------------------------------
3075 -- Write_Name_With_Col_Check --
3076 -------------------------------
3078 procedure Write_Name_With_Col_Check (N : Name_Id) is
3082 Get_Name_String (N);
3084 -- Deal with -gnatI which replaces digits in an internal
3085 -- name by three dots (e.g. R7b becomes R...b).
3087 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3090 while J < Name_Len loop
3091 exit when Name_Buffer (J) not in 'A' .. 'Z';
3095 if Name_Buffer (J) in '0' .. '9' then
3096 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3099 while J <= Name_Len loop
3100 if Name_Buffer (J) not in '0' .. '9' then
3101 Write_Str (Name_Buffer (J .. Name_Len));
3113 -- Fall through for normal case
3115 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3116 end Write_Name_With_Col_Check;
3118 ------------------------------------
3119 -- Write_Name_With_Col_Check_Sloc --
3120 ------------------------------------
3122 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3124 Get_Name_String (N);
3125 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3126 end Write_Name_With_Col_Check_Sloc;
3128 --------------------
3129 -- Write_Operator --
3130 --------------------
3132 procedure Write_Operator (N : Node_Id; S : String) is
3133 F : Natural := S'First;
3134 T : Natural := S'Last;
3137 -- If no overflow check, just write string out, and we are done
3139 if not Do_Overflow_Check (N) then
3142 -- If overflow check, we want to surround the operator with curly
3143 -- brackets, but not include spaces within the brackets.
3156 Write_Str_Sloc (S (F .. T));
3159 if S (S'Last) = ' ' then
3165 -----------------------
3166 -- Write_Param_Specs --
3167 -----------------------
3169 procedure Write_Param_Specs (N : Node_Id) is
3175 Specs := Parameter_Specifications (N);
3177 if Is_Non_Empty_List (Specs) then
3178 Write_Str_With_Col_Check (" (");
3179 Spec := First (Specs);
3183 Formal := Defining_Identifier (Spec);
3185 exit when Spec = Empty;
3187 -- Add semicolon, unless we are printing original tree and the
3188 -- next specification is part of a list (but not the first
3189 -- element of that list)
3191 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3196 -- Write out any extra formals
3198 while Present (Extra_Formal (Formal)) loop
3199 Formal := Extra_Formal (Formal);
3201 Write_Name_With_Col_Check (Chars (Formal));
3203 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3208 end Write_Param_Specs;
3210 --------------------------
3211 -- Write_Rewrite_Str --
3212 --------------------------
3214 procedure Write_Rewrite_Str (S : String) is
3216 if not Dump_Generated_Only then
3217 if S'Length = 3 and then S = ">>>" then
3220 Write_Str_With_Col_Check (S);
3223 end Write_Rewrite_Str;
3225 --------------------
3226 -- Write_Str_Sloc --
3227 --------------------
3229 procedure Write_Str_Sloc (S : String) is
3231 for J in S'Range loop
3232 Write_Char_Sloc (S (J));
3236 ------------------------------
3237 -- Write_Str_With_Col_Check --
3238 ------------------------------
3240 procedure Write_Str_With_Col_Check (S : String) is
3242 if Int (S'Last) + Column > Line_Limit then
3243 Write_Indent_Str (" ");
3246 Write_Str (S (2 .. S'Length));
3254 end Write_Str_With_Col_Check;
3256 -----------------------------------
3257 -- Write_Str_With_Col_Check_Sloc --
3258 -----------------------------------
3260 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3262 if Int (S'Last) + Column > Line_Limit then
3263 Write_Indent_Str (" ");
3266 Write_Str_Sloc (S (2 .. S'Length));
3274 end Write_Str_With_Col_Check_Sloc;
3276 ------------------------------------
3277 -- Write_Uint_With_Col_Check_Sloc --
3278 ------------------------------------
3280 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3282 Col_Check (UI_Decimal_Digits_Hi (U));
3284 UI_Write (U, Format);
3285 end Write_Uint_With_Col_Check_Sloc;
3287 -------------------------------------
3288 -- Write_Ureal_With_Col_Check_Sloc --
3289 -------------------------------------
3291 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3292 D : constant Uint := Denominator (U);
3293 N : constant Uint := Numerator (U);
3297 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3300 end Write_Ureal_With_Col_Check_Sloc;