1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2010, 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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Aspects; use Aspects;
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 Sem_Eval; use Sem_Eval;
40 with Sem_Util; use Sem_Util;
41 with Sinfo; use Sinfo;
42 with Sinput; use Sinput;
43 with Sinput.D; use Sinput.D;
44 with Snames; use Snames;
45 with Stand; use Stand;
46 with Stringt; use Stringt;
47 with Uintp; use Uintp;
48 with Uname; use Uname;
49 with Urealp; use Urealp;
51 package body Sprint is
52 Current_Source_File : Source_File_Index;
53 -- Index of source file whose generated code is being dumped
55 Dump_Node : Node_Id := Empty;
56 -- This is set to the current node, used for printing line numbers. In
57 -- Debug_Generated_Code mode, Dump_Node is set to the current node
58 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
59 -- value. The call clears it back to Empty.
61 Debug_Sloc : Source_Ptr;
62 -- Sloc of first byte of line currently being written if we are
63 -- generating a source debug file.
65 Dump_Original_Only : Boolean;
66 -- Set True if the -gnatdo (dump original tree) flag is set
68 Dump_Generated_Only : Boolean;
69 -- Set True if the -gnatdG (dump generated tree) debug flag is set
70 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
72 Dump_Freeze_Null : Boolean;
73 -- Set True if freeze nodes and non-source null statements output
75 Freeze_Indent : Int := 0;
76 -- Keep track of freeze indent level (controls output of blank lines before
77 -- procedures within expression freeze actions). Relevant only if we are
78 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
79 -- output these blank lines in any case.
82 -- Number of columns for current line output indentation
84 Indent_Annull_Flag : Boolean := False;
85 -- Set True if subsequent Write_Indent call to be ignored, gets reset
86 -- by this call, so it is only active to suppress a single indent call.
88 Last_Line_Printed : Physical_Line_Number;
89 -- This keeps track of the physical line number of the last source line
90 -- that has been output. The value is only valid in Dump_Source_Text mode.
92 -------------------------------
93 -- Operator Precedence Table --
94 -------------------------------
96 -- This table is used to decide whether a subexpression needs to be
97 -- parenthesized. The rule is that if an operand of an operator (which
98 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
99 -- with a lower precedence than the operator (or equal precedence if
100 -- appearing as the right operand), then parentheses are required.
102 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
135 procedure Sprint_Left_Opnd (N : Node_Id);
136 -- Print left operand of operator, parenthesizing if necessary
138 procedure Sprint_Right_Opnd (N : Node_Id);
139 -- Print right operand of operator, parenthesizing if necessary
141 -----------------------
142 -- Local Subprograms --
143 -----------------------
145 procedure Col_Check (N : Nat);
146 -- Check that at least N characters remain on current line, and if not,
147 -- then start an extra line with two characters extra indentation for
148 -- continuing text on the next line.
150 procedure Extra_Blank_Line;
151 -- In some situations we write extra blank lines to separate the generated
152 -- code to make it more readable. However, these extra blank lines are not
153 -- generated in Dump_Source_Text mode, since there the source text lines
154 -- output with preceding blank lines are quite sufficient as separators.
155 -- This procedure writes a blank line if Dump_Source_Text is False.
157 procedure Indent_Annull;
158 -- Causes following call to Write_Indent to be ignored. This is used when
159 -- a higher level node wants to stop a lower level node from starting a
160 -- new line, when it would otherwise be inclined to do so (e.g. the case
161 -- of an accept statement called from an accept alternative with a guard)
163 procedure Indent_Begin;
164 -- Increase indentation level
166 procedure Indent_End;
167 -- Decrease indentation level
169 procedure Print_Debug_Line (S : String);
170 -- Used to print output lines in Debug_Generated_Code mode (this is used
171 -- as the argument for a call to Set_Special_Output in package Output).
173 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
174 -- Given a divide, multiplication or division node, check the flags
175 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
176 -- appropriate special syntax characters (# and @).
178 procedure Set_Debug_Sloc;
179 -- If Dump_Node is non-empty, this routine sets the appropriate value
180 -- in its Sloc field, from the current location in the debug source file
181 -- that is currently being written.
183 procedure Sprint_And_List (List : List_Id);
184 -- Print the given list with items separated by vertical "and"
186 procedure Sprint_Aspect_Specifications (Node : Node_Id);
187 -- Node is a declaration node that has aspect specifications (Has_Aspects
188 -- flag set True). It is called after outputting the terminating semicolon
189 -- for the related node. The effect is to remove the semicolon and print
190 -- the aspect specifications, followed by a terminating semicolon.
192 procedure Sprint_Bar_List (List : List_Id);
193 -- Print the given list with items separated by vertical bars
195 procedure Sprint_End_Label
198 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
199 -- If there is not end label, use the defining identifier of the enclosing
200 -- construct. If the end label is present, treat it as a reference to the
201 -- defining entity of the construct: this guarantees that it carries the
202 -- proper sloc information for debugging purposes.
204 procedure Sprint_Node_Actual (Node : Node_Id);
205 -- This routine prints its node argument. It is a lower level routine than
206 -- Sprint_Node, in that it does not bother about rewritten trees.
208 procedure Sprint_Node_Sloc (Node : Node_Id);
209 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
210 -- sets the Sloc of the current debug node to be a copy of the Sloc
211 -- of the sprinted node Node. Note that this is done after printing
212 -- Node, so that the Sloc is the proper updated value for the debug file.
214 procedure Update_Itype (Node : Node_Id);
215 -- Update the Sloc of an itype that is not attached to the tree, when
216 -- debugging expanded code. This routine is called from nodes whose
217 -- type can be an Itype, such as defining_identifiers that may be of
218 -- an anonymous access type, or ranges in slices.
220 procedure Write_Char_Sloc (C : Character);
221 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
222 -- called to ensure that the current node has a proper Sloc set.
224 procedure Write_Condition_And_Reason (Node : Node_Id);
225 -- Write Condition and Reason codes of Raise_xxx_Error node
227 procedure Write_Corresponding_Source (S : String);
228 -- If S is a string with a single keyword (possibly followed by a space),
229 -- and if the next non-comment non-blank source line matches this keyword,
230 -- then output all source lines up to this matching line.
232 procedure Write_Discr_Specs (N : Node_Id);
233 -- Output discriminant specification for node, which is any of the type
234 -- declarations that can have discriminants.
236 procedure Write_Ekind (E : Entity_Id);
237 -- Write the String corresponding to the Ekind without "E_"
239 procedure Write_Id (N : Node_Id);
240 -- N is a node with a Chars field. This procedure writes the name that
241 -- will be used in the generated code associated with the name. For a
242 -- node with no associated entity, this is simply the Chars field. For
243 -- the case where there is an entity associated with the node, we print
244 -- the name associated with the entity (since it may have been encoded).
245 -- One other special case is that an entity has an active external name
246 -- (i.e. an external name present with no address clause), then this
247 -- external name is output. This procedure also deals with outputting
248 -- declarations of referenced itypes, if not output earlier.
250 function Write_Identifiers (Node : Node_Id) return Boolean;
251 -- Handle node where the grammar has a list of defining identifiers, but
252 -- the tree has a separate declaration for each identifier. Handles the
253 -- printing of the defining identifier, and returns True if the type and
254 -- initialization information is to be printed, False if it is to be
255 -- skipped (the latter case happens when printing defining identifiers
256 -- other than the first in the original tree output case).
258 procedure Write_Implicit_Def (E : Entity_Id);
259 pragma Warnings (Off, Write_Implicit_Def);
260 -- Write the definition of the implicit type E according to its Ekind
261 -- For now a debugging procedure, but might be used in the future.
263 procedure Write_Indent;
264 -- Start a new line and write indentation spacing
266 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
267 -- Like Write_Identifiers except that each new printed declaration
268 -- is at the start of a new line.
270 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
271 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
272 -- mode, the Sloc of the current debug node is set to point to the
273 -- first output identifier.
275 procedure Write_Indent_Str (S : String);
276 -- Start a new line and write indent spacing followed by given string
278 procedure Write_Indent_Str_Sloc (S : String);
279 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
280 -- the Sloc of the current node is set to the first non-blank character
283 procedure Write_Itype (Typ : Entity_Id);
284 -- If Typ is an Itype that has not been written yet, write it. If Typ is
285 -- any other kind of entity or tree node, the call is ignored.
287 procedure Write_Name_With_Col_Check (N : Name_Id);
288 -- Write name (using Write_Name) with initial column check, and possible
289 -- initial Write_Indent (to get new line) if current line is too full.
291 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
292 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
293 -- mode, sets Sloc of current debug node to first character of name.
295 procedure Write_Operator (N : Node_Id; S : String);
296 -- Like Write_Str_Sloc, used for operators, encloses the string in
297 -- characters {} if the Do_Overflow flag is set on the node N.
299 procedure Write_Param_Specs (N : Node_Id);
300 -- Output parameter specifications for node (which is either a function
301 -- or procedure specification with a Parameter_Specifications field)
303 procedure Write_Rewrite_Str (S : String);
304 -- Writes out a string (typically containing <<< or >>>}) for a node
305 -- created by rewriting the tree. Suppressed if we are outputting the
306 -- generated code only, since in this case we don't specially mark nodes
307 -- created by rewriting).
309 procedure Write_Source_Line (L : Physical_Line_Number);
310 -- If writing of interspersed source lines is enabled, then write the given
311 -- line from the source file, preceded by Eol, then an extra blank line if
312 -- the line has at least one blank, is not a comment and is not line one,
313 -- then "--" and the line number followed by period followed by text of the
314 -- source line (without terminating Eol). If interspersed source line
315 -- output not enabled, then the call has no effect.
317 procedure Write_Source_Lines (L : Physical_Line_Number);
318 -- If writing of interspersed source lines is enabled, then writes source
319 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
320 -- interspersed source line output not enabled, then call has no effect.
322 procedure Write_Str_Sloc (S : String);
323 -- Like Write_Str, but sets debug Sloc of current debug node to first
324 -- non-blank character if a current debug node is active.
326 procedure Write_Str_With_Col_Check (S : String);
327 -- Write string (using Write_Str) with initial column check, and possible
328 -- initial Write_Indent (to get new line) if current line is too full.
330 procedure Write_Str_With_Col_Check_Sloc (S : String);
331 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
332 -- node to first non-blank character if a current debug node is active.
334 procedure Write_Subprogram_Name (N : Node_Id);
335 -- N is the Name field of a function call or procedure statement call.
336 -- The effect of the call is to output the name, preceded by a $ if the
337 -- call is identified as an implicit call to a run time routine.
339 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format);
340 -- Write Uint (using UI_Write) with initial column check, and possible
341 -- initial Write_Indent (to get new line) if current line is too full.
342 -- The format parameter determines the output format (see UI_Write).
344 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
345 -- Write Uint (using UI_Write) with initial column check, and possible
346 -- initial Write_Indent (to get new line) if current line is too full.
347 -- The format parameter determines the output format (see UI_Write).
348 -- In addition, in Debug_Generated_Code mode, sets the current node
349 -- Sloc to the first character of the output value.
351 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
352 -- Write Ureal (using same output format as UR_Write) with column checks
353 -- and a possible initial Write_Indent (to get new line) if current line
354 -- is too full. In addition, in Debug_Generated_Code mode, sets the
355 -- current node Sloc to the first character of the output value.
361 procedure Col_Check (N : Nat) is
363 if N + Column > Sprint_Line_Limit then
364 Write_Indent_Str (" ");
368 ----------------------
369 -- Extra_Blank_Line --
370 ----------------------
372 procedure Extra_Blank_Line is
374 if not Dump_Source_Text then
377 end Extra_Blank_Line;
383 procedure Indent_Annull is
385 Indent_Annull_Flag := True;
392 procedure Indent_Begin is
394 Indent := Indent + 3;
401 procedure Indent_End is
403 Indent := Indent - 3;
410 procedure pg (Arg : Union_Id) is
412 Dump_Generated_Only := True;
413 Dump_Original_Only := False;
414 Dump_Freeze_Null := True;
415 Current_Source_File := No_Source_File;
417 if Arg in List_Range then
418 Sprint_Node_List (List_Id (Arg));
420 elsif Arg in Node_Range then
421 Sprint_Node (Node_Id (Arg));
434 procedure po (Arg : Union_Id) is
436 Dump_Generated_Only := False;
437 Dump_Original_Only := True;
438 Current_Source_File := No_Source_File;
440 if Arg in List_Range then
441 Sprint_Node_List (List_Id (Arg));
443 elsif Arg in Node_Range then
444 Sprint_Node (Node_Id (Arg));
453 ----------------------
454 -- Print_Debug_Line --
455 ----------------------
457 procedure Print_Debug_Line (S : String) is
459 Write_Debug_Line (S, Debug_Sloc);
460 end Print_Debug_Line;
462 ---------------------------
463 -- Process_TFAI_RR_Flags --
464 ---------------------------
466 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
468 if Treat_Fixed_As_Integer (Nod) then
472 if Rounded_Result (Nod) then
475 end Process_TFAI_RR_Flags;
481 procedure ps (Arg : Union_Id) is
483 Dump_Generated_Only := False;
484 Dump_Original_Only := False;
485 Current_Source_File := No_Source_File;
487 if Arg in List_Range then
488 Sprint_Node_List (List_Id (Arg));
490 elsif Arg in Node_Range then
491 Sprint_Node (Node_Id (Arg));
504 procedure Set_Debug_Sloc is
506 if Debug_Generated_Code and then Present (Dump_Node) then
507 Set_Sloc (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1));
516 procedure Source_Dump is
519 -- Put underline under string we just printed
525 procedure Underline is
526 Col : constant Int := Column;
531 while Col > Column loop
538 -- Start of processing for Source_Dump
541 Dump_Generated_Only := Debug_Flag_G or
542 Print_Generated_Code or
543 Debug_Generated_Code;
544 Dump_Original_Only := Debug_Flag_O;
545 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
547 -- Note that we turn off the tree dump flags immediately, before
548 -- starting the dump. This avoids generating two copies of the dump
549 -- if an abort occurs after printing the dump, and more importantly,
550 -- avoids an infinite loop if an abort occurs during the dump.
553 Current_Source_File := No_Source_File;
554 Debug_Flag_Z := False;
557 Write_Str ("Source recreated from tree of Standard (spec)");
559 Sprint_Node (Standard_Package_Node);
564 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
565 Debug_Flag_G := False;
566 Debug_Flag_O := False;
567 Debug_Flag_S := False;
569 -- Dump requested units
571 for U in Main_Unit .. Last_Unit loop
572 Current_Source_File := Source_Index (U);
574 -- Dump all units if -gnatdf set, otherwise we dump only
575 -- the source files that are in the extended main source.
578 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
580 -- If we are generating debug files, setup to write them
582 if Debug_Generated_Code then
583 Set_Special_Output (Print_Debug_Line'Access);
584 Create_Debug_Source (Source_Index (U), Debug_Sloc);
585 Write_Source_Line (1);
586 Last_Line_Printed := 1;
587 Sprint_Node (Cunit (U));
588 Write_Source_Lines (Last_Source_Line (Current_Source_File));
591 Set_Special_Output (null);
593 -- Normal output to standard output file
596 Write_Str ("Source recreated from tree for ");
597 Write_Unit_Name (Unit_Name (U));
599 Write_Source_Line (1);
600 Last_Line_Printed := 1;
601 Sprint_Node (Cunit (U));
602 Write_Source_Lines (Last_Source_Line (Current_Source_File));
611 ---------------------
612 -- Sprint_And_List --
613 ---------------------
615 procedure Sprint_And_List (List : List_Id) is
618 if Is_Non_Empty_List (List) then
619 Node := First (List);
623 exit when Node = Empty;
629 ----------------------------------
630 -- Sprint_Aspect_Specifications --
631 ----------------------------------
633 procedure Sprint_Aspect_Specifications (Node : Node_Id) is
634 AS : constant List_Id := Aspect_Specifications (Node);
638 Write_Erase_Char (';');
639 Indent := Indent + 2;
642 Indent := Indent + 5;
646 Sprint_Node (Identifier (A));
648 if Class_Present (A) then
649 Write_Str ("'Class");
652 if Present (Expression (A)) then
654 Sprint_Node (Expression (A));
664 Indent := Indent - 7;
666 end Sprint_Aspect_Specifications;
668 ---------------------
669 -- Sprint_Bar_List --
670 ---------------------
672 procedure Sprint_Bar_List (List : List_Id) is
675 if Is_Non_Empty_List (List) then
676 Node := First (List);
680 exit when Node = Empty;
686 ----------------------
687 -- Sprint_End_Label --
688 ----------------------
690 procedure Sprint_End_Label
696 and then Present (End_Label (Node))
697 and then Is_Entity_Name (End_Label (Node))
699 Set_Entity (End_Label (Node), Default);
701 -- For a function whose name is an operator, use the qualified name
702 -- created for the defining entity.
704 if Nkind (End_Label (Node)) = N_Operator_Symbol then
705 Set_Chars (End_Label (Node), Chars (Default));
708 Sprint_Node (End_Label (Node));
710 Sprint_Node (Default);
712 end Sprint_End_Label;
714 -----------------------
715 -- Sprint_Comma_List --
716 -----------------------
718 procedure Sprint_Comma_List (List : List_Id) is
722 if Is_Non_Empty_List (List) then
723 Node := First (List);
727 exit when Node = Empty;
729 if not Is_Rewrite_Insertion (Node)
730 or else not Dump_Original_Only
736 end Sprint_Comma_List;
738 --------------------------
739 -- Sprint_Indented_List --
740 --------------------------
742 procedure Sprint_Indented_List (List : List_Id) is
745 Sprint_Node_List (List);
747 end Sprint_Indented_List;
749 ---------------------
750 -- Sprint_Left_Opnd --
751 ---------------------
753 procedure Sprint_Left_Opnd (N : Node_Id) is
754 Opnd : constant Node_Id := Left_Opnd (N);
757 if Paren_Count (Opnd) /= 0
758 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
767 end Sprint_Left_Opnd;
773 procedure Sprint_Node (Node : Node_Id) is
775 if Is_Rewrite_Insertion (Node) then
776 if not Dump_Original_Only then
778 -- For special cases of nodes that always output <<< >>>
779 -- do not duplicate the output at this point.
781 if Nkind (Node) = N_Freeze_Entity
782 or else Nkind (Node) = N_Implicit_Label_Declaration
784 Sprint_Node_Actual (Node);
786 -- Normal case where <<< >>> may be required
789 Write_Rewrite_Str ("<<<");
790 Sprint_Node_Actual (Node);
791 Write_Rewrite_Str (">>>");
795 elsif Is_Rewrite_Substitution (Node) then
797 -- Case of dump generated only
799 if Dump_Generated_Only then
800 Sprint_Node_Actual (Node);
802 -- Case of dump original only
804 elsif Dump_Original_Only then
805 Sprint_Node_Actual (Original_Node (Node));
807 -- Case of both being dumped
810 Sprint_Node_Actual (Original_Node (Node));
811 Write_Rewrite_Str ("<<<");
812 Sprint_Node_Actual (Node);
813 Write_Rewrite_Str (">>>");
817 Sprint_Node_Actual (Node);
821 ------------------------
822 -- Sprint_Node_Actual --
823 ------------------------
825 procedure Sprint_Node_Actual (Node : Node_Id) is
826 Save_Dump_Node : constant Node_Id := Dump_Node;
833 for J in 1 .. Paren_Count (Node) loop
834 Write_Str_With_Col_Check ("(");
837 -- Setup current dump node
841 if Nkind (Node) in N_Subexpr
842 and then Do_Range_Check (Node)
844 Write_Str_With_Col_Check ("{");
847 -- Select print circuit based on node kind
850 when N_Abort_Statement =>
851 Write_Indent_Str_Sloc ("abort ");
852 Sprint_Comma_List (Names (Node));
855 when N_Abortable_Part =>
857 Write_Str_Sloc ("abort ");
858 Sprint_Indented_List (Statements (Node));
860 when N_Abstract_Subprogram_Declaration =>
862 Sprint_Node (Specification (Node));
863 Write_Str_With_Col_Check (" is ");
864 Write_Str_Sloc ("abstract;");
866 when N_Accept_Alternative =>
867 Sprint_Node_List (Pragmas_Before (Node));
869 if Present (Condition (Node)) then
870 Write_Indent_Str ("when ");
871 Sprint_Node (Condition (Node));
876 Sprint_Node_Sloc (Accept_Statement (Node));
877 Sprint_Node_List (Statements (Node));
879 when N_Accept_Statement =>
880 Write_Indent_Str_Sloc ("accept ");
881 Write_Id (Entry_Direct_Name (Node));
883 if Present (Entry_Index (Node)) then
884 Write_Str_With_Col_Check (" (");
885 Sprint_Node (Entry_Index (Node));
889 Write_Param_Specs (Node);
891 if Present (Handled_Statement_Sequence (Node)) then
892 Write_Str_With_Col_Check (" do");
893 Sprint_Node (Handled_Statement_Sequence (Node));
894 Write_Indent_Str ("end ");
895 Write_Id (Entry_Direct_Name (Node));
900 when N_Access_Definition =>
904 if Present (Access_To_Subprogram_Definition (Node)) then
905 Sprint_Node (Access_To_Subprogram_Definition (Node));
909 if Null_Exclusion_Present (Node) then
910 Write_Str ("not null ");
913 Write_Str_With_Col_Check_Sloc ("access ");
915 if All_Present (Node) then
917 elsif Constant_Present (Node) then
918 Write_Str ("constant ");
921 Sprint_Node (Subtype_Mark (Node));
924 when N_Access_Function_Definition =>
928 if Null_Exclusion_Present (Node) then
929 Write_Str ("not null ");
932 Write_Str_With_Col_Check_Sloc ("access ");
934 if Protected_Present (Node) then
935 Write_Str_With_Col_Check ("protected ");
938 Write_Str_With_Col_Check ("function");
939 Write_Param_Specs (Node);
940 Write_Str_With_Col_Check (" return ");
941 Sprint_Node (Result_Definition (Node));
943 when N_Access_Procedure_Definition =>
947 if Null_Exclusion_Present (Node) then
948 Write_Str ("not null ");
951 Write_Str_With_Col_Check_Sloc ("access ");
953 if Protected_Present (Node) then
954 Write_Str_With_Col_Check ("protected ");
957 Write_Str_With_Col_Check ("procedure");
958 Write_Param_Specs (Node);
960 when N_Access_To_Object_Definition =>
961 Write_Str_With_Col_Check_Sloc ("access ");
963 if All_Present (Node) then
964 Write_Str_With_Col_Check ("all ");
965 elsif Constant_Present (Node) then
966 Write_Str_With_Col_Check ("constant ");
971 if Null_Exclusion_Present (Node) then
972 Write_Str ("not null ");
975 Sprint_Node (Subtype_Indication (Node));
978 if Null_Record_Present (Node) then
979 Write_Str_With_Col_Check_Sloc ("(null record)");
982 Write_Str_With_Col_Check_Sloc ("(");
984 if Present (Expressions (Node)) then
985 Sprint_Comma_List (Expressions (Node));
987 if Present (Component_Associations (Node))
988 and then not Is_Empty_List (Component_Associations (Node))
994 if Present (Component_Associations (Node))
995 and then not Is_Empty_List (Component_Associations (Node))
1003 Nd := First (Component_Associations (Node));
1011 if not Is_Rewrite_Insertion (Nd)
1012 or else not Dump_Original_Only
1026 Write_Str_With_Col_Check_Sloc ("new ");
1028 -- Ada 2005 (AI-231)
1030 if Null_Exclusion_Present (Node) then
1031 Write_Str ("not null ");
1034 Sprint_Node (Expression (Node));
1036 if Present (Storage_Pool (Node)) then
1037 Write_Str_With_Col_Check ("[storage_pool = ");
1038 Sprint_Node (Storage_Pool (Node));
1043 Sprint_Left_Opnd (Node);
1044 Write_Str_Sloc (" and then ");
1045 Sprint_Right_Opnd (Node);
1047 when N_Aspect_Specification =>
1048 raise Program_Error;
1050 when N_Assignment_Statement =>
1052 Sprint_Node (Name (Node));
1053 Write_Str_Sloc (" := ");
1054 Sprint_Node (Expression (Node));
1057 when N_Asynchronous_Select =>
1058 Write_Indent_Str_Sloc ("select");
1060 Sprint_Node (Triggering_Alternative (Node));
1063 -- Note: let the printing of Abortable_Part handle outputting
1064 -- the ABORT keyword, so that the Sloc can be set correctly.
1066 Write_Indent_Str ("then ");
1067 Sprint_Node (Abortable_Part (Node));
1068 Write_Indent_Str ("end select;");
1071 Write_Indent_Str_Sloc ("for ");
1072 Write_Id (Identifier (Node));
1073 Write_Str_With_Col_Check (" use at ");
1074 Sprint_Node (Expression (Node));
1077 when N_Attribute_Definition_Clause =>
1078 Write_Indent_Str_Sloc ("for ");
1079 Sprint_Node (Name (Node));
1081 Write_Name_With_Col_Check (Chars (Node));
1082 Write_Str_With_Col_Check (" use ");
1083 Sprint_Node (Expression (Node));
1086 when N_Attribute_Reference =>
1087 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1091 Sprint_Node (Prefix (Node));
1092 Write_Char_Sloc (''');
1093 Write_Name_With_Col_Check (Attribute_Name (Node));
1094 Sprint_Paren_Comma_List (Expressions (Node));
1096 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1100 when N_Block_Statement =>
1103 if Present (Identifier (Node))
1104 and then (not Has_Created_Identifier (Node)
1105 or else not Dump_Original_Only)
1107 Write_Rewrite_Str ("<<<");
1108 Write_Id (Identifier (Node));
1110 Write_Rewrite_Str (">>>");
1113 if Present (Declarations (Node)) then
1114 Write_Str_With_Col_Check_Sloc ("declare");
1115 Sprint_Indented_List (Declarations (Node));
1119 Write_Str_With_Col_Check_Sloc ("begin");
1120 Sprint_Node (Handled_Statement_Sequence (Node));
1121 Write_Indent_Str ("end");
1123 if Present (Identifier (Node))
1124 and then (not Has_Created_Identifier (Node)
1125 or else not Dump_Original_Only)
1127 Write_Rewrite_Str ("<<<");
1129 Write_Id (Identifier (Node));
1130 Write_Rewrite_Str (">>>");
1135 when N_Case_Expression =>
1140 Write_Str_With_Col_Check_Sloc ("(case ");
1141 Sprint_Node (Expression (Node));
1142 Write_Str_With_Col_Check (" is");
1144 Alt := First (Alternatives (Node));
1155 when N_Case_Expression_Alternative =>
1156 Write_Str_With_Col_Check (" when ");
1157 Sprint_Bar_List (Discrete_Choices (Node));
1159 Sprint_Node (Expression (Node));
1161 when N_Case_Statement =>
1162 Write_Indent_Str_Sloc ("case ");
1163 Sprint_Node (Expression (Node));
1165 Sprint_Indented_List (Alternatives (Node));
1166 Write_Indent_Str ("end case;");
1168 when N_Case_Statement_Alternative =>
1169 Write_Indent_Str_Sloc ("when ");
1170 Sprint_Bar_List (Discrete_Choices (Node));
1172 Sprint_Indented_List (Statements (Node));
1174 when N_Character_Literal =>
1175 if Column > Sprint_Line_Limit - 2 then
1176 Write_Indent_Str (" ");
1179 Write_Char_Sloc (''');
1180 Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
1183 when N_Code_Statement =>
1186 Sprint_Node (Expression (Node));
1189 when N_Compilation_Unit =>
1190 Sprint_Node_List (Context_Items (Node));
1191 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
1193 if Private_Present (Node) then
1194 Write_Indent_Str ("private ");
1198 Sprint_Node_Sloc (Unit (Node));
1200 if Present (Actions (Aux_Decls_Node (Node)))
1202 Present (Pragmas_After (Aux_Decls_Node (Node)))
1207 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
1208 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
1210 when N_Compilation_Unit_Aux =>
1211 null; -- nothing to do, never used, see above
1213 when N_Component_Association =>
1215 Sprint_Bar_List (Choices (Node));
1218 -- Ada 2005 (AI-287): Print the box if present
1220 if Box_Present (Node) then
1221 Write_Str_With_Col_Check ("<>");
1223 Sprint_Node (Expression (Node));
1226 when N_Component_Clause =>
1228 Sprint_Node (Component_Name (Node));
1229 Write_Str_Sloc (" at ");
1230 Sprint_Node (Position (Node));
1232 Write_Str_With_Col_Check ("range ");
1233 Sprint_Node (First_Bit (Node));
1235 Sprint_Node (Last_Bit (Node));
1238 when N_Component_Definition =>
1241 -- Ada 2005 (AI-230): Access definition components
1243 if Present (Access_Definition (Node)) then
1244 Sprint_Node (Access_Definition (Node));
1246 elsif Present (Subtype_Indication (Node)) then
1247 if Aliased_Present (Node) then
1248 Write_Str_With_Col_Check ("aliased ");
1251 -- Ada 2005 (AI-231)
1253 if Null_Exclusion_Present (Node) then
1254 Write_Str (" not null ");
1257 Sprint_Node (Subtype_Indication (Node));
1260 Write_Str (" ??? ");
1263 when N_Component_Declaration =>
1264 if Write_Indent_Identifiers_Sloc (Node) then
1266 Sprint_Node (Component_Definition (Node));
1268 if Present (Expression (Node)) then
1270 Sprint_Node (Expression (Node));
1276 when N_Component_List =>
1277 if Null_Present (Node) then
1279 Write_Indent_Str_Sloc ("null");
1285 Sprint_Indented_List (Component_Items (Node));
1286 Sprint_Node (Variant_Part (Node));
1289 when N_Conditional_Entry_Call =>
1290 Write_Indent_Str_Sloc ("select");
1292 Sprint_Node (Entry_Call_Alternative (Node));
1294 Write_Indent_Str ("else");
1295 Sprint_Indented_List (Else_Statements (Node));
1296 Write_Indent_Str ("end select;");
1298 when N_Conditional_Expression =>
1300 Condition : constant Node_Id := First (Expressions (Node));
1301 Then_Expr : constant Node_Id := Next (Condition);
1304 Write_Str_With_Col_Check_Sloc ("(if ");
1305 Sprint_Node (Condition);
1306 Write_Str_With_Col_Check (" then ");
1308 -- Defense against junk here!
1310 if Present (Then_Expr) then
1311 Sprint_Node (Then_Expr);
1312 Write_Str_With_Col_Check (" else ");
1313 Sprint_Node (Next (Then_Expr));
1319 when N_Constrained_Array_Definition =>
1320 Write_Str_With_Col_Check_Sloc ("array ");
1321 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1324 Sprint_Node (Component_Definition (Node));
1326 when N_Decimal_Fixed_Point_Definition =>
1327 Write_Str_With_Col_Check_Sloc (" delta ");
1328 Sprint_Node (Delta_Expression (Node));
1329 Write_Str_With_Col_Check ("digits ");
1330 Sprint_Node (Digits_Expression (Node));
1331 Sprint_Opt_Node (Real_Range_Specification (Node));
1333 when N_Defining_Character_Literal =>
1334 Write_Name_With_Col_Check_Sloc (Chars (Node));
1336 when N_Defining_Identifier =>
1340 when N_Defining_Operator_Symbol =>
1341 Write_Name_With_Col_Check_Sloc (Chars (Node));
1343 when N_Defining_Program_Unit_Name =>
1345 Sprint_Node (Name (Node));
1347 Write_Id (Defining_Identifier (Node));
1349 when N_Delay_Alternative =>
1350 Sprint_Node_List (Pragmas_Before (Node));
1352 if Present (Condition (Node)) then
1354 Write_Str_With_Col_Check ("when ");
1355 Sprint_Node (Condition (Node));
1360 Sprint_Node_Sloc (Delay_Statement (Node));
1361 Sprint_Node_List (Statements (Node));
1363 when N_Delay_Relative_Statement =>
1364 Write_Indent_Str_Sloc ("delay ");
1365 Sprint_Node (Expression (Node));
1368 when N_Delay_Until_Statement =>
1369 Write_Indent_Str_Sloc ("delay until ");
1370 Sprint_Node (Expression (Node));
1373 when N_Delta_Constraint =>
1374 Write_Str_With_Col_Check_Sloc ("delta ");
1375 Sprint_Node (Delta_Expression (Node));
1376 Sprint_Opt_Node (Range_Constraint (Node));
1378 when N_Derived_Type_Definition =>
1379 if Abstract_Present (Node) then
1380 Write_Str_With_Col_Check ("abstract ");
1383 Write_Str_With_Col_Check ("new ");
1385 -- Ada 2005 (AI-231)
1387 if Null_Exclusion_Present (Node) then
1388 Write_Str_With_Col_Check ("not null ");
1391 Sprint_Node (Subtype_Indication (Node));
1393 if Present (Interface_List (Node)) then
1394 Write_Str_With_Col_Check (" and ");
1395 Sprint_And_List (Interface_List (Node));
1396 Write_Str_With_Col_Check (" with ");
1399 if Present (Record_Extension_Part (Node)) then
1400 if No (Interface_List (Node)) then
1401 Write_Str_With_Col_Check (" with ");
1404 Sprint_Node (Record_Extension_Part (Node));
1407 when N_Designator =>
1408 Sprint_Node (Name (Node));
1409 Write_Char_Sloc ('.');
1410 Write_Id (Identifier (Node));
1412 when N_Digits_Constraint =>
1413 Write_Str_With_Col_Check_Sloc ("digits ");
1414 Sprint_Node (Digits_Expression (Node));
1415 Sprint_Opt_Node (Range_Constraint (Node));
1417 when N_Discriminant_Association =>
1420 if Present (Selector_Names (Node)) then
1421 Sprint_Bar_List (Selector_Names (Node));
1426 Sprint_Node (Expression (Node));
1428 when N_Discriminant_Specification =>
1431 if Write_Identifiers (Node) then
1434 if Null_Exclusion_Present (Node) then
1435 Write_Str ("not null ");
1438 Sprint_Node (Discriminant_Type (Node));
1440 if Present (Expression (Node)) then
1442 Sprint_Node (Expression (Node));
1448 when N_Elsif_Part =>
1449 Write_Indent_Str_Sloc ("elsif ");
1450 Sprint_Node (Condition (Node));
1451 Write_Str_With_Col_Check (" then");
1452 Sprint_Indented_List (Then_Statements (Node));
1457 when N_Entry_Body =>
1458 Write_Indent_Str_Sloc ("entry ");
1459 Write_Id (Defining_Identifier (Node));
1460 Sprint_Node (Entry_Body_Formal_Part (Node));
1461 Write_Str_With_Col_Check (" is");
1462 Sprint_Indented_List (Declarations (Node));
1463 Write_Indent_Str ("begin");
1464 Sprint_Node (Handled_Statement_Sequence (Node));
1465 Write_Indent_Str ("end ");
1466 Write_Id (Defining_Identifier (Node));
1469 when N_Entry_Body_Formal_Part =>
1470 if Present (Entry_Index_Specification (Node)) then
1471 Write_Str_With_Col_Check_Sloc (" (");
1472 Sprint_Node (Entry_Index_Specification (Node));
1476 Write_Param_Specs (Node);
1477 Write_Str_With_Col_Check_Sloc (" when ");
1478 Sprint_Node (Condition (Node));
1480 when N_Entry_Call_Alternative =>
1481 Sprint_Node_List (Pragmas_Before (Node));
1482 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1483 Sprint_Node_List (Statements (Node));
1485 when N_Entry_Call_Statement =>
1487 Sprint_Node_Sloc (Name (Node));
1488 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1491 when N_Entry_Declaration =>
1492 Write_Indent_Str_Sloc ("entry ");
1493 Write_Id (Defining_Identifier (Node));
1495 if Present (Discrete_Subtype_Definition (Node)) then
1496 Write_Str_With_Col_Check (" (");
1497 Sprint_Node (Discrete_Subtype_Definition (Node));
1501 Write_Param_Specs (Node);
1504 when N_Entry_Index_Specification =>
1505 Write_Str_With_Col_Check_Sloc ("for ");
1506 Write_Id (Defining_Identifier (Node));
1507 Write_Str_With_Col_Check (" in ");
1508 Sprint_Node (Discrete_Subtype_Definition (Node));
1510 when N_Enumeration_Representation_Clause =>
1511 Write_Indent_Str_Sloc ("for ");
1512 Write_Id (Identifier (Node));
1513 Write_Str_With_Col_Check (" use ");
1514 Sprint_Node (Array_Aggregate (Node));
1517 when N_Enumeration_Type_Definition =>
1520 -- Skip attempt to print Literals field if it's not there and
1521 -- we are in package Standard (case of Character, which is
1522 -- handled specially (without an explicit literals list).
1524 if Sloc (Node) > Standard_Location
1525 or else Present (Literals (Node))
1527 Sprint_Paren_Comma_List (Literals (Node));
1531 Write_Str_With_Col_Check_Sloc ("<error>");
1533 when N_Exception_Declaration =>
1534 if Write_Indent_Identifiers (Node) then
1535 Write_Str_With_Col_Check (" : ");
1537 if Is_Statically_Allocated (Defining_Identifier (Node)) then
1538 Write_Str_With_Col_Check ("static ");
1541 Write_Str_Sloc ("exception");
1543 if Present (Expression (Node)) then
1545 Sprint_Node (Expression (Node));
1551 when N_Exception_Handler =>
1552 Write_Indent_Str_Sloc ("when ");
1554 if Present (Choice_Parameter (Node)) then
1555 Sprint_Node (Choice_Parameter (Node));
1559 Sprint_Bar_List (Exception_Choices (Node));
1561 Sprint_Indented_List (Statements (Node));
1563 when N_Exception_Renaming_Declaration =>
1566 Sprint_Node (Defining_Identifier (Node));
1567 Write_Str_With_Col_Check (" : exception renames ");
1568 Sprint_Node (Name (Node));
1571 when N_Exit_Statement =>
1572 Write_Indent_Str_Sloc ("exit");
1573 Sprint_Opt_Node (Name (Node));
1575 if Present (Condition (Node)) then
1576 Write_Str_With_Col_Check (" when ");
1577 Sprint_Node (Condition (Node));
1582 when N_Expanded_Name =>
1583 Sprint_Node (Prefix (Node));
1584 Write_Char_Sloc ('.');
1585 Sprint_Node (Selector_Name (Node));
1587 when N_Explicit_Dereference =>
1588 Sprint_Node (Prefix (Node));
1589 Write_Char_Sloc ('.');
1590 Write_Str_Sloc ("all");
1592 when N_Expression_With_Actions =>
1594 Write_Indent_Str_Sloc ("do ");
1596 Sprint_Node_List (Actions (Node));
1599 Write_Str_With_Col_Check_Sloc ("in ");
1600 Sprint_Node (Expression (Node));
1601 Write_Str_With_Col_Check (" end");
1605 when N_Extended_Return_Statement =>
1606 Write_Indent_Str_Sloc ("return ");
1607 Sprint_Node_List (Return_Object_Declarations (Node));
1609 if Present (Handled_Statement_Sequence (Node)) then
1610 Write_Str_With_Col_Check (" do");
1611 Sprint_Node (Handled_Statement_Sequence (Node));
1612 Write_Indent_Str ("end return;");
1614 Write_Indent_Str (";");
1617 when N_Extension_Aggregate =>
1618 Write_Str_With_Col_Check_Sloc ("(");
1619 Sprint_Node (Ancestor_Part (Node));
1620 Write_Str_With_Col_Check (" with ");
1622 if Null_Record_Present (Node) then
1623 Write_Str_With_Col_Check ("null record");
1625 if Present (Expressions (Node)) then
1626 Sprint_Comma_List (Expressions (Node));
1628 if Present (Component_Associations (Node)) then
1633 if Present (Component_Associations (Node)) then
1634 Sprint_Comma_List (Component_Associations (Node));
1640 when N_Floating_Point_Definition =>
1641 Write_Str_With_Col_Check_Sloc ("digits ");
1642 Sprint_Node (Digits_Expression (Node));
1643 Sprint_Opt_Node (Real_Range_Specification (Node));
1645 when N_Formal_Decimal_Fixed_Point_Definition =>
1646 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1648 when N_Formal_Derived_Type_Definition =>
1649 Write_Str_With_Col_Check_Sloc ("new ");
1650 Sprint_Node (Subtype_Mark (Node));
1652 if Present (Interface_List (Node)) then
1653 Write_Str_With_Col_Check (" and ");
1654 Sprint_And_List (Interface_List (Node));
1657 if Private_Present (Node) then
1658 Write_Str_With_Col_Check (" with private");
1661 when N_Formal_Abstract_Subprogram_Declaration =>
1662 Write_Indent_Str_Sloc ("with ");
1663 Sprint_Node (Specification (Node));
1665 Write_Str_With_Col_Check (" is abstract");
1667 if Box_Present (Node) then
1668 Write_Str_With_Col_Check (" <>");
1669 elsif Present (Default_Name (Node)) then
1670 Write_Str_With_Col_Check (" ");
1671 Sprint_Node (Default_Name (Node));
1676 when N_Formal_Concrete_Subprogram_Declaration =>
1677 Write_Indent_Str_Sloc ("with ");
1678 Sprint_Node (Specification (Node));
1680 if Box_Present (Node) then
1681 Write_Str_With_Col_Check (" is <>");
1682 elsif Present (Default_Name (Node)) then
1683 Write_Str_With_Col_Check (" is ");
1684 Sprint_Node (Default_Name (Node));
1689 when N_Formal_Discrete_Type_Definition =>
1690 Write_Str_With_Col_Check_Sloc ("<>");
1692 when N_Formal_Floating_Point_Definition =>
1693 Write_Str_With_Col_Check_Sloc ("digits <>");
1695 when N_Formal_Modular_Type_Definition =>
1696 Write_Str_With_Col_Check_Sloc ("mod <>");
1698 when N_Formal_Object_Declaration =>
1701 if Write_Indent_Identifiers (Node) then
1704 if In_Present (Node) then
1705 Write_Str_With_Col_Check ("in ");
1708 if Out_Present (Node) then
1709 Write_Str_With_Col_Check ("out ");
1712 if Present (Subtype_Mark (Node)) then
1714 -- Ada 2005 (AI-423): Formal object with null exclusion
1716 if Null_Exclusion_Present (Node) then
1717 Write_Str ("not null ");
1720 Sprint_Node (Subtype_Mark (Node));
1722 -- Ada 2005 (AI-423): Formal object with access definition
1725 pragma Assert (Present (Access_Definition (Node)));
1727 Sprint_Node (Access_Definition (Node));
1730 if Present (Default_Expression (Node)) then
1732 Sprint_Node (Default_Expression (Node));
1738 when N_Formal_Ordinary_Fixed_Point_Definition =>
1739 Write_Str_With_Col_Check_Sloc ("delta <>");
1741 when N_Formal_Package_Declaration =>
1742 Write_Indent_Str_Sloc ("with package ");
1743 Write_Id (Defining_Identifier (Node));
1744 Write_Str_With_Col_Check (" is new ");
1745 Sprint_Node (Name (Node));
1746 Write_Str_With_Col_Check (" (<>);");
1748 when N_Formal_Private_Type_Definition =>
1749 if Abstract_Present (Node) then
1750 Write_Str_With_Col_Check ("abstract ");
1753 if Tagged_Present (Node) then
1754 Write_Str_With_Col_Check ("tagged ");
1757 if Limited_Present (Node) then
1758 Write_Str_With_Col_Check ("limited ");
1761 Write_Str_With_Col_Check_Sloc ("private");
1763 when N_Formal_Signed_Integer_Type_Definition =>
1764 Write_Str_With_Col_Check_Sloc ("range <>");
1766 when N_Formal_Type_Declaration =>
1767 Write_Indent_Str_Sloc ("type ");
1768 Write_Id (Defining_Identifier (Node));
1770 if Present (Discriminant_Specifications (Node)) then
1771 Write_Discr_Specs (Node);
1772 elsif Unknown_Discriminants_Present (Node) then
1773 Write_Str_With_Col_Check ("(<>)");
1776 Write_Str_With_Col_Check (" is ");
1777 Sprint_Node (Formal_Type_Definition (Node));
1780 when N_Free_Statement =>
1781 Write_Indent_Str_Sloc ("free ");
1782 Sprint_Node (Expression (Node));
1785 when N_Freeze_Entity =>
1786 if Dump_Original_Only then
1789 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1791 Write_Rewrite_Str ("<<<");
1792 Write_Str_With_Col_Check_Sloc ("freeze ");
1793 Write_Id (Entity (Node));
1796 if No (Actions (Node)) then
1800 -- Output freeze actions. We increment Freeze_Indent during
1801 -- this output to avoid generating extra blank lines before
1802 -- any procedures included in the freeze actions.
1804 Freeze_Indent := Freeze_Indent + 1;
1805 Sprint_Indented_List (Actions (Node));
1806 Freeze_Indent := Freeze_Indent - 1;
1807 Write_Indent_Str ("]");
1810 Write_Rewrite_Str (">>>");
1813 when N_Full_Type_Declaration =>
1814 Write_Indent_Str_Sloc ("type ");
1815 Sprint_Node (Defining_Identifier (Node));
1816 Write_Discr_Specs (Node);
1817 Write_Str_With_Col_Check (" is ");
1818 Sprint_Node (Type_Definition (Node));
1821 when N_Function_Call =>
1823 Write_Subprogram_Name (Name (Node));
1824 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1826 when N_Function_Instantiation =>
1827 Write_Indent_Str_Sloc ("function ");
1828 Sprint_Node (Defining_Unit_Name (Node));
1829 Write_Str_With_Col_Check (" is new ");
1830 Sprint_Node (Name (Node));
1831 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1834 when N_Function_Specification =>
1835 Write_Str_With_Col_Check_Sloc ("function ");
1836 Sprint_Node (Defining_Unit_Name (Node));
1837 Write_Param_Specs (Node);
1838 Write_Str_With_Col_Check (" return ");
1840 -- Ada 2005 (AI-231)
1842 if Nkind (Result_Definition (Node)) /= N_Access_Definition
1843 and then Null_Exclusion_Present (Node)
1845 Write_Str (" not null ");
1848 Sprint_Node (Result_Definition (Node));
1850 when N_Generic_Association =>
1853 if Present (Selector_Name (Node)) then
1854 Sprint_Node (Selector_Name (Node));
1858 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1860 when N_Generic_Function_Renaming_Declaration =>
1861 Write_Indent_Str_Sloc ("generic function ");
1862 Sprint_Node (Defining_Unit_Name (Node));
1863 Write_Str_With_Col_Check (" renames ");
1864 Sprint_Node (Name (Node));
1867 when N_Generic_Package_Declaration =>
1869 Write_Indent_Str_Sloc ("generic ");
1870 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1872 Sprint_Node (Specification (Node));
1875 when N_Generic_Package_Renaming_Declaration =>
1876 Write_Indent_Str_Sloc ("generic package ");
1877 Sprint_Node (Defining_Unit_Name (Node));
1878 Write_Str_With_Col_Check (" renames ");
1879 Sprint_Node (Name (Node));
1882 when N_Generic_Procedure_Renaming_Declaration =>
1883 Write_Indent_Str_Sloc ("generic procedure ");
1884 Sprint_Node (Defining_Unit_Name (Node));
1885 Write_Str_With_Col_Check (" renames ");
1886 Sprint_Node (Name (Node));
1889 when N_Generic_Subprogram_Declaration =>
1891 Write_Indent_Str_Sloc ("generic ");
1892 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1894 Sprint_Node (Specification (Node));
1897 when N_Goto_Statement =>
1898 Write_Indent_Str_Sloc ("goto ");
1899 Sprint_Node (Name (Node));
1902 if Nkind (Next (Node)) = N_Label then
1906 when N_Handled_Sequence_Of_Statements =>
1908 Sprint_Indented_List (Statements (Node));
1910 if Present (Exception_Handlers (Node)) then
1911 Write_Indent_Str ("exception");
1913 Sprint_Node_List (Exception_Handlers (Node));
1917 if Present (At_End_Proc (Node)) then
1918 Write_Indent_Str ("at end");
1921 Sprint_Node (At_End_Proc (Node));
1926 when N_Identifier =>
1930 when N_If_Statement =>
1931 Write_Indent_Str_Sloc ("if ");
1932 Sprint_Node (Condition (Node));
1933 Write_Str_With_Col_Check (" then");
1934 Sprint_Indented_List (Then_Statements (Node));
1935 Sprint_Opt_Node_List (Elsif_Parts (Node));
1937 if Present (Else_Statements (Node)) then
1938 Write_Indent_Str ("else");
1939 Sprint_Indented_List (Else_Statements (Node));
1942 Write_Indent_Str ("end if;");
1944 when N_Implicit_Label_Declaration =>
1945 if not Dump_Original_Only then
1947 Write_Rewrite_Str ("<<<");
1949 Write_Id (Defining_Identifier (Node));
1951 Write_Str_With_Col_Check ("label");
1952 Write_Rewrite_Str (">>>");
1956 Sprint_Left_Opnd (Node);
1957 Write_Str_Sloc (" in ");
1959 if Present (Right_Opnd (Node)) then
1960 Sprint_Right_Opnd (Node);
1962 Sprint_Bar_List (Alternatives (Node));
1965 when N_Incomplete_Type_Declaration =>
1966 Write_Indent_Str_Sloc ("type ");
1967 Write_Id (Defining_Identifier (Node));
1969 if Present (Discriminant_Specifications (Node)) then
1970 Write_Discr_Specs (Node);
1971 elsif Unknown_Discriminants_Present (Node) then
1972 Write_Str_With_Col_Check ("(<>)");
1977 when N_Index_Or_Discriminant_Constraint =>
1979 Sprint_Paren_Comma_List (Constraints (Node));
1981 when N_Indexed_Component =>
1982 Sprint_Node_Sloc (Prefix (Node));
1983 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1985 when N_Integer_Literal =>
1986 if Print_In_Hex (Node) then
1987 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1989 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1992 when N_Iteration_Scheme =>
1993 if Present (Condition (Node)) then
1994 Write_Str_With_Col_Check_Sloc ("while ");
1995 Sprint_Node (Condition (Node));
1997 Write_Str_With_Col_Check_Sloc ("for ");
1998 Sprint_Node (Loop_Parameter_Specification (Node));
2003 when N_Itype_Reference =>
2004 Write_Indent_Str_Sloc ("reference ");
2005 Write_Id (Itype (Node));
2008 Write_Indent_Str_Sloc ("<<");
2009 Write_Id (Identifier (Node));
2012 when N_Loop_Parameter_Specification =>
2014 Write_Id (Defining_Identifier (Node));
2015 Write_Str_With_Col_Check (" in ");
2017 if Reverse_Present (Node) then
2018 Write_Str_With_Col_Check ("reverse ");
2021 Sprint_Node (Discrete_Subtype_Definition (Node));
2023 when N_Loop_Statement =>
2026 if Present (Identifier (Node))
2027 and then (not Has_Created_Identifier (Node)
2028 or else not Dump_Original_Only)
2030 Write_Rewrite_Str ("<<<");
2031 Write_Id (Identifier (Node));
2033 Write_Rewrite_Str (">>>");
2034 Sprint_Node (Iteration_Scheme (Node));
2035 Write_Str_With_Col_Check_Sloc ("loop");
2036 Sprint_Indented_List (Statements (Node));
2037 Write_Indent_Str ("end loop ");
2038 Write_Rewrite_Str ("<<<");
2039 Write_Id (Identifier (Node));
2040 Write_Rewrite_Str (">>>");
2044 Sprint_Node (Iteration_Scheme (Node));
2045 Write_Str_With_Col_Check_Sloc ("loop");
2046 Sprint_Indented_List (Statements (Node));
2047 Write_Indent_Str ("end loop;");
2050 when N_Mod_Clause =>
2051 Sprint_Node_List (Pragmas_Before (Node));
2052 Write_Str_With_Col_Check_Sloc ("at mod ");
2053 Sprint_Node (Expression (Node));
2055 when N_Modular_Type_Definition =>
2056 Write_Str_With_Col_Check_Sloc ("mod ");
2057 Sprint_Node (Expression (Node));
2060 Sprint_Left_Opnd (Node);
2061 Write_Str_Sloc (" not in ");
2063 if Present (Right_Opnd (Node)) then
2064 Sprint_Right_Opnd (Node);
2066 Sprint_Bar_List (Alternatives (Node));
2070 Write_Str_With_Col_Check_Sloc ("null");
2072 when N_Null_Statement =>
2073 if Comes_From_Source (Node)
2074 or else Dump_Freeze_Null
2075 or else not Is_List_Member (Node)
2076 or else (No (Prev (Node)) and then No (Next (Node)))
2078 Write_Indent_Str_Sloc ("null;");
2081 when N_Number_Declaration =>
2084 if Write_Indent_Identifiers (Node) then
2085 Write_Str_With_Col_Check (" : constant ");
2087 Sprint_Node (Expression (Node));
2091 when N_Object_Declaration =>
2094 if Write_Indent_Identifiers (Node) then
2096 Def_Id : constant Entity_Id := Defining_Identifier (Node);
2099 Write_Str_With_Col_Check (" : ");
2101 if Is_Statically_Allocated (Def_Id) then
2102 Write_Str_With_Col_Check ("static ");
2105 if Aliased_Present (Node) then
2106 Write_Str_With_Col_Check ("aliased ");
2109 if Constant_Present (Node) then
2110 Write_Str_With_Col_Check ("constant ");
2113 -- Ada 2005 (AI-231)
2115 if Null_Exclusion_Present (Node) then
2116 Write_Str_With_Col_Check ("not null ");
2119 Sprint_Node (Object_Definition (Node));
2121 if Present (Expression (Node)) then
2123 Sprint_Node (Expression (Node));
2128 -- Handle implicit importation and implicit exportation of
2129 -- object declarations:
2130 -- $pragma import (Convention_Id, Def_Id, "...");
2131 -- $pragma export (Convention_Id, Def_Id, "...");
2133 if Is_Internal (Def_Id)
2134 and then Present (Interface_Name (Def_Id))
2136 Write_Indent_Str_Sloc ("$pragma ");
2138 if Is_Imported (Def_Id) then
2139 Write_Str ("import (");
2141 else pragma Assert (Is_Exported (Def_Id));
2142 Write_Str ("export (");
2146 Prefix : constant String := "Convention_";
2147 S : constant String := Convention (Def_Id)'Img;
2150 Name_Len := S'Last - Prefix'Last;
2151 Name_Buffer (1 .. Name_Len) :=
2152 S (Prefix'Last + 1 .. S'Last);
2153 Set_Casing (All_Lower_Case);
2154 Write_Str (Name_Buffer (1 .. Name_Len));
2160 Write_String_Table_Entry
2161 (Strval (Interface_Name (Def_Id)));
2167 when N_Object_Renaming_Declaration =>
2170 Sprint_Node (Defining_Identifier (Node));
2173 -- Ada 2005 (AI-230): Access renamings
2175 if Present (Access_Definition (Node)) then
2176 Sprint_Node (Access_Definition (Node));
2178 elsif Present (Subtype_Mark (Node)) then
2180 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2182 if Null_Exclusion_Present (Node) then
2183 Write_Str ("not null ");
2186 Sprint_Node (Subtype_Mark (Node));
2189 Write_Str (" ??? ");
2192 Write_Str_With_Col_Check (" renames ");
2193 Sprint_Node (Name (Node));
2197 Write_Operator (Node, "abs ");
2198 Sprint_Right_Opnd (Node);
2201 Sprint_Left_Opnd (Node);
2202 Write_Operator (Node, " + ");
2203 Sprint_Right_Opnd (Node);
2206 Sprint_Left_Opnd (Node);
2207 Write_Operator (Node, " and ");
2208 Sprint_Right_Opnd (Node);
2211 Sprint_Left_Opnd (Node);
2212 Write_Operator (Node, " & ");
2213 Sprint_Right_Opnd (Node);
2216 Sprint_Left_Opnd (Node);
2218 Process_TFAI_RR_Flags (Node);
2219 Write_Operator (Node, "/ ");
2220 Sprint_Right_Opnd (Node);
2223 Sprint_Left_Opnd (Node);
2224 Write_Operator (Node, " = ");
2225 Sprint_Right_Opnd (Node);
2228 Sprint_Left_Opnd (Node);
2229 Write_Operator (Node, " ** ");
2230 Sprint_Right_Opnd (Node);
2233 Sprint_Left_Opnd (Node);
2234 Write_Operator (Node, " >= ");
2235 Sprint_Right_Opnd (Node);
2238 Sprint_Left_Opnd (Node);
2239 Write_Operator (Node, " > ");
2240 Sprint_Right_Opnd (Node);
2243 Sprint_Left_Opnd (Node);
2244 Write_Operator (Node, " <= ");
2245 Sprint_Right_Opnd (Node);
2248 Sprint_Left_Opnd (Node);
2249 Write_Operator (Node, " < ");
2250 Sprint_Right_Opnd (Node);
2253 Write_Operator (Node, "-");
2254 Sprint_Right_Opnd (Node);
2257 Sprint_Left_Opnd (Node);
2259 if Treat_Fixed_As_Integer (Node) then
2263 Write_Operator (Node, " mod ");
2264 Sprint_Right_Opnd (Node);
2266 when N_Op_Multiply =>
2267 Sprint_Left_Opnd (Node);
2269 Process_TFAI_RR_Flags (Node);
2270 Write_Operator (Node, "* ");
2271 Sprint_Right_Opnd (Node);
2274 Sprint_Left_Opnd (Node);
2275 Write_Operator (Node, " /= ");
2276 Sprint_Right_Opnd (Node);
2279 Write_Operator (Node, "not ");
2280 Sprint_Right_Opnd (Node);
2283 Sprint_Left_Opnd (Node);
2284 Write_Operator (Node, " or ");
2285 Sprint_Right_Opnd (Node);
2288 Write_Operator (Node, "+");
2289 Sprint_Right_Opnd (Node);
2292 Sprint_Left_Opnd (Node);
2294 if Treat_Fixed_As_Integer (Node) then
2298 Write_Operator (Node, " rem ");
2299 Sprint_Right_Opnd (Node);
2305 Write_Str_With_Col_Check ("(");
2306 Sprint_Node (Left_Opnd (Node));
2308 Sprint_Node (Right_Opnd (Node));
2311 when N_Op_Subtract =>
2312 Sprint_Left_Opnd (Node);
2313 Write_Operator (Node, " - ");
2314 Sprint_Right_Opnd (Node);
2317 Sprint_Left_Opnd (Node);
2318 Write_Operator (Node, " xor ");
2319 Sprint_Right_Opnd (Node);
2321 when N_Operator_Symbol =>
2322 Write_Name_With_Col_Check_Sloc (Chars (Node));
2324 when N_Ordinary_Fixed_Point_Definition =>
2325 Write_Str_With_Col_Check_Sloc ("delta ");
2326 Sprint_Node (Delta_Expression (Node));
2327 Sprint_Opt_Node (Real_Range_Specification (Node));
2330 Sprint_Left_Opnd (Node);
2331 Write_Str_Sloc (" or else ");
2332 Sprint_Right_Opnd (Node);
2334 when N_Others_Choice =>
2335 if All_Others (Node) then
2336 Write_Str_With_Col_Check ("all ");
2339 Write_Str_With_Col_Check_Sloc ("others");
2341 when N_Package_Body =>
2343 Write_Indent_Str_Sloc ("package body ");
2344 Sprint_Node (Defining_Unit_Name (Node));
2346 Sprint_Indented_List (Declarations (Node));
2348 if Present (Handled_Statement_Sequence (Node)) then
2349 Write_Indent_Str ("begin");
2350 Sprint_Node (Handled_Statement_Sequence (Node));
2353 Write_Indent_Str ("end ");
2355 (Handled_Statement_Sequence (Node), Defining_Unit_Name (Node));
2358 when N_Package_Body_Stub =>
2359 Write_Indent_Str_Sloc ("package body ");
2360 Sprint_Node (Defining_Identifier (Node));
2361 Write_Str_With_Col_Check (" is separate;");
2363 when N_Package_Declaration =>
2366 Sprint_Node_Sloc (Specification (Node));
2369 when N_Package_Instantiation =>
2371 Write_Indent_Str_Sloc ("package ");
2372 Sprint_Node (Defining_Unit_Name (Node));
2373 Write_Str (" is new ");
2374 Sprint_Node (Name (Node));
2375 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2378 when N_Package_Renaming_Declaration =>
2379 Write_Indent_Str_Sloc ("package ");
2380 Sprint_Node (Defining_Unit_Name (Node));
2381 Write_Str_With_Col_Check (" renames ");
2382 Sprint_Node (Name (Node));
2385 when N_Package_Specification =>
2386 Write_Str_With_Col_Check_Sloc ("package ");
2387 Sprint_Node (Defining_Unit_Name (Node));
2389 Sprint_Indented_List (Visible_Declarations (Node));
2391 if Present (Private_Declarations (Node)) then
2392 Write_Indent_Str ("private");
2393 Sprint_Indented_List (Private_Declarations (Node));
2396 Write_Indent_Str ("end ");
2397 Sprint_Node (Defining_Unit_Name (Node));
2399 when N_Parameter_Association =>
2400 Sprint_Node_Sloc (Selector_Name (Node));
2402 Sprint_Node (Explicit_Actual_Parameter (Node));
2404 when N_Parameter_Specification =>
2407 if Write_Identifiers (Node) then
2410 if In_Present (Node) then
2411 Write_Str_With_Col_Check ("in ");
2414 if Out_Present (Node) then
2415 Write_Str_With_Col_Check ("out ");
2418 -- Ada 2005 (AI-231): Parameter specification may carry null
2419 -- exclusion. Do not print it now if this is an access formal,
2420 -- it is emitted when the access definition is displayed.
2422 if Null_Exclusion_Present (Node)
2423 and then Nkind (Parameter_Type (Node))
2424 /= N_Access_Definition
2426 Write_Str ("not null ");
2429 Sprint_Node (Parameter_Type (Node));
2431 if Present (Expression (Node)) then
2433 Sprint_Node (Expression (Node));
2439 when N_Parameterized_Expression =>
2441 Sprint_Node_Sloc (Specification (Node));
2446 Sprint_Node (Expression (Node));
2450 when N_Pop_Constraint_Error_Label =>
2451 Write_Indent_Str ("%pop_constraint_error_label");
2453 when N_Pop_Program_Error_Label =>
2454 Write_Indent_Str ("%pop_program_error_label");
2456 when N_Pop_Storage_Error_Label =>
2457 Write_Indent_Str ("%pop_storage_error_label");
2459 when N_Private_Extension_Declaration =>
2460 Write_Indent_Str_Sloc ("type ");
2461 Write_Id (Defining_Identifier (Node));
2463 if Present (Discriminant_Specifications (Node)) then
2464 Write_Discr_Specs (Node);
2465 elsif Unknown_Discriminants_Present (Node) then
2466 Write_Str_With_Col_Check ("(<>)");
2469 Write_Str_With_Col_Check (" is new ");
2470 Sprint_Node (Subtype_Indication (Node));
2472 if Present (Interface_List (Node)) then
2473 Write_Str_With_Col_Check (" and ");
2474 Sprint_And_List (Interface_List (Node));
2477 Write_Str_With_Col_Check (" with private;");
2479 when N_Private_Type_Declaration =>
2480 Write_Indent_Str_Sloc ("type ");
2481 Write_Id (Defining_Identifier (Node));
2483 if Present (Discriminant_Specifications (Node)) then
2484 Write_Discr_Specs (Node);
2485 elsif Unknown_Discriminants_Present (Node) then
2486 Write_Str_With_Col_Check ("(<>)");
2491 if Tagged_Present (Node) then
2492 Write_Str_With_Col_Check ("tagged ");
2495 if Limited_Present (Node) then
2496 Write_Str_With_Col_Check ("limited ");
2499 Write_Str_With_Col_Check ("private;");
2501 when N_Push_Constraint_Error_Label =>
2502 Write_Indent_Str ("%push_constraint_error_label (");
2504 if Present (Exception_Label (Node)) then
2505 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2510 when N_Push_Program_Error_Label =>
2511 Write_Indent_Str ("%push_program_error_label (");
2513 if Present (Exception_Label (Node)) then
2514 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2519 when N_Push_Storage_Error_Label =>
2520 Write_Indent_Str ("%push_storage_error_label (");
2522 if Present (Exception_Label (Node)) then
2523 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2529 Write_Indent_Str_Sloc ("pragma ");
2530 Write_Name_With_Col_Check (Pragma_Name (Node));
2532 if Present (Pragma_Argument_Associations (Node)) then
2533 Sprint_Opt_Paren_Comma_List
2534 (Pragma_Argument_Associations (Node));
2539 when N_Pragma_Argument_Association =>
2542 if Chars (Node) /= No_Name then
2543 Write_Name_With_Col_Check (Chars (Node));
2547 Sprint_Node (Expression (Node));
2549 when N_Procedure_Call_Statement =>
2552 Write_Subprogram_Name (Name (Node));
2553 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2556 when N_Procedure_Instantiation =>
2557 Write_Indent_Str_Sloc ("procedure ");
2558 Sprint_Node (Defining_Unit_Name (Node));
2559 Write_Str_With_Col_Check (" is new ");
2560 Sprint_Node (Name (Node));
2561 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2564 when N_Procedure_Specification =>
2565 Write_Str_With_Col_Check_Sloc ("procedure ");
2566 Sprint_Node (Defining_Unit_Name (Node));
2567 Write_Param_Specs (Node);
2569 when N_Protected_Body =>
2570 Write_Indent_Str_Sloc ("protected body ");
2571 Write_Id (Defining_Identifier (Node));
2573 Sprint_Indented_List (Declarations (Node));
2574 Write_Indent_Str ("end ");
2575 Write_Id (Defining_Identifier (Node));
2578 when N_Protected_Body_Stub =>
2579 Write_Indent_Str_Sloc ("protected body ");
2580 Write_Id (Defining_Identifier (Node));
2581 Write_Str_With_Col_Check (" is separate;");
2583 when N_Protected_Definition =>
2585 Sprint_Indented_List (Visible_Declarations (Node));
2587 if Present (Private_Declarations (Node)) then
2588 Write_Indent_Str ("private");
2589 Sprint_Indented_List (Private_Declarations (Node));
2592 Write_Indent_Str ("end ");
2594 when N_Protected_Type_Declaration =>
2595 Write_Indent_Str_Sloc ("protected type ");
2596 Sprint_Node (Defining_Identifier (Node));
2597 Write_Discr_Specs (Node);
2599 if Present (Interface_List (Node)) then
2600 Write_Str (" is new ");
2601 Sprint_And_List (Interface_List (Node));
2602 Write_Str (" with ");
2607 Sprint_Node (Protected_Definition (Node));
2608 Write_Id (Defining_Identifier (Node));
2611 when N_Qualified_Expression =>
2612 Sprint_Node (Subtype_Mark (Node));
2613 Write_Char_Sloc (''');
2615 -- Print expression, make sure we have at least one level of
2616 -- parentheses around the expression. For cases of qualified
2617 -- expressions in the source, this is always the case, but
2618 -- for generated qualifications, there may be no explicit
2619 -- parentheses present.
2621 if Paren_Count (Expression (Node)) /= 0 then
2622 Sprint_Node (Expression (Node));
2625 Sprint_Node (Expression (Node));
2629 when N_Quantified_Expression =>
2632 if All_Present (Node) then
2633 Write_Str (" all ");
2635 Write_Str (" some ");
2638 Sprint_Node (Loop_Parameter_Specification (Node));
2640 Sprint_Node (Condition (Node));
2642 when N_Raise_Constraint_Error =>
2644 -- This node can be used either as a subexpression or as a
2645 -- statement form. The following test is a reasonably reliable
2646 -- way to distinguish the two cases.
2648 if Is_List_Member (Node)
2649 and then Nkind (Parent (Node)) not in N_Subexpr
2654 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2655 Write_Condition_And_Reason (Node);
2657 when N_Raise_Program_Error =>
2659 -- This node can be used either as a subexpression or as a
2660 -- statement form. The following test is a reasonably reliable
2661 -- way to distinguish the two cases.
2663 if Is_List_Member (Node)
2664 and then Nkind (Parent (Node)) not in N_Subexpr
2669 Write_Str_With_Col_Check_Sloc ("[program_error");
2670 Write_Condition_And_Reason (Node);
2672 when N_Raise_Storage_Error =>
2674 -- This node can be used either as a subexpression or as a
2675 -- statement form. The following test is a reasonably reliable
2676 -- way to distinguish the two cases.
2678 if Is_List_Member (Node)
2679 and then Nkind (Parent (Node)) not in N_Subexpr
2684 Write_Str_With_Col_Check_Sloc ("[storage_error");
2685 Write_Condition_And_Reason (Node);
2687 when N_Raise_Statement =>
2688 Write_Indent_Str_Sloc ("raise ");
2689 Sprint_Node (Name (Node));
2693 Sprint_Node (Low_Bound (Node));
2694 Write_Str_Sloc (" .. ");
2695 Sprint_Node (High_Bound (Node));
2696 Update_Itype (Node);
2698 when N_Range_Constraint =>
2699 Write_Str_With_Col_Check_Sloc ("range ");
2700 Sprint_Node (Range_Expression (Node));
2702 when N_Real_Literal =>
2703 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2705 when N_Real_Range_Specification =>
2706 Write_Str_With_Col_Check_Sloc ("range ");
2707 Sprint_Node (Low_Bound (Node));
2709 Sprint_Node (High_Bound (Node));
2711 when N_Record_Definition =>
2712 if Abstract_Present (Node) then
2713 Write_Str_With_Col_Check ("abstract ");
2716 if Tagged_Present (Node) then
2717 Write_Str_With_Col_Check ("tagged ");
2720 if Limited_Present (Node) then
2721 Write_Str_With_Col_Check ("limited ");
2724 if Null_Present (Node) then
2725 Write_Str_With_Col_Check_Sloc ("null record");
2728 Write_Str_With_Col_Check_Sloc ("record");
2729 Sprint_Node (Component_List (Node));
2730 Write_Indent_Str ("end record");
2733 when N_Record_Representation_Clause =>
2734 Write_Indent_Str_Sloc ("for ");
2735 Sprint_Node (Identifier (Node));
2736 Write_Str_With_Col_Check (" use record ");
2738 if Present (Mod_Clause (Node)) then
2739 Sprint_Node (Mod_Clause (Node));
2742 Sprint_Indented_List (Component_Clauses (Node));
2743 Write_Indent_Str ("end record;");
2746 Sprint_Node (Prefix (Node));
2747 Write_Str_With_Col_Check_Sloc ("'reference");
2749 when N_Requeue_Statement =>
2750 Write_Indent_Str_Sloc ("requeue ");
2751 Sprint_Node (Name (Node));
2753 if Abort_Present (Node) then
2754 Write_Str_With_Col_Check (" with abort");
2759 -- Don't we want to print more detail???
2761 -- Doc of this extended syntax belongs in sinfo.ads and/or
2764 when N_SCIL_Dispatch_Table_Tag_Init =>
2765 Write_Indent_Str ("[N_SCIL_Dispatch_Table_Tag_Init]");
2767 when N_SCIL_Dispatching_Call =>
2768 Write_Indent_Str ("[N_SCIL_Dispatching_Node]");
2770 when N_SCIL_Membership_Test =>
2771 Write_Indent_Str ("[N_SCIL_Membership_Test]");
2773 when N_Simple_Return_Statement =>
2774 if Present (Expression (Node)) then
2775 Write_Indent_Str_Sloc ("return ");
2776 Sprint_Node (Expression (Node));
2779 Write_Indent_Str_Sloc ("return;");
2782 when N_Selective_Accept =>
2783 Write_Indent_Str_Sloc ("select");
2788 Alt_Node := First (Select_Alternatives (Node));
2791 Sprint_Node (Alt_Node);
2794 exit when No (Alt_Node);
2795 Write_Indent_Str ("or");
2799 if Present (Else_Statements (Node)) then
2800 Write_Indent_Str ("else");
2801 Sprint_Indented_List (Else_Statements (Node));
2804 Write_Indent_Str ("end select;");
2806 when N_Signed_Integer_Type_Definition =>
2807 Write_Str_With_Col_Check_Sloc ("range ");
2808 Sprint_Node (Low_Bound (Node));
2810 Sprint_Node (High_Bound (Node));
2812 when N_Single_Protected_Declaration =>
2813 Write_Indent_Str_Sloc ("protected ");
2814 Write_Id (Defining_Identifier (Node));
2816 Sprint_Node (Protected_Definition (Node));
2817 Write_Id (Defining_Identifier (Node));
2820 when N_Single_Task_Declaration =>
2821 Write_Indent_Str_Sloc ("task ");
2822 Sprint_Node (Defining_Identifier (Node));
2824 if Present (Task_Definition (Node)) then
2826 Sprint_Node (Task_Definition (Node));
2831 when N_Selected_Component =>
2832 Sprint_Node (Prefix (Node));
2833 Write_Char_Sloc ('.');
2834 Sprint_Node (Selector_Name (Node));
2838 Sprint_Node (Prefix (Node));
2839 Write_Str_With_Col_Check (" (");
2840 Sprint_Node (Discrete_Range (Node));
2843 when N_String_Literal =>
2844 if String_Length (Strval (Node)) + Column > Sprint_Line_Limit then
2845 Write_Indent_Str (" ");
2849 Write_String_Table_Entry (Strval (Node));
2851 when N_Subprogram_Body =>
2853 -- Output extra blank line unless we are in freeze actions
2855 if Freeze_Indent = 0 then
2861 if Present (Corresponding_Spec (Node)) then
2862 Sprint_Node_Sloc (Parent (Corresponding_Spec (Node)));
2864 Sprint_Node_Sloc (Specification (Node));
2869 Sprint_Indented_List (Declarations (Node));
2870 Write_Indent_Str ("begin");
2871 Sprint_Node (Handled_Statement_Sequence (Node));
2873 Write_Indent_Str ("end ");
2876 (Handled_Statement_Sequence (Node),
2877 Defining_Unit_Name (Specification (Node)));
2880 if Is_List_Member (Node)
2881 and then Present (Next (Node))
2882 and then Nkind (Next (Node)) /= N_Subprogram_Body
2887 when N_Subprogram_Body_Stub =>
2889 Sprint_Node_Sloc (Specification (Node));
2890 Write_Str_With_Col_Check (" is separate;");
2892 when N_Subprogram_Declaration =>
2894 Sprint_Node_Sloc (Specification (Node));
2896 if Nkind (Specification (Node)) = N_Procedure_Specification
2897 and then Null_Present (Specification (Node))
2899 Write_Str_With_Col_Check (" is null");
2904 when N_Subprogram_Info =>
2905 Sprint_Node (Identifier (Node));
2906 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2908 when N_Subprogram_Renaming_Declaration =>
2910 Sprint_Node (Specification (Node));
2911 Write_Str_With_Col_Check_Sloc (" renames ");
2912 Sprint_Node (Name (Node));
2915 when N_Subtype_Declaration =>
2916 Write_Indent_Str_Sloc ("subtype ");
2917 Sprint_Node (Defining_Identifier (Node));
2920 -- Ada 2005 (AI-231)
2922 if Null_Exclusion_Present (Node) then
2923 Write_Str ("not null ");
2926 Sprint_Node (Subtype_Indication (Node));
2929 when N_Subtype_Indication =>
2930 Sprint_Node_Sloc (Subtype_Mark (Node));
2932 Sprint_Node (Constraint (Node));
2935 Write_Indent_Str_Sloc ("separate (");
2936 Sprint_Node (Name (Node));
2939 Sprint_Node (Proper_Body (Node));
2942 Write_Indent_Str_Sloc ("task body ");
2943 Write_Id (Defining_Identifier (Node));
2945 Sprint_Indented_List (Declarations (Node));
2946 Write_Indent_Str ("begin");
2947 Sprint_Node (Handled_Statement_Sequence (Node));
2948 Write_Indent_Str ("end ");
2950 (Handled_Statement_Sequence (Node), Defining_Identifier (Node));
2953 when N_Task_Body_Stub =>
2954 Write_Indent_Str_Sloc ("task body ");
2955 Write_Id (Defining_Identifier (Node));
2956 Write_Str_With_Col_Check (" is separate;");
2958 when N_Task_Definition =>
2960 Sprint_Indented_List (Visible_Declarations (Node));
2962 if Present (Private_Declarations (Node)) then
2963 Write_Indent_Str ("private");
2964 Sprint_Indented_List (Private_Declarations (Node));
2967 Write_Indent_Str ("end ");
2968 Sprint_End_Label (Node, Defining_Identifier (Parent (Node)));
2970 when N_Task_Type_Declaration =>
2971 Write_Indent_Str_Sloc ("task type ");
2972 Sprint_Node (Defining_Identifier (Node));
2973 Write_Discr_Specs (Node);
2975 if Present (Interface_List (Node)) then
2976 Write_Str (" is new ");
2977 Sprint_And_List (Interface_List (Node));
2980 if Present (Task_Definition (Node)) then
2981 if No (Interface_List (Node)) then
2984 Write_Str (" with ");
2987 Sprint_Node (Task_Definition (Node));
2992 when N_Terminate_Alternative =>
2993 Sprint_Node_List (Pragmas_Before (Node));
2996 if Present (Condition (Node)) then
2997 Write_Str_With_Col_Check ("when ");
2998 Sprint_Node (Condition (Node));
3002 Write_Str_With_Col_Check_Sloc ("terminate;");
3003 Sprint_Node_List (Pragmas_After (Node));
3005 when N_Timed_Entry_Call =>
3006 Write_Indent_Str_Sloc ("select");
3008 Sprint_Node (Entry_Call_Alternative (Node));
3010 Write_Indent_Str ("or");
3012 Sprint_Node (Delay_Alternative (Node));
3014 Write_Indent_Str ("end select;");
3016 when N_Triggering_Alternative =>
3017 Sprint_Node_List (Pragmas_Before (Node));
3018 Sprint_Node_Sloc (Triggering_Statement (Node));
3019 Sprint_Node_List (Statements (Node));
3021 when N_Type_Conversion =>
3023 Sprint_Node (Subtype_Mark (Node));
3026 if Conversion_OK (Node) then
3030 if Float_Truncate (Node) then
3034 if Rounded_Result (Node) then
3039 Sprint_Node (Expression (Node));
3042 when N_Unchecked_Expression =>
3045 Sprint_Node_Sloc (Expression (Node));
3048 when N_Unchecked_Type_Conversion =>
3049 Sprint_Node (Subtype_Mark (Node));
3051 Write_Str_With_Col_Check ("(");
3052 Sprint_Node_Sloc (Expression (Node));
3055 when N_Unconstrained_Array_Definition =>
3056 Write_Str_With_Col_Check_Sloc ("array (");
3061 Node1 := First (Subtype_Marks (Node));
3063 Sprint_Node (Node1);
3064 Write_Str_With_Col_Check (" range <>");
3066 exit when Node1 = Empty;
3071 Write_Str (") of ");
3072 Sprint_Node (Component_Definition (Node));
3074 when N_Unused_At_Start | N_Unused_At_End =>
3075 Write_Indent_Str ("***** Error, unused node encountered *****");
3078 when N_Use_Package_Clause =>
3079 Write_Indent_Str_Sloc ("use ");
3080 Sprint_Comma_List (Names (Node));
3083 when N_Use_Type_Clause =>
3084 Write_Indent_Str_Sloc ("use type ");
3085 Sprint_Comma_List (Subtype_Marks (Node));
3088 when N_Validate_Unchecked_Conversion =>
3089 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
3090 Sprint_Node (Source_Type (Node));
3092 Sprint_Node (Target_Type (Node));
3096 Write_Indent_Str_Sloc ("when ");
3097 Sprint_Bar_List (Discrete_Choices (Node));
3099 Sprint_Node (Component_List (Node));
3101 when N_Variant_Part =>
3103 Write_Indent_Str_Sloc ("case ");
3104 Sprint_Node (Name (Node));
3106 Sprint_Indented_List (Variants (Node));
3107 Write_Indent_Str ("end case");
3110 when N_With_Clause =>
3112 -- Special test, if we are dumping the original tree only,
3113 -- then we want to eliminate the bogus with clauses that
3114 -- correspond to the non-existent children of Text_IO.
3116 if Dump_Original_Only
3117 and then Is_Text_IO_Kludge_Unit (Name (Node))
3121 -- Normal case, output the with clause
3124 if First_Name (Node) or else not Dump_Original_Only then
3126 -- Ada 2005 (AI-50217): Print limited with_clauses
3128 if Private_Present (Node) and Limited_Present (Node) then
3129 Write_Indent_Str ("limited private with ");
3131 elsif Private_Present (Node) then
3132 Write_Indent_Str ("private with ");
3134 elsif Limited_Present (Node) then
3135 Write_Indent_Str ("limited with ");
3138 Write_Indent_Str ("with ");
3145 Sprint_Node_Sloc (Name (Node));
3147 if Last_Name (Node) or else not Dump_Original_Only then
3153 if Has_Aspects (Node) then
3154 Sprint_Aspect_Specifications (Node);
3157 if Nkind (Node) in N_Subexpr
3158 and then Do_Range_Check (Node)
3163 for J in 1 .. Paren_Count (Node) loop
3167 Dump_Node := Save_Dump_Node;
3168 end Sprint_Node_Actual;
3170 ----------------------
3171 -- Sprint_Node_List --
3172 ----------------------
3174 procedure Sprint_Node_List (List : List_Id) is
3178 if Is_Non_Empty_List (List) then
3179 Node := First (List);
3184 exit when Node = Empty;
3187 end Sprint_Node_List;
3189 ----------------------
3190 -- Sprint_Node_Sloc --
3191 ----------------------
3193 procedure Sprint_Node_Sloc (Node : Node_Id) is
3197 if Debug_Generated_Code and then Present (Dump_Node) then
3198 Set_Sloc (Dump_Node, Sloc (Node));
3201 end Sprint_Node_Sloc;
3203 ---------------------
3204 -- Sprint_Opt_Node --
3205 ---------------------
3207 procedure Sprint_Opt_Node (Node : Node_Id) is
3209 if Present (Node) then
3213 end Sprint_Opt_Node;
3215 --------------------------
3216 -- Sprint_Opt_Node_List --
3217 --------------------------
3219 procedure Sprint_Opt_Node_List (List : List_Id) is
3221 if Present (List) then
3222 Sprint_Node_List (List);
3224 end Sprint_Opt_Node_List;
3226 ---------------------------------
3227 -- Sprint_Opt_Paren_Comma_List --
3228 ---------------------------------
3230 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
3232 if Is_Non_Empty_List (List) then
3234 Sprint_Paren_Comma_List (List);
3236 end Sprint_Opt_Paren_Comma_List;
3238 -----------------------------
3239 -- Sprint_Paren_Comma_List --
3240 -----------------------------
3242 procedure Sprint_Paren_Comma_List (List : List_Id) is
3244 Node_Exists : Boolean := False;
3248 if Is_Non_Empty_List (List) then
3250 if Dump_Original_Only then
3252 while Present (N) loop
3253 if not Is_Rewrite_Insertion (N) then
3254 Node_Exists := True;
3261 if not Node_Exists then
3266 Write_Str_With_Col_Check ("(");
3267 Sprint_Comma_List (List);
3270 end Sprint_Paren_Comma_List;
3272 ----------------------
3273 -- Sprint_Right_Opnd --
3274 ----------------------
3276 procedure Sprint_Right_Opnd (N : Node_Id) is
3277 Opnd : constant Node_Id := Right_Opnd (N);
3280 if Paren_Count (Opnd) /= 0
3281 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
3290 end Sprint_Right_Opnd;
3296 procedure Update_Itype (Node : Node_Id) is
3298 if Present (Etype (Node))
3299 and then Is_Itype (Etype (Node))
3300 and then Debug_Generated_Code
3302 Set_Sloc (Etype (Node), Sloc (Node));
3306 ---------------------
3307 -- Write_Char_Sloc --
3308 ---------------------
3310 procedure Write_Char_Sloc (C : Character) is
3312 if Debug_Generated_Code and then C /= ' ' then
3317 end Write_Char_Sloc;
3319 --------------------------------
3320 -- Write_Condition_And_Reason --
3321 --------------------------------
3323 procedure Write_Condition_And_Reason (Node : Node_Id) is
3324 Cond : constant Node_Id := Condition (Node);
3325 Image : constant String := RT_Exception_Code'Image
3326 (RT_Exception_Code'Val
3327 (UI_To_Int (Reason (Node))));
3330 if Present (Cond) then
3332 -- If condition is a single entity, or NOT with a single entity,
3333 -- output all on one line, since it will likely fit just fine.
3335 if Is_Entity_Name (Cond)
3336 or else (Nkind (Cond) = N_Op_Not
3337 and then Is_Entity_Name (Right_Opnd (Cond)))
3339 Write_Str_With_Col_Check (" when ");
3343 -- Otherwise for more complex condition, multiple lines
3346 Write_Str_With_Col_Check (" when");
3347 Indent := Indent + 2;
3351 Indent := Indent - 2;
3354 -- If no condition, just need a space (all on one line)
3364 for J in 4 .. Image'Last loop
3365 if Image (J) = '_' then
3368 Write_Char (Fold_Lower (Image (J)));
3373 end Write_Condition_And_Reason;
3375 --------------------------------
3376 -- Write_Corresponding_Source --
3377 --------------------------------
3379 procedure Write_Corresponding_Source (S : String) is
3381 Src : Source_Buffer_Ptr;
3384 -- Ignore if not in dump source text mode, or if in freeze actions
3386 if Dump_Source_Text and then Freeze_Indent = 0 then
3388 -- Ignore null string
3394 -- Ignore space or semicolon at end of given string
3396 if S (S'Last) = ' ' or else S (S'Last) = ';' then
3397 Write_Corresponding_Source (S (S'First .. S'Last - 1));
3401 -- Loop to look at next lines not yet printed in source file
3404 Last_Line_Printed + 1 .. Last_Source_Line (Current_Source_File)
3406 Src := Source_Text (Current_Source_File);
3407 Loc := Line_Start (L, Current_Source_File);
3409 -- If comment, keep looking
3411 if Src (Loc .. Loc + 1) = "--" then
3414 -- Search to first non-blank
3417 while Src (Loc) not in Line_Terminator loop
3421 if Src (Loc) /= ' ' and then Src (Loc) /= ASCII.HT then
3423 -- Loop through characters in string to see if we match
3425 for J in S'Range loop
3427 -- If mismatch, then not the case we are looking for
3429 if Src (Loc) /= S (J) then
3436 -- If we fall through, string matched, if white space or
3437 -- semicolon after the matched string, this is the case
3438 -- we are looking for.
3440 if Src (Loc) in Line_Terminator
3441 or else Src (Loc) = ' '
3442 or else Src (Loc) = ASCII.HT
3443 or else Src (Loc) = ';'
3445 -- So output source lines up to and including this one
3447 Write_Source_Lines (L);
3456 -- Line was all blanks, or a comment line, keep looking
3460 end Write_Corresponding_Source;
3462 -----------------------
3463 -- Write_Discr_Specs --
3464 -----------------------
3466 procedure Write_Discr_Specs (N : Node_Id) is
3471 Specs := Discriminant_Specifications (N);
3473 if Present (Specs) then
3474 Write_Str_With_Col_Check (" (");
3475 Spec := First (Specs);
3480 exit when Spec = Empty;
3482 -- Add semicolon, unless we are printing original tree and the
3483 -- next specification is part of a list (but not the first
3484 -- element of that list)
3486 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3493 end Write_Discr_Specs;
3499 procedure Write_Ekind (E : Entity_Id) is
3500 S : constant String := Entity_Kind'Image (Ekind (E));
3503 Name_Len := S'Length;
3504 Name_Buffer (1 .. Name_Len) := S;
3505 Set_Casing (Mixed_Case);
3506 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3513 procedure Write_Id (N : Node_Id) is
3515 -- Deal with outputting Itype
3517 -- Note: if we are printing the full tree with -gnatds, then we may
3518 -- end up picking up the Associated_Node link from a generic template
3519 -- here which overlaps the Entity field, but as documented, Write_Itype
3520 -- is defended against junk calls.
3522 if Nkind (N) in N_Entity then
3524 elsif Nkind (N) in N_Has_Entity then
3525 Write_Itype (Entity (N));
3528 -- Case of a defining identifier
3530 if Nkind (N) = N_Defining_Identifier then
3532 -- If defining identifier has an interface name (and no
3533 -- address clause), then we output the interface name.
3535 if (Is_Imported (N) or else Is_Exported (N))
3536 and then Present (Interface_Name (N))
3537 and then No (Address_Clause (N))
3539 String_To_Name_Buffer (Strval (Interface_Name (N)));
3540 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3542 -- If no interface name (or inactive because there was
3543 -- an address clause), then just output the Chars name.
3546 Write_Name_With_Col_Check (Chars (N));
3549 -- Case of selector of an expanded name where the expanded name
3550 -- has an associated entity, output this entity. Check that the
3551 -- entity or associated node is of the right kind, see above.
3553 elsif Nkind (Parent (N)) = N_Expanded_Name
3554 and then Selector_Name (Parent (N)) = N
3555 and then Present (Entity_Or_Associated_Node (Parent (N)))
3556 and then Nkind (Entity (Parent (N))) in N_Entity
3558 Write_Id (Entity (Parent (N)));
3560 -- For any other node with an associated entity, output it
3562 elsif Nkind (N) in N_Has_Entity
3563 and then Present (Entity_Or_Associated_Node (N))
3564 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
3566 Write_Id (Entity (N));
3568 -- All other cases, we just print the Chars field
3571 Write_Name_With_Col_Check (Chars (N));
3575 -----------------------
3576 -- Write_Identifiers --
3577 -----------------------
3579 function Write_Identifiers (Node : Node_Id) return Boolean is
3581 Sprint_Node (Defining_Identifier (Node));
3582 Update_Itype (Defining_Identifier (Node));
3584 -- The remainder of the declaration must be printed unless we are
3585 -- printing the original tree and this is not the last identifier
3588 not Dump_Original_Only or else not More_Ids (Node);
3590 end Write_Identifiers;
3592 ------------------------
3593 -- Write_Implicit_Def --
3594 ------------------------
3596 procedure Write_Implicit_Def (E : Entity_Id) is
3601 when E_Array_Subtype =>
3602 Write_Str_With_Col_Check ("subtype ");
3604 Write_Str_With_Col_Check (" is ");
3605 Write_Id (Base_Type (E));
3606 Write_Str_With_Col_Check (" (");
3608 Ind := First_Index (E);
3609 while Present (Ind) loop
3613 if Present (Ind) then
3620 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
3621 Write_Str_With_Col_Check ("subtype ");
3624 Write_Id (Etype (E));
3625 Write_Str_With_Col_Check (" range ");
3626 Sprint_Node (Scalar_Range (E));
3630 Write_Str_With_Col_Check ("type ");
3632 Write_Str_With_Col_Check (" is <");
3637 end Write_Implicit_Def;
3643 procedure Write_Indent is
3644 Loc : constant Source_Ptr := Sloc (Dump_Node);
3647 if Indent_Annull_Flag then
3648 Indent_Annull_Flag := False;
3650 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3651 -- label declarations, since they typically have the sloc of the
3652 -- corresponding label, which really messes up the -gnatL output.
3655 and then Loc > No_Location
3656 and then Nkind (Dump_Node) /= N_Implicit_Label_Declaration
3658 if Get_Source_File_Index (Loc) = Current_Source_File then
3660 (Get_Physical_Line_Number (Sloc (Dump_Node)));
3666 for J in 1 .. Indent loop
3672 ------------------------------
3673 -- Write_Indent_Identifiers --
3674 ------------------------------
3676 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3678 -- We need to start a new line for every node, except in the case
3679 -- where we are printing the original tree and this is not the first
3680 -- defining identifier in the list.
3682 if not Dump_Original_Only or else not Prev_Ids (Node) then
3685 -- If printing original tree and this is not the first defining
3686 -- identifier in the list, then the previous call to this procedure
3687 -- printed only the name, and we add a comma to separate the names.
3693 Sprint_Node (Defining_Identifier (Node));
3695 -- The remainder of the declaration must be printed unless we are
3696 -- printing the original tree and this is not the last identifier
3699 not Dump_Original_Only or else not More_Ids (Node);
3700 end Write_Indent_Identifiers;
3702 -----------------------------------
3703 -- Write_Indent_Identifiers_Sloc --
3704 -----------------------------------
3706 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3708 -- We need to start a new line for every node, except in the case
3709 -- where we are printing the original tree and this is not the first
3710 -- defining identifier in the list.
3712 if not Dump_Original_Only or else not Prev_Ids (Node) then
3715 -- If printing original tree and this is not the first defining
3716 -- identifier in the list, then the previous call to this procedure
3717 -- printed only the name, and we add a comma to separate the names.
3724 Sprint_Node (Defining_Identifier (Node));
3726 -- The remainder of the declaration must be printed unless we are
3727 -- printing the original tree and this is not the last identifier
3729 return not Dump_Original_Only or else not More_Ids (Node);
3730 end Write_Indent_Identifiers_Sloc;
3732 ----------------------
3733 -- Write_Indent_Str --
3734 ----------------------
3736 procedure Write_Indent_Str (S : String) is
3738 Write_Corresponding_Source (S);
3741 end Write_Indent_Str;
3743 ---------------------------
3744 -- Write_Indent_Str_Sloc --
3745 ---------------------------
3747 procedure Write_Indent_Str_Sloc (S : String) is
3749 Write_Corresponding_Source (S);
3752 end Write_Indent_Str_Sloc;
3758 procedure Write_Itype (Typ : Entity_Id) is
3760 procedure Write_Header (T : Boolean := True);
3761 -- Write type if T is True, subtype if T is false
3767 procedure Write_Header (T : Boolean := True) is
3770 Write_Str ("[type ");
3772 Write_Str ("[subtype ");
3775 Write_Name_With_Col_Check (Chars (Typ));
3779 -- Start of processing for Write_Itype
3782 if Nkind (Typ) in N_Entity
3783 and then Is_Itype (Typ)
3784 and then not Itype_Printed (Typ)
3786 -- Itype to be printed
3789 B : constant Node_Id := Etype (Typ);
3791 P : constant Node_Id := Parent (Typ);
3793 S : constant Saved_Output_Buffer := Save_Output_Buffer;
3794 -- Save current output buffer
3796 Old_Sloc : Source_Ptr;
3797 -- Save sloc of related node, so it is not modified when
3798 -- printing with -gnatD.
3801 -- Write indentation at start of line
3803 for J in 1 .. Indent loop
3807 -- If we have a constructed declaration for the itype, print it
3810 and then Nkind (P) in N_Declaration
3811 and then Defining_Entity (P) = Typ
3813 -- We must set Itype_Printed true before the recursive call to
3814 -- print the node, otherwise we get an infinite recursion!
3816 Set_Itype_Printed (Typ, True);
3818 -- Write the declaration enclosed in [], avoiding new line
3819 -- at start of declaration, and semicolon at end.
3821 -- Note: The itype may be imported from another unit, in which
3822 -- case we do not want to modify the Sloc of the declaration.
3823 -- Otherwise the itype may appear to be in the current unit,
3824 -- and the back-end will reject a reference out of scope.
3827 Indent_Annull_Flag := True;
3828 Old_Sloc := Sloc (P);
3830 Set_Sloc (P, Old_Sloc);
3831 Write_Erase_Char (';');
3833 -- If no constructed declaration, then we have to concoct the
3834 -- source corresponding to the type entity that we have at hand.
3839 -- Access types and subtypes
3842 Write_Header (Ekind (Typ) = E_Access_Type);
3844 if Can_Never_Be_Null (Typ) then
3845 Write_Str ("not null ");
3848 Write_Str ("access ");
3850 if Is_Access_Constant (Typ) then
3851 Write_Str ("constant ");
3854 Write_Id (Directly_Designated_Type (Typ));
3856 -- Array types and string types
3858 when E_Array_Type | E_String_Type =>
3860 Write_Str ("array (");
3862 X := First_Index (Typ);
3866 if not Is_Constrained (Typ) then
3867 Write_Str (" range <>");
3875 Write_Str (") of ");
3876 X := Component_Type (Typ);
3878 -- Preserve sloc of component type, which is defined
3879 -- elsewhere than the itype (see comment above).
3881 Old_Sloc := Sloc (X);
3883 Set_Sloc (X, Old_Sloc);
3885 -- Array subtypes and string subtypes.
3886 -- Preserve Sloc of index subtypes, as above.
3888 when E_Array_Subtype | E_String_Subtype =>
3889 Write_Header (False);
3890 Write_Id (Etype (Typ));
3893 X := First_Index (Typ);
3895 Old_Sloc := Sloc (X);
3897 Set_Sloc (X, Old_Sloc);
3905 -- Signed integer types, and modular integer subtypes,
3906 -- and also enumeration subtypes.
3908 when E_Signed_Integer_Type |
3909 E_Signed_Integer_Subtype |
3910 E_Modular_Integer_Subtype |
3911 E_Enumeration_Subtype =>
3913 Write_Header (Ekind (Typ) = E_Signed_Integer_Type);
3915 if Ekind (Typ) = E_Signed_Integer_Type then
3921 -- Print bounds if different from base type
3924 L : constant Node_Id := Type_Low_Bound (Typ);
3925 H : constant Node_Id := Type_High_Bound (Typ);
3930 -- B can either be a scalar type, in which case the
3931 -- declaration of Typ may constrain it with different
3932 -- bounds, or a private type, in which case we know
3933 -- that the declaration of Typ cannot have a scalar
3936 if Is_Scalar_Type (B) then
3937 LE := Type_Low_Bound (B);
3938 HE := Type_High_Bound (B);
3946 and then Nkind (L) = N_Integer_Literal
3947 and then Nkind (H) = N_Integer_Literal
3948 and then Nkind (LE) = N_Integer_Literal
3949 and then Nkind (HE) = N_Integer_Literal
3950 and then UI_Eq (Intval (L), Intval (LE))
3951 and then UI_Eq (Intval (H), Intval (HE)))
3956 Write_Str (" range ");
3957 Sprint_Node (Type_Low_Bound (Typ));
3959 Sprint_Node (Type_High_Bound (Typ));
3963 -- Modular integer types
3965 when E_Modular_Integer_Type =>
3967 Write_Str (" mod ");
3968 Write_Uint_With_Col_Check (Modulus (Typ), Auto);
3970 -- Floating point types and subtypes
3972 when E_Floating_Point_Type |
3973 E_Floating_Point_Subtype =>
3975 Write_Header (Ekind (Typ) = E_Floating_Point_Type);
3977 if Ekind (Typ) = E_Floating_Point_Type then
3981 Write_Id (Etype (Typ));
3983 if Digits_Value (Typ) /= Digits_Value (Etype (Typ)) then
3984 Write_Str (" digits ");
3985 Write_Uint_With_Col_Check
3986 (Digits_Value (Typ), Decimal);
3989 -- Print bounds if not different from base type
3992 L : constant Node_Id := Type_Low_Bound (Typ);
3993 H : constant Node_Id := Type_High_Bound (Typ);
3994 LE : constant Node_Id := Type_Low_Bound (B);
3995 HE : constant Node_Id := Type_High_Bound (B);
3998 if Nkind (L) = N_Real_Literal
3999 and then Nkind (H) = N_Real_Literal
4000 and then Nkind (LE) = N_Real_Literal
4001 and then Nkind (HE) = N_Real_Literal
4002 and then UR_Eq (Realval (L), Realval (LE))
4003 and then UR_Eq (Realval (H), Realval (HE))
4008 Write_Str (" range ");
4009 Sprint_Node (Type_Low_Bound (Typ));
4011 Sprint_Node (Type_High_Bound (Typ));
4017 when E_Record_Subtype =>
4018 Write_Header (False);
4019 Write_Str ("record");
4025 C := First_Entity (Typ);
4026 while Present (C) loop
4030 Write_Id (Etype (C));
4036 Write_Indent_Str (" end record");
4040 when E_Class_Wide_Type |
4041 E_Class_Wide_Subtype =>
4043 Write_Name_With_Col_Check (Chars (Etype (Typ)));
4044 Write_Str ("'Class");
4048 when E_Subprogram_Type =>
4051 if Etype (Typ) = Standard_Void_Type then
4052 Write_Str ("procedure");
4054 Write_Str ("function");
4057 if Present (First_Entity (Typ)) then
4064 Param := First_Entity (Typ);
4069 if Ekind (Param) = E_In_Out_Parameter then
4070 Write_Str ("in out ");
4071 elsif Ekind (Param) = E_Out_Parameter then
4075 Write_Id (Etype (Param));
4076 Next_Entity (Param);
4077 exit when No (Param);
4085 if Etype (Typ) /= Standard_Void_Type then
4086 Write_Str (" return ");
4087 Write_Id (Etype (Typ));
4090 when E_String_Literal_Subtype =>
4092 LB : constant Uint :=
4093 Expr_Value (String_Literal_Low_Bound (Typ));
4094 Len : constant Uint :=
4095 String_Literal_Length (Typ);
4097 Write_Str ("String (");
4098 Write_Int (UI_To_Int (LB));
4100 Write_Int (UI_To_Int (LB + Len) - 1);
4104 -- For all other Itypes, print ??? (fill in later)
4107 Write_Header (True);
4113 -- Add terminating bracket and restore output buffer
4117 Restore_Output_Buffer (S);
4120 Set_Itype_Printed (Typ);
4124 -------------------------------
4125 -- Write_Name_With_Col_Check --
4126 -------------------------------
4128 procedure Write_Name_With_Col_Check (N : Name_Id) is
4134 Get_Name_String (N);
4136 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4137 -- upper case letter, nnn is one or more digits and b is a lower case
4138 -- letter by C...b, so that listings do not depend on serial numbers.
4140 if Debug_Flag_II then
4142 while J < Name_Len - 1 loop
4143 if Name_Buffer (J) in 'A' .. 'Z'
4144 and then Name_Buffer (J + 1) in '0' .. '9'
4147 while K < Name_Len loop
4148 exit when Name_Buffer (K) not in '0' .. '9';
4152 if Name_Buffer (K) in 'a' .. 'z' then
4153 L := Name_Len - K + 1;
4155 Name_Buffer (J + 4 .. J + L + 3) :=
4156 Name_Buffer (K .. Name_Len);
4157 Name_Buffer (J + 1 .. J + 3) := "...";
4158 Name_Len := J + L + 3;
4171 -- Fall through for normal case
4173 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
4174 end Write_Name_With_Col_Check;
4176 ------------------------------------
4177 -- Write_Name_With_Col_Check_Sloc --
4178 ------------------------------------
4180 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
4182 Get_Name_String (N);
4183 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
4184 end Write_Name_With_Col_Check_Sloc;
4186 --------------------
4187 -- Write_Operator --
4188 --------------------
4190 procedure Write_Operator (N : Node_Id; S : String) is
4191 F : Natural := S'First;
4192 T : Natural := S'Last;
4195 -- If no overflow check, just write string out, and we are done
4197 if not Do_Overflow_Check (N) then
4200 -- If overflow check, we want to surround the operator with curly
4201 -- brackets, but not include spaces within the brackets.
4214 Write_Str_Sloc (S (F .. T));
4217 if S (S'Last) = ' ' then
4223 -----------------------
4224 -- Write_Param_Specs --
4225 -----------------------
4227 procedure Write_Param_Specs (N : Node_Id) is
4233 Specs := Parameter_Specifications (N);
4235 if Is_Non_Empty_List (Specs) then
4236 Write_Str_With_Col_Check (" (");
4237 Spec := First (Specs);
4241 Formal := Defining_Identifier (Spec);
4243 exit when Spec = Empty;
4245 -- Add semicolon, unless we are printing original tree and the
4246 -- next specification is part of a list (but not the first element
4249 if not Dump_Original_Only or else not Prev_Ids (Spec) then
4254 -- Write out any extra formals
4256 while Present (Extra_Formal (Formal)) loop
4257 Formal := Extra_Formal (Formal);
4259 Write_Name_With_Col_Check (Chars (Formal));
4261 Write_Name_With_Col_Check (Chars (Etype (Formal)));
4266 end Write_Param_Specs;
4268 -----------------------
4269 -- Write_Rewrite_Str --
4270 -----------------------
4272 procedure Write_Rewrite_Str (S : String) is
4274 if not Dump_Generated_Only then
4275 if S'Length = 3 and then S = ">>>" then
4278 Write_Str_With_Col_Check (S);
4281 end Write_Rewrite_Str;
4283 -----------------------
4284 -- Write_Source_Line --
4285 -----------------------
4287 procedure Write_Source_Line (L : Physical_Line_Number) is
4289 Src : Source_Buffer_Ptr;
4293 if Dump_Source_Text then
4294 Src := Source_Text (Current_Source_File);
4295 Loc := Line_Start (L, Current_Source_File);
4298 -- See if line is a comment line, if not, and if not line one,
4299 -- precede with blank line.
4302 while Src (Scn) = ' ' or else Src (Scn) = ASCII.HT loop
4306 if (Src (Scn) in Line_Terminator
4307 or else Src (Scn .. Scn + 1) /= "--")
4313 -- Now write the source text of the line
4316 Write_Int (Int (L));
4319 while Src (Loc) not in Line_Terminator loop
4320 Write_Char (Src (Loc));
4324 end Write_Source_Line;
4326 ------------------------
4327 -- Write_Source_Lines --
4328 ------------------------
4330 procedure Write_Source_Lines (L : Physical_Line_Number) is
4332 while Last_Line_Printed < L loop
4333 Last_Line_Printed := Last_Line_Printed + 1;
4334 Write_Source_Line (Last_Line_Printed);
4336 end Write_Source_Lines;
4338 --------------------
4339 -- Write_Str_Sloc --
4340 --------------------
4342 procedure Write_Str_Sloc (S : String) is
4344 for J in S'Range loop
4345 Write_Char_Sloc (S (J));
4349 ------------------------------
4350 -- Write_Str_With_Col_Check --
4351 ------------------------------
4353 procedure Write_Str_With_Col_Check (S : String) is
4355 if Int (S'Last) + Column > Sprint_Line_Limit then
4356 Write_Indent_Str (" ");
4358 if S (S'First) = ' ' then
4359 Write_Str (S (S'First + 1 .. S'Last));
4367 end Write_Str_With_Col_Check;
4369 -----------------------------------
4370 -- Write_Str_With_Col_Check_Sloc --
4371 -----------------------------------
4373 procedure Write_Str_With_Col_Check_Sloc (S : String) is
4375 if Int (S'Last) + Column > Sprint_Line_Limit then
4376 Write_Indent_Str (" ");
4378 if S (S'First) = ' ' then
4379 Write_Str_Sloc (S (S'First + 1 .. S'Last));
4387 end Write_Str_With_Col_Check_Sloc;
4389 ---------------------------
4390 -- Write_Subprogram_Name --
4391 ---------------------------
4393 procedure Write_Subprogram_Name (N : Node_Id) is
4395 if not Comes_From_Source (N)
4396 and then Is_Entity_Name (N)
4399 Ent : constant Entity_Id := Entity (N);
4401 if not In_Extended_Main_Source_Unit (Ent)
4403 Is_Predefined_File_Name
4404 (Unit_File_Name (Get_Source_Unit (Ent)))
4406 -- Run-time routine name, output name with a preceding dollar
4407 -- making sure that we do not get a line split between them.
4409 Col_Check (Length_Of_Name (Chars (Ent)) + 1);
4411 Write_Name (Chars (Ent));
4417 -- Normal case, not a run-time routine name
4420 end Write_Subprogram_Name;
4422 -------------------------------
4423 -- Write_Uint_With_Col_Check --
4424 -------------------------------
4426 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format) is
4428 Col_Check (UI_Decimal_Digits_Hi (U));
4429 UI_Write (U, Format);
4430 end Write_Uint_With_Col_Check;
4432 ------------------------------------
4433 -- Write_Uint_With_Col_Check_Sloc --
4434 ------------------------------------
4436 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
4438 Col_Check (UI_Decimal_Digits_Hi (U));
4440 UI_Write (U, Format);
4441 end Write_Uint_With_Col_Check_Sloc;
4443 -------------------------------------
4444 -- Write_Ureal_With_Col_Check_Sloc --
4445 -------------------------------------
4447 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
4448 D : constant Uint := Denominator (U);
4449 N : constant Uint := Numerator (U);
4451 Col_Check (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
4453 UR_Write (U, Brackets => True);
4454 end Write_Ureal_With_Col_Check_Sloc;