1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2006, 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;
32 with Fname; use Fname;
34 with Namet; use Namet;
35 with Nlists; use Nlists;
37 with Output; use Output;
38 with Rtsfind; use Rtsfind;
39 with Sinfo; use Sinfo;
40 with Sinput; use Sinput;
41 with Sinput.D; use Sinput.D;
42 with Snames; use Snames;
43 with Stand; use Stand;
44 with Stringt; use Stringt;
45 with Uintp; use Uintp;
46 with Uname; use Uname;
47 with Urealp; use Urealp;
49 package body Sprint is
50 Current_Source_File : Source_File_Index;
51 -- Index of source file whose generated code is being dumped
53 Dump_Node : Node_Id := Empty;
54 -- This is set to the current node, used for printing line numbers. In
55 -- Debug_Generated_Code mode, Dump_Node is set to the current node
56 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
57 -- value. The call clears it back to Empty.
59 Debug_Sloc : Source_Ptr;
60 -- Sloc of first byte of line currently being written if we are
61 -- generating a source debug file.
63 Dump_Original_Only : Boolean;
64 -- Set True if the -gnatdo (dump original tree) flag is set
66 Dump_Generated_Only : Boolean;
67 -- Set True if the -gnatG (dump generated tree) debug flag is set
68 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
70 Dump_Freeze_Null : Boolean;
71 -- Set True if freeze nodes and non-source null statements output
73 Freeze_Indent : Int := 0;
74 -- Keep track of freeze indent level (controls output of blank lines before
75 -- procedures within expression freeze actions). Relevant only if we are
76 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
77 -- output these blank lines in any case.
80 -- Number of columns for current line output indentation
82 Indent_Annull_Flag : Boolean := False;
83 -- Set True if subsequent Write_Indent call to be ignored, gets reset
84 -- by this call, so it is only active to suppress a single indent call.
86 Last_Line_Printed : Physical_Line_Number;
87 -- This keeps track of the physical line number of the last source line
88 -- that has been output. The value is only valid in Dump_Source_Text mode.
90 Line_Limit : constant := 72;
91 -- Limit value for chopping long lines
93 -------------------------------
94 -- Operator Precedence Table --
95 -------------------------------
97 -- This table is used to decide whether a subexpression needs to be
98 -- parenthesized. The rule is that if an operand of an operator (which
99 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
100 -- with a lower precedence than the operator (or equal precedence if
101 -- appearing as the right operand), then parentheses are required.
103 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
136 procedure Sprint_Left_Opnd (N : Node_Id);
137 -- Print left operand of operator, parenthesizing if necessary
139 procedure Sprint_Right_Opnd (N : Node_Id);
140 -- Print right operand of operator, parenthesizing if necessary
142 -----------------------
143 -- Local Subprograms --
144 -----------------------
146 procedure Col_Check (N : Nat);
147 -- Check that at least N characters remain on current line, and if not,
148 -- then start an extra line with two characters extra indentation for
149 -- continuing text on the next line.
151 procedure Extra_Blank_Line;
152 -- In some situations we write extra blank lines to separate the generated
153 -- code to make it more readable. However, these extra blank lines are not
154 -- generated in Dump_Source_Text mode, since there the source text lines
155 -- output with preceding blank lines are quite sufficient as separators.
156 -- This procedure writes a blank line if Dump_Source_Text is False.
158 procedure Indent_Annull;
159 -- Causes following call to Write_Indent to be ignored. This is used when
160 -- a higher level node wants to stop a lower level node from starting a
161 -- new line, when it would otherwise be inclined to do so (e.g. the case
162 -- of an accept statement called from an accept alternative with a guard)
164 procedure Indent_Begin;
165 -- Increase indentation level
167 procedure Indent_End;
168 -- Decrease indentation level
170 procedure Note_Implicit_Run_Time_Call (N : Node_Id);
171 -- N is the Name field of a function call or procedure statement call.
172 -- The effect of the call is to output a $ if the call is identified as
173 -- an implicit call to a run time routine.
175 procedure Print_Debug_Line (S : String);
176 -- Used to print output lines in Debug_Generated_Code mode (this is used
177 -- as the argument for a call to Set_Special_Output in package Output).
179 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
180 -- Given a divide, multiplication or division node, check the flags
181 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
182 -- appropriate special syntax characters (# and @).
184 procedure Set_Debug_Sloc;
185 -- If Dump_Node is non-empty, this routine sets the appropriate value
186 -- in its Sloc field, from the current location in the debug source file
187 -- that is currently being written.
189 procedure Sprint_And_List (List : List_Id);
190 -- Print the given list with items separated by vertical "and"
192 procedure Sprint_Bar_List (List : List_Id);
193 -- Print the given list with items separated by vertical bars
195 procedure Sprint_Node_Actual (Node : Node_Id);
196 -- This routine prints its node argument. It is a lower level routine than
197 -- Sprint_Node, in that it does not bother about rewritten trees.
199 procedure Sprint_Node_Sloc (Node : Node_Id);
200 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
201 -- sets the Sloc of the current debug node to be a copy of the Sloc
202 -- of the sprinted node Node. Note that this is done after printing
203 -- Node, so that the Sloc is the proper updated value for the debug file.
205 procedure Write_Char_Sloc (C : Character);
206 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
207 -- called to ensure that the current node has a proper Sloc set.
209 procedure Write_Condition_And_Reason (Node : Node_Id);
210 -- Write Condition and Reason codes of Raise_xxx_Error node
212 procedure Write_Corresponding_Source (S : String);
213 -- If S is a string with a single keyword (possibly followed by a space),
214 -- and if the next non-comment non-blank source line matches this keyword,
215 -- then output all source lines up to this matching line.
217 procedure Write_Discr_Specs (N : Node_Id);
218 -- Ouput discriminant specification for node, which is any of the type
219 -- declarations that can have discriminants.
221 procedure Write_Ekind (E : Entity_Id);
222 -- Write the String corresponding to the Ekind without "E_"
224 procedure Write_Id (N : Node_Id);
225 -- N is a node with a Chars field. This procedure writes the name that
226 -- will be used in the generated code associated with the name. For a
227 -- node with no associated entity, this is simply the Chars field. For
228 -- the case where there is an entity associated with the node, we print
229 -- the name associated with the entity (since it may have been encoded).
230 -- One other special case is that an entity has an active external name
231 -- (i.e. an external name present with no address clause), then this
232 -- external name is output. This procedure also deals with outputting
233 -- declarations of referenced itypes, if not output earlier.
235 function Write_Identifiers (Node : Node_Id) return Boolean;
236 -- Handle node where the grammar has a list of defining identifiers, but
237 -- the tree has a separate declaration for each identifier. Handles the
238 -- printing of the defining identifier, and returns True if the type and
239 -- initialization information is to be printed, False if it is to be
240 -- skipped (the latter case happens when printing defining identifiers
241 -- other than the first in the original tree output case).
243 procedure Write_Implicit_Def (E : Entity_Id);
244 pragma Warnings (Off, Write_Implicit_Def);
245 -- Write the definition of the implicit type E according to its Ekind
246 -- For now a debugging procedure, but might be used in the future.
248 procedure Write_Indent;
249 -- Start a new line and write indentation spacing
251 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
252 -- Like Write_Identifiers except that each new printed declaration
253 -- is at the start of a new line.
255 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
256 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
257 -- mode, the Sloc of the current debug node is set to point ot the
258 -- first output identifier.
260 procedure Write_Indent_Str (S : String);
261 -- Start a new line and write indent spacing followed by given string
263 procedure Write_Indent_Str_Sloc (S : String);
264 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
265 -- the Sloc of the current node is set to the first non-blank character
268 procedure Write_Itype (Typ : Entity_Id);
269 -- If Typ is an Itype that has not been written yet, write it. If Typ is
270 -- any other kind of entity or tree node, the call is ignored.
272 procedure Write_Name_With_Col_Check (N : Name_Id);
273 -- Write name (using Write_Name) with initial column check, and possible
274 -- initial Write_Indent (to get new line) if current line is too full.
276 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
277 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
278 -- mode, sets Sloc of current debug node to first character of name.
280 procedure Write_Operator (N : Node_Id; S : String);
281 -- Like Write_Str_Sloc, used for operators, encloses the string in
282 -- characters {} if the Do_Overflow flag is set on the node N.
284 procedure Write_Param_Specs (N : Node_Id);
285 -- Output parameter specifications for node (which is either a function
286 -- or procedure specification with a Parameter_Specifications field)
288 procedure Write_Rewrite_Str (S : String);
289 -- Writes out a string (typically containing <<< or >>>}) for a node
290 -- created by rewriting the tree. Suppressed if we are outputting the
291 -- generated code only, since in this case we don't specially mark nodes
292 -- created by rewriting).
294 procedure Write_Source_Line (L : Physical_Line_Number);
295 -- If writing of interspersed source lines is enabled, then write the given
296 -- line from the source file, preceded by Eol, then an extra blank line if
297 -- the line has at least one blank, is not a comment and is not line one,
298 -- then "--" and the line number followed by period followed by text of the
299 -- source line (without terminating Eol). If interspersed source line
300 -- output not enabled, then the call has no effect.
302 procedure Write_Source_Lines (L : Physical_Line_Number);
303 -- If writing of interspersed source lines is enabled, then writes source
304 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
305 -- interspersed source line output not enabled, then call has no effect.
307 procedure Write_Str_Sloc (S : String);
308 -- Like Write_Str, but sets debug Sloc of current debug node to first
309 -- non-blank character if a current debug node is active.
311 procedure Write_Str_With_Col_Check (S : String);
312 -- Write string (using Write_Str) with initial column check, and possible
313 -- initial Write_Indent (to get new line) if current line is too full.
315 procedure Write_Str_With_Col_Check_Sloc (S : String);
316 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
317 -- node to first non-blank character if a current debug node is active.
319 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format);
320 -- Write Uint (using UI_Write) with initial column check, and possible
321 -- initial Write_Indent (to get new line) if current line is too full.
322 -- The format parameter determines the output format (see UI_Write).
324 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
325 -- Write Uint (using UI_Write) with initial column check, and possible
326 -- initial Write_Indent (to get new line) if current line is too full.
327 -- The format parameter determines the output format (see UI_Write).
328 -- In addition, in Debug_Generated_Code mode, sets the current node
329 -- Sloc to the first character of the output value.
331 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
332 -- Write Ureal (using same output format as UR_Write) with column checks
333 -- and a possible initial Write_Indent (to get new line) if current line
334 -- is too full. In addition, in Debug_Generated_Code mode, sets the
335 -- current node Sloc to the first character of the output value.
341 procedure Col_Check (N : Nat) is
343 if N + Column > Line_Limit then
344 Write_Indent_Str (" ");
348 ----------------------
349 -- Extra_Blank_Line --
350 ----------------------
352 procedure Extra_Blank_Line is
354 if not Dump_Source_Text then
357 end Extra_Blank_Line;
363 procedure Indent_Annull is
365 Indent_Annull_Flag := True;
372 procedure Indent_Begin is
374 Indent := Indent + 3;
381 procedure Indent_End is
383 Indent := Indent - 3;
386 ---------------------------------
387 -- Note_Implicit_Run_Time_Call --
388 ---------------------------------
390 procedure Note_Implicit_Run_Time_Call (N : Node_Id) is
392 if not Comes_From_Source (N)
393 and then Is_Entity_Name (N)
396 Ent : constant Entity_Id := Entity (N);
398 if not In_Extended_Main_Source_Unit (Ent)
400 Is_Predefined_File_Name
401 (Unit_File_Name (Get_Source_Unit (Ent)))
403 Col_Check (Length_Of_Name (Chars (Ent)));
408 end Note_Implicit_Run_Time_Call;
414 procedure pg (Node : Node_Id) is
416 Dump_Generated_Only := True;
417 Dump_Original_Only := False;
418 Current_Source_File := No_Source_File;
427 procedure po (Node : Node_Id) is
429 Dump_Generated_Only := False;
430 Dump_Original_Only := True;
431 Current_Source_File := No_Source_File;
436 ----------------------
437 -- Print_Debug_Line --
438 ----------------------
440 procedure Print_Debug_Line (S : String) is
442 Write_Debug_Line (S, Debug_Sloc);
443 end Print_Debug_Line;
445 ---------------------------
446 -- Process_TFAI_RR_Flags --
447 ---------------------------
449 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
451 if Treat_Fixed_As_Integer (Nod) then
455 if Rounded_Result (Nod) then
458 end Process_TFAI_RR_Flags;
464 procedure ps (Node : Node_Id) is
466 Dump_Generated_Only := False;
467 Dump_Original_Only := False;
468 Current_Source_File := No_Source_File;
477 procedure Set_Debug_Sloc is
479 if Debug_Generated_Code and then Present (Dump_Node) then
480 Set_Sloc (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1));
489 procedure Source_Dump is
492 -- Put underline under string we just printed
498 procedure Underline is
499 Col : constant Int := Column;
504 while Col > Column loop
511 -- Start of processing for Tree_Dump
514 Dump_Generated_Only := Debug_Flag_G or
515 Print_Generated_Code or
516 Debug_Generated_Code;
517 Dump_Original_Only := Debug_Flag_O;
518 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
520 -- Note that we turn off the tree dump flags immediately, before
521 -- starting the dump. This avoids generating two copies of the dump
522 -- if an abort occurs after printing the dump, and more importantly,
523 -- avoids an infinite loop if an abort occurs during the dump.
526 Current_Source_File := No_Source_File;
527 Debug_Flag_Z := False;
530 Write_Str ("Source recreated from tree of Standard (spec)");
532 Sprint_Node (Standard_Package_Node);
537 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
538 Debug_Flag_G := False;
539 Debug_Flag_O := False;
540 Debug_Flag_S := False;
542 -- Dump requested units
544 for U in Main_Unit .. Last_Unit loop
545 Current_Source_File := Source_Index (U);
547 -- Dump all units if -gnatdf set, otherwise we dump only
548 -- the source files that are in the extended main source.
551 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
553 -- If we are generating debug files, setup to write them
555 if Debug_Generated_Code then
556 Set_Special_Output (Print_Debug_Line'Access);
557 Create_Debug_Source (Source_Index (U), Debug_Sloc);
558 Write_Source_Line (1);
559 Last_Line_Printed := 1;
560 Sprint_Node (Cunit (U));
561 Write_Source_Lines (Last_Source_Line (Current_Source_File));
564 Set_Special_Output (null);
566 -- Normal output to standard output file
569 Write_Str ("Source recreated from tree for ");
570 Write_Unit_Name (Unit_Name (U));
572 Write_Source_Line (1);
573 Last_Line_Printed := 1;
574 Sprint_Node (Cunit (U));
575 Write_Source_Lines (Last_Source_Line (Current_Source_File));
584 ---------------------
585 -- Sprint_And_List --
586 ---------------------
588 procedure Sprint_And_List (List : List_Id) is
591 if Is_Non_Empty_List (List) then
592 Node := First (List);
596 exit when Node = Empty;
602 ---------------------
603 -- Sprint_Bar_List --
604 ---------------------
606 procedure Sprint_Bar_List (List : List_Id) is
609 if Is_Non_Empty_List (List) then
610 Node := First (List);
614 exit when Node = Empty;
620 -----------------------
621 -- Sprint_Comma_List --
622 -----------------------
624 procedure Sprint_Comma_List (List : List_Id) is
628 if Is_Non_Empty_List (List) then
629 Node := First (List);
633 exit when Node = Empty;
635 if not Is_Rewrite_Insertion (Node)
636 or else not Dump_Original_Only
642 end Sprint_Comma_List;
644 --------------------------
645 -- Sprint_Indented_List --
646 --------------------------
648 procedure Sprint_Indented_List (List : List_Id) is
651 Sprint_Node_List (List);
653 end Sprint_Indented_List;
655 ---------------------
656 -- Sprint_Left_Opnd --
657 ---------------------
659 procedure Sprint_Left_Opnd (N : Node_Id) is
660 Opnd : constant Node_Id := Left_Opnd (N);
663 if Paren_Count (Opnd) /= 0
664 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
673 end Sprint_Left_Opnd;
679 procedure Sprint_Node (Node : Node_Id) is
681 if Is_Rewrite_Insertion (Node) then
682 if not Dump_Original_Only then
684 -- For special cases of nodes that always output <<< >>>
685 -- do not duplicate the output at this point.
687 if Nkind (Node) = N_Freeze_Entity
688 or else Nkind (Node) = N_Implicit_Label_Declaration
690 Sprint_Node_Actual (Node);
692 -- Normal case where <<< >>> may be required
695 Write_Rewrite_Str ("<<<");
696 Sprint_Node_Actual (Node);
697 Write_Rewrite_Str (">>>");
701 elsif Is_Rewrite_Substitution (Node) then
703 -- Case of dump generated only
705 if Dump_Generated_Only then
706 Sprint_Node_Actual (Node);
708 -- Case of dump original only
710 elsif Dump_Original_Only then
711 Sprint_Node_Actual (Original_Node (Node));
713 -- Case of both being dumped
716 Sprint_Node_Actual (Original_Node (Node));
717 Write_Rewrite_Str ("<<<");
718 Sprint_Node_Actual (Node);
719 Write_Rewrite_Str (">>>");
723 Sprint_Node_Actual (Node);
727 ------------------------
728 -- Sprint_Node_Actual --
729 ------------------------
731 procedure Sprint_Node_Actual (Node : Node_Id) is
732 Save_Dump_Node : constant Node_Id := Dump_Node;
739 for J in 1 .. Paren_Count (Node) loop
740 Write_Str_With_Col_Check ("(");
743 -- Setup current dump node
747 if Nkind (Node) in N_Subexpr
748 and then Do_Range_Check (Node)
750 Write_Str_With_Col_Check ("{");
753 -- Select print circuit based on node kind
757 when N_Abort_Statement =>
758 Write_Indent_Str_Sloc ("abort ");
759 Sprint_Comma_List (Names (Node));
762 when N_Abortable_Part =>
764 Write_Str_Sloc ("abort ");
765 Sprint_Indented_List (Statements (Node));
767 when N_Abstract_Subprogram_Declaration =>
769 Sprint_Node (Specification (Node));
770 Write_Str_With_Col_Check (" is ");
771 Write_Str_Sloc ("abstract;");
773 when N_Accept_Alternative =>
774 Sprint_Node_List (Pragmas_Before (Node));
776 if Present (Condition (Node)) then
777 Write_Indent_Str ("when ");
778 Sprint_Node (Condition (Node));
783 Sprint_Node_Sloc (Accept_Statement (Node));
784 Sprint_Node_List (Statements (Node));
786 when N_Accept_Statement =>
787 Write_Indent_Str_Sloc ("accept ");
788 Write_Id (Entry_Direct_Name (Node));
790 if Present (Entry_Index (Node)) then
791 Write_Str_With_Col_Check (" (");
792 Sprint_Node (Entry_Index (Node));
796 Write_Param_Specs (Node);
798 if Present (Handled_Statement_Sequence (Node)) then
799 Write_Str_With_Col_Check (" do");
800 Sprint_Node (Handled_Statement_Sequence (Node));
801 Write_Indent_Str ("end ");
802 Write_Id (Entry_Direct_Name (Node));
807 when N_Access_Definition =>
811 if Present (Access_To_Subprogram_Definition (Node)) then
812 Sprint_Node (Access_To_Subprogram_Definition (Node));
816 if Null_Exclusion_Present (Node) then
817 Write_Str ("not null ");
820 Write_Str_With_Col_Check_Sloc ("access ");
822 if All_Present (Node) then
824 elsif Constant_Present (Node) then
825 Write_Str ("constant ");
828 Sprint_Node (Subtype_Mark (Node));
831 when N_Access_Function_Definition =>
835 if Null_Exclusion_Present (Node) then
836 Write_Str ("not null ");
839 Write_Str_With_Col_Check_Sloc ("access ");
841 if Protected_Present (Node) then
842 Write_Str_With_Col_Check ("protected ");
845 Write_Str_With_Col_Check ("function");
846 Write_Param_Specs (Node);
847 Write_Str_With_Col_Check (" return ");
848 Sprint_Node (Result_Definition (Node));
850 when N_Access_Procedure_Definition =>
854 if Null_Exclusion_Present (Node) then
855 Write_Str ("not null ");
858 Write_Str_With_Col_Check_Sloc ("access ");
860 if Protected_Present (Node) then
861 Write_Str_With_Col_Check ("protected ");
864 Write_Str_With_Col_Check ("procedure");
865 Write_Param_Specs (Node);
867 when N_Access_To_Object_Definition =>
868 Write_Str_With_Col_Check_Sloc ("access ");
870 if All_Present (Node) then
871 Write_Str_With_Col_Check ("all ");
872 elsif Constant_Present (Node) then
873 Write_Str_With_Col_Check ("constant ");
878 if Null_Exclusion_Present (Node) then
879 Write_Str ("not null ");
882 Sprint_Node (Subtype_Indication (Node));
885 if Null_Record_Present (Node) then
886 Write_Str_With_Col_Check_Sloc ("(null record)");
889 Write_Str_With_Col_Check_Sloc ("(");
891 if Present (Expressions (Node)) then
892 Sprint_Comma_List (Expressions (Node));
894 if Present (Component_Associations (Node)) then
899 if Present (Component_Associations (Node)) then
906 Nd := First (Component_Associations (Node));
914 if not Is_Rewrite_Insertion (Nd)
915 or else not Dump_Original_Only
929 Write_Str_With_Col_Check_Sloc ("new ");
933 if Null_Exclusion_Present (Node) then
934 Write_Str ("not null ");
937 Sprint_Node (Expression (Node));
939 if Present (Storage_Pool (Node)) then
940 Write_Str_With_Col_Check ("[storage_pool = ");
941 Sprint_Node (Storage_Pool (Node));
946 Sprint_Left_Opnd (Node);
947 Write_Str_Sloc (" and then ");
948 Sprint_Right_Opnd (Node);
951 Write_Indent_Str_Sloc ("for ");
952 Write_Id (Identifier (Node));
953 Write_Str_With_Col_Check (" use at ");
954 Sprint_Node (Expression (Node));
957 when N_Assignment_Statement =>
959 Sprint_Node (Name (Node));
960 Write_Str_Sloc (" := ");
961 Sprint_Node (Expression (Node));
964 when N_Asynchronous_Select =>
965 Write_Indent_Str_Sloc ("select");
967 Sprint_Node (Triggering_Alternative (Node));
970 -- Note: let the printing of Abortable_Part handle outputting
971 -- the ABORT keyword, so that the Slco can be set correctly.
973 Write_Indent_Str ("then ");
974 Sprint_Node (Abortable_Part (Node));
975 Write_Indent_Str ("end select;");
977 when N_Attribute_Definition_Clause =>
978 Write_Indent_Str_Sloc ("for ");
979 Sprint_Node (Name (Node));
981 Write_Name_With_Col_Check (Chars (Node));
982 Write_Str_With_Col_Check (" use ");
983 Sprint_Node (Expression (Node));
986 when N_Attribute_Reference =>
987 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
991 Sprint_Node (Prefix (Node));
992 Write_Char_Sloc (''');
993 Write_Name_With_Col_Check (Attribute_Name (Node));
994 Sprint_Paren_Comma_List (Expressions (Node));
996 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1000 when N_Block_Statement =>
1003 if Present (Identifier (Node))
1004 and then (not Has_Created_Identifier (Node)
1005 or else not Dump_Original_Only)
1007 Write_Rewrite_Str ("<<<");
1008 Write_Id (Identifier (Node));
1010 Write_Rewrite_Str (">>>");
1013 if Present (Declarations (Node)) then
1014 Write_Str_With_Col_Check_Sloc ("declare");
1015 Sprint_Indented_List (Declarations (Node));
1019 Write_Str_With_Col_Check_Sloc ("begin");
1020 Sprint_Node (Handled_Statement_Sequence (Node));
1021 Write_Indent_Str ("end");
1023 if Present (Identifier (Node))
1024 and then (not Has_Created_Identifier (Node)
1025 or else not Dump_Original_Only)
1027 Write_Rewrite_Str ("<<<");
1029 Write_Id (Identifier (Node));
1030 Write_Rewrite_Str (">>>");
1035 when N_Case_Statement =>
1036 Write_Indent_Str_Sloc ("case ");
1037 Sprint_Node (Expression (Node));
1039 Sprint_Indented_List (Alternatives (Node));
1040 Write_Indent_Str ("end case;");
1042 when N_Case_Statement_Alternative =>
1043 Write_Indent_Str_Sloc ("when ");
1044 Sprint_Bar_List (Discrete_Choices (Node));
1046 Sprint_Indented_List (Statements (Node));
1048 when N_Character_Literal =>
1050 Write_Indent_Str (" ");
1053 Write_Char_Sloc (''');
1054 Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
1057 when N_Code_Statement =>
1060 Sprint_Node (Expression (Node));
1063 when N_Compilation_Unit =>
1064 Sprint_Node_List (Context_Items (Node));
1065 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
1067 if Private_Present (Node) then
1068 Write_Indent_Str ("private ");
1072 Sprint_Node_Sloc (Unit (Node));
1074 if Present (Actions (Aux_Decls_Node (Node)))
1076 Present (Pragmas_After (Aux_Decls_Node (Node)))
1081 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
1082 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
1084 when N_Compilation_Unit_Aux =>
1085 null; -- nothing to do, never used, see above
1087 when N_Component_Association =>
1089 Sprint_Bar_List (Choices (Node));
1092 -- Ada 2005 (AI-287): Print the box if present
1094 if Box_Present (Node) then
1095 Write_Str_With_Col_Check ("<>");
1097 Sprint_Node (Expression (Node));
1100 when N_Component_Clause =>
1102 Sprint_Node (Component_Name (Node));
1103 Write_Str_Sloc (" at ");
1104 Sprint_Node (Position (Node));
1106 Write_Str_With_Col_Check ("range ");
1107 Sprint_Node (First_Bit (Node));
1109 Sprint_Node (Last_Bit (Node));
1112 when N_Component_Definition =>
1115 -- Ada 2005 (AI-230): Access definition components
1117 if Present (Access_Definition (Node)) then
1118 Sprint_Node (Access_Definition (Node));
1120 elsif Present (Subtype_Indication (Node)) then
1121 if Aliased_Present (Node) then
1122 Write_Str_With_Col_Check ("aliased ");
1125 -- Ada 2005 (AI-231)
1127 if Null_Exclusion_Present (Node) then
1128 Write_Str (" not null ");
1131 Sprint_Node (Subtype_Indication (Node));
1134 Write_Str (" ??? ");
1137 when N_Component_Declaration =>
1138 if Write_Indent_Identifiers_Sloc (Node) then
1140 Sprint_Node (Component_Definition (Node));
1142 if Present (Expression (Node)) then
1144 Sprint_Node (Expression (Node));
1150 when N_Component_List =>
1151 if Null_Present (Node) then
1153 Write_Indent_Str_Sloc ("null");
1159 Sprint_Indented_List (Component_Items (Node));
1160 Sprint_Node (Variant_Part (Node));
1163 when N_Conditional_Entry_Call =>
1164 Write_Indent_Str_Sloc ("select");
1166 Sprint_Node (Entry_Call_Alternative (Node));
1168 Write_Indent_Str ("else");
1169 Sprint_Indented_List (Else_Statements (Node));
1170 Write_Indent_Str ("end select;");
1172 when N_Conditional_Expression =>
1174 Condition : constant Node_Id := First (Expressions (Node));
1175 Then_Expr : constant Node_Id := Next (Condition);
1176 Else_Expr : constant Node_Id := Next (Then_Expr);
1178 Write_Str_With_Col_Check_Sloc ("(if ");
1179 Sprint_Node (Condition);
1180 Write_Str_With_Col_Check (" then ");
1181 Sprint_Node (Then_Expr);
1182 Write_Str_With_Col_Check (" else ");
1183 Sprint_Node (Else_Expr);
1187 when N_Constrained_Array_Definition =>
1188 Write_Str_With_Col_Check_Sloc ("array ");
1189 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1192 Sprint_Node (Component_Definition (Node));
1194 when N_Decimal_Fixed_Point_Definition =>
1195 Write_Str_With_Col_Check_Sloc (" delta ");
1196 Sprint_Node (Delta_Expression (Node));
1197 Write_Str_With_Col_Check ("digits ");
1198 Sprint_Node (Digits_Expression (Node));
1199 Sprint_Opt_Node (Real_Range_Specification (Node));
1201 when N_Defining_Character_Literal =>
1202 Write_Name_With_Col_Check_Sloc (Chars (Node));
1204 when N_Defining_Identifier =>
1208 when N_Defining_Operator_Symbol =>
1209 Write_Name_With_Col_Check_Sloc (Chars (Node));
1211 when N_Defining_Program_Unit_Name =>
1213 Sprint_Node (Name (Node));
1215 Write_Id (Defining_Identifier (Node));
1217 when N_Delay_Alternative =>
1218 Sprint_Node_List (Pragmas_Before (Node));
1220 if Present (Condition (Node)) then
1222 Write_Str_With_Col_Check ("when ");
1223 Sprint_Node (Condition (Node));
1228 Sprint_Node_Sloc (Delay_Statement (Node));
1229 Sprint_Node_List (Statements (Node));
1231 when N_Delay_Relative_Statement =>
1232 Write_Indent_Str_Sloc ("delay ");
1233 Sprint_Node (Expression (Node));
1236 when N_Delay_Until_Statement =>
1237 Write_Indent_Str_Sloc ("delay until ");
1238 Sprint_Node (Expression (Node));
1241 when N_Delta_Constraint =>
1242 Write_Str_With_Col_Check_Sloc ("delta ");
1243 Sprint_Node (Delta_Expression (Node));
1244 Sprint_Opt_Node (Range_Constraint (Node));
1246 when N_Derived_Type_Definition =>
1247 if Abstract_Present (Node) then
1248 Write_Str_With_Col_Check ("abstract ");
1251 Write_Str_With_Col_Check_Sloc ("new ");
1253 -- Ada 2005 (AI-231)
1255 if Null_Exclusion_Present (Node) then
1256 Write_Str_With_Col_Check ("not null ");
1259 Sprint_Node (Subtype_Indication (Node));
1261 if Present (Interface_List (Node)) then
1262 Sprint_And_List (Interface_List (Node));
1263 Write_Str_With_Col_Check (" with ");
1266 if Present (Record_Extension_Part (Node)) then
1267 if No (Interface_List (Node)) then
1268 Write_Str_With_Col_Check (" with ");
1271 Sprint_Node (Record_Extension_Part (Node));
1274 when N_Designator =>
1275 Sprint_Node (Name (Node));
1276 Write_Char_Sloc ('.');
1277 Write_Id (Identifier (Node));
1279 when N_Digits_Constraint =>
1280 Write_Str_With_Col_Check_Sloc ("digits ");
1281 Sprint_Node (Digits_Expression (Node));
1282 Sprint_Opt_Node (Range_Constraint (Node));
1284 when N_Discriminant_Association =>
1287 if Present (Selector_Names (Node)) then
1288 Sprint_Bar_List (Selector_Names (Node));
1293 Sprint_Node (Expression (Node));
1295 when N_Discriminant_Specification =>
1298 if Write_Identifiers (Node) then
1301 if Null_Exclusion_Present (Node) then
1302 Write_Str ("not null ");
1305 Sprint_Node (Discriminant_Type (Node));
1307 if Present (Expression (Node)) then
1309 Sprint_Node (Expression (Node));
1315 when N_Elsif_Part =>
1316 Write_Indent_Str_Sloc ("elsif ");
1317 Sprint_Node (Condition (Node));
1318 Write_Str_With_Col_Check (" then");
1319 Sprint_Indented_List (Then_Statements (Node));
1324 when N_Entry_Body =>
1325 Write_Indent_Str_Sloc ("entry ");
1326 Write_Id (Defining_Identifier (Node));
1327 Sprint_Node (Entry_Body_Formal_Part (Node));
1328 Write_Str_With_Col_Check (" is");
1329 Sprint_Indented_List (Declarations (Node));
1330 Write_Indent_Str ("begin");
1331 Sprint_Node (Handled_Statement_Sequence (Node));
1332 Write_Indent_Str ("end ");
1333 Write_Id (Defining_Identifier (Node));
1336 when N_Entry_Body_Formal_Part =>
1337 if Present (Entry_Index_Specification (Node)) then
1338 Write_Str_With_Col_Check_Sloc (" (");
1339 Sprint_Node (Entry_Index_Specification (Node));
1343 Write_Param_Specs (Node);
1344 Write_Str_With_Col_Check_Sloc (" when ");
1345 Sprint_Node (Condition (Node));
1347 when N_Entry_Call_Alternative =>
1348 Sprint_Node_List (Pragmas_Before (Node));
1349 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1350 Sprint_Node_List (Statements (Node));
1352 when N_Entry_Call_Statement =>
1354 Sprint_Node_Sloc (Name (Node));
1355 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1358 when N_Entry_Declaration =>
1359 Write_Indent_Str_Sloc ("entry ");
1360 Write_Id (Defining_Identifier (Node));
1362 if Present (Discrete_Subtype_Definition (Node)) then
1363 Write_Str_With_Col_Check (" (");
1364 Sprint_Node (Discrete_Subtype_Definition (Node));
1368 Write_Param_Specs (Node);
1371 when N_Entry_Index_Specification =>
1372 Write_Str_With_Col_Check_Sloc ("for ");
1373 Write_Id (Defining_Identifier (Node));
1374 Write_Str_With_Col_Check (" in ");
1375 Sprint_Node (Discrete_Subtype_Definition (Node));
1377 when N_Enumeration_Representation_Clause =>
1378 Write_Indent_Str_Sloc ("for ");
1379 Write_Id (Identifier (Node));
1380 Write_Str_With_Col_Check (" use ");
1381 Sprint_Node (Array_Aggregate (Node));
1384 when N_Enumeration_Type_Definition =>
1387 -- Skip attempt to print Literals field if it's not there and
1388 -- we are in package Standard (case of Character, which is
1389 -- handled specially (without an explicit literals list).
1391 if Sloc (Node) > Standard_Location
1392 or else Present (Literals (Node))
1394 Sprint_Paren_Comma_List (Literals (Node));
1398 Write_Str_With_Col_Check_Sloc ("<error>");
1400 when N_Exception_Declaration =>
1401 if Write_Indent_Identifiers (Node) then
1402 Write_Str_With_Col_Check (" : ");
1403 Write_Str_Sloc ("exception;");
1406 when N_Exception_Handler =>
1407 Write_Indent_Str_Sloc ("when ");
1409 if Present (Choice_Parameter (Node)) then
1410 Sprint_Node (Choice_Parameter (Node));
1414 Sprint_Bar_List (Exception_Choices (Node));
1416 Sprint_Indented_List (Statements (Node));
1418 when N_Exception_Renaming_Declaration =>
1421 Sprint_Node (Defining_Identifier (Node));
1422 Write_Str_With_Col_Check (" : exception renames ");
1423 Sprint_Node (Name (Node));
1426 when N_Exit_Statement =>
1427 Write_Indent_Str_Sloc ("exit");
1428 Sprint_Opt_Node (Name (Node));
1430 if Present (Condition (Node)) then
1431 Write_Str_With_Col_Check (" when ");
1432 Sprint_Node (Condition (Node));
1437 when N_Expanded_Name =>
1438 Sprint_Node (Prefix (Node));
1439 Write_Char_Sloc ('.');
1440 Sprint_Node (Selector_Name (Node));
1442 when N_Explicit_Dereference =>
1443 Sprint_Node (Prefix (Node));
1444 Write_Char_Sloc ('.');
1445 Write_Str_Sloc ("all");
1447 when N_Extended_Return_Statement =>
1448 Write_Indent_Str_Sloc ("return ");
1449 Sprint_Node_List (Return_Object_Declarations (Node));
1451 if Present (Handled_Statement_Sequence (Node)) then
1452 Write_Str_With_Col_Check (" do");
1453 Sprint_Node (Handled_Statement_Sequence (Node));
1454 Write_Indent_Str ("end return;");
1456 Write_Indent_Str (";");
1459 when N_Extension_Aggregate =>
1460 Write_Str_With_Col_Check_Sloc ("(");
1461 Sprint_Node (Ancestor_Part (Node));
1462 Write_Str_With_Col_Check (" with ");
1464 if Null_Record_Present (Node) then
1465 Write_Str_With_Col_Check ("null record");
1467 if Present (Expressions (Node)) then
1468 Sprint_Comma_List (Expressions (Node));
1470 if Present (Component_Associations (Node)) then
1475 if Present (Component_Associations (Node)) then
1476 Sprint_Comma_List (Component_Associations (Node));
1482 when N_Floating_Point_Definition =>
1483 Write_Str_With_Col_Check_Sloc ("digits ");
1484 Sprint_Node (Digits_Expression (Node));
1485 Sprint_Opt_Node (Real_Range_Specification (Node));
1487 when N_Formal_Decimal_Fixed_Point_Definition =>
1488 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1490 when N_Formal_Derived_Type_Definition =>
1491 Write_Str_With_Col_Check_Sloc ("new ");
1492 Sprint_Node (Subtype_Mark (Node));
1494 if Private_Present (Node) then
1495 Write_Str_With_Col_Check (" with private");
1498 when N_Formal_Abstract_Subprogram_Declaration =>
1499 Write_Indent_Str_Sloc ("with ");
1500 Sprint_Node (Specification (Node));
1502 Write_Str_With_Col_Check (" is abstract");
1504 if Box_Present (Node) then
1505 Write_Str_With_Col_Check (" <>");
1506 elsif Present (Default_Name (Node)) then
1507 Write_Str_With_Col_Check (" ");
1508 Sprint_Node (Default_Name (Node));
1513 when N_Formal_Concrete_Subprogram_Declaration =>
1514 Write_Indent_Str_Sloc ("with ");
1515 Sprint_Node (Specification (Node));
1517 if Box_Present (Node) then
1518 Write_Str_With_Col_Check (" is <>");
1519 elsif Present (Default_Name (Node)) then
1520 Write_Str_With_Col_Check (" is ");
1521 Sprint_Node (Default_Name (Node));
1526 when N_Formal_Discrete_Type_Definition =>
1527 Write_Str_With_Col_Check_Sloc ("<>");
1529 when N_Formal_Floating_Point_Definition =>
1530 Write_Str_With_Col_Check_Sloc ("digits <>");
1532 when N_Formal_Modular_Type_Definition =>
1533 Write_Str_With_Col_Check_Sloc ("mod <>");
1535 when N_Formal_Object_Declaration =>
1538 if Write_Indent_Identifiers (Node) then
1541 if In_Present (Node) then
1542 Write_Str_With_Col_Check ("in ");
1545 if Out_Present (Node) then
1546 Write_Str_With_Col_Check ("out ");
1549 if Present (Subtype_Mark (Node)) then
1551 -- Ada 2005 (AI-423): Formal object with null exclusion
1553 if Null_Exclusion_Present (Node) then
1554 Write_Str ("not null ");
1557 Sprint_Node (Subtype_Mark (Node));
1559 -- Ada 2005 (AI-423): Formal object with access definition
1562 pragma Assert (Present (Access_Definition (Node)));
1564 Sprint_Node (Access_Definition (Node));
1567 if Present (Default_Expression (Node)) then
1569 Sprint_Node (Default_Expression (Node));
1575 when N_Formal_Ordinary_Fixed_Point_Definition =>
1576 Write_Str_With_Col_Check_Sloc ("delta <>");
1578 when N_Formal_Package_Declaration =>
1579 Write_Indent_Str_Sloc ("with package ");
1580 Write_Id (Defining_Identifier (Node));
1581 Write_Str_With_Col_Check (" is new ");
1582 Sprint_Node (Name (Node));
1583 Write_Str_With_Col_Check (" (<>);");
1585 when N_Formal_Private_Type_Definition =>
1586 if Abstract_Present (Node) then
1587 Write_Str_With_Col_Check ("abstract ");
1590 if Tagged_Present (Node) then
1591 Write_Str_With_Col_Check ("tagged ");
1594 if Limited_Present (Node) then
1595 Write_Str_With_Col_Check ("limited ");
1598 Write_Str_With_Col_Check_Sloc ("private");
1600 when N_Formal_Signed_Integer_Type_Definition =>
1601 Write_Str_With_Col_Check_Sloc ("range <>");
1603 when N_Formal_Type_Declaration =>
1604 Write_Indent_Str_Sloc ("type ");
1605 Write_Id (Defining_Identifier (Node));
1607 if Present (Discriminant_Specifications (Node)) then
1608 Write_Discr_Specs (Node);
1609 elsif Unknown_Discriminants_Present (Node) then
1610 Write_Str_With_Col_Check ("(<>)");
1613 Write_Str_With_Col_Check (" is ");
1614 Sprint_Node (Formal_Type_Definition (Node));
1617 when N_Free_Statement =>
1618 Write_Indent_Str_Sloc ("free ");
1619 Sprint_Node (Expression (Node));
1622 when N_Freeze_Entity =>
1623 if Dump_Original_Only then
1626 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1628 Write_Rewrite_Str ("<<<");
1629 Write_Str_With_Col_Check_Sloc ("freeze ");
1630 Write_Id (Entity (Node));
1633 if No (Actions (Node)) then
1637 -- Output freeze actions. We increment Freeze_Indent during
1638 -- this output to avoid generating extra blank lines before
1639 -- any procedures included in the freeze actions.
1641 Freeze_Indent := Freeze_Indent + 1;
1642 Sprint_Indented_List (Actions (Node));
1643 Freeze_Indent := Freeze_Indent - 1;
1644 Write_Indent_Str ("]");
1647 Write_Rewrite_Str (">>>");
1650 when N_Full_Type_Declaration =>
1651 Write_Indent_Str_Sloc ("type ");
1652 Write_Id (Defining_Identifier (Node));
1653 Write_Discr_Specs (Node);
1654 Write_Str_With_Col_Check (" is ");
1655 Sprint_Node (Type_Definition (Node));
1658 when N_Function_Call =>
1660 Note_Implicit_Run_Time_Call (Name (Node));
1661 Sprint_Node (Name (Node));
1662 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1664 when N_Function_Instantiation =>
1665 Write_Indent_Str_Sloc ("function ");
1666 Sprint_Node (Defining_Unit_Name (Node));
1667 Write_Str_With_Col_Check (" is new ");
1668 Sprint_Node (Name (Node));
1669 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1672 when N_Function_Specification =>
1673 Write_Str_With_Col_Check_Sloc ("function ");
1674 Sprint_Node (Defining_Unit_Name (Node));
1675 Write_Param_Specs (Node);
1676 Write_Str_With_Col_Check (" return ");
1678 -- Ada 2005 (AI-231)
1680 if Nkind (Result_Definition (Node)) /= N_Access_Definition
1681 and then Null_Exclusion_Present (Node)
1683 Write_Str (" not null ");
1686 Sprint_Node (Result_Definition (Node));
1688 when N_Generic_Association =>
1691 if Present (Selector_Name (Node)) then
1692 Sprint_Node (Selector_Name (Node));
1696 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1698 when N_Generic_Function_Renaming_Declaration =>
1699 Write_Indent_Str_Sloc ("generic function ");
1700 Sprint_Node (Defining_Unit_Name (Node));
1701 Write_Str_With_Col_Check (" renames ");
1702 Sprint_Node (Name (Node));
1705 when N_Generic_Package_Declaration =>
1707 Write_Indent_Str_Sloc ("generic ");
1708 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1710 Sprint_Node (Specification (Node));
1713 when N_Generic_Package_Renaming_Declaration =>
1714 Write_Indent_Str_Sloc ("generic package ");
1715 Sprint_Node (Defining_Unit_Name (Node));
1716 Write_Str_With_Col_Check (" renames ");
1717 Sprint_Node (Name (Node));
1720 when N_Generic_Procedure_Renaming_Declaration =>
1721 Write_Indent_Str_Sloc ("generic procedure ");
1722 Sprint_Node (Defining_Unit_Name (Node));
1723 Write_Str_With_Col_Check (" renames ");
1724 Sprint_Node (Name (Node));
1727 when N_Generic_Subprogram_Declaration =>
1729 Write_Indent_Str_Sloc ("generic ");
1730 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1732 Sprint_Node (Specification (Node));
1735 when N_Goto_Statement =>
1736 Write_Indent_Str_Sloc ("goto ");
1737 Sprint_Node (Name (Node));
1740 if Nkind (Next (Node)) = N_Label then
1744 when N_Handled_Sequence_Of_Statements =>
1746 Sprint_Indented_List (Statements (Node));
1748 if Present (Exception_Handlers (Node)) then
1749 Write_Indent_Str ("exception");
1751 Sprint_Node_List (Exception_Handlers (Node));
1755 if Present (At_End_Proc (Node)) then
1756 Write_Indent_Str ("at end");
1759 Sprint_Node (At_End_Proc (Node));
1764 when N_Identifier =>
1768 when N_If_Statement =>
1769 Write_Indent_Str_Sloc ("if ");
1770 Sprint_Node (Condition (Node));
1771 Write_Str_With_Col_Check (" then");
1772 Sprint_Indented_List (Then_Statements (Node));
1773 Sprint_Opt_Node_List (Elsif_Parts (Node));
1775 if Present (Else_Statements (Node)) then
1776 Write_Indent_Str ("else");
1777 Sprint_Indented_List (Else_Statements (Node));
1780 Write_Indent_Str ("end if;");
1782 when N_Implicit_Label_Declaration =>
1783 if not Dump_Original_Only then
1785 Write_Rewrite_Str ("<<<");
1787 Write_Id (Defining_Identifier (Node));
1789 Write_Str_With_Col_Check ("label");
1790 Write_Rewrite_Str (">>>");
1794 Sprint_Left_Opnd (Node);
1795 Write_Str_Sloc (" in ");
1796 Sprint_Right_Opnd (Node);
1798 when N_Incomplete_Type_Declaration =>
1799 Write_Indent_Str_Sloc ("type ");
1800 Write_Id (Defining_Identifier (Node));
1802 if Present (Discriminant_Specifications (Node)) then
1803 Write_Discr_Specs (Node);
1804 elsif Unknown_Discriminants_Present (Node) then
1805 Write_Str_With_Col_Check ("(<>)");
1810 when N_Index_Or_Discriminant_Constraint =>
1812 Sprint_Paren_Comma_List (Constraints (Node));
1814 when N_Indexed_Component =>
1815 Sprint_Node_Sloc (Prefix (Node));
1816 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1818 when N_Integer_Literal =>
1819 if Print_In_Hex (Node) then
1820 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1822 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1825 when N_Iteration_Scheme =>
1826 if Present (Condition (Node)) then
1827 Write_Str_With_Col_Check_Sloc ("while ");
1828 Sprint_Node (Condition (Node));
1830 Write_Str_With_Col_Check_Sloc ("for ");
1831 Sprint_Node (Loop_Parameter_Specification (Node));
1836 when N_Itype_Reference =>
1837 Write_Indent_Str_Sloc ("reference ");
1838 Write_Id (Itype (Node));
1841 Write_Indent_Str_Sloc ("<<");
1842 Write_Id (Identifier (Node));
1845 when N_Loop_Parameter_Specification =>
1847 Write_Id (Defining_Identifier (Node));
1848 Write_Str_With_Col_Check (" in ");
1850 if Reverse_Present (Node) then
1851 Write_Str_With_Col_Check ("reverse ");
1854 Sprint_Node (Discrete_Subtype_Definition (Node));
1856 when N_Loop_Statement =>
1859 if Present (Identifier (Node))
1860 and then (not Has_Created_Identifier (Node)
1861 or else not Dump_Original_Only)
1863 Write_Rewrite_Str ("<<<");
1864 Write_Id (Identifier (Node));
1866 Write_Rewrite_Str (">>>");
1867 Sprint_Node (Iteration_Scheme (Node));
1868 Write_Str_With_Col_Check_Sloc ("loop");
1869 Sprint_Indented_List (Statements (Node));
1870 Write_Indent_Str ("end loop ");
1871 Write_Rewrite_Str ("<<<");
1872 Write_Id (Identifier (Node));
1873 Write_Rewrite_Str (">>>");
1877 Sprint_Node (Iteration_Scheme (Node));
1878 Write_Str_With_Col_Check_Sloc ("loop");
1879 Sprint_Indented_List (Statements (Node));
1880 Write_Indent_Str ("end loop;");
1883 when N_Mod_Clause =>
1884 Sprint_Node_List (Pragmas_Before (Node));
1885 Write_Str_With_Col_Check_Sloc ("at mod ");
1886 Sprint_Node (Expression (Node));
1888 when N_Modular_Type_Definition =>
1889 Write_Str_With_Col_Check_Sloc ("mod ");
1890 Sprint_Node (Expression (Node));
1893 Sprint_Left_Opnd (Node);
1894 Write_Str_Sloc (" not in ");
1895 Sprint_Right_Opnd (Node);
1898 Write_Str_With_Col_Check_Sloc ("null");
1900 when N_Null_Statement =>
1901 if Comes_From_Source (Node)
1902 or else Dump_Freeze_Null
1903 or else not Is_List_Member (Node)
1904 or else (No (Prev (Node)) and then No (Next (Node)))
1906 Write_Indent_Str_Sloc ("null;");
1909 when N_Number_Declaration =>
1912 if Write_Indent_Identifiers (Node) then
1913 Write_Str_With_Col_Check (" : constant ");
1915 Sprint_Node (Expression (Node));
1919 when N_Object_Declaration =>
1922 if Write_Indent_Identifiers (Node) then
1925 if Aliased_Present (Node) then
1926 Write_Str_With_Col_Check ("aliased ");
1929 if Constant_Present (Node) then
1930 Write_Str_With_Col_Check ("constant ");
1933 -- Ada 2005 (AI-231)
1935 if Null_Exclusion_Present (Node) then
1936 Write_Str_With_Col_Check ("not null ");
1939 Sprint_Node (Object_Definition (Node));
1941 if Present (Expression (Node)) then
1943 Sprint_Node (Expression (Node));
1949 when N_Object_Renaming_Declaration =>
1952 Sprint_Node (Defining_Identifier (Node));
1955 -- Ada 2005 (AI-230): Access renamings
1957 if Present (Access_Definition (Node)) then
1958 Sprint_Node (Access_Definition (Node));
1960 elsif Present (Subtype_Mark (Node)) then
1962 -- Ada 2005 (AI-423): Object renaming with a null exclusion
1964 if Null_Exclusion_Present (Node) then
1965 Write_Str ("not null ");
1968 Sprint_Node (Subtype_Mark (Node));
1971 Write_Str (" ??? ");
1974 Write_Str_With_Col_Check (" renames ");
1975 Sprint_Node (Name (Node));
1979 Write_Operator (Node, "abs ");
1980 Sprint_Right_Opnd (Node);
1983 Sprint_Left_Opnd (Node);
1984 Write_Operator (Node, " + ");
1985 Sprint_Right_Opnd (Node);
1988 Sprint_Left_Opnd (Node);
1989 Write_Operator (Node, " and ");
1990 Sprint_Right_Opnd (Node);
1993 Sprint_Left_Opnd (Node);
1994 Write_Operator (Node, " & ");
1995 Sprint_Right_Opnd (Node);
1998 Sprint_Left_Opnd (Node);
2000 Process_TFAI_RR_Flags (Node);
2001 Write_Operator (Node, "/ ");
2002 Sprint_Right_Opnd (Node);
2005 Sprint_Left_Opnd (Node);
2006 Write_Operator (Node, " = ");
2007 Sprint_Right_Opnd (Node);
2010 Sprint_Left_Opnd (Node);
2011 Write_Operator (Node, " ** ");
2012 Sprint_Right_Opnd (Node);
2015 Sprint_Left_Opnd (Node);
2016 Write_Operator (Node, " >= ");
2017 Sprint_Right_Opnd (Node);
2020 Sprint_Left_Opnd (Node);
2021 Write_Operator (Node, " > ");
2022 Sprint_Right_Opnd (Node);
2025 Sprint_Left_Opnd (Node);
2026 Write_Operator (Node, " <= ");
2027 Sprint_Right_Opnd (Node);
2030 Sprint_Left_Opnd (Node);
2031 Write_Operator (Node, " < ");
2032 Sprint_Right_Opnd (Node);
2035 Write_Operator (Node, "-");
2036 Sprint_Right_Opnd (Node);
2039 Sprint_Left_Opnd (Node);
2041 if Treat_Fixed_As_Integer (Node) then
2045 Write_Operator (Node, " mod ");
2046 Sprint_Right_Opnd (Node);
2048 when N_Op_Multiply =>
2049 Sprint_Left_Opnd (Node);
2051 Process_TFAI_RR_Flags (Node);
2052 Write_Operator (Node, "* ");
2053 Sprint_Right_Opnd (Node);
2056 Sprint_Left_Opnd (Node);
2057 Write_Operator (Node, " /= ");
2058 Sprint_Right_Opnd (Node);
2061 Write_Operator (Node, "not ");
2062 Sprint_Right_Opnd (Node);
2065 Sprint_Left_Opnd (Node);
2066 Write_Operator (Node, " or ");
2067 Sprint_Right_Opnd (Node);
2070 Write_Operator (Node, "+");
2071 Sprint_Right_Opnd (Node);
2074 Sprint_Left_Opnd (Node);
2076 if Treat_Fixed_As_Integer (Node) then
2080 Write_Operator (Node, " rem ");
2081 Sprint_Right_Opnd (Node);
2087 Write_Str_With_Col_Check ("(");
2088 Sprint_Node (Left_Opnd (Node));
2090 Sprint_Node (Right_Opnd (Node));
2093 when N_Op_Subtract =>
2094 Sprint_Left_Opnd (Node);
2095 Write_Operator (Node, " - ");
2096 Sprint_Right_Opnd (Node);
2099 Sprint_Left_Opnd (Node);
2100 Write_Operator (Node, " xor ");
2101 Sprint_Right_Opnd (Node);
2103 when N_Operator_Symbol =>
2104 Write_Name_With_Col_Check_Sloc (Chars (Node));
2106 when N_Ordinary_Fixed_Point_Definition =>
2107 Write_Str_With_Col_Check_Sloc ("delta ");
2108 Sprint_Node (Delta_Expression (Node));
2109 Sprint_Opt_Node (Real_Range_Specification (Node));
2112 Sprint_Left_Opnd (Node);
2113 Write_Str_Sloc (" or else ");
2114 Sprint_Right_Opnd (Node);
2116 when N_Others_Choice =>
2117 if All_Others (Node) then
2118 Write_Str_With_Col_Check ("all ");
2121 Write_Str_With_Col_Check_Sloc ("others");
2123 when N_Package_Body =>
2125 Write_Indent_Str_Sloc ("package body ");
2126 Sprint_Node (Defining_Unit_Name (Node));
2128 Sprint_Indented_List (Declarations (Node));
2130 if Present (Handled_Statement_Sequence (Node)) then
2131 Write_Indent_Str ("begin");
2132 Sprint_Node (Handled_Statement_Sequence (Node));
2135 Write_Indent_Str ("end ");
2136 Sprint_Node (Defining_Unit_Name (Node));
2139 when N_Package_Body_Stub =>
2140 Write_Indent_Str_Sloc ("package body ");
2141 Sprint_Node (Defining_Identifier (Node));
2142 Write_Str_With_Col_Check (" is separate;");
2144 when N_Package_Declaration =>
2147 Sprint_Node_Sloc (Specification (Node));
2150 when N_Package_Instantiation =>
2152 Write_Indent_Str_Sloc ("package ");
2153 Sprint_Node (Defining_Unit_Name (Node));
2154 Write_Str (" is new ");
2155 Sprint_Node (Name (Node));
2156 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2159 when N_Package_Renaming_Declaration =>
2160 Write_Indent_Str_Sloc ("package ");
2161 Sprint_Node (Defining_Unit_Name (Node));
2162 Write_Str_With_Col_Check (" renames ");
2163 Sprint_Node (Name (Node));
2166 when N_Package_Specification =>
2167 Write_Str_With_Col_Check_Sloc ("package ");
2168 Sprint_Node (Defining_Unit_Name (Node));
2170 Sprint_Indented_List (Visible_Declarations (Node));
2172 if Present (Private_Declarations (Node)) then
2173 Write_Indent_Str ("private");
2174 Sprint_Indented_List (Private_Declarations (Node));
2177 Write_Indent_Str ("end ");
2178 Sprint_Node (Defining_Unit_Name (Node));
2180 when N_Parameter_Association =>
2181 Sprint_Node_Sloc (Selector_Name (Node));
2183 Sprint_Node (Explicit_Actual_Parameter (Node));
2185 when N_Parameter_Specification =>
2188 if Write_Identifiers (Node) then
2191 if In_Present (Node) then
2192 Write_Str_With_Col_Check ("in ");
2195 if Out_Present (Node) then
2196 Write_Str_With_Col_Check ("out ");
2199 -- Ada 2005 (AI-231) parameter specification may carry
2200 -- null exclusion. Do not print it now if this is an
2201 -- access parameter, it is emitted when the access
2202 -- definition is displayed.
2204 if Null_Exclusion_Present (Node)
2205 and then Nkind (Parameter_Type (Node))
2206 /= N_Access_Definition
2208 Write_Str ("not null ");
2211 Sprint_Node (Parameter_Type (Node));
2213 if Present (Expression (Node)) then
2215 Sprint_Node (Expression (Node));
2221 when N_Pop_Constraint_Error_Label =>
2222 Write_Indent_Str ("%pop_constraint_error_label");
2224 when N_Pop_Program_Error_Label =>
2225 Write_Indent_Str ("%pop_program_error_label");
2227 when N_Pop_Storage_Error_Label =>
2228 Write_Indent_Str ("%pop_storage_error_label");
2230 when N_Push_Constraint_Error_Label =>
2231 Write_Indent_Str ("%push_constraint_error_label (");
2233 if Present (Exception_Label (Node)) then
2234 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2239 when N_Push_Program_Error_Label =>
2240 Write_Indent_Str ("%push_program_error_label (");
2242 if Present (Exception_Label (Node)) then
2243 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2248 when N_Push_Storage_Error_Label =>
2249 Write_Indent_Str ("%push_storage_error_label (");
2251 if Present (Exception_Label (Node)) then
2252 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2258 Write_Indent_Str_Sloc ("pragma ");
2259 Write_Name_With_Col_Check (Chars (Node));
2261 if Present (Pragma_Argument_Associations (Node)) then
2262 Sprint_Opt_Paren_Comma_List
2263 (Pragma_Argument_Associations (Node));
2268 when N_Pragma_Argument_Association =>
2271 if Chars (Node) /= No_Name then
2272 Write_Name_With_Col_Check (Chars (Node));
2276 Sprint_Node (Expression (Node));
2278 when N_Private_Type_Declaration =>
2279 Write_Indent_Str_Sloc ("type ");
2280 Write_Id (Defining_Identifier (Node));
2282 if Present (Discriminant_Specifications (Node)) then
2283 Write_Discr_Specs (Node);
2284 elsif Unknown_Discriminants_Present (Node) then
2285 Write_Str_With_Col_Check ("(<>)");
2290 if Tagged_Present (Node) then
2291 Write_Str_With_Col_Check ("tagged ");
2294 if Limited_Present (Node) then
2295 Write_Str_With_Col_Check ("limited ");
2298 Write_Str_With_Col_Check ("private;");
2300 when N_Private_Extension_Declaration =>
2301 Write_Indent_Str_Sloc ("type ");
2302 Write_Id (Defining_Identifier (Node));
2304 if Present (Discriminant_Specifications (Node)) then
2305 Write_Discr_Specs (Node);
2306 elsif Unknown_Discriminants_Present (Node) then
2307 Write_Str_With_Col_Check ("(<>)");
2310 Write_Str_With_Col_Check (" is new ");
2311 Sprint_Node (Subtype_Indication (Node));
2312 Write_Str_With_Col_Check (" with private;");
2314 when N_Procedure_Call_Statement =>
2317 Note_Implicit_Run_Time_Call (Name (Node));
2318 Sprint_Node (Name (Node));
2319 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2322 when N_Procedure_Instantiation =>
2323 Write_Indent_Str_Sloc ("procedure ");
2324 Sprint_Node (Defining_Unit_Name (Node));
2325 Write_Str_With_Col_Check (" is new ");
2326 Sprint_Node (Name (Node));
2327 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2330 when N_Procedure_Specification =>
2331 Write_Str_With_Col_Check_Sloc ("procedure ");
2332 Sprint_Node (Defining_Unit_Name (Node));
2333 Write_Param_Specs (Node);
2335 when N_Protected_Body =>
2336 Write_Indent_Str_Sloc ("protected body ");
2337 Write_Id (Defining_Identifier (Node));
2339 Sprint_Indented_List (Declarations (Node));
2340 Write_Indent_Str ("end ");
2341 Write_Id (Defining_Identifier (Node));
2344 when N_Protected_Body_Stub =>
2345 Write_Indent_Str_Sloc ("protected body ");
2346 Write_Id (Defining_Identifier (Node));
2347 Write_Str_With_Col_Check (" is separate;");
2349 when N_Protected_Definition =>
2351 Sprint_Indented_List (Visible_Declarations (Node));
2353 if Present (Private_Declarations (Node)) then
2354 Write_Indent_Str ("private");
2355 Sprint_Indented_List (Private_Declarations (Node));
2358 Write_Indent_Str ("end ");
2360 when N_Protected_Type_Declaration =>
2361 Write_Indent_Str_Sloc ("protected type ");
2362 Write_Id (Defining_Identifier (Node));
2363 Write_Discr_Specs (Node);
2365 if Present (Interface_List (Node)) then
2366 Write_Str (" is new ");
2367 Sprint_And_List (Interface_List (Node));
2368 Write_Str (" with ");
2373 Sprint_Node (Protected_Definition (Node));
2374 Write_Id (Defining_Identifier (Node));
2377 when N_Qualified_Expression =>
2378 Sprint_Node (Subtype_Mark (Node));
2379 Write_Char_Sloc (''');
2381 -- Print expression, make sure we have at least one level of
2382 -- parentheses around the expression. For cases of qualified
2383 -- expressions in the source, this is always the case, but
2384 -- for generated qualifications, there may be no explicit
2385 -- parentheses present.
2387 if Paren_Count (Expression (Node)) /= 0 then
2388 Sprint_Node (Expression (Node));
2391 Sprint_Node (Expression (Node));
2395 when N_Raise_Constraint_Error =>
2397 -- This node can be used either as a subexpression or as a
2398 -- statement form. The following test is a reasonably reliable
2399 -- way to distinguish the two cases.
2401 if Is_List_Member (Node)
2402 and then Nkind (Parent (Node)) not in N_Subexpr
2407 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2408 Write_Condition_And_Reason (Node);
2410 when N_Raise_Program_Error =>
2412 -- This node can be used either as a subexpression or as a
2413 -- statement form. The following test is a reasonably reliable
2414 -- way to distinguish the two cases.
2416 if Is_List_Member (Node)
2417 and then Nkind (Parent (Node)) not in N_Subexpr
2422 Write_Str_With_Col_Check_Sloc ("[program_error");
2423 Write_Condition_And_Reason (Node);
2425 when N_Raise_Storage_Error =>
2427 -- This node can be used either as a subexpression or as a
2428 -- statement form. The following test is a reasonably reliable
2429 -- way to distinguish the two cases.
2431 if Is_List_Member (Node)
2432 and then Nkind (Parent (Node)) not in N_Subexpr
2437 Write_Str_With_Col_Check_Sloc ("[storage_error");
2438 Write_Condition_And_Reason (Node);
2440 when N_Raise_Statement =>
2441 Write_Indent_Str_Sloc ("raise ");
2442 Sprint_Node (Name (Node));
2446 Sprint_Node (Low_Bound (Node));
2447 Write_Str_Sloc (" .. ");
2448 Sprint_Node (High_Bound (Node));
2450 when N_Range_Constraint =>
2451 Write_Str_With_Col_Check_Sloc ("range ");
2452 Sprint_Node (Range_Expression (Node));
2454 when N_Real_Literal =>
2455 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2457 when N_Real_Range_Specification =>
2458 Write_Str_With_Col_Check_Sloc ("range ");
2459 Sprint_Node (Low_Bound (Node));
2461 Sprint_Node (High_Bound (Node));
2463 when N_Record_Definition =>
2464 if Abstract_Present (Node) then
2465 Write_Str_With_Col_Check ("abstract ");
2468 if Tagged_Present (Node) then
2469 Write_Str_With_Col_Check ("tagged ");
2472 if Limited_Present (Node) then
2473 Write_Str_With_Col_Check ("limited ");
2476 if Null_Present (Node) then
2477 Write_Str_With_Col_Check_Sloc ("null record");
2480 Write_Str_With_Col_Check_Sloc ("record");
2481 Sprint_Node (Component_List (Node));
2482 Write_Indent_Str ("end record");
2485 when N_Record_Representation_Clause =>
2486 Write_Indent_Str_Sloc ("for ");
2487 Sprint_Node (Identifier (Node));
2488 Write_Str_With_Col_Check (" use record ");
2490 if Present (Mod_Clause (Node)) then
2491 Sprint_Node (Mod_Clause (Node));
2494 Sprint_Indented_List (Component_Clauses (Node));
2495 Write_Indent_Str ("end record;");
2498 Sprint_Node (Prefix (Node));
2499 Write_Str_With_Col_Check_Sloc ("'reference");
2501 when N_Requeue_Statement =>
2502 Write_Indent_Str_Sloc ("requeue ");
2503 Sprint_Node (Name (Node));
2505 if Abort_Present (Node) then
2506 Write_Str_With_Col_Check (" with abort");
2511 when N_Return_Statement =>
2512 if Present (Expression (Node)) then
2513 Write_Indent_Str_Sloc ("return ");
2514 Sprint_Node (Expression (Node));
2517 Write_Indent_Str_Sloc ("return;");
2520 when N_Selective_Accept =>
2521 Write_Indent_Str_Sloc ("select");
2526 Alt_Node := First (Select_Alternatives (Node));
2529 Sprint_Node (Alt_Node);
2532 exit when No (Alt_Node);
2533 Write_Indent_Str ("or");
2537 if Present (Else_Statements (Node)) then
2538 Write_Indent_Str ("else");
2539 Sprint_Indented_List (Else_Statements (Node));
2542 Write_Indent_Str ("end select;");
2544 when N_Signed_Integer_Type_Definition =>
2545 Write_Str_With_Col_Check_Sloc ("range ");
2546 Sprint_Node (Low_Bound (Node));
2548 Sprint_Node (High_Bound (Node));
2550 when N_Single_Protected_Declaration =>
2551 Write_Indent_Str_Sloc ("protected ");
2552 Write_Id (Defining_Identifier (Node));
2554 Sprint_Node (Protected_Definition (Node));
2555 Write_Id (Defining_Identifier (Node));
2558 when N_Single_Task_Declaration =>
2559 Write_Indent_Str_Sloc ("task ");
2560 Write_Id (Defining_Identifier (Node));
2562 if Present (Task_Definition (Node)) then
2564 Sprint_Node (Task_Definition (Node));
2565 Write_Id (Defining_Identifier (Node));
2570 when N_Selected_Component =>
2571 Sprint_Node (Prefix (Node));
2572 Write_Char_Sloc ('.');
2573 Sprint_Node (Selector_Name (Node));
2577 Sprint_Node (Prefix (Node));
2578 Write_Str_With_Col_Check (" (");
2579 Sprint_Node (Discrete_Range (Node));
2582 when N_String_Literal =>
2583 if String_Length (Strval (Node)) + Column > 75 then
2584 Write_Indent_Str (" ");
2588 Write_String_Table_Entry (Strval (Node));
2590 when N_Subprogram_Body =>
2592 -- Output extra blank line unless we are in freeze actions
2594 if Freeze_Indent = 0 then
2599 Sprint_Node_Sloc (Specification (Node));
2602 Sprint_Indented_List (Declarations (Node));
2603 Write_Indent_Str ("begin");
2604 Sprint_Node (Handled_Statement_Sequence (Node));
2606 Write_Indent_Str ("end ");
2607 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2610 if Is_List_Member (Node)
2611 and then Present (Next (Node))
2612 and then Nkind (Next (Node)) /= N_Subprogram_Body
2617 when N_Subprogram_Body_Stub =>
2619 Sprint_Node_Sloc (Specification (Node));
2620 Write_Str_With_Col_Check (" is separate;");
2622 when N_Subprogram_Declaration =>
2624 Sprint_Node_Sloc (Specification (Node));
2626 if Nkind (Specification (Node)) = N_Procedure_Specification
2627 and then Null_Present (Specification (Node))
2629 Write_Str_With_Col_Check (" is null");
2634 when N_Subprogram_Info =>
2635 Sprint_Node (Identifier (Node));
2636 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2638 when N_Subprogram_Renaming_Declaration =>
2640 Sprint_Node (Specification (Node));
2641 Write_Str_With_Col_Check_Sloc (" renames ");
2642 Sprint_Node (Name (Node));
2645 when N_Subtype_Declaration =>
2646 Write_Indent_Str_Sloc ("subtype ");
2647 Write_Id (Defining_Identifier (Node));
2650 -- Ada 2005 (AI-231)
2652 if Null_Exclusion_Present (Node) then
2653 Write_Str ("not null ");
2656 Sprint_Node (Subtype_Indication (Node));
2659 when N_Subtype_Indication =>
2660 Sprint_Node_Sloc (Subtype_Mark (Node));
2662 Sprint_Node (Constraint (Node));
2665 Write_Indent_Str_Sloc ("separate (");
2666 Sprint_Node (Name (Node));
2669 Sprint_Node (Proper_Body (Node));
2672 Write_Indent_Str_Sloc ("task body ");
2673 Write_Id (Defining_Identifier (Node));
2675 Sprint_Indented_List (Declarations (Node));
2676 Write_Indent_Str ("begin");
2677 Sprint_Node (Handled_Statement_Sequence (Node));
2678 Write_Indent_Str ("end ");
2679 Write_Id (Defining_Identifier (Node));
2682 when N_Task_Body_Stub =>
2683 Write_Indent_Str_Sloc ("task body ");
2684 Write_Id (Defining_Identifier (Node));
2685 Write_Str_With_Col_Check (" is separate;");
2687 when N_Task_Definition =>
2689 Sprint_Indented_List (Visible_Declarations (Node));
2691 if Present (Private_Declarations (Node)) then
2692 Write_Indent_Str ("private");
2693 Sprint_Indented_List (Private_Declarations (Node));
2696 Write_Indent_Str ("end ");
2698 when N_Task_Type_Declaration =>
2699 Write_Indent_Str_Sloc ("task type ");
2700 Write_Id (Defining_Identifier (Node));
2701 Write_Discr_Specs (Node);
2703 if Present (Interface_List (Node)) then
2704 Write_Str (" is new ");
2705 Sprint_And_List (Interface_List (Node));
2708 if Present (Task_Definition (Node)) then
2709 if No (Interface_List (Node)) then
2712 Write_Str (" with ");
2715 Sprint_Node (Task_Definition (Node));
2716 Write_Id (Defining_Identifier (Node));
2721 when N_Terminate_Alternative =>
2722 Sprint_Node_List (Pragmas_Before (Node));
2726 if Present (Condition (Node)) then
2727 Write_Str_With_Col_Check ("when ");
2728 Sprint_Node (Condition (Node));
2732 Write_Str_With_Col_Check_Sloc ("terminate;");
2733 Sprint_Node_List (Pragmas_After (Node));
2735 when N_Timed_Entry_Call =>
2736 Write_Indent_Str_Sloc ("select");
2738 Sprint_Node (Entry_Call_Alternative (Node));
2740 Write_Indent_Str ("or");
2742 Sprint_Node (Delay_Alternative (Node));
2744 Write_Indent_Str ("end select;");
2746 when N_Triggering_Alternative =>
2747 Sprint_Node_List (Pragmas_Before (Node));
2748 Sprint_Node_Sloc (Triggering_Statement (Node));
2749 Sprint_Node_List (Statements (Node));
2751 when N_Type_Conversion =>
2753 Sprint_Node (Subtype_Mark (Node));
2756 if Conversion_OK (Node) then
2760 if Float_Truncate (Node) then
2764 if Rounded_Result (Node) then
2769 Sprint_Node (Expression (Node));
2772 when N_Unchecked_Expression =>
2775 Sprint_Node_Sloc (Expression (Node));
2778 when N_Unchecked_Type_Conversion =>
2779 Sprint_Node (Subtype_Mark (Node));
2781 Write_Str_With_Col_Check ("(");
2782 Sprint_Node_Sloc (Expression (Node));
2785 when N_Unconstrained_Array_Definition =>
2786 Write_Str_With_Col_Check_Sloc ("array (");
2791 Node1 := First (Subtype_Marks (Node));
2793 Sprint_Node (Node1);
2794 Write_Str_With_Col_Check (" range <>");
2796 exit when Node1 = Empty;
2801 Write_Str (") of ");
2802 Sprint_Node (Component_Definition (Node));
2804 when N_Unused_At_Start | N_Unused_At_End =>
2805 Write_Indent_Str ("***** Error, unused node encountered *****");
2808 when N_Use_Package_Clause =>
2809 Write_Indent_Str_Sloc ("use ");
2810 Sprint_Comma_List (Names (Node));
2813 when N_Use_Type_Clause =>
2814 Write_Indent_Str_Sloc ("use type ");
2815 Sprint_Comma_List (Subtype_Marks (Node));
2818 when N_Validate_Unchecked_Conversion =>
2819 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2820 Sprint_Node (Source_Type (Node));
2822 Sprint_Node (Target_Type (Node));
2826 Write_Indent_Str_Sloc ("when ");
2827 Sprint_Bar_List (Discrete_Choices (Node));
2829 Sprint_Node (Component_List (Node));
2831 when N_Variant_Part =>
2833 Write_Indent_Str_Sloc ("case ");
2834 Sprint_Node (Name (Node));
2836 Sprint_Indented_List (Variants (Node));
2837 Write_Indent_Str ("end case");
2840 when N_With_Clause =>
2842 -- Special test, if we are dumping the original tree only,
2843 -- then we want to eliminate the bogus with clauses that
2844 -- correspond to the non-existent children of Text_IO.
2846 if Dump_Original_Only
2847 and then Is_Text_IO_Kludge_Unit (Name (Node))
2851 -- Normal case, output the with clause
2854 if First_Name (Node) or else not Dump_Original_Only then
2856 -- Ada 2005 (AI-50217): Print limited with_clauses
2858 if Private_Present (Node) and Limited_Present (Node) then
2859 Write_Indent_Str ("limited private with ");
2861 elsif Private_Present (Node) then
2862 Write_Indent_Str ("private with ");
2864 elsif Limited_Present (Node) then
2865 Write_Indent_Str ("limited with ");
2868 Write_Indent_Str ("with ");
2875 Sprint_Node_Sloc (Name (Node));
2877 if Last_Name (Node) or else not Dump_Original_Only then
2882 when N_With_Type_Clause =>
2883 Write_Indent_Str ("with type ");
2884 Sprint_Node_Sloc (Name (Node));
2886 if Tagged_Present (Node) then
2887 Write_Str (" is tagged;");
2889 Write_Str (" is access;");
2894 if Nkind (Node) in N_Subexpr
2895 and then Do_Range_Check (Node)
2900 for J in 1 .. Paren_Count (Node) loop
2904 Dump_Node := Save_Dump_Node;
2905 end Sprint_Node_Actual;
2907 ----------------------
2908 -- Sprint_Node_List --
2909 ----------------------
2911 procedure Sprint_Node_List (List : List_Id) is
2915 if Is_Non_Empty_List (List) then
2916 Node := First (List);
2921 exit when Node = Empty;
2924 end Sprint_Node_List;
2926 ----------------------
2927 -- Sprint_Node_Sloc --
2928 ----------------------
2930 procedure Sprint_Node_Sloc (Node : Node_Id) is
2934 if Debug_Generated_Code and then Present (Dump_Node) then
2935 Set_Sloc (Dump_Node, Sloc (Node));
2938 end Sprint_Node_Sloc;
2940 ---------------------
2941 -- Sprint_Opt_Node --
2942 ---------------------
2944 procedure Sprint_Opt_Node (Node : Node_Id) is
2946 if Present (Node) then
2950 end Sprint_Opt_Node;
2952 --------------------------
2953 -- Sprint_Opt_Node_List --
2954 --------------------------
2956 procedure Sprint_Opt_Node_List (List : List_Id) is
2958 if Present (List) then
2959 Sprint_Node_List (List);
2961 end Sprint_Opt_Node_List;
2963 ---------------------------------
2964 -- Sprint_Opt_Paren_Comma_List --
2965 ---------------------------------
2967 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2969 if Is_Non_Empty_List (List) then
2971 Sprint_Paren_Comma_List (List);
2973 end Sprint_Opt_Paren_Comma_List;
2975 -----------------------------
2976 -- Sprint_Paren_Comma_List --
2977 -----------------------------
2979 procedure Sprint_Paren_Comma_List (List : List_Id) is
2981 Node_Exists : Boolean := False;
2985 if Is_Non_Empty_List (List) then
2987 if Dump_Original_Only then
2989 while Present (N) loop
2990 if not Is_Rewrite_Insertion (N) then
2991 Node_Exists := True;
2998 if not Node_Exists then
3003 Write_Str_With_Col_Check ("(");
3004 Sprint_Comma_List (List);
3007 end Sprint_Paren_Comma_List;
3009 ----------------------
3010 -- Sprint_Right_Opnd --
3011 ----------------------
3013 procedure Sprint_Right_Opnd (N : Node_Id) is
3014 Opnd : constant Node_Id := Right_Opnd (N);
3017 if Paren_Count (Opnd) /= 0
3018 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
3027 end Sprint_Right_Opnd;
3029 ---------------------
3030 -- Write_Char_Sloc --
3031 ---------------------
3033 procedure Write_Char_Sloc (C : Character) is
3035 if Debug_Generated_Code and then C /= ' ' then
3040 end Write_Char_Sloc;
3042 --------------------------------
3043 -- Write_Condition_And_Reason --
3044 --------------------------------
3046 procedure Write_Condition_And_Reason (Node : Node_Id) is
3047 Cond : constant Node_Id := Condition (Node);
3048 Image : constant String := RT_Exception_Code'Image
3049 (RT_Exception_Code'Val
3050 (UI_To_Int (Reason (Node))));
3053 if Present (Cond) then
3055 -- If condition is a single entity, or NOT with a single entity,
3056 -- output all on one line, since it will likely fit just fine.
3058 if Is_Entity_Name (Cond)
3059 or else (Nkind (Cond) = N_Op_Not
3060 and then Is_Entity_Name (Right_Opnd (Cond)))
3062 Write_Str_With_Col_Check (" when ");
3066 -- Otherwise for more complex condition, multiple lines
3069 Write_Str_With_Col_Check (" when");
3070 Indent := Indent + 2;
3074 Indent := Indent - 2;
3077 -- If no condition, just need a space (all on one line)
3087 for J in 4 .. Image'Last loop
3088 if Image (J) = '_' then
3091 Write_Char (Fold_Lower (Image (J)));
3096 end Write_Condition_And_Reason;
3098 --------------------------------
3099 -- Write_Corresponding_Source --
3100 --------------------------------
3102 procedure Write_Corresponding_Source (S : String) is
3104 Src : Source_Buffer_Ptr;
3107 -- Ignore if not in dump source text mode, or if in freeze actions
3109 if Dump_Source_Text and then Freeze_Indent = 0 then
3111 -- Ignore null string
3117 -- Ignore space or semicolon at end of given string
3119 if S (S'Last) = ' ' or else S (S'Last) = ';' then
3120 Write_Corresponding_Source (S (S'First .. S'Last - 1));
3124 -- Loop to look at next lines not yet printed in source file
3127 Last_Line_Printed + 1 .. Last_Source_Line (Current_Source_File)
3129 Src := Source_Text (Current_Source_File);
3130 Loc := Line_Start (L, Current_Source_File);
3132 -- If comment, keep looking
3134 if Src (Loc .. Loc + 1) = "--" then
3137 -- Search to first non-blank
3140 while Src (Loc) not in Line_Terminator loop
3144 if Src (Loc) /= ' ' and then Src (Loc) /= ASCII.HT then
3146 -- Loop through characters in string to see if we match
3148 for J in S'Range loop
3150 -- If mismatch, then not the case we are looking for
3152 if Src (Loc) /= S (J) then
3159 -- If we fall through, string matched, if white space or
3160 -- semicolon after the matched string, this is the case
3161 -- we are looking for.
3163 if Src (Loc) in Line_Terminator
3164 or else Src (Loc) = ' '
3165 or else Src (Loc) = ASCII.HT
3166 or else Src (Loc) = ';'
3168 -- So output source lines up to and including this one
3170 Write_Source_Lines (L);
3179 -- Line was all blanks, or a comment line, keep looking
3183 end Write_Corresponding_Source;
3185 -----------------------
3186 -- Write_Discr_Specs --
3187 -----------------------
3189 procedure Write_Discr_Specs (N : Node_Id) is
3194 Specs := Discriminant_Specifications (N);
3196 if Present (Specs) then
3197 Write_Str_With_Col_Check (" (");
3198 Spec := First (Specs);
3203 exit when Spec = Empty;
3205 -- Add semicolon, unless we are printing original tree and the
3206 -- next specification is part of a list (but not the first
3207 -- element of that list)
3209 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3216 end Write_Discr_Specs;
3222 procedure Write_Ekind (E : Entity_Id) is
3223 S : constant String := Entity_Kind'Image (Ekind (E));
3226 Name_Len := S'Length;
3227 Name_Buffer (1 .. Name_Len) := S;
3228 Set_Casing (Mixed_Case);
3229 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3236 procedure Write_Id (N : Node_Id) is
3238 -- Deal with outputting Itype
3240 -- Note: if we are printing the full tree with -gnatds, then we may
3241 -- end up picking up the Associated_Node link from a generic template
3242 -- here which overlaps the Entity field, but as documented, Write_Itype
3243 -- is defended against junk calls.
3245 if Nkind (N) in N_Entity then
3247 elsif Nkind (N) in N_Has_Entity then
3248 Write_Itype (Entity (N));
3251 -- Case of a defining identifier
3253 if Nkind (N) = N_Defining_Identifier then
3255 -- If defining identifier has an interface name (and no
3256 -- address clause), then we output the interface name.
3258 if (Is_Imported (N) or else Is_Exported (N))
3259 and then Present (Interface_Name (N))
3260 and then No (Address_Clause (N))
3262 String_To_Name_Buffer (Strval (Interface_Name (N)));
3263 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3265 -- If no interface name (or inactive because there was
3266 -- an address clause), then just output the Chars name.
3269 Write_Name_With_Col_Check (Chars (N));
3272 -- Case of selector of an expanded name where the expanded name
3273 -- has an associated entity, output this entity.
3275 elsif Nkind (Parent (N)) = N_Expanded_Name
3276 and then Selector_Name (Parent (N)) = N
3277 and then Present (Entity (Parent (N)))
3279 Write_Id (Entity (Parent (N)));
3281 -- For any other node with an associated entity, output it
3283 elsif Nkind (N) in N_Has_Entity
3284 and then Present (Entity_Or_Associated_Node (N))
3285 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
3287 Write_Id (Entity (N));
3289 -- All other cases, we just print the Chars field
3292 Write_Name_With_Col_Check (Chars (N));
3296 -----------------------
3297 -- Write_Identifiers --
3298 -----------------------
3300 function Write_Identifiers (Node : Node_Id) return Boolean is
3302 Sprint_Node (Defining_Identifier (Node));
3304 -- The remainder of the declaration must be printed unless we are
3305 -- printing the original tree and this is not the last identifier
3308 not Dump_Original_Only or else not More_Ids (Node);
3310 end Write_Identifiers;
3312 ------------------------
3313 -- Write_Implicit_Def --
3314 ------------------------
3316 procedure Write_Implicit_Def (E : Entity_Id) is
3321 when E_Array_Subtype =>
3322 Write_Str_With_Col_Check ("subtype ");
3324 Write_Str_With_Col_Check (" is ");
3325 Write_Id (Base_Type (E));
3326 Write_Str_With_Col_Check (" (");
3328 Ind := First_Index (E);
3329 while Present (Ind) loop
3333 if Present (Ind) then
3340 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
3341 Write_Str_With_Col_Check ("subtype ");
3344 Write_Id (Etype (E));
3345 Write_Str_With_Col_Check (" range ");
3346 Sprint_Node (Scalar_Range (E));
3350 Write_Str_With_Col_Check ("type ");
3352 Write_Str_With_Col_Check (" is <");
3357 end Write_Implicit_Def;
3363 procedure Write_Indent is
3364 Loc : constant Source_Ptr := Sloc (Dump_Node);
3367 if Indent_Annull_Flag then
3368 Indent_Annull_Flag := False;
3370 if Dump_Source_Text and then Loc > No_Location then
3371 if Get_Source_File_Index (Loc) = Current_Source_File then
3373 (Get_Physical_Line_Number (Sloc (Dump_Node)));
3379 for J in 1 .. Indent loop
3385 ------------------------------
3386 -- Write_Indent_Identifiers --
3387 ------------------------------
3389 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3391 -- We need to start a new line for every node, except in the case
3392 -- where we are printing the original tree and this is not the first
3393 -- defining identifier in the list.
3395 if not Dump_Original_Only or else not Prev_Ids (Node) then
3398 -- If printing original tree and this is not the first defining
3399 -- identifier in the list, then the previous call to this procedure
3400 -- printed only the name, and we add a comma to separate the names.
3406 Sprint_Node (Defining_Identifier (Node));
3408 -- The remainder of the declaration must be printed unless we are
3409 -- printing the original tree and this is not the last identifier
3412 not Dump_Original_Only or else not More_Ids (Node);
3414 end Write_Indent_Identifiers;
3416 -----------------------------------
3417 -- Write_Indent_Identifiers_Sloc --
3418 -----------------------------------
3420 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3422 -- We need to start a new line for every node, except in the case
3423 -- where we are printing the original tree and this is not the first
3424 -- defining identifier in the list.
3426 if not Dump_Original_Only or else not Prev_Ids (Node) then
3429 -- If printing original tree and this is not the first defining
3430 -- identifier in the list, then the previous call to this procedure
3431 -- printed only the name, and we add a comma to separate the names.
3438 Sprint_Node (Defining_Identifier (Node));
3440 -- The remainder of the declaration must be printed unless we are
3441 -- printing the original tree and this is not the last identifier
3443 return not Dump_Original_Only or else not More_Ids (Node);
3444 end Write_Indent_Identifiers_Sloc;
3446 ----------------------
3447 -- Write_Indent_Str --
3448 ----------------------
3450 procedure Write_Indent_Str (S : String) is
3452 Write_Corresponding_Source (S);
3455 end Write_Indent_Str;
3457 ---------------------------
3458 -- Write_Indent_Str_Sloc --
3459 ---------------------------
3461 procedure Write_Indent_Str_Sloc (S : String) is
3463 Write_Corresponding_Source (S);
3466 end Write_Indent_Str_Sloc;
3472 procedure Write_Itype (Typ : Entity_Id) is
3474 procedure Write_Header (T : Boolean := True);
3475 -- Write type if T is True, subtype if T is false
3481 procedure Write_Header (T : Boolean := True) is
3484 Write_Str ("[type ");
3486 Write_Str ("[subtype ");
3489 Write_Name_With_Col_Check (Chars (Typ));
3493 -- Start of processing for Write_Itype
3496 if Nkind (Typ) in N_Entity
3497 and then Is_Itype (Typ)
3498 and then not Itype_Printed (Typ)
3500 -- Itype to be printed
3503 B : constant Node_Id := Etype (Typ);
3505 P : constant Node_Id := Parent (Typ);
3507 S : constant Saved_Output_Buffer := Save_Output_Buffer;
3508 -- Save current output buffer
3510 Old_Sloc : Source_Ptr;
3511 -- Save sloc of related node, so it is not modified when
3512 -- printing with -gnatD.
3515 -- Write indentation at start of line
3517 for J in 1 .. Indent loop
3521 -- If we have a constructed declaration, print it
3523 if Present (P) and then Nkind (P) in N_Declaration then
3525 -- We must set Itype_Printed true before the recursive call to
3526 -- print the node, otherwise we get an infinite recursion!
3528 Set_Itype_Printed (Typ, True);
3530 -- Write the declaration enclosed in [], avoiding new line
3531 -- at start of declaration, and semicolon at end.
3533 -- Note: The itype may be imported from another unit, in which
3534 -- case we do not want to modify the Sloc of the declaration.
3535 -- Otherwise the itype may appear to be in the current unit,
3536 -- and the back-end will reject a reference out of scope.
3539 Indent_Annull_Flag := True;
3540 Old_Sloc := Sloc (P);
3542 Set_Sloc (P, Old_Sloc);
3543 Write_Erase_Char (';');
3545 -- If no constructed declaration, then we have to concoct the
3546 -- source corresponding to the type entity that we have at hand.
3551 -- Access types and subtypes
3554 Write_Header (Ekind (Typ) = E_Access_Type);
3555 Write_Str ("access ");
3557 if Is_Access_Constant (Typ) then
3558 Write_Str ("constant ");
3559 elsif Can_Never_Be_Null (Typ) then
3560 Write_Str ("not null ");
3563 Write_Id (Directly_Designated_Type (Typ));
3565 -- Array types and string types
3567 when E_Array_Type | E_String_Type =>
3569 Write_Str ("array (");
3571 X := First_Index (Typ);
3575 if not Is_Constrained (Typ) then
3576 Write_Str (" range <>");
3584 Write_Str (") of ");
3585 Sprint_Node (Component_Type (Typ));
3587 -- Array subtypes and string subtypes
3589 when E_Array_Subtype | E_String_Subtype =>
3590 Write_Header (False);
3591 Write_Id (Etype (Typ));
3594 X := First_Index (Typ);
3604 -- Signed integer types, and modular integer subtypes
3606 when E_Signed_Integer_Type |
3607 E_Signed_Integer_Subtype |
3608 E_Modular_Integer_Subtype =>
3610 Write_Header (Ekind (Typ) = E_Signed_Integer_Type);
3612 if Ekind (Typ) = E_Signed_Integer_Type then
3618 -- Print bounds if different from base type
3621 L : constant Node_Id := Type_Low_Bound (Typ);
3622 H : constant Node_Id := Type_High_Bound (Typ);
3627 -- B can either be a scalar type, in which case the
3628 -- declaration of Typ may constrain it with different
3629 -- bounds, or a private type, in which case we know
3630 -- that the declaration of Typ cannot have a scalar
3633 if Is_Scalar_Type (B) then
3634 LE := Type_Low_Bound (B);
3635 HE := Type_High_Bound (B);
3643 and then Nkind (L) = N_Integer_Literal
3644 and then Nkind (H) = N_Integer_Literal
3645 and then Nkind (LE) = N_Integer_Literal
3646 and then Nkind (HE) = N_Integer_Literal
3647 and then UI_Eq (Intval (L), Intval (LE))
3648 and then UI_Eq (Intval (H), Intval (HE)))
3653 Write_Str (" range ");
3654 Sprint_Node (Type_Low_Bound (Typ));
3656 Sprint_Node (Type_High_Bound (Typ));
3660 -- Modular integer types
3662 when E_Modular_Integer_Type =>
3664 Write_Str (" mod ");
3665 Write_Uint_With_Col_Check (Modulus (Typ), Auto);
3667 -- Floating point types and subtypes
3669 when E_Floating_Point_Type |
3670 E_Floating_Point_Subtype =>
3672 Write_Header (Ekind (Typ) = E_Floating_Point_Type);
3674 if Ekind (Typ) = E_Floating_Point_Type then
3678 Write_Id (Etype (Typ));
3680 if Digits_Value (Typ) /= Digits_Value (Etype (Typ)) then
3681 Write_Str (" digits ");
3682 Write_Uint_With_Col_Check
3683 (Digits_Value (Typ), Decimal);
3686 -- Print bounds if not different from base type
3689 L : constant Node_Id := Type_Low_Bound (Typ);
3690 H : constant Node_Id := Type_High_Bound (Typ);
3691 LE : constant Node_Id := Type_Low_Bound (B);
3692 HE : constant Node_Id := Type_High_Bound (B);
3695 if Nkind (L) = N_Real_Literal
3696 and then Nkind (H) = N_Real_Literal
3697 and then Nkind (LE) = N_Real_Literal
3698 and then Nkind (HE) = N_Real_Literal
3699 and then UR_Eq (Realval (L), Realval (LE))
3700 and then UR_Eq (Realval (H), Realval (HE))
3705 Write_Str (" range ");
3706 Sprint_Node (Type_Low_Bound (Typ));
3708 Sprint_Node (Type_High_Bound (Typ));
3714 when E_Record_Subtype =>
3715 Write_Header (False);
3716 Write_Str ("record");
3722 C := First_Entity (Typ);
3723 while Present (C) loop
3727 Write_Id (Etype (C));
3733 Write_Indent_Str (" end record");
3737 when E_Class_Wide_Type |
3738 E_Class_Wide_Subtype =>
3740 Write_Name_With_Col_Check (Chars (Etype (Typ)));
3741 Write_Str ("'Class");
3745 when E_Subprogram_Type =>
3748 if Etype (Typ) = Standard_Void_Type then
3749 Write_Str ("procedure");
3751 Write_Str ("function");
3754 if Present (First_Entity (Typ)) then
3761 Param := First_Entity (Typ);
3766 if Ekind (Param) = E_In_Out_Parameter then
3767 Write_Str ("in out ");
3768 elsif Ekind (Param) = E_Out_Parameter then
3772 Write_Id (Etype (Param));
3773 Next_Entity (Param);
3774 exit when No (Param);
3782 if Etype (Typ) /= Standard_Void_Type then
3783 Write_Str (" return ");
3784 Write_Id (Etype (Typ));
3787 -- For all other Itypes, print ??? (fill in later)
3790 Write_Header (True);
3796 -- Add terminating bracket and restore output buffer
3800 Restore_Output_Buffer (S);
3803 Set_Itype_Printed (Typ);
3807 -------------------------------
3808 -- Write_Name_With_Col_Check --
3809 -------------------------------
3811 procedure Write_Name_With_Col_Check (N : Name_Id) is
3815 Get_Name_String (N);
3817 -- Deal with -gnatI which replaces digits in an internal
3818 -- name by three dots (e.g. R7b becomes R...b).
3820 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3822 while J < Name_Len loop
3823 exit when Name_Buffer (J) not in 'A' .. 'Z';
3827 if Name_Buffer (J) in '0' .. '9' then
3828 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3831 while J <= Name_Len loop
3832 if Name_Buffer (J) not in '0' .. '9' then
3833 Write_Str (Name_Buffer (J .. Name_Len));
3845 -- Fall through for normal case
3847 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3848 end Write_Name_With_Col_Check;
3850 ------------------------------------
3851 -- Write_Name_With_Col_Check_Sloc --
3852 ------------------------------------
3854 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3856 Get_Name_String (N);
3857 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3858 end Write_Name_With_Col_Check_Sloc;
3860 --------------------
3861 -- Write_Operator --
3862 --------------------
3864 procedure Write_Operator (N : Node_Id; S : String) is
3865 F : Natural := S'First;
3866 T : Natural := S'Last;
3869 -- If no overflow check, just write string out, and we are done
3871 if not Do_Overflow_Check (N) then
3874 -- If overflow check, we want to surround the operator with curly
3875 -- brackets, but not include spaces within the brackets.
3888 Write_Str_Sloc (S (F .. T));
3891 if S (S'Last) = ' ' then
3897 -----------------------
3898 -- Write_Param_Specs --
3899 -----------------------
3901 procedure Write_Param_Specs (N : Node_Id) is
3907 Specs := Parameter_Specifications (N);
3909 if Is_Non_Empty_List (Specs) then
3910 Write_Str_With_Col_Check (" (");
3911 Spec := First (Specs);
3915 Formal := Defining_Identifier (Spec);
3917 exit when Spec = Empty;
3919 -- Add semicolon, unless we are printing original tree and the
3920 -- next specification is part of a list (but not the first
3921 -- element of that list)
3923 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3928 -- Write out any extra formals
3930 while Present (Extra_Formal (Formal)) loop
3931 Formal := Extra_Formal (Formal);
3933 Write_Name_With_Col_Check (Chars (Formal));
3935 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3940 end Write_Param_Specs;
3942 -----------------------
3943 -- Write_Rewrite_Str --
3944 -----------------------
3946 procedure Write_Rewrite_Str (S : String) is
3948 if not Dump_Generated_Only then
3949 if S'Length = 3 and then S = ">>>" then
3952 Write_Str_With_Col_Check (S);
3955 end Write_Rewrite_Str;
3957 -----------------------
3958 -- Write_Source_Line --
3959 -----------------------
3961 procedure Write_Source_Line (L : Physical_Line_Number) is
3963 Src : Source_Buffer_Ptr;
3967 if Dump_Source_Text then
3968 Src := Source_Text (Current_Source_File);
3969 Loc := Line_Start (L, Current_Source_File);
3972 -- See if line is a comment line, if not, and if not line one,
3973 -- precede with blank line.
3976 while Src (Scn) = ' ' or else Src (Scn) = ASCII.HT loop
3980 if (Src (Scn) in Line_Terminator
3981 or else Src (Scn .. Scn + 1) /= "--")
3987 -- Now write the source text of the line
3990 Write_Int (Int (L));
3993 while Src (Loc) not in Line_Terminator loop
3994 Write_Char (Src (Loc));
3998 end Write_Source_Line;
4000 ------------------------
4001 -- Write_Source_Lines --
4002 ------------------------
4004 procedure Write_Source_Lines (L : Physical_Line_Number) is
4006 while Last_Line_Printed < L loop
4007 Last_Line_Printed := Last_Line_Printed + 1;
4008 Write_Source_Line (Last_Line_Printed);
4010 end Write_Source_Lines;
4012 --------------------
4013 -- Write_Str_Sloc --
4014 --------------------
4016 procedure Write_Str_Sloc (S : String) is
4018 for J in S'Range loop
4019 Write_Char_Sloc (S (J));
4023 ------------------------------
4024 -- Write_Str_With_Col_Check --
4025 ------------------------------
4027 procedure Write_Str_With_Col_Check (S : String) is
4029 if Int (S'Last) + Column > Line_Limit then
4030 Write_Indent_Str (" ");
4032 if S (S'First) = ' ' then
4033 Write_Str (S (S'First + 1 .. S'Last));
4041 end Write_Str_With_Col_Check;
4043 -----------------------------------
4044 -- Write_Str_With_Col_Check_Sloc --
4045 -----------------------------------
4047 procedure Write_Str_With_Col_Check_Sloc (S : String) is
4049 if Int (S'Last) + Column > Line_Limit then
4050 Write_Indent_Str (" ");
4052 if S (S'First) = ' ' then
4053 Write_Str_Sloc (S (S'First + 1 .. S'Last));
4061 end Write_Str_With_Col_Check_Sloc;
4063 -------------------------------
4064 -- Write_Uint_With_Col_Check --
4065 -------------------------------
4067 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format) is
4069 Col_Check (UI_Decimal_Digits_Hi (U));
4070 UI_Write (U, Format);
4071 end Write_Uint_With_Col_Check;
4073 ------------------------------------
4074 -- Write_Uint_With_Col_Check_Sloc --
4075 ------------------------------------
4077 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
4079 Col_Check (UI_Decimal_Digits_Hi (U));
4081 UI_Write (U, Format);
4082 end Write_Uint_With_Col_Check_Sloc;
4084 -------------------------------------
4085 -- Write_Ureal_With_Col_Check_Sloc --
4086 -------------------------------------
4088 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
4089 D : constant Uint := Denominator (U);
4090 N : constant Uint := Numerator (U);
4094 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
4097 end Write_Ureal_With_Col_Check_Sloc;