* gnu/regexp/CharIndexedReader.java: Removed.
[official-gcc.git] / gcc / ada / sprint.adb
blob5fe9e1c550e6fad53448c66f997a0abab674d319
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S P R I N T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 with Atree; use Atree;
28 with Casing; use Casing;
29 with Csets; use Csets;
30 with Debug; use Debug;
31 with Einfo; use Einfo;
32 with Lib; use Lib;
33 with Namet; use Namet;
34 with Nlists; use Nlists;
35 with Opt; use Opt;
36 with Output; use Output;
37 with Rtsfind; use Rtsfind;
38 with Sinfo; use Sinfo;
39 with Sinput; use Sinput;
40 with Sinput.D; use Sinput.D;
41 with Snames; use Snames;
42 with Stand; use Stand;
43 with Stringt; use Stringt;
44 with Uintp; use Uintp;
45 with Uname; use Uname;
46 with Urealp; use Urealp;
48 package body Sprint is
50 Debug_Node : Node_Id := Empty;
51 -- If we are in Debug_Generated_Code mode, then this location is set
52 -- to the current node requiring Sloc fixup, until Set_Debug_Sloc is
53 -- called to set the proper value. The call clears it back to Empty.
55 Debug_Sloc : Source_Ptr;
56 -- Sloc of first byte of line currently being written if we are
57 -- generating a source debug file.
59 Dump_Original_Only : Boolean;
60 -- Set True if the -gnatdo (dump original tree) flag is set
62 Dump_Generated_Only : Boolean;
63 -- Set True if the -gnatG (dump generated tree) debug flag is set
64 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
66 Dump_Freeze_Null : Boolean;
67 -- Set True if freeze nodes and non-source null statements output
69 Indent : Int := 0;
70 -- Number of columns for current line output indentation
72 Indent_Annull_Flag : Boolean := False;
73 -- Set True if subsequent Write_Indent call to be ignored, gets reset
74 -- by this call, so it is only active to suppress a single indent call.
76 Line_Limit : constant := 72;
77 -- Limit value for chopping long lines
79 Freeze_Indent : Int := 0;
80 -- Keep track of freeze indent level (controls blank lines before
81 -- procedures within expression freeze actions)
83 -------------------------------
84 -- Operator Precedence Table --
85 -------------------------------
87 -- This table is used to decide whether a subexpression needs to be
88 -- parenthesized. The rule is that if an operand of an operator (which
89 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
90 -- with a lower precedence than the operator (or equal precedence if
91 -- appearing as the right operand), then parentheses are required.
93 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
94 (N_Op_And => 1,
95 N_Op_Or => 1,
96 N_Op_Xor => 1,
97 N_And_Then => 1,
98 N_Or_Else => 1,
100 N_In => 2,
101 N_Not_In => 2,
102 N_Op_Eq => 2,
103 N_Op_Ge => 2,
104 N_Op_Gt => 2,
105 N_Op_Le => 2,
106 N_Op_Lt => 2,
107 N_Op_Ne => 2,
109 N_Op_Add => 3,
110 N_Op_Concat => 3,
111 N_Op_Subtract => 3,
112 N_Op_Plus => 3,
113 N_Op_Minus => 3,
115 N_Op_Divide => 4,
116 N_Op_Mod => 4,
117 N_Op_Rem => 4,
118 N_Op_Multiply => 4,
120 N_Op_Expon => 5,
121 N_Op_Abs => 5,
122 N_Op_Not => 5,
124 others => 6);
126 procedure Sprint_Left_Opnd (N : Node_Id);
127 -- Print left operand of operator, parenthesizing if necessary
129 procedure Sprint_Right_Opnd (N : Node_Id);
130 -- Print right operand of operator, parenthesizing if necessary
132 -----------------------
133 -- Local Subprograms --
134 -----------------------
136 procedure Col_Check (N : Nat);
137 -- Check that at least N characters remain on current line, and if not,
138 -- then start an extra line with two characters extra indentation for
139 -- continuing text on the next line.
141 procedure Indent_Annull;
142 -- Causes following call to Write_Indent to be ignored. This is used when
143 -- a higher level node wants to stop a lower level node from starting a
144 -- new line, when it would otherwise be inclined to do so (e.g. the case
145 -- of an accept statement called from an accept alternative with a guard)
147 procedure Indent_Begin;
148 -- Increase indentation level
150 procedure Indent_End;
151 -- Decrease indentation level
153 procedure Print_Debug_Line (S : String);
154 -- Used to print output lines in Debug_Generated_Code mode (this is used
155 -- as the argument for a call to Set_Special_Output in package Output).
157 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
158 -- Given a divide, multiplication or division node, check the flags
159 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
160 -- appropriate special syntax characters (# and @).
162 procedure Set_Debug_Sloc;
163 -- If Debug_Node is non-empty, this routine sets the appropriate value
164 -- in its Sloc field, from the current location in the debug source file
165 -- that is currently being written. Note that Debug_Node is always empty
166 -- if a debug source file is not being written.
168 procedure Sprint_Bar_List (List : List_Id);
169 -- Print the given list with items separated by vertical bars
171 procedure Sprint_Node_Actual (Node : Node_Id);
172 -- This routine prints its node argument. It is a lower level routine than
173 -- Sprint_Node, in that it does not bother about rewritten trees.
175 procedure Sprint_Node_Sloc (Node : Node_Id);
176 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
177 -- sets the Sloc of the current debug node to be a copy of the Sloc
178 -- of the sprinted node Node. Note that this is done after printing
179 -- Node, so that the Sloc is the proper updated value for the debug file.
181 procedure Write_Char_Sloc (C : Character);
182 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
183 -- called to ensure that the current node has a proper Sloc set.
185 procedure Write_Condition_And_Reason (Node : Node_Id);
186 -- Write Condition and Reason codes of Raise_xxx_Error node
188 procedure Write_Discr_Specs (N : Node_Id);
189 -- Ouput discriminant specification for node, which is any of the type
190 -- declarations that can have discriminants.
192 procedure Write_Ekind (E : Entity_Id);
193 -- Write the String corresponding to the Ekind without "E_".
195 procedure Write_Id (N : Node_Id);
196 -- N is a node with a Chars field. This procedure writes the name that
197 -- will be used in the generated code associated with the name. For a
198 -- node with no associated entity, this is simply the Chars field. For
199 -- the case where there is an entity associated with the node, we print
200 -- the name associated with the entity (since it may have been encoded).
201 -- One other special case is that an entity has an active external name
202 -- (i.e. an external name present with no address clause), then this
203 -- external name is output.
205 function Write_Identifiers (Node : Node_Id) return Boolean;
206 -- Handle node where the grammar has a list of defining identifiers, but
207 -- the tree has a separate declaration for each identifier. Handles the
208 -- printing of the defining identifier, and returns True if the type and
209 -- initialization information is to be printed, False if it is to be
210 -- skipped (the latter case happens when printing defining identifiers
211 -- other than the first in the original tree output case).
213 procedure Write_Implicit_Def (E : Entity_Id);
214 pragma Warnings (Off, Write_Implicit_Def);
215 -- Write the definition of the implicit type E according to its Ekind
216 -- For now a debugging procedure, but might be used in the future.
218 procedure Write_Indent;
219 -- Start a new line and write indentation spacing
221 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
222 -- Like Write_Identifiers except that each new printed declaration
223 -- is at the start of a new line.
225 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
226 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
227 -- mode, the Sloc of the current debug node is set to point ot the
228 -- first output identifier.
230 procedure Write_Indent_Str (S : String);
231 -- Start a new line and write indent spacing followed by given string
233 procedure Write_Indent_Str_Sloc (S : String);
234 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
235 -- the Sloc of the current node is set to the first non-blank character
236 -- in the string S.
238 procedure Write_Name_With_Col_Check (N : Name_Id);
239 -- Write name (using Write_Name) with initial column check, and possible
240 -- initial Write_Indent (to get new line) if current line is too full.
242 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
243 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
244 -- mode, sets Sloc of current debug node to first character of name.
246 procedure Write_Operator (N : Node_Id; S : String);
247 -- Like Write_Str_Sloc, used for operators, encloses the string in
248 -- characters {} if the Do_Overflow flag is set on the node N.
250 procedure Write_Param_Specs (N : Node_Id);
251 -- Output parameter specifications for node (which is either a function
252 -- or procedure specification with a Parameter_Specifications field)
254 procedure Write_Rewrite_Str (S : String);
255 -- Writes out a string (typically containing <<< or >>>}) for a node
256 -- created by rewriting the tree. Suppressed if we are outputting the
257 -- generated code only, since in this case we don't specially mark nodes
258 -- created by rewriting).
260 procedure Write_Str_Sloc (S : String);
261 -- Like Write_Str, but sets debug Sloc of current debug node to first
262 -- non-blank character if a current debug node is active.
264 procedure Write_Str_With_Col_Check (S : String);
265 -- Write string (using Write_Str) with initial column check, and possible
266 -- initial Write_Indent (to get new line) if current line is too full.
268 procedure Write_Str_With_Col_Check_Sloc (S : String);
269 -- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
270 -- node to first non-blank character if a current debug node is active.
272 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
273 -- Write Uint (using UI_Write) with initial column check, and possible
274 -- initial Write_Indent (to get new line) if current line is too full.
275 -- The format parameter determines the output format (see UI_Write).
276 -- In addition, in Debug_Generated_Code mode, sets the current node
277 -- Sloc to the first character of the output value.
279 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
280 -- Write Ureal (using same output format as UR_Write) with column checks
281 -- and a possible initial Write_Indent (to get new line) if current line
282 -- is too full. In addition, in Debug_Generated_Code mode, sets the
283 -- current node Sloc to the first character of the output value.
285 ---------------
286 -- Col_Check --
287 ---------------
289 procedure Col_Check (N : Nat) is
290 begin
291 if N + Column > Line_Limit then
292 Write_Indent_Str (" ");
293 end if;
294 end Col_Check;
296 -------------------
297 -- Indent_Annull --
298 -------------------
300 procedure Indent_Annull is
301 begin
302 Indent_Annull_Flag := True;
303 end Indent_Annull;
305 ------------------
306 -- Indent_Begin --
307 ------------------
309 procedure Indent_Begin is
310 begin
311 Indent := Indent + 3;
312 end Indent_Begin;
314 ----------------
315 -- Indent_End --
316 ----------------
318 procedure Indent_End is
319 begin
320 Indent := Indent - 3;
321 end Indent_End;
323 --------
324 -- pg --
325 --------
327 procedure pg (Node : Node_Id) is
328 begin
329 Dump_Generated_Only := True;
330 Dump_Original_Only := False;
331 Sprint_Node (Node);
332 Write_Eol;
333 end pg;
335 --------
336 -- po --
337 --------
339 procedure po (Node : Node_Id) is
340 begin
341 Dump_Generated_Only := False;
342 Dump_Original_Only := True;
343 Sprint_Node (Node);
344 Write_Eol;
345 end po;
347 ----------------------
348 -- Print_Debug_Line --
349 ----------------------
351 procedure Print_Debug_Line (S : String) is
352 begin
353 Write_Debug_Line (S, Debug_Sloc);
354 end Print_Debug_Line;
356 ---------------------------
357 -- Process_TFAI_RR_Flags --
358 ---------------------------
360 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
361 begin
362 if Treat_Fixed_As_Integer (Nod) then
363 Write_Char ('#');
364 end if;
366 if Rounded_Result (Nod) then
367 Write_Char ('@');
368 end if;
369 end Process_TFAI_RR_Flags;
371 --------
372 -- ps --
373 --------
375 procedure ps (Node : Node_Id) is
376 begin
377 Dump_Generated_Only := False;
378 Dump_Original_Only := False;
379 Sprint_Node (Node);
380 Write_Eol;
381 end ps;
383 --------------------
384 -- Set_Debug_Sloc --
385 --------------------
387 procedure Set_Debug_Sloc is
388 begin
389 if Present (Debug_Node) then
390 Set_Sloc (Debug_Node, Debug_Sloc + Source_Ptr (Column - 1));
391 Debug_Node := Empty;
392 end if;
393 end Set_Debug_Sloc;
395 -----------------
396 -- Source_Dump --
397 -----------------
399 procedure Source_Dump is
401 procedure Underline;
402 -- Put underline under string we just printed
404 procedure Underline is
405 Col : constant Int := Column;
407 begin
408 Write_Eol;
410 while Col > Column loop
411 Write_Char ('-');
412 end loop;
414 Write_Eol;
415 end Underline;
417 -- Start of processing for Tree_Dump.
419 begin
420 Dump_Generated_Only := Debug_Flag_G or
421 Print_Generated_Code or
422 Debug_Generated_Code;
423 Dump_Original_Only := Debug_Flag_O;
424 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
426 -- Note that we turn off the tree dump flags immediately, before
427 -- starting the dump. This avoids generating two copies of the dump
428 -- if an abort occurs after printing the dump, and more importantly,
429 -- avoids an infinite loop if an abort occurs during the dump.
431 if Debug_Flag_Z then
432 Debug_Flag_Z := False;
433 Write_Eol;
434 Write_Eol;
435 Write_Str ("Source recreated from tree of Standard (spec)");
436 Underline;
437 Sprint_Node (Standard_Package_Node);
438 Write_Eol;
439 Write_Eol;
440 end if;
442 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
443 Debug_Flag_G := False;
444 Debug_Flag_O := False;
445 Debug_Flag_S := False;
447 -- Dump requested units
449 for U in Main_Unit .. Last_Unit loop
451 -- Dump all units if -gnatdf set, otherwise we dump only
452 -- the source files that are in the extended main source.
454 if Debug_Flag_F
455 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
456 then
457 -- If we are generating debug files, setup to write them
459 if Debug_Generated_Code then
460 Set_Special_Output (Print_Debug_Line'Access);
461 Create_Debug_Source (Source_Index (U), Debug_Sloc);
462 Sprint_Node (Cunit (U));
463 Write_Eol;
464 Close_Debug_Source;
465 Set_Special_Output (null);
467 -- Normal output to standard output file
469 else
470 Write_Str ("Source recreated from tree for ");
471 Write_Unit_Name (Unit_Name (U));
472 Underline;
473 Sprint_Node (Cunit (U));
474 Write_Eol;
475 Write_Eol;
476 end if;
477 end if;
478 end loop;
479 end if;
480 end Source_Dump;
482 ---------------------
483 -- Sprint_Bar_List --
484 ---------------------
486 procedure Sprint_Bar_List (List : List_Id) is
487 Node : Node_Id;
489 begin
490 if Is_Non_Empty_List (List) then
491 Node := First (List);
493 loop
494 Sprint_Node (Node);
495 Next (Node);
496 exit when Node = Empty;
497 Write_Str (" | ");
498 end loop;
499 end if;
500 end Sprint_Bar_List;
502 -----------------------
503 -- Sprint_Comma_List --
504 -----------------------
506 procedure Sprint_Comma_List (List : List_Id) is
507 Node : Node_Id;
509 begin
510 if Is_Non_Empty_List (List) then
511 Node := First (List);
513 loop
514 Sprint_Node (Node);
515 Next (Node);
516 exit when Node = Empty;
518 if not Is_Rewrite_Insertion (Node)
519 or else not Dump_Original_Only
520 then
521 Write_Str (", ");
522 end if;
524 end loop;
525 end if;
526 end Sprint_Comma_List;
528 --------------------------
529 -- Sprint_Indented_List --
530 --------------------------
532 procedure Sprint_Indented_List (List : List_Id) is
533 begin
534 Indent_Begin;
535 Sprint_Node_List (List);
536 Indent_End;
537 end Sprint_Indented_List;
539 ---------------------
540 -- Sprint_Left_Opnd --
541 ---------------------
543 procedure Sprint_Left_Opnd (N : Node_Id) is
544 Opnd : constant Node_Id := Left_Opnd (N);
546 begin
547 if Paren_Count (Opnd) /= 0
548 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
549 then
550 Sprint_Node (Opnd);
552 else
553 Write_Char ('(');
554 Sprint_Node (Opnd);
555 Write_Char (')');
556 end if;
557 end Sprint_Left_Opnd;
559 -----------------
560 -- Sprint_Node --
561 -----------------
563 procedure Sprint_Node (Node : Node_Id) is
564 begin
565 if Is_Rewrite_Insertion (Node) then
566 if not Dump_Original_Only then
568 -- For special cases of nodes that always output <<< >>>
569 -- do not duplicate the output at this point.
571 if Nkind (Node) = N_Freeze_Entity
572 or else Nkind (Node) = N_Implicit_Label_Declaration
573 then
574 Sprint_Node_Actual (Node);
576 -- Normal case where <<< >>> may be required
578 else
579 Write_Rewrite_Str ("<<<");
580 Sprint_Node_Actual (Node);
581 Write_Rewrite_Str (">>>");
582 end if;
583 end if;
585 elsif Is_Rewrite_Substitution (Node) then
587 -- Case of dump generated only
589 if Dump_Generated_Only then
590 Sprint_Node_Actual (Node);
592 -- Case of dump original only
594 elsif Dump_Original_Only then
595 Sprint_Node_Actual (Original_Node (Node));
597 -- Case of both being dumped
599 else
600 Sprint_Node_Actual (Original_Node (Node));
601 Write_Rewrite_Str ("<<<");
602 Sprint_Node_Actual (Node);
603 Write_Rewrite_Str (">>>");
604 end if;
606 else
607 Sprint_Node_Actual (Node);
608 end if;
609 end Sprint_Node;
611 ------------------------
612 -- Sprint_Node_Actual --
613 ------------------------
615 procedure Sprint_Node_Actual (Node : Node_Id) is
616 Save_Debug_Node : constant Node_Id := Debug_Node;
618 begin
619 if Node = Empty then
620 return;
621 end if;
623 for J in 1 .. Paren_Count (Node) loop
624 Write_Str_With_Col_Check ("(");
625 end loop;
627 -- Setup node for Sloc fixup if writing a debug source file. Note
628 -- that we take care of any previous node not yet properly set.
630 if Debug_Generated_Code then
631 Debug_Node := Node;
632 end if;
634 if Nkind (Node) in N_Subexpr
635 and then Do_Range_Check (Node)
636 then
637 Write_Str_With_Col_Check ("{");
638 end if;
640 -- Select print circuit based on node kind
642 case Nkind (Node) is
644 when N_Abort_Statement =>
645 Write_Indent_Str_Sloc ("abort ");
646 Sprint_Comma_List (Names (Node));
647 Write_Char (';');
649 when N_Abortable_Part =>
650 Set_Debug_Sloc;
651 Write_Str_Sloc ("abort ");
652 Sprint_Indented_List (Statements (Node));
654 when N_Abstract_Subprogram_Declaration =>
655 Write_Indent;
656 Sprint_Node (Specification (Node));
657 Write_Str_With_Col_Check (" is ");
658 Write_Str_Sloc ("abstract;");
660 when N_Accept_Alternative =>
661 Sprint_Node_List (Pragmas_Before (Node));
663 if Present (Condition (Node)) then
664 Write_Indent_Str ("when ");
665 Sprint_Node (Condition (Node));
666 Write_Str (" => ");
667 Indent_Annull;
668 end if;
670 Sprint_Node_Sloc (Accept_Statement (Node));
671 Sprint_Node_List (Statements (Node));
673 when N_Accept_Statement =>
674 Write_Indent_Str_Sloc ("accept ");
675 Write_Id (Entry_Direct_Name (Node));
677 if Present (Entry_Index (Node)) then
678 Write_Str_With_Col_Check (" (");
679 Sprint_Node (Entry_Index (Node));
680 Write_Char (')');
681 end if;
683 Write_Param_Specs (Node);
685 if Present (Handled_Statement_Sequence (Node)) then
686 Write_Str_With_Col_Check (" do");
687 Sprint_Node (Handled_Statement_Sequence (Node));
688 Write_Indent_Str ("end ");
689 Write_Id (Entry_Direct_Name (Node));
690 end if;
692 Write_Char (';');
694 when N_Access_Definition =>
696 -- Ada 0Y (AI-254)
698 if Present (Access_To_Subprogram_Definition (Node)) then
699 Sprint_Node (Access_To_Subprogram_Definition (Node));
700 else
701 -- Ada 0Y (AI-231)
703 if Null_Exclusion_Present (Node) then
704 Write_Str ("not null ");
705 end if;
707 Write_Str_With_Col_Check_Sloc ("access ");
709 if All_Present (Node) then
710 Write_Str ("all ");
711 elsif Constant_Present (Node) then
712 Write_Str ("constant ");
713 end if;
715 Sprint_Node (Subtype_Mark (Node));
716 end if;
718 when N_Access_Function_Definition =>
720 -- Ada 0Y (AI-231)
722 if Null_Exclusion_Present (Node) then
723 Write_Str ("not null ");
724 end if;
726 Write_Str_With_Col_Check_Sloc ("access ");
728 if Protected_Present (Node) then
729 Write_Str_With_Col_Check ("protected ");
730 end if;
732 Write_Str_With_Col_Check ("function");
733 Write_Param_Specs (Node);
734 Write_Str_With_Col_Check (" return ");
735 Sprint_Node (Subtype_Mark (Node));
737 when N_Access_Procedure_Definition =>
738 -- Ada 0Y (AI-231)
740 if Null_Exclusion_Present (Node) then
741 Write_Str ("not null ");
742 end if;
744 Write_Str_With_Col_Check_Sloc ("access ");
746 if Protected_Present (Node) then
747 Write_Str_With_Col_Check ("protected ");
748 end if;
750 Write_Str_With_Col_Check ("procedure");
751 Write_Param_Specs (Node);
753 when N_Access_To_Object_Definition =>
754 Write_Str_With_Col_Check_Sloc ("access ");
756 if All_Present (Node) then
757 Write_Str_With_Col_Check ("all ");
758 elsif Constant_Present (Node) then
759 Write_Str_With_Col_Check ("constant ");
760 end if;
762 -- Ada 0Y (AI-231)
764 if Null_Exclusion_Present (Node) then
765 Write_Str ("not null ");
766 end if;
768 Sprint_Node (Subtype_Indication (Node));
770 when N_Aggregate =>
771 if Null_Record_Present (Node) then
772 Write_Str_With_Col_Check_Sloc ("(null record)");
774 else
775 Write_Str_With_Col_Check_Sloc ("(");
777 if Present (Expressions (Node)) then
778 Sprint_Comma_List (Expressions (Node));
780 if Present (Component_Associations (Node)) then
781 Write_Str (", ");
782 end if;
783 end if;
785 if Present (Component_Associations (Node)) then
786 Indent_Begin;
788 declare
789 Nd : Node_Id;
791 begin
792 Nd := First (Component_Associations (Node));
794 loop
795 Write_Indent;
796 Sprint_Node (Nd);
797 Next (Nd);
798 exit when No (Nd);
800 if not Is_Rewrite_Insertion (Nd)
801 or else not Dump_Original_Only
802 then
803 Write_Str (", ");
804 end if;
805 end loop;
806 end;
808 Indent_End;
809 end if;
811 Write_Char (')');
812 end if;
814 when N_Allocator =>
815 Write_Str_With_Col_Check_Sloc ("new ");
816 -- Ada 0Y (AI-231)
818 if Null_Exclusion_Present (Node) then
819 Write_Str ("not null ");
820 end if;
822 Sprint_Node (Expression (Node));
824 if Present (Storage_Pool (Node)) then
825 Write_Str_With_Col_Check ("[storage_pool = ");
826 Sprint_Node (Storage_Pool (Node));
827 Write_Char (']');
828 end if;
830 when N_And_Then =>
831 Sprint_Left_Opnd (Node);
832 Write_Str_Sloc (" and then ");
833 Sprint_Right_Opnd (Node);
835 when N_At_Clause =>
836 Write_Indent_Str_Sloc ("for ");
837 Write_Id (Identifier (Node));
838 Write_Str_With_Col_Check (" use at ");
839 Sprint_Node (Expression (Node));
840 Write_Char (';');
842 when N_Assignment_Statement =>
843 Write_Indent;
844 Sprint_Node (Name (Node));
845 Write_Str_Sloc (" := ");
846 Sprint_Node (Expression (Node));
847 Write_Char (';');
849 when N_Asynchronous_Select =>
850 Write_Indent_Str_Sloc ("select");
851 Indent_Begin;
852 Sprint_Node (Triggering_Alternative (Node));
853 Indent_End;
855 -- Note: let the printing of Abortable_Part handle outputting
856 -- the ABORT keyword, so that the Slco can be set correctly.
858 Write_Indent_Str ("then ");
859 Sprint_Node (Abortable_Part (Node));
860 Write_Indent_Str ("end select;");
862 when N_Attribute_Definition_Clause =>
863 Write_Indent_Str_Sloc ("for ");
864 Sprint_Node (Name (Node));
865 Write_Char (''');
866 Write_Name_With_Col_Check (Chars (Node));
867 Write_Str_With_Col_Check (" use ");
868 Sprint_Node (Expression (Node));
869 Write_Char (';');
871 when N_Attribute_Reference =>
872 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
873 Write_Indent;
874 end if;
876 Sprint_Node (Prefix (Node));
877 Write_Char_Sloc (''');
878 Write_Name_With_Col_Check (Attribute_Name (Node));
879 Sprint_Paren_Comma_List (Expressions (Node));
881 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
882 Write_Char (';');
883 end if;
885 when N_Block_Statement =>
886 Write_Indent;
888 if Present (Identifier (Node))
889 and then (not Has_Created_Identifier (Node)
890 or else not Dump_Original_Only)
891 then
892 Write_Rewrite_Str ("<<<");
893 Write_Id (Identifier (Node));
894 Write_Str (" : ");
895 Write_Rewrite_Str (">>>");
896 end if;
898 if Present (Declarations (Node)) then
899 Write_Str_With_Col_Check_Sloc ("declare");
900 Sprint_Indented_List (Declarations (Node));
901 Write_Indent;
902 end if;
904 Write_Str_With_Col_Check_Sloc ("begin");
905 Sprint_Node (Handled_Statement_Sequence (Node));
906 Write_Indent_Str ("end");
908 if Present (Identifier (Node))
909 and then (not Has_Created_Identifier (Node)
910 or else not Dump_Original_Only)
911 then
912 Write_Rewrite_Str ("<<<");
913 Write_Char (' ');
914 Write_Id (Identifier (Node));
915 Write_Rewrite_Str (">>>");
916 end if;
918 Write_Char (';');
920 when N_Case_Statement =>
921 Write_Indent_Str_Sloc ("case ");
922 Sprint_Node (Expression (Node));
923 Write_Str (" is");
924 Sprint_Indented_List (Alternatives (Node));
925 Write_Indent_Str ("end case;");
927 when N_Case_Statement_Alternative =>
928 Write_Indent_Str_Sloc ("when ");
929 Sprint_Bar_List (Discrete_Choices (Node));
930 Write_Str (" => ");
931 Sprint_Indented_List (Statements (Node));
933 when N_Character_Literal =>
934 if Column > 70 then
935 Write_Indent_Str (" ");
936 end if;
938 Write_Char_Sloc (''');
939 Write_Char_Code (Char_Literal_Value (Node));
940 Write_Char (''');
942 when N_Code_Statement =>
943 Write_Indent;
944 Set_Debug_Sloc;
945 Sprint_Node (Expression (Node));
946 Write_Char (';');
948 when N_Compilation_Unit =>
949 Sprint_Node_List (Context_Items (Node));
950 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
952 if Private_Present (Node) then
953 Write_Indent_Str ("private ");
954 Indent_Annull;
955 end if;
957 Sprint_Node_Sloc (Unit (Node));
959 if Present (Actions (Aux_Decls_Node (Node)))
960 or else
961 Present (Pragmas_After (Aux_Decls_Node (Node)))
962 then
963 Write_Indent;
964 end if;
966 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
967 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
969 when N_Compilation_Unit_Aux =>
970 null; -- nothing to do, never used, see above
972 when N_Component_Association =>
973 Set_Debug_Sloc;
974 Sprint_Bar_List (Choices (Node));
975 Write_Str (" => ");
977 -- Ada 0Y (AI-287): Print the mbox if present
979 if Box_Present (Node) then
980 Write_Str_With_Col_Check ("<>");
981 else
982 Sprint_Node (Expression (Node));
983 end if;
985 when N_Component_Clause =>
986 Write_Indent;
987 Sprint_Node (Component_Name (Node));
988 Write_Str_Sloc (" at ");
989 Sprint_Node (Position (Node));
990 Write_Char (' ');
991 Write_Str_With_Col_Check ("range ");
992 Sprint_Node (First_Bit (Node));
993 Write_Str (" .. ");
994 Sprint_Node (Last_Bit (Node));
995 Write_Char (';');
997 when N_Component_Definition =>
998 Set_Debug_Sloc;
1000 -- Ada 0Y (AI-230): Access definition components
1002 if Present (Access_Definition (Node)) then
1003 Sprint_Node (Access_Definition (Node));
1005 elsif Present (Subtype_Indication (Node)) then
1006 if Aliased_Present (Node) then
1007 Write_Str_With_Col_Check ("aliased ");
1008 end if;
1010 -- Ada 0Y (AI-231)
1012 if Null_Exclusion_Present (Node) then
1013 Write_Str (" not null ");
1014 end if;
1016 Sprint_Node (Subtype_Indication (Node));
1018 else
1019 Write_Str (" ??? ");
1020 end if;
1022 when N_Component_Declaration =>
1023 if Write_Indent_Identifiers_Sloc (Node) then
1024 Write_Str (" : ");
1025 Sprint_Node (Component_Definition (Node));
1027 if Present (Expression (Node)) then
1028 Write_Str (" := ");
1029 Sprint_Node (Expression (Node));
1030 end if;
1032 Write_Char (';');
1033 end if;
1035 when N_Component_List =>
1036 if Null_Present (Node) then
1037 Indent_Begin;
1038 Write_Indent_Str_Sloc ("null");
1039 Write_Char (';');
1040 Indent_End;
1042 else
1043 Set_Debug_Sloc;
1044 Sprint_Indented_List (Component_Items (Node));
1045 Sprint_Node (Variant_Part (Node));
1046 end if;
1048 when N_Conditional_Entry_Call =>
1049 Write_Indent_Str_Sloc ("select");
1050 Indent_Begin;
1051 Sprint_Node (Entry_Call_Alternative (Node));
1052 Indent_End;
1053 Write_Indent_Str ("else");
1054 Sprint_Indented_List (Else_Statements (Node));
1055 Write_Indent_Str ("end select;");
1057 when N_Conditional_Expression =>
1058 declare
1059 Condition : constant Node_Id := First (Expressions (Node));
1060 Then_Expr : constant Node_Id := Next (Condition);
1061 Else_Expr : constant Node_Id := Next (Then_Expr);
1063 begin
1064 Write_Str_With_Col_Check_Sloc ("(if ");
1065 Sprint_Node (Condition);
1066 Write_Str_With_Col_Check (" then ");
1067 Sprint_Node (Then_Expr);
1068 Write_Str_With_Col_Check (" else ");
1069 Sprint_Node (Else_Expr);
1070 Write_Char (')');
1071 end;
1073 when N_Constrained_Array_Definition =>
1074 Write_Str_With_Col_Check_Sloc ("array ");
1075 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1076 Write_Str (" of ");
1078 Sprint_Node (Component_Definition (Node));
1080 when N_Decimal_Fixed_Point_Definition =>
1081 Write_Str_With_Col_Check_Sloc (" delta ");
1082 Sprint_Node (Delta_Expression (Node));
1083 Write_Str_With_Col_Check ("digits ");
1084 Sprint_Node (Digits_Expression (Node));
1085 Sprint_Opt_Node (Real_Range_Specification (Node));
1087 when N_Defining_Character_Literal =>
1088 Write_Name_With_Col_Check_Sloc (Chars (Node));
1090 when N_Defining_Identifier =>
1091 Set_Debug_Sloc;
1092 Write_Id (Node);
1094 when N_Defining_Operator_Symbol =>
1095 Write_Name_With_Col_Check_Sloc (Chars (Node));
1097 when N_Defining_Program_Unit_Name =>
1098 Set_Debug_Sloc;
1099 Sprint_Node (Name (Node));
1100 Write_Char ('.');
1101 Write_Id (Defining_Identifier (Node));
1103 when N_Delay_Alternative =>
1104 Sprint_Node_List (Pragmas_Before (Node));
1106 if Present (Condition (Node)) then
1107 Write_Indent;
1108 Write_Str_With_Col_Check ("when ");
1109 Sprint_Node (Condition (Node));
1110 Write_Str (" => ");
1111 Indent_Annull;
1112 end if;
1114 Sprint_Node_Sloc (Delay_Statement (Node));
1115 Sprint_Node_List (Statements (Node));
1117 when N_Delay_Relative_Statement =>
1118 Write_Indent_Str_Sloc ("delay ");
1119 Sprint_Node (Expression (Node));
1120 Write_Char (';');
1122 when N_Delay_Until_Statement =>
1123 Write_Indent_Str_Sloc ("delay until ");
1124 Sprint_Node (Expression (Node));
1125 Write_Char (';');
1127 when N_Delta_Constraint =>
1128 Write_Str_With_Col_Check_Sloc ("delta ");
1129 Sprint_Node (Delta_Expression (Node));
1130 Sprint_Opt_Node (Range_Constraint (Node));
1132 when N_Derived_Type_Definition =>
1133 if Abstract_Present (Node) then
1134 Write_Str_With_Col_Check ("abstract ");
1135 end if;
1137 Write_Str_With_Col_Check_Sloc ("new ");
1139 -- Ada 0Y (AI-231)
1141 if Null_Exclusion_Present (Node) then
1142 Write_Str_With_Col_Check ("not null ");
1143 end if;
1145 Sprint_Node (Subtype_Indication (Node));
1147 if Present (Record_Extension_Part (Node)) then
1148 Write_Str_With_Col_Check (" with ");
1149 Sprint_Node (Record_Extension_Part (Node));
1150 end if;
1152 when N_Designator =>
1153 Sprint_Node (Name (Node));
1154 Write_Char_Sloc ('.');
1155 Write_Id (Identifier (Node));
1157 when N_Digits_Constraint =>
1158 Write_Str_With_Col_Check_Sloc ("digits ");
1159 Sprint_Node (Digits_Expression (Node));
1160 Sprint_Opt_Node (Range_Constraint (Node));
1162 when N_Discriminant_Association =>
1163 Set_Debug_Sloc;
1165 if Present (Selector_Names (Node)) then
1166 Sprint_Bar_List (Selector_Names (Node));
1167 Write_Str (" => ");
1168 end if;
1170 Set_Debug_Sloc;
1171 Sprint_Node (Expression (Node));
1173 when N_Discriminant_Specification =>
1174 Set_Debug_Sloc;
1176 if Write_Identifiers (Node) then
1177 Write_Str (" : ");
1179 if Null_Exclusion_Present (Node) then
1180 Write_Str ("not null ");
1181 end if;
1183 Sprint_Node (Discriminant_Type (Node));
1185 if Present (Expression (Node)) then
1186 Write_Str (" := ");
1187 Sprint_Node (Expression (Node));
1188 end if;
1189 else
1190 Write_Str (", ");
1191 end if;
1193 when N_Elsif_Part =>
1194 Write_Indent_Str_Sloc ("elsif ");
1195 Sprint_Node (Condition (Node));
1196 Write_Str_With_Col_Check (" then");
1197 Sprint_Indented_List (Then_Statements (Node));
1199 when N_Empty =>
1200 null;
1202 when N_Entry_Body =>
1203 Write_Indent_Str_Sloc ("entry ");
1204 Write_Id (Defining_Identifier (Node));
1205 Sprint_Node (Entry_Body_Formal_Part (Node));
1206 Write_Str_With_Col_Check (" is");
1207 Sprint_Indented_List (Declarations (Node));
1208 Write_Indent_Str ("begin");
1209 Sprint_Node (Handled_Statement_Sequence (Node));
1210 Write_Indent_Str ("end ");
1211 Write_Id (Defining_Identifier (Node));
1212 Write_Char (';');
1214 when N_Entry_Body_Formal_Part =>
1215 if Present (Entry_Index_Specification (Node)) then
1216 Write_Str_With_Col_Check_Sloc (" (");
1217 Sprint_Node (Entry_Index_Specification (Node));
1218 Write_Char (')');
1219 end if;
1221 Write_Param_Specs (Node);
1222 Write_Str_With_Col_Check_Sloc (" when ");
1223 Sprint_Node (Condition (Node));
1225 when N_Entry_Call_Alternative =>
1226 Sprint_Node_List (Pragmas_Before (Node));
1227 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1228 Sprint_Node_List (Statements (Node));
1230 when N_Entry_Call_Statement =>
1231 Write_Indent;
1232 Sprint_Node_Sloc (Name (Node));
1233 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1234 Write_Char (';');
1236 when N_Entry_Declaration =>
1237 Write_Indent_Str_Sloc ("entry ");
1238 Write_Id (Defining_Identifier (Node));
1240 if Present (Discrete_Subtype_Definition (Node)) then
1241 Write_Str_With_Col_Check (" (");
1242 Sprint_Node (Discrete_Subtype_Definition (Node));
1243 Write_Char (')');
1244 end if;
1246 Write_Param_Specs (Node);
1247 Write_Char (';');
1249 when N_Entry_Index_Specification =>
1250 Write_Str_With_Col_Check_Sloc ("for ");
1251 Write_Id (Defining_Identifier (Node));
1252 Write_Str_With_Col_Check (" in ");
1253 Sprint_Node (Discrete_Subtype_Definition (Node));
1255 when N_Enumeration_Representation_Clause =>
1256 Write_Indent_Str_Sloc ("for ");
1257 Write_Id (Identifier (Node));
1258 Write_Str_With_Col_Check (" use ");
1259 Sprint_Node (Array_Aggregate (Node));
1260 Write_Char (';');
1262 when N_Enumeration_Type_Definition =>
1263 Set_Debug_Sloc;
1265 -- Skip attempt to print Literals field if it's not there and
1266 -- we are in package Standard (case of Character, which is
1267 -- handled specially (without an explicit literals list).
1269 if Sloc (Node) > Standard_Location
1270 or else Present (Literals (Node))
1271 then
1272 Sprint_Paren_Comma_List (Literals (Node));
1273 end if;
1275 when N_Error =>
1276 Write_Str_With_Col_Check_Sloc ("<error>");
1278 when N_Exception_Declaration =>
1279 if Write_Indent_Identifiers (Node) then
1280 Write_Str_With_Col_Check (" : ");
1281 Write_Str_Sloc ("exception;");
1282 end if;
1284 when N_Exception_Handler =>
1285 Write_Indent_Str_Sloc ("when ");
1287 if Present (Choice_Parameter (Node)) then
1288 Sprint_Node (Choice_Parameter (Node));
1289 Write_Str (" : ");
1290 end if;
1292 Sprint_Bar_List (Exception_Choices (Node));
1293 Write_Str (" => ");
1294 Sprint_Indented_List (Statements (Node));
1296 when N_Exception_Renaming_Declaration =>
1297 Write_Indent;
1298 Set_Debug_Sloc;
1299 Sprint_Node (Defining_Identifier (Node));
1300 Write_Str_With_Col_Check (" : exception renames ");
1301 Sprint_Node (Name (Node));
1302 Write_Char (';');
1304 when N_Exit_Statement =>
1305 Write_Indent_Str_Sloc ("exit");
1306 Sprint_Opt_Node (Name (Node));
1308 if Present (Condition (Node)) then
1309 Write_Str_With_Col_Check (" when ");
1310 Sprint_Node (Condition (Node));
1311 end if;
1313 Write_Char (';');
1315 when N_Expanded_Name =>
1316 Sprint_Node (Prefix (Node));
1317 Write_Char_Sloc ('.');
1318 Sprint_Node (Selector_Name (Node));
1320 when N_Explicit_Dereference =>
1321 Sprint_Node (Prefix (Node));
1322 Write_Char_Sloc ('.');
1323 Write_Str_Sloc ("all");
1325 when N_Extension_Aggregate =>
1326 Write_Str_With_Col_Check_Sloc ("(");
1327 Sprint_Node (Ancestor_Part (Node));
1328 Write_Str_With_Col_Check (" with ");
1330 if Null_Record_Present (Node) then
1331 Write_Str_With_Col_Check ("null record");
1332 else
1333 if Present (Expressions (Node)) then
1334 Sprint_Comma_List (Expressions (Node));
1336 if Present (Component_Associations (Node)) then
1337 Write_Str (", ");
1338 end if;
1339 end if;
1341 if Present (Component_Associations (Node)) then
1342 Sprint_Comma_List (Component_Associations (Node));
1343 end if;
1344 end if;
1346 Write_Char (')');
1348 when N_Floating_Point_Definition =>
1349 Write_Str_With_Col_Check_Sloc ("digits ");
1350 Sprint_Node (Digits_Expression (Node));
1351 Sprint_Opt_Node (Real_Range_Specification (Node));
1353 when N_Formal_Decimal_Fixed_Point_Definition =>
1354 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1356 when N_Formal_Derived_Type_Definition =>
1357 Write_Str_With_Col_Check_Sloc ("new ");
1358 Sprint_Node (Subtype_Mark (Node));
1360 if Private_Present (Node) then
1361 Write_Str_With_Col_Check (" with private");
1362 end if;
1364 when N_Formal_Discrete_Type_Definition =>
1365 Write_Str_With_Col_Check_Sloc ("<>");
1367 when N_Formal_Floating_Point_Definition =>
1368 Write_Str_With_Col_Check_Sloc ("digits <>");
1370 when N_Formal_Modular_Type_Definition =>
1371 Write_Str_With_Col_Check_Sloc ("mod <>");
1373 when N_Formal_Object_Declaration =>
1374 Set_Debug_Sloc;
1376 if Write_Indent_Identifiers (Node) then
1377 Write_Str (" : ");
1379 if In_Present (Node) then
1380 Write_Str_With_Col_Check ("in ");
1381 end if;
1383 if Out_Present (Node) then
1384 Write_Str_With_Col_Check ("out ");
1385 end if;
1387 Sprint_Node (Subtype_Mark (Node));
1389 if Present (Expression (Node)) then
1390 Write_Str (" := ");
1391 Sprint_Node (Expression (Node));
1392 end if;
1394 Write_Char (';');
1395 end if;
1397 when N_Formal_Ordinary_Fixed_Point_Definition =>
1398 Write_Str_With_Col_Check_Sloc ("delta <>");
1400 when N_Formal_Package_Declaration =>
1401 Write_Indent_Str_Sloc ("with package ");
1402 Write_Id (Defining_Identifier (Node));
1403 Write_Str_With_Col_Check (" is new ");
1404 Sprint_Node (Name (Node));
1405 Write_Str_With_Col_Check (" (<>);");
1407 when N_Formal_Private_Type_Definition =>
1408 if Abstract_Present (Node) then
1409 Write_Str_With_Col_Check ("abstract ");
1410 end if;
1412 if Tagged_Present (Node) then
1413 Write_Str_With_Col_Check ("tagged ");
1414 end if;
1416 if Limited_Present (Node) then
1417 Write_Str_With_Col_Check ("limited ");
1418 end if;
1420 Write_Str_With_Col_Check_Sloc ("private");
1422 when N_Formal_Signed_Integer_Type_Definition =>
1423 Write_Str_With_Col_Check_Sloc ("range <>");
1425 when N_Formal_Subprogram_Declaration =>
1426 Write_Indent_Str_Sloc ("with ");
1427 Sprint_Node (Specification (Node));
1429 if Box_Present (Node) then
1430 Write_Str_With_Col_Check (" is <>");
1431 elsif Present (Default_Name (Node)) then
1432 Write_Str_With_Col_Check (" is ");
1433 Sprint_Node (Default_Name (Node));
1434 end if;
1436 Write_Char (';');
1438 when N_Formal_Type_Declaration =>
1439 Write_Indent_Str_Sloc ("type ");
1440 Write_Id (Defining_Identifier (Node));
1442 if Present (Discriminant_Specifications (Node)) then
1443 Write_Discr_Specs (Node);
1444 elsif Unknown_Discriminants_Present (Node) then
1445 Write_Str_With_Col_Check ("(<>)");
1446 end if;
1448 Write_Str_With_Col_Check (" is ");
1449 Sprint_Node (Formal_Type_Definition (Node));
1450 Write_Char (';');
1452 when N_Free_Statement =>
1453 Write_Indent_Str_Sloc ("free ");
1454 Sprint_Node (Expression (Node));
1455 Write_Char (';');
1457 when N_Freeze_Entity =>
1458 if Dump_Original_Only then
1459 null;
1461 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1462 Write_Indent;
1463 Write_Rewrite_Str ("<<<");
1464 Write_Str_With_Col_Check_Sloc ("freeze ");
1465 Write_Id (Entity (Node));
1466 Write_Str (" [");
1468 if No (Actions (Node)) then
1469 Write_Char (']');
1471 else
1472 Freeze_Indent := Freeze_Indent + 1;
1473 Sprint_Indented_List (Actions (Node));
1474 Freeze_Indent := Freeze_Indent - 1;
1475 Write_Indent_Str ("]");
1476 end if;
1478 Write_Rewrite_Str (">>>");
1479 end if;
1481 when N_Full_Type_Declaration =>
1482 Write_Indent_Str_Sloc ("type ");
1483 Write_Id (Defining_Identifier (Node));
1484 Write_Discr_Specs (Node);
1485 Write_Str_With_Col_Check (" is ");
1486 Sprint_Node (Type_Definition (Node));
1487 Write_Char (';');
1489 when N_Function_Call =>
1490 Set_Debug_Sloc;
1491 Sprint_Node (Name (Node));
1492 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1494 when N_Function_Instantiation =>
1495 Write_Indent_Str_Sloc ("function ");
1496 Sprint_Node (Defining_Unit_Name (Node));
1497 Write_Str_With_Col_Check (" is new ");
1498 Sprint_Node (Name (Node));
1499 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1500 Write_Char (';');
1502 when N_Function_Specification =>
1503 Write_Str_With_Col_Check_Sloc ("function ");
1504 Sprint_Node (Defining_Unit_Name (Node));
1505 Write_Param_Specs (Node);
1506 Write_Str_With_Col_Check (" return ");
1507 Sprint_Node (Subtype_Mark (Node));
1509 when N_Generic_Association =>
1510 Set_Debug_Sloc;
1512 if Present (Selector_Name (Node)) then
1513 Sprint_Node (Selector_Name (Node));
1514 Write_Str (" => ");
1515 end if;
1517 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1519 when N_Generic_Function_Renaming_Declaration =>
1520 Write_Indent_Str_Sloc ("generic function ");
1521 Sprint_Node (Defining_Unit_Name (Node));
1522 Write_Str_With_Col_Check (" renames ");
1523 Sprint_Node (Name (Node));
1524 Write_Char (';');
1526 when N_Generic_Package_Declaration =>
1527 Write_Indent;
1528 Write_Indent_Str_Sloc ("generic ");
1529 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1530 Write_Indent;
1531 Sprint_Node (Specification (Node));
1532 Write_Char (';');
1534 when N_Generic_Package_Renaming_Declaration =>
1535 Write_Indent_Str_Sloc ("generic package ");
1536 Sprint_Node (Defining_Unit_Name (Node));
1537 Write_Str_With_Col_Check (" renames ");
1538 Sprint_Node (Name (Node));
1539 Write_Char (';');
1541 when N_Generic_Procedure_Renaming_Declaration =>
1542 Write_Indent_Str_Sloc ("generic procedure ");
1543 Sprint_Node (Defining_Unit_Name (Node));
1544 Write_Str_With_Col_Check (" renames ");
1545 Sprint_Node (Name (Node));
1546 Write_Char (';');
1548 when N_Generic_Subprogram_Declaration =>
1549 Write_Indent;
1550 Write_Indent_Str_Sloc ("generic ");
1551 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1552 Write_Indent;
1553 Sprint_Node (Specification (Node));
1554 Write_Char (';');
1556 when N_Goto_Statement =>
1557 Write_Indent_Str_Sloc ("goto ");
1558 Sprint_Node (Name (Node));
1559 Write_Char (';');
1561 if Nkind (Next (Node)) = N_Label then
1562 Write_Indent;
1563 end if;
1565 when N_Handled_Sequence_Of_Statements =>
1566 Set_Debug_Sloc;
1567 Sprint_Indented_List (Statements (Node));
1569 if Present (Exception_Handlers (Node)) then
1570 Write_Indent_Str ("exception");
1571 Indent_Begin;
1572 Sprint_Node_List (Exception_Handlers (Node));
1573 Indent_End;
1574 end if;
1576 if Present (At_End_Proc (Node)) then
1577 Write_Indent_Str ("at end");
1578 Indent_Begin;
1579 Write_Indent;
1580 Sprint_Node (At_End_Proc (Node));
1581 Write_Char (';');
1582 Indent_End;
1583 end if;
1585 when N_Identifier =>
1586 Set_Debug_Sloc;
1587 Write_Id (Node);
1589 when N_If_Statement =>
1590 Write_Indent_Str_Sloc ("if ");
1591 Sprint_Node (Condition (Node));
1592 Write_Str_With_Col_Check (" then");
1593 Sprint_Indented_List (Then_Statements (Node));
1594 Sprint_Opt_Node_List (Elsif_Parts (Node));
1596 if Present (Else_Statements (Node)) then
1597 Write_Indent_Str ("else");
1598 Sprint_Indented_List (Else_Statements (Node));
1599 end if;
1601 Write_Indent_Str ("end if;");
1603 when N_Implicit_Label_Declaration =>
1604 if not Dump_Original_Only then
1605 Write_Indent;
1606 Write_Rewrite_Str ("<<<");
1607 Set_Debug_Sloc;
1608 Write_Id (Defining_Identifier (Node));
1609 Write_Str (" : ");
1610 Write_Str_With_Col_Check ("label");
1611 Write_Rewrite_Str (">>>");
1612 end if;
1614 when N_In =>
1615 Sprint_Left_Opnd (Node);
1616 Write_Str_Sloc (" in ");
1617 Sprint_Right_Opnd (Node);
1619 when N_Incomplete_Type_Declaration =>
1620 Write_Indent_Str_Sloc ("type ");
1621 Write_Id (Defining_Identifier (Node));
1623 if Present (Discriminant_Specifications (Node)) then
1624 Write_Discr_Specs (Node);
1625 elsif Unknown_Discriminants_Present (Node) then
1626 Write_Str_With_Col_Check ("(<>)");
1627 end if;
1629 Write_Char (';');
1631 when N_Index_Or_Discriminant_Constraint =>
1632 Set_Debug_Sloc;
1633 Sprint_Paren_Comma_List (Constraints (Node));
1635 when N_Indexed_Component =>
1636 Sprint_Node_Sloc (Prefix (Node));
1637 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1639 when N_Integer_Literal =>
1640 if Print_In_Hex (Node) then
1641 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1642 else
1643 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1644 end if;
1646 when N_Iteration_Scheme =>
1647 if Present (Condition (Node)) then
1648 Write_Str_With_Col_Check_Sloc ("while ");
1649 Sprint_Node (Condition (Node));
1650 else
1651 Write_Str_With_Col_Check_Sloc ("for ");
1652 Sprint_Node (Loop_Parameter_Specification (Node));
1653 end if;
1655 Write_Char (' ');
1657 when N_Itype_Reference =>
1658 Write_Indent_Str_Sloc ("reference ");
1659 Write_Id (Itype (Node));
1661 when N_Label =>
1662 Write_Indent_Str_Sloc ("<<");
1663 Write_Id (Identifier (Node));
1664 Write_Str (">>");
1666 when N_Loop_Parameter_Specification =>
1667 Set_Debug_Sloc;
1668 Write_Id (Defining_Identifier (Node));
1669 Write_Str_With_Col_Check (" in ");
1671 if Reverse_Present (Node) then
1672 Write_Str_With_Col_Check ("reverse ");
1673 end if;
1675 Sprint_Node (Discrete_Subtype_Definition (Node));
1677 when N_Loop_Statement =>
1678 Write_Indent;
1680 if Present (Identifier (Node))
1681 and then (not Has_Created_Identifier (Node)
1682 or else not Dump_Original_Only)
1683 then
1684 Write_Rewrite_Str ("<<<");
1685 Write_Id (Identifier (Node));
1686 Write_Str (" : ");
1687 Write_Rewrite_Str (">>>");
1688 Sprint_Node (Iteration_Scheme (Node));
1689 Write_Str_With_Col_Check_Sloc ("loop");
1690 Sprint_Indented_List (Statements (Node));
1691 Write_Indent_Str ("end loop ");
1692 Write_Rewrite_Str ("<<<");
1693 Write_Id (Identifier (Node));
1694 Write_Rewrite_Str (">>>");
1695 Write_Char (';');
1697 else
1698 Sprint_Node (Iteration_Scheme (Node));
1699 Write_Str_With_Col_Check_Sloc ("loop");
1700 Sprint_Indented_List (Statements (Node));
1701 Write_Indent_Str ("end loop;");
1702 end if;
1704 when N_Mod_Clause =>
1705 Sprint_Node_List (Pragmas_Before (Node));
1706 Write_Str_With_Col_Check_Sloc ("at mod ");
1707 Sprint_Node (Expression (Node));
1709 when N_Modular_Type_Definition =>
1710 Write_Str_With_Col_Check_Sloc ("mod ");
1711 Sprint_Node (Expression (Node));
1713 when N_Not_In =>
1714 Sprint_Left_Opnd (Node);
1715 Write_Str_Sloc (" not in ");
1716 Sprint_Right_Opnd (Node);
1718 when N_Null =>
1719 Write_Str_With_Col_Check_Sloc ("null");
1721 when N_Null_Statement =>
1722 if Comes_From_Source (Node)
1723 or else Dump_Freeze_Null
1724 or else not Is_List_Member (Node)
1725 or else (No (Prev (Node)) and then No (Next (Node)))
1726 then
1727 Write_Indent_Str_Sloc ("null;");
1728 end if;
1730 when N_Number_Declaration =>
1731 Set_Debug_Sloc;
1733 if Write_Indent_Identifiers (Node) then
1734 Write_Str_With_Col_Check (" : constant ");
1735 Write_Str (" := ");
1736 Sprint_Node (Expression (Node));
1737 Write_Char (';');
1738 end if;
1740 when N_Object_Declaration =>
1741 Set_Debug_Sloc;
1743 if Write_Indent_Identifiers (Node) then
1744 Write_Str (" : ");
1746 if Aliased_Present (Node) then
1747 Write_Str_With_Col_Check ("aliased ");
1748 end if;
1750 if Constant_Present (Node) then
1751 Write_Str_With_Col_Check ("constant ");
1752 end if;
1754 -- Ada 0Y (AI-231)
1756 if Null_Exclusion_Present (Node) then
1757 Write_Str_With_Col_Check ("not null ");
1758 end if;
1760 Sprint_Node (Object_Definition (Node));
1762 if Present (Expression (Node)) then
1763 Write_Str (" := ");
1764 Sprint_Node (Expression (Node));
1765 end if;
1767 Write_Char (';');
1768 end if;
1770 when N_Object_Renaming_Declaration =>
1771 Write_Indent;
1772 Set_Debug_Sloc;
1773 Sprint_Node (Defining_Identifier (Node));
1774 Write_Str (" : ");
1776 -- Ada 0Y (AI-230): Access renamings
1778 if Present (Access_Definition (Node)) then
1779 Sprint_Node (Access_Definition (Node));
1781 elsif Present (Subtype_Mark (Node)) then
1782 Sprint_Node (Subtype_Mark (Node));
1784 else
1785 Write_Str (" ??? ");
1786 end if;
1788 Write_Str_With_Col_Check (" renames ");
1789 Sprint_Node (Name (Node));
1790 Write_Char (';');
1792 when N_Op_Abs =>
1793 Write_Operator (Node, "abs ");
1794 Sprint_Right_Opnd (Node);
1796 when N_Op_Add =>
1797 Sprint_Left_Opnd (Node);
1798 Write_Operator (Node, " + ");
1799 Sprint_Right_Opnd (Node);
1801 when N_Op_And =>
1802 Sprint_Left_Opnd (Node);
1803 Write_Operator (Node, " and ");
1804 Sprint_Right_Opnd (Node);
1806 when N_Op_Concat =>
1807 Sprint_Left_Opnd (Node);
1808 Write_Operator (Node, " & ");
1809 Sprint_Right_Opnd (Node);
1811 when N_Op_Divide =>
1812 Sprint_Left_Opnd (Node);
1813 Write_Char (' ');
1814 Process_TFAI_RR_Flags (Node);
1815 Write_Operator (Node, "/ ");
1816 Sprint_Right_Opnd (Node);
1818 when N_Op_Eq =>
1819 Sprint_Left_Opnd (Node);
1820 Write_Operator (Node, " = ");
1821 Sprint_Right_Opnd (Node);
1823 when N_Op_Expon =>
1824 Sprint_Left_Opnd (Node);
1825 Write_Operator (Node, " ** ");
1826 Sprint_Right_Opnd (Node);
1828 when N_Op_Ge =>
1829 Sprint_Left_Opnd (Node);
1830 Write_Operator (Node, " >= ");
1831 Sprint_Right_Opnd (Node);
1833 when N_Op_Gt =>
1834 Sprint_Left_Opnd (Node);
1835 Write_Operator (Node, " > ");
1836 Sprint_Right_Opnd (Node);
1838 when N_Op_Le =>
1839 Sprint_Left_Opnd (Node);
1840 Write_Operator (Node, " <= ");
1841 Sprint_Right_Opnd (Node);
1843 when N_Op_Lt =>
1844 Sprint_Left_Opnd (Node);
1845 Write_Operator (Node, " < ");
1846 Sprint_Right_Opnd (Node);
1848 when N_Op_Minus =>
1849 Write_Operator (Node, "-");
1850 Sprint_Right_Opnd (Node);
1852 when N_Op_Mod =>
1853 Sprint_Left_Opnd (Node);
1855 if Treat_Fixed_As_Integer (Node) then
1856 Write_Str (" #");
1857 end if;
1859 Write_Operator (Node, " mod ");
1860 Sprint_Right_Opnd (Node);
1862 when N_Op_Multiply =>
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_Ne =>
1870 Sprint_Left_Opnd (Node);
1871 Write_Operator (Node, " /= ");
1872 Sprint_Right_Opnd (Node);
1874 when N_Op_Not =>
1875 Write_Operator (Node, "not ");
1876 Sprint_Right_Opnd (Node);
1878 when N_Op_Or =>
1879 Sprint_Left_Opnd (Node);
1880 Write_Operator (Node, " or ");
1881 Sprint_Right_Opnd (Node);
1883 when N_Op_Plus =>
1884 Write_Operator (Node, "+");
1885 Sprint_Right_Opnd (Node);
1887 when N_Op_Rem =>
1888 Sprint_Left_Opnd (Node);
1890 if Treat_Fixed_As_Integer (Node) then
1891 Write_Str (" #");
1892 end if;
1894 Write_Operator (Node, " rem ");
1895 Sprint_Right_Opnd (Node);
1897 when N_Op_Shift =>
1898 Set_Debug_Sloc;
1899 Write_Id (Node);
1900 Write_Char ('!');
1901 Write_Str_With_Col_Check ("(");
1902 Sprint_Node (Left_Opnd (Node));
1903 Write_Str (", ");
1904 Sprint_Node (Right_Opnd (Node));
1905 Write_Char (')');
1907 when N_Op_Subtract =>
1908 Sprint_Left_Opnd (Node);
1909 Write_Operator (Node, " - ");
1910 Sprint_Right_Opnd (Node);
1912 when N_Op_Xor =>
1913 Sprint_Left_Opnd (Node);
1914 Write_Operator (Node, " xor ");
1915 Sprint_Right_Opnd (Node);
1917 when N_Operator_Symbol =>
1918 Write_Name_With_Col_Check_Sloc (Chars (Node));
1920 when N_Ordinary_Fixed_Point_Definition =>
1921 Write_Str_With_Col_Check_Sloc ("delta ");
1922 Sprint_Node (Delta_Expression (Node));
1923 Sprint_Opt_Node (Real_Range_Specification (Node));
1925 when N_Or_Else =>
1926 Sprint_Left_Opnd (Node);
1927 Write_Str_Sloc (" or else ");
1928 Sprint_Right_Opnd (Node);
1930 when N_Others_Choice =>
1931 if All_Others (Node) then
1932 Write_Str_With_Col_Check ("all ");
1933 end if;
1935 Write_Str_With_Col_Check_Sloc ("others");
1937 when N_Package_Body =>
1938 Write_Indent;
1939 Write_Indent_Str_Sloc ("package body ");
1940 Sprint_Node (Defining_Unit_Name (Node));
1941 Write_Str (" is");
1942 Sprint_Indented_List (Declarations (Node));
1944 if Present (Handled_Statement_Sequence (Node)) then
1945 Write_Indent_Str ("begin");
1946 Sprint_Node (Handled_Statement_Sequence (Node));
1947 end if;
1949 Write_Indent_Str ("end ");
1950 Sprint_Node (Defining_Unit_Name (Node));
1951 Write_Char (';');
1953 when N_Package_Body_Stub =>
1954 Write_Indent_Str_Sloc ("package body ");
1955 Sprint_Node (Defining_Identifier (Node));
1956 Write_Str_With_Col_Check (" is separate;");
1958 when N_Package_Declaration =>
1959 Write_Indent;
1960 Write_Indent;
1961 Sprint_Node_Sloc (Specification (Node));
1962 Write_Char (';');
1964 when N_Package_Instantiation =>
1965 Write_Indent;
1966 Write_Indent_Str_Sloc ("package ");
1967 Sprint_Node (Defining_Unit_Name (Node));
1968 Write_Str (" is new ");
1969 Sprint_Node (Name (Node));
1970 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1971 Write_Char (';');
1973 when N_Package_Renaming_Declaration =>
1974 Write_Indent_Str_Sloc ("package ");
1975 Sprint_Node (Defining_Unit_Name (Node));
1976 Write_Str_With_Col_Check (" renames ");
1977 Sprint_Node (Name (Node));
1978 Write_Char (';');
1980 when N_Package_Specification =>
1981 Write_Str_With_Col_Check_Sloc ("package ");
1982 Sprint_Node (Defining_Unit_Name (Node));
1983 Write_Str (" is");
1984 Sprint_Indented_List (Visible_Declarations (Node));
1986 if Present (Private_Declarations (Node)) then
1987 Write_Indent_Str ("private");
1988 Sprint_Indented_List (Private_Declarations (Node));
1989 end if;
1991 Write_Indent_Str ("end ");
1992 Sprint_Node (Defining_Unit_Name (Node));
1994 when N_Parameter_Association =>
1995 Sprint_Node_Sloc (Selector_Name (Node));
1996 Write_Str (" => ");
1997 Sprint_Node (Explicit_Actual_Parameter (Node));
1999 when N_Parameter_Specification =>
2000 Set_Debug_Sloc;
2002 if Write_Identifiers (Node) then
2003 Write_Str (" : ");
2005 if In_Present (Node) then
2006 Write_Str_With_Col_Check ("in ");
2007 end if;
2009 if Out_Present (Node) then
2010 Write_Str_With_Col_Check ("out ");
2011 end if;
2013 -- Ada 0Y (AI-231)
2015 if Null_Exclusion_Present (Node) then
2016 Write_Str ("not null ");
2017 end if;
2019 Sprint_Node (Parameter_Type (Node));
2021 if Present (Expression (Node)) then
2022 Write_Str (" := ");
2023 Sprint_Node (Expression (Node));
2024 end if;
2025 else
2026 Write_Str (", ");
2027 end if;
2029 when N_Pragma =>
2030 Write_Indent_Str_Sloc ("pragma ");
2031 Write_Name_With_Col_Check (Chars (Node));
2033 if Present (Pragma_Argument_Associations (Node)) then
2034 Sprint_Opt_Paren_Comma_List
2035 (Pragma_Argument_Associations (Node));
2036 end if;
2038 Write_Char (';');
2040 when N_Pragma_Argument_Association =>
2041 Set_Debug_Sloc;
2043 if Chars (Node) /= No_Name then
2044 Write_Name_With_Col_Check (Chars (Node));
2045 Write_Str (" => ");
2046 end if;
2048 Sprint_Node (Expression (Node));
2050 when N_Private_Type_Declaration =>
2051 Write_Indent_Str_Sloc ("type ");
2052 Write_Id (Defining_Identifier (Node));
2054 if Present (Discriminant_Specifications (Node)) then
2055 Write_Discr_Specs (Node);
2056 elsif Unknown_Discriminants_Present (Node) then
2057 Write_Str_With_Col_Check ("(<>)");
2058 end if;
2060 Write_Str (" is ");
2062 if Tagged_Present (Node) then
2063 Write_Str_With_Col_Check ("tagged ");
2064 end if;
2066 if Limited_Present (Node) then
2067 Write_Str_With_Col_Check ("limited ");
2068 end if;
2070 Write_Str_With_Col_Check ("private;");
2072 when N_Private_Extension_Declaration =>
2073 Write_Indent_Str_Sloc ("type ");
2074 Write_Id (Defining_Identifier (Node));
2076 if Present (Discriminant_Specifications (Node)) then
2077 Write_Discr_Specs (Node);
2078 elsif Unknown_Discriminants_Present (Node) then
2079 Write_Str_With_Col_Check ("(<>)");
2080 end if;
2082 Write_Str_With_Col_Check (" is new ");
2083 Sprint_Node (Subtype_Indication (Node));
2084 Write_Str_With_Col_Check (" with private;");
2086 when N_Procedure_Call_Statement =>
2087 Write_Indent;
2088 Set_Debug_Sloc;
2089 Sprint_Node (Name (Node));
2090 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2091 Write_Char (';');
2093 when N_Procedure_Instantiation =>
2094 Write_Indent_Str_Sloc ("procedure ");
2095 Sprint_Node (Defining_Unit_Name (Node));
2096 Write_Str_With_Col_Check (" is new ");
2097 Sprint_Node (Name (Node));
2098 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2099 Write_Char (';');
2101 when N_Procedure_Specification =>
2102 Write_Str_With_Col_Check_Sloc ("procedure ");
2103 Sprint_Node (Defining_Unit_Name (Node));
2104 Write_Param_Specs (Node);
2106 when N_Protected_Body =>
2107 Write_Indent_Str_Sloc ("protected body ");
2108 Write_Id (Defining_Identifier (Node));
2109 Write_Str (" is");
2110 Sprint_Indented_List (Declarations (Node));
2111 Write_Indent_Str ("end ");
2112 Write_Id (Defining_Identifier (Node));
2113 Write_Char (';');
2115 when N_Protected_Body_Stub =>
2116 Write_Indent_Str_Sloc ("protected body ");
2117 Write_Id (Defining_Identifier (Node));
2118 Write_Str_With_Col_Check (" is separate;");
2120 when N_Protected_Definition =>
2121 Set_Debug_Sloc;
2122 Sprint_Indented_List (Visible_Declarations (Node));
2124 if Present (Private_Declarations (Node)) then
2125 Write_Indent_Str ("private");
2126 Sprint_Indented_List (Private_Declarations (Node));
2127 end if;
2129 Write_Indent_Str ("end ");
2131 when N_Protected_Type_Declaration =>
2132 Write_Indent_Str_Sloc ("protected type ");
2133 Write_Id (Defining_Identifier (Node));
2134 Write_Discr_Specs (Node);
2135 Write_Str (" is");
2136 Sprint_Node (Protected_Definition (Node));
2137 Write_Id (Defining_Identifier (Node));
2138 Write_Char (';');
2140 when N_Qualified_Expression =>
2141 Sprint_Node (Subtype_Mark (Node));
2142 Write_Char_Sloc (''');
2144 -- Print expression, make sure we have at least one level of
2145 -- parentheses around the expression. For cases of qualified
2146 -- expressions in the source, this is always the case, but
2147 -- for generated qualifications, there may be no explicit
2148 -- parentheses present.
2150 if Paren_Count (Expression (Node)) /= 0 then
2151 Sprint_Node (Expression (Node));
2152 else
2153 Write_Char ('(');
2154 Sprint_Node (Expression (Node));
2155 Write_Char (')');
2156 end if;
2158 when N_Raise_Constraint_Error =>
2160 -- This node can be used either as a subexpression or as a
2161 -- statement form. The following test is a reasonably reliable
2162 -- way to distinguish the two cases.
2164 if Is_List_Member (Node)
2165 and then Nkind (Parent (Node)) not in N_Subexpr
2166 then
2167 Write_Indent;
2168 end if;
2170 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2171 Write_Condition_And_Reason (Node);
2173 when N_Raise_Program_Error =>
2175 -- This node can be used either as a subexpression or as a
2176 -- statement form. The following test is a reasonably reliable
2177 -- way to distinguish the two cases.
2179 if Is_List_Member (Node)
2180 and then Nkind (Parent (Node)) not in N_Subexpr
2181 then
2182 Write_Indent;
2183 end if;
2185 Write_Str_With_Col_Check_Sloc ("[program_error");
2186 Write_Condition_And_Reason (Node);
2188 when N_Raise_Storage_Error =>
2190 -- This node can be used either as a subexpression or as a
2191 -- statement form. The following test is a reasonably reliable
2192 -- way to distinguish the two cases.
2194 if Is_List_Member (Node)
2195 and then Nkind (Parent (Node)) not in N_Subexpr
2196 then
2197 Write_Indent;
2198 end if;
2200 Write_Str_With_Col_Check_Sloc ("[storage_error");
2201 Write_Condition_And_Reason (Node);
2203 when N_Raise_Statement =>
2204 Write_Indent_Str_Sloc ("raise ");
2205 Sprint_Node (Name (Node));
2206 Write_Char (';');
2208 when N_Range =>
2209 Sprint_Node (Low_Bound (Node));
2210 Write_Str_Sloc (" .. ");
2211 Sprint_Node (High_Bound (Node));
2213 when N_Range_Constraint =>
2214 Write_Str_With_Col_Check_Sloc ("range ");
2215 Sprint_Node (Range_Expression (Node));
2217 when N_Real_Literal =>
2218 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2220 when N_Real_Range_Specification =>
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_Record_Definition =>
2227 if Abstract_Present (Node) then
2228 Write_Str_With_Col_Check ("abstract ");
2229 end if;
2231 if Tagged_Present (Node) then
2232 Write_Str_With_Col_Check ("tagged ");
2233 end if;
2235 if Limited_Present (Node) then
2236 Write_Str_With_Col_Check ("limited ");
2237 end if;
2239 if Null_Present (Node) then
2240 Write_Str_With_Col_Check_Sloc ("null record");
2242 else
2243 Write_Str_With_Col_Check_Sloc ("record");
2244 Sprint_Node (Component_List (Node));
2245 Write_Indent_Str ("end record");
2246 end if;
2248 when N_Record_Representation_Clause =>
2249 Write_Indent_Str_Sloc ("for ");
2250 Sprint_Node (Identifier (Node));
2251 Write_Str_With_Col_Check (" use record ");
2253 if Present (Mod_Clause (Node)) then
2254 Sprint_Node (Mod_Clause (Node));
2255 end if;
2257 Sprint_Indented_List (Component_Clauses (Node));
2258 Write_Indent_Str ("end record;");
2260 when N_Reference =>
2261 Sprint_Node (Prefix (Node));
2262 Write_Str_With_Col_Check_Sloc ("'reference");
2264 when N_Requeue_Statement =>
2265 Write_Indent_Str_Sloc ("requeue ");
2266 Sprint_Node (Name (Node));
2268 if Abort_Present (Node) then
2269 Write_Str_With_Col_Check (" with abort");
2270 end if;
2272 Write_Char (';');
2274 when N_Return_Statement =>
2275 if Present (Expression (Node)) then
2276 Write_Indent_Str_Sloc ("return ");
2277 Sprint_Node (Expression (Node));
2278 Write_Char (';');
2279 else
2280 Write_Indent_Str_Sloc ("return;");
2281 end if;
2283 when N_Selective_Accept =>
2284 Write_Indent_Str_Sloc ("select");
2286 declare
2287 Alt_Node : Node_Id;
2289 begin
2290 Alt_Node := First (Select_Alternatives (Node));
2291 loop
2292 Indent_Begin;
2293 Sprint_Node (Alt_Node);
2294 Indent_End;
2295 Next (Alt_Node);
2296 exit when No (Alt_Node);
2297 Write_Indent_Str ("or");
2298 end loop;
2299 end;
2301 if Present (Else_Statements (Node)) then
2302 Write_Indent_Str ("else");
2303 Sprint_Indented_List (Else_Statements (Node));
2304 end if;
2306 Write_Indent_Str ("end select;");
2308 when N_Signed_Integer_Type_Definition =>
2309 Write_Str_With_Col_Check_Sloc ("range ");
2310 Sprint_Node (Low_Bound (Node));
2311 Write_Str (" .. ");
2312 Sprint_Node (High_Bound (Node));
2314 when N_Single_Protected_Declaration =>
2315 Write_Indent_Str_Sloc ("protected ");
2316 Write_Id (Defining_Identifier (Node));
2317 Write_Str (" is");
2318 Sprint_Node (Protected_Definition (Node));
2319 Write_Id (Defining_Identifier (Node));
2320 Write_Char (';');
2322 when N_Single_Task_Declaration =>
2323 Write_Indent_Str_Sloc ("task ");
2324 Write_Id (Defining_Identifier (Node));
2326 if Present (Task_Definition (Node)) then
2327 Write_Str (" is");
2328 Sprint_Node (Task_Definition (Node));
2329 Write_Id (Defining_Identifier (Node));
2330 end if;
2332 Write_Char (';');
2334 when N_Selected_Component =>
2335 Sprint_Node (Prefix (Node));
2336 Write_Char_Sloc ('.');
2337 Sprint_Node (Selector_Name (Node));
2339 when N_Slice =>
2340 Set_Debug_Sloc;
2341 Sprint_Node (Prefix (Node));
2342 Write_Str_With_Col_Check (" (");
2343 Sprint_Node (Discrete_Range (Node));
2344 Write_Char (')');
2346 when N_String_Literal =>
2347 if String_Length (Strval (Node)) + Column > 75 then
2348 Write_Indent_Str (" ");
2349 end if;
2351 Set_Debug_Sloc;
2352 Write_String_Table_Entry (Strval (Node));
2354 when N_Subprogram_Body =>
2355 if Freeze_Indent = 0 then
2356 Write_Indent;
2357 end if;
2359 Write_Indent;
2360 Sprint_Node_Sloc (Specification (Node));
2361 Write_Str (" is");
2363 Sprint_Indented_List (Declarations (Node));
2364 Write_Indent_Str ("begin");
2365 Sprint_Node (Handled_Statement_Sequence (Node));
2367 Write_Indent_Str ("end ");
2368 Sprint_Node (Defining_Unit_Name (Specification (Node)));
2369 Write_Char (';');
2371 if Is_List_Member (Node)
2372 and then Present (Next (Node))
2373 and then Nkind (Next (Node)) /= N_Subprogram_Body
2374 then
2375 Write_Indent;
2376 end if;
2378 when N_Subprogram_Body_Stub =>
2379 Write_Indent;
2380 Sprint_Node_Sloc (Specification (Node));
2381 Write_Str_With_Col_Check (" is separate;");
2383 when N_Subprogram_Declaration =>
2384 Write_Indent;
2385 Sprint_Node_Sloc (Specification (Node));
2386 Write_Char (';');
2388 when N_Subprogram_Info =>
2389 Sprint_Node (Identifier (Node));
2390 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2392 when N_Subprogram_Renaming_Declaration =>
2393 Write_Indent;
2394 Sprint_Node (Specification (Node));
2395 Write_Str_With_Col_Check_Sloc (" renames ");
2396 Sprint_Node (Name (Node));
2397 Write_Char (';');
2399 when N_Subtype_Declaration =>
2400 Write_Indent_Str_Sloc ("subtype ");
2401 Write_Id (Defining_Identifier (Node));
2402 Write_Str (" is ");
2404 -- Ada 0Y (AI-231)
2406 if Null_Exclusion_Present (Node) then
2407 Write_Str ("not null ");
2408 end if;
2410 Sprint_Node (Subtype_Indication (Node));
2411 Write_Char (';');
2413 when N_Subtype_Indication =>
2414 Sprint_Node_Sloc (Subtype_Mark (Node));
2415 Write_Char (' ');
2416 Sprint_Node (Constraint (Node));
2418 when N_Subunit =>
2419 Write_Indent_Str_Sloc ("separate (");
2420 Sprint_Node (Name (Node));
2421 Write_Char (')');
2422 Write_Eol;
2423 Sprint_Node (Proper_Body (Node));
2425 when N_Task_Body =>
2426 Write_Indent_Str_Sloc ("task body ");
2427 Write_Id (Defining_Identifier (Node));
2428 Write_Str (" is");
2429 Sprint_Indented_List (Declarations (Node));
2430 Write_Indent_Str ("begin");
2431 Sprint_Node (Handled_Statement_Sequence (Node));
2432 Write_Indent_Str ("end ");
2433 Write_Id (Defining_Identifier (Node));
2434 Write_Char (';');
2436 when N_Task_Body_Stub =>
2437 Write_Indent_Str_Sloc ("task body ");
2438 Write_Id (Defining_Identifier (Node));
2439 Write_Str_With_Col_Check (" is separate;");
2441 when N_Task_Definition =>
2442 Set_Debug_Sloc;
2443 Sprint_Indented_List (Visible_Declarations (Node));
2445 if Present (Private_Declarations (Node)) then
2446 Write_Indent_Str ("private");
2447 Sprint_Indented_List (Private_Declarations (Node));
2448 end if;
2450 Write_Indent_Str ("end ");
2452 when N_Task_Type_Declaration =>
2453 Write_Indent_Str_Sloc ("task type ");
2454 Write_Id (Defining_Identifier (Node));
2455 Write_Discr_Specs (Node);
2457 if Present (Task_Definition (Node)) then
2458 Write_Str (" is");
2459 Sprint_Node (Task_Definition (Node));
2460 Write_Id (Defining_Identifier (Node));
2461 end if;
2463 Write_Char (';');
2465 when N_Terminate_Alternative =>
2466 Sprint_Node_List (Pragmas_Before (Node));
2468 Write_Indent;
2470 if Present (Condition (Node)) then
2471 Write_Str_With_Col_Check ("when ");
2472 Sprint_Node (Condition (Node));
2473 Write_Str (" => ");
2474 end if;
2476 Write_Str_With_Col_Check_Sloc ("terminate;");
2477 Sprint_Node_List (Pragmas_After (Node));
2479 when N_Timed_Entry_Call =>
2480 Write_Indent_Str_Sloc ("select");
2481 Indent_Begin;
2482 Sprint_Node (Entry_Call_Alternative (Node));
2483 Indent_End;
2484 Write_Indent_Str ("or");
2485 Indent_Begin;
2486 Sprint_Node (Delay_Alternative (Node));
2487 Indent_End;
2488 Write_Indent_Str ("end select;");
2490 when N_Triggering_Alternative =>
2491 Sprint_Node_List (Pragmas_Before (Node));
2492 Sprint_Node_Sloc (Triggering_Statement (Node));
2493 Sprint_Node_List (Statements (Node));
2495 when N_Type_Conversion =>
2496 Set_Debug_Sloc;
2497 Sprint_Node (Subtype_Mark (Node));
2498 Col_Check (4);
2500 if Conversion_OK (Node) then
2501 Write_Char ('?');
2502 end if;
2504 if Float_Truncate (Node) then
2505 Write_Char ('^');
2506 end if;
2508 if Rounded_Result (Node) then
2509 Write_Char ('@');
2510 end if;
2512 Write_Char ('(');
2513 Sprint_Node (Expression (Node));
2514 Write_Char (')');
2516 when N_Unchecked_Expression =>
2517 Col_Check (10);
2518 Write_Str ("`(");
2519 Sprint_Node_Sloc (Expression (Node));
2520 Write_Char (')');
2522 when N_Unchecked_Type_Conversion =>
2523 Sprint_Node (Subtype_Mark (Node));
2524 Write_Char ('!');
2525 Write_Str_With_Col_Check ("(");
2526 Sprint_Node_Sloc (Expression (Node));
2527 Write_Char (')');
2529 when N_Unconstrained_Array_Definition =>
2530 Write_Str_With_Col_Check_Sloc ("array (");
2532 declare
2533 Node1 : Node_Id;
2535 begin
2536 Node1 := First (Subtype_Marks (Node));
2537 loop
2538 Sprint_Node (Node1);
2539 Write_Str_With_Col_Check (" range <>");
2540 Next (Node1);
2541 exit when Node1 = Empty;
2542 Write_Str (", ");
2543 end loop;
2544 end;
2546 Write_Str (") of ");
2547 Sprint_Node (Component_Definition (Node));
2549 when N_Unused_At_Start | N_Unused_At_End =>
2550 Write_Indent_Str ("***** Error, unused node encountered *****");
2551 Write_Eol;
2553 when N_Use_Package_Clause =>
2554 Write_Indent_Str_Sloc ("use ");
2555 Sprint_Comma_List (Names (Node));
2556 Write_Char (';');
2558 when N_Use_Type_Clause =>
2559 Write_Indent_Str_Sloc ("use type ");
2560 Sprint_Comma_List (Subtype_Marks (Node));
2561 Write_Char (';');
2563 when N_Validate_Unchecked_Conversion =>
2564 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2565 Sprint_Node (Source_Type (Node));
2566 Write_Str (", ");
2567 Sprint_Node (Target_Type (Node));
2568 Write_Str (");");
2570 when N_Variant =>
2571 Write_Indent_Str_Sloc ("when ");
2572 Sprint_Bar_List (Discrete_Choices (Node));
2573 Write_Str (" => ");
2574 Sprint_Node (Component_List (Node));
2576 when N_Variant_Part =>
2577 Indent_Begin;
2578 Write_Indent_Str_Sloc ("case ");
2579 Sprint_Node (Name (Node));
2580 Write_Str (" is ");
2581 Sprint_Indented_List (Variants (Node));
2582 Write_Indent_Str ("end case");
2583 Indent_End;
2585 when N_With_Clause =>
2587 -- Special test, if we are dumping the original tree only,
2588 -- then we want to eliminate the bogus with clauses that
2589 -- correspond to the non-existent children of Text_IO.
2591 if Dump_Original_Only
2592 and then Is_Text_IO_Kludge_Unit (Name (Node))
2593 then
2594 null;
2596 -- Normal case, output the with clause
2598 else
2599 if First_Name (Node) or else not Dump_Original_Only then
2601 -- Ada 0Y (AI-50217): Print limited with_clauses
2603 if Private_Present (Node) and Limited_Present (Node) then
2604 Write_Indent_Str ("limited private with ");
2606 elsif Private_Present (Node) then
2607 Write_Indent_Str ("private with ");
2609 elsif Limited_Present (Node) then
2610 Write_Indent_Str ("limited with ");
2612 else
2613 Write_Indent_Str ("with ");
2614 end if;
2616 else
2617 Write_Str (", ");
2618 end if;
2620 Sprint_Node_Sloc (Name (Node));
2622 if Last_Name (Node) or else not Dump_Original_Only then
2623 Write_Char (';');
2624 end if;
2625 end if;
2627 when N_With_Type_Clause =>
2628 Write_Indent_Str ("with type ");
2629 Sprint_Node_Sloc (Name (Node));
2631 if Tagged_Present (Node) then
2632 Write_Str (" is tagged;");
2633 else
2634 Write_Str (" is access;");
2635 end if;
2637 end case;
2639 if Nkind (Node) in N_Subexpr
2640 and then Do_Range_Check (Node)
2641 then
2642 Write_Str ("}");
2643 end if;
2645 for J in 1 .. Paren_Count (Node) loop
2646 Write_Char (')');
2647 end loop;
2649 pragma Assert (No (Debug_Node));
2650 Debug_Node := Save_Debug_Node;
2651 end Sprint_Node_Actual;
2653 ----------------------
2654 -- Sprint_Node_List --
2655 ----------------------
2657 procedure Sprint_Node_List (List : List_Id) is
2658 Node : Node_Id;
2660 begin
2661 if Is_Non_Empty_List (List) then
2662 Node := First (List);
2664 loop
2665 Sprint_Node (Node);
2666 Next (Node);
2667 exit when Node = Empty;
2668 end loop;
2669 end if;
2670 end Sprint_Node_List;
2672 ----------------------
2673 -- Sprint_Node_Sloc --
2674 ----------------------
2676 procedure Sprint_Node_Sloc (Node : Node_Id) is
2677 begin
2678 Sprint_Node (Node);
2680 if Present (Debug_Node) then
2681 Set_Sloc (Debug_Node, Sloc (Node));
2682 Debug_Node := Empty;
2683 end if;
2684 end Sprint_Node_Sloc;
2686 ---------------------
2687 -- Sprint_Opt_Node --
2688 ---------------------
2690 procedure Sprint_Opt_Node (Node : Node_Id) is
2691 begin
2692 if Present (Node) then
2693 Write_Char (' ');
2694 Sprint_Node (Node);
2695 end if;
2696 end Sprint_Opt_Node;
2698 --------------------------
2699 -- Sprint_Opt_Node_List --
2700 --------------------------
2702 procedure Sprint_Opt_Node_List (List : List_Id) is
2703 begin
2704 if Present (List) then
2705 Sprint_Node_List (List);
2706 end if;
2707 end Sprint_Opt_Node_List;
2709 ---------------------------------
2710 -- Sprint_Opt_Paren_Comma_List --
2711 ---------------------------------
2713 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2714 begin
2715 if Is_Non_Empty_List (List) then
2716 Write_Char (' ');
2717 Sprint_Paren_Comma_List (List);
2718 end if;
2719 end Sprint_Opt_Paren_Comma_List;
2721 -----------------------------
2722 -- Sprint_Paren_Comma_List --
2723 -----------------------------
2725 procedure Sprint_Paren_Comma_List (List : List_Id) is
2726 N : Node_Id;
2727 Node_Exists : Boolean := False;
2729 begin
2731 if Is_Non_Empty_List (List) then
2733 if Dump_Original_Only then
2734 N := First (List);
2736 while Present (N) loop
2738 if not Is_Rewrite_Insertion (N) then
2739 Node_Exists := True;
2740 exit;
2741 end if;
2743 Next (N);
2744 end loop;
2746 if not Node_Exists then
2747 return;
2748 end if;
2749 end if;
2751 Write_Str_With_Col_Check ("(");
2752 Sprint_Comma_List (List);
2753 Write_Char (')');
2754 end if;
2755 end Sprint_Paren_Comma_List;
2757 ----------------------
2758 -- Sprint_Right_Opnd --
2759 ----------------------
2761 procedure Sprint_Right_Opnd (N : Node_Id) is
2762 Opnd : constant Node_Id := Right_Opnd (N);
2764 begin
2765 if Paren_Count (Opnd) /= 0
2766 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2767 then
2768 Sprint_Node (Opnd);
2770 else
2771 Write_Char ('(');
2772 Sprint_Node (Opnd);
2773 Write_Char (')');
2774 end if;
2775 end Sprint_Right_Opnd;
2777 ---------------------
2778 -- Write_Char_Sloc --
2779 ---------------------
2781 procedure Write_Char_Sloc (C : Character) is
2782 begin
2783 if Debug_Generated_Code and then C /= ' ' then
2784 Set_Debug_Sloc;
2785 end if;
2787 Write_Char (C);
2788 end Write_Char_Sloc;
2790 --------------------------------
2791 -- Write_Condition_And_Reason --
2792 --------------------------------
2794 procedure Write_Condition_And_Reason (Node : Node_Id) is
2795 Image : constant String := RT_Exception_Code'Image
2796 (RT_Exception_Code'Val
2797 (UI_To_Int (Reason (Node))));
2799 begin
2800 if Present (Condition (Node)) then
2801 Write_Str_With_Col_Check (" when ");
2802 Sprint_Node (Condition (Node));
2803 end if;
2805 Write_Str (" """);
2807 for J in 4 .. Image'Last loop
2808 if Image (J) = '_' then
2809 Write_Char (' ');
2810 else
2811 Write_Char (Fold_Lower (Image (J)));
2812 end if;
2813 end loop;
2815 Write_Str ("""]");
2816 end Write_Condition_And_Reason;
2818 ------------------------
2819 -- Write_Discr_Specs --
2820 ------------------------
2822 procedure Write_Discr_Specs (N : Node_Id) is
2823 Specs : List_Id;
2824 Spec : Node_Id;
2826 begin
2827 Specs := Discriminant_Specifications (N);
2829 if Present (Specs) then
2830 Write_Str_With_Col_Check (" (");
2831 Spec := First (Specs);
2833 loop
2834 Sprint_Node (Spec);
2835 Next (Spec);
2836 exit when Spec = Empty;
2838 -- Add semicolon, unless we are printing original tree and the
2839 -- next specification is part of a list (but not the first
2840 -- element of that list)
2842 if not Dump_Original_Only or else not Prev_Ids (Spec) then
2843 Write_Str ("; ");
2844 end if;
2845 end loop;
2847 Write_Char (')');
2848 end if;
2849 end Write_Discr_Specs;
2851 -----------------
2852 -- Write_Ekind --
2853 -----------------
2855 procedure Write_Ekind (E : Entity_Id) is
2856 S : constant String := Entity_Kind'Image (Ekind (E));
2858 begin
2859 Name_Len := S'Length;
2860 Name_Buffer (1 .. Name_Len) := S;
2861 Set_Casing (Mixed_Case);
2862 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2863 end Write_Ekind;
2865 --------------
2866 -- Write_Id --
2867 --------------
2869 procedure Write_Id (N : Node_Id) is
2870 begin
2871 -- Case of a defining identifier
2873 if Nkind (N) = N_Defining_Identifier then
2875 -- If defining identifier has an interface name (and no
2876 -- address clause), then we output the interface name.
2878 if (Is_Imported (N) or else Is_Exported (N))
2879 and then Present (Interface_Name (N))
2880 and then No (Address_Clause (N))
2881 then
2882 String_To_Name_Buffer (Strval (Interface_Name (N)));
2883 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2885 -- If no interface name (or inactive because there was
2886 -- an address clause), then just output the Chars name.
2888 else
2889 Write_Name_With_Col_Check (Chars (N));
2890 end if;
2892 -- Case of selector of an expanded name where the expanded name
2893 -- has an associated entity, output this entity.
2895 elsif Nkind (Parent (N)) = N_Expanded_Name
2896 and then Selector_Name (Parent (N)) = N
2897 and then Present (Entity (Parent (N)))
2898 then
2899 Write_Id (Entity (Parent (N)));
2901 -- For any other node with an associated entity, output it
2903 elsif Nkind (N) in N_Has_Entity
2904 and then Present (Entity_Or_Associated_Node (N))
2905 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2906 then
2907 Write_Id (Entity (N));
2909 -- All other cases, we just print the Chars field
2911 else
2912 Write_Name_With_Col_Check (Chars (N));
2913 end if;
2914 end Write_Id;
2916 -----------------------
2917 -- Write_Identifiers --
2918 -----------------------
2920 function Write_Identifiers (Node : Node_Id) return Boolean is
2921 begin
2922 Sprint_Node (Defining_Identifier (Node));
2924 -- The remainder of the declaration must be printed unless we are
2925 -- printing the original tree and this is not the last identifier
2927 return
2928 not Dump_Original_Only or else not More_Ids (Node);
2930 end Write_Identifiers;
2932 ------------------------
2933 -- Write_Implicit_Def --
2934 ------------------------
2936 procedure Write_Implicit_Def (E : Entity_Id) is
2937 Ind : Node_Id;
2939 begin
2940 case Ekind (E) is
2941 when E_Array_Subtype =>
2942 Write_Str_With_Col_Check ("subtype ");
2943 Write_Id (E);
2944 Write_Str_With_Col_Check (" is ");
2945 Write_Id (Base_Type (E));
2946 Write_Str_With_Col_Check (" (");
2948 Ind := First_Index (E);
2950 while Present (Ind) loop
2951 Sprint_Node (Ind);
2952 Next_Index (Ind);
2954 if Present (Ind) then
2955 Write_Str (", ");
2956 end if;
2957 end loop;
2959 Write_Str (");");
2961 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2962 Write_Str_With_Col_Check ("subtype ");
2963 Write_Id (E);
2964 Write_Str (" is ");
2965 Write_Id (Etype (E));
2966 Write_Str_With_Col_Check (" range ");
2967 Sprint_Node (Scalar_Range (E));
2968 Write_Str (";");
2970 when others =>
2971 Write_Str_With_Col_Check ("type ");
2972 Write_Id (E);
2973 Write_Str_With_Col_Check (" is <");
2974 Write_Ekind (E);
2975 Write_Str (">;");
2976 end case;
2978 end Write_Implicit_Def;
2980 ------------------
2981 -- Write_Indent --
2982 ------------------
2984 procedure Write_Indent is
2985 begin
2986 if Indent_Annull_Flag then
2987 Indent_Annull_Flag := False;
2988 else
2989 Write_Eol;
2991 for J in 1 .. Indent loop
2992 Write_Char (' ');
2993 end loop;
2994 end if;
2995 end Write_Indent;
2997 ------------------------------
2998 -- Write_Indent_Identifiers --
2999 ------------------------------
3001 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3002 begin
3003 -- We need to start a new line for every node, except in the case
3004 -- where we are printing the original tree and this is not the first
3005 -- defining identifier in the list.
3007 if not Dump_Original_Only or else not Prev_Ids (Node) then
3008 Write_Indent;
3010 -- If printing original tree and this is not the first defining
3011 -- identifier in the list, then the previous call to this procedure
3012 -- printed only the name, and we add a comma to separate the names.
3014 else
3015 Write_Str (", ");
3016 end if;
3018 Sprint_Node (Defining_Identifier (Node));
3020 -- The remainder of the declaration must be printed unless we are
3021 -- printing the original tree and this is not the last identifier
3023 return
3024 not Dump_Original_Only or else not More_Ids (Node);
3026 end Write_Indent_Identifiers;
3028 -----------------------------------
3029 -- Write_Indent_Identifiers_Sloc --
3030 -----------------------------------
3032 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3033 begin
3034 -- We need to start a new line for every node, except in the case
3035 -- where we are printing the original tree and this is not the first
3036 -- defining identifier in the list.
3038 if not Dump_Original_Only or else not Prev_Ids (Node) then
3039 Write_Indent;
3041 -- If printing original tree and this is not the first defining
3042 -- identifier in the list, then the previous call to this procedure
3043 -- printed only the name, and we add a comma to separate the names.
3045 else
3046 Write_Str (", ");
3047 end if;
3049 Set_Debug_Sloc;
3050 Sprint_Node (Defining_Identifier (Node));
3052 -- The remainder of the declaration must be printed unless we are
3053 -- printing the original tree and this is not the last identifier
3055 return
3056 not Dump_Original_Only or else not More_Ids (Node);
3058 end Write_Indent_Identifiers_Sloc;
3060 ----------------------
3061 -- Write_Indent_Str --
3062 ----------------------
3064 procedure Write_Indent_Str (S : String) is
3065 begin
3066 Write_Indent;
3067 Write_Str (S);
3068 end Write_Indent_Str;
3070 ---------------------------
3071 -- Write_Indent_Str_Sloc --
3072 ---------------------------
3074 procedure Write_Indent_Str_Sloc (S : String) is
3075 begin
3076 Write_Indent;
3077 Write_Str_Sloc (S);
3078 end Write_Indent_Str_Sloc;
3080 -------------------------------
3081 -- Write_Name_With_Col_Check --
3082 -------------------------------
3084 procedure Write_Name_With_Col_Check (N : Name_Id) is
3085 J : Natural;
3087 begin
3088 Get_Name_String (N);
3090 -- Deal with -gnatI which replaces digits in an internal
3091 -- name by three dots (e.g. R7b becomes R...b).
3093 if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3095 J := 2;
3096 while J < Name_Len loop
3097 exit when Name_Buffer (J) not in 'A' .. 'Z';
3098 J := J + 1;
3099 end loop;
3101 if Name_Buffer (J) in '0' .. '9' then
3102 Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3103 Write_Str ("...");
3105 while J <= Name_Len loop
3106 if Name_Buffer (J) not in '0' .. '9' then
3107 Write_Str (Name_Buffer (J .. Name_Len));
3108 exit;
3110 else
3111 J := J + 1;
3112 end if;
3113 end loop;
3115 return;
3116 end if;
3117 end if;
3119 -- Fall through for normal case
3121 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3122 end Write_Name_With_Col_Check;
3124 ------------------------------------
3125 -- Write_Name_With_Col_Check_Sloc --
3126 ------------------------------------
3128 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3129 begin
3130 Get_Name_String (N);
3131 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3132 end Write_Name_With_Col_Check_Sloc;
3134 --------------------
3135 -- Write_Operator --
3136 --------------------
3138 procedure Write_Operator (N : Node_Id; S : String) is
3139 F : Natural := S'First;
3140 T : Natural := S'Last;
3142 begin
3143 -- If no overflow check, just write string out, and we are done
3145 if not Do_Overflow_Check (N) then
3146 Write_Str_Sloc (S);
3148 -- If overflow check, we want to surround the operator with curly
3149 -- brackets, but not include spaces within the brackets.
3151 else
3152 if S (F) = ' ' then
3153 Write_Char (' ');
3154 F := F + 1;
3155 end if;
3157 if S (T) = ' ' then
3158 T := T - 1;
3159 end if;
3161 Write_Char ('{');
3162 Write_Str_Sloc (S (F .. T));
3163 Write_Char ('}');
3165 if S (S'Last) = ' ' then
3166 Write_Char (' ');
3167 end if;
3168 end if;
3169 end Write_Operator;
3171 -----------------------
3172 -- Write_Param_Specs --
3173 -----------------------
3175 procedure Write_Param_Specs (N : Node_Id) is
3176 Specs : List_Id;
3177 Spec : Node_Id;
3178 Formal : Node_Id;
3180 begin
3181 Specs := Parameter_Specifications (N);
3183 if Is_Non_Empty_List (Specs) then
3184 Write_Str_With_Col_Check (" (");
3185 Spec := First (Specs);
3187 loop
3188 Sprint_Node (Spec);
3189 Formal := Defining_Identifier (Spec);
3190 Next (Spec);
3191 exit when Spec = Empty;
3193 -- Add semicolon, unless we are printing original tree and the
3194 -- next specification is part of a list (but not the first
3195 -- element of that list)
3197 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3198 Write_Str ("; ");
3199 end if;
3200 end loop;
3202 -- Write out any extra formals
3204 while Present (Extra_Formal (Formal)) loop
3205 Formal := Extra_Formal (Formal);
3206 Write_Str ("; ");
3207 Write_Name_With_Col_Check (Chars (Formal));
3208 Write_Str (" : ");
3209 Write_Name_With_Col_Check (Chars (Etype (Formal)));
3210 end loop;
3212 Write_Char (')');
3213 end if;
3214 end Write_Param_Specs;
3216 --------------------------
3217 -- Write_Rewrite_Str --
3218 --------------------------
3220 procedure Write_Rewrite_Str (S : String) is
3221 begin
3222 if not Dump_Generated_Only then
3223 if S'Length = 3 and then S = ">>>" then
3224 Write_Str (">>>");
3225 else
3226 Write_Str_With_Col_Check (S);
3227 end if;
3228 end if;
3229 end Write_Rewrite_Str;
3231 --------------------
3232 -- Write_Str_Sloc --
3233 --------------------
3235 procedure Write_Str_Sloc (S : String) is
3236 begin
3237 for J in S'Range loop
3238 Write_Char_Sloc (S (J));
3239 end loop;
3240 end Write_Str_Sloc;
3242 ------------------------------
3243 -- Write_Str_With_Col_Check --
3244 ------------------------------
3246 procedure Write_Str_With_Col_Check (S : String) is
3247 begin
3248 if Int (S'Last) + Column > Line_Limit then
3249 Write_Indent_Str (" ");
3251 if S (1) = ' ' then
3252 Write_Str (S (2 .. S'Length));
3253 else
3254 Write_Str (S);
3255 end if;
3257 else
3258 Write_Str (S);
3259 end if;
3260 end Write_Str_With_Col_Check;
3262 -----------------------------------
3263 -- Write_Str_With_Col_Check_Sloc --
3264 -----------------------------------
3266 procedure Write_Str_With_Col_Check_Sloc (S : String) is
3267 begin
3268 if Int (S'Last) + Column > Line_Limit then
3269 Write_Indent_Str (" ");
3271 if S (1) = ' ' then
3272 Write_Str_Sloc (S (2 .. S'Length));
3273 else
3274 Write_Str_Sloc (S);
3275 end if;
3277 else
3278 Write_Str_Sloc (S);
3279 end if;
3280 end Write_Str_With_Col_Check_Sloc;
3282 ------------------------------------
3283 -- Write_Uint_With_Col_Check_Sloc --
3284 ------------------------------------
3286 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3287 begin
3288 Col_Check (UI_Decimal_Digits_Hi (U));
3289 Set_Debug_Sloc;
3290 UI_Write (U, Format);
3291 end Write_Uint_With_Col_Check_Sloc;
3293 -------------------------------------
3294 -- Write_Ureal_With_Col_Check_Sloc --
3295 -------------------------------------
3297 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3298 D : constant Uint := Denominator (U);
3299 N : constant Uint := Numerator (U);
3301 begin
3302 Col_Check
3303 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3304 Set_Debug_Sloc;
3305 UR_Write (U);
3306 end Write_Ureal_With_Col_Check_Sloc;
3308 end Sprint;