PR target/16201
[official-gcc.git] / gcc / ada / sprint.adb
blob0d814441c49dad4a8db1256dee9642149c209aca
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S P R I N T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 with Atree; use Atree;
28 with Casing; use Casing;
29 with Csets; use Csets;
30 with Debug; use Debug;
31 with Einfo; use Einfo;
32 with Lib; use Lib;
33 with Namet; use Namet;
34 with Nlists; use Nlists;
35 with Opt; use Opt;
36 with Output; use Output;
37 with Rtsfind; use Rtsfind;
38 with Sinfo; use Sinfo;
39 with Sinput; use Sinput;
40 with Sinput.D; use Sinput.D;
41 with Snames; use Snames;
42 with Stand; use Stand;
43 with Stringt; use Stringt;
44 with Uintp; use Uintp;
45 with Uname; use Uname;
46 with Urealp; use Urealp;
48 package body Sprint is
50 Debug_Node : Node_Id := Empty;
51 -- If we are in Debug_Generated_Code mode, then this location is set
52 -- to the current node requiring Sloc fixup, until Set_Debug_Sloc is
53 -- called to set the proper value. The call clears it back to Empty.
55 Debug_Sloc : Source_Ptr;
56 -- Sloc of first byte of line currently being written if we are
57 -- generating a source debug file.
59 Dump_Original_Only : Boolean;
60 -- Set True if the -gnatdo (dump original tree) flag is set
62 Dump_Generated_Only : Boolean;
63 -- Set True if the -gnatG (dump generated tree) debug flag is set
64 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
66 Dump_Freeze_Null : Boolean;
67 -- Set True if freeze nodes and non-source null statements output
69 Indent : Int := 0;
70 -- Number of columns for current line output indentation
72 Indent_Annull_Flag : Boolean := False;
73 -- Set True if subsequent Write_Indent call to be ignored, gets reset
74 -- by this call, so it is only active to suppress a single indent call.
76 Line_Limit : constant := 72;
77 -- Limit value for chopping long lines
79 Freeze_Indent : Int := 0;
80 -- Keep track of freeze indent level (controls blank lines before
81 -- procedures within expression freeze actions)
83 -------------------------------
84 -- Operator Precedence Table --
85 -------------------------------
87 -- This table is used to decide whether a subexpression needs to be
88 -- parenthesized. The rule is that if an operand of an operator (which
89 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
90 -- with a lower precedence than the operator (or equal precedence if
91 -- appearing as the right operand), then parentheses are required.
93 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
94 (N_Op_And => 1,
95 N_Op_Or => 1,
96 N_Op_Xor => 1,
97 N_And_Then => 1,
98 N_Or_Else => 1,
100 N_In => 2,
101 N_Not_In => 2,
102 N_Op_Eq => 2,
103 N_Op_Ge => 2,
104 N_Op_Gt => 2,
105 N_Op_Le => 2,
106 N_Op_Lt => 2,
107 N_Op_Ne => 2,
109 N_Op_Add => 3,
110 N_Op_Concat => 3,
111 N_Op_Subtract => 3,
112 N_Op_Plus => 3,
113 N_Op_Minus => 3,
115 N_Op_Divide => 4,
116 N_Op_Mod => 4,
117 N_Op_Rem => 4,
118 N_Op_Multiply => 4,
120 N_Op_Expon => 5,
121 N_Op_Abs => 5,
122 N_Op_Not => 5,
124 others => 6);
126 procedure Sprint_Left_Opnd (N : Node_Id);
127 -- Print left operand of operator, parenthesizing if necessary
129 procedure Sprint_Right_Opnd (N : Node_Id);
130 -- Print right operand of operator, parenthesizing if necessary
132 -----------------------
133 -- Local Subprograms --
134 -----------------------
136 procedure Col_Check (N : Nat);
137 -- Check that at least N characters remain on current line, and if not,
138 -- then start an extra line with two characters extra indentation for
139 -- continuing text on the next line.
141 procedure Indent_Annull;
142 -- Causes following call to Write_Indent to be ignored. This is used when
143 -- a higher level node wants to stop a lower level node from starting a
144 -- new line, when it would otherwise be inclined to do so (e.g. the case
145 -- of an accept statement called from an accept alternative with a guard)
147 procedure Indent_Begin;
148 -- Increase indentation level
150 procedure Indent_End;
151 -- Decrease indentation level
153 procedure Print_Debug_Line (S : String);
154 -- Used to print output lines in Debug_Generated_Code mode (this is used
155 -- as the argument for a call to Set_Special_Output in package Output).
157 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
158 -- Given a divide, multiplication or division node, check the flags
159 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
160 -- appropriate special syntax characters (# and @).
162 procedure Set_Debug_Sloc;
163 -- If Debug_Node is non-empty, this routine sets the appropriate value
164 -- in its Sloc field, from the current location in the debug source file
165 -- that is currently being written. Note that Debug_Node is always empty
166 -- if a debug source file is not being written.
168 procedure Sprint_Bar_List (List : List_Id);
169 -- Print the given list with items separated by vertical bars
171 procedure Sprint_Node_Actual (Node : Node_Id);
172 -- This routine prints its node argument. It is a lower level routine than
173 -- Sprint_Node, in that it does not bother about rewritten trees.
175 procedure Sprint_Node_Sloc (Node : Node_Id);
176 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
177 -- sets the Sloc of the current debug node to be a copy of the Sloc
178 -- of the sprinted node Node. Note that this is done after printing
179 -- Node, so that the Sloc is the proper updated value for the debug file.
181 procedure Write_Char_Sloc (C : Character);
182 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
183 -- called to ensure that the current node has a proper Sloc set.
185 procedure Write_Condition_And_Reason (Node : Node_Id);
186 -- Write Condition and Reason codes of Raise_xxx_Error node
188 procedure Write_Discr_Specs (N : Node_Id);
189 -- Ouput discriminant specification for node, which is any of the type
190 -- declarations that can have discriminants.
192 procedure Write_Ekind (E : Entity_Id);
193 -- Write the String corresponding to the Ekind without "E_".
195 procedure Write_Id (N : Node_Id);
196 -- N is a node with a Chars field. This procedure writes the name that
197 -- will be used in the generated code associated with the name. For a
198 -- node with no associated entity, this is simply the Chars field. For
199 -- the case where there is an entity associated with the node, we print
200 -- the name associated with the entity (since it may have been encoded).
201 -- One other special case is that an entity has an active external name
202 -- (i.e. an external name present with no address clause), then this
203 -- external name is output.
205 function Write_Identifiers (Node : Node_Id) return Boolean;
206 -- Handle node where the grammar has a list of defining identifiers, but
207 -- the tree has a separate declaration for each identifier. Handles the
208 -- printing of the defining identifier, and returns True if the type and
209 -- initialization information is to be printed, False if it is to be
210 -- skipped (the latter case happens when printing defining identifiers
211 -- other than the first in the original tree output case).
213 procedure Write_Implicit_Def (E : Entity_Id);
214 pragma Warnings (Off, Write_Implicit_Def);
215 -- Write the definition of the implicit type E according to its Ekind
216 -- For now a debugging procedure, but might be used in the future.
218 procedure Write_Indent;
219 -- Start a new line and write indentation spacing
221 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
222 -- Like Write_Identifiers except that each new printed declaration
223 -- is at the start of a new line.
225 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
226 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
227 -- mode, the Sloc of the current debug node is set to point ot the
228 -- first output identifier.
230 procedure Write_Indent_Str (S : String);
231 -- Start a new line and write indent spacing followed by given string
233 procedure Write_Indent_Str_Sloc (S : String);
234 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
235 -- the Sloc of the current node is set to the first non-blank character
236 -- in the string S.
238 procedure Write_Name_With_Col_Check (N : Name_Id);
239 -- Write name (using Write_Name) with initial column check, and possible
240 -- initial Write_Indent (to get new line) if current line is too full.
242 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
243 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
244 -- mode, sets Sloc of current debug node to first character of name.
246 procedure Write_Operator (N : Node_Id; S : String);
247 -- Like Write_Str_Sloc, used for operators, encloses the string in
248 -- characters {} if the Do_Overflow flag is set on the node N.
250 procedure Write_Param_Specs (N : Node_Id);
251 -- Output parameter specifications for node (which is either a function
252 -- or procedure specification with a Parameter_Specifications field)
254 procedure Write_Rewrite_Str (S : String);
255 -- Writes out a string (typically containing <<< or >>>}) for a node
256 -- created by rewriting the tree. Suppressed if we are outputting the
257 -- generated code only, since in this case we don't specially mark nodes
258 -- created by rewriting).
260 procedure Write_Str_Sloc (S : String);
261 -- Like Write_Str, but sets debug Sloc of current debug node to first
262 -- non-blank character if a current debug node is active.
264 procedure Write_Str_With_Col_Check (S : String);
265 -- Write string (using Write_Str) with initial column check, and possible
266 -- initial Write_Indent (to get new line) if current line is too full.
268 procedure Write_Str_With_Col_Check_Sloc (S : String);
269 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
270 -- node to first non-blank character if a current debug node is active.
272 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
273 -- Write Uint (using UI_Write) with initial column check, and possible
274 -- initial Write_Indent (to get new line) if current line is too full.
275 -- The format parameter determines the output format (see UI_Write).
276 -- In addition, in Debug_Generated_Code mode, sets the current node
277 -- Sloc to the first character of the output value.
279 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
280 -- Write Ureal (using same output format as UR_Write) with column checks
281 -- and a possible initial Write_Indent (to get new line) if current line
282 -- is too full. In addition, in Debug_Generated_Code mode, sets the
283 -- current node Sloc to the first character of the output value.
285 ---------------
286 -- Col_Check --
287 ---------------
289 procedure Col_Check (N : Nat) is
290 begin
291 if N + Column > Line_Limit then
292 Write_Indent_Str (" ");
293 end if;
294 end Col_Check;
296 -------------------
297 -- Indent_Annull --
298 -------------------
300 procedure Indent_Annull is
301 begin
302 Indent_Annull_Flag := True;
303 end Indent_Annull;
305 ------------------
306 -- Indent_Begin --
307 ------------------
309 procedure Indent_Begin is
310 begin
311 Indent := Indent + 3;
312 end Indent_Begin;
314 ----------------
315 -- Indent_End --
316 ----------------
318 procedure Indent_End is
319 begin
320 Indent := Indent - 3;
321 end Indent_End;
323 --------
324 -- pg --
325 --------
327 procedure pg (Node : Node_Id) is
328 begin
329 Dump_Generated_Only := True;
330 Dump_Original_Only := False;
331 Sprint_Node (Node);
332 Write_Eol;
333 end pg;
335 --------
336 -- po --
337 --------
339 procedure po (Node : Node_Id) is
340 begin
341 Dump_Generated_Only := False;
342 Dump_Original_Only := True;
343 Sprint_Node (Node);
344 Write_Eol;
345 end po;
347 ----------------------
348 -- Print_Debug_Line --
349 ----------------------
351 procedure Print_Debug_Line (S : String) is
352 begin
353 Write_Debug_Line (S, Debug_Sloc);
354 end Print_Debug_Line;
356 ---------------------------
357 -- Process_TFAI_RR_Flags --
358 ---------------------------
360 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
361 begin
362 if Treat_Fixed_As_Integer (Nod) then
363 Write_Char ('#');
364 end if;
366 if Rounded_Result (Nod) then
367 Write_Char ('@');
368 end if;
369 end Process_TFAI_RR_Flags;
371 --------
372 -- ps --
373 --------
375 procedure ps (Node : Node_Id) is
376 begin
377 Dump_Generated_Only := False;
378 Dump_Original_Only := False;
379 Sprint_Node (Node);
380 Write_Eol;
381 end ps;
383 --------------------
384 -- Set_Debug_Sloc --
385 --------------------
387 procedure Set_Debug_Sloc is
388 begin
389 if Present (Debug_Node) then
390 Set_Sloc (Debug_Node, Debug_Sloc + Source_Ptr (Column - 1));
391 Debug_Node := Empty;
392 end if;
393 end Set_Debug_Sloc;
395 -----------------
396 -- Source_Dump --
397 -----------------
399 procedure Source_Dump is
401 procedure Underline;
402 -- Put underline under string we just printed
404 procedure Underline is
405 Col : constant Int := Column;
407 begin
408 Write_Eol;
410 while Col > Column loop
411 Write_Char ('-');
412 end loop;
414 Write_Eol;
415 end Underline;
417 -- Start of processing for Tree_Dump.
419 begin
420 Dump_Generated_Only := Debug_Flag_G or
421 Print_Generated_Code or
422 Debug_Generated_Code;
423 Dump_Original_Only := Debug_Flag_O;
424 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
426 -- Note that we turn off the tree dump flags immediately, before
427 -- starting the dump. This avoids generating two copies of the dump
428 -- if an abort occurs after printing the dump, and more importantly,
429 -- avoids an infinite loop if an abort occurs during the dump.
431 if Debug_Flag_Z then
432 Debug_Flag_Z := False;
433 Write_Eol;
434 Write_Eol;
435 Write_Str ("Source recreated from tree of Standard (spec)");
436 Underline;
437 Sprint_Node (Standard_Package_Node);
438 Write_Eol;
439 Write_Eol;
440 end if;
442 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
443 Debug_Flag_G := False;
444 Debug_Flag_O := False;
445 Debug_Flag_S := False;
447 -- Dump requested units
449 for U in Main_Unit .. Last_Unit loop
451 -- Dump all units if -gnatdf set, otherwise we dump only
452 -- the source files that are in the extended main source.
454 if Debug_Flag_F
455 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
456 then
457 -- If we are generating debug files, setup to write them
459 if Debug_Generated_Code then
460 Set_Special_Output (Print_Debug_Line'Access);
461 Create_Debug_Source (Source_Index (U), Debug_Sloc);
462 Sprint_Node (Cunit (U));
463 Write_Eol;
464 Close_Debug_Source;
465 Set_Special_Output (null);
467 -- Normal output to standard output file
469 else
470 Write_Str ("Source recreated from tree for ");
471 Write_Unit_Name (Unit_Name (U));
472 Underline;
473 Sprint_Node (Cunit (U));
474 Write_Eol;
475 Write_Eol;
476 end if;
477 end if;
478 end loop;
479 end if;
480 end Source_Dump;
482 ---------------------
483 -- Sprint_Bar_List --
484 ---------------------
486 procedure Sprint_Bar_List (List : List_Id) is
487 Node : Node_Id;
489 begin
490 if Is_Non_Empty_List (List) then
491 Node := First (List);
493 loop
494 Sprint_Node (Node);
495 Next (Node);
496 exit when Node = Empty;
497 Write_Str (" | ");
498 end loop;
499 end if;
500 end Sprint_Bar_List;
502 -----------------------
503 -- Sprint_Comma_List --
504 -----------------------
506 procedure Sprint_Comma_List (List : List_Id) is
507 Node : Node_Id;
509 begin
510 if Is_Non_Empty_List (List) then
511 Node := First (List);
513 loop
514 Sprint_Node (Node);
515 Next (Node);
516 exit when Node = Empty;
518 if not Is_Rewrite_Insertion (Node)
519 or else not Dump_Original_Only
520 then
521 Write_Str (", ");
522 end if;
524 end loop;
525 end if;
526 end Sprint_Comma_List;
528 --------------------------
529 -- Sprint_Indented_List --
530 --------------------------
532 procedure Sprint_Indented_List (List : List_Id) is
533 begin
534 Indent_Begin;
535 Sprint_Node_List (List);
536 Indent_End;
537 end Sprint_Indented_List;
539 ---------------------
540 -- Sprint_Left_Opnd --
541 ---------------------
543 procedure Sprint_Left_Opnd (N : Node_Id) is
544 Opnd : constant Node_Id := Left_Opnd (N);
546 begin
547 if Paren_Count (Opnd) /= 0
548 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
549 then
550 Sprint_Node (Opnd);
552 else
553 Write_Char ('(');
554 Sprint_Node (Opnd);
555 Write_Char (')');
556 end if;
557 end Sprint_Left_Opnd;
559 -----------------
560 -- Sprint_Node --
561 -----------------
563 procedure Sprint_Node (Node : Node_Id) is
564 begin
565 if Is_Rewrite_Insertion (Node) then
566 if not Dump_Original_Only then
568 -- For special cases of nodes that always output <<< >>>
569 -- do not duplicate the output at this point.
571 if Nkind (Node) = N_Freeze_Entity
572 or else Nkind (Node) = N_Implicit_Label_Declaration
573 then
574 Sprint_Node_Actual (Node);
576 -- Normal case where <<< >>> may be required
578 else
579 Write_Rewrite_Str ("<<<");
580 Sprint_Node_Actual (Node);
581 Write_Rewrite_Str (">>>");
582 end if;
583 end if;
585 elsif Is_Rewrite_Substitution (Node) then
587 -- Case of dump generated only
589 if Dump_Generated_Only then
590 Sprint_Node_Actual (Node);
592 -- Case of dump original only
594 elsif Dump_Original_Only then
595 Sprint_Node_Actual (Original_Node (Node));
597 -- Case of both being dumped
599 else
600 Sprint_Node_Actual (Original_Node (Node));
601 Write_Rewrite_Str ("<<<");
602 Sprint_Node_Actual (Node);
603 Write_Rewrite_Str (">>>");
604 end if;
606 else
607 Sprint_Node_Actual (Node);
608 end if;
609 end Sprint_Node;
611 ------------------------
612 -- Sprint_Node_Actual --
613 ------------------------
615 procedure Sprint_Node_Actual (Node : Node_Id) is
616 Save_Debug_Node : constant Node_Id := Debug_Node;
618 begin
619 if Node = Empty then
620 return;
621 end if;
623 for J in 1 .. Paren_Count (Node) loop
624 Write_Str_With_Col_Check ("(");
625 end loop;
627 -- Setup node for Sloc fixup if writing a debug source file. Note
628 -- that we take care of any previous node not yet properly set.
630 if Debug_Generated_Code then
631 Debug_Node := Node;
632 end if;
634 if Nkind (Node) in N_Subexpr
635 and then Do_Range_Check (Node)
636 then
637 Write_Str_With_Col_Check ("{");
638 end if;
640 -- Select print circuit based on node kind
642 case Nkind (Node) is
644 when N_Abort_Statement =>
645 Write_Indent_Str_Sloc ("abort ");
646 Sprint_Comma_List (Names (Node));
647 Write_Char (';');
649 when N_Abortable_Part =>
650 Set_Debug_Sloc;
651 Write_Str_Sloc ("abort ");
652 Sprint_Indented_List (Statements (Node));
654 when N_Abstract_Subprogram_Declaration =>
655 Write_Indent;
656 Sprint_Node (Specification (Node));
657 Write_Str_With_Col_Check (" is ");
658 Write_Str_Sloc ("abstract;");
660 when N_Accept_Alternative =>
661 Sprint_Node_List (Pragmas_Before (Node));
663 if Present (Condition (Node)) then
664 Write_Indent_Str ("when ");
665 Sprint_Node (Condition (Node));
666 Write_Str (" => ");
667 Indent_Annull;
668 end if;
670 Sprint_Node_Sloc (Accept_Statement (Node));
671 Sprint_Node_List (Statements (Node));
673 when N_Accept_Statement =>
674 Write_Indent_Str_Sloc ("accept ");
675 Write_Id (Entry_Direct_Name (Node));
677 if Present (Entry_Index (Node)) then
678 Write_Str_With_Col_Check (" (");
679 Sprint_Node (Entry_Index (Node));
680 Write_Char (')');
681 end if;
683 Write_Param_Specs (Node);
685 if Present (Handled_Statement_Sequence (Node)) then
686 Write_Str_With_Col_Check (" do");
687 Sprint_Node (Handled_Statement_Sequence (Node));
688 Write_Indent_Str ("end ");
689 Write_Id (Entry_Direct_Name (Node));
690 end if;
692 Write_Char (';');
694 when N_Access_Definition =>
696 -- Ada 2005 (AI-254)
698 if Present (Access_To_Subprogram_Definition (Node)) then
699 Sprint_Node (Access_To_Subprogram_Definition (Node));
700 else
701 -- Ada 2005 (AI-231)
703 if Null_Exclusion_Present (Node) then
704 Write_Str ("not null ");
705 end if;
707 Write_Str_With_Col_Check_Sloc ("access ");
709 if All_Present (Node) then
710 Write_Str ("all ");
711 elsif Constant_Present (Node) then
712 Write_Str ("constant ");
713 end if;
715 Sprint_Node (Subtype_Mark (Node));
716 end if;
718 when N_Access_Function_Definition =>
720 -- Ada 2005 (AI-231)
722 if Null_Exclusion_Present (Node) then
723 Write_Str ("not null ");
724 end if;
726 Write_Str_With_Col_Check_Sloc ("access ");
728 if Protected_Present (Node) then
729 Write_Str_With_Col_Check ("protected ");
730 end if;
732 Write_Str_With_Col_Check ("function");
733 Write_Param_Specs (Node);
734 Write_Str_With_Col_Check (" return ");
735 Sprint_Node (Subtype_Mark (Node));
737 when N_Access_Procedure_Definition =>
739 -- Ada 2005 (AI-231)
741 if Null_Exclusion_Present (Node) then
742 Write_Str ("not null ");
743 end if;
745 Write_Str_With_Col_Check_Sloc ("access ");
747 if Protected_Present (Node) then
748 Write_Str_With_Col_Check ("protected ");
749 end if;
751 Write_Str_With_Col_Check ("procedure");
752 Write_Param_Specs (Node);
754 when N_Access_To_Object_Definition =>
755 Write_Str_With_Col_Check_Sloc ("access ");
757 if All_Present (Node) then
758 Write_Str_With_Col_Check ("all ");
759 elsif Constant_Present (Node) then
760 Write_Str_With_Col_Check ("constant ");
761 end if;
763 -- Ada 2005 (AI-231)
765 if Null_Exclusion_Present (Node) then
766 Write_Str ("not null ");
767 end if;
769 Sprint_Node (Subtype_Indication (Node));
771 when N_Aggregate =>
772 if Null_Record_Present (Node) then
773 Write_Str_With_Col_Check_Sloc ("(null record)");
775 else
776 Write_Str_With_Col_Check_Sloc ("(");
778 if Present (Expressions (Node)) then
779 Sprint_Comma_List (Expressions (Node));
781 if Present (Component_Associations (Node)) then
782 Write_Str (", ");
783 end if;
784 end if;
786 if Present (Component_Associations (Node)) then
787 Indent_Begin;
789 declare
790 Nd : Node_Id;
792 begin
793 Nd := First (Component_Associations (Node));
795 loop
796 Write_Indent;
797 Sprint_Node (Nd);
798 Next (Nd);
799 exit when No (Nd);
801 if not Is_Rewrite_Insertion (Nd)
802 or else not Dump_Original_Only
803 then
804 Write_Str (", ");
805 end if;
806 end loop;
807 end;
809 Indent_End;
810 end if;
812 Write_Char (')');
813 end if;
815 when N_Allocator =>
816 Write_Str_With_Col_Check_Sloc ("new ");
818 -- Ada 2005 (AI-231)
820 if Null_Exclusion_Present (Node) then
821 Write_Str ("not null ");
822 end if;
824 Sprint_Node (Expression (Node));
826 if Present (Storage_Pool (Node)) then
827 Write_Str_With_Col_Check ("[storage_pool = ");
828 Sprint_Node (Storage_Pool (Node));
829 Write_Char (']');
830 end if;
832 when N_And_Then =>
833 Sprint_Left_Opnd (Node);
834 Write_Str_Sloc (" and then ");
835 Sprint_Right_Opnd (Node);
837 when N_At_Clause =>
838 Write_Indent_Str_Sloc ("for ");
839 Write_Id (Identifier (Node));
840 Write_Str_With_Col_Check (" use at ");
841 Sprint_Node (Expression (Node));
842 Write_Char (';');
844 when N_Assignment_Statement =>
845 Write_Indent;
846 Sprint_Node (Name (Node));
847 Write_Str_Sloc (" := ");
848 Sprint_Node (Expression (Node));
849 Write_Char (';');
851 when N_Asynchronous_Select =>
852 Write_Indent_Str_Sloc ("select");
853 Indent_Begin;
854 Sprint_Node (Triggering_Alternative (Node));
855 Indent_End;
857 -- Note: let the printing of Abortable_Part handle outputting
858 -- the ABORT keyword, so that the Slco can be set correctly.
860 Write_Indent_Str ("then ");
861 Sprint_Node (Abortable_Part (Node));
862 Write_Indent_Str ("end select;");
864 when N_Attribute_Definition_Clause =>
865 Write_Indent_Str_Sloc ("for ");
866 Sprint_Node (Name (Node));
867 Write_Char (''');
868 Write_Name_With_Col_Check (Chars (Node));
869 Write_Str_With_Col_Check (" use ");
870 Sprint_Node (Expression (Node));
871 Write_Char (';');
873 when N_Attribute_Reference =>
874 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
875 Write_Indent;
876 end if;
878 Sprint_Node (Prefix (Node));
879 Write_Char_Sloc (''');
880 Write_Name_With_Col_Check (Attribute_Name (Node));
881 Sprint_Paren_Comma_List (Expressions (Node));
883 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
884 Write_Char (';');
885 end if;
887 when N_Block_Statement =>
888 Write_Indent;
890 if Present (Identifier (Node))
891 and then (not Has_Created_Identifier (Node)
892 or else not Dump_Original_Only)
893 then
894 Write_Rewrite_Str ("<<<");
895 Write_Id (Identifier (Node));
896 Write_Str (" : ");
897 Write_Rewrite_Str (">>>");
898 end if;
900 if Present (Declarations (Node)) then
901 Write_Str_With_Col_Check_Sloc ("declare");
902 Sprint_Indented_List (Declarations (Node));
903 Write_Indent;
904 end if;
906 Write_Str_With_Col_Check_Sloc ("begin");
907 Sprint_Node (Handled_Statement_Sequence (Node));
908 Write_Indent_Str ("end");
910 if Present (Identifier (Node))
911 and then (not Has_Created_Identifier (Node)
912 or else not Dump_Original_Only)
913 then
914 Write_Rewrite_Str ("<<<");
915 Write_Char (' ');
916 Write_Id (Identifier (Node));
917 Write_Rewrite_Str (">>>");
918 end if;
920 Write_Char (';');
922 when N_Case_Statement =>
923 Write_Indent_Str_Sloc ("case ");
924 Sprint_Node (Expression (Node));
925 Write_Str (" is");
926 Sprint_Indented_List (Alternatives (Node));
927 Write_Indent_Str ("end case;");
929 when N_Case_Statement_Alternative =>
930 Write_Indent_Str_Sloc ("when ");
931 Sprint_Bar_List (Discrete_Choices (Node));
932 Write_Str (" => ");
933 Sprint_Indented_List (Statements (Node));
935 when N_Character_Literal =>
936 if Column > 70 then
937 Write_Indent_Str (" ");
938 end if;
940 Write_Char_Sloc (''');
941 Write_Char_Code (Char_Literal_Value (Node));
942 Write_Char (''');
944 when N_Code_Statement =>
945 Write_Indent;
946 Set_Debug_Sloc;
947 Sprint_Node (Expression (Node));
948 Write_Char (';');
950 when N_Compilation_Unit =>
951 Sprint_Node_List (Context_Items (Node));
952 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
954 if Private_Present (Node) then
955 Write_Indent_Str ("private ");
956 Indent_Annull;
957 end if;
959 Sprint_Node_Sloc (Unit (Node));
961 if Present (Actions (Aux_Decls_Node (Node)))
962 or else
963 Present (Pragmas_After (Aux_Decls_Node (Node)))
964 then
965 Write_Indent;
966 end if;
968 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
969 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
971 when N_Compilation_Unit_Aux =>
972 null; -- nothing to do, never used, see above
974 when N_Component_Association =>
975 Set_Debug_Sloc;
976 Sprint_Bar_List (Choices (Node));
977 Write_Str (" => ");
979 -- Ada 2005 (AI-287): Print the mbox if present
981 if Box_Present (Node) then
982 Write_Str_With_Col_Check ("<>");
983 else
984 Sprint_Node (Expression (Node));
985 end if;
987 when N_Component_Clause =>
988 Write_Indent;
989 Sprint_Node (Component_Name (Node));
990 Write_Str_Sloc (" at ");
991 Sprint_Node (Position (Node));
992 Write_Char (' ');
993 Write_Str_With_Col_Check ("range ");
994 Sprint_Node (First_Bit (Node));
995 Write_Str (" .. ");
996 Sprint_Node (Last_Bit (Node));
997 Write_Char (';');
999 when N_Component_Definition =>
1000 Set_Debug_Sloc;
1002 -- Ada 2005 (AI-230): Access definition components
1004 if Present (Access_Definition (Node)) then
1005 Sprint_Node (Access_Definition (Node));
1007 elsif Present (Subtype_Indication (Node)) then
1008 if Aliased_Present (Node) then
1009 Write_Str_With_Col_Check ("aliased ");
1010 end if;
1012 -- Ada 2005 (AI-231)
1014 if Null_Exclusion_Present (Node) then
1015 Write_Str (" not null ");
1016 end if;
1018 Sprint_Node (Subtype_Indication (Node));
1020 else
1021 Write_Str (" ??? ");
1022 end if;
1024 when N_Component_Declaration =>
1025 if Write_Indent_Identifiers_Sloc (Node) then
1026 Write_Str (" : ");
1027 Sprint_Node (Component_Definition (Node));
1029 if Present (Expression (Node)) then
1030 Write_Str (" := ");
1031 Sprint_Node (Expression (Node));
1032 end if;
1034 Write_Char (';');
1035 end if;
1037 when N_Component_List =>
1038 if Null_Present (Node) then
1039 Indent_Begin;
1040 Write_Indent_Str_Sloc ("null");
1041 Write_Char (';');
1042 Indent_End;
1044 else
1045 Set_Debug_Sloc;
1046 Sprint_Indented_List (Component_Items (Node));
1047 Sprint_Node (Variant_Part (Node));
1048 end if;
1050 when N_Conditional_Entry_Call =>
1051 Write_Indent_Str_Sloc ("select");
1052 Indent_Begin;
1053 Sprint_Node (Entry_Call_Alternative (Node));
1054 Indent_End;
1055 Write_Indent_Str ("else");
1056 Sprint_Indented_List (Else_Statements (Node));
1057 Write_Indent_Str ("end select;");
1059 when N_Conditional_Expression =>
1060 declare
1061 Condition : constant Node_Id := First (Expressions (Node));
1062 Then_Expr : constant Node_Id := Next (Condition);
1063 Else_Expr : constant Node_Id := Next (Then_Expr);
1065 begin
1066 Write_Str_With_Col_Check_Sloc ("(if ");
1067 Sprint_Node (Condition);
1068 Write_Str_With_Col_Check (" then ");
1069 Sprint_Node (Then_Expr);
1070 Write_Str_With_Col_Check (" else ");
1071 Sprint_Node (Else_Expr);
1072 Write_Char (')');
1073 end;
1075 when N_Constrained_Array_Definition =>
1076 Write_Str_With_Col_Check_Sloc ("array ");
1077 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1078 Write_Str (" of ");
1080 Sprint_Node (Component_Definition (Node));
1082 when N_Decimal_Fixed_Point_Definition =>
1083 Write_Str_With_Col_Check_Sloc (" delta ");
1084 Sprint_Node (Delta_Expression (Node));
1085 Write_Str_With_Col_Check ("digits ");
1086 Sprint_Node (Digits_Expression (Node));
1087 Sprint_Opt_Node (Real_Range_Specification (Node));
1089 when N_Defining_Character_Literal =>
1090 Write_Name_With_Col_Check_Sloc (Chars (Node));
1092 when N_Defining_Identifier =>
1093 Set_Debug_Sloc;
1094 Write_Id (Node);
1096 when N_Defining_Operator_Symbol =>
1097 Write_Name_With_Col_Check_Sloc (Chars (Node));
1099 when N_Defining_Program_Unit_Name =>
1100 Set_Debug_Sloc;
1101 Sprint_Node (Name (Node));
1102 Write_Char ('.');
1103 Write_Id (Defining_Identifier (Node));
1105 when N_Delay_Alternative =>
1106 Sprint_Node_List (Pragmas_Before (Node));
1108 if Present (Condition (Node)) then
1109 Write_Indent;
1110 Write_Str_With_Col_Check ("when ");
1111 Sprint_Node (Condition (Node));
1112 Write_Str (" => ");
1113 Indent_Annull;
1114 end if;
1116 Sprint_Node_Sloc (Delay_Statement (Node));
1117 Sprint_Node_List (Statements (Node));
1119 when N_Delay_Relative_Statement =>
1120 Write_Indent_Str_Sloc ("delay ");
1121 Sprint_Node (Expression (Node));
1122 Write_Char (';');
1124 when N_Delay_Until_Statement =>
1125 Write_Indent_Str_Sloc ("delay until ");
1126 Sprint_Node (Expression (Node));
1127 Write_Char (';');
1129 when N_Delta_Constraint =>
1130 Write_Str_With_Col_Check_Sloc ("delta ");
1131 Sprint_Node (Delta_Expression (Node));
1132 Sprint_Opt_Node (Range_Constraint (Node));
1134 when N_Derived_Type_Definition =>
1135 if Abstract_Present (Node) then
1136 Write_Str_With_Col_Check ("abstract ");
1137 end if;
1139 Write_Str_With_Col_Check_Sloc ("new ");
1141 -- Ada 2005 (AI-231)
1143 if Null_Exclusion_Present (Node) then
1144 Write_Str_With_Col_Check ("not null ");
1145 end if;
1147 Sprint_Node (Subtype_Indication (Node));
1149 if Present (Record_Extension_Part (Node)) then
1150 Write_Str_With_Col_Check (" with ");
1151 Sprint_Node (Record_Extension_Part (Node));
1152 end if;
1154 when N_Designator =>
1155 Sprint_Node (Name (Node));
1156 Write_Char_Sloc ('.');
1157 Write_Id (Identifier (Node));
1159 when N_Digits_Constraint =>
1160 Write_Str_With_Col_Check_Sloc ("digits ");
1161 Sprint_Node (Digits_Expression (Node));
1162 Sprint_Opt_Node (Range_Constraint (Node));
1164 when N_Discriminant_Association =>
1165 Set_Debug_Sloc;
1167 if Present (Selector_Names (Node)) then
1168 Sprint_Bar_List (Selector_Names (Node));
1169 Write_Str (" => ");
1170 end if;
1172 Set_Debug_Sloc;
1173 Sprint_Node (Expression (Node));
1175 when N_Discriminant_Specification =>
1176 Set_Debug_Sloc;
1178 if Write_Identifiers (Node) then
1179 Write_Str (" : ");
1181 if Null_Exclusion_Present (Node) then
1182 Write_Str ("not null ");
1183 end if;
1185 Sprint_Node (Discriminant_Type (Node));
1187 if Present (Expression (Node)) then
1188 Write_Str (" := ");
1189 Sprint_Node (Expression (Node));
1190 end if;
1191 else
1192 Write_Str (", ");
1193 end if;
1195 when N_Elsif_Part =>
1196 Write_Indent_Str_Sloc ("elsif ");
1197 Sprint_Node (Condition (Node));
1198 Write_Str_With_Col_Check (" then");
1199 Sprint_Indented_List (Then_Statements (Node));
1201 when N_Empty =>
1202 null;
1204 when N_Entry_Body =>
1205 Write_Indent_Str_Sloc ("entry ");
1206 Write_Id (Defining_Identifier (Node));
1207 Sprint_Node (Entry_Body_Formal_Part (Node));
1208 Write_Str_With_Col_Check (" is");
1209 Sprint_Indented_List (Declarations (Node));
1210 Write_Indent_Str ("begin");
1211 Sprint_Node (Handled_Statement_Sequence (Node));
1212 Write_Indent_Str ("end ");
1213 Write_Id (Defining_Identifier (Node));
1214 Write_Char (';');
1216 when N_Entry_Body_Formal_Part =>
1217 if Present (Entry_Index_Specification (Node)) then
1218 Write_Str_With_Col_Check_Sloc (" (");
1219 Sprint_Node (Entry_Index_Specification (Node));
1220 Write_Char (')');
1221 end if;
1223 Write_Param_Specs (Node);
1224 Write_Str_With_Col_Check_Sloc (" when ");
1225 Sprint_Node (Condition (Node));
1227 when N_Entry_Call_Alternative =>
1228 Sprint_Node_List (Pragmas_Before (Node));
1229 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1230 Sprint_Node_List (Statements (Node));
1232 when N_Entry_Call_Statement =>
1233 Write_Indent;
1234 Sprint_Node_Sloc (Name (Node));
1235 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1236 Write_Char (';');
1238 when N_Entry_Declaration =>
1239 Write_Indent_Str_Sloc ("entry ");
1240 Write_Id (Defining_Identifier (Node));
1242 if Present (Discrete_Subtype_Definition (Node)) then
1243 Write_Str_With_Col_Check (" (");
1244 Sprint_Node (Discrete_Subtype_Definition (Node));
1245 Write_Char (')');
1246 end if;
1248 Write_Param_Specs (Node);
1249 Write_Char (';');
1251 when N_Entry_Index_Specification =>
1252 Write_Str_With_Col_Check_Sloc ("for ");
1253 Write_Id (Defining_Identifier (Node));
1254 Write_Str_With_Col_Check (" in ");
1255 Sprint_Node (Discrete_Subtype_Definition (Node));
1257 when N_Enumeration_Representation_Clause =>
1258 Write_Indent_Str_Sloc ("for ");
1259 Write_Id (Identifier (Node));
1260 Write_Str_With_Col_Check (" use ");
1261 Sprint_Node (Array_Aggregate (Node));
1262 Write_Char (';');
1264 when N_Enumeration_Type_Definition =>
1265 Set_Debug_Sloc;
1267 -- Skip attempt to print Literals field if it's not there and
1268 -- we are in package Standard (case of Character, which is
1269 -- handled specially (without an explicit literals list).
1271 if Sloc (Node) > Standard_Location
1272 or else Present (Literals (Node))
1273 then
1274 Sprint_Paren_Comma_List (Literals (Node));
1275 end if;
1277 when N_Error =>
1278 Write_Str_With_Col_Check_Sloc ("<error>");
1280 when N_Exception_Declaration =>
1281 if Write_Indent_Identifiers (Node) then
1282 Write_Str_With_Col_Check (" : ");
1283 Write_Str_Sloc ("exception;");
1284 end if;
1286 when N_Exception_Handler =>
1287 Write_Indent_Str_Sloc ("when ");
1289 if Present (Choice_Parameter (Node)) then
1290 Sprint_Node (Choice_Parameter (Node));
1291 Write_Str (" : ");
1292 end if;
1294 Sprint_Bar_List (Exception_Choices (Node));
1295 Write_Str (" => ");
1296 Sprint_Indented_List (Statements (Node));
1298 when N_Exception_Renaming_Declaration =>
1299 Write_Indent;
1300 Set_Debug_Sloc;
1301 Sprint_Node (Defining_Identifier (Node));
1302 Write_Str_With_Col_Check (" : exception renames ");
1303 Sprint_Node (Name (Node));
1304 Write_Char (';');
1306 when N_Exit_Statement =>
1307 Write_Indent_Str_Sloc ("exit");
1308 Sprint_Opt_Node (Name (Node));
1310 if Present (Condition (Node)) then
1311 Write_Str_With_Col_Check (" when ");
1312 Sprint_Node (Condition (Node));
1313 end if;
1315 Write_Char (';');
1317 when N_Expanded_Name =>
1318 Sprint_Node (Prefix (Node));
1319 Write_Char_Sloc ('.');
1320 Sprint_Node (Selector_Name (Node));
1322 when N_Explicit_Dereference =>
1323 Sprint_Node (Prefix (Node));
1324 Write_Char_Sloc ('.');
1325 Write_Str_Sloc ("all");
1327 when N_Extension_Aggregate =>
1328 Write_Str_With_Col_Check_Sloc ("(");
1329 Sprint_Node (Ancestor_Part (Node));
1330 Write_Str_With_Col_Check (" with ");
1332 if Null_Record_Present (Node) then
1333 Write_Str_With_Col_Check ("null record");
1334 else
1335 if Present (Expressions (Node)) then
1336 Sprint_Comma_List (Expressions (Node));
1338 if Present (Component_Associations (Node)) then
1339 Write_Str (", ");
1340 end if;
1341 end if;
1343 if Present (Component_Associations (Node)) then
1344 Sprint_Comma_List (Component_Associations (Node));
1345 end if;
1346 end if;
1348 Write_Char (')');
1350 when N_Floating_Point_Definition =>
1351 Write_Str_With_Col_Check_Sloc ("digits ");
1352 Sprint_Node (Digits_Expression (Node));
1353 Sprint_Opt_Node (Real_Range_Specification (Node));
1355 when N_Formal_Decimal_Fixed_Point_Definition =>
1356 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1358 when N_Formal_Derived_Type_Definition =>
1359 Write_Str_With_Col_Check_Sloc ("new ");
1360 Sprint_Node (Subtype_Mark (Node));
1362 if Private_Present (Node) then
1363 Write_Str_With_Col_Check (" with private");
1364 end if;
1366 when N_Formal_Discrete_Type_Definition =>
1367 Write_Str_With_Col_Check_Sloc ("<>");
1369 when N_Formal_Floating_Point_Definition =>
1370 Write_Str_With_Col_Check_Sloc ("digits <>");
1372 when N_Formal_Modular_Type_Definition =>
1373 Write_Str_With_Col_Check_Sloc ("mod <>");
1375 when N_Formal_Object_Declaration =>
1376 Set_Debug_Sloc;
1378 if Write_Indent_Identifiers (Node) then
1379 Write_Str (" : ");
1381 if In_Present (Node) then
1382 Write_Str_With_Col_Check ("in ");
1383 end if;
1385 if Out_Present (Node) then
1386 Write_Str_With_Col_Check ("out ");
1387 end if;
1389 Sprint_Node (Subtype_Mark (Node));
1391 if Present (Expression (Node)) then
1392 Write_Str (" := ");
1393 Sprint_Node (Expression (Node));
1394 end if;
1396 Write_Char (';');
1397 end if;
1399 when N_Formal_Ordinary_Fixed_Point_Definition =>
1400 Write_Str_With_Col_Check_Sloc ("delta <>");
1402 when N_Formal_Package_Declaration =>
1403 Write_Indent_Str_Sloc ("with package ");
1404 Write_Id (Defining_Identifier (Node));
1405 Write_Str_With_Col_Check (" is new ");
1406 Sprint_Node (Name (Node));
1407 Write_Str_With_Col_Check (" (<>);");
1409 when N_Formal_Private_Type_Definition =>
1410 if Abstract_Present (Node) then
1411 Write_Str_With_Col_Check ("abstract ");
1412 end if;
1414 if Tagged_Present (Node) then
1415 Write_Str_With_Col_Check ("tagged ");
1416 end if;
1418 if Limited_Present (Node) then
1419 Write_Str_With_Col_Check ("limited ");
1420 end if;
1422 Write_Str_With_Col_Check_Sloc ("private");
1424 when N_Formal_Signed_Integer_Type_Definition =>
1425 Write_Str_With_Col_Check_Sloc ("range <>");
1427 when N_Formal_Subprogram_Declaration =>
1428 Write_Indent_Str_Sloc ("with ");
1429 Sprint_Node (Specification (Node));
1431 if Box_Present (Node) then
1432 Write_Str_With_Col_Check (" is <>");
1433 elsif Present (Default_Name (Node)) then
1434 Write_Str_With_Col_Check (" is ");
1435 Sprint_Node (Default_Name (Node));
1436 end if;
1438 Write_Char (';');
1440 when N_Formal_Type_Declaration =>
1441 Write_Indent_Str_Sloc ("type ");
1442 Write_Id (Defining_Identifier (Node));
1444 if Present (Discriminant_Specifications (Node)) then
1445 Write_Discr_Specs (Node);
1446 elsif Unknown_Discriminants_Present (Node) then
1447 Write_Str_With_Col_Check ("(<>)");
1448 end if;
1450 Write_Str_With_Col_Check (" is ");
1451 Sprint_Node (Formal_Type_Definition (Node));
1452 Write_Char (';');
1454 when N_Free_Statement =>
1455 Write_Indent_Str_Sloc ("free ");
1456 Sprint_Node (Expression (Node));
1457 Write_Char (';');
1459 when N_Freeze_Entity =>
1460 if Dump_Original_Only then
1461 null;
1463 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1464 Write_Indent;
1465 Write_Rewrite_Str ("<<<");
1466 Write_Str_With_Col_Check_Sloc ("freeze ");
1467 Write_Id (Entity (Node));
1468 Write_Str (" [");
1470 if No (Actions (Node)) then
1471 Write_Char (']');
1473 else
1474 Freeze_Indent := Freeze_Indent + 1;
1475 Sprint_Indented_List (Actions (Node));
1476 Freeze_Indent := Freeze_Indent - 1;
1477 Write_Indent_Str ("]");
1478 end if;
1480 Write_Rewrite_Str (">>>");
1481 end if;
1483 when N_Full_Type_Declaration =>
1484 Write_Indent_Str_Sloc ("type ");
1485 Write_Id (Defining_Identifier (Node));
1486 Write_Discr_Specs (Node);
1487 Write_Str_With_Col_Check (" is ");
1488 Sprint_Node (Type_Definition (Node));
1489 Write_Char (';');
1491 when N_Function_Call =>
1492 Set_Debug_Sloc;
1493 Sprint_Node (Name (Node));
1494 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1496 when N_Function_Instantiation =>
1497 Write_Indent_Str_Sloc ("function ");
1498 Sprint_Node (Defining_Unit_Name (Node));
1499 Write_Str_With_Col_Check (" is new ");
1500 Sprint_Node (Name (Node));
1501 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1502 Write_Char (';');
1504 when N_Function_Specification =>
1505 Write_Str_With_Col_Check_Sloc ("function ");
1506 Sprint_Node (Defining_Unit_Name (Node));
1507 Write_Param_Specs (Node);
1508 Write_Str_With_Col_Check (" return ");
1509 Sprint_Node (Subtype_Mark (Node));
1511 when N_Generic_Association =>
1512 Set_Debug_Sloc;
1514 if Present (Selector_Name (Node)) then
1515 Sprint_Node (Selector_Name (Node));
1516 Write_Str (" => ");
1517 end if;
1519 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1521 when N_Generic_Function_Renaming_Declaration =>
1522 Write_Indent_Str_Sloc ("generic function ");
1523 Sprint_Node (Defining_Unit_Name (Node));
1524 Write_Str_With_Col_Check (" renames ");
1525 Sprint_Node (Name (Node));
1526 Write_Char (';');
1528 when N_Generic_Package_Declaration =>
1529 Write_Indent;
1530 Write_Indent_Str_Sloc ("generic ");
1531 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1532 Write_Indent;
1533 Sprint_Node (Specification (Node));
1534 Write_Char (';');
1536 when N_Generic_Package_Renaming_Declaration =>
1537 Write_Indent_Str_Sloc ("generic package ");
1538 Sprint_Node (Defining_Unit_Name (Node));
1539 Write_Str_With_Col_Check (" renames ");
1540 Sprint_Node (Name (Node));
1541 Write_Char (';');
1543 when N_Generic_Procedure_Renaming_Declaration =>
1544 Write_Indent_Str_Sloc ("generic procedure ");
1545 Sprint_Node (Defining_Unit_Name (Node));
1546 Write_Str_With_Col_Check (" renames ");
1547 Sprint_Node (Name (Node));
1548 Write_Char (';');
1550 when N_Generic_Subprogram_Declaration =>
1551 Write_Indent;
1552 Write_Indent_Str_Sloc ("generic ");
1553 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1554 Write_Indent;
1555 Sprint_Node (Specification (Node));
1556 Write_Char (';');
1558 when N_Goto_Statement =>
1559 Write_Indent_Str_Sloc ("goto ");
1560 Sprint_Node (Name (Node));
1561 Write_Char (';');
1563 if Nkind (Next (Node)) = N_Label then
1564 Write_Indent;
1565 end if;
1567 when N_Handled_Sequence_Of_Statements =>
1568 Set_Debug_Sloc;
1569 Sprint_Indented_List (Statements (Node));
1571 if Present (Exception_Handlers (Node)) then
1572 Write_Indent_Str ("exception");
1573 Indent_Begin;
1574 Sprint_Node_List (Exception_Handlers (Node));
1575 Indent_End;
1576 end if;
1578 if Present (At_End_Proc (Node)) then
1579 Write_Indent_Str ("at end");
1580 Indent_Begin;
1581 Write_Indent;
1582 Sprint_Node (At_End_Proc (Node));
1583 Write_Char (';');
1584 Indent_End;
1585 end if;
1587 when N_Identifier =>
1588 Set_Debug_Sloc;
1589 Write_Id (Node);
1591 when N_If_Statement =>
1592 Write_Indent_Str_Sloc ("if ");
1593 Sprint_Node (Condition (Node));
1594 Write_Str_With_Col_Check (" then");
1595 Sprint_Indented_List (Then_Statements (Node));
1596 Sprint_Opt_Node_List (Elsif_Parts (Node));
1598 if Present (Else_Statements (Node)) then
1599 Write_Indent_Str ("else");
1600 Sprint_Indented_List (Else_Statements (Node));
1601 end if;
1603 Write_Indent_Str ("end if;");
1605 when N_Implicit_Label_Declaration =>
1606 if not Dump_Original_Only then
1607 Write_Indent;
1608 Write_Rewrite_Str ("<<<");
1609 Set_Debug_Sloc;
1610 Write_Id (Defining_Identifier (Node));
1611 Write_Str (" : ");
1612 Write_Str_With_Col_Check ("label");
1613 Write_Rewrite_Str (">>>");
1614 end if;
1616 when N_In =>
1617 Sprint_Left_Opnd (Node);
1618 Write_Str_Sloc (" in ");
1619 Sprint_Right_Opnd (Node);
1621 when N_Incomplete_Type_Declaration =>
1622 Write_Indent_Str_Sloc ("type ");
1623 Write_Id (Defining_Identifier (Node));
1625 if Present (Discriminant_Specifications (Node)) then
1626 Write_Discr_Specs (Node);
1627 elsif Unknown_Discriminants_Present (Node) then
1628 Write_Str_With_Col_Check ("(<>)");
1629 end if;
1631 Write_Char (';');
1633 when N_Index_Or_Discriminant_Constraint =>
1634 Set_Debug_Sloc;
1635 Sprint_Paren_Comma_List (Constraints (Node));
1637 when N_Indexed_Component =>
1638 Sprint_Node_Sloc (Prefix (Node));
1639 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1641 when N_Integer_Literal =>
1642 if Print_In_Hex (Node) then
1643 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1644 else
1645 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1646 end if;
1648 when N_Iteration_Scheme =>
1649 if Present (Condition (Node)) then
1650 Write_Str_With_Col_Check_Sloc ("while ");
1651 Sprint_Node (Condition (Node));
1652 else
1653 Write_Str_With_Col_Check_Sloc ("for ");
1654 Sprint_Node (Loop_Parameter_Specification (Node));
1655 end if;
1657 Write_Char (' ');
1659 when N_Itype_Reference =>
1660 Write_Indent_Str_Sloc ("reference ");
1661 Write_Id (Itype (Node));
1663 when N_Label =>
1664 Write_Indent_Str_Sloc ("<<");
1665 Write_Id (Identifier (Node));
1666 Write_Str (">>");
1668 when N_Loop_Parameter_Specification =>
1669 Set_Debug_Sloc;
1670 Write_Id (Defining_Identifier (Node));
1671 Write_Str_With_Col_Check (" in ");
1673 if Reverse_Present (Node) then
1674 Write_Str_With_Col_Check ("reverse ");
1675 end if;
1677 Sprint_Node (Discrete_Subtype_Definition (Node));
1679 when N_Loop_Statement =>
1680 Write_Indent;
1682 if Present (Identifier (Node))
1683 and then (not Has_Created_Identifier (Node)
1684 or else not Dump_Original_Only)
1685 then
1686 Write_Rewrite_Str ("<<<");
1687 Write_Id (Identifier (Node));
1688 Write_Str (" : ");
1689 Write_Rewrite_Str (">>>");
1690 Sprint_Node (Iteration_Scheme (Node));
1691 Write_Str_With_Col_Check_Sloc ("loop");
1692 Sprint_Indented_List (Statements (Node));
1693 Write_Indent_Str ("end loop ");
1694 Write_Rewrite_Str ("<<<");
1695 Write_Id (Identifier (Node));
1696 Write_Rewrite_Str (">>>");
1697 Write_Char (';');
1699 else
1700 Sprint_Node (Iteration_Scheme (Node));
1701 Write_Str_With_Col_Check_Sloc ("loop");
1702 Sprint_Indented_List (Statements (Node));
1703 Write_Indent_Str ("end loop;");
1704 end if;
1706 when N_Mod_Clause =>
1707 Sprint_Node_List (Pragmas_Before (Node));
1708 Write_Str_With_Col_Check_Sloc ("at mod ");
1709 Sprint_Node (Expression (Node));
1711 when N_Modular_Type_Definition =>
1712 Write_Str_With_Col_Check_Sloc ("mod ");
1713 Sprint_Node (Expression (Node));
1715 when N_Not_In =>
1716 Sprint_Left_Opnd (Node);
1717 Write_Str_Sloc (" not in ");
1718 Sprint_Right_Opnd (Node);
1720 when N_Null =>
1721 Write_Str_With_Col_Check_Sloc ("null");
1723 when N_Null_Statement =>
1724 if Comes_From_Source (Node)
1725 or else Dump_Freeze_Null
1726 or else not Is_List_Member (Node)
1727 or else (No (Prev (Node)) and then No (Next (Node)))
1728 then
1729 Write_Indent_Str_Sloc ("null;");
1730 end if;
1732 when N_Number_Declaration =>
1733 Set_Debug_Sloc;
1735 if Write_Indent_Identifiers (Node) then
1736 Write_Str_With_Col_Check (" : constant ");
1737 Write_Str (" := ");
1738 Sprint_Node (Expression (Node));
1739 Write_Char (';');
1740 end if;
1742 when N_Object_Declaration =>
1743 Set_Debug_Sloc;
1745 if Write_Indent_Identifiers (Node) then
1746 Write_Str (" : ");
1748 if Aliased_Present (Node) then
1749 Write_Str_With_Col_Check ("aliased ");
1750 end if;
1752 if Constant_Present (Node) then
1753 Write_Str_With_Col_Check ("constant ");
1754 end if;
1756 -- Ada 2005 (AI-231)
1758 if Null_Exclusion_Present (Node) then
1759 Write_Str_With_Col_Check ("not null ");
1760 end if;
1762 Sprint_Node (Object_Definition (Node));
1764 if Present (Expression (Node)) then
1765 Write_Str (" := ");
1766 Sprint_Node (Expression (Node));
1767 end if;
1769 Write_Char (';');
1770 end if;
1772 when N_Object_Renaming_Declaration =>
1773 Write_Indent;
1774 Set_Debug_Sloc;
1775 Sprint_Node (Defining_Identifier (Node));
1776 Write_Str (" : ");
1778 -- Ada 2005 (AI-230): Access renamings
1780 if Present (Access_Definition (Node)) then
1781 Sprint_Node (Access_Definition (Node));
1783 elsif Present (Subtype_Mark (Node)) then
1784 Sprint_Node (Subtype_Mark (Node));
1786 else
1787 Write_Str (" ??? ");
1788 end if;
1790 Write_Str_With_Col_Check (" renames ");
1791 Sprint_Node (Name (Node));
1792 Write_Char (';');
1794 when N_Op_Abs =>
1795 Write_Operator (Node, "abs ");
1796 Sprint_Right_Opnd (Node);
1798 when N_Op_Add =>
1799 Sprint_Left_Opnd (Node);
1800 Write_Operator (Node, " + ");
1801 Sprint_Right_Opnd (Node);
1803 when N_Op_And =>
1804 Sprint_Left_Opnd (Node);
1805 Write_Operator (Node, " and ");
1806 Sprint_Right_Opnd (Node);
1808 when N_Op_Concat =>
1809 Sprint_Left_Opnd (Node);
1810 Write_Operator (Node, " & ");
1811 Sprint_Right_Opnd (Node);
1813 when N_Op_Divide =>
1814 Sprint_Left_Opnd (Node);
1815 Write_Char (' ');
1816 Process_TFAI_RR_Flags (Node);
1817 Write_Operator (Node, "/ ");
1818 Sprint_Right_Opnd (Node);
1820 when N_Op_Eq =>
1821 Sprint_Left_Opnd (Node);
1822 Write_Operator (Node, " = ");
1823 Sprint_Right_Opnd (Node);
1825 when N_Op_Expon =>
1826 Sprint_Left_Opnd (Node);
1827 Write_Operator (Node, " ** ");
1828 Sprint_Right_Opnd (Node);
1830 when N_Op_Ge =>
1831 Sprint_Left_Opnd (Node);
1832 Write_Operator (Node, " >= ");
1833 Sprint_Right_Opnd (Node);
1835 when N_Op_Gt =>
1836 Sprint_Left_Opnd (Node);
1837 Write_Operator (Node, " > ");
1838 Sprint_Right_Opnd (Node);
1840 when N_Op_Le =>
1841 Sprint_Left_Opnd (Node);
1842 Write_Operator (Node, " <= ");
1843 Sprint_Right_Opnd (Node);
1845 when N_Op_Lt =>
1846 Sprint_Left_Opnd (Node);
1847 Write_Operator (Node, " < ");
1848 Sprint_Right_Opnd (Node);
1850 when N_Op_Minus =>
1851 Write_Operator (Node, "-");
1852 Sprint_Right_Opnd (Node);
1854 when N_Op_Mod =>
1855 Sprint_Left_Opnd (Node);
1857 if Treat_Fixed_As_Integer (Node) then
1858 Write_Str (" #");
1859 end if;
1861 Write_Operator (Node, " mod ");
1862 Sprint_Right_Opnd (Node);
1864 when N_Op_Multiply =>
1865 Sprint_Left_Opnd (Node);
1866 Write_Char (' ');
1867 Process_TFAI_RR_Flags (Node);
1868 Write_Operator (Node, "* ");
1869 Sprint_Right_Opnd (Node);
1871 when N_Op_Ne =>
1872 Sprint_Left_Opnd (Node);
1873 Write_Operator (Node, " /= ");
1874 Sprint_Right_Opnd (Node);
1876 when N_Op_Not =>
1877 Write_Operator (Node, "not ");
1878 Sprint_Right_Opnd (Node);
1880 when N_Op_Or =>
1881 Sprint_Left_Opnd (Node);
1882 Write_Operator (Node, " or ");
1883 Sprint_Right_Opnd (Node);
1885 when N_Op_Plus =>
1886 Write_Operator (Node, "+");
1887 Sprint_Right_Opnd (Node);
1889 when N_Op_Rem =>
1890 Sprint_Left_Opnd (Node);
1892 if Treat_Fixed_As_Integer (Node) then
1893 Write_Str (" #");
1894 end if;
1896 Write_Operator (Node, " rem ");
1897 Sprint_Right_Opnd (Node);
1899 when N_Op_Shift =>
1900 Set_Debug_Sloc;
1901 Write_Id (Node);
1902 Write_Char ('!');
1903 Write_Str_With_Col_Check ("(");
1904 Sprint_Node (Left_Opnd (Node));
1905 Write_Str (", ");
1906 Sprint_Node (Right_Opnd (Node));
1907 Write_Char (')');
1909 when N_Op_Subtract =>
1910 Sprint_Left_Opnd (Node);
1911 Write_Operator (Node, " - ");
1912 Sprint_Right_Opnd (Node);
1914 when N_Op_Xor =>
1915 Sprint_Left_Opnd (Node);
1916 Write_Operator (Node, " xor ");
1917 Sprint_Right_Opnd (Node);
1919 when N_Operator_Symbol =>
1920 Write_Name_With_Col_Check_Sloc (Chars (Node));
1922 when N_Ordinary_Fixed_Point_Definition =>
1923 Write_Str_With_Col_Check_Sloc ("delta ");
1924 Sprint_Node (Delta_Expression (Node));
1925 Sprint_Opt_Node (Real_Range_Specification (Node));
1927 when N_Or_Else =>
1928 Sprint_Left_Opnd (Node);
1929 Write_Str_Sloc (" or else ");
1930 Sprint_Right_Opnd (Node);
1932 when N_Others_Choice =>
1933 if All_Others (Node) then
1934 Write_Str_With_Col_Check ("all ");
1935 end if;
1937 Write_Str_With_Col_Check_Sloc ("others");
1939 when N_Package_Body =>
1940 Write_Indent;
1941 Write_Indent_Str_Sloc ("package body ");
1942 Sprint_Node (Defining_Unit_Name (Node));
1943 Write_Str (" is");
1944 Sprint_Indented_List (Declarations (Node));
1946 if Present (Handled_Statement_Sequence (Node)) then
1947 Write_Indent_Str ("begin");
1948 Sprint_Node (Handled_Statement_Sequence (Node));
1949 end if;
1951 Write_Indent_Str ("end ");
1952 Sprint_Node (Defining_Unit_Name (Node));
1953 Write_Char (';');
1955 when N_Package_Body_Stub =>
1956 Write_Indent_Str_Sloc ("package body ");
1957 Sprint_Node (Defining_Identifier (Node));
1958 Write_Str_With_Col_Check (" is separate;");
1960 when N_Package_Declaration =>
1961 Write_Indent;
1962 Write_Indent;
1963 Sprint_Node_Sloc (Specification (Node));
1964 Write_Char (';');
1966 when N_Package_Instantiation =>
1967 Write_Indent;
1968 Write_Indent_Str_Sloc ("package ");
1969 Sprint_Node (Defining_Unit_Name (Node));
1970 Write_Str (" is new ");
1971 Sprint_Node (Name (Node));
1972 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1973 Write_Char (';');
1975 when N_Package_Renaming_Declaration =>
1976 Write_Indent_Str_Sloc ("package ");
1977 Sprint_Node (Defining_Unit_Name (Node));
1978 Write_Str_With_Col_Check (" renames ");
1979 Sprint_Node (Name (Node));
1980 Write_Char (';');
1982 when N_Package_Specification =>
1983 Write_Str_With_Col_Check_Sloc ("package ");
1984 Sprint_Node (Defining_Unit_Name (Node));
1985 Write_Str (" is");
1986 Sprint_Indented_List (Visible_Declarations (Node));
1988 if Present (Private_Declarations (Node)) then
1989 Write_Indent_Str ("private");
1990 Sprint_Indented_List (Private_Declarations (Node));
1991 end if;
1993 Write_Indent_Str ("end ");
1994 Sprint_Node (Defining_Unit_Name (Node));
1996 when N_Parameter_Association =>
1997 Sprint_Node_Sloc (Selector_Name (Node));
1998 Write_Str (" => ");
1999 Sprint_Node (Explicit_Actual_Parameter (Node));
2001 when N_Parameter_Specification =>
2002 Set_Debug_Sloc;
2004 if Write_Identifiers (Node) then
2005 Write_Str (" : ");
2007 if In_Present (Node) then
2008 Write_Str_With_Col_Check ("in ");
2009 end if;
2011 if Out_Present (Node) then
2012 Write_Str_With_Col_Check ("out ");
2013 end if;
2015 -- Ada 2005 (AI-231)
2017 if Null_Exclusion_Present (Node) then
2018 Write_Str ("not null ");
2019 end if;
2021 Sprint_Node (Parameter_Type (Node));
2023 if Present (Expression (Node)) then
2024 Write_Str (" := ");
2025 Sprint_Node (Expression (Node));
2026 end if;
2027 else
2028 Write_Str (", ");
2029 end if;
2031 when N_Pragma =>
2032 Write_Indent_Str_Sloc ("pragma ");
2033 Write_Name_With_Col_Check (Chars (Node));
2035 if Present (Pragma_Argument_Associations (Node)) then
2036 Sprint_Opt_Paren_Comma_List
2037 (Pragma_Argument_Associations (Node));
2038 end if;
2040 Write_Char (';');
2042 when N_Pragma_Argument_Association =>
2043 Set_Debug_Sloc;
2045 if Chars (Node) /= No_Name then
2046 Write_Name_With_Col_Check (Chars (Node));
2047 Write_Str (" => ");
2048 end if;
2050 Sprint_Node (Expression (Node));
2052 when N_Private_Type_Declaration =>
2053 Write_Indent_Str_Sloc ("type ");
2054 Write_Id (Defining_Identifier (Node));
2056 if Present (Discriminant_Specifications (Node)) then
2057 Write_Discr_Specs (Node);
2058 elsif Unknown_Discriminants_Present (Node) then
2059 Write_Str_With_Col_Check ("(<>)");
2060 end if;
2062 Write_Str (" is ");
2064 if Tagged_Present (Node) then
2065 Write_Str_With_Col_Check ("tagged ");
2066 end if;
2068 if Limited_Present (Node) then
2069 Write_Str_With_Col_Check ("limited ");
2070 end if;
2072 Write_Str_With_Col_Check ("private;");
2074 when N_Private_Extension_Declaration =>
2075 Write_Indent_Str_Sloc ("type ");
2076 Write_Id (Defining_Identifier (Node));
2078 if Present (Discriminant_Specifications (Node)) then
2079 Write_Discr_Specs (Node);
2080 elsif Unknown_Discriminants_Present (Node) then
2081 Write_Str_With_Col_Check ("(<>)");
2082 end if;
2084 Write_Str_With_Col_Check (" is new ");
2085 Sprint_Node (Subtype_Indication (Node));
2086 Write_Str_With_Col_Check (" with private;");
2088 when N_Procedure_Call_Statement =>
2089 Write_Indent;
2090 Set_Debug_Sloc;
2091 Sprint_Node (Name (Node));
2092 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2093 Write_Char (';');
2095 when N_Procedure_Instantiation =>
2096 Write_Indent_Str_Sloc ("procedure ");
2097 Sprint_Node (Defining_Unit_Name (Node));
2098 Write_Str_With_Col_Check (" is new ");
2099 Sprint_Node (Name (Node));
2100 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2101 Write_Char (';');
2103 when N_Procedure_Specification =>
2104 Write_Str_With_Col_Check_Sloc ("procedure ");
2105 Sprint_Node (Defining_Unit_Name (Node));
2106 Write_Param_Specs (Node);
2108 when N_Protected_Body =>
2109 Write_Indent_Str_Sloc ("protected body ");
2110 Write_Id (Defining_Identifier (Node));
2111 Write_Str (" is");
2112 Sprint_Indented_List (Declarations (Node));
2113 Write_Indent_Str ("end ");
2114 Write_Id (Defining_Identifier (Node));
2115 Write_Char (';');
2117 when N_Protected_Body_Stub =>
2118 Write_Indent_Str_Sloc ("protected body ");
2119 Write_Id (Defining_Identifier (Node));
2120 Write_Str_With_Col_Check (" is separate;");
2122 when N_Protected_Definition =>
2123 Set_Debug_Sloc;
2124 Sprint_Indented_List (Visible_Declarations (Node));
2126 if Present (Private_Declarations (Node)) then
2127 Write_Indent_Str ("private");
2128 Sprint_Indented_List (Private_Declarations (Node));
2129 end if;
2131 Write_Indent_Str ("end ");
2133 when N_Protected_Type_Declaration =>
2134 Write_Indent_Str_Sloc ("protected type ");
2135 Write_Id (Defining_Identifier (Node));
2136 Write_Discr_Specs (Node);
2137 Write_Str (" is");
2138 Sprint_Node (Protected_Definition (Node));
2139 Write_Id (Defining_Identifier (Node));
2140 Write_Char (';');
2142 when N_Qualified_Expression =>
2143 Sprint_Node (Subtype_Mark (Node));
2144 Write_Char_Sloc (''');
2146 -- Print expression, make sure we have at least one level of
2147 -- parentheses around the expression. For cases of qualified
2148 -- expressions in the source, this is always the case, but
2149 -- for generated qualifications, there may be no explicit
2150 -- parentheses present.
2152 if Paren_Count (Expression (Node)) /= 0 then
2153 Sprint_Node (Expression (Node));
2154 else
2155 Write_Char ('(');
2156 Sprint_Node (Expression (Node));
2157 Write_Char (')');
2158 end if;
2160 when N_Raise_Constraint_Error =>
2162 -- This node can be used either as a subexpression or as a
2163 -- statement form. The following test is a reasonably reliable
2164 -- way to distinguish the two cases.
2166 if Is_List_Member (Node)
2167 and then Nkind (Parent (Node)) not in N_Subexpr
2168 then
2169 Write_Indent;
2170 end if;
2172 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2173 Write_Condition_And_Reason (Node);
2175 when N_Raise_Program_Error =>
2177 -- This node can be used either as a subexpression or as a
2178 -- statement form. The following test is a reasonably reliable
2179 -- way to distinguish the two cases.
2181 if Is_List_Member (Node)
2182 and then Nkind (Parent (Node)) not in N_Subexpr
2183 then
2184 Write_Indent;
2185 end if;
2187 Write_Str_With_Col_Check_Sloc ("[program_error");
2188 Write_Condition_And_Reason (Node);
2190 when N_Raise_Storage_Error =>
2192 -- This node can be used either as a subexpression or as a
2193 -- statement form. The following test is a reasonably reliable
2194 -- way to distinguish the two cases.
2196 if Is_List_Member (Node)
2197 and then Nkind (Parent (Node)) not in N_Subexpr
2198 then
2199 Write_Indent;
2200 end if;
2202 Write_Str_With_Col_Check_Sloc ("[storage_error");
2203 Write_Condition_And_Reason (Node);
2205 when N_Raise_Statement =>
2206 Write_Indent_Str_Sloc ("raise ");
2207 Sprint_Node (Name (Node));
2208 Write_Char (';');
2210 when N_Range =>
2211 Sprint_Node (Low_Bound (Node));
2212 Write_Str_Sloc (" .. ");
2213 Sprint_Node (High_Bound (Node));
2215 when N_Range_Constraint =>
2216 Write_Str_With_Col_Check_Sloc ("range ");
2217 Sprint_Node (Range_Expression (Node));
2219 when N_Real_Literal =>
2220 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2222 when N_Real_Range_Specification =>
2223 Write_Str_With_Col_Check_Sloc ("range ");
2224 Sprint_Node (Low_Bound (Node));
2225 Write_Str (" .. ");
2226 Sprint_Node (High_Bound (Node));
2228 when N_Record_Definition =>
2229 if Abstract_Present (Node) then
2230 Write_Str_With_Col_Check ("abstract ");
2231 end if;
2233 if Tagged_Present (Node) then
2234 Write_Str_With_Col_Check ("tagged ");
2235 end if;
2237 if Limited_Present (Node) then
2238 Write_Str_With_Col_Check ("limited ");
2239 end if;
2241 if Null_Present (Node) then
2242 Write_Str_With_Col_Check_Sloc ("null record");
2244 else
2245 Write_Str_With_Col_Check_Sloc ("record");
2246 Sprint_Node (Component_List (Node));
2247 Write_Indent_Str ("end record");
2248 end if;
2250 when N_Record_Representation_Clause =>
2251 Write_Indent_Str_Sloc ("for ");
2252 Sprint_Node (Identifier (Node));
2253 Write_Str_With_Col_Check (" use record ");
2255 if Present (Mod_Clause (Node)) then
2256 Sprint_Node (Mod_Clause (Node));
2257 end if;
2259 Sprint_Indented_List (Component_Clauses (Node));
2260 Write_Indent_Str ("end record;");
2262 when N_Reference =>
2263 Sprint_Node (Prefix (Node));
2264 Write_Str_With_Col_Check_Sloc ("'reference");
2266 when N_Requeue_Statement =>
2267 Write_Indent_Str_Sloc ("requeue ");
2268 Sprint_Node (Name (Node));
2270 if Abort_Present (Node) then
2271 Write_Str_With_Col_Check (" with abort");
2272 end if;
2274 Write_Char (';');
2276 when N_Return_Statement =>
2277 if Present (Expression (Node)) then
2278 Write_Indent_Str_Sloc ("return ");
2279 Sprint_Node (Expression (Node));
2280 Write_Char (';');
2281 else
2282 Write_Indent_Str_Sloc ("return;");
2283 end if;
2285 when N_Selective_Accept =>
2286 Write_Indent_Str_Sloc ("select");
2288 declare
2289 Alt_Node : Node_Id;
2291 begin
2292 Alt_Node := First (Select_Alternatives (Node));
2293 loop
2294 Indent_Begin;
2295 Sprint_Node (Alt_Node);
2296 Indent_End;
2297 Next (Alt_Node);
2298 exit when No (Alt_Node);
2299 Write_Indent_Str ("or");
2300 end loop;
2301 end;
2303 if Present (Else_Statements (Node)) then
2304 Write_Indent_Str ("else");
2305 Sprint_Indented_List (Else_Statements (Node));
2306 end if;
2308 Write_Indent_Str ("end select;");
2310 when N_Signed_Integer_Type_Definition =>
2311 Write_Str_With_Col_Check_Sloc ("range ");
2312 Sprint_Node (Low_Bound (Node));
2313 Write_Str (" .. ");
2314 Sprint_Node (High_Bound (Node));
2316 when N_Single_Protected_Declaration =>
2317 Write_Indent_Str_Sloc ("protected ");
2318 Write_Id (Defining_Identifier (Node));
2319 Write_Str (" is");
2320 Sprint_Node (Protected_Definition (Node));
2321 Write_Id (Defining_Identifier (Node));
2322 Write_Char (';');
2324 when N_Single_Task_Declaration =>
2325 Write_Indent_Str_Sloc ("task ");
2326 Write_Id (Defining_Identifier (Node));
2328 if Present (Task_Definition (Node)) then
2329 Write_Str (" is");
2330 Sprint_Node (Task_Definition (Node));
2331 Write_Id (Defining_Identifier (Node));
2332 end if;
2334 Write_Char (';');
2336 when N_Selected_Component =>
2337 Sprint_Node (Prefix (Node));
2338 Write_Char_Sloc ('.');
2339 Sprint_Node (Selector_Name (Node));
2341 when N_Slice =>
2342 Set_Debug_Sloc;
2343 Sprint_Node (Prefix (Node));
2344 Write_Str_With_Col_Check (" (");
2345 Sprint_Node (Discrete_Range (Node));
2346 Write_Char (')');
2348 when N_String_Literal =>
2349 if String_Length (Strval (Node)) + Column > 75 then
2350 Write_Indent_Str (" ");
2351 end if;
2353 Set_Debug_Sloc;
2354 Write_String_Table_Entry (Strval (Node));
2356 when N_Subprogram_Body =>
2357 if Freeze_Indent = 0 then
2358 Write_Indent;
2359 end if;
2361 Write_Indent;
2362 Sprint_Node_Sloc (Specification (Node));
2363 Write_Str (" is");
2365 Sprint_Indented_List (Declarations (Node));
2366 Write_Indent_Str ("begin");
2367 Sprint_Node (Handled_Statement_Sequence (Node));
2369 Write_Indent_Str ("end ");
2370 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2371 Write_Char (';');
2373 if Is_List_Member (Node)
2374 and then Present (Next (Node))
2375 and then Nkind (Next (Node)) /= N_Subprogram_Body
2376 then
2377 Write_Indent;
2378 end if;
2380 when N_Subprogram_Body_Stub =>
2381 Write_Indent;
2382 Sprint_Node_Sloc (Specification (Node));
2383 Write_Str_With_Col_Check (" is separate;");
2385 when N_Subprogram_Declaration =>
2386 Write_Indent;
2387 Sprint_Node_Sloc (Specification (Node));
2388 Write_Char (';');
2390 when N_Subprogram_Info =>
2391 Sprint_Node (Identifier (Node));
2392 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2394 when N_Subprogram_Renaming_Declaration =>
2395 Write_Indent;
2396 Sprint_Node (Specification (Node));
2397 Write_Str_With_Col_Check_Sloc (" renames ");
2398 Sprint_Node (Name (Node));
2399 Write_Char (';');
2401 when N_Subtype_Declaration =>
2402 Write_Indent_Str_Sloc ("subtype ");
2403 Write_Id (Defining_Identifier (Node));
2404 Write_Str (" is ");
2406 -- Ada 2005 (AI-231)
2408 if Null_Exclusion_Present (Node) then
2409 Write_Str ("not null ");
2410 end if;
2412 Sprint_Node (Subtype_Indication (Node));
2413 Write_Char (';');
2415 when N_Subtype_Indication =>
2416 Sprint_Node_Sloc (Subtype_Mark (Node));
2417 Write_Char (' ');
2418 Sprint_Node (Constraint (Node));
2420 when N_Subunit =>
2421 Write_Indent_Str_Sloc ("separate (");
2422 Sprint_Node (Name (Node));
2423 Write_Char (')');
2424 Write_Eol;
2425 Sprint_Node (Proper_Body (Node));
2427 when N_Task_Body =>
2428 Write_Indent_Str_Sloc ("task body ");
2429 Write_Id (Defining_Identifier (Node));
2430 Write_Str (" is");
2431 Sprint_Indented_List (Declarations (Node));
2432 Write_Indent_Str ("begin");
2433 Sprint_Node (Handled_Statement_Sequence (Node));
2434 Write_Indent_Str ("end ");
2435 Write_Id (Defining_Identifier (Node));
2436 Write_Char (';');
2438 when N_Task_Body_Stub =>
2439 Write_Indent_Str_Sloc ("task body ");
2440 Write_Id (Defining_Identifier (Node));
2441 Write_Str_With_Col_Check (" is separate;");
2443 when N_Task_Definition =>
2444 Set_Debug_Sloc;
2445 Sprint_Indented_List (Visible_Declarations (Node));
2447 if Present (Private_Declarations (Node)) then
2448 Write_Indent_Str ("private");
2449 Sprint_Indented_List (Private_Declarations (Node));
2450 end if;
2452 Write_Indent_Str ("end ");
2454 when N_Task_Type_Declaration =>
2455 Write_Indent_Str_Sloc ("task type ");
2456 Write_Id (Defining_Identifier (Node));
2457 Write_Discr_Specs (Node);
2459 if Present (Task_Definition (Node)) then
2460 Write_Str (" is");
2461 Sprint_Node (Task_Definition (Node));
2462 Write_Id (Defining_Identifier (Node));
2463 end if;
2465 Write_Char (';');
2467 when N_Terminate_Alternative =>
2468 Sprint_Node_List (Pragmas_Before (Node));
2470 Write_Indent;
2472 if Present (Condition (Node)) then
2473 Write_Str_With_Col_Check ("when ");
2474 Sprint_Node (Condition (Node));
2475 Write_Str (" => ");
2476 end if;
2478 Write_Str_With_Col_Check_Sloc ("terminate;");
2479 Sprint_Node_List (Pragmas_After (Node));
2481 when N_Timed_Entry_Call =>
2482 Write_Indent_Str_Sloc ("select");
2483 Indent_Begin;
2484 Sprint_Node (Entry_Call_Alternative (Node));
2485 Indent_End;
2486 Write_Indent_Str ("or");
2487 Indent_Begin;
2488 Sprint_Node (Delay_Alternative (Node));
2489 Indent_End;
2490 Write_Indent_Str ("end select;");
2492 when N_Triggering_Alternative =>
2493 Sprint_Node_List (Pragmas_Before (Node));
2494 Sprint_Node_Sloc (Triggering_Statement (Node));
2495 Sprint_Node_List (Statements (Node));
2497 when N_Type_Conversion =>
2498 Set_Debug_Sloc;
2499 Sprint_Node (Subtype_Mark (Node));
2500 Col_Check (4);
2502 if Conversion_OK (Node) then
2503 Write_Char ('?');
2504 end if;
2506 if Float_Truncate (Node) then
2507 Write_Char ('^');
2508 end if;
2510 if Rounded_Result (Node) then
2511 Write_Char ('@');
2512 end if;
2514 Write_Char ('(');
2515 Sprint_Node (Expression (Node));
2516 Write_Char (')');
2518 when N_Unchecked_Expression =>
2519 Col_Check (10);
2520 Write_Str ("`(");
2521 Sprint_Node_Sloc (Expression (Node));
2522 Write_Char (')');
2524 when N_Unchecked_Type_Conversion =>
2525 Sprint_Node (Subtype_Mark (Node));
2526 Write_Char ('!');
2527 Write_Str_With_Col_Check ("(");
2528 Sprint_Node_Sloc (Expression (Node));
2529 Write_Char (')');
2531 when N_Unconstrained_Array_Definition =>
2532 Write_Str_With_Col_Check_Sloc ("array (");
2534 declare
2535 Node1 : Node_Id;
2537 begin
2538 Node1 := First (Subtype_Marks (Node));
2539 loop
2540 Sprint_Node (Node1);
2541 Write_Str_With_Col_Check (" range <>");
2542 Next (Node1);
2543 exit when Node1 = Empty;
2544 Write_Str (", ");
2545 end loop;
2546 end;
2548 Write_Str (") of ");
2549 Sprint_Node (Component_Definition (Node));
2551 when N_Unused_At_Start | N_Unused_At_End =>
2552 Write_Indent_Str ("***** Error, unused node encountered *****");
2553 Write_Eol;
2555 when N_Use_Package_Clause =>
2556 Write_Indent_Str_Sloc ("use ");
2557 Sprint_Comma_List (Names (Node));
2558 Write_Char (';');
2560 when N_Use_Type_Clause =>
2561 Write_Indent_Str_Sloc ("use type ");
2562 Sprint_Comma_List (Subtype_Marks (Node));
2563 Write_Char (';');
2565 when N_Validate_Unchecked_Conversion =>
2566 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2567 Sprint_Node (Source_Type (Node));
2568 Write_Str (", ");
2569 Sprint_Node (Target_Type (Node));
2570 Write_Str (");");
2572 when N_Variant =>
2573 Write_Indent_Str_Sloc ("when ");
2574 Sprint_Bar_List (Discrete_Choices (Node));
2575 Write_Str (" => ");
2576 Sprint_Node (Component_List (Node));
2578 when N_Variant_Part =>
2579 Indent_Begin;
2580 Write_Indent_Str_Sloc ("case ");
2581 Sprint_Node (Name (Node));
2582 Write_Str (" is ");
2583 Sprint_Indented_List (Variants (Node));
2584 Write_Indent_Str ("end case");
2585 Indent_End;
2587 when N_With_Clause =>
2589 -- Special test, if we are dumping the original tree only,
2590 -- then we want to eliminate the bogus with clauses that
2591 -- correspond to the non-existent children of Text_IO.
2593 if Dump_Original_Only
2594 and then Is_Text_IO_Kludge_Unit (Name (Node))
2595 then
2596 null;
2598 -- Normal case, output the with clause
2600 else
2601 if First_Name (Node) or else not Dump_Original_Only then
2603 -- Ada 2005 (AI-50217): Print limited with_clauses
2605 if Private_Present (Node) and Limited_Present (Node) then
2606 Write_Indent_Str ("limited private with ");
2608 elsif Private_Present (Node) then
2609 Write_Indent_Str ("private with ");
2611 elsif Limited_Present (Node) then
2612 Write_Indent_Str ("limited with ");
2614 else
2615 Write_Indent_Str ("with ");
2616 end if;
2618 else
2619 Write_Str (", ");
2620 end if;
2622 Sprint_Node_Sloc (Name (Node));
2624 if Last_Name (Node) or else not Dump_Original_Only then
2625 Write_Char (';');
2626 end if;
2627 end if;
2629 when N_With_Type_Clause =>
2630 Write_Indent_Str ("with type ");
2631 Sprint_Node_Sloc (Name (Node));
2633 if Tagged_Present (Node) then
2634 Write_Str (" is tagged;");
2635 else
2636 Write_Str (" is access;");
2637 end if;
2639 end case;
2641 if Nkind (Node) in N_Subexpr
2642 and then Do_Range_Check (Node)
2643 then
2644 Write_Str ("}");
2645 end if;
2647 for J in 1 .. Paren_Count (Node) loop
2648 Write_Char (')');
2649 end loop;
2651 pragma Assert (No (Debug_Node));
2652 Debug_Node := Save_Debug_Node;
2653 end Sprint_Node_Actual;
2655 ----------------------
2656 -- Sprint_Node_List --
2657 ----------------------
2659 procedure Sprint_Node_List (List : List_Id) is
2660 Node : Node_Id;
2662 begin
2663 if Is_Non_Empty_List (List) then
2664 Node := First (List);
2666 loop
2667 Sprint_Node (Node);
2668 Next (Node);
2669 exit when Node = Empty;
2670 end loop;
2671 end if;
2672 end Sprint_Node_List;
2674 ----------------------
2675 -- Sprint_Node_Sloc --
2676 ----------------------
2678 procedure Sprint_Node_Sloc (Node : Node_Id) is
2679 begin
2680 Sprint_Node (Node);
2682 if Present (Debug_Node) then
2683 Set_Sloc (Debug_Node, Sloc (Node));
2684 Debug_Node := Empty;
2685 end if;
2686 end Sprint_Node_Sloc;
2688 ---------------------
2689 -- Sprint_Opt_Node --
2690 ---------------------
2692 procedure Sprint_Opt_Node (Node : Node_Id) is
2693 begin
2694 if Present (Node) then
2695 Write_Char (' ');
2696 Sprint_Node (Node);
2697 end if;
2698 end Sprint_Opt_Node;
2700 --------------------------
2701 -- Sprint_Opt_Node_List --
2702 --------------------------
2704 procedure Sprint_Opt_Node_List (List : List_Id) is
2705 begin
2706 if Present (List) then
2707 Sprint_Node_List (List);
2708 end if;
2709 end Sprint_Opt_Node_List;
2711 ---------------------------------
2712 -- Sprint_Opt_Paren_Comma_List --
2713 ---------------------------------
2715 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2716 begin
2717 if Is_Non_Empty_List (List) then
2718 Write_Char (' ');
2719 Sprint_Paren_Comma_List (List);
2720 end if;
2721 end Sprint_Opt_Paren_Comma_List;
2723 -----------------------------
2724 -- Sprint_Paren_Comma_List --
2725 -----------------------------
2727 procedure Sprint_Paren_Comma_List (List : List_Id) is
2728 N : Node_Id;
2729 Node_Exists : Boolean := False;
2731 begin
2733 if Is_Non_Empty_List (List) then
2735 if Dump_Original_Only then
2736 N := First (List);
2738 while Present (N) loop
2740 if not Is_Rewrite_Insertion (N) then
2741 Node_Exists := True;
2742 exit;
2743 end if;
2745 Next (N);
2746 end loop;
2748 if not Node_Exists then
2749 return;
2750 end if;
2751 end if;
2753 Write_Str_With_Col_Check ("(");
2754 Sprint_Comma_List (List);
2755 Write_Char (')');
2756 end if;
2757 end Sprint_Paren_Comma_List;
2759 ----------------------
2760 -- Sprint_Right_Opnd --
2761 ----------------------
2763 procedure Sprint_Right_Opnd (N : Node_Id) is
2764 Opnd : constant Node_Id := Right_Opnd (N);
2766 begin
2767 if Paren_Count (Opnd) /= 0
2768 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2769 then
2770 Sprint_Node (Opnd);
2772 else
2773 Write_Char ('(');
2774 Sprint_Node (Opnd);
2775 Write_Char (')');
2776 end if;
2777 end Sprint_Right_Opnd;
2779 ---------------------
2780 -- Write_Char_Sloc --
2781 ---------------------
2783 procedure Write_Char_Sloc (C : Character) is
2784 begin
2785 if Debug_Generated_Code and then C /= ' ' then
2786 Set_Debug_Sloc;
2787 end if;
2789 Write_Char (C);
2790 end Write_Char_Sloc;
2792 --------------------------------
2793 -- Write_Condition_And_Reason --
2794 --------------------------------
2796 procedure Write_Condition_And_Reason (Node : Node_Id) is
2797 Image : constant String := RT_Exception_Code'Image
2798 (RT_Exception_Code'Val
2799 (UI_To_Int (Reason (Node))));
2801 begin
2802 if Present (Condition (Node)) then
2803 Write_Str_With_Col_Check (" when ");
2804 Sprint_Node (Condition (Node));
2805 end if;
2807 Write_Str (" """);
2809 for J in 4 .. Image'Last loop
2810 if Image (J) = '_' then
2811 Write_Char (' ');
2812 else
2813 Write_Char (Fold_Lower (Image (J)));
2814 end if;
2815 end loop;
2817 Write_Str ("""]");
2818 end Write_Condition_And_Reason;
2820 -----------------------
2821 -- Write_Discr_Specs --
2822 -----------------------
2824 procedure Write_Discr_Specs (N : Node_Id) is
2825 Specs : List_Id;
2826 Spec : Node_Id;
2828 begin
2829 Specs := Discriminant_Specifications (N);
2831 if Present (Specs) then
2832 Write_Str_With_Col_Check (" (");
2833 Spec := First (Specs);
2835 loop
2836 Sprint_Node (Spec);
2837 Next (Spec);
2838 exit when Spec = Empty;
2840 -- Add semicolon, unless we are printing original tree and the
2841 -- next specification is part of a list (but not the first
2842 -- element of that list)
2844 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2845 Write_Str ("; ");
2846 end if;
2847 end loop;
2849 Write_Char (')');
2850 end if;
2851 end Write_Discr_Specs;
2853 -----------------
2854 -- Write_Ekind --
2855 -----------------
2857 procedure Write_Ekind (E : Entity_Id) is
2858 S : constant String := Entity_Kind'Image (Ekind (E));
2860 begin
2861 Name_Len := S'Length;
2862 Name_Buffer (1 .. Name_Len) := S;
2863 Set_Casing (Mixed_Case);
2864 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2865 end Write_Ekind;
2867 --------------
2868 -- Write_Id --
2869 --------------
2871 procedure Write_Id (N : Node_Id) is
2872 begin
2873 -- Case of a defining identifier
2875 if Nkind (N) = N_Defining_Identifier then
2877 -- If defining identifier has an interface name (and no
2878 -- address clause), then we output the interface name.
2880 if (Is_Imported (N) or else Is_Exported (N))
2881 and then Present (Interface_Name (N))
2882 and then No (Address_Clause (N))
2883 then
2884 String_To_Name_Buffer (Strval (Interface_Name (N)));
2885 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2887 -- If no interface name (or inactive because there was
2888 -- an address clause), then just output the Chars name.
2890 else
2891 Write_Name_With_Col_Check (Chars (N));
2892 end if;
2894 -- Case of selector of an expanded name where the expanded name
2895 -- has an associated entity, output this entity.
2897 elsif Nkind (Parent (N)) = N_Expanded_Name
2898 and then Selector_Name (Parent (N)) = N
2899 and then Present (Entity (Parent (N)))
2900 then
2901 Write_Id (Entity (Parent (N)));
2903 -- For any other node with an associated entity, output it
2905 elsif Nkind (N) in N_Has_Entity
2906 and then Present (Entity_Or_Associated_Node (N))
2907 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2908 then
2909 Write_Id (Entity (N));
2911 -- All other cases, we just print the Chars field
2913 else
2914 Write_Name_With_Col_Check (Chars (N));
2915 end if;
2916 end Write_Id;
2918 -----------------------
2919 -- Write_Identifiers --
2920 -----------------------
2922 function Write_Identifiers (Node : Node_Id) return Boolean is
2923 begin
2924 Sprint_Node (Defining_Identifier (Node));
2926 -- The remainder of the declaration must be printed unless we are
2927 -- printing the original tree and this is not the last identifier
2929 return
2930 not Dump_Original_Only or else not More_Ids (Node);
2932 end Write_Identifiers;
2934 ------------------------
2935 -- Write_Implicit_Def --
2936 ------------------------
2938 procedure Write_Implicit_Def (E : Entity_Id) is
2939 Ind : Node_Id;
2941 begin
2942 case Ekind (E) is
2943 when E_Array_Subtype =>
2944 Write_Str_With_Col_Check ("subtype ");
2945 Write_Id (E);
2946 Write_Str_With_Col_Check (" is ");
2947 Write_Id (Base_Type (E));
2948 Write_Str_With_Col_Check (" (");
2950 Ind := First_Index (E);
2952 while Present (Ind) loop
2953 Sprint_Node (Ind);
2954 Next_Index (Ind);
2956 if Present (Ind) then
2957 Write_Str (", ");
2958 end if;
2959 end loop;
2961 Write_Str (");");
2963 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2964 Write_Str_With_Col_Check ("subtype ");
2965 Write_Id (E);
2966 Write_Str (" is ");
2967 Write_Id (Etype (E));
2968 Write_Str_With_Col_Check (" range ");
2969 Sprint_Node (Scalar_Range (E));
2970 Write_Str (";");
2972 when others =>
2973 Write_Str_With_Col_Check ("type ");
2974 Write_Id (E);
2975 Write_Str_With_Col_Check (" is <");
2976 Write_Ekind (E);
2977 Write_Str (">;");
2978 end case;
2980 end Write_Implicit_Def;
2982 ------------------
2983 -- Write_Indent --
2984 ------------------
2986 procedure Write_Indent is
2987 begin
2988 if Indent_Annull_Flag then
2989 Indent_Annull_Flag := False;
2990 else
2991 Write_Eol;
2993 for J in 1 .. Indent loop
2994 Write_Char (' ');
2995 end loop;
2996 end if;
2997 end Write_Indent;
2999 ------------------------------
3000 -- Write_Indent_Identifiers --
3001 ------------------------------
3003 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3004 begin
3005 -- We need to start a new line for every node, except in the case
3006 -- where we are printing the original tree and this is not the first
3007 -- defining identifier in the list.
3009 if not Dump_Original_Only or else not Prev_Ids (Node) then
3010 Write_Indent;
3012 -- If printing original tree and this is not the first defining
3013 -- identifier in the list, then the previous call to this procedure
3014 -- printed only the name, and we add a comma to separate the names.
3016 else
3017 Write_Str (", ");
3018 end if;
3020 Sprint_Node (Defining_Identifier (Node));
3022 -- The remainder of the declaration must be printed unless we are
3023 -- printing the original tree and this is not the last identifier
3025 return
3026 not Dump_Original_Only or else not More_Ids (Node);
3028 end Write_Indent_Identifiers;
3030 -----------------------------------
3031 -- Write_Indent_Identifiers_Sloc --
3032 -----------------------------------
3034 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3035 begin
3036 -- We need to start a new line for every node, except in the case
3037 -- where we are printing the original tree and this is not the first
3038 -- defining identifier in the list.
3040 if not Dump_Original_Only or else not Prev_Ids (Node) then
3041 Write_Indent;
3043 -- If printing original tree and this is not the first defining
3044 -- identifier in the list, then the previous call to this procedure
3045 -- printed only the name, and we add a comma to separate the names.
3047 else
3048 Write_Str (", ");
3049 end if;
3051 Set_Debug_Sloc;
3052 Sprint_Node (Defining_Identifier (Node));
3054 -- The remainder of the declaration must be printed unless we are
3055 -- printing the original tree and this is not the last identifier
3057 return
3058 not Dump_Original_Only or else not More_Ids (Node);
3060 end Write_Indent_Identifiers_Sloc;
3062 ----------------------
3063 -- Write_Indent_Str --
3064 ----------------------
3066 procedure Write_Indent_Str (S : String) is
3067 begin
3068 Write_Indent;
3069 Write_Str (S);
3070 end Write_Indent_Str;
3072 ---------------------------
3073 -- Write_Indent_Str_Sloc --
3074 ---------------------------
3076 procedure Write_Indent_Str_Sloc (S : String) is
3077 begin
3078 Write_Indent;
3079 Write_Str_Sloc (S);
3080 end Write_Indent_Str_Sloc;
3082 -------------------------------
3083 -- Write_Name_With_Col_Check --
3084 -------------------------------
3086 procedure Write_Name_With_Col_Check (N : Name_Id) is
3087 J : Natural;
3089 begin
3090 Get_Name_String (N);
3092 -- Deal with -gnatI which replaces digits in an internal
3093 -- name by three dots (e.g. R7b becomes R...b).
3095 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3097 J := 2;
3098 while J < Name_Len loop
3099 exit when Name_Buffer (J) not in 'A' .. 'Z';
3100 J := J + 1;
3101 end loop;
3103 if Name_Buffer (J) in '0' .. '9' then
3104 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3105 Write_Str ("...");
3107 while J <= Name_Len loop
3108 if Name_Buffer (J) not in '0' .. '9' then
3109 Write_Str (Name_Buffer (J .. Name_Len));
3110 exit;
3112 else
3113 J := J + 1;
3114 end if;
3115 end loop;
3117 return;
3118 end if;
3119 end if;
3121 -- Fall through for normal case
3123 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3124 end Write_Name_With_Col_Check;
3126 ------------------------------------
3127 -- Write_Name_With_Col_Check_Sloc --
3128 ------------------------------------
3130 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3131 begin
3132 Get_Name_String (N);
3133 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3134 end Write_Name_With_Col_Check_Sloc;
3136 --------------------
3137 -- Write_Operator --
3138 --------------------
3140 procedure Write_Operator (N : Node_Id; S : String) is
3141 F : Natural := S'First;
3142 T : Natural := S'Last;
3144 begin
3145 -- If no overflow check, just write string out, and we are done
3147 if not Do_Overflow_Check (N) then
3148 Write_Str_Sloc (S);
3150 -- If overflow check, we want to surround the operator with curly
3151 -- brackets, but not include spaces within the brackets.
3153 else
3154 if S (F) = ' ' then
3155 Write_Char (' ');
3156 F := F + 1;
3157 end if;
3159 if S (T) = ' ' then
3160 T := T - 1;
3161 end if;
3163 Write_Char ('{');
3164 Write_Str_Sloc (S (F .. T));
3165 Write_Char ('}');
3167 if S (S'Last) = ' ' then
3168 Write_Char (' ');
3169 end if;
3170 end if;
3171 end Write_Operator;
3173 -----------------------
3174 -- Write_Param_Specs --
3175 -----------------------
3177 procedure Write_Param_Specs (N : Node_Id) is
3178 Specs : List_Id;
3179 Spec : Node_Id;
3180 Formal : Node_Id;
3182 begin
3183 Specs := Parameter_Specifications (N);
3185 if Is_Non_Empty_List (Specs) then
3186 Write_Str_With_Col_Check (" (");
3187 Spec := First (Specs);
3189 loop
3190 Sprint_Node (Spec);
3191 Formal := Defining_Identifier (Spec);
3192 Next (Spec);
3193 exit when Spec = Empty;
3195 -- Add semicolon, unless we are printing original tree and the
3196 -- next specification is part of a list (but not the first
3197 -- element of that list)
3199 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3200 Write_Str ("; ");
3201 end if;
3202 end loop;
3204 -- Write out any extra formals
3206 while Present (Extra_Formal (Formal)) loop
3207 Formal := Extra_Formal (Formal);
3208 Write_Str ("; ");
3209 Write_Name_With_Col_Check (Chars (Formal));
3210 Write_Str (" : ");
3211 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3212 end loop;
3214 Write_Char (')');
3215 end if;
3216 end Write_Param_Specs;
3218 --------------------------
3219 -- Write_Rewrite_Str --
3220 --------------------------
3222 procedure Write_Rewrite_Str (S : String) is
3223 begin
3224 if not Dump_Generated_Only then
3225 if S'Length = 3 and then S = ">>>" then
3226 Write_Str (">>>");
3227 else
3228 Write_Str_With_Col_Check (S);
3229 end if;
3230 end if;
3231 end Write_Rewrite_Str;
3233 --------------------
3234 -- Write_Str_Sloc --
3235 --------------------
3237 procedure Write_Str_Sloc (S : String) is
3238 begin
3239 for J in S'Range loop
3240 Write_Char_Sloc (S (J));
3241 end loop;
3242 end Write_Str_Sloc;
3244 ------------------------------
3245 -- Write_Str_With_Col_Check --
3246 ------------------------------
3248 procedure Write_Str_With_Col_Check (S : String) is
3249 begin
3250 if Int (S'Last) + Column > Line_Limit then
3251 Write_Indent_Str (" ");
3253 if S (1) = ' ' then
3254 Write_Str (S (2 .. S'Length));
3255 else
3256 Write_Str (S);
3257 end if;
3259 else
3260 Write_Str (S);
3261 end if;
3262 end Write_Str_With_Col_Check;
3264 -----------------------------------
3265 -- Write_Str_With_Col_Check_Sloc --
3266 -----------------------------------
3268 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3269 begin
3270 if Int (S'Last) + Column > Line_Limit then
3271 Write_Indent_Str (" ");
3273 if S (1) = ' ' then
3274 Write_Str_Sloc (S (2 .. S'Length));
3275 else
3276 Write_Str_Sloc (S);
3277 end if;
3279 else
3280 Write_Str_Sloc (S);
3281 end if;
3282 end Write_Str_With_Col_Check_Sloc;
3284 ------------------------------------
3285 -- Write_Uint_With_Col_Check_Sloc --
3286 ------------------------------------
3288 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3289 begin
3290 Col_Check (UI_Decimal_Digits_Hi (U));
3291 Set_Debug_Sloc;
3292 UI_Write (U, Format);
3293 end Write_Uint_With_Col_Check_Sloc;
3295 -------------------------------------
3296 -- Write_Ureal_With_Col_Check_Sloc --
3297 -------------------------------------
3299 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3300 D : constant Uint := Denominator (U);
3301 N : constant Uint := Numerator (U);
3303 begin
3304 Col_Check
3305 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3306 Set_Debug_Sloc;
3307 UR_Write (U);
3308 end Write_Ureal_With_Col_Check_Sloc;
3310 end Sprint;