* gcc.dg/vect/vect-22.c: Require vect_float.
[official-gcc.git] / gcc / ada / sprint.adb
blob58e61df896755220b0d71666dc32d7327a0234b0
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-2005, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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_And_List (List : List_Id);
169 -- Print the given list with items separated by vertical "and"
171 procedure Sprint_Bar_List (List : List_Id);
172 -- Print the given list with items separated by vertical bars
174 procedure Sprint_Node_Actual (Node : Node_Id);
175 -- This routine prints its node argument. It is a lower level routine than
176 -- Sprint_Node, in that it does not bother about rewritten trees.
178 procedure Sprint_Node_Sloc (Node : Node_Id);
179 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
180 -- sets the Sloc of the current debug node to be a copy of the Sloc
181 -- of the sprinted node Node. Note that this is done after printing
182 -- Node, so that the Sloc is the proper updated value for the debug file.
184 procedure Write_Char_Sloc (C : Character);
185 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
186 -- called to ensure that the current node has a proper Sloc set.
188 procedure Write_Condition_And_Reason (Node : Node_Id);
189 -- Write Condition and Reason codes of Raise_xxx_Error node
191 procedure Write_Discr_Specs (N : Node_Id);
192 -- Ouput discriminant specification for node, which is any of the type
193 -- declarations that can have discriminants.
195 procedure Write_Ekind (E : Entity_Id);
196 -- Write the String corresponding to the Ekind without "E_".
198 procedure Write_Id (N : Node_Id);
199 -- N is a node with a Chars field. This procedure writes the name that
200 -- will be used in the generated code associated with the name. For a
201 -- node with no associated entity, this is simply the Chars field. For
202 -- the case where there is an entity associated with the node, we print
203 -- the name associated with the entity (since it may have been encoded).
204 -- One other special case is that an entity has an active external name
205 -- (i.e. an external name present with no address clause), then this
206 -- external name is output.
208 function Write_Identifiers (Node : Node_Id) return Boolean;
209 -- Handle node where the grammar has a list of defining identifiers, but
210 -- the tree has a separate declaration for each identifier. Handles the
211 -- printing of the defining identifier, and returns True if the type and
212 -- initialization information is to be printed, False if it is to be
213 -- skipped (the latter case happens when printing defining identifiers
214 -- other than the first in the original tree output case).
216 procedure Write_Implicit_Def (E : Entity_Id);
217 pragma Warnings (Off, Write_Implicit_Def);
218 -- Write the definition of the implicit type E according to its Ekind
219 -- For now a debugging procedure, but might be used in the future.
221 procedure Write_Indent;
222 -- Start a new line and write indentation spacing
224 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
225 -- Like Write_Identifiers except that each new printed declaration
226 -- is at the start of a new line.
228 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
229 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
230 -- mode, the Sloc of the current debug node is set to point ot the
231 -- first output identifier.
233 procedure Write_Indent_Str (S : String);
234 -- Start a new line and write indent spacing followed by given string
236 procedure Write_Indent_Str_Sloc (S : String);
237 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
238 -- the Sloc of the current node is set to the first non-blank character
239 -- in the string S.
241 procedure Write_Name_With_Col_Check (N : Name_Id);
242 -- Write name (using Write_Name) with initial column check, and possible
243 -- initial Write_Indent (to get new line) if current line is too full.
245 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
246 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
247 -- mode, sets Sloc of current debug node to first character of name.
249 procedure Write_Operator (N : Node_Id; S : String);
250 -- Like Write_Str_Sloc, used for operators, encloses the string in
251 -- characters {} if the Do_Overflow flag is set on the node N.
253 procedure Write_Param_Specs (N : Node_Id);
254 -- Output parameter specifications for node (which is either a function
255 -- or procedure specification with a Parameter_Specifications field)
257 procedure Write_Rewrite_Str (S : String);
258 -- Writes out a string (typically containing <<< or >>>}) for a node
259 -- created by rewriting the tree. Suppressed if we are outputting the
260 -- generated code only, since in this case we don't specially mark nodes
261 -- created by rewriting).
263 procedure Write_Str_Sloc (S : String);
264 -- Like Write_Str, but sets debug Sloc of current debug node to first
265 -- non-blank character if a current debug node is active.
267 procedure Write_Str_With_Col_Check (S : String);
268 -- Write string (using Write_Str) with initial column check, and possible
269 -- initial Write_Indent (to get new line) if current line is too full.
271 procedure Write_Str_With_Col_Check_Sloc (S : String);
272 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
273 -- node to first non-blank character if a current debug node is active.
275 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
276 -- Write Uint (using UI_Write) with initial column check, and possible
277 -- initial Write_Indent (to get new line) if current line is too full.
278 -- The format parameter determines the output format (see UI_Write).
279 -- In addition, in Debug_Generated_Code mode, sets the current node
280 -- Sloc to the first character of the output value.
282 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
283 -- Write Ureal (using same output format as UR_Write) with column checks
284 -- and a possible initial Write_Indent (to get new line) if current line
285 -- is too full. In addition, in Debug_Generated_Code mode, sets the
286 -- current node Sloc to the first character of the output value.
288 ---------------
289 -- Col_Check --
290 ---------------
292 procedure Col_Check (N : Nat) is
293 begin
294 if N + Column > Line_Limit then
295 Write_Indent_Str (" ");
296 end if;
297 end Col_Check;
299 -------------------
300 -- Indent_Annull --
301 -------------------
303 procedure Indent_Annull is
304 begin
305 Indent_Annull_Flag := True;
306 end Indent_Annull;
308 ------------------
309 -- Indent_Begin --
310 ------------------
312 procedure Indent_Begin is
313 begin
314 Indent := Indent + 3;
315 end Indent_Begin;
317 ----------------
318 -- Indent_End --
319 ----------------
321 procedure Indent_End is
322 begin
323 Indent := Indent - 3;
324 end Indent_End;
326 --------
327 -- pg --
328 --------
330 procedure pg (Node : Node_Id) is
331 begin
332 Dump_Generated_Only := True;
333 Dump_Original_Only := False;
334 Sprint_Node (Node);
335 Write_Eol;
336 end pg;
338 --------
339 -- po --
340 --------
342 procedure po (Node : Node_Id) is
343 begin
344 Dump_Generated_Only := False;
345 Dump_Original_Only := True;
346 Sprint_Node (Node);
347 Write_Eol;
348 end po;
350 ----------------------
351 -- Print_Debug_Line --
352 ----------------------
354 procedure Print_Debug_Line (S : String) is
355 begin
356 Write_Debug_Line (S, Debug_Sloc);
357 end Print_Debug_Line;
359 ---------------------------
360 -- Process_TFAI_RR_Flags --
361 ---------------------------
363 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
364 begin
365 if Treat_Fixed_As_Integer (Nod) then
366 Write_Char ('#');
367 end if;
369 if Rounded_Result (Nod) then
370 Write_Char ('@');
371 end if;
372 end Process_TFAI_RR_Flags;
374 --------
375 -- ps --
376 --------
378 procedure ps (Node : Node_Id) is
379 begin
380 Dump_Generated_Only := False;
381 Dump_Original_Only := False;
382 Sprint_Node (Node);
383 Write_Eol;
384 end ps;
386 --------------------
387 -- Set_Debug_Sloc --
388 --------------------
390 procedure Set_Debug_Sloc is
391 begin
392 if Present (Debug_Node) then
393 Set_Sloc (Debug_Node, Debug_Sloc + Source_Ptr (Column - 1));
394 Debug_Node := Empty;
395 end if;
396 end Set_Debug_Sloc;
398 -----------------
399 -- Source_Dump --
400 -----------------
402 procedure Source_Dump is
404 procedure Underline;
405 -- Put underline under string we just printed
407 procedure Underline is
408 Col : constant Int := Column;
410 begin
411 Write_Eol;
413 while Col > Column loop
414 Write_Char ('-');
415 end loop;
417 Write_Eol;
418 end Underline;
420 -- Start of processing for Tree_Dump.
422 begin
423 Dump_Generated_Only := Debug_Flag_G or
424 Print_Generated_Code or
425 Debug_Generated_Code;
426 Dump_Original_Only := Debug_Flag_O;
427 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
429 -- Note that we turn off the tree dump flags immediately, before
430 -- starting the dump. This avoids generating two copies of the dump
431 -- if an abort occurs after printing the dump, and more importantly,
432 -- avoids an infinite loop if an abort occurs during the dump.
434 if Debug_Flag_Z then
435 Debug_Flag_Z := False;
436 Write_Eol;
437 Write_Eol;
438 Write_Str ("Source recreated from tree of Standard (spec)");
439 Underline;
440 Sprint_Node (Standard_Package_Node);
441 Write_Eol;
442 Write_Eol;
443 end if;
445 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
446 Debug_Flag_G := False;
447 Debug_Flag_O := False;
448 Debug_Flag_S := False;
450 -- Dump requested units
452 for U in Main_Unit .. Last_Unit loop
454 -- Dump all units if -gnatdf set, otherwise we dump only
455 -- the source files that are in the extended main source.
457 if Debug_Flag_F
458 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
459 then
460 -- If we are generating debug files, setup to write them
462 if Debug_Generated_Code then
463 Set_Special_Output (Print_Debug_Line'Access);
464 Create_Debug_Source (Source_Index (U), Debug_Sloc);
465 Sprint_Node (Cunit (U));
466 Write_Eol;
467 Close_Debug_Source;
468 Set_Special_Output (null);
470 -- Normal output to standard output file
472 else
473 Write_Str ("Source recreated from tree for ");
474 Write_Unit_Name (Unit_Name (U));
475 Underline;
476 Sprint_Node (Cunit (U));
477 Write_Eol;
478 Write_Eol;
479 end if;
480 end if;
481 end loop;
482 end if;
483 end Source_Dump;
485 ---------------------
486 -- Sprint_And_List --
487 ---------------------
489 procedure Sprint_And_List (List : List_Id) is
490 Node : Node_Id;
491 begin
492 if Is_Non_Empty_List (List) then
493 Node := First (List);
494 loop
495 Sprint_Node (Node);
496 Next (Node);
497 exit when Node = Empty;
498 Write_Str (" and ");
499 end loop;
500 end if;
501 end Sprint_And_List;
503 ---------------------
504 -- Sprint_Bar_List --
505 ---------------------
507 procedure Sprint_Bar_List (List : List_Id) is
508 Node : Node_Id;
509 begin
510 if Is_Non_Empty_List (List) then
511 Node := First (List);
512 loop
513 Sprint_Node (Node);
514 Next (Node);
515 exit when Node = Empty;
516 Write_Str (" | ");
517 end loop;
518 end if;
519 end Sprint_Bar_List;
521 -----------------------
522 -- Sprint_Comma_List --
523 -----------------------
525 procedure Sprint_Comma_List (List : List_Id) is
526 Node : Node_Id;
528 begin
529 if Is_Non_Empty_List (List) then
530 Node := First (List);
531 loop
532 Sprint_Node (Node);
533 Next (Node);
534 exit when Node = Empty;
536 if not Is_Rewrite_Insertion (Node)
537 or else not Dump_Original_Only
538 then
539 Write_Str (", ");
540 end if;
541 end loop;
542 end if;
543 end Sprint_Comma_List;
545 --------------------------
546 -- Sprint_Indented_List --
547 --------------------------
549 procedure Sprint_Indented_List (List : List_Id) is
550 begin
551 Indent_Begin;
552 Sprint_Node_List (List);
553 Indent_End;
554 end Sprint_Indented_List;
556 ---------------------
557 -- Sprint_Left_Opnd --
558 ---------------------
560 procedure Sprint_Left_Opnd (N : Node_Id) is
561 Opnd : constant Node_Id := Left_Opnd (N);
563 begin
564 if Paren_Count (Opnd) /= 0
565 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
566 then
567 Sprint_Node (Opnd);
569 else
570 Write_Char ('(');
571 Sprint_Node (Opnd);
572 Write_Char (')');
573 end if;
574 end Sprint_Left_Opnd;
576 -----------------
577 -- Sprint_Node --
578 -----------------
580 procedure Sprint_Node (Node : Node_Id) is
581 begin
582 if Is_Rewrite_Insertion (Node) then
583 if not Dump_Original_Only then
585 -- For special cases of nodes that always output <<< >>>
586 -- do not duplicate the output at this point.
588 if Nkind (Node) = N_Freeze_Entity
589 or else Nkind (Node) = N_Implicit_Label_Declaration
590 then
591 Sprint_Node_Actual (Node);
593 -- Normal case where <<< >>> may be required
595 else
596 Write_Rewrite_Str ("<<<");
597 Sprint_Node_Actual (Node);
598 Write_Rewrite_Str (">>>");
599 end if;
600 end if;
602 elsif Is_Rewrite_Substitution (Node) then
604 -- Case of dump generated only
606 if Dump_Generated_Only then
607 Sprint_Node_Actual (Node);
609 -- Case of dump original only
611 elsif Dump_Original_Only then
612 Sprint_Node_Actual (Original_Node (Node));
614 -- Case of both being dumped
616 else
617 Sprint_Node_Actual (Original_Node (Node));
618 Write_Rewrite_Str ("<<<");
619 Sprint_Node_Actual (Node);
620 Write_Rewrite_Str (">>>");
621 end if;
623 else
624 Sprint_Node_Actual (Node);
625 end if;
626 end Sprint_Node;
628 ------------------------
629 -- Sprint_Node_Actual --
630 ------------------------
632 procedure Sprint_Node_Actual (Node : Node_Id) is
633 Save_Debug_Node : constant Node_Id := Debug_Node;
635 begin
636 if Node = Empty then
637 return;
638 end if;
640 for J in 1 .. Paren_Count (Node) loop
641 Write_Str_With_Col_Check ("(");
642 end loop;
644 -- Setup node for Sloc fixup if writing a debug source file. Note
645 -- that we take care of any previous node not yet properly set.
647 if Debug_Generated_Code then
648 Debug_Node := Node;
649 end if;
651 if Nkind (Node) in N_Subexpr
652 and then Do_Range_Check (Node)
653 then
654 Write_Str_With_Col_Check ("{");
655 end if;
657 -- Select print circuit based on node kind
659 case Nkind (Node) is
661 when N_Abort_Statement =>
662 Write_Indent_Str_Sloc ("abort ");
663 Sprint_Comma_List (Names (Node));
664 Write_Char (';');
666 when N_Abortable_Part =>
667 Set_Debug_Sloc;
668 Write_Str_Sloc ("abort ");
669 Sprint_Indented_List (Statements (Node));
671 when N_Abstract_Subprogram_Declaration =>
672 Write_Indent;
673 Sprint_Node (Specification (Node));
674 Write_Str_With_Col_Check (" is ");
675 Write_Str_Sloc ("abstract;");
677 when N_Accept_Alternative =>
678 Sprint_Node_List (Pragmas_Before (Node));
680 if Present (Condition (Node)) then
681 Write_Indent_Str ("when ");
682 Sprint_Node (Condition (Node));
683 Write_Str (" => ");
684 Indent_Annull;
685 end if;
687 Sprint_Node_Sloc (Accept_Statement (Node));
688 Sprint_Node_List (Statements (Node));
690 when N_Accept_Statement =>
691 Write_Indent_Str_Sloc ("accept ");
692 Write_Id (Entry_Direct_Name (Node));
694 if Present (Entry_Index (Node)) then
695 Write_Str_With_Col_Check (" (");
696 Sprint_Node (Entry_Index (Node));
697 Write_Char (')');
698 end if;
700 Write_Param_Specs (Node);
702 if Present (Handled_Statement_Sequence (Node)) then
703 Write_Str_With_Col_Check (" do");
704 Sprint_Node (Handled_Statement_Sequence (Node));
705 Write_Indent_Str ("end ");
706 Write_Id (Entry_Direct_Name (Node));
707 end if;
709 Write_Char (';');
711 when N_Access_Definition =>
713 -- Ada 2005 (AI-254)
715 if Present (Access_To_Subprogram_Definition (Node)) then
716 Sprint_Node (Access_To_Subprogram_Definition (Node));
717 else
718 -- Ada 2005 (AI-231)
720 if Null_Exclusion_Present (Node) then
721 Write_Str ("not null ");
722 end if;
724 Write_Str_With_Col_Check_Sloc ("access ");
726 if All_Present (Node) then
727 Write_Str ("all ");
728 elsif Constant_Present (Node) then
729 Write_Str ("constant ");
730 end if;
732 Sprint_Node (Subtype_Mark (Node));
733 end if;
735 when N_Access_Function_Definition =>
737 -- Ada 2005 (AI-231)
739 if Null_Exclusion_Present (Node) then
740 Write_Str ("not null ");
741 end if;
743 Write_Str_With_Col_Check_Sloc ("access ");
745 if Protected_Present (Node) then
746 Write_Str_With_Col_Check ("protected ");
747 end if;
749 Write_Str_With_Col_Check ("function");
750 Write_Param_Specs (Node);
751 Write_Str_With_Col_Check (" return ");
752 Sprint_Node (Result_Definition (Node));
754 when N_Access_Procedure_Definition =>
756 -- Ada 2005 (AI-231)
758 if Null_Exclusion_Present (Node) then
759 Write_Str ("not null ");
760 end if;
762 Write_Str_With_Col_Check_Sloc ("access ");
764 if Protected_Present (Node) then
765 Write_Str_With_Col_Check ("protected ");
766 end if;
768 Write_Str_With_Col_Check ("procedure");
769 Write_Param_Specs (Node);
771 when N_Access_To_Object_Definition =>
772 Write_Str_With_Col_Check_Sloc ("access ");
774 if All_Present (Node) then
775 Write_Str_With_Col_Check ("all ");
776 elsif Constant_Present (Node) then
777 Write_Str_With_Col_Check ("constant ");
778 end if;
780 -- Ada 2005 (AI-231)
782 if Null_Exclusion_Present (Node) then
783 Write_Str ("not null ");
784 end if;
786 Sprint_Node (Subtype_Indication (Node));
788 when N_Aggregate =>
789 if Null_Record_Present (Node) then
790 Write_Str_With_Col_Check_Sloc ("(null record)");
792 else
793 Write_Str_With_Col_Check_Sloc ("(");
795 if Present (Expressions (Node)) then
796 Sprint_Comma_List (Expressions (Node));
798 if Present (Component_Associations (Node)) then
799 Write_Str (", ");
800 end if;
801 end if;
803 if Present (Component_Associations (Node)) then
804 Indent_Begin;
806 declare
807 Nd : Node_Id;
809 begin
810 Nd := First (Component_Associations (Node));
812 loop
813 Write_Indent;
814 Sprint_Node (Nd);
815 Next (Nd);
816 exit when No (Nd);
818 if not Is_Rewrite_Insertion (Nd)
819 or else not Dump_Original_Only
820 then
821 Write_Str (", ");
822 end if;
823 end loop;
824 end;
826 Indent_End;
827 end if;
829 Write_Char (')');
830 end if;
832 when N_Allocator =>
833 Write_Str_With_Col_Check_Sloc ("new ");
835 -- Ada 2005 (AI-231)
837 if Null_Exclusion_Present (Node) then
838 Write_Str ("not null ");
839 end if;
841 Sprint_Node (Expression (Node));
843 if Present (Storage_Pool (Node)) then
844 Write_Str_With_Col_Check ("[storage_pool = ");
845 Sprint_Node (Storage_Pool (Node));
846 Write_Char (']');
847 end if;
849 when N_And_Then =>
850 Sprint_Left_Opnd (Node);
851 Write_Str_Sloc (" and then ");
852 Sprint_Right_Opnd (Node);
854 when N_At_Clause =>
855 Write_Indent_Str_Sloc ("for ");
856 Write_Id (Identifier (Node));
857 Write_Str_With_Col_Check (" use at ");
858 Sprint_Node (Expression (Node));
859 Write_Char (';');
861 when N_Assignment_Statement =>
862 Write_Indent;
863 Sprint_Node (Name (Node));
864 Write_Str_Sloc (" := ");
865 Sprint_Node (Expression (Node));
866 Write_Char (';');
868 when N_Asynchronous_Select =>
869 Write_Indent_Str_Sloc ("select");
870 Indent_Begin;
871 Sprint_Node (Triggering_Alternative (Node));
872 Indent_End;
874 -- Note: let the printing of Abortable_Part handle outputting
875 -- the ABORT keyword, so that the Slco can be set correctly.
877 Write_Indent_Str ("then ");
878 Sprint_Node (Abortable_Part (Node));
879 Write_Indent_Str ("end select;");
881 when N_Attribute_Definition_Clause =>
882 Write_Indent_Str_Sloc ("for ");
883 Sprint_Node (Name (Node));
884 Write_Char (''');
885 Write_Name_With_Col_Check (Chars (Node));
886 Write_Str_With_Col_Check (" use ");
887 Sprint_Node (Expression (Node));
888 Write_Char (';');
890 when N_Attribute_Reference =>
891 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
892 Write_Indent;
893 end if;
895 Sprint_Node (Prefix (Node));
896 Write_Char_Sloc (''');
897 Write_Name_With_Col_Check (Attribute_Name (Node));
898 Sprint_Paren_Comma_List (Expressions (Node));
900 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
901 Write_Char (';');
902 end if;
904 when N_Block_Statement =>
905 Write_Indent;
907 if Present (Identifier (Node))
908 and then (not Has_Created_Identifier (Node)
909 or else not Dump_Original_Only)
910 then
911 Write_Rewrite_Str ("<<<");
912 Write_Id (Identifier (Node));
913 Write_Str (" : ");
914 Write_Rewrite_Str (">>>");
915 end if;
917 if Present (Declarations (Node)) then
918 Write_Str_With_Col_Check_Sloc ("declare");
919 Sprint_Indented_List (Declarations (Node));
920 Write_Indent;
921 end if;
923 Write_Str_With_Col_Check_Sloc ("begin");
924 Sprint_Node (Handled_Statement_Sequence (Node));
925 Write_Indent_Str ("end");
927 if Present (Identifier (Node))
928 and then (not Has_Created_Identifier (Node)
929 or else not Dump_Original_Only)
930 then
931 Write_Rewrite_Str ("<<<");
932 Write_Char (' ');
933 Write_Id (Identifier (Node));
934 Write_Rewrite_Str (">>>");
935 end if;
937 Write_Char (';');
939 when N_Case_Statement =>
940 Write_Indent_Str_Sloc ("case ");
941 Sprint_Node (Expression (Node));
942 Write_Str (" is");
943 Sprint_Indented_List (Alternatives (Node));
944 Write_Indent_Str ("end case;");
946 when N_Case_Statement_Alternative =>
947 Write_Indent_Str_Sloc ("when ");
948 Sprint_Bar_List (Discrete_Choices (Node));
949 Write_Str (" => ");
950 Sprint_Indented_List (Statements (Node));
952 when N_Character_Literal =>
953 if Column > 70 then
954 Write_Indent_Str (" ");
955 end if;
957 Write_Char_Sloc (''');
958 Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
959 Write_Char (''');
961 when N_Code_Statement =>
962 Write_Indent;
963 Set_Debug_Sloc;
964 Sprint_Node (Expression (Node));
965 Write_Char (';');
967 when N_Compilation_Unit =>
968 Sprint_Node_List (Context_Items (Node));
969 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
971 if Private_Present (Node) then
972 Write_Indent_Str ("private ");
973 Indent_Annull;
974 end if;
976 Sprint_Node_Sloc (Unit (Node));
978 if Present (Actions (Aux_Decls_Node (Node)))
979 or else
980 Present (Pragmas_After (Aux_Decls_Node (Node)))
981 then
982 Write_Indent;
983 end if;
985 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
986 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
988 when N_Compilation_Unit_Aux =>
989 null; -- nothing to do, never used, see above
991 when N_Component_Association =>
992 Set_Debug_Sloc;
993 Sprint_Bar_List (Choices (Node));
994 Write_Str (" => ");
996 -- Ada 2005 (AI-287): Print the mbox if present
998 if Box_Present (Node) then
999 Write_Str_With_Col_Check ("<>");
1000 else
1001 Sprint_Node (Expression (Node));
1002 end if;
1004 when N_Component_Clause =>
1005 Write_Indent;
1006 Sprint_Node (Component_Name (Node));
1007 Write_Str_Sloc (" at ");
1008 Sprint_Node (Position (Node));
1009 Write_Char (' ');
1010 Write_Str_With_Col_Check ("range ");
1011 Sprint_Node (First_Bit (Node));
1012 Write_Str (" .. ");
1013 Sprint_Node (Last_Bit (Node));
1014 Write_Char (';');
1016 when N_Component_Definition =>
1017 Set_Debug_Sloc;
1019 -- Ada 2005 (AI-230): Access definition components
1021 if Present (Access_Definition (Node)) then
1022 Sprint_Node (Access_Definition (Node));
1024 elsif Present (Subtype_Indication (Node)) then
1025 if Aliased_Present (Node) then
1026 Write_Str_With_Col_Check ("aliased ");
1027 end if;
1029 -- Ada 2005 (AI-231)
1031 if Null_Exclusion_Present (Node) then
1032 Write_Str (" not null ");
1033 end if;
1035 Sprint_Node (Subtype_Indication (Node));
1037 else
1038 Write_Str (" ??? ");
1039 end if;
1041 when N_Component_Declaration =>
1042 if Write_Indent_Identifiers_Sloc (Node) then
1043 Write_Str (" : ");
1044 Sprint_Node (Component_Definition (Node));
1046 if Present (Expression (Node)) then
1047 Write_Str (" := ");
1048 Sprint_Node (Expression (Node));
1049 end if;
1051 Write_Char (';');
1052 end if;
1054 when N_Component_List =>
1055 if Null_Present (Node) then
1056 Indent_Begin;
1057 Write_Indent_Str_Sloc ("null");
1058 Write_Char (';');
1059 Indent_End;
1061 else
1062 Set_Debug_Sloc;
1063 Sprint_Indented_List (Component_Items (Node));
1064 Sprint_Node (Variant_Part (Node));
1065 end if;
1067 when N_Conditional_Entry_Call =>
1068 Write_Indent_Str_Sloc ("select");
1069 Indent_Begin;
1070 Sprint_Node (Entry_Call_Alternative (Node));
1071 Indent_End;
1072 Write_Indent_Str ("else");
1073 Sprint_Indented_List (Else_Statements (Node));
1074 Write_Indent_Str ("end select;");
1076 when N_Conditional_Expression =>
1077 declare
1078 Condition : constant Node_Id := First (Expressions (Node));
1079 Then_Expr : constant Node_Id := Next (Condition);
1080 Else_Expr : constant Node_Id := Next (Then_Expr);
1082 begin
1083 Write_Str_With_Col_Check_Sloc ("(if ");
1084 Sprint_Node (Condition);
1085 Write_Str_With_Col_Check (" then ");
1086 Sprint_Node (Then_Expr);
1087 Write_Str_With_Col_Check (" else ");
1088 Sprint_Node (Else_Expr);
1089 Write_Char (')');
1090 end;
1092 when N_Constrained_Array_Definition =>
1093 Write_Str_With_Col_Check_Sloc ("array ");
1094 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1095 Write_Str (" of ");
1097 Sprint_Node (Component_Definition (Node));
1099 when N_Decimal_Fixed_Point_Definition =>
1100 Write_Str_With_Col_Check_Sloc (" delta ");
1101 Sprint_Node (Delta_Expression (Node));
1102 Write_Str_With_Col_Check ("digits ");
1103 Sprint_Node (Digits_Expression (Node));
1104 Sprint_Opt_Node (Real_Range_Specification (Node));
1106 when N_Defining_Character_Literal =>
1107 Write_Name_With_Col_Check_Sloc (Chars (Node));
1109 when N_Defining_Identifier =>
1110 Set_Debug_Sloc;
1111 Write_Id (Node);
1113 when N_Defining_Operator_Symbol =>
1114 Write_Name_With_Col_Check_Sloc (Chars (Node));
1116 when N_Defining_Program_Unit_Name =>
1117 Set_Debug_Sloc;
1118 Sprint_Node (Name (Node));
1119 Write_Char ('.');
1120 Write_Id (Defining_Identifier (Node));
1122 when N_Delay_Alternative =>
1123 Sprint_Node_List (Pragmas_Before (Node));
1125 if Present (Condition (Node)) then
1126 Write_Indent;
1127 Write_Str_With_Col_Check ("when ");
1128 Sprint_Node (Condition (Node));
1129 Write_Str (" => ");
1130 Indent_Annull;
1131 end if;
1133 Sprint_Node_Sloc (Delay_Statement (Node));
1134 Sprint_Node_List (Statements (Node));
1136 when N_Delay_Relative_Statement =>
1137 Write_Indent_Str_Sloc ("delay ");
1138 Sprint_Node (Expression (Node));
1139 Write_Char (';');
1141 when N_Delay_Until_Statement =>
1142 Write_Indent_Str_Sloc ("delay until ");
1143 Sprint_Node (Expression (Node));
1144 Write_Char (';');
1146 when N_Delta_Constraint =>
1147 Write_Str_With_Col_Check_Sloc ("delta ");
1148 Sprint_Node (Delta_Expression (Node));
1149 Sprint_Opt_Node (Range_Constraint (Node));
1151 when N_Derived_Type_Definition =>
1152 if Abstract_Present (Node) then
1153 Write_Str_With_Col_Check ("abstract ");
1154 end if;
1156 Write_Str_With_Col_Check_Sloc ("new ");
1158 -- Ada 2005 (AI-231)
1160 if Null_Exclusion_Present (Node) then
1161 Write_Str_With_Col_Check ("not null ");
1162 end if;
1164 Sprint_Node (Subtype_Indication (Node));
1166 if Present (Interface_List (Node)) then
1167 Sprint_And_List (Interface_List (Node));
1168 Write_Str_With_Col_Check (" with ");
1169 end if;
1171 if Present (Record_Extension_Part (Node)) then
1172 if No (Interface_List (Node)) then
1173 Write_Str_With_Col_Check (" with ");
1174 end if;
1176 Sprint_Node (Record_Extension_Part (Node));
1177 end if;
1179 when N_Designator =>
1180 Sprint_Node (Name (Node));
1181 Write_Char_Sloc ('.');
1182 Write_Id (Identifier (Node));
1184 when N_Digits_Constraint =>
1185 Write_Str_With_Col_Check_Sloc ("digits ");
1186 Sprint_Node (Digits_Expression (Node));
1187 Sprint_Opt_Node (Range_Constraint (Node));
1189 when N_Discriminant_Association =>
1190 Set_Debug_Sloc;
1192 if Present (Selector_Names (Node)) then
1193 Sprint_Bar_List (Selector_Names (Node));
1194 Write_Str (" => ");
1195 end if;
1197 Set_Debug_Sloc;
1198 Sprint_Node (Expression (Node));
1200 when N_Discriminant_Specification =>
1201 Set_Debug_Sloc;
1203 if Write_Identifiers (Node) then
1204 Write_Str (" : ");
1206 if Null_Exclusion_Present (Node) then
1207 Write_Str ("not null ");
1208 end if;
1210 Sprint_Node (Discriminant_Type (Node));
1212 if Present (Expression (Node)) then
1213 Write_Str (" := ");
1214 Sprint_Node (Expression (Node));
1215 end if;
1216 else
1217 Write_Str (", ");
1218 end if;
1220 when N_Elsif_Part =>
1221 Write_Indent_Str_Sloc ("elsif ");
1222 Sprint_Node (Condition (Node));
1223 Write_Str_With_Col_Check (" then");
1224 Sprint_Indented_List (Then_Statements (Node));
1226 when N_Empty =>
1227 null;
1229 when N_Entry_Body =>
1230 Write_Indent_Str_Sloc ("entry ");
1231 Write_Id (Defining_Identifier (Node));
1232 Sprint_Node (Entry_Body_Formal_Part (Node));
1233 Write_Str_With_Col_Check (" is");
1234 Sprint_Indented_List (Declarations (Node));
1235 Write_Indent_Str ("begin");
1236 Sprint_Node (Handled_Statement_Sequence (Node));
1237 Write_Indent_Str ("end ");
1238 Write_Id (Defining_Identifier (Node));
1239 Write_Char (';');
1241 when N_Entry_Body_Formal_Part =>
1242 if Present (Entry_Index_Specification (Node)) then
1243 Write_Str_With_Col_Check_Sloc (" (");
1244 Sprint_Node (Entry_Index_Specification (Node));
1245 Write_Char (')');
1246 end if;
1248 Write_Param_Specs (Node);
1249 Write_Str_With_Col_Check_Sloc (" when ");
1250 Sprint_Node (Condition (Node));
1252 when N_Entry_Call_Alternative =>
1253 Sprint_Node_List (Pragmas_Before (Node));
1254 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1255 Sprint_Node_List (Statements (Node));
1257 when N_Entry_Call_Statement =>
1258 Write_Indent;
1259 Sprint_Node_Sloc (Name (Node));
1260 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1261 Write_Char (';');
1263 when N_Entry_Declaration =>
1264 Write_Indent_Str_Sloc ("entry ");
1265 Write_Id (Defining_Identifier (Node));
1267 if Present (Discrete_Subtype_Definition (Node)) then
1268 Write_Str_With_Col_Check (" (");
1269 Sprint_Node (Discrete_Subtype_Definition (Node));
1270 Write_Char (')');
1271 end if;
1273 Write_Param_Specs (Node);
1274 Write_Char (';');
1276 when N_Entry_Index_Specification =>
1277 Write_Str_With_Col_Check_Sloc ("for ");
1278 Write_Id (Defining_Identifier (Node));
1279 Write_Str_With_Col_Check (" in ");
1280 Sprint_Node (Discrete_Subtype_Definition (Node));
1282 when N_Enumeration_Representation_Clause =>
1283 Write_Indent_Str_Sloc ("for ");
1284 Write_Id (Identifier (Node));
1285 Write_Str_With_Col_Check (" use ");
1286 Sprint_Node (Array_Aggregate (Node));
1287 Write_Char (';');
1289 when N_Enumeration_Type_Definition =>
1290 Set_Debug_Sloc;
1292 -- Skip attempt to print Literals field if it's not there and
1293 -- we are in package Standard (case of Character, which is
1294 -- handled specially (without an explicit literals list).
1296 if Sloc (Node) > Standard_Location
1297 or else Present (Literals (Node))
1298 then
1299 Sprint_Paren_Comma_List (Literals (Node));
1300 end if;
1302 when N_Error =>
1303 Write_Str_With_Col_Check_Sloc ("<error>");
1305 when N_Exception_Declaration =>
1306 if Write_Indent_Identifiers (Node) then
1307 Write_Str_With_Col_Check (" : ");
1308 Write_Str_Sloc ("exception;");
1309 end if;
1311 when N_Exception_Handler =>
1312 Write_Indent_Str_Sloc ("when ");
1314 if Present (Choice_Parameter (Node)) then
1315 Sprint_Node (Choice_Parameter (Node));
1316 Write_Str (" : ");
1317 end if;
1319 Sprint_Bar_List (Exception_Choices (Node));
1320 Write_Str (" => ");
1321 Sprint_Indented_List (Statements (Node));
1323 when N_Exception_Renaming_Declaration =>
1324 Write_Indent;
1325 Set_Debug_Sloc;
1326 Sprint_Node (Defining_Identifier (Node));
1327 Write_Str_With_Col_Check (" : exception renames ");
1328 Sprint_Node (Name (Node));
1329 Write_Char (';');
1331 when N_Exit_Statement =>
1332 Write_Indent_Str_Sloc ("exit");
1333 Sprint_Opt_Node (Name (Node));
1335 if Present (Condition (Node)) then
1336 Write_Str_With_Col_Check (" when ");
1337 Sprint_Node (Condition (Node));
1338 end if;
1340 Write_Char (';');
1342 when N_Expanded_Name =>
1343 Sprint_Node (Prefix (Node));
1344 Write_Char_Sloc ('.');
1345 Sprint_Node (Selector_Name (Node));
1347 when N_Explicit_Dereference =>
1348 Sprint_Node (Prefix (Node));
1349 Write_Char_Sloc ('.');
1350 Write_Str_Sloc ("all");
1352 when N_Extension_Aggregate =>
1353 Write_Str_With_Col_Check_Sloc ("(");
1354 Sprint_Node (Ancestor_Part (Node));
1355 Write_Str_With_Col_Check (" with ");
1357 if Null_Record_Present (Node) then
1358 Write_Str_With_Col_Check ("null record");
1359 else
1360 if Present (Expressions (Node)) then
1361 Sprint_Comma_List (Expressions (Node));
1363 if Present (Component_Associations (Node)) then
1364 Write_Str (", ");
1365 end if;
1366 end if;
1368 if Present (Component_Associations (Node)) then
1369 Sprint_Comma_List (Component_Associations (Node));
1370 end if;
1371 end if;
1373 Write_Char (')');
1375 when N_Floating_Point_Definition =>
1376 Write_Str_With_Col_Check_Sloc ("digits ");
1377 Sprint_Node (Digits_Expression (Node));
1378 Sprint_Opt_Node (Real_Range_Specification (Node));
1380 when N_Formal_Decimal_Fixed_Point_Definition =>
1381 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1383 when N_Formal_Derived_Type_Definition =>
1384 Write_Str_With_Col_Check_Sloc ("new ");
1385 Sprint_Node (Subtype_Mark (Node));
1387 if Private_Present (Node) then
1388 Write_Str_With_Col_Check (" with private");
1389 end if;
1391 when N_Formal_Abstract_Subprogram_Declaration =>
1392 Write_Indent_Str_Sloc ("with ");
1393 Sprint_Node (Specification (Node));
1395 Write_Str_With_Col_Check (" is abstract");
1397 if Box_Present (Node) then
1398 Write_Str_With_Col_Check (" <>");
1399 elsif Present (Default_Name (Node)) then
1400 Write_Str_With_Col_Check (" ");
1401 Sprint_Node (Default_Name (Node));
1402 end if;
1404 Write_Char (';');
1406 when N_Formal_Concrete_Subprogram_Declaration =>
1407 Write_Indent_Str_Sloc ("with ");
1408 Sprint_Node (Specification (Node));
1410 if Box_Present (Node) then
1411 Write_Str_With_Col_Check (" is <>");
1412 elsif Present (Default_Name (Node)) then
1413 Write_Str_With_Col_Check (" is ");
1414 Sprint_Node (Default_Name (Node));
1415 end if;
1417 Write_Char (';');
1419 when N_Formal_Discrete_Type_Definition =>
1420 Write_Str_With_Col_Check_Sloc ("<>");
1422 when N_Formal_Floating_Point_Definition =>
1423 Write_Str_With_Col_Check_Sloc ("digits <>");
1425 when N_Formal_Modular_Type_Definition =>
1426 Write_Str_With_Col_Check_Sloc ("mod <>");
1428 when N_Formal_Object_Declaration =>
1429 Set_Debug_Sloc;
1431 if Write_Indent_Identifiers (Node) then
1432 Write_Str (" : ");
1434 if In_Present (Node) then
1435 Write_Str_With_Col_Check ("in ");
1436 end if;
1438 if Out_Present (Node) then
1439 Write_Str_With_Col_Check ("out ");
1440 end if;
1442 Sprint_Node (Subtype_Mark (Node));
1444 if Present (Expression (Node)) then
1445 Write_Str (" := ");
1446 Sprint_Node (Expression (Node));
1447 end if;
1449 Write_Char (';');
1450 end if;
1452 when N_Formal_Ordinary_Fixed_Point_Definition =>
1453 Write_Str_With_Col_Check_Sloc ("delta <>");
1455 when N_Formal_Package_Declaration =>
1456 Write_Indent_Str_Sloc ("with package ");
1457 Write_Id (Defining_Identifier (Node));
1458 Write_Str_With_Col_Check (" is new ");
1459 Sprint_Node (Name (Node));
1460 Write_Str_With_Col_Check (" (<>);");
1462 when N_Formal_Private_Type_Definition =>
1463 if Abstract_Present (Node) then
1464 Write_Str_With_Col_Check ("abstract ");
1465 end if;
1467 if Tagged_Present (Node) then
1468 Write_Str_With_Col_Check ("tagged ");
1469 end if;
1471 if Limited_Present (Node) then
1472 Write_Str_With_Col_Check ("limited ");
1473 end if;
1475 Write_Str_With_Col_Check_Sloc ("private");
1477 when N_Formal_Signed_Integer_Type_Definition =>
1478 Write_Str_With_Col_Check_Sloc ("range <>");
1480 when N_Formal_Type_Declaration =>
1481 Write_Indent_Str_Sloc ("type ");
1482 Write_Id (Defining_Identifier (Node));
1484 if Present (Discriminant_Specifications (Node)) then
1485 Write_Discr_Specs (Node);
1486 elsif Unknown_Discriminants_Present (Node) then
1487 Write_Str_With_Col_Check ("(<>)");
1488 end if;
1490 Write_Str_With_Col_Check (" is ");
1491 Sprint_Node (Formal_Type_Definition (Node));
1492 Write_Char (';');
1494 when N_Free_Statement =>
1495 Write_Indent_Str_Sloc ("free ");
1496 Sprint_Node (Expression (Node));
1497 Write_Char (';');
1499 when N_Freeze_Entity =>
1500 if Dump_Original_Only then
1501 null;
1503 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1504 Write_Indent;
1505 Write_Rewrite_Str ("<<<");
1506 Write_Str_With_Col_Check_Sloc ("freeze ");
1507 Write_Id (Entity (Node));
1508 Write_Str (" [");
1510 if No (Actions (Node)) then
1511 Write_Char (']');
1513 else
1514 Freeze_Indent := Freeze_Indent + 1;
1515 Sprint_Indented_List (Actions (Node));
1516 Freeze_Indent := Freeze_Indent - 1;
1517 Write_Indent_Str ("]");
1518 end if;
1520 Write_Rewrite_Str (">>>");
1521 end if;
1523 when N_Full_Type_Declaration =>
1524 Write_Indent_Str_Sloc ("type ");
1525 Write_Id (Defining_Identifier (Node));
1526 Write_Discr_Specs (Node);
1527 Write_Str_With_Col_Check (" is ");
1528 Sprint_Node (Type_Definition (Node));
1529 Write_Char (';');
1531 when N_Function_Call =>
1532 Set_Debug_Sloc;
1533 Sprint_Node (Name (Node));
1534 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1536 when N_Function_Instantiation =>
1537 Write_Indent_Str_Sloc ("function ");
1538 Sprint_Node (Defining_Unit_Name (Node));
1539 Write_Str_With_Col_Check (" is new ");
1540 Sprint_Node (Name (Node));
1541 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1542 Write_Char (';');
1544 when N_Function_Specification =>
1545 Write_Str_With_Col_Check_Sloc ("function ");
1546 Sprint_Node (Defining_Unit_Name (Node));
1547 Write_Param_Specs (Node);
1548 Write_Str_With_Col_Check (" return ");
1550 -- Ada 2005 (AI-231)
1552 if Nkind (Result_Definition (Node)) /= N_Access_Definition
1553 and then Null_Exclusion_Present (Node)
1554 then
1555 Write_Str (" not null ");
1556 end if;
1558 Sprint_Node (Result_Definition (Node));
1560 when N_Generic_Association =>
1561 Set_Debug_Sloc;
1563 if Present (Selector_Name (Node)) then
1564 Sprint_Node (Selector_Name (Node));
1565 Write_Str (" => ");
1566 end if;
1568 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1570 when N_Generic_Function_Renaming_Declaration =>
1571 Write_Indent_Str_Sloc ("generic function ");
1572 Sprint_Node (Defining_Unit_Name (Node));
1573 Write_Str_With_Col_Check (" renames ");
1574 Sprint_Node (Name (Node));
1575 Write_Char (';');
1577 when N_Generic_Package_Declaration =>
1578 Write_Indent;
1579 Write_Indent_Str_Sloc ("generic ");
1580 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1581 Write_Indent;
1582 Sprint_Node (Specification (Node));
1583 Write_Char (';');
1585 when N_Generic_Package_Renaming_Declaration =>
1586 Write_Indent_Str_Sloc ("generic package ");
1587 Sprint_Node (Defining_Unit_Name (Node));
1588 Write_Str_With_Col_Check (" renames ");
1589 Sprint_Node (Name (Node));
1590 Write_Char (';');
1592 when N_Generic_Procedure_Renaming_Declaration =>
1593 Write_Indent_Str_Sloc ("generic procedure ");
1594 Sprint_Node (Defining_Unit_Name (Node));
1595 Write_Str_With_Col_Check (" renames ");
1596 Sprint_Node (Name (Node));
1597 Write_Char (';');
1599 when N_Generic_Subprogram_Declaration =>
1600 Write_Indent;
1601 Write_Indent_Str_Sloc ("generic ");
1602 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1603 Write_Indent;
1604 Sprint_Node (Specification (Node));
1605 Write_Char (';');
1607 when N_Goto_Statement =>
1608 Write_Indent_Str_Sloc ("goto ");
1609 Sprint_Node (Name (Node));
1610 Write_Char (';');
1612 if Nkind (Next (Node)) = N_Label then
1613 Write_Indent;
1614 end if;
1616 when N_Handled_Sequence_Of_Statements =>
1617 Set_Debug_Sloc;
1618 Sprint_Indented_List (Statements (Node));
1620 if Present (Exception_Handlers (Node)) then
1621 Write_Indent_Str ("exception");
1622 Indent_Begin;
1623 Sprint_Node_List (Exception_Handlers (Node));
1624 Indent_End;
1625 end if;
1627 if Present (At_End_Proc (Node)) then
1628 Write_Indent_Str ("at end");
1629 Indent_Begin;
1630 Write_Indent;
1631 Sprint_Node (At_End_Proc (Node));
1632 Write_Char (';');
1633 Indent_End;
1634 end if;
1636 when N_Identifier =>
1637 Set_Debug_Sloc;
1638 Write_Id (Node);
1640 when N_If_Statement =>
1641 Write_Indent_Str_Sloc ("if ");
1642 Sprint_Node (Condition (Node));
1643 Write_Str_With_Col_Check (" then");
1644 Sprint_Indented_List (Then_Statements (Node));
1645 Sprint_Opt_Node_List (Elsif_Parts (Node));
1647 if Present (Else_Statements (Node)) then
1648 Write_Indent_Str ("else");
1649 Sprint_Indented_List (Else_Statements (Node));
1650 end if;
1652 Write_Indent_Str ("end if;");
1654 when N_Implicit_Label_Declaration =>
1655 if not Dump_Original_Only then
1656 Write_Indent;
1657 Write_Rewrite_Str ("<<<");
1658 Set_Debug_Sloc;
1659 Write_Id (Defining_Identifier (Node));
1660 Write_Str (" : ");
1661 Write_Str_With_Col_Check ("label");
1662 Write_Rewrite_Str (">>>");
1663 end if;
1665 when N_In =>
1666 Sprint_Left_Opnd (Node);
1667 Write_Str_Sloc (" in ");
1668 Sprint_Right_Opnd (Node);
1670 when N_Incomplete_Type_Declaration =>
1671 Write_Indent_Str_Sloc ("type ");
1672 Write_Id (Defining_Identifier (Node));
1674 if Present (Discriminant_Specifications (Node)) then
1675 Write_Discr_Specs (Node);
1676 elsif Unknown_Discriminants_Present (Node) then
1677 Write_Str_With_Col_Check ("(<>)");
1678 end if;
1680 Write_Char (';');
1682 when N_Index_Or_Discriminant_Constraint =>
1683 Set_Debug_Sloc;
1684 Sprint_Paren_Comma_List (Constraints (Node));
1686 when N_Indexed_Component =>
1687 Sprint_Node_Sloc (Prefix (Node));
1688 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1690 when N_Integer_Literal =>
1691 if Print_In_Hex (Node) then
1692 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1693 else
1694 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1695 end if;
1697 when N_Iteration_Scheme =>
1698 if Present (Condition (Node)) then
1699 Write_Str_With_Col_Check_Sloc ("while ");
1700 Sprint_Node (Condition (Node));
1701 else
1702 Write_Str_With_Col_Check_Sloc ("for ");
1703 Sprint_Node (Loop_Parameter_Specification (Node));
1704 end if;
1706 Write_Char (' ');
1708 when N_Itype_Reference =>
1709 Write_Indent_Str_Sloc ("reference ");
1710 Write_Id (Itype (Node));
1712 when N_Label =>
1713 Write_Indent_Str_Sloc ("<<");
1714 Write_Id (Identifier (Node));
1715 Write_Str (">>");
1717 when N_Loop_Parameter_Specification =>
1718 Set_Debug_Sloc;
1719 Write_Id (Defining_Identifier (Node));
1720 Write_Str_With_Col_Check (" in ");
1722 if Reverse_Present (Node) then
1723 Write_Str_With_Col_Check ("reverse ");
1724 end if;
1726 Sprint_Node (Discrete_Subtype_Definition (Node));
1728 when N_Loop_Statement =>
1729 Write_Indent;
1731 if Present (Identifier (Node))
1732 and then (not Has_Created_Identifier (Node)
1733 or else not Dump_Original_Only)
1734 then
1735 Write_Rewrite_Str ("<<<");
1736 Write_Id (Identifier (Node));
1737 Write_Str (" : ");
1738 Write_Rewrite_Str (">>>");
1739 Sprint_Node (Iteration_Scheme (Node));
1740 Write_Str_With_Col_Check_Sloc ("loop");
1741 Sprint_Indented_List (Statements (Node));
1742 Write_Indent_Str ("end loop ");
1743 Write_Rewrite_Str ("<<<");
1744 Write_Id (Identifier (Node));
1745 Write_Rewrite_Str (">>>");
1746 Write_Char (';');
1748 else
1749 Sprint_Node (Iteration_Scheme (Node));
1750 Write_Str_With_Col_Check_Sloc ("loop");
1751 Sprint_Indented_List (Statements (Node));
1752 Write_Indent_Str ("end loop;");
1753 end if;
1755 when N_Mod_Clause =>
1756 Sprint_Node_List (Pragmas_Before (Node));
1757 Write_Str_With_Col_Check_Sloc ("at mod ");
1758 Sprint_Node (Expression (Node));
1760 when N_Modular_Type_Definition =>
1761 Write_Str_With_Col_Check_Sloc ("mod ");
1762 Sprint_Node (Expression (Node));
1764 when N_Not_In =>
1765 Sprint_Left_Opnd (Node);
1766 Write_Str_Sloc (" not in ");
1767 Sprint_Right_Opnd (Node);
1769 when N_Null =>
1770 Write_Str_With_Col_Check_Sloc ("null");
1772 when N_Null_Statement =>
1773 if Comes_From_Source (Node)
1774 or else Dump_Freeze_Null
1775 or else not Is_List_Member (Node)
1776 or else (No (Prev (Node)) and then No (Next (Node)))
1777 then
1778 Write_Indent_Str_Sloc ("null;");
1779 end if;
1781 when N_Number_Declaration =>
1782 Set_Debug_Sloc;
1784 if Write_Indent_Identifiers (Node) then
1785 Write_Str_With_Col_Check (" : constant ");
1786 Write_Str (" := ");
1787 Sprint_Node (Expression (Node));
1788 Write_Char (';');
1789 end if;
1791 when N_Object_Declaration =>
1792 Set_Debug_Sloc;
1794 if Write_Indent_Identifiers (Node) then
1795 Write_Str (" : ");
1797 if Aliased_Present (Node) then
1798 Write_Str_With_Col_Check ("aliased ");
1799 end if;
1801 if Constant_Present (Node) then
1802 Write_Str_With_Col_Check ("constant ");
1803 end if;
1805 -- Ada 2005 (AI-231)
1807 if Null_Exclusion_Present (Node) then
1808 Write_Str_With_Col_Check ("not null ");
1809 end if;
1811 Sprint_Node (Object_Definition (Node));
1813 if Present (Expression (Node)) then
1814 Write_Str (" := ");
1815 Sprint_Node (Expression (Node));
1816 end if;
1818 Write_Char (';');
1819 end if;
1821 when N_Object_Renaming_Declaration =>
1822 Write_Indent;
1823 Set_Debug_Sloc;
1824 Sprint_Node (Defining_Identifier (Node));
1825 Write_Str (" : ");
1827 -- Ada 2005 (AI-230): Access renamings
1829 if Present (Access_Definition (Node)) then
1830 Sprint_Node (Access_Definition (Node));
1832 elsif Present (Subtype_Mark (Node)) then
1833 Sprint_Node (Subtype_Mark (Node));
1835 else
1836 Write_Str (" ??? ");
1837 end if;
1839 Write_Str_With_Col_Check (" renames ");
1840 Sprint_Node (Name (Node));
1841 Write_Char (';');
1843 when N_Op_Abs =>
1844 Write_Operator (Node, "abs ");
1845 Sprint_Right_Opnd (Node);
1847 when N_Op_Add =>
1848 Sprint_Left_Opnd (Node);
1849 Write_Operator (Node, " + ");
1850 Sprint_Right_Opnd (Node);
1852 when N_Op_And =>
1853 Sprint_Left_Opnd (Node);
1854 Write_Operator (Node, " and ");
1855 Sprint_Right_Opnd (Node);
1857 when N_Op_Concat =>
1858 Sprint_Left_Opnd (Node);
1859 Write_Operator (Node, " & ");
1860 Sprint_Right_Opnd (Node);
1862 when N_Op_Divide =>
1863 Sprint_Left_Opnd (Node);
1864 Write_Char (' ');
1865 Process_TFAI_RR_Flags (Node);
1866 Write_Operator (Node, "/ ");
1867 Sprint_Right_Opnd (Node);
1869 when N_Op_Eq =>
1870 Sprint_Left_Opnd (Node);
1871 Write_Operator (Node, " = ");
1872 Sprint_Right_Opnd (Node);
1874 when N_Op_Expon =>
1875 Sprint_Left_Opnd (Node);
1876 Write_Operator (Node, " ** ");
1877 Sprint_Right_Opnd (Node);
1879 when N_Op_Ge =>
1880 Sprint_Left_Opnd (Node);
1881 Write_Operator (Node, " >= ");
1882 Sprint_Right_Opnd (Node);
1884 when N_Op_Gt =>
1885 Sprint_Left_Opnd (Node);
1886 Write_Operator (Node, " > ");
1887 Sprint_Right_Opnd (Node);
1889 when N_Op_Le =>
1890 Sprint_Left_Opnd (Node);
1891 Write_Operator (Node, " <= ");
1892 Sprint_Right_Opnd (Node);
1894 when N_Op_Lt =>
1895 Sprint_Left_Opnd (Node);
1896 Write_Operator (Node, " < ");
1897 Sprint_Right_Opnd (Node);
1899 when N_Op_Minus =>
1900 Write_Operator (Node, "-");
1901 Sprint_Right_Opnd (Node);
1903 when N_Op_Mod =>
1904 Sprint_Left_Opnd (Node);
1906 if Treat_Fixed_As_Integer (Node) then
1907 Write_Str (" #");
1908 end if;
1910 Write_Operator (Node, " mod ");
1911 Sprint_Right_Opnd (Node);
1913 when N_Op_Multiply =>
1914 Sprint_Left_Opnd (Node);
1915 Write_Char (' ');
1916 Process_TFAI_RR_Flags (Node);
1917 Write_Operator (Node, "* ");
1918 Sprint_Right_Opnd (Node);
1920 when N_Op_Ne =>
1921 Sprint_Left_Opnd (Node);
1922 Write_Operator (Node, " /= ");
1923 Sprint_Right_Opnd (Node);
1925 when N_Op_Not =>
1926 Write_Operator (Node, "not ");
1927 Sprint_Right_Opnd (Node);
1929 when N_Op_Or =>
1930 Sprint_Left_Opnd (Node);
1931 Write_Operator (Node, " or ");
1932 Sprint_Right_Opnd (Node);
1934 when N_Op_Plus =>
1935 Write_Operator (Node, "+");
1936 Sprint_Right_Opnd (Node);
1938 when N_Op_Rem =>
1939 Sprint_Left_Opnd (Node);
1941 if Treat_Fixed_As_Integer (Node) then
1942 Write_Str (" #");
1943 end if;
1945 Write_Operator (Node, " rem ");
1946 Sprint_Right_Opnd (Node);
1948 when N_Op_Shift =>
1949 Set_Debug_Sloc;
1950 Write_Id (Node);
1951 Write_Char ('!');
1952 Write_Str_With_Col_Check ("(");
1953 Sprint_Node (Left_Opnd (Node));
1954 Write_Str (", ");
1955 Sprint_Node (Right_Opnd (Node));
1956 Write_Char (')');
1958 when N_Op_Subtract =>
1959 Sprint_Left_Opnd (Node);
1960 Write_Operator (Node, " - ");
1961 Sprint_Right_Opnd (Node);
1963 when N_Op_Xor =>
1964 Sprint_Left_Opnd (Node);
1965 Write_Operator (Node, " xor ");
1966 Sprint_Right_Opnd (Node);
1968 when N_Operator_Symbol =>
1969 Write_Name_With_Col_Check_Sloc (Chars (Node));
1971 when N_Ordinary_Fixed_Point_Definition =>
1972 Write_Str_With_Col_Check_Sloc ("delta ");
1973 Sprint_Node (Delta_Expression (Node));
1974 Sprint_Opt_Node (Real_Range_Specification (Node));
1976 when N_Or_Else =>
1977 Sprint_Left_Opnd (Node);
1978 Write_Str_Sloc (" or else ");
1979 Sprint_Right_Opnd (Node);
1981 when N_Others_Choice =>
1982 if All_Others (Node) then
1983 Write_Str_With_Col_Check ("all ");
1984 end if;
1986 Write_Str_With_Col_Check_Sloc ("others");
1988 when N_Package_Body =>
1989 Write_Indent;
1990 Write_Indent_Str_Sloc ("package body ");
1991 Sprint_Node (Defining_Unit_Name (Node));
1992 Write_Str (" is");
1993 Sprint_Indented_List (Declarations (Node));
1995 if Present (Handled_Statement_Sequence (Node)) then
1996 Write_Indent_Str ("begin");
1997 Sprint_Node (Handled_Statement_Sequence (Node));
1998 end if;
2000 Write_Indent_Str ("end ");
2001 Sprint_Node (Defining_Unit_Name (Node));
2002 Write_Char (';');
2004 when N_Package_Body_Stub =>
2005 Write_Indent_Str_Sloc ("package body ");
2006 Sprint_Node (Defining_Identifier (Node));
2007 Write_Str_With_Col_Check (" is separate;");
2009 when N_Package_Declaration =>
2010 Write_Indent;
2011 Write_Indent;
2012 Sprint_Node_Sloc (Specification (Node));
2013 Write_Char (';');
2015 when N_Package_Instantiation =>
2016 Write_Indent;
2017 Write_Indent_Str_Sloc ("package ");
2018 Sprint_Node (Defining_Unit_Name (Node));
2019 Write_Str (" is new ");
2020 Sprint_Node (Name (Node));
2021 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2022 Write_Char (';');
2024 when N_Package_Renaming_Declaration =>
2025 Write_Indent_Str_Sloc ("package ");
2026 Sprint_Node (Defining_Unit_Name (Node));
2027 Write_Str_With_Col_Check (" renames ");
2028 Sprint_Node (Name (Node));
2029 Write_Char (';');
2031 when N_Package_Specification =>
2032 Write_Str_With_Col_Check_Sloc ("package ");
2033 Sprint_Node (Defining_Unit_Name (Node));
2034 Write_Str (" is");
2035 Sprint_Indented_List (Visible_Declarations (Node));
2037 if Present (Private_Declarations (Node)) then
2038 Write_Indent_Str ("private");
2039 Sprint_Indented_List (Private_Declarations (Node));
2040 end if;
2042 Write_Indent_Str ("end ");
2043 Sprint_Node (Defining_Unit_Name (Node));
2045 when N_Parameter_Association =>
2046 Sprint_Node_Sloc (Selector_Name (Node));
2047 Write_Str (" => ");
2048 Sprint_Node (Explicit_Actual_Parameter (Node));
2050 when N_Parameter_Specification =>
2051 Set_Debug_Sloc;
2053 if Write_Identifiers (Node) then
2054 Write_Str (" : ");
2056 if In_Present (Node) then
2057 Write_Str_With_Col_Check ("in ");
2058 end if;
2060 if Out_Present (Node) then
2061 Write_Str_With_Col_Check ("out ");
2062 end if;
2064 -- Ada 2005 (AI-231)
2066 if Null_Exclusion_Present (Node) then
2067 Write_Str ("not null ");
2068 end if;
2070 Sprint_Node (Parameter_Type (Node));
2072 if Present (Expression (Node)) then
2073 Write_Str (" := ");
2074 Sprint_Node (Expression (Node));
2075 end if;
2076 else
2077 Write_Str (", ");
2078 end if;
2080 when N_Pragma =>
2081 Write_Indent_Str_Sloc ("pragma ");
2082 Write_Name_With_Col_Check (Chars (Node));
2084 if Present (Pragma_Argument_Associations (Node)) then
2085 Sprint_Opt_Paren_Comma_List
2086 (Pragma_Argument_Associations (Node));
2087 end if;
2089 Write_Char (';');
2091 when N_Pragma_Argument_Association =>
2092 Set_Debug_Sloc;
2094 if Chars (Node) /= No_Name then
2095 Write_Name_With_Col_Check (Chars (Node));
2096 Write_Str (" => ");
2097 end if;
2099 Sprint_Node (Expression (Node));
2101 when N_Private_Type_Declaration =>
2102 Write_Indent_Str_Sloc ("type ");
2103 Write_Id (Defining_Identifier (Node));
2105 if Present (Discriminant_Specifications (Node)) then
2106 Write_Discr_Specs (Node);
2107 elsif Unknown_Discriminants_Present (Node) then
2108 Write_Str_With_Col_Check ("(<>)");
2109 end if;
2111 Write_Str (" is ");
2113 if Tagged_Present (Node) then
2114 Write_Str_With_Col_Check ("tagged ");
2115 end if;
2117 if Limited_Present (Node) then
2118 Write_Str_With_Col_Check ("limited ");
2119 end if;
2121 Write_Str_With_Col_Check ("private;");
2123 when N_Private_Extension_Declaration =>
2124 Write_Indent_Str_Sloc ("type ");
2125 Write_Id (Defining_Identifier (Node));
2127 if Present (Discriminant_Specifications (Node)) then
2128 Write_Discr_Specs (Node);
2129 elsif Unknown_Discriminants_Present (Node) then
2130 Write_Str_With_Col_Check ("(<>)");
2131 end if;
2133 Write_Str_With_Col_Check (" is new ");
2134 Sprint_Node (Subtype_Indication (Node));
2135 Write_Str_With_Col_Check (" with private;");
2137 when N_Procedure_Call_Statement =>
2138 Write_Indent;
2139 Set_Debug_Sloc;
2140 Sprint_Node (Name (Node));
2141 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2142 Write_Char (';');
2144 when N_Procedure_Instantiation =>
2145 Write_Indent_Str_Sloc ("procedure ");
2146 Sprint_Node (Defining_Unit_Name (Node));
2147 Write_Str_With_Col_Check (" is new ");
2148 Sprint_Node (Name (Node));
2149 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2150 Write_Char (';');
2152 when N_Procedure_Specification =>
2153 Write_Str_With_Col_Check_Sloc ("procedure ");
2154 Sprint_Node (Defining_Unit_Name (Node));
2155 Write_Param_Specs (Node);
2157 when N_Protected_Body =>
2158 Write_Indent_Str_Sloc ("protected body ");
2159 Write_Id (Defining_Identifier (Node));
2160 Write_Str (" is");
2161 Sprint_Indented_List (Declarations (Node));
2162 Write_Indent_Str ("end ");
2163 Write_Id (Defining_Identifier (Node));
2164 Write_Char (';');
2166 when N_Protected_Body_Stub =>
2167 Write_Indent_Str_Sloc ("protected body ");
2168 Write_Id (Defining_Identifier (Node));
2169 Write_Str_With_Col_Check (" is separate;");
2171 when N_Protected_Definition =>
2172 Set_Debug_Sloc;
2173 Sprint_Indented_List (Visible_Declarations (Node));
2175 if Present (Private_Declarations (Node)) then
2176 Write_Indent_Str ("private");
2177 Sprint_Indented_List (Private_Declarations (Node));
2178 end if;
2180 Write_Indent_Str ("end ");
2182 when N_Protected_Type_Declaration =>
2183 Write_Indent_Str_Sloc ("protected type ");
2184 Write_Id (Defining_Identifier (Node));
2185 Write_Discr_Specs (Node);
2187 if Present (Interface_List (Node)) then
2188 Write_Str (" is new ");
2189 Sprint_And_List (Interface_List (Node));
2190 Write_Str (" with ");
2191 else
2192 Write_Str (" is");
2193 end if;
2195 Sprint_Node (Protected_Definition (Node));
2196 Write_Id (Defining_Identifier (Node));
2197 Write_Char (';');
2199 when N_Qualified_Expression =>
2200 Sprint_Node (Subtype_Mark (Node));
2201 Write_Char_Sloc (''');
2203 -- Print expression, make sure we have at least one level of
2204 -- parentheses around the expression. For cases of qualified
2205 -- expressions in the source, this is always the case, but
2206 -- for generated qualifications, there may be no explicit
2207 -- parentheses present.
2209 if Paren_Count (Expression (Node)) /= 0 then
2210 Sprint_Node (Expression (Node));
2211 else
2212 Write_Char ('(');
2213 Sprint_Node (Expression (Node));
2214 Write_Char (')');
2215 end if;
2217 when N_Raise_Constraint_Error =>
2219 -- This node can be used either as a subexpression or as a
2220 -- statement form. The following test is a reasonably reliable
2221 -- way to distinguish the two cases.
2223 if Is_List_Member (Node)
2224 and then Nkind (Parent (Node)) not in N_Subexpr
2225 then
2226 Write_Indent;
2227 end if;
2229 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2230 Write_Condition_And_Reason (Node);
2232 when N_Raise_Program_Error =>
2234 -- This node can be used either as a subexpression or as a
2235 -- statement form. The following test is a reasonably reliable
2236 -- way to distinguish the two cases.
2238 if Is_List_Member (Node)
2239 and then Nkind (Parent (Node)) not in N_Subexpr
2240 then
2241 Write_Indent;
2242 end if;
2244 Write_Str_With_Col_Check_Sloc ("[program_error");
2245 Write_Condition_And_Reason (Node);
2247 when N_Raise_Storage_Error =>
2249 -- This node can be used either as a subexpression or as a
2250 -- statement form. The following test is a reasonably reliable
2251 -- way to distinguish the two cases.
2253 if Is_List_Member (Node)
2254 and then Nkind (Parent (Node)) not in N_Subexpr
2255 then
2256 Write_Indent;
2257 end if;
2259 Write_Str_With_Col_Check_Sloc ("[storage_error");
2260 Write_Condition_And_Reason (Node);
2262 when N_Raise_Statement =>
2263 Write_Indent_Str_Sloc ("raise ");
2264 Sprint_Node (Name (Node));
2265 Write_Char (';');
2267 when N_Range =>
2268 Sprint_Node (Low_Bound (Node));
2269 Write_Str_Sloc (" .. ");
2270 Sprint_Node (High_Bound (Node));
2272 when N_Range_Constraint =>
2273 Write_Str_With_Col_Check_Sloc ("range ");
2274 Sprint_Node (Range_Expression (Node));
2276 when N_Real_Literal =>
2277 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2279 when N_Real_Range_Specification =>
2280 Write_Str_With_Col_Check_Sloc ("range ");
2281 Sprint_Node (Low_Bound (Node));
2282 Write_Str (" .. ");
2283 Sprint_Node (High_Bound (Node));
2285 when N_Record_Definition =>
2286 if Abstract_Present (Node) then
2287 Write_Str_With_Col_Check ("abstract ");
2288 end if;
2290 if Tagged_Present (Node) then
2291 Write_Str_With_Col_Check ("tagged ");
2292 end if;
2294 if Limited_Present (Node) then
2295 Write_Str_With_Col_Check ("limited ");
2296 end if;
2298 if Null_Present (Node) then
2299 Write_Str_With_Col_Check_Sloc ("null record");
2301 else
2302 Write_Str_With_Col_Check_Sloc ("record");
2303 Sprint_Node (Component_List (Node));
2304 Write_Indent_Str ("end record");
2305 end if;
2307 when N_Record_Representation_Clause =>
2308 Write_Indent_Str_Sloc ("for ");
2309 Sprint_Node (Identifier (Node));
2310 Write_Str_With_Col_Check (" use record ");
2312 if Present (Mod_Clause (Node)) then
2313 Sprint_Node (Mod_Clause (Node));
2314 end if;
2316 Sprint_Indented_List (Component_Clauses (Node));
2317 Write_Indent_Str ("end record;");
2319 when N_Reference =>
2320 Sprint_Node (Prefix (Node));
2321 Write_Str_With_Col_Check_Sloc ("'reference");
2323 when N_Requeue_Statement =>
2324 Write_Indent_Str_Sloc ("requeue ");
2325 Sprint_Node (Name (Node));
2327 if Abort_Present (Node) then
2328 Write_Str_With_Col_Check (" with abort");
2329 end if;
2331 Write_Char (';');
2333 when N_Return_Statement =>
2334 if Present (Expression (Node)) then
2335 Write_Indent_Str_Sloc ("return ");
2336 Sprint_Node (Expression (Node));
2337 Write_Char (';');
2338 else
2339 Write_Indent_Str_Sloc ("return;");
2340 end if;
2342 when N_Selective_Accept =>
2343 Write_Indent_Str_Sloc ("select");
2345 declare
2346 Alt_Node : Node_Id;
2348 begin
2349 Alt_Node := First (Select_Alternatives (Node));
2350 loop
2351 Indent_Begin;
2352 Sprint_Node (Alt_Node);
2353 Indent_End;
2354 Next (Alt_Node);
2355 exit when No (Alt_Node);
2356 Write_Indent_Str ("or");
2357 end loop;
2358 end;
2360 if Present (Else_Statements (Node)) then
2361 Write_Indent_Str ("else");
2362 Sprint_Indented_List (Else_Statements (Node));
2363 end if;
2365 Write_Indent_Str ("end select;");
2367 when N_Signed_Integer_Type_Definition =>
2368 Write_Str_With_Col_Check_Sloc ("range ");
2369 Sprint_Node (Low_Bound (Node));
2370 Write_Str (" .. ");
2371 Sprint_Node (High_Bound (Node));
2373 when N_Single_Protected_Declaration =>
2374 Write_Indent_Str_Sloc ("protected ");
2375 Write_Id (Defining_Identifier (Node));
2376 Write_Str (" is");
2377 Sprint_Node (Protected_Definition (Node));
2378 Write_Id (Defining_Identifier (Node));
2379 Write_Char (';');
2381 when N_Single_Task_Declaration =>
2382 Write_Indent_Str_Sloc ("task ");
2383 Write_Id (Defining_Identifier (Node));
2385 if Present (Task_Definition (Node)) then
2386 Write_Str (" is");
2387 Sprint_Node (Task_Definition (Node));
2388 Write_Id (Defining_Identifier (Node));
2389 end if;
2391 Write_Char (';');
2393 when N_Selected_Component =>
2394 Sprint_Node (Prefix (Node));
2395 Write_Char_Sloc ('.');
2396 Sprint_Node (Selector_Name (Node));
2398 when N_Slice =>
2399 Set_Debug_Sloc;
2400 Sprint_Node (Prefix (Node));
2401 Write_Str_With_Col_Check (" (");
2402 Sprint_Node (Discrete_Range (Node));
2403 Write_Char (')');
2405 when N_String_Literal =>
2406 if String_Length (Strval (Node)) + Column > 75 then
2407 Write_Indent_Str (" ");
2408 end if;
2410 Set_Debug_Sloc;
2411 Write_String_Table_Entry (Strval (Node));
2413 when N_Subprogram_Body =>
2414 if Freeze_Indent = 0 then
2415 Write_Indent;
2416 end if;
2418 Write_Indent;
2419 Sprint_Node_Sloc (Specification (Node));
2420 Write_Str (" is");
2422 Sprint_Indented_List (Declarations (Node));
2423 Write_Indent_Str ("begin");
2424 Sprint_Node (Handled_Statement_Sequence (Node));
2426 Write_Indent_Str ("end ");
2427 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2428 Write_Char (';');
2430 if Is_List_Member (Node)
2431 and then Present (Next (Node))
2432 and then Nkind (Next (Node)) /= N_Subprogram_Body
2433 then
2434 Write_Indent;
2435 end if;
2437 when N_Subprogram_Body_Stub =>
2438 Write_Indent;
2439 Sprint_Node_Sloc (Specification (Node));
2440 Write_Str_With_Col_Check (" is separate;");
2442 when N_Subprogram_Declaration =>
2443 Write_Indent;
2444 Sprint_Node_Sloc (Specification (Node));
2446 if Nkind (Specification (Node)) = N_Procedure_Specification
2447 and then Null_Present (Specification (Node))
2448 then
2449 Write_Str_With_Col_Check (" is null");
2450 end if;
2452 Write_Char (';');
2454 when N_Subprogram_Info =>
2455 Sprint_Node (Identifier (Node));
2456 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2458 when N_Subprogram_Renaming_Declaration =>
2459 Write_Indent;
2460 Sprint_Node (Specification (Node));
2461 Write_Str_With_Col_Check_Sloc (" renames ");
2462 Sprint_Node (Name (Node));
2463 Write_Char (';');
2465 when N_Subtype_Declaration =>
2466 Write_Indent_Str_Sloc ("subtype ");
2467 Write_Id (Defining_Identifier (Node));
2468 Write_Str (" is ");
2470 -- Ada 2005 (AI-231)
2472 if Null_Exclusion_Present (Node) then
2473 Write_Str ("not null ");
2474 end if;
2476 Sprint_Node (Subtype_Indication (Node));
2477 Write_Char (';');
2479 when N_Subtype_Indication =>
2480 Sprint_Node_Sloc (Subtype_Mark (Node));
2481 Write_Char (' ');
2482 Sprint_Node (Constraint (Node));
2484 when N_Subunit =>
2485 Write_Indent_Str_Sloc ("separate (");
2486 Sprint_Node (Name (Node));
2487 Write_Char (')');
2488 Write_Eol;
2489 Sprint_Node (Proper_Body (Node));
2491 when N_Task_Body =>
2492 Write_Indent_Str_Sloc ("task body ");
2493 Write_Id (Defining_Identifier (Node));
2494 Write_Str (" is");
2495 Sprint_Indented_List (Declarations (Node));
2496 Write_Indent_Str ("begin");
2497 Sprint_Node (Handled_Statement_Sequence (Node));
2498 Write_Indent_Str ("end ");
2499 Write_Id (Defining_Identifier (Node));
2500 Write_Char (';');
2502 when N_Task_Body_Stub =>
2503 Write_Indent_Str_Sloc ("task body ");
2504 Write_Id (Defining_Identifier (Node));
2505 Write_Str_With_Col_Check (" is separate;");
2507 when N_Task_Definition =>
2508 Set_Debug_Sloc;
2509 Sprint_Indented_List (Visible_Declarations (Node));
2511 if Present (Private_Declarations (Node)) then
2512 Write_Indent_Str ("private");
2513 Sprint_Indented_List (Private_Declarations (Node));
2514 end if;
2516 Write_Indent_Str ("end ");
2518 when N_Task_Type_Declaration =>
2519 Write_Indent_Str_Sloc ("task type ");
2520 Write_Id (Defining_Identifier (Node));
2521 Write_Discr_Specs (Node);
2523 if Present (Interface_List (Node)) then
2524 Write_Str (" is new ");
2525 Sprint_And_List (Interface_List (Node));
2526 end if;
2528 if Present (Task_Definition (Node)) then
2529 if No (Interface_List (Node)) then
2530 Write_Str (" is");
2531 else
2532 Write_Str (" with ");
2533 end if;
2535 Sprint_Node (Task_Definition (Node));
2536 Write_Id (Defining_Identifier (Node));
2537 end if;
2539 Write_Char (';');
2541 when N_Terminate_Alternative =>
2542 Sprint_Node_List (Pragmas_Before (Node));
2544 Write_Indent;
2546 if Present (Condition (Node)) then
2547 Write_Str_With_Col_Check ("when ");
2548 Sprint_Node (Condition (Node));
2549 Write_Str (" => ");
2550 end if;
2552 Write_Str_With_Col_Check_Sloc ("terminate;");
2553 Sprint_Node_List (Pragmas_After (Node));
2555 when N_Timed_Entry_Call =>
2556 Write_Indent_Str_Sloc ("select");
2557 Indent_Begin;
2558 Sprint_Node (Entry_Call_Alternative (Node));
2559 Indent_End;
2560 Write_Indent_Str ("or");
2561 Indent_Begin;
2562 Sprint_Node (Delay_Alternative (Node));
2563 Indent_End;
2564 Write_Indent_Str ("end select;");
2566 when N_Triggering_Alternative =>
2567 Sprint_Node_List (Pragmas_Before (Node));
2568 Sprint_Node_Sloc (Triggering_Statement (Node));
2569 Sprint_Node_List (Statements (Node));
2571 when N_Type_Conversion =>
2572 Set_Debug_Sloc;
2573 Sprint_Node (Subtype_Mark (Node));
2574 Col_Check (4);
2576 if Conversion_OK (Node) then
2577 Write_Char ('?');
2578 end if;
2580 if Float_Truncate (Node) then
2581 Write_Char ('^');
2582 end if;
2584 if Rounded_Result (Node) then
2585 Write_Char ('@');
2586 end if;
2588 Write_Char ('(');
2589 Sprint_Node (Expression (Node));
2590 Write_Char (')');
2592 when N_Unchecked_Expression =>
2593 Col_Check (10);
2594 Write_Str ("`(");
2595 Sprint_Node_Sloc (Expression (Node));
2596 Write_Char (')');
2598 when N_Unchecked_Type_Conversion =>
2599 Sprint_Node (Subtype_Mark (Node));
2600 Write_Char ('!');
2601 Write_Str_With_Col_Check ("(");
2602 Sprint_Node_Sloc (Expression (Node));
2603 Write_Char (')');
2605 when N_Unconstrained_Array_Definition =>
2606 Write_Str_With_Col_Check_Sloc ("array (");
2608 declare
2609 Node1 : Node_Id;
2611 begin
2612 Node1 := First (Subtype_Marks (Node));
2613 loop
2614 Sprint_Node (Node1);
2615 Write_Str_With_Col_Check (" range <>");
2616 Next (Node1);
2617 exit when Node1 = Empty;
2618 Write_Str (", ");
2619 end loop;
2620 end;
2622 Write_Str (") of ");
2623 Sprint_Node (Component_Definition (Node));
2625 when N_Unused_At_Start | N_Unused_At_End =>
2626 Write_Indent_Str ("***** Error, unused node encountered *****");
2627 Write_Eol;
2629 when N_Use_Package_Clause =>
2630 Write_Indent_Str_Sloc ("use ");
2631 Sprint_Comma_List (Names (Node));
2632 Write_Char (';');
2634 when N_Use_Type_Clause =>
2635 Write_Indent_Str_Sloc ("use type ");
2636 Sprint_Comma_List (Subtype_Marks (Node));
2637 Write_Char (';');
2639 when N_Validate_Unchecked_Conversion =>
2640 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2641 Sprint_Node (Source_Type (Node));
2642 Write_Str (", ");
2643 Sprint_Node (Target_Type (Node));
2644 Write_Str (");");
2646 when N_Variant =>
2647 Write_Indent_Str_Sloc ("when ");
2648 Sprint_Bar_List (Discrete_Choices (Node));
2649 Write_Str (" => ");
2650 Sprint_Node (Component_List (Node));
2652 when N_Variant_Part =>
2653 Indent_Begin;
2654 Write_Indent_Str_Sloc ("case ");
2655 Sprint_Node (Name (Node));
2656 Write_Str (" is ");
2657 Sprint_Indented_List (Variants (Node));
2658 Write_Indent_Str ("end case");
2659 Indent_End;
2661 when N_With_Clause =>
2663 -- Special test, if we are dumping the original tree only,
2664 -- then we want to eliminate the bogus with clauses that
2665 -- correspond to the non-existent children of Text_IO.
2667 if Dump_Original_Only
2668 and then Is_Text_IO_Kludge_Unit (Name (Node))
2669 then
2670 null;
2672 -- Normal case, output the with clause
2674 else
2675 if First_Name (Node) or else not Dump_Original_Only then
2677 -- Ada 2005 (AI-50217): Print limited with_clauses
2679 if Private_Present (Node) and Limited_Present (Node) then
2680 Write_Indent_Str ("limited private with ");
2682 elsif Private_Present (Node) then
2683 Write_Indent_Str ("private with ");
2685 elsif Limited_Present (Node) then
2686 Write_Indent_Str ("limited with ");
2688 else
2689 Write_Indent_Str ("with ");
2690 end if;
2692 else
2693 Write_Str (", ");
2694 end if;
2696 Sprint_Node_Sloc (Name (Node));
2698 if Last_Name (Node) or else not Dump_Original_Only then
2699 Write_Char (';');
2700 end if;
2701 end if;
2703 when N_With_Type_Clause =>
2704 Write_Indent_Str ("with type ");
2705 Sprint_Node_Sloc (Name (Node));
2707 if Tagged_Present (Node) then
2708 Write_Str (" is tagged;");
2709 else
2710 Write_Str (" is access;");
2711 end if;
2713 end case;
2715 if Nkind (Node) in N_Subexpr
2716 and then Do_Range_Check (Node)
2717 then
2718 Write_Str ("}");
2719 end if;
2721 for J in 1 .. Paren_Count (Node) loop
2722 Write_Char (')');
2723 end loop;
2725 pragma Assert (No (Debug_Node));
2726 Debug_Node := Save_Debug_Node;
2727 end Sprint_Node_Actual;
2729 ----------------------
2730 -- Sprint_Node_List --
2731 ----------------------
2733 procedure Sprint_Node_List (List : List_Id) is
2734 Node : Node_Id;
2736 begin
2737 if Is_Non_Empty_List (List) then
2738 Node := First (List);
2740 loop
2741 Sprint_Node (Node);
2742 Next (Node);
2743 exit when Node = Empty;
2744 end loop;
2745 end if;
2746 end Sprint_Node_List;
2748 ----------------------
2749 -- Sprint_Node_Sloc --
2750 ----------------------
2752 procedure Sprint_Node_Sloc (Node : Node_Id) is
2753 begin
2754 Sprint_Node (Node);
2756 if Present (Debug_Node) then
2757 Set_Sloc (Debug_Node, Sloc (Node));
2758 Debug_Node := Empty;
2759 end if;
2760 end Sprint_Node_Sloc;
2762 ---------------------
2763 -- Sprint_Opt_Node --
2764 ---------------------
2766 procedure Sprint_Opt_Node (Node : Node_Id) is
2767 begin
2768 if Present (Node) then
2769 Write_Char (' ');
2770 Sprint_Node (Node);
2771 end if;
2772 end Sprint_Opt_Node;
2774 --------------------------
2775 -- Sprint_Opt_Node_List --
2776 --------------------------
2778 procedure Sprint_Opt_Node_List (List : List_Id) is
2779 begin
2780 if Present (List) then
2781 Sprint_Node_List (List);
2782 end if;
2783 end Sprint_Opt_Node_List;
2785 ---------------------------------
2786 -- Sprint_Opt_Paren_Comma_List --
2787 ---------------------------------
2789 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2790 begin
2791 if Is_Non_Empty_List (List) then
2792 Write_Char (' ');
2793 Sprint_Paren_Comma_List (List);
2794 end if;
2795 end Sprint_Opt_Paren_Comma_List;
2797 -----------------------------
2798 -- Sprint_Paren_Comma_List --
2799 -----------------------------
2801 procedure Sprint_Paren_Comma_List (List : List_Id) is
2802 N : Node_Id;
2803 Node_Exists : Boolean := False;
2805 begin
2807 if Is_Non_Empty_List (List) then
2809 if Dump_Original_Only then
2810 N := First (List);
2812 while Present (N) loop
2814 if not Is_Rewrite_Insertion (N) then
2815 Node_Exists := True;
2816 exit;
2817 end if;
2819 Next (N);
2820 end loop;
2822 if not Node_Exists then
2823 return;
2824 end if;
2825 end if;
2827 Write_Str_With_Col_Check ("(");
2828 Sprint_Comma_List (List);
2829 Write_Char (')');
2830 end if;
2831 end Sprint_Paren_Comma_List;
2833 ----------------------
2834 -- Sprint_Right_Opnd --
2835 ----------------------
2837 procedure Sprint_Right_Opnd (N : Node_Id) is
2838 Opnd : constant Node_Id := Right_Opnd (N);
2840 begin
2841 if Paren_Count (Opnd) /= 0
2842 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2843 then
2844 Sprint_Node (Opnd);
2846 else
2847 Write_Char ('(');
2848 Sprint_Node (Opnd);
2849 Write_Char (')');
2850 end if;
2851 end Sprint_Right_Opnd;
2853 ---------------------
2854 -- Write_Char_Sloc --
2855 ---------------------
2857 procedure Write_Char_Sloc (C : Character) is
2858 begin
2859 if Debug_Generated_Code and then C /= ' ' then
2860 Set_Debug_Sloc;
2861 end if;
2863 Write_Char (C);
2864 end Write_Char_Sloc;
2866 --------------------------------
2867 -- Write_Condition_And_Reason --
2868 --------------------------------
2870 procedure Write_Condition_And_Reason (Node : Node_Id) is
2871 Image : constant String := RT_Exception_Code'Image
2872 (RT_Exception_Code'Val
2873 (UI_To_Int (Reason (Node))));
2875 begin
2876 if Present (Condition (Node)) then
2877 Write_Str_With_Col_Check (" when ");
2878 Sprint_Node (Condition (Node));
2879 end if;
2881 Write_Str (" """);
2883 for J in 4 .. Image'Last loop
2884 if Image (J) = '_' then
2885 Write_Char (' ');
2886 else
2887 Write_Char (Fold_Lower (Image (J)));
2888 end if;
2889 end loop;
2891 Write_Str ("""]");
2892 end Write_Condition_And_Reason;
2894 -----------------------
2895 -- Write_Discr_Specs --
2896 -----------------------
2898 procedure Write_Discr_Specs (N : Node_Id) is
2899 Specs : List_Id;
2900 Spec : Node_Id;
2902 begin
2903 Specs := Discriminant_Specifications (N);
2905 if Present (Specs) then
2906 Write_Str_With_Col_Check (" (");
2907 Spec := First (Specs);
2909 loop
2910 Sprint_Node (Spec);
2911 Next (Spec);
2912 exit when Spec = Empty;
2914 -- Add semicolon, unless we are printing original tree and the
2915 -- next specification is part of a list (but not the first
2916 -- element of that list)
2918 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2919 Write_Str ("; ");
2920 end if;
2921 end loop;
2923 Write_Char (')');
2924 end if;
2925 end Write_Discr_Specs;
2927 -----------------
2928 -- Write_Ekind --
2929 -----------------
2931 procedure Write_Ekind (E : Entity_Id) is
2932 S : constant String := Entity_Kind'Image (Ekind (E));
2934 begin
2935 Name_Len := S'Length;
2936 Name_Buffer (1 .. Name_Len) := S;
2937 Set_Casing (Mixed_Case);
2938 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2939 end Write_Ekind;
2941 --------------
2942 -- Write_Id --
2943 --------------
2945 procedure Write_Id (N : Node_Id) is
2946 begin
2947 -- Case of a defining identifier
2949 if Nkind (N) = N_Defining_Identifier then
2951 -- If defining identifier has an interface name (and no
2952 -- address clause), then we output the interface name.
2954 if (Is_Imported (N) or else Is_Exported (N))
2955 and then Present (Interface_Name (N))
2956 and then No (Address_Clause (N))
2957 then
2958 String_To_Name_Buffer (Strval (Interface_Name (N)));
2959 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2961 -- If no interface name (or inactive because there was
2962 -- an address clause), then just output the Chars name.
2964 else
2965 Write_Name_With_Col_Check (Chars (N));
2966 end if;
2968 -- Case of selector of an expanded name where the expanded name
2969 -- has an associated entity, output this entity.
2971 elsif Nkind (Parent (N)) = N_Expanded_Name
2972 and then Selector_Name (Parent (N)) = N
2973 and then Present (Entity (Parent (N)))
2974 then
2975 Write_Id (Entity (Parent (N)));
2977 -- For any other node with an associated entity, output it
2979 elsif Nkind (N) in N_Has_Entity
2980 and then Present (Entity_Or_Associated_Node (N))
2981 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2982 then
2983 Write_Id (Entity (N));
2985 -- All other cases, we just print the Chars field
2987 else
2988 Write_Name_With_Col_Check (Chars (N));
2989 end if;
2990 end Write_Id;
2992 -----------------------
2993 -- Write_Identifiers --
2994 -----------------------
2996 function Write_Identifiers (Node : Node_Id) return Boolean is
2997 begin
2998 Sprint_Node (Defining_Identifier (Node));
3000 -- The remainder of the declaration must be printed unless we are
3001 -- printing the original tree and this is not the last identifier
3003 return
3004 not Dump_Original_Only or else not More_Ids (Node);
3006 end Write_Identifiers;
3008 ------------------------
3009 -- Write_Implicit_Def --
3010 ------------------------
3012 procedure Write_Implicit_Def (E : Entity_Id) is
3013 Ind : Node_Id;
3015 begin
3016 case Ekind (E) is
3017 when E_Array_Subtype =>
3018 Write_Str_With_Col_Check ("subtype ");
3019 Write_Id (E);
3020 Write_Str_With_Col_Check (" is ");
3021 Write_Id (Base_Type (E));
3022 Write_Str_With_Col_Check (" (");
3024 Ind := First_Index (E);
3026 while Present (Ind) loop
3027 Sprint_Node (Ind);
3028 Next_Index (Ind);
3030 if Present (Ind) then
3031 Write_Str (", ");
3032 end if;
3033 end loop;
3035 Write_Str (");");
3037 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
3038 Write_Str_With_Col_Check ("subtype ");
3039 Write_Id (E);
3040 Write_Str (" is ");
3041 Write_Id (Etype (E));
3042 Write_Str_With_Col_Check (" range ");
3043 Sprint_Node (Scalar_Range (E));
3044 Write_Str (";");
3046 when others =>
3047 Write_Str_With_Col_Check ("type ");
3048 Write_Id (E);
3049 Write_Str_With_Col_Check (" is <");
3050 Write_Ekind (E);
3051 Write_Str (">;");
3052 end case;
3054 end Write_Implicit_Def;
3056 ------------------
3057 -- Write_Indent --
3058 ------------------
3060 procedure Write_Indent is
3061 begin
3062 if Indent_Annull_Flag then
3063 Indent_Annull_Flag := False;
3064 else
3065 Write_Eol;
3067 for J in 1 .. Indent loop
3068 Write_Char (' ');
3069 end loop;
3070 end if;
3071 end Write_Indent;
3073 ------------------------------
3074 -- Write_Indent_Identifiers --
3075 ------------------------------
3077 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3078 begin
3079 -- We need to start a new line for every node, except in the case
3080 -- where we are printing the original tree and this is not the first
3081 -- defining identifier in the list.
3083 if not Dump_Original_Only or else not Prev_Ids (Node) then
3084 Write_Indent;
3086 -- If printing original tree and this is not the first defining
3087 -- identifier in the list, then the previous call to this procedure
3088 -- printed only the name, and we add a comma to separate the names.
3090 else
3091 Write_Str (", ");
3092 end if;
3094 Sprint_Node (Defining_Identifier (Node));
3096 -- The remainder of the declaration must be printed unless we are
3097 -- printing the original tree and this is not the last identifier
3099 return
3100 not Dump_Original_Only or else not More_Ids (Node);
3102 end Write_Indent_Identifiers;
3104 -----------------------------------
3105 -- Write_Indent_Identifiers_Sloc --
3106 -----------------------------------
3108 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3109 begin
3110 -- We need to start a new line for every node, except in the case
3111 -- where we are printing the original tree and this is not the first
3112 -- defining identifier in the list.
3114 if not Dump_Original_Only or else not Prev_Ids (Node) then
3115 Write_Indent;
3117 -- If printing original tree and this is not the first defining
3118 -- identifier in the list, then the previous call to this procedure
3119 -- printed only the name, and we add a comma to separate the names.
3121 else
3122 Write_Str (", ");
3123 end if;
3125 Set_Debug_Sloc;
3126 Sprint_Node (Defining_Identifier (Node));
3128 -- The remainder of the declaration must be printed unless we are
3129 -- printing the original tree and this is not the last identifier
3131 return
3132 not Dump_Original_Only or else not More_Ids (Node);
3134 end Write_Indent_Identifiers_Sloc;
3136 ----------------------
3137 -- Write_Indent_Str --
3138 ----------------------
3140 procedure Write_Indent_Str (S : String) is
3141 begin
3142 Write_Indent;
3143 Write_Str (S);
3144 end Write_Indent_Str;
3146 ---------------------------
3147 -- Write_Indent_Str_Sloc --
3148 ---------------------------
3150 procedure Write_Indent_Str_Sloc (S : String) is
3151 begin
3152 Write_Indent;
3153 Write_Str_Sloc (S);
3154 end Write_Indent_Str_Sloc;
3156 -------------------------------
3157 -- Write_Name_With_Col_Check --
3158 -------------------------------
3160 procedure Write_Name_With_Col_Check (N : Name_Id) is
3161 J : Natural;
3163 begin
3164 Get_Name_String (N);
3166 -- Deal with -gnatI which replaces digits in an internal
3167 -- name by three dots (e.g. R7b becomes R...b).
3169 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3171 J := 2;
3172 while J < Name_Len loop
3173 exit when Name_Buffer (J) not in 'A' .. 'Z';
3174 J := J + 1;
3175 end loop;
3177 if Name_Buffer (J) in '0' .. '9' then
3178 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3179 Write_Str ("...");
3181 while J <= Name_Len loop
3182 if Name_Buffer (J) not in '0' .. '9' then
3183 Write_Str (Name_Buffer (J .. Name_Len));
3184 exit;
3186 else
3187 J := J + 1;
3188 end if;
3189 end loop;
3191 return;
3192 end if;
3193 end if;
3195 -- Fall through for normal case
3197 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3198 end Write_Name_With_Col_Check;
3200 ------------------------------------
3201 -- Write_Name_With_Col_Check_Sloc --
3202 ------------------------------------
3204 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3205 begin
3206 Get_Name_String (N);
3207 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3208 end Write_Name_With_Col_Check_Sloc;
3210 --------------------
3211 -- Write_Operator --
3212 --------------------
3214 procedure Write_Operator (N : Node_Id; S : String) is
3215 F : Natural := S'First;
3216 T : Natural := S'Last;
3218 begin
3219 -- If no overflow check, just write string out, and we are done
3221 if not Do_Overflow_Check (N) then
3222 Write_Str_Sloc (S);
3224 -- If overflow check, we want to surround the operator with curly
3225 -- brackets, but not include spaces within the brackets.
3227 else
3228 if S (F) = ' ' then
3229 Write_Char (' ');
3230 F := F + 1;
3231 end if;
3233 if S (T) = ' ' then
3234 T := T - 1;
3235 end if;
3237 Write_Char ('{');
3238 Write_Str_Sloc (S (F .. T));
3239 Write_Char ('}');
3241 if S (S'Last) = ' ' then
3242 Write_Char (' ');
3243 end if;
3244 end if;
3245 end Write_Operator;
3247 -----------------------
3248 -- Write_Param_Specs --
3249 -----------------------
3251 procedure Write_Param_Specs (N : Node_Id) is
3252 Specs : List_Id;
3253 Spec : Node_Id;
3254 Formal : Node_Id;
3256 begin
3257 Specs := Parameter_Specifications (N);
3259 if Is_Non_Empty_List (Specs) then
3260 Write_Str_With_Col_Check (" (");
3261 Spec := First (Specs);
3263 loop
3264 Sprint_Node (Spec);
3265 Formal := Defining_Identifier (Spec);
3266 Next (Spec);
3267 exit when Spec = Empty;
3269 -- Add semicolon, unless we are printing original tree and the
3270 -- next specification is part of a list (but not the first
3271 -- element of that list)
3273 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3274 Write_Str ("; ");
3275 end if;
3276 end loop;
3278 -- Write out any extra formals
3280 while Present (Extra_Formal (Formal)) loop
3281 Formal := Extra_Formal (Formal);
3282 Write_Str ("; ");
3283 Write_Name_With_Col_Check (Chars (Formal));
3284 Write_Str (" : ");
3285 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3286 end loop;
3288 Write_Char (')');
3289 end if;
3290 end Write_Param_Specs;
3292 --------------------------
3293 -- Write_Rewrite_Str --
3294 --------------------------
3296 procedure Write_Rewrite_Str (S : String) is
3297 begin
3298 if not Dump_Generated_Only then
3299 if S'Length = 3 and then S = ">>>" then
3300 Write_Str (">>>");
3301 else
3302 Write_Str_With_Col_Check (S);
3303 end if;
3304 end if;
3305 end Write_Rewrite_Str;
3307 --------------------
3308 -- Write_Str_Sloc --
3309 --------------------
3311 procedure Write_Str_Sloc (S : String) is
3312 begin
3313 for J in S'Range loop
3314 Write_Char_Sloc (S (J));
3315 end loop;
3316 end Write_Str_Sloc;
3318 ------------------------------
3319 -- Write_Str_With_Col_Check --
3320 ------------------------------
3322 procedure Write_Str_With_Col_Check (S : String) is
3323 begin
3324 if Int (S'Last) + Column > Line_Limit then
3325 Write_Indent_Str (" ");
3327 if S (1) = ' ' then
3328 Write_Str (S (2 .. S'Length));
3329 else
3330 Write_Str (S);
3331 end if;
3333 else
3334 Write_Str (S);
3335 end if;
3336 end Write_Str_With_Col_Check;
3338 -----------------------------------
3339 -- Write_Str_With_Col_Check_Sloc --
3340 -----------------------------------
3342 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3343 begin
3344 if Int (S'Last) + Column > Line_Limit then
3345 Write_Indent_Str (" ");
3347 if S (1) = ' ' then
3348 Write_Str_Sloc (S (2 .. S'Length));
3349 else
3350 Write_Str_Sloc (S);
3351 end if;
3353 else
3354 Write_Str_Sloc (S);
3355 end if;
3356 end Write_Str_With_Col_Check_Sloc;
3358 ------------------------------------
3359 -- Write_Uint_With_Col_Check_Sloc --
3360 ------------------------------------
3362 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3363 begin
3364 Col_Check (UI_Decimal_Digits_Hi (U));
3365 Set_Debug_Sloc;
3366 UI_Write (U, Format);
3367 end Write_Uint_With_Col_Check_Sloc;
3369 -------------------------------------
3370 -- Write_Ureal_With_Col_Check_Sloc --
3371 -------------------------------------
3373 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3374 D : constant Uint := Denominator (U);
3375 N : constant Uint := Numerator (U);
3377 begin
3378 Col_Check
3379 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3380 Set_Debug_Sloc;
3381 UR_Write (U);
3382 end Write_Ureal_With_Col_Check_Sloc;
3384 end Sprint;