* config/arm/elf.h (ASM_OUTPUT_ALIGNED_COMMON): Remove definition.
[official-gcc.git] / gcc / ada / sprint.adb
blob4d1b4a4ac0b86a8a2b673e10317825a35bff76f3
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-2002, 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_Gnerated_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 : 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 -- Output 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 =>
695 Write_Str_With_Col_Check_Sloc ("access ");
696 Sprint_Node (Subtype_Mark (Node));
698 when N_Access_Function_Definition =>
699 Write_Str_With_Col_Check_Sloc ("access ");
701 if Protected_Present (Node) then
702 Write_Str_With_Col_Check ("protected ");
703 end if;
705 Write_Str_With_Col_Check ("function");
706 Write_Param_Specs (Node);
707 Write_Str_With_Col_Check (" return ");
708 Sprint_Node (Subtype_Mark (Node));
710 when N_Access_Procedure_Definition =>
711 Write_Str_With_Col_Check_Sloc ("access ");
713 if Protected_Present (Node) then
714 Write_Str_With_Col_Check ("protected ");
715 end if;
717 Write_Str_With_Col_Check ("procedure");
718 Write_Param_Specs (Node);
720 when N_Access_To_Object_Definition =>
721 Write_Str_With_Col_Check_Sloc ("access ");
723 if All_Present (Node) then
724 Write_Str_With_Col_Check ("all ");
725 elsif Constant_Present (Node) then
726 Write_Str_With_Col_Check ("constant ");
727 end if;
729 Sprint_Node (Subtype_Indication (Node));
731 when N_Aggregate =>
732 if Null_Record_Present (Node) then
733 Write_Str_With_Col_Check_Sloc ("(null record)");
735 else
736 Write_Str_With_Col_Check_Sloc ("(");
738 if Present (Expressions (Node)) then
739 Sprint_Comma_List (Expressions (Node));
741 if Present (Component_Associations (Node)) then
742 Write_Str (", ");
743 end if;
744 end if;
746 if Present (Component_Associations (Node)) then
747 Indent_Begin;
749 declare
750 Nd : Node_Id;
752 begin
753 Nd := First (Component_Associations (Node));
755 loop
756 Write_Indent;
757 Sprint_Node (Nd);
758 Next (Nd);
759 exit when No (Nd);
761 if not Is_Rewrite_Insertion (Nd)
762 or else not Dump_Original_Only
763 then
764 Write_Str (", ");
765 end if;
766 end loop;
767 end;
769 Indent_End;
770 end if;
772 Write_Char (')');
773 end if;
775 when N_Allocator =>
776 Write_Str_With_Col_Check_Sloc ("new ");
777 Sprint_Node (Expression (Node));
779 if Present (Storage_Pool (Node)) then
780 Write_Str_With_Col_Check ("[storage_pool = ");
781 Sprint_Node (Storage_Pool (Node));
782 Write_Char (']');
783 end if;
785 when N_And_Then =>
786 Sprint_Left_Opnd (Node);
787 Write_Str_Sloc (" and then ");
788 Sprint_Right_Opnd (Node);
790 when N_At_Clause =>
791 Write_Indent_Str_Sloc ("for ");
792 Write_Id (Identifier (Node));
793 Write_Str_With_Col_Check (" use at ");
794 Sprint_Node (Expression (Node));
795 Write_Char (';');
797 when N_Assignment_Statement =>
798 Write_Indent;
799 Sprint_Node (Name (Node));
800 Write_Str_Sloc (" := ");
801 Sprint_Node (Expression (Node));
802 Write_Char (';');
804 when N_Asynchronous_Select =>
805 Write_Indent_Str_Sloc ("select");
806 Indent_Begin;
807 Sprint_Node (Triggering_Alternative (Node));
808 Indent_End;
810 -- Note: let the printing of Abortable_Part handle outputting
811 -- the ABORT keyword, so that the Slco can be set correctly.
813 Write_Indent_Str ("then ");
814 Sprint_Node (Abortable_Part (Node));
815 Write_Indent_Str ("end select;");
817 when N_Attribute_Definition_Clause =>
818 Write_Indent_Str_Sloc ("for ");
819 Sprint_Node (Name (Node));
820 Write_Char (''');
821 Write_Name_With_Col_Check (Chars (Node));
822 Write_Str_With_Col_Check (" use ");
823 Sprint_Node (Expression (Node));
824 Write_Char (';');
826 when N_Attribute_Reference =>
827 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
828 Write_Indent;
829 end if;
831 Sprint_Node (Prefix (Node));
832 Write_Char_Sloc (''');
833 Write_Name_With_Col_Check (Attribute_Name (Node));
834 Sprint_Paren_Comma_List (Expressions (Node));
836 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
837 Write_Char (';');
838 end if;
840 when N_Block_Statement =>
841 Write_Indent;
843 if Present (Identifier (Node))
844 and then (not Has_Created_Identifier (Node)
845 or else not Dump_Original_Only)
846 then
847 Write_Rewrite_Str ("<<<");
848 Write_Id (Identifier (Node));
849 Write_Str (" : ");
850 Write_Rewrite_Str (">>>");
851 end if;
853 if Present (Declarations (Node)) then
854 Write_Str_With_Col_Check_Sloc ("declare");
855 Sprint_Indented_List (Declarations (Node));
856 Write_Indent;
857 end if;
859 Write_Str_With_Col_Check_Sloc ("begin");
860 Sprint_Node (Handled_Statement_Sequence (Node));
861 Write_Indent_Str ("end");
863 if Present (Identifier (Node))
864 and then (not Has_Created_Identifier (Node)
865 or else not Dump_Original_Only)
866 then
867 Write_Rewrite_Str ("<<<");
868 Write_Char (' ');
869 Write_Id (Identifier (Node));
870 Write_Rewrite_Str (">>>");
871 end if;
873 Write_Char (';');
875 when N_Case_Statement =>
876 Write_Indent_Str_Sloc ("case ");
877 Sprint_Node (Expression (Node));
878 Write_Str (" is");
879 Sprint_Indented_List (Alternatives (Node));
880 Write_Indent_Str ("end case;");
882 when N_Case_Statement_Alternative =>
883 Write_Indent_Str_Sloc ("when ");
884 Sprint_Bar_List (Discrete_Choices (Node));
885 Write_Str (" => ");
886 Sprint_Indented_List (Statements (Node));
888 when N_Character_Literal =>
889 if Column > 70 then
890 Write_Indent_Str (" ");
891 end if;
893 Write_Char_Sloc (''');
894 Write_Char_Code (Char_Literal_Value (Node));
895 Write_Char (''');
897 when N_Code_Statement =>
898 Write_Indent;
899 Set_Debug_Sloc;
900 Sprint_Node (Expression (Node));
901 Write_Char (';');
903 when N_Compilation_Unit =>
904 Sprint_Node_List (Context_Items (Node));
905 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
907 if Private_Present (Node) then
908 Write_Indent_Str ("private ");
909 Indent_Annull;
910 end if;
912 Sprint_Node_Sloc (Unit (Node));
914 if Present (Actions (Aux_Decls_Node (Node)))
915 or else
916 Present (Pragmas_After (Aux_Decls_Node (Node)))
917 then
918 Write_Indent;
919 end if;
921 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
922 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
924 when N_Compilation_Unit_Aux =>
925 null; -- nothing to do, never used, see above
927 when N_Component_Association =>
928 Set_Debug_Sloc;
929 Sprint_Bar_List (Choices (Node));
930 Write_Str (" => ");
931 Sprint_Node (Expression (Node));
933 when N_Component_Clause =>
934 Write_Indent;
935 Sprint_Node (Component_Name (Node));
936 Write_Str_Sloc (" at ");
937 Sprint_Node (Position (Node));
938 Write_Char (' ');
939 Write_Str_With_Col_Check ("range ");
940 Sprint_Node (First_Bit (Node));
941 Write_Str (" .. ");
942 Sprint_Node (Last_Bit (Node));
943 Write_Char (';');
945 when N_Component_Declaration =>
946 if Write_Indent_Identifiers_Sloc (Node) then
947 Write_Str (" : ");
949 if Aliased_Present (Node) then
950 Write_Str_With_Col_Check ("aliased ");
951 end if;
953 Sprint_Node (Subtype_Indication (Node));
955 if Present (Expression (Node)) then
956 Write_Str (" := ");
957 Sprint_Node (Expression (Node));
958 end if;
960 Write_Char (';');
961 end if;
963 when N_Component_List =>
964 if Null_Present (Node) then
965 Indent_Begin;
966 Write_Indent_Str_Sloc ("null");
967 Write_Char (';');
968 Indent_End;
970 else
971 Set_Debug_Sloc;
972 Sprint_Indented_List (Component_Items (Node));
973 Sprint_Node (Variant_Part (Node));
974 end if;
976 when N_Conditional_Entry_Call =>
977 Write_Indent_Str_Sloc ("select");
978 Indent_Begin;
979 Sprint_Node (Entry_Call_Alternative (Node));
980 Indent_End;
981 Write_Indent_Str ("else");
982 Sprint_Indented_List (Else_Statements (Node));
983 Write_Indent_Str ("end select;");
985 when N_Conditional_Expression =>
986 declare
987 Condition : constant Node_Id := First (Expressions (Node));
988 Then_Expr : constant Node_Id := Next (Condition);
989 Else_Expr : constant Node_Id := Next (Then_Expr);
991 begin
992 Write_Str_With_Col_Check_Sloc ("(if ");
993 Sprint_Node (Condition);
994 Write_Str_With_Col_Check (" then ");
995 Sprint_Node (Then_Expr);
996 Write_Str_With_Col_Check (" else ");
997 Sprint_Node (Else_Expr);
998 Write_Char (')');
999 end;
1001 when N_Constrained_Array_Definition =>
1002 Write_Str_With_Col_Check_Sloc ("array ");
1003 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1004 Write_Str (" of ");
1006 if Aliased_Present (Node) then
1007 Write_Str_With_Col_Check ("aliased ");
1008 end if;
1010 Sprint_Node (Subtype_Indication (Node));
1012 when N_Decimal_Fixed_Point_Definition =>
1013 Write_Str_With_Col_Check_Sloc (" delta ");
1014 Sprint_Node (Delta_Expression (Node));
1015 Write_Str_With_Col_Check ("digits ");
1016 Sprint_Node (Digits_Expression (Node));
1017 Sprint_Opt_Node (Real_Range_Specification (Node));
1019 when N_Defining_Character_Literal =>
1020 Write_Name_With_Col_Check_Sloc (Chars (Node));
1022 when N_Defining_Identifier =>
1023 Set_Debug_Sloc;
1024 Write_Id (Node);
1026 when N_Defining_Operator_Symbol =>
1027 Write_Name_With_Col_Check_Sloc (Chars (Node));
1029 when N_Defining_Program_Unit_Name =>
1030 Set_Debug_Sloc;
1031 Sprint_Node (Name (Node));
1032 Write_Char ('.');
1033 Write_Id (Defining_Identifier (Node));
1035 when N_Delay_Alternative =>
1036 Sprint_Node_List (Pragmas_Before (Node));
1038 if Present (Condition (Node)) then
1039 Write_Indent;
1040 Write_Str_With_Col_Check ("when ");
1041 Sprint_Node (Condition (Node));
1042 Write_Str (" => ");
1043 Indent_Annull;
1044 end if;
1046 Sprint_Node_Sloc (Delay_Statement (Node));
1047 Sprint_Node_List (Statements (Node));
1049 when N_Delay_Relative_Statement =>
1050 Write_Indent_Str_Sloc ("delay ");
1051 Sprint_Node (Expression (Node));
1052 Write_Char (';');
1054 when N_Delay_Until_Statement =>
1055 Write_Indent_Str_Sloc ("delay until ");
1056 Sprint_Node (Expression (Node));
1057 Write_Char (';');
1059 when N_Delta_Constraint =>
1060 Write_Str_With_Col_Check_Sloc ("delta ");
1061 Sprint_Node (Delta_Expression (Node));
1062 Sprint_Opt_Node (Range_Constraint (Node));
1064 when N_Derived_Type_Definition =>
1065 if Abstract_Present (Node) then
1066 Write_Str_With_Col_Check ("abstract ");
1067 end if;
1069 Write_Str_With_Col_Check_Sloc ("new ");
1070 Sprint_Node (Subtype_Indication (Node));
1072 if Present (Record_Extension_Part (Node)) then
1073 Write_Str_With_Col_Check (" with ");
1074 Sprint_Node (Record_Extension_Part (Node));
1075 end if;
1077 when N_Designator =>
1078 Sprint_Node (Name (Node));
1079 Write_Char_Sloc ('.');
1080 Write_Id (Identifier (Node));
1082 when N_Digits_Constraint =>
1083 Write_Str_With_Col_Check_Sloc ("digits ");
1084 Sprint_Node (Digits_Expression (Node));
1085 Sprint_Opt_Node (Range_Constraint (Node));
1087 when N_Discriminant_Association =>
1088 Set_Debug_Sloc;
1090 if Present (Selector_Names (Node)) then
1091 Sprint_Bar_List (Selector_Names (Node));
1092 Write_Str (" => ");
1093 end if;
1095 Set_Debug_Sloc;
1096 Sprint_Node (Expression (Node));
1098 when N_Discriminant_Specification =>
1099 Set_Debug_Sloc;
1101 if Write_Identifiers (Node) then
1102 Write_Str (" : ");
1103 Sprint_Node (Discriminant_Type (Node));
1105 if Present (Expression (Node)) then
1106 Write_Str (" := ");
1107 Sprint_Node (Expression (Node));
1108 end if;
1109 else
1110 Write_Str (", ");
1111 end if;
1113 when N_Elsif_Part =>
1114 Write_Indent_Str_Sloc ("elsif ");
1115 Sprint_Node (Condition (Node));
1116 Write_Str_With_Col_Check (" then");
1117 Sprint_Indented_List (Then_Statements (Node));
1119 when N_Empty =>
1120 null;
1122 when N_Entry_Body =>
1123 Write_Indent_Str_Sloc ("entry ");
1124 Write_Id (Defining_Identifier (Node));
1125 Sprint_Node (Entry_Body_Formal_Part (Node));
1126 Write_Str_With_Col_Check (" is");
1127 Sprint_Indented_List (Declarations (Node));
1128 Write_Indent_Str ("begin");
1129 Sprint_Node (Handled_Statement_Sequence (Node));
1130 Write_Indent_Str ("end ");
1131 Write_Id (Defining_Identifier (Node));
1132 Write_Char (';');
1134 when N_Entry_Body_Formal_Part =>
1135 if Present (Entry_Index_Specification (Node)) then
1136 Write_Str_With_Col_Check_Sloc (" (");
1137 Sprint_Node (Entry_Index_Specification (Node));
1138 Write_Char (')');
1139 end if;
1141 Write_Param_Specs (Node);
1142 Write_Str_With_Col_Check_Sloc (" when ");
1143 Sprint_Node (Condition (Node));
1145 when N_Entry_Call_Alternative =>
1146 Sprint_Node_List (Pragmas_Before (Node));
1147 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1148 Sprint_Node_List (Statements (Node));
1150 when N_Entry_Call_Statement =>
1151 Write_Indent;
1152 Sprint_Node_Sloc (Name (Node));
1153 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1154 Write_Char (';');
1156 when N_Entry_Declaration =>
1157 Write_Indent_Str_Sloc ("entry ");
1158 Write_Id (Defining_Identifier (Node));
1160 if Present (Discrete_Subtype_Definition (Node)) then
1161 Write_Str_With_Col_Check (" (");
1162 Sprint_Node (Discrete_Subtype_Definition (Node));
1163 Write_Char (')');
1164 end if;
1166 Write_Param_Specs (Node);
1167 Write_Char (';');
1169 when N_Entry_Index_Specification =>
1170 Write_Str_With_Col_Check_Sloc ("for ");
1171 Write_Id (Defining_Identifier (Node));
1172 Write_Str_With_Col_Check (" in ");
1173 Sprint_Node (Discrete_Subtype_Definition (Node));
1175 when N_Enumeration_Representation_Clause =>
1176 Write_Indent_Str_Sloc ("for ");
1177 Write_Id (Identifier (Node));
1178 Write_Str_With_Col_Check (" use ");
1179 Sprint_Node (Array_Aggregate (Node));
1180 Write_Char (';');
1182 when N_Enumeration_Type_Definition =>
1183 Set_Debug_Sloc;
1185 -- Skip attempt to print Literals field if it's not there and
1186 -- we are in package Standard (case of Character, which is
1187 -- handled specially (without an explicit literals list).
1189 if Sloc (Node) > Standard_Location
1190 or else Present (Literals (Node))
1191 then
1192 Sprint_Paren_Comma_List (Literals (Node));
1193 end if;
1195 when N_Error =>
1196 Write_Str_With_Col_Check_Sloc ("<error>");
1198 when N_Exception_Declaration =>
1199 if Write_Indent_Identifiers (Node) then
1200 Write_Str_With_Col_Check (" : ");
1201 Write_Str_Sloc ("exception;");
1202 end if;
1204 when N_Exception_Handler =>
1205 Write_Indent_Str_Sloc ("when ");
1207 if Present (Choice_Parameter (Node)) then
1208 Sprint_Node (Choice_Parameter (Node));
1209 Write_Str (" : ");
1210 end if;
1212 Sprint_Bar_List (Exception_Choices (Node));
1213 Write_Str (" => ");
1214 Sprint_Indented_List (Statements (Node));
1216 when N_Exception_Renaming_Declaration =>
1217 Write_Indent;
1218 Set_Debug_Sloc;
1219 Sprint_Node (Defining_Identifier (Node));
1220 Write_Str_With_Col_Check (" : exception renames ");
1221 Sprint_Node (Name (Node));
1222 Write_Char (';');
1224 when N_Exit_Statement =>
1225 Write_Indent_Str_Sloc ("exit");
1226 Sprint_Opt_Node (Name (Node));
1228 if Present (Condition (Node)) then
1229 Write_Str_With_Col_Check (" when ");
1230 Sprint_Node (Condition (Node));
1231 end if;
1233 Write_Char (';');
1235 when N_Explicit_Dereference =>
1236 Sprint_Node (Prefix (Node));
1237 Write_Char ('.');
1238 Write_Str_Sloc ("all");
1240 when N_Extension_Aggregate =>
1241 Write_Str_With_Col_Check_Sloc ("(");
1242 Sprint_Node (Ancestor_Part (Node));
1243 Write_Str_With_Col_Check (" with ");
1245 if Null_Record_Present (Node) then
1246 Write_Str_With_Col_Check ("null record");
1247 else
1248 if Present (Expressions (Node)) then
1249 Sprint_Comma_List (Expressions (Node));
1251 if Present (Component_Associations (Node)) then
1252 Write_Str (", ");
1253 end if;
1254 end if;
1256 if Present (Component_Associations (Node)) then
1257 Sprint_Comma_List (Component_Associations (Node));
1258 end if;
1259 end if;
1261 Write_Char (')');
1263 when N_Floating_Point_Definition =>
1264 Write_Str_With_Col_Check_Sloc ("digits ");
1265 Sprint_Node (Digits_Expression (Node));
1266 Sprint_Opt_Node (Real_Range_Specification (Node));
1268 when N_Formal_Decimal_Fixed_Point_Definition =>
1269 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1271 when N_Formal_Derived_Type_Definition =>
1272 Write_Str_With_Col_Check_Sloc ("new ");
1273 Sprint_Node (Subtype_Mark (Node));
1275 if Private_Present (Node) then
1276 Write_Str_With_Col_Check (" with private");
1277 end if;
1279 when N_Formal_Discrete_Type_Definition =>
1280 Write_Str_With_Col_Check_Sloc ("<>");
1282 when N_Formal_Floating_Point_Definition =>
1283 Write_Str_With_Col_Check_Sloc ("digits <>");
1285 when N_Formal_Modular_Type_Definition =>
1286 Write_Str_With_Col_Check_Sloc ("mod <>");
1288 when N_Formal_Object_Declaration =>
1289 Set_Debug_Sloc;
1291 if Write_Indent_Identifiers (Node) then
1292 Write_Str (" : ");
1294 if In_Present (Node) then
1295 Write_Str_With_Col_Check ("in ");
1296 end if;
1298 if Out_Present (Node) then
1299 Write_Str_With_Col_Check ("out ");
1300 end if;
1302 Sprint_Node (Subtype_Mark (Node));
1304 if Present (Expression (Node)) then
1305 Write_Str (" := ");
1306 Sprint_Node (Expression (Node));
1307 end if;
1309 Write_Char (';');
1310 end if;
1312 when N_Formal_Ordinary_Fixed_Point_Definition =>
1313 Write_Str_With_Col_Check_Sloc ("delta <>");
1315 when N_Formal_Package_Declaration =>
1316 Write_Indent_Str_Sloc ("with package ");
1317 Write_Id (Defining_Identifier (Node));
1318 Write_Str_With_Col_Check (" is new ");
1319 Sprint_Node (Name (Node));
1320 Write_Str_With_Col_Check (" (<>);");
1322 when N_Formal_Private_Type_Definition =>
1323 if Abstract_Present (Node) then
1324 Write_Str_With_Col_Check ("abstract ");
1325 end if;
1327 if Tagged_Present (Node) then
1328 Write_Str_With_Col_Check ("tagged ");
1329 end if;
1331 if Limited_Present (Node) then
1332 Write_Str_With_Col_Check ("limited ");
1333 end if;
1335 Write_Str_With_Col_Check_Sloc ("private");
1337 when N_Formal_Signed_Integer_Type_Definition =>
1338 Write_Str_With_Col_Check_Sloc ("range <>");
1340 when N_Formal_Subprogram_Declaration =>
1341 Write_Indent_Str_Sloc ("with ");
1342 Sprint_Node (Specification (Node));
1344 if Box_Present (Node) then
1345 Write_Str_With_Col_Check (" is <>");
1346 elsif Present (Default_Name (Node)) then
1347 Write_Str_With_Col_Check (" is ");
1348 Sprint_Node (Default_Name (Node));
1349 end if;
1351 Write_Char (';');
1353 when N_Formal_Type_Declaration =>
1354 Write_Indent_Str_Sloc ("type ");
1355 Write_Id (Defining_Identifier (Node));
1357 if Present (Discriminant_Specifications (Node)) then
1358 Write_Discr_Specs (Node);
1359 elsif Unknown_Discriminants_Present (Node) then
1360 Write_Str_With_Col_Check ("(<>)");
1361 end if;
1363 Write_Str_With_Col_Check (" is ");
1364 Sprint_Node (Formal_Type_Definition (Node));
1365 Write_Char (';');
1367 when N_Free_Statement =>
1368 Write_Indent_Str_Sloc ("free ");
1369 Sprint_Node (Expression (Node));
1370 Write_Char (';');
1372 when N_Freeze_Entity =>
1373 if Dump_Original_Only then
1374 null;
1376 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1377 Write_Indent;
1378 Write_Rewrite_Str ("<<<");
1379 Write_Str_With_Col_Check_Sloc ("freeze ");
1380 Write_Id (Entity (Node));
1381 Write_Str (" [");
1383 if No (Actions (Node)) then
1384 Write_Char (']');
1386 else
1387 Freeze_Indent := Freeze_Indent + 1;
1388 Sprint_Indented_List (Actions (Node));
1389 Freeze_Indent := Freeze_Indent - 1;
1390 Write_Indent_Str ("]");
1391 end if;
1393 Write_Rewrite_Str (">>>");
1394 end if;
1396 when N_Full_Type_Declaration =>
1397 Write_Indent_Str_Sloc ("type ");
1398 Write_Id (Defining_Identifier (Node));
1399 Write_Discr_Specs (Node);
1400 Write_Str_With_Col_Check (" is ");
1401 Sprint_Node (Type_Definition (Node));
1402 Write_Char (';');
1404 when N_Function_Call =>
1405 Set_Debug_Sloc;
1406 Sprint_Node (Name (Node));
1407 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1409 when N_Function_Instantiation =>
1410 Write_Indent_Str_Sloc ("function ");
1411 Sprint_Node (Defining_Unit_Name (Node));
1412 Write_Str_With_Col_Check (" is new ");
1413 Sprint_Node (Name (Node));
1414 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1415 Write_Char (';');
1417 when N_Function_Specification =>
1418 Write_Str_With_Col_Check_Sloc ("function ");
1419 Sprint_Node (Defining_Unit_Name (Node));
1420 Write_Param_Specs (Node);
1421 Write_Str_With_Col_Check (" return ");
1422 Sprint_Node (Subtype_Mark (Node));
1424 when N_Generic_Association =>
1425 Set_Debug_Sloc;
1427 if Present (Selector_Name (Node)) then
1428 Sprint_Node (Selector_Name (Node));
1429 Write_Str (" => ");
1430 end if;
1432 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1434 when N_Generic_Function_Renaming_Declaration =>
1435 Write_Indent_Str_Sloc ("generic function ");
1436 Sprint_Node (Defining_Unit_Name (Node));
1437 Write_Str_With_Col_Check (" renames ");
1438 Sprint_Node (Name (Node));
1439 Write_Char (';');
1441 when N_Generic_Package_Declaration =>
1442 Write_Indent;
1443 Write_Indent_Str_Sloc ("generic ");
1444 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1445 Write_Indent;
1446 Sprint_Node (Specification (Node));
1447 Write_Char (';');
1449 when N_Generic_Package_Renaming_Declaration =>
1450 Write_Indent_Str_Sloc ("generic package ");
1451 Sprint_Node (Defining_Unit_Name (Node));
1452 Write_Str_With_Col_Check (" renames ");
1453 Sprint_Node (Name (Node));
1454 Write_Char (';');
1456 when N_Generic_Procedure_Renaming_Declaration =>
1457 Write_Indent_Str_Sloc ("generic procedure ");
1458 Sprint_Node (Defining_Unit_Name (Node));
1459 Write_Str_With_Col_Check (" renames ");
1460 Sprint_Node (Name (Node));
1461 Write_Char (';');
1463 when N_Generic_Subprogram_Declaration =>
1464 Write_Indent;
1465 Write_Indent_Str_Sloc ("generic ");
1466 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1467 Write_Indent;
1468 Sprint_Node (Specification (Node));
1469 Write_Char (';');
1471 when N_Goto_Statement =>
1472 Write_Indent_Str_Sloc ("goto ");
1473 Sprint_Node (Name (Node));
1474 Write_Char (';');
1476 if Nkind (Next (Node)) = N_Label then
1477 Write_Indent;
1478 end if;
1480 when N_Handled_Sequence_Of_Statements =>
1481 Set_Debug_Sloc;
1482 Sprint_Indented_List (Statements (Node));
1484 if Present (Exception_Handlers (Node)) then
1485 Write_Indent_Str ("exception");
1486 Indent_Begin;
1487 Sprint_Node_List (Exception_Handlers (Node));
1488 Indent_End;
1489 end if;
1491 if Present (At_End_Proc (Node)) then
1492 Write_Indent_Str ("at end");
1493 Indent_Begin;
1494 Write_Indent;
1495 Sprint_Node (At_End_Proc (Node));
1496 Write_Char (';');
1497 Indent_End;
1498 end if;
1500 when N_Identifier =>
1501 Set_Debug_Sloc;
1502 Write_Id (Node);
1504 when N_If_Statement =>
1505 Write_Indent_Str_Sloc ("if ");
1506 Sprint_Node (Condition (Node));
1507 Write_Str_With_Col_Check (" then");
1508 Sprint_Indented_List (Then_Statements (Node));
1509 Sprint_Opt_Node_List (Elsif_Parts (Node));
1511 if Present (Else_Statements (Node)) then
1512 Write_Indent_Str ("else");
1513 Sprint_Indented_List (Else_Statements (Node));
1514 end if;
1516 Write_Indent_Str ("end if;");
1518 when N_Implicit_Label_Declaration =>
1519 if not Dump_Original_Only then
1520 Write_Indent;
1521 Write_Rewrite_Str ("<<<");
1522 Set_Debug_Sloc;
1523 Write_Id (Defining_Identifier (Node));
1524 Write_Str (" : ");
1525 Write_Str_With_Col_Check ("label");
1526 Write_Rewrite_Str (">>>");
1527 end if;
1529 when N_In =>
1530 Sprint_Left_Opnd (Node);
1531 Write_Str_Sloc (" in ");
1532 Sprint_Right_Opnd (Node);
1534 when N_Incomplete_Type_Declaration =>
1535 Write_Indent_Str_Sloc ("type ");
1536 Write_Id (Defining_Identifier (Node));
1538 if Present (Discriminant_Specifications (Node)) then
1539 Write_Discr_Specs (Node);
1540 elsif Unknown_Discriminants_Present (Node) then
1541 Write_Str_With_Col_Check ("(<>)");
1542 end if;
1544 Write_Char (';');
1546 when N_Index_Or_Discriminant_Constraint =>
1547 Set_Debug_Sloc;
1548 Sprint_Paren_Comma_List (Constraints (Node));
1550 when N_Indexed_Component =>
1551 Sprint_Node_Sloc (Prefix (Node));
1552 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1554 when N_Integer_Literal =>
1555 if Print_In_Hex (Node) then
1556 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1557 else
1558 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1559 end if;
1561 when N_Iteration_Scheme =>
1562 if Present (Condition (Node)) then
1563 Write_Str_With_Col_Check_Sloc ("while ");
1564 Sprint_Node (Condition (Node));
1565 else
1566 Write_Str_With_Col_Check_Sloc ("for ");
1567 Sprint_Node (Loop_Parameter_Specification (Node));
1568 end if;
1570 Write_Char (' ');
1572 when N_Itype_Reference =>
1573 Write_Indent_Str_Sloc ("reference ");
1574 Write_Id (Itype (Node));
1576 when N_Label =>
1577 Write_Indent_Str_Sloc ("<<");
1578 Write_Id (Identifier (Node));
1579 Write_Str (">>");
1581 when N_Loop_Parameter_Specification =>
1582 Set_Debug_Sloc;
1583 Write_Id (Defining_Identifier (Node));
1584 Write_Str_With_Col_Check (" in ");
1586 if Reverse_Present (Node) then
1587 Write_Str_With_Col_Check ("reverse ");
1588 end if;
1590 Sprint_Node (Discrete_Subtype_Definition (Node));
1592 when N_Loop_Statement =>
1593 Write_Indent;
1595 if Present (Identifier (Node))
1596 and then (not Has_Created_Identifier (Node)
1597 or else not Dump_Original_Only)
1598 then
1599 Write_Rewrite_Str ("<<<");
1600 Write_Id (Identifier (Node));
1601 Write_Str (" : ");
1602 Write_Rewrite_Str (">>>");
1603 Sprint_Node (Iteration_Scheme (Node));
1604 Write_Str_With_Col_Check_Sloc ("loop");
1605 Sprint_Indented_List (Statements (Node));
1606 Write_Indent_Str ("end loop ");
1607 Write_Rewrite_Str ("<<<");
1608 Write_Id (Identifier (Node));
1609 Write_Rewrite_Str (">>>");
1610 Write_Char (';');
1612 else
1613 Sprint_Node (Iteration_Scheme (Node));
1614 Write_Str_With_Col_Check_Sloc ("loop");
1615 Sprint_Indented_List (Statements (Node));
1616 Write_Indent_Str ("end loop;");
1617 end if;
1619 when N_Mod_Clause =>
1620 Sprint_Node_List (Pragmas_Before (Node));
1621 Write_Str_With_Col_Check_Sloc ("at mod ");
1622 Sprint_Node (Expression (Node));
1624 when N_Modular_Type_Definition =>
1625 Write_Str_With_Col_Check_Sloc ("mod ");
1626 Sprint_Node (Expression (Node));
1628 when N_Not_In =>
1629 Sprint_Left_Opnd (Node);
1630 Write_Str_Sloc (" not in ");
1631 Sprint_Right_Opnd (Node);
1633 when N_Null =>
1634 Write_Str_With_Col_Check_Sloc ("null");
1636 when N_Null_Statement =>
1637 if Comes_From_Source (Node)
1638 or else Dump_Freeze_Null
1639 or else not Is_List_Member (Node)
1640 or else (No (Prev (Node)) and then No (Next (Node)))
1641 then
1642 Write_Indent_Str_Sloc ("null;");
1643 end if;
1645 when N_Number_Declaration =>
1646 Set_Debug_Sloc;
1648 if Write_Indent_Identifiers (Node) then
1649 Write_Str_With_Col_Check (" : constant ");
1650 Write_Str (" := ");
1651 Sprint_Node (Expression (Node));
1652 Write_Char (';');
1653 end if;
1655 when N_Object_Declaration =>
1657 -- Put extra blank line before and after if this is a handler
1658 -- record or a subprogram descriptor.
1660 declare
1661 Typ : constant Entity_Id := Etype (Defining_Identifier (Node));
1662 Exc : constant Boolean :=
1663 Is_RTE (Typ, RE_Handler_Record)
1664 or else
1665 Is_RTE (Typ, RE_Subprogram_Descriptor);
1667 begin
1668 if Exc then
1669 Write_Indent;
1670 end if;
1672 Set_Debug_Sloc;
1674 if Write_Indent_Identifiers (Node) then
1675 Write_Str (" : ");
1677 if Aliased_Present (Node) then
1678 Write_Str_With_Col_Check ("aliased ");
1679 end if;
1681 if Constant_Present (Node) then
1682 Write_Str_With_Col_Check ("constant ");
1683 end if;
1685 Sprint_Node (Object_Definition (Node));
1687 if Present (Expression (Node)) then
1688 Write_Str (" := ");
1689 Sprint_Node (Expression (Node));
1690 end if;
1692 Write_Char (';');
1693 end if;
1695 if Exc then
1696 Write_Indent;
1697 end if;
1698 end;
1700 when N_Object_Renaming_Declaration =>
1701 Write_Indent;
1702 Set_Debug_Sloc;
1703 Sprint_Node (Defining_Identifier (Node));
1704 Write_Str (" : ");
1705 Sprint_Node (Subtype_Mark (Node));
1706 Write_Str_With_Col_Check (" renames ");
1707 Sprint_Node (Name (Node));
1708 Write_Char (';');
1710 when N_Op_Abs =>
1711 Write_Operator (Node, "abs ");
1712 Sprint_Right_Opnd (Node);
1714 when N_Op_Add =>
1715 Sprint_Left_Opnd (Node);
1716 Write_Operator (Node, " + ");
1717 Sprint_Right_Opnd (Node);
1719 when N_Op_And =>
1720 Sprint_Left_Opnd (Node);
1721 Write_Operator (Node, " and ");
1722 Sprint_Right_Opnd (Node);
1724 when N_Op_Concat =>
1725 Sprint_Left_Opnd (Node);
1726 Write_Operator (Node, " & ");
1727 Sprint_Right_Opnd (Node);
1729 when N_Op_Divide =>
1730 Sprint_Left_Opnd (Node);
1731 Write_Char (' ');
1732 Process_TFAI_RR_Flags (Node);
1733 Write_Operator (Node, "/ ");
1734 Sprint_Right_Opnd (Node);
1736 when N_Op_Eq =>
1737 Sprint_Left_Opnd (Node);
1738 Write_Operator (Node, " = ");
1739 Sprint_Right_Opnd (Node);
1741 when N_Op_Expon =>
1742 Sprint_Left_Opnd (Node);
1743 Write_Operator (Node, " ** ");
1744 Sprint_Right_Opnd (Node);
1746 when N_Op_Ge =>
1747 Sprint_Left_Opnd (Node);
1748 Write_Operator (Node, " >= ");
1749 Sprint_Right_Opnd (Node);
1751 when N_Op_Gt =>
1752 Sprint_Left_Opnd (Node);
1753 Write_Operator (Node, " > ");
1754 Sprint_Right_Opnd (Node);
1756 when N_Op_Le =>
1757 Sprint_Left_Opnd (Node);
1758 Write_Operator (Node, " <= ");
1759 Sprint_Right_Opnd (Node);
1761 when N_Op_Lt =>
1762 Sprint_Left_Opnd (Node);
1763 Write_Operator (Node, " < ");
1764 Sprint_Right_Opnd (Node);
1766 when N_Op_Minus =>
1767 Write_Operator (Node, "-");
1768 Sprint_Right_Opnd (Node);
1770 when N_Op_Mod =>
1771 Sprint_Left_Opnd (Node);
1773 if Treat_Fixed_As_Integer (Node) then
1774 Write_Str (" #");
1775 end if;
1777 Write_Operator (Node, " mod ");
1778 Sprint_Right_Opnd (Node);
1780 when N_Op_Multiply =>
1781 Sprint_Left_Opnd (Node);
1782 Write_Char (' ');
1783 Process_TFAI_RR_Flags (Node);
1784 Write_Operator (Node, "* ");
1785 Sprint_Right_Opnd (Node);
1787 when N_Op_Ne =>
1788 Sprint_Left_Opnd (Node);
1789 Write_Operator (Node, " /= ");
1790 Sprint_Right_Opnd (Node);
1792 when N_Op_Not =>
1793 Write_Operator (Node, "not ");
1794 Sprint_Right_Opnd (Node);
1796 when N_Op_Or =>
1797 Sprint_Left_Opnd (Node);
1798 Write_Operator (Node, " or ");
1799 Sprint_Right_Opnd (Node);
1801 when N_Op_Plus =>
1802 Write_Operator (Node, "+");
1803 Sprint_Right_Opnd (Node);
1805 when N_Op_Rem =>
1806 Sprint_Left_Opnd (Node);
1808 if Treat_Fixed_As_Integer (Node) then
1809 Write_Str (" #");
1810 end if;
1812 Write_Operator (Node, " rem ");
1813 Sprint_Right_Opnd (Node);
1815 when N_Op_Shift =>
1816 Set_Debug_Sloc;
1817 Write_Id (Node);
1818 Write_Char ('!');
1819 Write_Str_With_Col_Check ("(");
1820 Sprint_Node (Left_Opnd (Node));
1821 Write_Str (", ");
1822 Sprint_Node (Right_Opnd (Node));
1823 Write_Char (')');
1825 when N_Op_Subtract =>
1826 Sprint_Left_Opnd (Node);
1827 Write_Operator (Node, " - ");
1828 Sprint_Right_Opnd (Node);
1830 when N_Op_Xor =>
1831 Sprint_Left_Opnd (Node);
1832 Write_Operator (Node, " xor ");
1833 Sprint_Right_Opnd (Node);
1835 when N_Operator_Symbol =>
1836 Write_Name_With_Col_Check_Sloc (Chars (Node));
1838 when N_Ordinary_Fixed_Point_Definition =>
1839 Write_Str_With_Col_Check_Sloc ("delta ");
1840 Sprint_Node (Delta_Expression (Node));
1841 Sprint_Opt_Node (Real_Range_Specification (Node));
1843 when N_Or_Else =>
1844 Sprint_Left_Opnd (Node);
1845 Write_Str_Sloc (" or else ");
1846 Sprint_Right_Opnd (Node);
1848 when N_Others_Choice =>
1849 if All_Others (Node) then
1850 Write_Str_With_Col_Check ("all ");
1851 end if;
1853 Write_Str_With_Col_Check_Sloc ("others");
1855 when N_Package_Body =>
1856 Write_Indent;
1857 Write_Indent_Str_Sloc ("package body ");
1858 Sprint_Node (Defining_Unit_Name (Node));
1859 Write_Str (" is");
1860 Sprint_Indented_List (Declarations (Node));
1862 if Present (Handled_Statement_Sequence (Node)) then
1863 Write_Indent_Str ("begin");
1864 Sprint_Node (Handled_Statement_Sequence (Node));
1865 end if;
1867 Write_Indent_Str ("end ");
1868 Sprint_Node (Defining_Unit_Name (Node));
1869 Write_Char (';');
1871 when N_Package_Body_Stub =>
1872 Write_Indent_Str_Sloc ("package body ");
1873 Sprint_Node (Defining_Identifier (Node));
1874 Write_Str_With_Col_Check (" is separate;");
1876 when N_Package_Declaration =>
1877 Write_Indent;
1878 Write_Indent;
1879 Sprint_Node_Sloc (Specification (Node));
1880 Write_Char (';');
1882 when N_Package_Instantiation =>
1883 Write_Indent;
1884 Write_Indent_Str_Sloc ("package ");
1885 Sprint_Node (Defining_Unit_Name (Node));
1886 Write_Str (" is new ");
1887 Sprint_Node (Name (Node));
1888 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1889 Write_Char (';');
1891 when N_Package_Renaming_Declaration =>
1892 Write_Indent_Str_Sloc ("package ");
1893 Sprint_Node (Defining_Unit_Name (Node));
1894 Write_Str_With_Col_Check (" renames ");
1895 Sprint_Node (Name (Node));
1896 Write_Char (';');
1898 when N_Package_Specification =>
1899 Write_Str_With_Col_Check_Sloc ("package ");
1900 Sprint_Node (Defining_Unit_Name (Node));
1901 Write_Str (" is");
1902 Sprint_Indented_List (Visible_Declarations (Node));
1904 if Present (Private_Declarations (Node)) then
1905 Write_Indent_Str ("private");
1906 Sprint_Indented_List (Private_Declarations (Node));
1907 end if;
1909 Write_Indent_Str ("end ");
1910 Sprint_Node (Defining_Unit_Name (Node));
1912 when N_Parameter_Association =>
1913 Sprint_Node_Sloc (Selector_Name (Node));
1914 Write_Str (" => ");
1915 Sprint_Node (Explicit_Actual_Parameter (Node));
1917 when N_Parameter_Specification =>
1918 Set_Debug_Sloc;
1920 if Write_Identifiers (Node) then
1921 Write_Str (" : ");
1923 if In_Present (Node) then
1924 Write_Str_With_Col_Check ("in ");
1925 end if;
1927 if Out_Present (Node) then
1928 Write_Str_With_Col_Check ("out ");
1929 end if;
1931 Sprint_Node (Parameter_Type (Node));
1933 if Present (Expression (Node)) then
1934 Write_Str (" := ");
1935 Sprint_Node (Expression (Node));
1936 end if;
1937 else
1938 Write_Str (", ");
1939 end if;
1941 when N_Pragma =>
1942 Write_Indent_Str_Sloc ("pragma ");
1943 Write_Name_With_Col_Check (Chars (Node));
1945 if Present (Pragma_Argument_Associations (Node)) then
1946 Sprint_Opt_Paren_Comma_List
1947 (Pragma_Argument_Associations (Node));
1948 end if;
1950 Write_Char (';');
1952 when N_Pragma_Argument_Association =>
1953 Set_Debug_Sloc;
1955 if Chars (Node) /= No_Name then
1956 Write_Name_With_Col_Check (Chars (Node));
1957 Write_Str (" => ");
1958 end if;
1960 Sprint_Node (Expression (Node));
1962 when N_Private_Type_Declaration =>
1963 Write_Indent_Str_Sloc ("type ");
1964 Write_Id (Defining_Identifier (Node));
1966 if Present (Discriminant_Specifications (Node)) then
1967 Write_Discr_Specs (Node);
1968 elsif Unknown_Discriminants_Present (Node) then
1969 Write_Str_With_Col_Check ("(<>)");
1970 end if;
1972 Write_Str (" is ");
1974 if Tagged_Present (Node) then
1975 Write_Str_With_Col_Check ("tagged ");
1976 end if;
1978 if Limited_Present (Node) then
1979 Write_Str_With_Col_Check ("limited ");
1980 end if;
1982 Write_Str_With_Col_Check ("private;");
1984 when N_Private_Extension_Declaration =>
1985 Write_Indent_Str_Sloc ("type ");
1986 Write_Id (Defining_Identifier (Node));
1988 if Present (Discriminant_Specifications (Node)) then
1989 Write_Discr_Specs (Node);
1990 elsif Unknown_Discriminants_Present (Node) then
1991 Write_Str_With_Col_Check ("(<>)");
1992 end if;
1994 Write_Str_With_Col_Check (" is new ");
1995 Sprint_Node (Subtype_Indication (Node));
1996 Write_Str_With_Col_Check (" with private;");
1998 when N_Procedure_Call_Statement =>
1999 Write_Indent;
2000 Set_Debug_Sloc;
2001 Sprint_Node (Name (Node));
2002 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2003 Write_Char (';');
2005 when N_Procedure_Instantiation =>
2006 Write_Indent_Str_Sloc ("procedure ");
2007 Sprint_Node (Defining_Unit_Name (Node));
2008 Write_Str_With_Col_Check (" is new ");
2009 Sprint_Node (Name (Node));
2010 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2011 Write_Char (';');
2013 when N_Procedure_Specification =>
2014 Write_Str_With_Col_Check_Sloc ("procedure ");
2015 Sprint_Node (Defining_Unit_Name (Node));
2016 Write_Param_Specs (Node);
2018 when N_Protected_Body =>
2019 Write_Indent_Str_Sloc ("protected body ");
2020 Write_Id (Defining_Identifier (Node));
2021 Write_Str (" is");
2022 Sprint_Indented_List (Declarations (Node));
2023 Write_Indent_Str ("end ");
2024 Write_Id (Defining_Identifier (Node));
2025 Write_Char (';');
2027 when N_Protected_Body_Stub =>
2028 Write_Indent_Str_Sloc ("protected body ");
2029 Write_Id (Defining_Identifier (Node));
2030 Write_Str_With_Col_Check (" is separate;");
2032 when N_Protected_Definition =>
2033 Set_Debug_Sloc;
2034 Sprint_Indented_List (Visible_Declarations (Node));
2036 if Present (Private_Declarations (Node)) then
2037 Write_Indent_Str ("private");
2038 Sprint_Indented_List (Private_Declarations (Node));
2039 end if;
2041 Write_Indent_Str ("end ");
2043 when N_Protected_Type_Declaration =>
2044 Write_Indent_Str_Sloc ("protected type ");
2045 Write_Id (Defining_Identifier (Node));
2046 Write_Discr_Specs (Node);
2047 Write_Str (" is");
2048 Sprint_Node (Protected_Definition (Node));
2049 Write_Id (Defining_Identifier (Node));
2050 Write_Char (';');
2052 when N_Qualified_Expression =>
2053 Sprint_Node (Subtype_Mark (Node));
2054 Write_Char_Sloc (''');
2056 -- Print expression, make sure we have at least one level of
2057 -- parentheses around the expression. For cases of qualified
2058 -- expressions in the source, this is always the case, but
2059 -- for generated qualifications, there may be no explicit
2060 -- parentheses present.
2062 if Paren_Count (Expression (Node)) /= 0 then
2063 Sprint_Node (Expression (Node));
2064 else
2065 Write_Char ('(');
2066 Sprint_Node (Expression (Node));
2067 Write_Char (')');
2068 end if;
2070 when N_Raise_Constraint_Error =>
2072 -- This node can be used either as a subexpression or as a
2073 -- statement form. The following test is a reasonably reliable
2074 -- way to distinguish the two cases.
2076 if Is_List_Member (Node)
2077 and then Nkind (Parent (Node)) not in N_Subexpr
2078 then
2079 Write_Indent;
2080 end if;
2082 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2083 Write_Condition_And_Reason (Node);
2085 when N_Raise_Program_Error =>
2087 -- This node can be used either as a subexpression or as a
2088 -- statement form. The following test is a reasonably reliable
2089 -- way to distinguish the two cases.
2091 if Is_List_Member (Node)
2092 and then Nkind (Parent (Node)) not in N_Subexpr
2093 then
2094 Write_Indent;
2095 end if;
2097 Write_Str_With_Col_Check_Sloc ("[program_error");
2098 Write_Condition_And_Reason (Node);
2100 when N_Raise_Storage_Error =>
2102 -- This node can be used either as a subexpression or as a
2103 -- statement form. The following test is a reasonably reliable
2104 -- way to distinguish the two cases.
2106 if Is_List_Member (Node)
2107 and then Nkind (Parent (Node)) not in N_Subexpr
2108 then
2109 Write_Indent;
2110 end if;
2112 Write_Str_With_Col_Check_Sloc ("[storage_error");
2113 Write_Condition_And_Reason (Node);
2115 when N_Raise_Statement =>
2116 Write_Indent_Str_Sloc ("raise ");
2117 Sprint_Node (Name (Node));
2118 Write_Char (';');
2120 when N_Range =>
2121 Sprint_Node (Low_Bound (Node));
2122 Write_Str_Sloc (" .. ");
2123 Sprint_Node (High_Bound (Node));
2125 when N_Range_Constraint =>
2126 Write_Str_With_Col_Check_Sloc ("range ");
2127 Sprint_Node (Range_Expression (Node));
2129 when N_Real_Literal =>
2130 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2132 when N_Real_Range_Specification =>
2133 Write_Str_With_Col_Check_Sloc ("range ");
2134 Sprint_Node (Low_Bound (Node));
2135 Write_Str (" .. ");
2136 Sprint_Node (High_Bound (Node));
2138 when N_Record_Definition =>
2139 if Abstract_Present (Node) then
2140 Write_Str_With_Col_Check ("abstract ");
2141 end if;
2143 if Tagged_Present (Node) then
2144 Write_Str_With_Col_Check ("tagged ");
2145 end if;
2147 if Limited_Present (Node) then
2148 Write_Str_With_Col_Check ("limited ");
2149 end if;
2151 if Null_Present (Node) then
2152 Write_Str_With_Col_Check_Sloc ("null record");
2154 else
2155 Write_Str_With_Col_Check_Sloc ("record");
2156 Sprint_Node (Component_List (Node));
2157 Write_Indent_Str ("end record");
2158 end if;
2160 when N_Record_Representation_Clause =>
2161 Write_Indent_Str_Sloc ("for ");
2162 Sprint_Node (Identifier (Node));
2163 Write_Str_With_Col_Check (" use record ");
2165 if Present (Mod_Clause (Node)) then
2166 Sprint_Node (Mod_Clause (Node));
2167 end if;
2169 Sprint_Indented_List (Component_Clauses (Node));
2170 Write_Indent_Str ("end record;");
2172 when N_Reference =>
2173 Sprint_Node (Prefix (Node));
2174 Write_Str_With_Col_Check_Sloc ("'reference");
2176 when N_Requeue_Statement =>
2177 Write_Indent_Str_Sloc ("requeue ");
2178 Sprint_Node (Name (Node));
2180 if Abort_Present (Node) then
2181 Write_Str_With_Col_Check (" with abort");
2182 end if;
2184 Write_Char (';');
2186 when N_Return_Statement =>
2187 if Present (Expression (Node)) then
2188 Write_Indent_Str_Sloc ("return ");
2189 Sprint_Node (Expression (Node));
2190 Write_Char (';');
2191 else
2192 Write_Indent_Str_Sloc ("return;");
2193 end if;
2195 when N_Selective_Accept =>
2196 Write_Indent_Str_Sloc ("select");
2198 declare
2199 Alt_Node : Node_Id;
2201 begin
2202 Alt_Node := First (Select_Alternatives (Node));
2203 loop
2204 Indent_Begin;
2205 Sprint_Node (Alt_Node);
2206 Indent_End;
2207 Next (Alt_Node);
2208 exit when No (Alt_Node);
2209 Write_Indent_Str ("or");
2210 end loop;
2211 end;
2213 if Present (Else_Statements (Node)) then
2214 Write_Indent_Str ("else");
2215 Sprint_Indented_List (Else_Statements (Node));
2216 end if;
2218 Write_Indent_Str ("end select;");
2220 when N_Signed_Integer_Type_Definition =>
2221 Write_Str_With_Col_Check_Sloc ("range ");
2222 Sprint_Node (Low_Bound (Node));
2223 Write_Str (" .. ");
2224 Sprint_Node (High_Bound (Node));
2226 when N_Single_Protected_Declaration =>
2227 Write_Indent_Str_Sloc ("protected ");
2228 Write_Id (Defining_Identifier (Node));
2229 Write_Str (" is");
2230 Sprint_Node (Protected_Definition (Node));
2231 Write_Id (Defining_Identifier (Node));
2232 Write_Char (';');
2234 when N_Single_Task_Declaration =>
2235 Write_Indent_Str_Sloc ("task ");
2236 Write_Id (Defining_Identifier (Node));
2238 if Present (Task_Definition (Node)) then
2239 Write_Str (" is");
2240 Sprint_Node (Task_Definition (Node));
2241 Write_Id (Defining_Identifier (Node));
2242 end if;
2244 Write_Char (';');
2246 when N_Selected_Component | N_Expanded_Name =>
2247 Sprint_Node (Prefix (Node));
2248 Write_Char_Sloc ('.');
2249 Sprint_Node (Selector_Name (Node));
2251 when N_Slice =>
2252 Set_Debug_Sloc;
2253 Sprint_Node (Prefix (Node));
2254 Write_Str_With_Col_Check (" (");
2255 Sprint_Node (Discrete_Range (Node));
2256 Write_Char (')');
2258 when N_String_Literal =>
2259 if String_Length (Strval (Node)) + Column > 75 then
2260 Write_Indent_Str (" ");
2261 end if;
2263 Set_Debug_Sloc;
2264 Write_String_Table_Entry (Strval (Node));
2266 when N_Subprogram_Body =>
2267 if Freeze_Indent = 0 then
2268 Write_Indent;
2269 end if;
2271 Write_Indent;
2272 Sprint_Node_Sloc (Specification (Node));
2273 Write_Str (" is");
2275 Sprint_Indented_List (Declarations (Node));
2276 Write_Indent_Str ("begin");
2277 Sprint_Node (Handled_Statement_Sequence (Node));
2279 Write_Indent_Str ("end ");
2280 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2281 Write_Char (';');
2283 if Is_List_Member (Node)
2284 and then Present (Next (Node))
2285 and then Nkind (Next (Node)) /= N_Subprogram_Body
2286 then
2287 Write_Indent;
2288 end if;
2290 when N_Subprogram_Body_Stub =>
2291 Write_Indent;
2292 Sprint_Node_Sloc (Specification (Node));
2293 Write_Str_With_Col_Check (" is separate;");
2295 when N_Subprogram_Declaration =>
2296 Write_Indent;
2297 Sprint_Node_Sloc (Specification (Node));
2298 Write_Char (';');
2300 when N_Subprogram_Info =>
2301 Sprint_Node (Identifier (Node));
2302 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2304 when N_Subprogram_Renaming_Declaration =>
2305 Write_Indent;
2306 Sprint_Node (Specification (Node));
2307 Write_Str_With_Col_Check_Sloc (" renames ");
2308 Sprint_Node (Name (Node));
2309 Write_Char (';');
2311 when N_Subtype_Declaration =>
2312 Write_Indent_Str_Sloc ("subtype ");
2313 Write_Id (Defining_Identifier (Node));
2314 Write_Str (" is ");
2315 Sprint_Node (Subtype_Indication (Node));
2316 Write_Char (';');
2318 when N_Subtype_Indication =>
2319 Sprint_Node_Sloc (Subtype_Mark (Node));
2320 Write_Char (' ');
2321 Sprint_Node (Constraint (Node));
2323 when N_Subunit =>
2324 Write_Indent_Str_Sloc ("separate (");
2325 Sprint_Node (Name (Node));
2326 Write_Char (')');
2327 Write_Eol;
2328 Sprint_Node (Proper_Body (Node));
2330 when N_Task_Body =>
2331 Write_Indent_Str_Sloc ("task body ");
2332 Write_Id (Defining_Identifier (Node));
2333 Write_Str (" is");
2334 Sprint_Indented_List (Declarations (Node));
2335 Write_Indent_Str ("begin");
2336 Sprint_Node (Handled_Statement_Sequence (Node));
2337 Write_Indent_Str ("end ");
2338 Write_Id (Defining_Identifier (Node));
2339 Write_Char (';');
2341 when N_Task_Body_Stub =>
2342 Write_Indent_Str_Sloc ("task body ");
2343 Write_Id (Defining_Identifier (Node));
2344 Write_Str_With_Col_Check (" is separate;");
2346 when N_Task_Definition =>
2347 Set_Debug_Sloc;
2348 Sprint_Indented_List (Visible_Declarations (Node));
2350 if Present (Private_Declarations (Node)) then
2351 Write_Indent_Str ("private");
2352 Sprint_Indented_List (Private_Declarations (Node));
2353 end if;
2355 Write_Indent_Str ("end ");
2357 when N_Task_Type_Declaration =>
2358 Write_Indent_Str_Sloc ("task type ");
2359 Write_Id (Defining_Identifier (Node));
2360 Write_Discr_Specs (Node);
2361 if Present (Task_Definition (Node)) then
2362 Write_Str (" is");
2363 Sprint_Node (Task_Definition (Node));
2364 Write_Id (Defining_Identifier (Node));
2365 end if;
2367 Write_Char (';');
2369 when N_Terminate_Alternative =>
2370 Sprint_Node_List (Pragmas_Before (Node));
2372 Write_Indent;
2374 if Present (Condition (Node)) then
2375 Write_Str_With_Col_Check ("when ");
2376 Sprint_Node (Condition (Node));
2377 Write_Str (" => ");
2378 end if;
2380 Write_Str_With_Col_Check_Sloc ("terminate;");
2381 Sprint_Node_List (Pragmas_After (Node));
2383 when N_Timed_Entry_Call =>
2384 Write_Indent_Str_Sloc ("select");
2385 Indent_Begin;
2386 Sprint_Node (Entry_Call_Alternative (Node));
2387 Indent_End;
2388 Write_Indent_Str ("or");
2389 Indent_Begin;
2390 Sprint_Node (Delay_Alternative (Node));
2391 Indent_End;
2392 Write_Indent_Str ("end select;");
2394 when N_Triggering_Alternative =>
2395 Sprint_Node_List (Pragmas_Before (Node));
2396 Sprint_Node_Sloc (Triggering_Statement (Node));
2397 Sprint_Node_List (Statements (Node));
2399 when N_Type_Conversion =>
2400 Set_Debug_Sloc;
2401 Sprint_Node (Subtype_Mark (Node));
2402 Col_Check (4);
2404 if Conversion_OK (Node) then
2405 Write_Char ('?');
2406 end if;
2408 if Float_Truncate (Node) then
2409 Write_Char ('^');
2410 end if;
2412 if Rounded_Result (Node) then
2413 Write_Char ('@');
2414 end if;
2416 Write_Char ('(');
2417 Sprint_Node (Expression (Node));
2418 Write_Char (')');
2420 when N_Unchecked_Expression =>
2421 Col_Check (10);
2422 Write_Str ("`(");
2423 Sprint_Node_Sloc (Expression (Node));
2424 Write_Char (')');
2426 when N_Unchecked_Type_Conversion =>
2427 Sprint_Node (Subtype_Mark (Node));
2428 Write_Char ('!');
2429 Write_Str_With_Col_Check ("(");
2430 Sprint_Node_Sloc (Expression (Node));
2431 Write_Char (')');
2433 when N_Unconstrained_Array_Definition =>
2434 Write_Str_With_Col_Check_Sloc ("array (");
2436 declare
2437 Node1 : Node_Id;
2439 begin
2440 Node1 := First (Subtype_Marks (Node));
2441 loop
2442 Sprint_Node (Node1);
2443 Write_Str_With_Col_Check (" range <>");
2444 Next (Node1);
2445 exit when Node1 = Empty;
2446 Write_Str (", ");
2447 end loop;
2448 end;
2450 Write_Str (") of ");
2452 if Aliased_Present (Node) then
2453 Write_Str_With_Col_Check ("aliased ");
2454 end if;
2456 Sprint_Node (Subtype_Indication (Node));
2458 when N_Unused_At_Start | N_Unused_At_End =>
2459 Write_Indent_Str ("***** Error, unused node encountered *****");
2460 Write_Eol;
2462 when N_Use_Package_Clause =>
2463 Write_Indent_Str_Sloc ("use ");
2464 Sprint_Comma_List (Names (Node));
2465 Write_Char (';');
2467 when N_Use_Type_Clause =>
2468 Write_Indent_Str_Sloc ("use type ");
2469 Sprint_Comma_List (Subtype_Marks (Node));
2470 Write_Char (';');
2472 when N_Validate_Unchecked_Conversion =>
2473 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2474 Sprint_Node (Source_Type (Node));
2475 Write_Str (", ");
2476 Sprint_Node (Target_Type (Node));
2477 Write_Str (");");
2479 when N_Variant =>
2480 Write_Indent_Str_Sloc ("when ");
2481 Sprint_Bar_List (Discrete_Choices (Node));
2482 Write_Str (" => ");
2483 Sprint_Node (Component_List (Node));
2485 when N_Variant_Part =>
2486 Indent_Begin;
2487 Write_Indent_Str_Sloc ("case ");
2488 Sprint_Node (Name (Node));
2489 Write_Str (" is ");
2490 Sprint_Indented_List (Variants (Node));
2491 Write_Indent_Str ("end case");
2492 Indent_End;
2494 when N_With_Clause =>
2496 -- Special test, if we are dumping the original tree only,
2497 -- then we want to eliminate the bogus with clauses that
2498 -- correspond to the non-existent children of Text_IO.
2500 if Dump_Original_Only
2501 and then Is_Text_IO_Kludge_Unit (Name (Node))
2502 then
2503 null;
2505 -- Normal case, output the with clause
2507 else
2508 if First_Name (Node) or else not Dump_Original_Only then
2509 Write_Indent_Str ("with ");
2510 else
2511 Write_Str (", ");
2512 end if;
2514 Sprint_Node_Sloc (Name (Node));
2516 if Last_Name (Node) or else not Dump_Original_Only then
2517 Write_Char (';');
2518 end if;
2519 end if;
2521 when N_With_Type_Clause =>
2523 Write_Indent_Str ("with type ");
2524 Sprint_Node_Sloc (Name (Node));
2526 if Tagged_Present (Node) then
2527 Write_Str (" is tagged;");
2528 else
2529 Write_Str (" is access;");
2530 end if;
2532 end case;
2534 if Nkind (Node) in N_Subexpr
2535 and then Do_Range_Check (Node)
2536 then
2537 Write_Str ("}");
2538 end if;
2540 for J in 1 .. Paren_Count (Node) loop
2541 Write_Char (')');
2542 end loop;
2544 pragma Assert (No (Debug_Node));
2545 Debug_Node := Save_Debug_Node;
2546 end Sprint_Node_Actual;
2548 ----------------------
2549 -- Sprint_Node_List --
2550 ----------------------
2552 procedure Sprint_Node_List (List : List_Id) is
2553 Node : Node_Id;
2555 begin
2556 if Is_Non_Empty_List (List) then
2557 Node := First (List);
2559 loop
2560 Sprint_Node (Node);
2561 Next (Node);
2562 exit when Node = Empty;
2563 end loop;
2564 end if;
2565 end Sprint_Node_List;
2567 ----------------------
2568 -- Sprint_Node_Sloc --
2569 ----------------------
2571 procedure Sprint_Node_Sloc (Node : Node_Id) is
2572 begin
2573 Sprint_Node (Node);
2575 if Present (Debug_Node) then
2576 Set_Sloc (Debug_Node, Sloc (Node));
2577 Debug_Node := Empty;
2578 end if;
2579 end Sprint_Node_Sloc;
2581 ---------------------
2582 -- Sprint_Opt_Node --
2583 ---------------------
2585 procedure Sprint_Opt_Node (Node : Node_Id) is
2586 begin
2587 if Present (Node) then
2588 Write_Char (' ');
2589 Sprint_Node (Node);
2590 end if;
2591 end Sprint_Opt_Node;
2593 --------------------------
2594 -- Sprint_Opt_Node_List --
2595 --------------------------
2597 procedure Sprint_Opt_Node_List (List : List_Id) is
2598 begin
2599 if Present (List) then
2600 Sprint_Node_List (List);
2601 end if;
2602 end Sprint_Opt_Node_List;
2604 ---------------------------------
2605 -- Sprint_Opt_Paren_Comma_List --
2606 ---------------------------------
2608 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2609 begin
2610 if Is_Non_Empty_List (List) then
2611 Write_Char (' ');
2612 Sprint_Paren_Comma_List (List);
2613 end if;
2614 end Sprint_Opt_Paren_Comma_List;
2616 -----------------------------
2617 -- Sprint_Paren_Comma_List --
2618 -----------------------------
2620 procedure Sprint_Paren_Comma_List (List : List_Id) is
2621 N : Node_Id;
2622 Node_Exists : Boolean := False;
2624 begin
2626 if Is_Non_Empty_List (List) then
2628 if Dump_Original_Only then
2629 N := First (List);
2631 while Present (N) loop
2633 if not Is_Rewrite_Insertion (N) then
2634 Node_Exists := True;
2635 exit;
2636 end if;
2638 Next (N);
2639 end loop;
2641 if not Node_Exists then
2642 return;
2643 end if;
2644 end if;
2646 Write_Str_With_Col_Check ("(");
2647 Sprint_Comma_List (List);
2648 Write_Char (')');
2649 end if;
2650 end Sprint_Paren_Comma_List;
2652 ----------------------
2653 -- Sprint_Right_Opnd --
2654 ----------------------
2656 procedure Sprint_Right_Opnd (N : Node_Id) is
2657 Opnd : constant Node_Id := Right_Opnd (N);
2659 begin
2660 if Paren_Count (Opnd) /= 0
2661 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2662 then
2663 Sprint_Node (Opnd);
2665 else
2666 Write_Char ('(');
2667 Sprint_Node (Opnd);
2668 Write_Char (')');
2669 end if;
2670 end Sprint_Right_Opnd;
2672 ---------------------
2673 -- Write_Char_Sloc --
2674 ---------------------
2676 procedure Write_Char_Sloc (C : Character) is
2677 begin
2678 if Debug_Generated_Code and then C /= ' ' then
2679 Set_Debug_Sloc;
2680 end if;
2682 Write_Char (C);
2683 end Write_Char_Sloc;
2685 --------------------------------
2686 -- Write_Condition_And_Reason --
2687 --------------------------------
2689 procedure Write_Condition_And_Reason (Node : Node_Id) is
2690 Image : constant String := RT_Exception_Code'Image
2691 (RT_Exception_Code'Val
2692 (UI_To_Int (Reason (Node))));
2694 begin
2695 if Present (Condition (Node)) then
2696 Write_Str_With_Col_Check (" when ");
2697 Sprint_Node (Condition (Node));
2698 end if;
2700 Write_Str (" """);
2702 for J in 4 .. Image'Last loop
2703 if Image (J) = '_' then
2704 Write_Char (' ');
2705 else
2706 Write_Char (Fold_Lower (Image (J)));
2707 end if;
2708 end loop;
2710 Write_Str ("""]");
2711 end Write_Condition_And_Reason;
2713 ------------------------
2714 -- Write_Discr_Specs --
2715 ------------------------
2717 procedure Write_Discr_Specs (N : Node_Id) is
2718 Specs : List_Id;
2719 Spec : Node_Id;
2721 begin
2722 Specs := Discriminant_Specifications (N);
2724 if Present (Specs) then
2725 Write_Str_With_Col_Check (" (");
2726 Spec := First (Specs);
2728 loop
2729 Sprint_Node (Spec);
2730 Next (Spec);
2731 exit when Spec = Empty;
2733 -- Add semicolon, unless we are printing original tree and the
2734 -- next specification is part of a list (but not the first
2735 -- element of that list)
2737 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2738 Write_Str ("; ");
2739 end if;
2740 end loop;
2742 Write_Char (')');
2743 end if;
2744 end Write_Discr_Specs;
2746 -----------------
2747 -- Write_Ekind --
2748 -----------------
2750 procedure Write_Ekind (E : Entity_Id) is
2751 S : constant String := Entity_Kind'Image (Ekind (E));
2753 begin
2754 Name_Len := S'Length;
2755 Name_Buffer (1 .. Name_Len) := S;
2756 Set_Casing (Mixed_Case);
2757 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2758 end Write_Ekind;
2760 --------------
2761 -- Write_Id --
2762 --------------
2764 procedure Write_Id (N : Node_Id) is
2765 begin
2766 -- Case of a defining identifier
2768 if Nkind (N) = N_Defining_Identifier then
2770 -- If defining identifier has an interface name (and no
2771 -- address clause), then we output the interface name.
2773 if (Is_Imported (N) or else Is_Exported (N))
2774 and then Present (Interface_Name (N))
2775 and then No (Address_Clause (N))
2776 then
2777 String_To_Name_Buffer (Strval (Interface_Name (N)));
2778 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2780 -- If no interface name (or inactive because there was
2781 -- an address clause), then just output the Chars name.
2783 else
2784 Write_Name_With_Col_Check (Chars (N));
2785 end if;
2787 -- Case of selector of an expanded name where the expanded name
2788 -- has an associated entity, output this entity.
2790 elsif Nkind (Parent (N)) = N_Expanded_Name
2791 and then Selector_Name (Parent (N)) = N
2792 and then Present (Entity (Parent (N)))
2793 then
2794 Write_Id (Entity (Parent (N)));
2796 -- For any other kind of node with an associated entity, output it.
2798 elsif Nkind (N) in N_Has_Entity
2799 and then Present (Entity (N))
2800 then
2801 Write_Id (Entity (N));
2803 -- All other cases, we just print the Chars field
2805 else
2806 Write_Name_With_Col_Check (Chars (N));
2807 end if;
2808 end Write_Id;
2810 -----------------------
2811 -- Write_Identifiers --
2812 -----------------------
2814 function Write_Identifiers (Node : Node_Id) return Boolean is
2815 begin
2816 Sprint_Node (Defining_Identifier (Node));
2818 -- The remainder of the declaration must be printed unless we are
2819 -- printing the original tree and this is not the last identifier
2821 return
2822 not Dump_Original_Only or else not More_Ids (Node);
2824 end Write_Identifiers;
2826 ------------------------
2827 -- Write_Implicit_Def --
2828 ------------------------
2830 procedure Write_Implicit_Def (E : Entity_Id) is
2831 Ind : Node_Id;
2833 begin
2834 case Ekind (E) is
2835 when E_Array_Subtype =>
2836 Write_Str_With_Col_Check ("subtype ");
2837 Write_Id (E);
2838 Write_Str_With_Col_Check (" is ");
2839 Write_Id (Base_Type (E));
2840 Write_Str_With_Col_Check (" (");
2842 Ind := First_Index (E);
2844 while Present (Ind) loop
2845 Sprint_Node (Ind);
2846 Next_Index (Ind);
2848 if Present (Ind) then
2849 Write_Str (", ");
2850 end if;
2851 end loop;
2853 Write_Str (");");
2855 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2856 Write_Str_With_Col_Check ("subtype ");
2857 Write_Id (E);
2858 Write_Str (" is ");
2859 Write_Id (Etype (E));
2860 Write_Str_With_Col_Check (" range ");
2861 Sprint_Node (Scalar_Range (E));
2862 Write_Str (";");
2864 when others =>
2865 Write_Str_With_Col_Check ("type ");
2866 Write_Id (E);
2867 Write_Str_With_Col_Check (" is <");
2868 Write_Ekind (E);
2869 Write_Str (">;");
2870 end case;
2872 end Write_Implicit_Def;
2874 ------------------
2875 -- Write_Indent --
2876 ------------------
2878 procedure Write_Indent is
2879 begin
2880 if Indent_Annull_Flag then
2881 Indent_Annull_Flag := False;
2882 else
2883 Write_Eol;
2885 for J in 1 .. Indent loop
2886 Write_Char (' ');
2887 end loop;
2888 end if;
2889 end Write_Indent;
2891 ------------------------------
2892 -- Write_Indent_Identifiers --
2893 ------------------------------
2895 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
2896 begin
2897 -- We need to start a new line for every node, except in the case
2898 -- where we are printing the original tree and this is not the first
2899 -- defining identifier in the list.
2901 if not Dump_Original_Only or else not Prev_Ids (Node) then
2902 Write_Indent;
2904 -- If printing original tree and this is not the first defining
2905 -- identifier in the list, then the previous call to this procedure
2906 -- printed only the name, and we add a comma to separate the names.
2908 else
2909 Write_Str (", ");
2910 end if;
2912 Sprint_Node (Defining_Identifier (Node));
2914 -- The remainder of the declaration must be printed unless we are
2915 -- printing the original tree and this is not the last identifier
2917 return
2918 not Dump_Original_Only or else not More_Ids (Node);
2920 end Write_Indent_Identifiers;
2922 -----------------------------------
2923 -- Write_Indent_Identifiers_Sloc --
2924 -----------------------------------
2926 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
2927 begin
2928 -- We need to start a new line for every node, except in the case
2929 -- where we are printing the original tree and this is not the first
2930 -- defining identifier in the list.
2932 if not Dump_Original_Only or else not Prev_Ids (Node) then
2933 Write_Indent;
2935 -- If printing original tree and this is not the first defining
2936 -- identifier in the list, then the previous call to this procedure
2937 -- printed only the name, and we add a comma to separate the names.
2939 else
2940 Write_Str (", ");
2941 end if;
2943 Set_Debug_Sloc;
2944 Sprint_Node (Defining_Identifier (Node));
2946 -- The remainder of the declaration must be printed unless we are
2947 -- printing the original tree and this is not the last identifier
2949 return
2950 not Dump_Original_Only or else not More_Ids (Node);
2952 end Write_Indent_Identifiers_Sloc;
2954 ----------------------
2955 -- Write_Indent_Str --
2956 ----------------------
2958 procedure Write_Indent_Str (S : String) is
2959 begin
2960 Write_Indent;
2961 Write_Str (S);
2962 end Write_Indent_Str;
2964 ---------------------------
2965 -- Write_Indent_Str_Sloc --
2966 ---------------------------
2968 procedure Write_Indent_Str_Sloc (S : String) is
2969 begin
2970 Write_Indent;
2971 Write_Str_Sloc (S);
2972 end Write_Indent_Str_Sloc;
2974 -------------------------------
2975 -- Write_Name_With_Col_Check --
2976 -------------------------------
2978 procedure Write_Name_With_Col_Check (N : Name_Id) is
2979 J : Natural;
2981 begin
2982 Get_Name_String (N);
2984 -- Deal with -gnatI which replaces digits in an internal
2985 -- name by three dots (e.g. R7b becomes R...b).
2987 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
2989 J := 2;
2990 while J < Name_Len loop
2991 exit when Name_Buffer (J) not in 'A' .. 'Z';
2992 J := J + 1;
2993 end loop;
2995 if Name_Buffer (J) in '0' .. '9' then
2996 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
2997 Write_Str ("...");
2999 while J <= Name_Len loop
3000 if Name_Buffer (J) not in '0' .. '9' then
3001 Write_Str (Name_Buffer (J .. Name_Len));
3002 exit;
3004 else
3005 J := J + 1;
3006 end if;
3007 end loop;
3009 return;
3010 end if;
3011 end if;
3013 -- Fall through for normal case
3015 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3016 end Write_Name_With_Col_Check;
3018 ------------------------------------
3019 -- Write_Name_With_Col_Check_Sloc --
3020 ------------------------------------
3022 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3023 begin
3024 Get_Name_String (N);
3025 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3026 end Write_Name_With_Col_Check_Sloc;
3028 --------------------
3029 -- Write_Operator --
3030 --------------------
3032 procedure Write_Operator (N : Node_Id; S : String) is
3033 F : Natural := S'First;
3034 T : Natural := S'Last;
3036 begin
3037 -- If no overflow check, just write string out, and we are done
3039 if not Do_Overflow_Check (N) then
3040 Write_Str_Sloc (S);
3042 -- If overflow check, we want to surround the operator with curly
3043 -- brackets, but not include spaces within the brackets.
3045 else
3046 if S (F) = ' ' then
3047 Write_Char (' ');
3048 F := F + 1;
3049 end if;
3051 if S (T) = ' ' then
3052 T := T - 1;
3053 end if;
3055 Write_Char ('{');
3056 Write_Str_Sloc (S (F .. T));
3057 Write_Char ('}');
3059 if S (S'Last) = ' ' then
3060 Write_Char (' ');
3061 end if;
3062 end if;
3063 end Write_Operator;
3065 -----------------------
3066 -- Write_Param_Specs --
3067 -----------------------
3069 procedure Write_Param_Specs (N : Node_Id) is
3070 Specs : List_Id;
3071 Spec : Node_Id;
3072 Formal : Node_Id;
3074 begin
3075 Specs := Parameter_Specifications (N);
3077 if Is_Non_Empty_List (Specs) then
3078 Write_Str_With_Col_Check (" (");
3079 Spec := First (Specs);
3081 loop
3082 Sprint_Node (Spec);
3083 Formal := Defining_Identifier (Spec);
3084 Next (Spec);
3085 exit when Spec = Empty;
3087 -- Add semicolon, unless we are printing original tree and the
3088 -- next specification is part of a list (but not the first
3089 -- element of that list)
3091 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3092 Write_Str ("; ");
3093 end if;
3094 end loop;
3096 -- Write out any extra formals
3098 while Present (Extra_Formal (Formal)) loop
3099 Formal := Extra_Formal (Formal);
3100 Write_Str ("; ");
3101 Write_Name_With_Col_Check (Chars (Formal));
3102 Write_Str (" : ");
3103 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3104 end loop;
3106 Write_Char (')');
3107 end if;
3108 end Write_Param_Specs;
3110 --------------------------
3111 -- Write_Rewrite_Str --
3112 --------------------------
3114 procedure Write_Rewrite_Str (S : String) is
3115 begin
3116 if not Dump_Generated_Only then
3117 if S'Length = 3 and then S = ">>>" then
3118 Write_Str (">>>");
3119 else
3120 Write_Str_With_Col_Check (S);
3121 end if;
3122 end if;
3123 end Write_Rewrite_Str;
3125 --------------------
3126 -- Write_Str_Sloc --
3127 --------------------
3129 procedure Write_Str_Sloc (S : String) is
3130 begin
3131 for J in S'Range loop
3132 Write_Char_Sloc (S (J));
3133 end loop;
3134 end Write_Str_Sloc;
3136 ------------------------------
3137 -- Write_Str_With_Col_Check --
3138 ------------------------------
3140 procedure Write_Str_With_Col_Check (S : String) is
3141 begin
3142 if Int (S'Last) + Column > Line_Limit then
3143 Write_Indent_Str (" ");
3145 if S (1) = ' ' then
3146 Write_Str (S (2 .. S'Length));
3147 else
3148 Write_Str (S);
3149 end if;
3151 else
3152 Write_Str (S);
3153 end if;
3154 end Write_Str_With_Col_Check;
3156 -----------------------------------
3157 -- Write_Str_With_Col_Check_Sloc --
3158 -----------------------------------
3160 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3161 begin
3162 if Int (S'Last) + Column > Line_Limit then
3163 Write_Indent_Str (" ");
3165 if S (1) = ' ' then
3166 Write_Str_Sloc (S (2 .. S'Length));
3167 else
3168 Write_Str_Sloc (S);
3169 end if;
3171 else
3172 Write_Str_Sloc (S);
3173 end if;
3174 end Write_Str_With_Col_Check_Sloc;
3176 ------------------------------------
3177 -- Write_Uint_With_Col_Check_Sloc --
3178 ------------------------------------
3180 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3181 begin
3182 Col_Check (UI_Decimal_Digits_Hi (U));
3183 Set_Debug_Sloc;
3184 UI_Write (U, Format);
3185 end Write_Uint_With_Col_Check_Sloc;
3187 -------------------------------------
3188 -- Write_Ureal_With_Col_Check_Sloc --
3189 -------------------------------------
3191 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3192 D : constant Uint := Denominator (U);
3193 N : constant Uint := Numerator (U);
3195 begin
3196 Col_Check
3197 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3198 Set_Debug_Sloc;
3199 UR_Write (U);
3200 end Write_Ureal_With_Col_Check_Sloc;
3202 end Sprint;