1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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_And_List (List : List_Id);
169 -- Print the given list with items separated by vertical "and"
171 procedure Sprint_Bar_List (List : List_Id);
172 -- Print the given list with items separated by vertical bars
174 procedure Sprint_Node_Actual (Node : Node_Id);
175 -- This routine prints its node argument. It is a lower level routine than
176 -- Sprint_Node, in that it does not bother about rewritten trees.
178 procedure Sprint_Node_Sloc (Node : Node_Id);
179 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
180 -- sets the Sloc of the current debug node to be a copy of the Sloc
181 -- of the sprinted node Node. Note that this is done after printing
182 -- Node, so that the Sloc is the proper updated value for the debug file.
184 procedure Write_Char_Sloc (C : Character);
185 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
186 -- called to ensure that the current node has a proper Sloc set.
188 procedure Write_Condition_And_Reason (Node : Node_Id);
189 -- Write Condition and Reason codes of Raise_xxx_Error node
191 procedure Write_Discr_Specs (N : Node_Id);
192 -- Ouput discriminant specification for node, which is any of the type
193 -- declarations that can have discriminants.
195 procedure Write_Ekind (E : Entity_Id);
196 -- Write the String corresponding to the Ekind without "E_".
198 procedure Write_Id (N : Node_Id);
199 -- N is a node with a Chars field. This procedure writes the name that
200 -- will be used in the generated code associated with the name. For a
201 -- node with no associated entity, this is simply the Chars field. For
202 -- the case where there is an entity associated with the node, we print
203 -- the name associated with the entity (since it may have been encoded).
204 -- One other special case is that an entity has an active external name
205 -- (i.e. an external name present with no address clause), then this
206 -- external name is output.
208 function Write_Identifiers (Node : Node_Id) return Boolean;
209 -- Handle node where the grammar has a list of defining identifiers, but
210 -- the tree has a separate declaration for each identifier. Handles the
211 -- printing of the defining identifier, and returns True if the type and
212 -- initialization information is to be printed, False if it is to be
213 -- skipped (the latter case happens when printing defining identifiers
214 -- other than the first in the original tree output case).
216 procedure Write_Implicit_Def (E : Entity_Id);
217 pragma Warnings (Off, Write_Implicit_Def);
218 -- Write the definition of the implicit type E according to its Ekind
219 -- For now a debugging procedure, but might be used in the future.
221 procedure Write_Indent;
222 -- Start a new line and write indentation spacing
224 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
225 -- Like Write_Identifiers except that each new printed declaration
226 -- is at the start of a new line.
228 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
229 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
230 -- mode, the Sloc of the current debug node is set to point ot the
231 -- first output identifier.
233 procedure Write_Indent_Str (S : String);
234 -- Start a new line and write indent spacing followed by given string
236 procedure Write_Indent_Str_Sloc (S : String);
237 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
238 -- the Sloc of the current node is set to the first non-blank character
241 procedure Write_Name_With_Col_Check (N : Name_Id);
242 -- Write name (using Write_Name) with initial column check, and possible
243 -- initial Write_Indent (to get new line) if current line is too full.
245 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
246 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
247 -- mode, sets Sloc of current debug node to first character of name.
249 procedure Write_Operator (N : Node_Id; S : String);
250 -- Like Write_Str_Sloc, used for operators, encloses the string in
251 -- characters {} if the Do_Overflow flag is set on the node N.
253 procedure Write_Param_Specs (N : Node_Id);
254 -- Output parameter specifications for node (which is either a function
255 -- or procedure specification with a Parameter_Specifications field)
257 procedure Write_Rewrite_Str (S : String);
258 -- Writes out a string (typically containing <<< or >>>}) for a node
259 -- created by rewriting the tree. Suppressed if we are outputting the
260 -- generated code only, since in this case we don't specially mark nodes
261 -- created by rewriting).
263 procedure Write_Str_Sloc (S : String);
264 -- Like Write_Str, but sets debug Sloc of current debug node to first
265 -- non-blank character if a current debug node is active.
267 procedure Write_Str_With_Col_Check (S : String);
268 -- Write string (using Write_Str) with initial column check, and possible
269 -- initial Write_Indent (to get new line) if current line is too full.
271 procedure Write_Str_With_Col_Check_Sloc (S : String);
272 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
273 -- node to first non-blank character if a current debug node is active.
275 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
276 -- Write Uint (using UI_Write) with initial column check, and possible
277 -- initial Write_Indent (to get new line) if current line is too full.
278 -- The format parameter determines the output format (see UI_Write).
279 -- In addition, in Debug_Generated_Code mode, sets the current node
280 -- Sloc to the first character of the output value.
282 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
283 -- Write Ureal (using same output format as UR_Write) with column checks
284 -- and a possible initial Write_Indent (to get new line) if current line
285 -- is too full. In addition, in Debug_Generated_Code mode, sets the
286 -- current node Sloc to the first character of the output value.
292 procedure Col_Check (N : Nat) is
294 if N + Column > Line_Limit then
295 Write_Indent_Str (" ");
303 procedure Indent_Annull is
305 Indent_Annull_Flag := True;
312 procedure Indent_Begin is
314 Indent := Indent + 3;
321 procedure Indent_End is
323 Indent := Indent - 3;
330 procedure pg (Node : Node_Id) is
332 Dump_Generated_Only := True;
333 Dump_Original_Only := False;
342 procedure po (Node : Node_Id) is
344 Dump_Generated_Only := False;
345 Dump_Original_Only := True;
350 ----------------------
351 -- Print_Debug_Line --
352 ----------------------
354 procedure Print_Debug_Line (S : String) is
356 Write_Debug_Line (S, Debug_Sloc);
357 end Print_Debug_Line;
359 ---------------------------
360 -- Process_TFAI_RR_Flags --
361 ---------------------------
363 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
365 if Treat_Fixed_As_Integer (Nod) then
369 if Rounded_Result (Nod) then
372 end Process_TFAI_RR_Flags;
378 procedure ps (Node : Node_Id) is
380 Dump_Generated_Only := False;
381 Dump_Original_Only := False;
390 procedure Set_Debug_Sloc is
392 if Present (Debug_Node) then
393 Set_Sloc (Debug_Node, Debug_Sloc + Source_Ptr (Column - 1));
402 procedure Source_Dump is
405 -- Put underline under string we just printed
407 procedure Underline is
408 Col : constant Int := Column;
413 while Col > Column loop
420 -- Start of processing for Tree_Dump.
423 Dump_Generated_Only := Debug_Flag_G or
424 Print_Generated_Code or
425 Debug_Generated_Code;
426 Dump_Original_Only := Debug_Flag_O;
427 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
429 -- Note that we turn off the tree dump flags immediately, before
430 -- starting the dump. This avoids generating two copies of the dump
431 -- if an abort occurs after printing the dump, and more importantly,
432 -- avoids an infinite loop if an abort occurs during the dump.
435 Debug_Flag_Z := False;
438 Write_Str ("Source recreated from tree of Standard (spec)");
440 Sprint_Node (Standard_Package_Node);
445 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
446 Debug_Flag_G := False;
447 Debug_Flag_O := False;
448 Debug_Flag_S := False;
450 -- Dump requested units
452 for U in Main_Unit .. Last_Unit loop
454 -- Dump all units if -gnatdf set, otherwise we dump only
455 -- the source files that are in the extended main source.
458 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
460 -- If we are generating debug files, setup to write them
462 if Debug_Generated_Code then
463 Set_Special_Output (Print_Debug_Line'Access);
464 Create_Debug_Source (Source_Index (U), Debug_Sloc);
465 Sprint_Node (Cunit (U));
468 Set_Special_Output (null);
470 -- Normal output to standard output file
473 Write_Str ("Source recreated from tree for ");
474 Write_Unit_Name (Unit_Name (U));
476 Sprint_Node (Cunit (U));
485 ---------------------
486 -- Sprint_And_List --
487 ---------------------
489 procedure Sprint_And_List (List : List_Id) is
492 if Is_Non_Empty_List (List) then
493 Node := First (List);
497 exit when Node = Empty;
503 ---------------------
504 -- Sprint_Bar_List --
505 ---------------------
507 procedure Sprint_Bar_List (List : List_Id) is
510 if Is_Non_Empty_List (List) then
511 Node := First (List);
515 exit when Node = Empty;
521 -----------------------
522 -- Sprint_Comma_List --
523 -----------------------
525 procedure Sprint_Comma_List (List : List_Id) is
529 if Is_Non_Empty_List (List) then
530 Node := First (List);
534 exit when Node = Empty;
536 if not Is_Rewrite_Insertion (Node)
537 or else not Dump_Original_Only
543 end Sprint_Comma_List;
545 --------------------------
546 -- Sprint_Indented_List --
547 --------------------------
549 procedure Sprint_Indented_List (List : List_Id) is
552 Sprint_Node_List (List);
554 end Sprint_Indented_List;
556 ---------------------
557 -- Sprint_Left_Opnd --
558 ---------------------
560 procedure Sprint_Left_Opnd (N : Node_Id) is
561 Opnd : constant Node_Id := Left_Opnd (N);
564 if Paren_Count (Opnd) /= 0
565 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
574 end Sprint_Left_Opnd;
580 procedure Sprint_Node (Node : Node_Id) is
582 if Is_Rewrite_Insertion (Node) then
583 if not Dump_Original_Only then
585 -- For special cases of nodes that always output <<< >>>
586 -- do not duplicate the output at this point.
588 if Nkind (Node) = N_Freeze_Entity
589 or else Nkind (Node) = N_Implicit_Label_Declaration
591 Sprint_Node_Actual (Node);
593 -- Normal case where <<< >>> may be required
596 Write_Rewrite_Str ("<<<");
597 Sprint_Node_Actual (Node);
598 Write_Rewrite_Str (">>>");
602 elsif Is_Rewrite_Substitution (Node) then
604 -- Case of dump generated only
606 if Dump_Generated_Only then
607 Sprint_Node_Actual (Node);
609 -- Case of dump original only
611 elsif Dump_Original_Only then
612 Sprint_Node_Actual (Original_Node (Node));
614 -- Case of both being dumped
617 Sprint_Node_Actual (Original_Node (Node));
618 Write_Rewrite_Str ("<<<");
619 Sprint_Node_Actual (Node);
620 Write_Rewrite_Str (">>>");
624 Sprint_Node_Actual (Node);
628 ------------------------
629 -- Sprint_Node_Actual --
630 ------------------------
632 procedure Sprint_Node_Actual (Node : Node_Id) is
633 Save_Debug_Node : constant Node_Id := Debug_Node;
640 for J in 1 .. Paren_Count (Node) loop
641 Write_Str_With_Col_Check ("(");
644 -- Setup node for Sloc fixup if writing a debug source file. Note
645 -- that we take care of any previous node not yet properly set.
647 if Debug_Generated_Code then
651 if Nkind (Node) in N_Subexpr
652 and then Do_Range_Check (Node)
654 Write_Str_With_Col_Check ("{");
657 -- Select print circuit based on node kind
661 when N_Abort_Statement =>
662 Write_Indent_Str_Sloc ("abort ");
663 Sprint_Comma_List (Names (Node));
666 when N_Abortable_Part =>
668 Write_Str_Sloc ("abort ");
669 Sprint_Indented_List (Statements (Node));
671 when N_Abstract_Subprogram_Declaration =>
673 Sprint_Node (Specification (Node));
674 Write_Str_With_Col_Check (" is ");
675 Write_Str_Sloc ("abstract;");
677 when N_Accept_Alternative =>
678 Sprint_Node_List (Pragmas_Before (Node));
680 if Present (Condition (Node)) then
681 Write_Indent_Str ("when ");
682 Sprint_Node (Condition (Node));
687 Sprint_Node_Sloc (Accept_Statement (Node));
688 Sprint_Node_List (Statements (Node));
690 when N_Accept_Statement =>
691 Write_Indent_Str_Sloc ("accept ");
692 Write_Id (Entry_Direct_Name (Node));
694 if Present (Entry_Index (Node)) then
695 Write_Str_With_Col_Check (" (");
696 Sprint_Node (Entry_Index (Node));
700 Write_Param_Specs (Node);
702 if Present (Handled_Statement_Sequence (Node)) then
703 Write_Str_With_Col_Check (" do");
704 Sprint_Node (Handled_Statement_Sequence (Node));
705 Write_Indent_Str ("end ");
706 Write_Id (Entry_Direct_Name (Node));
711 when N_Access_Definition =>
715 if Present (Access_To_Subprogram_Definition (Node)) then
716 Sprint_Node (Access_To_Subprogram_Definition (Node));
720 if Null_Exclusion_Present (Node) then
721 Write_Str ("not null ");
724 Write_Str_With_Col_Check_Sloc ("access ");
726 if All_Present (Node) then
728 elsif Constant_Present (Node) then
729 Write_Str ("constant ");
732 Sprint_Node (Subtype_Mark (Node));
735 when N_Access_Function_Definition =>
739 if Null_Exclusion_Present (Node) then
740 Write_Str ("not null ");
743 Write_Str_With_Col_Check_Sloc ("access ");
745 if Protected_Present (Node) then
746 Write_Str_With_Col_Check ("protected ");
749 Write_Str_With_Col_Check ("function");
750 Write_Param_Specs (Node);
751 Write_Str_With_Col_Check (" return ");
752 Sprint_Node (Subtype_Mark (Node));
754 when N_Access_Procedure_Definition =>
758 if Null_Exclusion_Present (Node) then
759 Write_Str ("not null ");
762 Write_Str_With_Col_Check_Sloc ("access ");
764 if Protected_Present (Node) then
765 Write_Str_With_Col_Check ("protected ");
768 Write_Str_With_Col_Check ("procedure");
769 Write_Param_Specs (Node);
771 when N_Access_To_Object_Definition =>
772 Write_Str_With_Col_Check_Sloc ("access ");
774 if All_Present (Node) then
775 Write_Str_With_Col_Check ("all ");
776 elsif Constant_Present (Node) then
777 Write_Str_With_Col_Check ("constant ");
782 if Null_Exclusion_Present (Node) then
783 Write_Str ("not null ");
786 Sprint_Node (Subtype_Indication (Node));
789 if Null_Record_Present (Node) then
790 Write_Str_With_Col_Check_Sloc ("(null record)");
793 Write_Str_With_Col_Check_Sloc ("(");
795 if Present (Expressions (Node)) then
796 Sprint_Comma_List (Expressions (Node));
798 if Present (Component_Associations (Node)) then
803 if Present (Component_Associations (Node)) then
810 Nd := First (Component_Associations (Node));
818 if not Is_Rewrite_Insertion (Nd)
819 or else not Dump_Original_Only
833 Write_Str_With_Col_Check_Sloc ("new ");
837 if Null_Exclusion_Present (Node) then
838 Write_Str ("not null ");
841 Sprint_Node (Expression (Node));
843 if Present (Storage_Pool (Node)) then
844 Write_Str_With_Col_Check ("[storage_pool = ");
845 Sprint_Node (Storage_Pool (Node));
850 Sprint_Left_Opnd (Node);
851 Write_Str_Sloc (" and then ");
852 Sprint_Right_Opnd (Node);
855 Write_Indent_Str_Sloc ("for ");
856 Write_Id (Identifier (Node));
857 Write_Str_With_Col_Check (" use at ");
858 Sprint_Node (Expression (Node));
861 when N_Assignment_Statement =>
863 Sprint_Node (Name (Node));
864 Write_Str_Sloc (" := ");
865 Sprint_Node (Expression (Node));
868 when N_Asynchronous_Select =>
869 Write_Indent_Str_Sloc ("select");
871 Sprint_Node (Triggering_Alternative (Node));
874 -- Note: let the printing of Abortable_Part handle outputting
875 -- the ABORT keyword, so that the Slco can be set correctly.
877 Write_Indent_Str ("then ");
878 Sprint_Node (Abortable_Part (Node));
879 Write_Indent_Str ("end select;");
881 when N_Attribute_Definition_Clause =>
882 Write_Indent_Str_Sloc ("for ");
883 Sprint_Node (Name (Node));
885 Write_Name_With_Col_Check (Chars (Node));
886 Write_Str_With_Col_Check (" use ");
887 Sprint_Node (Expression (Node));
890 when N_Attribute_Reference =>
891 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
895 Sprint_Node (Prefix (Node));
896 Write_Char_Sloc (''');
897 Write_Name_With_Col_Check (Attribute_Name (Node));
898 Sprint_Paren_Comma_List (Expressions (Node));
900 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
904 when N_Block_Statement =>
907 if Present (Identifier (Node))
908 and then (not Has_Created_Identifier (Node)
909 or else not Dump_Original_Only)
911 Write_Rewrite_Str ("<<<");
912 Write_Id (Identifier (Node));
914 Write_Rewrite_Str (">>>");
917 if Present (Declarations (Node)) then
918 Write_Str_With_Col_Check_Sloc ("declare");
919 Sprint_Indented_List (Declarations (Node));
923 Write_Str_With_Col_Check_Sloc ("begin");
924 Sprint_Node (Handled_Statement_Sequence (Node));
925 Write_Indent_Str ("end");
927 if Present (Identifier (Node))
928 and then (not Has_Created_Identifier (Node)
929 or else not Dump_Original_Only)
931 Write_Rewrite_Str ("<<<");
933 Write_Id (Identifier (Node));
934 Write_Rewrite_Str (">>>");
939 when N_Case_Statement =>
940 Write_Indent_Str_Sloc ("case ");
941 Sprint_Node (Expression (Node));
943 Sprint_Indented_List (Alternatives (Node));
944 Write_Indent_Str ("end case;");
946 when N_Case_Statement_Alternative =>
947 Write_Indent_Str_Sloc ("when ");
948 Sprint_Bar_List (Discrete_Choices (Node));
950 Sprint_Indented_List (Statements (Node));
952 when N_Character_Literal =>
954 Write_Indent_Str (" ");
957 Write_Char_Sloc (''');
958 Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
961 when N_Code_Statement =>
964 Sprint_Node (Expression (Node));
967 when N_Compilation_Unit =>
968 Sprint_Node_List (Context_Items (Node));
969 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
971 if Private_Present (Node) then
972 Write_Indent_Str ("private ");
976 Sprint_Node_Sloc (Unit (Node));
978 if Present (Actions (Aux_Decls_Node (Node)))
980 Present (Pragmas_After (Aux_Decls_Node (Node)))
985 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
986 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
988 when N_Compilation_Unit_Aux =>
989 null; -- nothing to do, never used, see above
991 when N_Component_Association =>
993 Sprint_Bar_List (Choices (Node));
996 -- Ada 2005 (AI-287): Print the mbox if present
998 if Box_Present (Node) then
999 Write_Str_With_Col_Check ("<>");
1001 Sprint_Node (Expression (Node));
1004 when N_Component_Clause =>
1006 Sprint_Node (Component_Name (Node));
1007 Write_Str_Sloc (" at ");
1008 Sprint_Node (Position (Node));
1010 Write_Str_With_Col_Check ("range ");
1011 Sprint_Node (First_Bit (Node));
1013 Sprint_Node (Last_Bit (Node));
1016 when N_Component_Definition =>
1019 -- Ada 2005 (AI-230): Access definition components
1021 if Present (Access_Definition (Node)) then
1022 Sprint_Node (Access_Definition (Node));
1024 elsif Present (Subtype_Indication (Node)) then
1025 if Aliased_Present (Node) then
1026 Write_Str_With_Col_Check ("aliased ");
1029 -- Ada 2005 (AI-231)
1031 if Null_Exclusion_Present (Node) then
1032 Write_Str (" not null ");
1035 Sprint_Node (Subtype_Indication (Node));
1038 Write_Str (" ??? ");
1041 when N_Component_Declaration =>
1042 if Write_Indent_Identifiers_Sloc (Node) then
1044 Sprint_Node (Component_Definition (Node));
1046 if Present (Expression (Node)) then
1048 Sprint_Node (Expression (Node));
1054 when N_Component_List =>
1055 if Null_Present (Node) then
1057 Write_Indent_Str_Sloc ("null");
1063 Sprint_Indented_List (Component_Items (Node));
1064 Sprint_Node (Variant_Part (Node));
1067 when N_Conditional_Entry_Call =>
1068 Write_Indent_Str_Sloc ("select");
1070 Sprint_Node (Entry_Call_Alternative (Node));
1072 Write_Indent_Str ("else");
1073 Sprint_Indented_List (Else_Statements (Node));
1074 Write_Indent_Str ("end select;");
1076 when N_Conditional_Expression =>
1078 Condition : constant Node_Id := First (Expressions (Node));
1079 Then_Expr : constant Node_Id := Next (Condition);
1080 Else_Expr : constant Node_Id := Next (Then_Expr);
1083 Write_Str_With_Col_Check_Sloc ("(if ");
1084 Sprint_Node (Condition);
1085 Write_Str_With_Col_Check (" then ");
1086 Sprint_Node (Then_Expr);
1087 Write_Str_With_Col_Check (" else ");
1088 Sprint_Node (Else_Expr);
1092 when N_Constrained_Array_Definition =>
1093 Write_Str_With_Col_Check_Sloc ("array ");
1094 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1097 Sprint_Node (Component_Definition (Node));
1099 when N_Decimal_Fixed_Point_Definition =>
1100 Write_Str_With_Col_Check_Sloc (" delta ");
1101 Sprint_Node (Delta_Expression (Node));
1102 Write_Str_With_Col_Check ("digits ");
1103 Sprint_Node (Digits_Expression (Node));
1104 Sprint_Opt_Node (Real_Range_Specification (Node));
1106 when N_Defining_Character_Literal =>
1107 Write_Name_With_Col_Check_Sloc (Chars (Node));
1109 when N_Defining_Identifier =>
1113 when N_Defining_Operator_Symbol =>
1114 Write_Name_With_Col_Check_Sloc (Chars (Node));
1116 when N_Defining_Program_Unit_Name =>
1118 Sprint_Node (Name (Node));
1120 Write_Id (Defining_Identifier (Node));
1122 when N_Delay_Alternative =>
1123 Sprint_Node_List (Pragmas_Before (Node));
1125 if Present (Condition (Node)) then
1127 Write_Str_With_Col_Check ("when ");
1128 Sprint_Node (Condition (Node));
1133 Sprint_Node_Sloc (Delay_Statement (Node));
1134 Sprint_Node_List (Statements (Node));
1136 when N_Delay_Relative_Statement =>
1137 Write_Indent_Str_Sloc ("delay ");
1138 Sprint_Node (Expression (Node));
1141 when N_Delay_Until_Statement =>
1142 Write_Indent_Str_Sloc ("delay until ");
1143 Sprint_Node (Expression (Node));
1146 when N_Delta_Constraint =>
1147 Write_Str_With_Col_Check_Sloc ("delta ");
1148 Sprint_Node (Delta_Expression (Node));
1149 Sprint_Opt_Node (Range_Constraint (Node));
1151 when N_Derived_Type_Definition =>
1152 if Abstract_Present (Node) then
1153 Write_Str_With_Col_Check ("abstract ");
1156 Write_Str_With_Col_Check_Sloc ("new ");
1158 -- Ada 2005 (AI-231)
1160 if Null_Exclusion_Present (Node) then
1161 Write_Str_With_Col_Check ("not null ");
1164 Sprint_Node (Subtype_Indication (Node));
1166 if Present (Interface_List (Node)) then
1167 Sprint_And_List (Interface_List (Node));
1168 Write_Str_With_Col_Check (" with ");
1171 if Present (Record_Extension_Part (Node)) then
1172 if No (Interface_List (Node)) then
1173 Write_Str_With_Col_Check (" with ");
1176 Sprint_Node (Record_Extension_Part (Node));
1179 when N_Designator =>
1180 Sprint_Node (Name (Node));
1181 Write_Char_Sloc ('.');
1182 Write_Id (Identifier (Node));
1184 when N_Digits_Constraint =>
1185 Write_Str_With_Col_Check_Sloc ("digits ");
1186 Sprint_Node (Digits_Expression (Node));
1187 Sprint_Opt_Node (Range_Constraint (Node));
1189 when N_Discriminant_Association =>
1192 if Present (Selector_Names (Node)) then
1193 Sprint_Bar_List (Selector_Names (Node));
1198 Sprint_Node (Expression (Node));
1200 when N_Discriminant_Specification =>
1203 if Write_Identifiers (Node) then
1206 if Null_Exclusion_Present (Node) then
1207 Write_Str ("not null ");
1210 Sprint_Node (Discriminant_Type (Node));
1212 if Present (Expression (Node)) then
1214 Sprint_Node (Expression (Node));
1220 when N_Elsif_Part =>
1221 Write_Indent_Str_Sloc ("elsif ");
1222 Sprint_Node (Condition (Node));
1223 Write_Str_With_Col_Check (" then");
1224 Sprint_Indented_List (Then_Statements (Node));
1229 when N_Entry_Body =>
1230 Write_Indent_Str_Sloc ("entry ");
1231 Write_Id (Defining_Identifier (Node));
1232 Sprint_Node (Entry_Body_Formal_Part (Node));
1233 Write_Str_With_Col_Check (" is");
1234 Sprint_Indented_List (Declarations (Node));
1235 Write_Indent_Str ("begin");
1236 Sprint_Node (Handled_Statement_Sequence (Node));
1237 Write_Indent_Str ("end ");
1238 Write_Id (Defining_Identifier (Node));
1241 when N_Entry_Body_Formal_Part =>
1242 if Present (Entry_Index_Specification (Node)) then
1243 Write_Str_With_Col_Check_Sloc (" (");
1244 Sprint_Node (Entry_Index_Specification (Node));
1248 Write_Param_Specs (Node);
1249 Write_Str_With_Col_Check_Sloc (" when ");
1250 Sprint_Node (Condition (Node));
1252 when N_Entry_Call_Alternative =>
1253 Sprint_Node_List (Pragmas_Before (Node));
1254 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1255 Sprint_Node_List (Statements (Node));
1257 when N_Entry_Call_Statement =>
1259 Sprint_Node_Sloc (Name (Node));
1260 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1263 when N_Entry_Declaration =>
1264 Write_Indent_Str_Sloc ("entry ");
1265 Write_Id (Defining_Identifier (Node));
1267 if Present (Discrete_Subtype_Definition (Node)) then
1268 Write_Str_With_Col_Check (" (");
1269 Sprint_Node (Discrete_Subtype_Definition (Node));
1273 Write_Param_Specs (Node);
1276 when N_Entry_Index_Specification =>
1277 Write_Str_With_Col_Check_Sloc ("for ");
1278 Write_Id (Defining_Identifier (Node));
1279 Write_Str_With_Col_Check (" in ");
1280 Sprint_Node (Discrete_Subtype_Definition (Node));
1282 when N_Enumeration_Representation_Clause =>
1283 Write_Indent_Str_Sloc ("for ");
1284 Write_Id (Identifier (Node));
1285 Write_Str_With_Col_Check (" use ");
1286 Sprint_Node (Array_Aggregate (Node));
1289 when N_Enumeration_Type_Definition =>
1292 -- Skip attempt to print Literals field if it's not there and
1293 -- we are in package Standard (case of Character, which is
1294 -- handled specially (without an explicit literals list).
1296 if Sloc (Node) > Standard_Location
1297 or else Present (Literals (Node))
1299 Sprint_Paren_Comma_List (Literals (Node));
1303 Write_Str_With_Col_Check_Sloc ("<error>");
1305 when N_Exception_Declaration =>
1306 if Write_Indent_Identifiers (Node) then
1307 Write_Str_With_Col_Check (" : ");
1308 Write_Str_Sloc ("exception;");
1311 when N_Exception_Handler =>
1312 Write_Indent_Str_Sloc ("when ");
1314 if Present (Choice_Parameter (Node)) then
1315 Sprint_Node (Choice_Parameter (Node));
1319 Sprint_Bar_List (Exception_Choices (Node));
1321 Sprint_Indented_List (Statements (Node));
1323 when N_Exception_Renaming_Declaration =>
1326 Sprint_Node (Defining_Identifier (Node));
1327 Write_Str_With_Col_Check (" : exception renames ");
1328 Sprint_Node (Name (Node));
1331 when N_Exit_Statement =>
1332 Write_Indent_Str_Sloc ("exit");
1333 Sprint_Opt_Node (Name (Node));
1335 if Present (Condition (Node)) then
1336 Write_Str_With_Col_Check (" when ");
1337 Sprint_Node (Condition (Node));
1342 when N_Expanded_Name =>
1343 Sprint_Node (Prefix (Node));
1344 Write_Char_Sloc ('.');
1345 Sprint_Node (Selector_Name (Node));
1347 when N_Explicit_Dereference =>
1348 Sprint_Node (Prefix (Node));
1349 Write_Char_Sloc ('.');
1350 Write_Str_Sloc ("all");
1352 when N_Extension_Aggregate =>
1353 Write_Str_With_Col_Check_Sloc ("(");
1354 Sprint_Node (Ancestor_Part (Node));
1355 Write_Str_With_Col_Check (" with ");
1357 if Null_Record_Present (Node) then
1358 Write_Str_With_Col_Check ("null record");
1360 if Present (Expressions (Node)) then
1361 Sprint_Comma_List (Expressions (Node));
1363 if Present (Component_Associations (Node)) then
1368 if Present (Component_Associations (Node)) then
1369 Sprint_Comma_List (Component_Associations (Node));
1375 when N_Floating_Point_Definition =>
1376 Write_Str_With_Col_Check_Sloc ("digits ");
1377 Sprint_Node (Digits_Expression (Node));
1378 Sprint_Opt_Node (Real_Range_Specification (Node));
1380 when N_Formal_Decimal_Fixed_Point_Definition =>
1381 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1383 when N_Formal_Derived_Type_Definition =>
1384 Write_Str_With_Col_Check_Sloc ("new ");
1385 Sprint_Node (Subtype_Mark (Node));
1387 if Private_Present (Node) then
1388 Write_Str_With_Col_Check (" with private");
1391 when N_Formal_Abstract_Subprogram_Declaration =>
1392 Write_Indent_Str_Sloc ("with ");
1393 Sprint_Node (Specification (Node));
1395 Write_Str_With_Col_Check (" is abstract");
1397 if Box_Present (Node) then
1398 Write_Str_With_Col_Check (" <>");
1399 elsif Present (Default_Name (Node)) then
1400 Write_Str_With_Col_Check (" ");
1401 Sprint_Node (Default_Name (Node));
1406 when N_Formal_Concrete_Subprogram_Declaration =>
1407 Write_Indent_Str_Sloc ("with ");
1408 Sprint_Node (Specification (Node));
1410 if Box_Present (Node) then
1411 Write_Str_With_Col_Check (" is <>");
1412 elsif Present (Default_Name (Node)) then
1413 Write_Str_With_Col_Check (" is ");
1414 Sprint_Node (Default_Name (Node));
1419 when N_Formal_Discrete_Type_Definition =>
1420 Write_Str_With_Col_Check_Sloc ("<>");
1422 when N_Formal_Floating_Point_Definition =>
1423 Write_Str_With_Col_Check_Sloc ("digits <>");
1425 when N_Formal_Modular_Type_Definition =>
1426 Write_Str_With_Col_Check_Sloc ("mod <>");
1428 when N_Formal_Object_Declaration =>
1431 if Write_Indent_Identifiers (Node) then
1434 if In_Present (Node) then
1435 Write_Str_With_Col_Check ("in ");
1438 if Out_Present (Node) then
1439 Write_Str_With_Col_Check ("out ");
1442 Sprint_Node (Subtype_Mark (Node));
1444 if Present (Expression (Node)) then
1446 Sprint_Node (Expression (Node));
1452 when N_Formal_Ordinary_Fixed_Point_Definition =>
1453 Write_Str_With_Col_Check_Sloc ("delta <>");
1455 when N_Formal_Package_Declaration =>
1456 Write_Indent_Str_Sloc ("with package ");
1457 Write_Id (Defining_Identifier (Node));
1458 Write_Str_With_Col_Check (" is new ");
1459 Sprint_Node (Name (Node));
1460 Write_Str_With_Col_Check (" (<>);");
1462 when N_Formal_Private_Type_Definition =>
1463 if Abstract_Present (Node) then
1464 Write_Str_With_Col_Check ("abstract ");
1467 if Tagged_Present (Node) then
1468 Write_Str_With_Col_Check ("tagged ");
1471 if Limited_Present (Node) then
1472 Write_Str_With_Col_Check ("limited ");
1475 Write_Str_With_Col_Check_Sloc ("private");
1477 when N_Formal_Signed_Integer_Type_Definition =>
1478 Write_Str_With_Col_Check_Sloc ("range <>");
1480 when N_Formal_Type_Declaration =>
1481 Write_Indent_Str_Sloc ("type ");
1482 Write_Id (Defining_Identifier (Node));
1484 if Present (Discriminant_Specifications (Node)) then
1485 Write_Discr_Specs (Node);
1486 elsif Unknown_Discriminants_Present (Node) then
1487 Write_Str_With_Col_Check ("(<>)");
1490 Write_Str_With_Col_Check (" is ");
1491 Sprint_Node (Formal_Type_Definition (Node));
1494 when N_Free_Statement =>
1495 Write_Indent_Str_Sloc ("free ");
1496 Sprint_Node (Expression (Node));
1499 when N_Freeze_Entity =>
1500 if Dump_Original_Only then
1503 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1505 Write_Rewrite_Str ("<<<");
1506 Write_Str_With_Col_Check_Sloc ("freeze ");
1507 Write_Id (Entity (Node));
1510 if No (Actions (Node)) then
1514 Freeze_Indent := Freeze_Indent + 1;
1515 Sprint_Indented_List (Actions (Node));
1516 Freeze_Indent := Freeze_Indent - 1;
1517 Write_Indent_Str ("]");
1520 Write_Rewrite_Str (">>>");
1523 when N_Full_Type_Declaration =>
1524 Write_Indent_Str_Sloc ("type ");
1525 Write_Id (Defining_Identifier (Node));
1526 Write_Discr_Specs (Node);
1527 Write_Str_With_Col_Check (" is ");
1528 Sprint_Node (Type_Definition (Node));
1531 when N_Function_Call =>
1533 Sprint_Node (Name (Node));
1534 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1536 when N_Function_Instantiation =>
1537 Write_Indent_Str_Sloc ("function ");
1538 Sprint_Node (Defining_Unit_Name (Node));
1539 Write_Str_With_Col_Check (" is new ");
1540 Sprint_Node (Name (Node));
1541 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1544 when N_Function_Specification =>
1545 Write_Str_With_Col_Check_Sloc ("function ");
1546 Sprint_Node (Defining_Unit_Name (Node));
1547 Write_Param_Specs (Node);
1548 Write_Str_With_Col_Check (" return ");
1549 Sprint_Node (Subtype_Mark (Node));
1551 when N_Generic_Association =>
1554 if Present (Selector_Name (Node)) then
1555 Sprint_Node (Selector_Name (Node));
1559 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1561 when N_Generic_Function_Renaming_Declaration =>
1562 Write_Indent_Str_Sloc ("generic function ");
1563 Sprint_Node (Defining_Unit_Name (Node));
1564 Write_Str_With_Col_Check (" renames ");
1565 Sprint_Node (Name (Node));
1568 when N_Generic_Package_Declaration =>
1570 Write_Indent_Str_Sloc ("generic ");
1571 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1573 Sprint_Node (Specification (Node));
1576 when N_Generic_Package_Renaming_Declaration =>
1577 Write_Indent_Str_Sloc ("generic package ");
1578 Sprint_Node (Defining_Unit_Name (Node));
1579 Write_Str_With_Col_Check (" renames ");
1580 Sprint_Node (Name (Node));
1583 when N_Generic_Procedure_Renaming_Declaration =>
1584 Write_Indent_Str_Sloc ("generic procedure ");
1585 Sprint_Node (Defining_Unit_Name (Node));
1586 Write_Str_With_Col_Check (" renames ");
1587 Sprint_Node (Name (Node));
1590 when N_Generic_Subprogram_Declaration =>
1592 Write_Indent_Str_Sloc ("generic ");
1593 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1595 Sprint_Node (Specification (Node));
1598 when N_Goto_Statement =>
1599 Write_Indent_Str_Sloc ("goto ");
1600 Sprint_Node (Name (Node));
1603 if Nkind (Next (Node)) = N_Label then
1607 when N_Handled_Sequence_Of_Statements =>
1609 Sprint_Indented_List (Statements (Node));
1611 if Present (Exception_Handlers (Node)) then
1612 Write_Indent_Str ("exception");
1614 Sprint_Node_List (Exception_Handlers (Node));
1618 if Present (At_End_Proc (Node)) then
1619 Write_Indent_Str ("at end");
1622 Sprint_Node (At_End_Proc (Node));
1627 when N_Identifier =>
1631 when N_If_Statement =>
1632 Write_Indent_Str_Sloc ("if ");
1633 Sprint_Node (Condition (Node));
1634 Write_Str_With_Col_Check (" then");
1635 Sprint_Indented_List (Then_Statements (Node));
1636 Sprint_Opt_Node_List (Elsif_Parts (Node));
1638 if Present (Else_Statements (Node)) then
1639 Write_Indent_Str ("else");
1640 Sprint_Indented_List (Else_Statements (Node));
1643 Write_Indent_Str ("end if;");
1645 when N_Implicit_Label_Declaration =>
1646 if not Dump_Original_Only then
1648 Write_Rewrite_Str ("<<<");
1650 Write_Id (Defining_Identifier (Node));
1652 Write_Str_With_Col_Check ("label");
1653 Write_Rewrite_Str (">>>");
1657 Sprint_Left_Opnd (Node);
1658 Write_Str_Sloc (" in ");
1659 Sprint_Right_Opnd (Node);
1661 when N_Incomplete_Type_Declaration =>
1662 Write_Indent_Str_Sloc ("type ");
1663 Write_Id (Defining_Identifier (Node));
1665 if Present (Discriminant_Specifications (Node)) then
1666 Write_Discr_Specs (Node);
1667 elsif Unknown_Discriminants_Present (Node) then
1668 Write_Str_With_Col_Check ("(<>)");
1673 when N_Index_Or_Discriminant_Constraint =>
1675 Sprint_Paren_Comma_List (Constraints (Node));
1677 when N_Indexed_Component =>
1678 Sprint_Node_Sloc (Prefix (Node));
1679 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1681 when N_Integer_Literal =>
1682 if Print_In_Hex (Node) then
1683 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1685 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1688 when N_Iteration_Scheme =>
1689 if Present (Condition (Node)) then
1690 Write_Str_With_Col_Check_Sloc ("while ");
1691 Sprint_Node (Condition (Node));
1693 Write_Str_With_Col_Check_Sloc ("for ");
1694 Sprint_Node (Loop_Parameter_Specification (Node));
1699 when N_Itype_Reference =>
1700 Write_Indent_Str_Sloc ("reference ");
1701 Write_Id (Itype (Node));
1704 Write_Indent_Str_Sloc ("<<");
1705 Write_Id (Identifier (Node));
1708 when N_Loop_Parameter_Specification =>
1710 Write_Id (Defining_Identifier (Node));
1711 Write_Str_With_Col_Check (" in ");
1713 if Reverse_Present (Node) then
1714 Write_Str_With_Col_Check ("reverse ");
1717 Sprint_Node (Discrete_Subtype_Definition (Node));
1719 when N_Loop_Statement =>
1722 if Present (Identifier (Node))
1723 and then (not Has_Created_Identifier (Node)
1724 or else not Dump_Original_Only)
1726 Write_Rewrite_Str ("<<<");
1727 Write_Id (Identifier (Node));
1729 Write_Rewrite_Str (">>>");
1730 Sprint_Node (Iteration_Scheme (Node));
1731 Write_Str_With_Col_Check_Sloc ("loop");
1732 Sprint_Indented_List (Statements (Node));
1733 Write_Indent_Str ("end loop ");
1734 Write_Rewrite_Str ("<<<");
1735 Write_Id (Identifier (Node));
1736 Write_Rewrite_Str (">>>");
1740 Sprint_Node (Iteration_Scheme (Node));
1741 Write_Str_With_Col_Check_Sloc ("loop");
1742 Sprint_Indented_List (Statements (Node));
1743 Write_Indent_Str ("end loop;");
1746 when N_Mod_Clause =>
1747 Sprint_Node_List (Pragmas_Before (Node));
1748 Write_Str_With_Col_Check_Sloc ("at mod ");
1749 Sprint_Node (Expression (Node));
1751 when N_Modular_Type_Definition =>
1752 Write_Str_With_Col_Check_Sloc ("mod ");
1753 Sprint_Node (Expression (Node));
1756 Sprint_Left_Opnd (Node);
1757 Write_Str_Sloc (" not in ");
1758 Sprint_Right_Opnd (Node);
1761 Write_Str_With_Col_Check_Sloc ("null");
1763 when N_Null_Statement =>
1764 if Comes_From_Source (Node)
1765 or else Dump_Freeze_Null
1766 or else not Is_List_Member (Node)
1767 or else (No (Prev (Node)) and then No (Next (Node)))
1769 Write_Indent_Str_Sloc ("null;");
1772 when N_Number_Declaration =>
1775 if Write_Indent_Identifiers (Node) then
1776 Write_Str_With_Col_Check (" : constant ");
1778 Sprint_Node (Expression (Node));
1782 when N_Object_Declaration =>
1785 if Write_Indent_Identifiers (Node) then
1788 if Aliased_Present (Node) then
1789 Write_Str_With_Col_Check ("aliased ");
1792 if Constant_Present (Node) then
1793 Write_Str_With_Col_Check ("constant ");
1796 -- Ada 2005 (AI-231)
1798 if Null_Exclusion_Present (Node) then
1799 Write_Str_With_Col_Check ("not null ");
1802 Sprint_Node (Object_Definition (Node));
1804 if Present (Expression (Node)) then
1806 Sprint_Node (Expression (Node));
1812 when N_Object_Renaming_Declaration =>
1815 Sprint_Node (Defining_Identifier (Node));
1818 -- Ada 2005 (AI-230): Access renamings
1820 if Present (Access_Definition (Node)) then
1821 Sprint_Node (Access_Definition (Node));
1823 elsif Present (Subtype_Mark (Node)) then
1824 Sprint_Node (Subtype_Mark (Node));
1827 Write_Str (" ??? ");
1830 Write_Str_With_Col_Check (" renames ");
1831 Sprint_Node (Name (Node));
1835 Write_Operator (Node, "abs ");
1836 Sprint_Right_Opnd (Node);
1839 Sprint_Left_Opnd (Node);
1840 Write_Operator (Node, " + ");
1841 Sprint_Right_Opnd (Node);
1844 Sprint_Left_Opnd (Node);
1845 Write_Operator (Node, " and ");
1846 Sprint_Right_Opnd (Node);
1849 Sprint_Left_Opnd (Node);
1850 Write_Operator (Node, " & ");
1851 Sprint_Right_Opnd (Node);
1854 Sprint_Left_Opnd (Node);
1856 Process_TFAI_RR_Flags (Node);
1857 Write_Operator (Node, "/ ");
1858 Sprint_Right_Opnd (Node);
1861 Sprint_Left_Opnd (Node);
1862 Write_Operator (Node, " = ");
1863 Sprint_Right_Opnd (Node);
1866 Sprint_Left_Opnd (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 Sprint_Left_Opnd (Node);
1877 Write_Operator (Node, " > ");
1878 Sprint_Right_Opnd (Node);
1881 Sprint_Left_Opnd (Node);
1882 Write_Operator (Node, " <= ");
1883 Sprint_Right_Opnd (Node);
1886 Sprint_Left_Opnd (Node);
1887 Write_Operator (Node, " < ");
1888 Sprint_Right_Opnd (Node);
1891 Write_Operator (Node, "-");
1892 Sprint_Right_Opnd (Node);
1895 Sprint_Left_Opnd (Node);
1897 if Treat_Fixed_As_Integer (Node) then
1901 Write_Operator (Node, " mod ");
1902 Sprint_Right_Opnd (Node);
1904 when N_Op_Multiply =>
1905 Sprint_Left_Opnd (Node);
1907 Process_TFAI_RR_Flags (Node);
1908 Write_Operator (Node, "* ");
1909 Sprint_Right_Opnd (Node);
1912 Sprint_Left_Opnd (Node);
1913 Write_Operator (Node, " /= ");
1914 Sprint_Right_Opnd (Node);
1917 Write_Operator (Node, "not ");
1918 Sprint_Right_Opnd (Node);
1921 Sprint_Left_Opnd (Node);
1922 Write_Operator (Node, " or ");
1923 Sprint_Right_Opnd (Node);
1926 Write_Operator (Node, "+");
1927 Sprint_Right_Opnd (Node);
1930 Sprint_Left_Opnd (Node);
1932 if Treat_Fixed_As_Integer (Node) then
1936 Write_Operator (Node, " rem ");
1937 Sprint_Right_Opnd (Node);
1943 Write_Str_With_Col_Check ("(");
1944 Sprint_Node (Left_Opnd (Node));
1946 Sprint_Node (Right_Opnd (Node));
1949 when N_Op_Subtract =>
1950 Sprint_Left_Opnd (Node);
1951 Write_Operator (Node, " - ");
1952 Sprint_Right_Opnd (Node);
1955 Sprint_Left_Opnd (Node);
1956 Write_Operator (Node, " xor ");
1957 Sprint_Right_Opnd (Node);
1959 when N_Operator_Symbol =>
1960 Write_Name_With_Col_Check_Sloc (Chars (Node));
1962 when N_Ordinary_Fixed_Point_Definition =>
1963 Write_Str_With_Col_Check_Sloc ("delta ");
1964 Sprint_Node (Delta_Expression (Node));
1965 Sprint_Opt_Node (Real_Range_Specification (Node));
1968 Sprint_Left_Opnd (Node);
1969 Write_Str_Sloc (" or else ");
1970 Sprint_Right_Opnd (Node);
1972 when N_Others_Choice =>
1973 if All_Others (Node) then
1974 Write_Str_With_Col_Check ("all ");
1977 Write_Str_With_Col_Check_Sloc ("others");
1979 when N_Package_Body =>
1981 Write_Indent_Str_Sloc ("package body ");
1982 Sprint_Node (Defining_Unit_Name (Node));
1984 Sprint_Indented_List (Declarations (Node));
1986 if Present (Handled_Statement_Sequence (Node)) then
1987 Write_Indent_Str ("begin");
1988 Sprint_Node (Handled_Statement_Sequence (Node));
1991 Write_Indent_Str ("end ");
1992 Sprint_Node (Defining_Unit_Name (Node));
1995 when N_Package_Body_Stub =>
1996 Write_Indent_Str_Sloc ("package body ");
1997 Sprint_Node (Defining_Identifier (Node));
1998 Write_Str_With_Col_Check (" is separate;");
2000 when N_Package_Declaration =>
2003 Sprint_Node_Sloc (Specification (Node));
2006 when N_Package_Instantiation =>
2008 Write_Indent_Str_Sloc ("package ");
2009 Sprint_Node (Defining_Unit_Name (Node));
2010 Write_Str (" is new ");
2011 Sprint_Node (Name (Node));
2012 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2015 when N_Package_Renaming_Declaration =>
2016 Write_Indent_Str_Sloc ("package ");
2017 Sprint_Node (Defining_Unit_Name (Node));
2018 Write_Str_With_Col_Check (" renames ");
2019 Sprint_Node (Name (Node));
2022 when N_Package_Specification =>
2023 Write_Str_With_Col_Check_Sloc ("package ");
2024 Sprint_Node (Defining_Unit_Name (Node));
2026 Sprint_Indented_List (Visible_Declarations (Node));
2028 if Present (Private_Declarations (Node)) then
2029 Write_Indent_Str ("private");
2030 Sprint_Indented_List (Private_Declarations (Node));
2033 Write_Indent_Str ("end ");
2034 Sprint_Node (Defining_Unit_Name (Node));
2036 when N_Parameter_Association =>
2037 Sprint_Node_Sloc (Selector_Name (Node));
2039 Sprint_Node (Explicit_Actual_Parameter (Node));
2041 when N_Parameter_Specification =>
2044 if Write_Identifiers (Node) then
2047 if In_Present (Node) then
2048 Write_Str_With_Col_Check ("in ");
2051 if Out_Present (Node) then
2052 Write_Str_With_Col_Check ("out ");
2055 -- Ada 2005 (AI-231)
2057 if Null_Exclusion_Present (Node) then
2058 Write_Str ("not null ");
2061 Sprint_Node (Parameter_Type (Node));
2063 if Present (Expression (Node)) then
2065 Sprint_Node (Expression (Node));
2072 Write_Indent_Str_Sloc ("pragma ");
2073 Write_Name_With_Col_Check (Chars (Node));
2075 if Present (Pragma_Argument_Associations (Node)) then
2076 Sprint_Opt_Paren_Comma_List
2077 (Pragma_Argument_Associations (Node));
2082 when N_Pragma_Argument_Association =>
2085 if Chars (Node) /= No_Name then
2086 Write_Name_With_Col_Check (Chars (Node));
2090 Sprint_Node (Expression (Node));
2092 when N_Private_Type_Declaration =>
2093 Write_Indent_Str_Sloc ("type ");
2094 Write_Id (Defining_Identifier (Node));
2096 if Present (Discriminant_Specifications (Node)) then
2097 Write_Discr_Specs (Node);
2098 elsif Unknown_Discriminants_Present (Node) then
2099 Write_Str_With_Col_Check ("(<>)");
2104 if Tagged_Present (Node) then
2105 Write_Str_With_Col_Check ("tagged ");
2108 if Limited_Present (Node) then
2109 Write_Str_With_Col_Check ("limited ");
2112 Write_Str_With_Col_Check ("private;");
2114 when N_Private_Extension_Declaration =>
2115 Write_Indent_Str_Sloc ("type ");
2116 Write_Id (Defining_Identifier (Node));
2118 if Present (Discriminant_Specifications (Node)) then
2119 Write_Discr_Specs (Node);
2120 elsif Unknown_Discriminants_Present (Node) then
2121 Write_Str_With_Col_Check ("(<>)");
2124 Write_Str_With_Col_Check (" is new ");
2125 Sprint_Node (Subtype_Indication (Node));
2126 Write_Str_With_Col_Check (" with private;");
2128 when N_Procedure_Call_Statement =>
2131 Sprint_Node (Name (Node));
2132 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2135 when N_Procedure_Instantiation =>
2136 Write_Indent_Str_Sloc ("procedure ");
2137 Sprint_Node (Defining_Unit_Name (Node));
2138 Write_Str_With_Col_Check (" is new ");
2139 Sprint_Node (Name (Node));
2140 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2143 when N_Procedure_Specification =>
2144 Write_Str_With_Col_Check_Sloc ("procedure ");
2145 Sprint_Node (Defining_Unit_Name (Node));
2146 Write_Param_Specs (Node);
2148 when N_Protected_Body =>
2149 Write_Indent_Str_Sloc ("protected body ");
2150 Write_Id (Defining_Identifier (Node));
2152 Sprint_Indented_List (Declarations (Node));
2153 Write_Indent_Str ("end ");
2154 Write_Id (Defining_Identifier (Node));
2157 when N_Protected_Body_Stub =>
2158 Write_Indent_Str_Sloc ("protected body ");
2159 Write_Id (Defining_Identifier (Node));
2160 Write_Str_With_Col_Check (" is separate;");
2162 when N_Protected_Definition =>
2164 Sprint_Indented_List (Visible_Declarations (Node));
2166 if Present (Private_Declarations (Node)) then
2167 Write_Indent_Str ("private");
2168 Sprint_Indented_List (Private_Declarations (Node));
2171 Write_Indent_Str ("end ");
2173 when N_Protected_Type_Declaration =>
2174 Write_Indent_Str_Sloc ("protected type ");
2175 Write_Id (Defining_Identifier (Node));
2176 Write_Discr_Specs (Node);
2178 if Present (Interface_List (Node)) then
2179 Write_Str (" is new ");
2180 Sprint_And_List (Interface_List (Node));
2181 Write_Str (" with ");
2186 Sprint_Node (Protected_Definition (Node));
2187 Write_Id (Defining_Identifier (Node));
2190 when N_Qualified_Expression =>
2191 Sprint_Node (Subtype_Mark (Node));
2192 Write_Char_Sloc (''');
2194 -- Print expression, make sure we have at least one level of
2195 -- parentheses around the expression. For cases of qualified
2196 -- expressions in the source, this is always the case, but
2197 -- for generated qualifications, there may be no explicit
2198 -- parentheses present.
2200 if Paren_Count (Expression (Node)) /= 0 then
2201 Sprint_Node (Expression (Node));
2204 Sprint_Node (Expression (Node));
2208 when N_Raise_Constraint_Error =>
2210 -- This node can be used either as a subexpression or as a
2211 -- statement form. The following test is a reasonably reliable
2212 -- way to distinguish the two cases.
2214 if Is_List_Member (Node)
2215 and then Nkind (Parent (Node)) not in N_Subexpr
2220 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2221 Write_Condition_And_Reason (Node);
2223 when N_Raise_Program_Error =>
2225 -- This node can be used either as a subexpression or as a
2226 -- statement form. The following test is a reasonably reliable
2227 -- way to distinguish the two cases.
2229 if Is_List_Member (Node)
2230 and then Nkind (Parent (Node)) not in N_Subexpr
2235 Write_Str_With_Col_Check_Sloc ("[program_error");
2236 Write_Condition_And_Reason (Node);
2238 when N_Raise_Storage_Error =>
2240 -- This node can be used either as a subexpression or as a
2241 -- statement form. The following test is a reasonably reliable
2242 -- way to distinguish the two cases.
2244 if Is_List_Member (Node)
2245 and then Nkind (Parent (Node)) not in N_Subexpr
2250 Write_Str_With_Col_Check_Sloc ("[storage_error");
2251 Write_Condition_And_Reason (Node);
2253 when N_Raise_Statement =>
2254 Write_Indent_Str_Sloc ("raise ");
2255 Sprint_Node (Name (Node));
2259 Sprint_Node (Low_Bound (Node));
2260 Write_Str_Sloc (" .. ");
2261 Sprint_Node (High_Bound (Node));
2263 when N_Range_Constraint =>
2264 Write_Str_With_Col_Check_Sloc ("range ");
2265 Sprint_Node (Range_Expression (Node));
2267 when N_Real_Literal =>
2268 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2270 when N_Real_Range_Specification =>
2271 Write_Str_With_Col_Check_Sloc ("range ");
2272 Sprint_Node (Low_Bound (Node));
2274 Sprint_Node (High_Bound (Node));
2276 when N_Record_Definition =>
2277 if Abstract_Present (Node) then
2278 Write_Str_With_Col_Check ("abstract ");
2281 if Tagged_Present (Node) then
2282 Write_Str_With_Col_Check ("tagged ");
2285 if Limited_Present (Node) then
2286 Write_Str_With_Col_Check ("limited ");
2289 if Null_Present (Node) then
2290 Write_Str_With_Col_Check_Sloc ("null record");
2293 Write_Str_With_Col_Check_Sloc ("record");
2294 Sprint_Node (Component_List (Node));
2295 Write_Indent_Str ("end record");
2298 when N_Record_Representation_Clause =>
2299 Write_Indent_Str_Sloc ("for ");
2300 Sprint_Node (Identifier (Node));
2301 Write_Str_With_Col_Check (" use record ");
2303 if Present (Mod_Clause (Node)) then
2304 Sprint_Node (Mod_Clause (Node));
2307 Sprint_Indented_List (Component_Clauses (Node));
2308 Write_Indent_Str ("end record;");
2311 Sprint_Node (Prefix (Node));
2312 Write_Str_With_Col_Check_Sloc ("'reference");
2314 when N_Requeue_Statement =>
2315 Write_Indent_Str_Sloc ("requeue ");
2316 Sprint_Node (Name (Node));
2318 if Abort_Present (Node) then
2319 Write_Str_With_Col_Check (" with abort");
2324 when N_Return_Statement =>
2325 if Present (Expression (Node)) then
2326 Write_Indent_Str_Sloc ("return ");
2327 Sprint_Node (Expression (Node));
2330 Write_Indent_Str_Sloc ("return;");
2333 when N_Selective_Accept =>
2334 Write_Indent_Str_Sloc ("select");
2340 Alt_Node := First (Select_Alternatives (Node));
2343 Sprint_Node (Alt_Node);
2346 exit when No (Alt_Node);
2347 Write_Indent_Str ("or");
2351 if Present (Else_Statements (Node)) then
2352 Write_Indent_Str ("else");
2353 Sprint_Indented_List (Else_Statements (Node));
2356 Write_Indent_Str ("end select;");
2358 when N_Signed_Integer_Type_Definition =>
2359 Write_Str_With_Col_Check_Sloc ("range ");
2360 Sprint_Node (Low_Bound (Node));
2362 Sprint_Node (High_Bound (Node));
2364 when N_Single_Protected_Declaration =>
2365 Write_Indent_Str_Sloc ("protected ");
2366 Write_Id (Defining_Identifier (Node));
2368 Sprint_Node (Protected_Definition (Node));
2369 Write_Id (Defining_Identifier (Node));
2372 when N_Single_Task_Declaration =>
2373 Write_Indent_Str_Sloc ("task ");
2374 Write_Id (Defining_Identifier (Node));
2376 if Present (Task_Definition (Node)) then
2378 Sprint_Node (Task_Definition (Node));
2379 Write_Id (Defining_Identifier (Node));
2384 when N_Selected_Component =>
2385 Sprint_Node (Prefix (Node));
2386 Write_Char_Sloc ('.');
2387 Sprint_Node (Selector_Name (Node));
2391 Sprint_Node (Prefix (Node));
2392 Write_Str_With_Col_Check (" (");
2393 Sprint_Node (Discrete_Range (Node));
2396 when N_String_Literal =>
2397 if String_Length (Strval (Node)) + Column > 75 then
2398 Write_Indent_Str (" ");
2402 Write_String_Table_Entry (Strval (Node));
2404 when N_Subprogram_Body =>
2405 if Freeze_Indent = 0 then
2410 Sprint_Node_Sloc (Specification (Node));
2413 Sprint_Indented_List (Declarations (Node));
2414 Write_Indent_Str ("begin");
2415 Sprint_Node (Handled_Statement_Sequence (Node));
2417 Write_Indent_Str ("end ");
2418 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2421 if Is_List_Member (Node)
2422 and then Present (Next (Node))
2423 and then Nkind (Next (Node)) /= N_Subprogram_Body
2428 when N_Subprogram_Body_Stub =>
2430 Sprint_Node_Sloc (Specification (Node));
2431 Write_Str_With_Col_Check (" is separate;");
2433 when N_Subprogram_Declaration =>
2435 Sprint_Node_Sloc (Specification (Node));
2437 if Nkind (Specification (Node)) = N_Procedure_Specification
2438 and then Null_Present (Specification (Node))
2440 Write_Str_With_Col_Check (" is null");
2445 when N_Subprogram_Info =>
2446 Sprint_Node (Identifier (Node));
2447 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2449 when N_Subprogram_Renaming_Declaration =>
2451 Sprint_Node (Specification (Node));
2452 Write_Str_With_Col_Check_Sloc (" renames ");
2453 Sprint_Node (Name (Node));
2456 when N_Subtype_Declaration =>
2457 Write_Indent_Str_Sloc ("subtype ");
2458 Write_Id (Defining_Identifier (Node));
2461 -- Ada 2005 (AI-231)
2463 if Null_Exclusion_Present (Node) then
2464 Write_Str ("not null ");
2467 Sprint_Node (Subtype_Indication (Node));
2470 when N_Subtype_Indication =>
2471 Sprint_Node_Sloc (Subtype_Mark (Node));
2473 Sprint_Node (Constraint (Node));
2476 Write_Indent_Str_Sloc ("separate (");
2477 Sprint_Node (Name (Node));
2480 Sprint_Node (Proper_Body (Node));
2483 Write_Indent_Str_Sloc ("task body ");
2484 Write_Id (Defining_Identifier (Node));
2486 Sprint_Indented_List (Declarations (Node));
2487 Write_Indent_Str ("begin");
2488 Sprint_Node (Handled_Statement_Sequence (Node));
2489 Write_Indent_Str ("end ");
2490 Write_Id (Defining_Identifier (Node));
2493 when N_Task_Body_Stub =>
2494 Write_Indent_Str_Sloc ("task body ");
2495 Write_Id (Defining_Identifier (Node));
2496 Write_Str_With_Col_Check (" is separate;");
2498 when N_Task_Definition =>
2500 Sprint_Indented_List (Visible_Declarations (Node));
2502 if Present (Private_Declarations (Node)) then
2503 Write_Indent_Str ("private");
2504 Sprint_Indented_List (Private_Declarations (Node));
2507 Write_Indent_Str ("end ");
2509 when N_Task_Type_Declaration =>
2510 Write_Indent_Str_Sloc ("task type ");
2511 Write_Id (Defining_Identifier (Node));
2512 Write_Discr_Specs (Node);
2514 if Present (Interface_List (Node)) then
2515 Write_Str (" is new ");
2516 Sprint_And_List (Interface_List (Node));
2519 if Present (Task_Definition (Node)) then
2520 if No (Interface_List (Node)) then
2523 Write_Str (" with ");
2526 Sprint_Node (Task_Definition (Node));
2527 Write_Id (Defining_Identifier (Node));
2532 when N_Terminate_Alternative =>
2533 Sprint_Node_List (Pragmas_Before (Node));
2537 if Present (Condition (Node)) then
2538 Write_Str_With_Col_Check ("when ");
2539 Sprint_Node (Condition (Node));
2543 Write_Str_With_Col_Check_Sloc ("terminate;");
2544 Sprint_Node_List (Pragmas_After (Node));
2546 when N_Timed_Entry_Call =>
2547 Write_Indent_Str_Sloc ("select");
2549 Sprint_Node (Entry_Call_Alternative (Node));
2551 Write_Indent_Str ("or");
2553 Sprint_Node (Delay_Alternative (Node));
2555 Write_Indent_Str ("end select;");
2557 when N_Triggering_Alternative =>
2558 Sprint_Node_List (Pragmas_Before (Node));
2559 Sprint_Node_Sloc (Triggering_Statement (Node));
2560 Sprint_Node_List (Statements (Node));
2562 when N_Type_Conversion =>
2564 Sprint_Node (Subtype_Mark (Node));
2567 if Conversion_OK (Node) then
2571 if Float_Truncate (Node) then
2575 if Rounded_Result (Node) then
2580 Sprint_Node (Expression (Node));
2583 when N_Unchecked_Expression =>
2586 Sprint_Node_Sloc (Expression (Node));
2589 when N_Unchecked_Type_Conversion =>
2590 Sprint_Node (Subtype_Mark (Node));
2592 Write_Str_With_Col_Check ("(");
2593 Sprint_Node_Sloc (Expression (Node));
2596 when N_Unconstrained_Array_Definition =>
2597 Write_Str_With_Col_Check_Sloc ("array (");
2603 Node1 := First (Subtype_Marks (Node));
2605 Sprint_Node (Node1);
2606 Write_Str_With_Col_Check (" range <>");
2608 exit when Node1 = Empty;
2613 Write_Str (") of ");
2614 Sprint_Node (Component_Definition (Node));
2616 when N_Unused_At_Start | N_Unused_At_End =>
2617 Write_Indent_Str ("***** Error, unused node encountered *****");
2620 when N_Use_Package_Clause =>
2621 Write_Indent_Str_Sloc ("use ");
2622 Sprint_Comma_List (Names (Node));
2625 when N_Use_Type_Clause =>
2626 Write_Indent_Str_Sloc ("use type ");
2627 Sprint_Comma_List (Subtype_Marks (Node));
2630 when N_Validate_Unchecked_Conversion =>
2631 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2632 Sprint_Node (Source_Type (Node));
2634 Sprint_Node (Target_Type (Node));
2638 Write_Indent_Str_Sloc ("when ");
2639 Sprint_Bar_List (Discrete_Choices (Node));
2641 Sprint_Node (Component_List (Node));
2643 when N_Variant_Part =>
2645 Write_Indent_Str_Sloc ("case ");
2646 Sprint_Node (Name (Node));
2648 Sprint_Indented_List (Variants (Node));
2649 Write_Indent_Str ("end case");
2652 when N_With_Clause =>
2654 -- Special test, if we are dumping the original tree only,
2655 -- then we want to eliminate the bogus with clauses that
2656 -- correspond to the non-existent children of Text_IO.
2658 if Dump_Original_Only
2659 and then Is_Text_IO_Kludge_Unit (Name (Node))
2663 -- Normal case, output the with clause
2666 if First_Name (Node) or else not Dump_Original_Only then
2668 -- Ada 2005 (AI-50217): Print limited with_clauses
2670 if Private_Present (Node) and Limited_Present (Node) then
2671 Write_Indent_Str ("limited private with ");
2673 elsif Private_Present (Node) then
2674 Write_Indent_Str ("private with ");
2676 elsif Limited_Present (Node) then
2677 Write_Indent_Str ("limited with ");
2680 Write_Indent_Str ("with ");
2687 Sprint_Node_Sloc (Name (Node));
2689 if Last_Name (Node) or else not Dump_Original_Only then
2694 when N_With_Type_Clause =>
2695 Write_Indent_Str ("with type ");
2696 Sprint_Node_Sloc (Name (Node));
2698 if Tagged_Present (Node) then
2699 Write_Str (" is tagged;");
2701 Write_Str (" is access;");
2706 if Nkind (Node) in N_Subexpr
2707 and then Do_Range_Check (Node)
2712 for J in 1 .. Paren_Count (Node) loop
2716 pragma Assert (No (Debug_Node));
2717 Debug_Node := Save_Debug_Node;
2718 end Sprint_Node_Actual;
2720 ----------------------
2721 -- Sprint_Node_List --
2722 ----------------------
2724 procedure Sprint_Node_List (List : List_Id) is
2728 if Is_Non_Empty_List (List) then
2729 Node := First (List);
2734 exit when Node = Empty;
2737 end Sprint_Node_List;
2739 ----------------------
2740 -- Sprint_Node_Sloc --
2741 ----------------------
2743 procedure Sprint_Node_Sloc (Node : Node_Id) is
2747 if Present (Debug_Node) then
2748 Set_Sloc (Debug_Node, Sloc (Node));
2749 Debug_Node := Empty;
2751 end Sprint_Node_Sloc;
2753 ---------------------
2754 -- Sprint_Opt_Node --
2755 ---------------------
2757 procedure Sprint_Opt_Node (Node : Node_Id) is
2759 if Present (Node) then
2763 end Sprint_Opt_Node;
2765 --------------------------
2766 -- Sprint_Opt_Node_List --
2767 --------------------------
2769 procedure Sprint_Opt_Node_List (List : List_Id) is
2771 if Present (List) then
2772 Sprint_Node_List (List);
2774 end Sprint_Opt_Node_List;
2776 ---------------------------------
2777 -- Sprint_Opt_Paren_Comma_List --
2778 ---------------------------------
2780 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2782 if Is_Non_Empty_List (List) then
2784 Sprint_Paren_Comma_List (List);
2786 end Sprint_Opt_Paren_Comma_List;
2788 -----------------------------
2789 -- Sprint_Paren_Comma_List --
2790 -----------------------------
2792 procedure Sprint_Paren_Comma_List (List : List_Id) is
2794 Node_Exists : Boolean := False;
2798 if Is_Non_Empty_List (List) then
2800 if Dump_Original_Only then
2803 while Present (N) loop
2805 if not Is_Rewrite_Insertion (N) then
2806 Node_Exists := True;
2813 if not Node_Exists then
2818 Write_Str_With_Col_Check ("(");
2819 Sprint_Comma_List (List);
2822 end Sprint_Paren_Comma_List;
2824 ----------------------
2825 -- Sprint_Right_Opnd --
2826 ----------------------
2828 procedure Sprint_Right_Opnd (N : Node_Id) is
2829 Opnd : constant Node_Id := Right_Opnd (N);
2832 if Paren_Count (Opnd) /= 0
2833 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2842 end Sprint_Right_Opnd;
2844 ---------------------
2845 -- Write_Char_Sloc --
2846 ---------------------
2848 procedure Write_Char_Sloc (C : Character) is
2850 if Debug_Generated_Code and then C /= ' ' then
2855 end Write_Char_Sloc;
2857 --------------------------------
2858 -- Write_Condition_And_Reason --
2859 --------------------------------
2861 procedure Write_Condition_And_Reason (Node : Node_Id) is
2862 Image : constant String := RT_Exception_Code'Image
2863 (RT_Exception_Code'Val
2864 (UI_To_Int (Reason (Node))));
2867 if Present (Condition (Node)) then
2868 Write_Str_With_Col_Check (" when ");
2869 Sprint_Node (Condition (Node));
2874 for J in 4 .. Image'Last loop
2875 if Image (J) = '_' then
2878 Write_Char (Fold_Lower (Image (J)));
2883 end Write_Condition_And_Reason;
2885 -----------------------
2886 -- Write_Discr_Specs --
2887 -----------------------
2889 procedure Write_Discr_Specs (N : Node_Id) is
2894 Specs := Discriminant_Specifications (N);
2896 if Present (Specs) then
2897 Write_Str_With_Col_Check (" (");
2898 Spec := First (Specs);
2903 exit when Spec = Empty;
2905 -- Add semicolon, unless we are printing original tree and the
2906 -- next specification is part of a list (but not the first
2907 -- element of that list)
2909 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2916 end Write_Discr_Specs;
2922 procedure Write_Ekind (E : Entity_Id) is
2923 S : constant String := Entity_Kind'Image (Ekind (E));
2926 Name_Len := S'Length;
2927 Name_Buffer (1 .. Name_Len) := S;
2928 Set_Casing (Mixed_Case);
2929 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2936 procedure Write_Id (N : Node_Id) is
2938 -- Case of a defining identifier
2940 if Nkind (N) = N_Defining_Identifier then
2942 -- If defining identifier has an interface name (and no
2943 -- address clause), then we output the interface name.
2945 if (Is_Imported (N) or else Is_Exported (N))
2946 and then Present (Interface_Name (N))
2947 and then No (Address_Clause (N))
2949 String_To_Name_Buffer (Strval (Interface_Name (N)));
2950 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2952 -- If no interface name (or inactive because there was
2953 -- an address clause), then just output the Chars name.
2956 Write_Name_With_Col_Check (Chars (N));
2959 -- Case of selector of an expanded name where the expanded name
2960 -- has an associated entity, output this entity.
2962 elsif Nkind (Parent (N)) = N_Expanded_Name
2963 and then Selector_Name (Parent (N)) = N
2964 and then Present (Entity (Parent (N)))
2966 Write_Id (Entity (Parent (N)));
2968 -- For any other node with an associated entity, output it
2970 elsif Nkind (N) in N_Has_Entity
2971 and then Present (Entity_Or_Associated_Node (N))
2972 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2974 Write_Id (Entity (N));
2976 -- All other cases, we just print the Chars field
2979 Write_Name_With_Col_Check (Chars (N));
2983 -----------------------
2984 -- Write_Identifiers --
2985 -----------------------
2987 function Write_Identifiers (Node : Node_Id) return Boolean is
2989 Sprint_Node (Defining_Identifier (Node));
2991 -- The remainder of the declaration must be printed unless we are
2992 -- printing the original tree and this is not the last identifier
2995 not Dump_Original_Only or else not More_Ids (Node);
2997 end Write_Identifiers;
2999 ------------------------
3000 -- Write_Implicit_Def --
3001 ------------------------
3003 procedure Write_Implicit_Def (E : Entity_Id) is
3008 when E_Array_Subtype =>
3009 Write_Str_With_Col_Check ("subtype ");
3011 Write_Str_With_Col_Check (" is ");
3012 Write_Id (Base_Type (E));
3013 Write_Str_With_Col_Check (" (");
3015 Ind := First_Index (E);
3017 while Present (Ind) loop
3021 if Present (Ind) then
3028 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
3029 Write_Str_With_Col_Check ("subtype ");
3032 Write_Id (Etype (E));
3033 Write_Str_With_Col_Check (" range ");
3034 Sprint_Node (Scalar_Range (E));
3038 Write_Str_With_Col_Check ("type ");
3040 Write_Str_With_Col_Check (" is <");
3045 end Write_Implicit_Def;
3051 procedure Write_Indent is
3053 if Indent_Annull_Flag then
3054 Indent_Annull_Flag := False;
3058 for J in 1 .. Indent loop
3064 ------------------------------
3065 -- Write_Indent_Identifiers --
3066 ------------------------------
3068 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3070 -- We need to start a new line for every node, except in the case
3071 -- where we are printing the original tree and this is not the first
3072 -- defining identifier in the list.
3074 if not Dump_Original_Only or else not Prev_Ids (Node) then
3077 -- If printing original tree and this is not the first defining
3078 -- identifier in the list, then the previous call to this procedure
3079 -- printed only the name, and we add a comma to separate the names.
3085 Sprint_Node (Defining_Identifier (Node));
3087 -- The remainder of the declaration must be printed unless we are
3088 -- printing the original tree and this is not the last identifier
3091 not Dump_Original_Only or else not More_Ids (Node);
3093 end Write_Indent_Identifiers;
3095 -----------------------------------
3096 -- Write_Indent_Identifiers_Sloc --
3097 -----------------------------------
3099 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3101 -- We need to start a new line for every node, except in the case
3102 -- where we are printing the original tree and this is not the first
3103 -- defining identifier in the list.
3105 if not Dump_Original_Only or else not Prev_Ids (Node) then
3108 -- If printing original tree and this is not the first defining
3109 -- identifier in the list, then the previous call to this procedure
3110 -- printed only the name, and we add a comma to separate the names.
3117 Sprint_Node (Defining_Identifier (Node));
3119 -- The remainder of the declaration must be printed unless we are
3120 -- printing the original tree and this is not the last identifier
3123 not Dump_Original_Only or else not More_Ids (Node);
3125 end Write_Indent_Identifiers_Sloc;
3127 ----------------------
3128 -- Write_Indent_Str --
3129 ----------------------
3131 procedure Write_Indent_Str (S : String) is
3135 end Write_Indent_Str;
3137 ---------------------------
3138 -- Write_Indent_Str_Sloc --
3139 ---------------------------
3141 procedure Write_Indent_Str_Sloc (S : String) is
3145 end Write_Indent_Str_Sloc;
3147 -------------------------------
3148 -- Write_Name_With_Col_Check --
3149 -------------------------------
3151 procedure Write_Name_With_Col_Check (N : Name_Id) is
3155 Get_Name_String (N);
3157 -- Deal with -gnatI which replaces digits in an internal
3158 -- name by three dots (e.g. R7b becomes R...b).
3160 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3163 while J < Name_Len loop
3164 exit when Name_Buffer (J) not in 'A' .. 'Z';
3168 if Name_Buffer (J) in '0' .. '9' then
3169 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3172 while J <= Name_Len loop
3173 if Name_Buffer (J) not in '0' .. '9' then
3174 Write_Str (Name_Buffer (J .. Name_Len));
3186 -- Fall through for normal case
3188 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3189 end Write_Name_With_Col_Check;
3191 ------------------------------------
3192 -- Write_Name_With_Col_Check_Sloc --
3193 ------------------------------------
3195 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3197 Get_Name_String (N);
3198 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3199 end Write_Name_With_Col_Check_Sloc;
3201 --------------------
3202 -- Write_Operator --
3203 --------------------
3205 procedure Write_Operator (N : Node_Id; S : String) is
3206 F : Natural := S'First;
3207 T : Natural := S'Last;
3210 -- If no overflow check, just write string out, and we are done
3212 if not Do_Overflow_Check (N) then
3215 -- If overflow check, we want to surround the operator with curly
3216 -- brackets, but not include spaces within the brackets.
3229 Write_Str_Sloc (S (F .. T));
3232 if S (S'Last) = ' ' then
3238 -----------------------
3239 -- Write_Param_Specs --
3240 -----------------------
3242 procedure Write_Param_Specs (N : Node_Id) is
3248 Specs := Parameter_Specifications (N);
3250 if Is_Non_Empty_List (Specs) then
3251 Write_Str_With_Col_Check (" (");
3252 Spec := First (Specs);
3256 Formal := Defining_Identifier (Spec);
3258 exit when Spec = Empty;
3260 -- Add semicolon, unless we are printing original tree and the
3261 -- next specification is part of a list (but not the first
3262 -- element of that list)
3264 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3269 -- Write out any extra formals
3271 while Present (Extra_Formal (Formal)) loop
3272 Formal := Extra_Formal (Formal);
3274 Write_Name_With_Col_Check (Chars (Formal));
3276 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3281 end Write_Param_Specs;
3283 --------------------------
3284 -- Write_Rewrite_Str --
3285 --------------------------
3287 procedure Write_Rewrite_Str (S : String) is
3289 if not Dump_Generated_Only then
3290 if S'Length = 3 and then S = ">>>" then
3293 Write_Str_With_Col_Check (S);
3296 end Write_Rewrite_Str;
3298 --------------------
3299 -- Write_Str_Sloc --
3300 --------------------
3302 procedure Write_Str_Sloc (S : String) is
3304 for J in S'Range loop
3305 Write_Char_Sloc (S (J));
3309 ------------------------------
3310 -- Write_Str_With_Col_Check --
3311 ------------------------------
3313 procedure Write_Str_With_Col_Check (S : String) is
3315 if Int (S'Last) + Column > Line_Limit then
3316 Write_Indent_Str (" ");
3319 Write_Str (S (2 .. S'Length));
3327 end Write_Str_With_Col_Check;
3329 -----------------------------------
3330 -- Write_Str_With_Col_Check_Sloc --
3331 -----------------------------------
3333 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3335 if Int (S'Last) + Column > Line_Limit then
3336 Write_Indent_Str (" ");
3339 Write_Str_Sloc (S (2 .. S'Length));
3347 end Write_Str_With_Col_Check_Sloc;
3349 ------------------------------------
3350 -- Write_Uint_With_Col_Check_Sloc --
3351 ------------------------------------
3353 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3355 Col_Check (UI_Decimal_Digits_Hi (U));
3357 UI_Write (U, Format);
3358 end Write_Uint_With_Col_Check_Sloc;
3360 -------------------------------------
3361 -- Write_Ureal_With_Col_Check_Sloc --
3362 -------------------------------------
3364 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3365 D : constant Uint := Denominator (U);
3366 N : constant Uint := Numerator (U);
3370 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3373 end Write_Ureal_With_Col_Check_Sloc;