* gcc-interface/Makefile.in (LIBGNAT_TARGET_PAIRS): Simplify test for
[official-gcc.git] / gcc / ada / sprint.adb
blobe73d204d758633a34b001319d11e5d180b6259c0
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-2009, 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 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 with Atree; use Atree;
27 with Casing; use Casing;
28 with Csets; use Csets;
29 with Debug; use Debug;
30 with Einfo; use Einfo;
31 with Fname; use Fname;
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 Sem_Util; use Sem_Util;
39 with Sinfo; use Sinfo;
40 with Sinput; use Sinput;
41 with Sinput.D; use Sinput.D;
42 with Snames; use Snames;
43 with Stand; use Stand;
44 with Stringt; use Stringt;
45 with Uintp; use Uintp;
46 with Uname; use Uname;
47 with Urealp; use Urealp;
49 package body Sprint is
50 Current_Source_File : Source_File_Index;
51 -- Index of source file whose generated code is being dumped
53 Dump_Node : Node_Id := Empty;
54 -- This is set to the current node, used for printing line numbers. In
55 -- Debug_Generated_Code mode, Dump_Node is set to the current node
56 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
57 -- value. The call clears it back to Empty.
59 Debug_Sloc : Source_Ptr;
60 -- Sloc of first byte of line currently being written if we are
61 -- generating a source debug file.
63 Dump_Original_Only : Boolean;
64 -- Set True if the -gnatdo (dump original tree) flag is set
66 Dump_Generated_Only : Boolean;
67 -- Set True if the -gnatG (dump generated tree) debug flag is set
68 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
70 Dump_Freeze_Null : Boolean;
71 -- Set True if freeze nodes and non-source null statements output
73 Freeze_Indent : Int := 0;
74 -- Keep track of freeze indent level (controls output of blank lines before
75 -- procedures within expression freeze actions). Relevant only if we are
76 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
77 -- output these blank lines in any case.
79 Indent : Int := 0;
80 -- Number of columns for current line output indentation
82 Indent_Annull_Flag : Boolean := False;
83 -- Set True if subsequent Write_Indent call to be ignored, gets reset
84 -- by this call, so it is only active to suppress a single indent call.
86 Last_Line_Printed : Physical_Line_Number;
87 -- This keeps track of the physical line number of the last source line
88 -- that has been output. The value is only valid in Dump_Source_Text mode.
90 -------------------------------
91 -- Operator Precedence Table --
92 -------------------------------
94 -- This table is used to decide whether a subexpression needs to be
95 -- parenthesized. The rule is that if an operand of an operator (which
96 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
97 -- with a lower precedence than the operator (or equal precedence if
98 -- appearing as the right operand), then parentheses are required.
100 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
101 (N_Op_And => 1,
102 N_Op_Or => 1,
103 N_Op_Xor => 1,
104 N_And_Then => 1,
105 N_Or_Else => 1,
107 N_In => 2,
108 N_Not_In => 2,
109 N_Op_Eq => 2,
110 N_Op_Ge => 2,
111 N_Op_Gt => 2,
112 N_Op_Le => 2,
113 N_Op_Lt => 2,
114 N_Op_Ne => 2,
116 N_Op_Add => 3,
117 N_Op_Concat => 3,
118 N_Op_Subtract => 3,
119 N_Op_Plus => 3,
120 N_Op_Minus => 3,
122 N_Op_Divide => 4,
123 N_Op_Mod => 4,
124 N_Op_Rem => 4,
125 N_Op_Multiply => 4,
127 N_Op_Expon => 5,
128 N_Op_Abs => 5,
129 N_Op_Not => 5,
131 others => 6);
133 procedure Sprint_Left_Opnd (N : Node_Id);
134 -- Print left operand of operator, parenthesizing if necessary
136 procedure Sprint_Right_Opnd (N : Node_Id);
137 -- Print right operand of operator, parenthesizing if necessary
139 -----------------------
140 -- Local Subprograms --
141 -----------------------
143 procedure Col_Check (N : Nat);
144 -- Check that at least N characters remain on current line, and if not,
145 -- then start an extra line with two characters extra indentation for
146 -- continuing text on the next line.
148 procedure Extra_Blank_Line;
149 -- In some situations we write extra blank lines to separate the generated
150 -- code to make it more readable. However, these extra blank lines are not
151 -- generated in Dump_Source_Text mode, since there the source text lines
152 -- output with preceding blank lines are quite sufficient as separators.
153 -- This procedure writes a blank line if Dump_Source_Text is False.
155 procedure Indent_Annull;
156 -- Causes following call to Write_Indent to be ignored. This is used when
157 -- a higher level node wants to stop a lower level node from starting a
158 -- new line, when it would otherwise be inclined to do so (e.g. the case
159 -- of an accept statement called from an accept alternative with a guard)
161 procedure Indent_Begin;
162 -- Increase indentation level
164 procedure Indent_End;
165 -- Decrease indentation level
167 procedure Print_Debug_Line (S : String);
168 -- Used to print output lines in Debug_Generated_Code mode (this is used
169 -- as the argument for a call to Set_Special_Output in package Output).
171 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
172 -- Given a divide, multiplication or division node, check the flags
173 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
174 -- appropriate special syntax characters (# and @).
176 procedure Set_Debug_Sloc;
177 -- If Dump_Node is non-empty, this routine sets the appropriate value
178 -- in its Sloc field, from the current location in the debug source file
179 -- that is currently being written.
181 procedure Sprint_And_List (List : List_Id);
182 -- Print the given list with items separated by vertical "and"
184 procedure Sprint_Bar_List (List : List_Id);
185 -- Print the given list with items separated by vertical bars
187 procedure Sprint_End_Label
188 (Node : Node_Id;
189 Default : Node_Id);
190 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
191 -- If there is not end label, use the defining identifier of the enclosing
192 -- construct. If the end label is present, treat it as a reference to the
193 -- defining entity of the construct: this guarantees that it carries the
194 -- proper sloc information for debugging purposes.
196 procedure Sprint_Node_Actual (Node : Node_Id);
197 -- This routine prints its node argument. It is a lower level routine than
198 -- Sprint_Node, in that it does not bother about rewritten trees.
200 procedure Sprint_Node_Sloc (Node : Node_Id);
201 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
202 -- sets the Sloc of the current debug node to be a copy of the Sloc
203 -- of the sprinted node Node. Note that this is done after printing
204 -- Node, so that the Sloc is the proper updated value for the debug file.
206 procedure Update_Itype (Node : Node_Id);
207 -- Update the Sloc of an itype that is not attached to the tree, when
208 -- debugging expanded code. This routine is called from nodes whose
209 -- type can be an Itype, such as defining_identifiers that may be of
210 -- an anonymous access type, or ranges in slices.
212 procedure Write_Char_Sloc (C : Character);
213 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
214 -- called to ensure that the current node has a proper Sloc set.
216 procedure Write_Condition_And_Reason (Node : Node_Id);
217 -- Write Condition and Reason codes of Raise_xxx_Error node
219 procedure Write_Corresponding_Source (S : String);
220 -- If S is a string with a single keyword (possibly followed by a space),
221 -- and if the next non-comment non-blank source line matches this keyword,
222 -- then output all source lines up to this matching line.
224 procedure Write_Discr_Specs (N : Node_Id);
225 -- Output discriminant specification for node, which is any of the type
226 -- declarations that can have discriminants.
228 procedure Write_Ekind (E : Entity_Id);
229 -- Write the String corresponding to the Ekind without "E_"
231 procedure Write_Id (N : Node_Id);
232 -- N is a node with a Chars field. This procedure writes the name that
233 -- will be used in the generated code associated with the name. For a
234 -- node with no associated entity, this is simply the Chars field. For
235 -- the case where there is an entity associated with the node, we print
236 -- the name associated with the entity (since it may have been encoded).
237 -- One other special case is that an entity has an active external name
238 -- (i.e. an external name present with no address clause), then this
239 -- external name is output. This procedure also deals with outputting
240 -- declarations of referenced itypes, if not output earlier.
242 function Write_Identifiers (Node : Node_Id) return Boolean;
243 -- Handle node where the grammar has a list of defining identifiers, but
244 -- the tree has a separate declaration for each identifier. Handles the
245 -- printing of the defining identifier, and returns True if the type and
246 -- initialization information is to be printed, False if it is to be
247 -- skipped (the latter case happens when printing defining identifiers
248 -- other than the first in the original tree output case).
250 procedure Write_Implicit_Def (E : Entity_Id);
251 pragma Warnings (Off, Write_Implicit_Def);
252 -- Write the definition of the implicit type E according to its Ekind
253 -- For now a debugging procedure, but might be used in the future.
255 procedure Write_Indent;
256 -- Start a new line and write indentation spacing
258 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
259 -- Like Write_Identifiers except that each new printed declaration
260 -- is at the start of a new line.
262 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
263 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
264 -- mode, the Sloc of the current debug node is set to point to the
265 -- first output identifier.
267 procedure Write_Indent_Str (S : String);
268 -- Start a new line and write indent spacing followed by given string
270 procedure Write_Indent_Str_Sloc (S : String);
271 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
272 -- the Sloc of the current node is set to the first non-blank character
273 -- in the string S.
275 procedure Write_Itype (Typ : Entity_Id);
276 -- If Typ is an Itype that has not been written yet, write it. If Typ is
277 -- any other kind of entity or tree node, the call is ignored.
279 procedure Write_Name_With_Col_Check (N : Name_Id);
280 -- Write name (using Write_Name) with initial column check, and possible
281 -- initial Write_Indent (to get new line) if current line is too full.
283 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
284 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
285 -- mode, sets Sloc of current debug node to first character of name.
287 procedure Write_Operator (N : Node_Id; S : String);
288 -- Like Write_Str_Sloc, used for operators, encloses the string in
289 -- characters {} if the Do_Overflow flag is set on the node N.
291 procedure Write_Param_Specs (N : Node_Id);
292 -- Output parameter specifications for node (which is either a function
293 -- or procedure specification with a Parameter_Specifications field)
295 procedure Write_Rewrite_Str (S : String);
296 -- Writes out a string (typically containing <<< or >>>}) for a node
297 -- created by rewriting the tree. Suppressed if we are outputting the
298 -- generated code only, since in this case we don't specially mark nodes
299 -- created by rewriting).
301 procedure Write_Source_Line (L : Physical_Line_Number);
302 -- If writing of interspersed source lines is enabled, then write the given
303 -- line from the source file, preceded by Eol, then an extra blank line if
304 -- the line has at least one blank, is not a comment and is not line one,
305 -- then "--" and the line number followed by period followed by text of the
306 -- source line (without terminating Eol). If interspersed source line
307 -- output not enabled, then the call has no effect.
309 procedure Write_Source_Lines (L : Physical_Line_Number);
310 -- If writing of interspersed source lines is enabled, then writes source
311 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
312 -- interspersed source line output not enabled, then call has no effect.
314 procedure Write_Str_Sloc (S : String);
315 -- Like Write_Str, but sets debug Sloc of current debug node to first
316 -- non-blank character if a current debug node is active.
318 procedure Write_Str_With_Col_Check (S : String);
319 -- Write string (using Write_Str) with initial column check, and possible
320 -- initial Write_Indent (to get new line) if current line is too full.
322 procedure Write_Str_With_Col_Check_Sloc (S : String);
323 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
324 -- node to first non-blank character if a current debug node is active.
326 procedure Write_Subprogram_Name (N : Node_Id);
327 -- N is the Name field of a function call or procedure statement call.
328 -- The effect of the call is to output the name, preceded by a $ if the
329 -- call is identified as an implicit call to a run time routine.
331 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format);
332 -- Write Uint (using UI_Write) with initial column check, and possible
333 -- initial Write_Indent (to get new line) if current line is too full.
334 -- The format parameter determines the output format (see UI_Write).
336 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
337 -- Write Uint (using UI_Write) with initial column check, and possible
338 -- initial Write_Indent (to get new line) if current line is too full.
339 -- The format parameter determines the output format (see UI_Write).
340 -- In addition, in Debug_Generated_Code mode, sets the current node
341 -- Sloc to the first character of the output value.
343 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
344 -- Write Ureal (using same output format as UR_Write) with column checks
345 -- and a possible initial Write_Indent (to get new line) if current line
346 -- is too full. In addition, in Debug_Generated_Code mode, sets the
347 -- current node Sloc to the first character of the output value.
349 ---------------
350 -- Col_Check --
351 ---------------
353 procedure Col_Check (N : Nat) is
354 begin
355 if N + Column > Sprint_Line_Limit then
356 Write_Indent_Str (" ");
357 end if;
358 end Col_Check;
360 ----------------------
361 -- Extra_Blank_Line --
362 ----------------------
364 procedure Extra_Blank_Line is
365 begin
366 if not Dump_Source_Text then
367 Write_Indent;
368 end if;
369 end Extra_Blank_Line;
371 -------------------
372 -- Indent_Annull --
373 -------------------
375 procedure Indent_Annull is
376 begin
377 Indent_Annull_Flag := True;
378 end Indent_Annull;
380 ------------------
381 -- Indent_Begin --
382 ------------------
384 procedure Indent_Begin is
385 begin
386 Indent := Indent + 3;
387 end Indent_Begin;
389 ----------------
390 -- Indent_End --
391 ----------------
393 procedure Indent_End is
394 begin
395 Indent := Indent - 3;
396 end Indent_End;
398 --------
399 -- pg --
400 --------
402 procedure pg (Arg : Union_Id) is
403 begin
404 Dump_Generated_Only := True;
405 Dump_Original_Only := False;
406 Current_Source_File := No_Source_File;
408 if Arg in List_Range then
409 Sprint_Node_List (List_Id (Arg));
411 elsif Arg in Node_Range then
412 Sprint_Node (Node_Id (Arg));
414 else
415 null;
416 end if;
418 Write_Eol;
419 end pg;
421 --------
422 -- po --
423 --------
425 procedure po (Arg : Union_Id) is
426 begin
427 Dump_Generated_Only := False;
428 Dump_Original_Only := True;
429 Current_Source_File := No_Source_File;
431 if Arg in List_Range then
432 Sprint_Node_List (List_Id (Arg));
434 elsif Arg in Node_Range then
435 Sprint_Node (Node_Id (Arg));
437 else
438 null;
439 end if;
441 Write_Eol;
442 end po;
444 ----------------------
445 -- Print_Debug_Line --
446 ----------------------
448 procedure Print_Debug_Line (S : String) is
449 begin
450 Write_Debug_Line (S, Debug_Sloc);
451 end Print_Debug_Line;
453 ---------------------------
454 -- Process_TFAI_RR_Flags --
455 ---------------------------
457 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
458 begin
459 if Treat_Fixed_As_Integer (Nod) then
460 Write_Char ('#');
461 end if;
463 if Rounded_Result (Nod) then
464 Write_Char ('@');
465 end if;
466 end Process_TFAI_RR_Flags;
468 --------
469 -- ps --
470 --------
472 procedure ps (Arg : Union_Id) is
473 begin
474 Dump_Generated_Only := False;
475 Dump_Original_Only := False;
476 Current_Source_File := No_Source_File;
478 if Arg in List_Range then
479 Sprint_Node_List (List_Id (Arg));
481 elsif Arg in Node_Range then
482 Sprint_Node (Node_Id (Arg));
484 else
485 null;
486 end if;
488 Write_Eol;
489 end ps;
491 --------------------
492 -- Set_Debug_Sloc --
493 --------------------
495 procedure Set_Debug_Sloc is
496 begin
497 if Debug_Generated_Code and then Present (Dump_Node) then
498 Set_Sloc (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1));
499 Dump_Node := Empty;
500 end if;
501 end Set_Debug_Sloc;
503 -----------------
504 -- Source_Dump --
505 -----------------
507 procedure Source_Dump is
509 procedure Underline;
510 -- Put underline under string we just printed
512 ---------------
513 -- Underline --
514 ---------------
516 procedure Underline is
517 Col : constant Int := Column;
519 begin
520 Write_Eol;
522 while Col > Column loop
523 Write_Char ('-');
524 end loop;
526 Write_Eol;
527 end Underline;
529 -- Start of processing for Tree_Dump
531 begin
532 Dump_Generated_Only := Debug_Flag_G or
533 Print_Generated_Code or
534 Debug_Generated_Code;
535 Dump_Original_Only := Debug_Flag_O;
536 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
538 -- Note that we turn off the tree dump flags immediately, before
539 -- starting the dump. This avoids generating two copies of the dump
540 -- if an abort occurs after printing the dump, and more importantly,
541 -- avoids an infinite loop if an abort occurs during the dump.
543 if Debug_Flag_Z then
544 Current_Source_File := No_Source_File;
545 Debug_Flag_Z := False;
546 Write_Eol;
547 Write_Eol;
548 Write_Str ("Source recreated from tree of Standard (spec)");
549 Underline;
550 Sprint_Node (Standard_Package_Node);
551 Write_Eol;
552 Write_Eol;
553 end if;
555 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
556 Debug_Flag_G := False;
557 Debug_Flag_O := False;
558 Debug_Flag_S := False;
560 -- Dump requested units
562 for U in Main_Unit .. Last_Unit loop
563 Current_Source_File := Source_Index (U);
565 -- Dump all units if -gnatdf set, otherwise we dump only
566 -- the source files that are in the extended main source.
568 if Debug_Flag_F
569 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
570 then
571 -- If we are generating debug files, setup to write them
573 if Debug_Generated_Code then
574 Set_Special_Output (Print_Debug_Line'Access);
575 Create_Debug_Source (Source_Index (U), Debug_Sloc);
576 Write_Source_Line (1);
577 Last_Line_Printed := 1;
578 Sprint_Node (Cunit (U));
579 Write_Source_Lines (Last_Source_Line (Current_Source_File));
580 Write_Eol;
581 Close_Debug_Source;
582 Set_Special_Output (null);
584 -- Normal output to standard output file
586 else
587 Write_Str ("Source recreated from tree for ");
588 Write_Unit_Name (Unit_Name (U));
589 Underline;
590 Write_Source_Line (1);
591 Last_Line_Printed := 1;
592 Sprint_Node (Cunit (U));
593 Write_Source_Lines (Last_Source_Line (Current_Source_File));
594 Write_Eol;
595 Write_Eol;
596 end if;
597 end if;
598 end loop;
599 end if;
600 end Source_Dump;
602 ---------------------
603 -- Sprint_And_List --
604 ---------------------
606 procedure Sprint_And_List (List : List_Id) is
607 Node : Node_Id;
608 begin
609 if Is_Non_Empty_List (List) then
610 Node := First (List);
611 loop
612 Sprint_Node (Node);
613 Next (Node);
614 exit when Node = Empty;
615 Write_Str (" and ");
616 end loop;
617 end if;
618 end Sprint_And_List;
620 ---------------------
621 -- Sprint_Bar_List --
622 ---------------------
624 procedure Sprint_Bar_List (List : List_Id) is
625 Node : Node_Id;
626 begin
627 if Is_Non_Empty_List (List) then
628 Node := First (List);
629 loop
630 Sprint_Node (Node);
631 Next (Node);
632 exit when Node = Empty;
633 Write_Str (" | ");
634 end loop;
635 end if;
636 end Sprint_Bar_List;
638 ----------------------
639 -- Sprint_End_Label --
640 ----------------------
642 procedure Sprint_End_Label
643 (Node : Node_Id;
644 Default : Node_Id)
646 begin
647 if Present (Node)
648 and then Present (End_Label (Node))
649 and then Is_Entity_Name (End_Label (Node))
650 then
651 Set_Entity (End_Label (Node), Default);
653 -- For a function whose name is an operator, use the qualified name
654 -- created for the defining entity.
656 if Nkind (End_Label (Node)) = N_Operator_Symbol then
657 Set_Chars (End_Label (Node), Chars (Default));
658 end if;
660 Sprint_Node (End_Label (Node));
661 else
662 Sprint_Node (Default);
663 end if;
664 end Sprint_End_Label;
666 -----------------------
667 -- Sprint_Comma_List --
668 -----------------------
670 procedure Sprint_Comma_List (List : List_Id) is
671 Node : Node_Id;
673 begin
674 if Is_Non_Empty_List (List) then
675 Node := First (List);
676 loop
677 Sprint_Node (Node);
678 Next (Node);
679 exit when Node = Empty;
681 if not Is_Rewrite_Insertion (Node)
682 or else not Dump_Original_Only
683 then
684 Write_Str (", ");
685 end if;
686 end loop;
687 end if;
688 end Sprint_Comma_List;
690 --------------------------
691 -- Sprint_Indented_List --
692 --------------------------
694 procedure Sprint_Indented_List (List : List_Id) is
695 begin
696 Indent_Begin;
697 Sprint_Node_List (List);
698 Indent_End;
699 end Sprint_Indented_List;
701 ---------------------
702 -- Sprint_Left_Opnd --
703 ---------------------
705 procedure Sprint_Left_Opnd (N : Node_Id) is
706 Opnd : constant Node_Id := Left_Opnd (N);
708 begin
709 if Paren_Count (Opnd) /= 0
710 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
711 then
712 Sprint_Node (Opnd);
714 else
715 Write_Char ('(');
716 Sprint_Node (Opnd);
717 Write_Char (')');
718 end if;
719 end Sprint_Left_Opnd;
721 -----------------
722 -- Sprint_Node --
723 -----------------
725 procedure Sprint_Node (Node : Node_Id) is
726 begin
727 if Is_Rewrite_Insertion (Node) then
728 if not Dump_Original_Only then
730 -- For special cases of nodes that always output <<< >>>
731 -- do not duplicate the output at this point.
733 if Nkind (Node) = N_Freeze_Entity
734 or else Nkind (Node) = N_Implicit_Label_Declaration
735 then
736 Sprint_Node_Actual (Node);
738 -- Normal case where <<< >>> may be required
740 else
741 Write_Rewrite_Str ("<<<");
742 Sprint_Node_Actual (Node);
743 Write_Rewrite_Str (">>>");
744 end if;
745 end if;
747 elsif Is_Rewrite_Substitution (Node) then
749 -- Case of dump generated only
751 if Dump_Generated_Only then
752 Sprint_Node_Actual (Node);
754 -- Case of dump original only
756 elsif Dump_Original_Only then
757 Sprint_Node_Actual (Original_Node (Node));
759 -- Case of both being dumped
761 else
762 Sprint_Node_Actual (Original_Node (Node));
763 Write_Rewrite_Str ("<<<");
764 Sprint_Node_Actual (Node);
765 Write_Rewrite_Str (">>>");
766 end if;
768 else
769 Sprint_Node_Actual (Node);
770 end if;
771 end Sprint_Node;
773 ------------------------
774 -- Sprint_Node_Actual --
775 ------------------------
777 procedure Sprint_Node_Actual (Node : Node_Id) is
778 Save_Dump_Node : constant Node_Id := Dump_Node;
780 begin
781 if Node = Empty then
782 return;
783 end if;
785 for J in 1 .. Paren_Count (Node) loop
786 Write_Str_With_Col_Check ("(");
787 end loop;
789 -- Setup current dump node
791 Dump_Node := Node;
793 if Nkind (Node) in N_Subexpr
794 and then Do_Range_Check (Node)
795 then
796 Write_Str_With_Col_Check ("{");
797 end if;
799 -- Select print circuit based on node kind
801 case Nkind (Node) is
803 when N_Abort_Statement =>
804 Write_Indent_Str_Sloc ("abort ");
805 Sprint_Comma_List (Names (Node));
806 Write_Char (';');
808 when N_Abortable_Part =>
809 Set_Debug_Sloc;
810 Write_Str_Sloc ("abort ");
811 Sprint_Indented_List (Statements (Node));
813 when N_Abstract_Subprogram_Declaration =>
814 Write_Indent;
815 Sprint_Node (Specification (Node));
816 Write_Str_With_Col_Check (" is ");
817 Write_Str_Sloc ("abstract;");
819 when N_Accept_Alternative =>
820 Sprint_Node_List (Pragmas_Before (Node));
822 if Present (Condition (Node)) then
823 Write_Indent_Str ("when ");
824 Sprint_Node (Condition (Node));
825 Write_Str (" => ");
826 Indent_Annull;
827 end if;
829 Sprint_Node_Sloc (Accept_Statement (Node));
830 Sprint_Node_List (Statements (Node));
832 when N_Accept_Statement =>
833 Write_Indent_Str_Sloc ("accept ");
834 Write_Id (Entry_Direct_Name (Node));
836 if Present (Entry_Index (Node)) then
837 Write_Str_With_Col_Check (" (");
838 Sprint_Node (Entry_Index (Node));
839 Write_Char (')');
840 end if;
842 Write_Param_Specs (Node);
844 if Present (Handled_Statement_Sequence (Node)) then
845 Write_Str_With_Col_Check (" do");
846 Sprint_Node (Handled_Statement_Sequence (Node));
847 Write_Indent_Str ("end ");
848 Write_Id (Entry_Direct_Name (Node));
849 end if;
851 Write_Char (';');
853 when N_Access_Definition =>
855 -- Ada 2005 (AI-254)
857 if Present (Access_To_Subprogram_Definition (Node)) then
858 Sprint_Node (Access_To_Subprogram_Definition (Node));
859 else
860 -- Ada 2005 (AI-231)
862 if Null_Exclusion_Present (Node) then
863 Write_Str ("not null ");
864 end if;
866 Write_Str_With_Col_Check_Sloc ("access ");
868 if All_Present (Node) then
869 Write_Str ("all ");
870 elsif Constant_Present (Node) then
871 Write_Str ("constant ");
872 end if;
874 Sprint_Node (Subtype_Mark (Node));
875 end if;
877 when N_Access_Function_Definition =>
879 -- Ada 2005 (AI-231)
881 if Null_Exclusion_Present (Node) then
882 Write_Str ("not null ");
883 end if;
885 Write_Str_With_Col_Check_Sloc ("access ");
887 if Protected_Present (Node) then
888 Write_Str_With_Col_Check ("protected ");
889 end if;
891 Write_Str_With_Col_Check ("function");
892 Write_Param_Specs (Node);
893 Write_Str_With_Col_Check (" return ");
894 Sprint_Node (Result_Definition (Node));
896 when N_Access_Procedure_Definition =>
898 -- Ada 2005 (AI-231)
900 if Null_Exclusion_Present (Node) then
901 Write_Str ("not null ");
902 end if;
904 Write_Str_With_Col_Check_Sloc ("access ");
906 if Protected_Present (Node) then
907 Write_Str_With_Col_Check ("protected ");
908 end if;
910 Write_Str_With_Col_Check ("procedure");
911 Write_Param_Specs (Node);
913 when N_Access_To_Object_Definition =>
914 Write_Str_With_Col_Check_Sloc ("access ");
916 if All_Present (Node) then
917 Write_Str_With_Col_Check ("all ");
918 elsif Constant_Present (Node) then
919 Write_Str_With_Col_Check ("constant ");
920 end if;
922 -- Ada 2005 (AI-231)
924 if Null_Exclusion_Present (Node) then
925 Write_Str ("not null ");
926 end if;
928 Sprint_Node (Subtype_Indication (Node));
930 when N_Aggregate =>
931 if Null_Record_Present (Node) then
932 Write_Str_With_Col_Check_Sloc ("(null record)");
934 else
935 Write_Str_With_Col_Check_Sloc ("(");
937 if Present (Expressions (Node)) then
938 Sprint_Comma_List (Expressions (Node));
940 if Present (Component_Associations (Node))
941 and then not Is_Empty_List (Component_Associations (Node))
942 then
943 Write_Str (", ");
944 end if;
945 end if;
947 if Present (Component_Associations (Node))
948 and then not Is_Empty_List (Component_Associations (Node))
949 then
950 Indent_Begin;
952 declare
953 Nd : Node_Id;
955 begin
956 Nd := First (Component_Associations (Node));
958 loop
959 Write_Indent;
960 Sprint_Node (Nd);
961 Next (Nd);
962 exit when No (Nd);
964 if not Is_Rewrite_Insertion (Nd)
965 or else not Dump_Original_Only
966 then
967 Write_Str (", ");
968 end if;
969 end loop;
970 end;
972 Indent_End;
973 end if;
975 Write_Char (')');
976 end if;
978 when N_Allocator =>
979 Write_Str_With_Col_Check_Sloc ("new ");
981 -- Ada 2005 (AI-231)
983 if Null_Exclusion_Present (Node) then
984 Write_Str ("not null ");
985 end if;
987 Sprint_Node (Expression (Node));
989 if Present (Storage_Pool (Node)) then
990 Write_Str_With_Col_Check ("[storage_pool = ");
991 Sprint_Node (Storage_Pool (Node));
992 Write_Char (']');
993 end if;
995 when N_And_Then =>
996 Sprint_Left_Opnd (Node);
997 Write_Str_Sloc (" and then ");
998 Sprint_Right_Opnd (Node);
1000 when N_At_Clause =>
1001 Write_Indent_Str_Sloc ("for ");
1002 Write_Id (Identifier (Node));
1003 Write_Str_With_Col_Check (" use at ");
1004 Sprint_Node (Expression (Node));
1005 Write_Char (';');
1007 when N_Assignment_Statement =>
1008 Write_Indent;
1009 Sprint_Node (Name (Node));
1010 Write_Str_Sloc (" := ");
1011 Sprint_Node (Expression (Node));
1012 Write_Char (';');
1014 when N_Asynchronous_Select =>
1015 Write_Indent_Str_Sloc ("select");
1016 Indent_Begin;
1017 Sprint_Node (Triggering_Alternative (Node));
1018 Indent_End;
1020 -- Note: let the printing of Abortable_Part handle outputting
1021 -- the ABORT keyword, so that the Sloc can be set correctly.
1023 Write_Indent_Str ("then ");
1024 Sprint_Node (Abortable_Part (Node));
1025 Write_Indent_Str ("end select;");
1027 when N_Attribute_Definition_Clause =>
1028 Write_Indent_Str_Sloc ("for ");
1029 Sprint_Node (Name (Node));
1030 Write_Char (''');
1031 Write_Name_With_Col_Check (Chars (Node));
1032 Write_Str_With_Col_Check (" use ");
1033 Sprint_Node (Expression (Node));
1034 Write_Char (';');
1036 when N_Attribute_Reference =>
1037 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1038 Write_Indent;
1039 end if;
1041 Sprint_Node (Prefix (Node));
1042 Write_Char_Sloc (''');
1043 Write_Name_With_Col_Check (Attribute_Name (Node));
1044 Sprint_Paren_Comma_List (Expressions (Node));
1046 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1047 Write_Char (';');
1048 end if;
1050 when N_Block_Statement =>
1051 Write_Indent;
1053 if Present (Identifier (Node))
1054 and then (not Has_Created_Identifier (Node)
1055 or else not Dump_Original_Only)
1056 then
1057 Write_Rewrite_Str ("<<<");
1058 Write_Id (Identifier (Node));
1059 Write_Str (" : ");
1060 Write_Rewrite_Str (">>>");
1061 end if;
1063 if Present (Declarations (Node)) then
1064 Write_Str_With_Col_Check_Sloc ("declare");
1065 Sprint_Indented_List (Declarations (Node));
1066 Write_Indent;
1067 end if;
1069 Write_Str_With_Col_Check_Sloc ("begin");
1070 Sprint_Node (Handled_Statement_Sequence (Node));
1071 Write_Indent_Str ("end");
1073 if Present (Identifier (Node))
1074 and then (not Has_Created_Identifier (Node)
1075 or else not Dump_Original_Only)
1076 then
1077 Write_Rewrite_Str ("<<<");
1078 Write_Char (' ');
1079 Write_Id (Identifier (Node));
1080 Write_Rewrite_Str (">>>");
1081 end if;
1083 Write_Char (';');
1085 when N_Case_Statement =>
1086 Write_Indent_Str_Sloc ("case ");
1087 Sprint_Node (Expression (Node));
1088 Write_Str (" is");
1089 Sprint_Indented_List (Alternatives (Node));
1090 Write_Indent_Str ("end case;");
1092 when N_Case_Statement_Alternative =>
1093 Write_Indent_Str_Sloc ("when ");
1094 Sprint_Bar_List (Discrete_Choices (Node));
1095 Write_Str (" => ");
1096 Sprint_Indented_List (Statements (Node));
1098 when N_Character_Literal =>
1099 if Column > Sprint_Line_Limit - 2 then
1100 Write_Indent_Str (" ");
1101 end if;
1103 Write_Char_Sloc (''');
1104 Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
1105 Write_Char (''');
1107 when N_Code_Statement =>
1108 Write_Indent;
1109 Set_Debug_Sloc;
1110 Sprint_Node (Expression (Node));
1111 Write_Char (';');
1113 when N_Compilation_Unit =>
1114 Sprint_Node_List (Context_Items (Node));
1115 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
1117 if Private_Present (Node) then
1118 Write_Indent_Str ("private ");
1119 Indent_Annull;
1120 end if;
1122 Sprint_Node_Sloc (Unit (Node));
1124 if Present (Actions (Aux_Decls_Node (Node)))
1125 or else
1126 Present (Pragmas_After (Aux_Decls_Node (Node)))
1127 then
1128 Write_Indent;
1129 end if;
1131 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
1132 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
1134 when N_Compilation_Unit_Aux =>
1135 null; -- nothing to do, never used, see above
1137 when N_Component_Association =>
1138 Set_Debug_Sloc;
1139 Sprint_Bar_List (Choices (Node));
1140 Write_Str (" => ");
1142 -- Ada 2005 (AI-287): Print the box if present
1144 if Box_Present (Node) then
1145 Write_Str_With_Col_Check ("<>");
1146 else
1147 Sprint_Node (Expression (Node));
1148 end if;
1150 when N_Component_Clause =>
1151 Write_Indent;
1152 Sprint_Node (Component_Name (Node));
1153 Write_Str_Sloc (" at ");
1154 Sprint_Node (Position (Node));
1155 Write_Char (' ');
1156 Write_Str_With_Col_Check ("range ");
1157 Sprint_Node (First_Bit (Node));
1158 Write_Str (" .. ");
1159 Sprint_Node (Last_Bit (Node));
1160 Write_Char (';');
1162 when N_Component_Definition =>
1163 Set_Debug_Sloc;
1165 -- Ada 2005 (AI-230): Access definition components
1167 if Present (Access_Definition (Node)) then
1168 Sprint_Node (Access_Definition (Node));
1170 elsif Present (Subtype_Indication (Node)) then
1171 if Aliased_Present (Node) then
1172 Write_Str_With_Col_Check ("aliased ");
1173 end if;
1175 -- Ada 2005 (AI-231)
1177 if Null_Exclusion_Present (Node) then
1178 Write_Str (" not null ");
1179 end if;
1181 Sprint_Node (Subtype_Indication (Node));
1183 else
1184 Write_Str (" ??? ");
1185 end if;
1187 when N_Component_Declaration =>
1188 if Write_Indent_Identifiers_Sloc (Node) then
1189 Write_Str (" : ");
1190 Sprint_Node (Component_Definition (Node));
1192 if Present (Expression (Node)) then
1193 Write_Str (" := ");
1194 Sprint_Node (Expression (Node));
1195 end if;
1197 Write_Char (';');
1198 end if;
1200 when N_Component_List =>
1201 if Null_Present (Node) then
1202 Indent_Begin;
1203 Write_Indent_Str_Sloc ("null");
1204 Write_Char (';');
1205 Indent_End;
1207 else
1208 Set_Debug_Sloc;
1209 Sprint_Indented_List (Component_Items (Node));
1210 Sprint_Node (Variant_Part (Node));
1211 end if;
1213 when N_Conditional_Entry_Call =>
1214 Write_Indent_Str_Sloc ("select");
1215 Indent_Begin;
1216 Sprint_Node (Entry_Call_Alternative (Node));
1217 Indent_End;
1218 Write_Indent_Str ("else");
1219 Sprint_Indented_List (Else_Statements (Node));
1220 Write_Indent_Str ("end select;");
1222 when N_Conditional_Expression =>
1223 declare
1224 Condition : constant Node_Id := First (Expressions (Node));
1225 Then_Expr : constant Node_Id := Next (Condition);
1226 Else_Expr : constant Node_Id := Next (Then_Expr);
1227 begin
1228 Write_Str_With_Col_Check_Sloc ("(if ");
1229 Sprint_Node (Condition);
1230 Write_Str_With_Col_Check (" then ");
1231 Sprint_Node (Then_Expr);
1232 Write_Str_With_Col_Check (" else ");
1233 Sprint_Node (Else_Expr);
1234 Write_Char (')');
1235 end;
1237 when N_Constrained_Array_Definition =>
1238 Write_Str_With_Col_Check_Sloc ("array ");
1239 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1240 Write_Str (" of ");
1242 Sprint_Node (Component_Definition (Node));
1244 when N_Decimal_Fixed_Point_Definition =>
1245 Write_Str_With_Col_Check_Sloc (" delta ");
1246 Sprint_Node (Delta_Expression (Node));
1247 Write_Str_With_Col_Check ("digits ");
1248 Sprint_Node (Digits_Expression (Node));
1249 Sprint_Opt_Node (Real_Range_Specification (Node));
1251 when N_Defining_Character_Literal =>
1252 Write_Name_With_Col_Check_Sloc (Chars (Node));
1254 when N_Defining_Identifier =>
1255 Set_Debug_Sloc;
1256 Write_Id (Node);
1258 when N_Defining_Operator_Symbol =>
1259 Write_Name_With_Col_Check_Sloc (Chars (Node));
1261 when N_Defining_Program_Unit_Name =>
1262 Set_Debug_Sloc;
1263 Sprint_Node (Name (Node));
1264 Write_Char ('.');
1265 Write_Id (Defining_Identifier (Node));
1267 when N_Delay_Alternative =>
1268 Sprint_Node_List (Pragmas_Before (Node));
1270 if Present (Condition (Node)) then
1271 Write_Indent;
1272 Write_Str_With_Col_Check ("when ");
1273 Sprint_Node (Condition (Node));
1274 Write_Str (" => ");
1275 Indent_Annull;
1276 end if;
1278 Sprint_Node_Sloc (Delay_Statement (Node));
1279 Sprint_Node_List (Statements (Node));
1281 when N_Delay_Relative_Statement =>
1282 Write_Indent_Str_Sloc ("delay ");
1283 Sprint_Node (Expression (Node));
1284 Write_Char (';');
1286 when N_Delay_Until_Statement =>
1287 Write_Indent_Str_Sloc ("delay until ");
1288 Sprint_Node (Expression (Node));
1289 Write_Char (';');
1291 when N_Delta_Constraint =>
1292 Write_Str_With_Col_Check_Sloc ("delta ");
1293 Sprint_Node (Delta_Expression (Node));
1294 Sprint_Opt_Node (Range_Constraint (Node));
1296 when N_Derived_Type_Definition =>
1297 if Abstract_Present (Node) then
1298 Write_Str_With_Col_Check ("abstract ");
1299 end if;
1301 Write_Str_With_Col_Check_Sloc ("new ");
1303 -- Ada 2005 (AI-231)
1305 if Null_Exclusion_Present (Node) then
1306 Write_Str_With_Col_Check ("not null ");
1307 end if;
1309 Sprint_Node (Subtype_Indication (Node));
1311 if Present (Interface_List (Node)) then
1312 Write_Str_With_Col_Check (" and ");
1313 Sprint_And_List (Interface_List (Node));
1314 Write_Str_With_Col_Check (" with ");
1315 end if;
1317 if Present (Record_Extension_Part (Node)) then
1318 if No (Interface_List (Node)) then
1319 Write_Str_With_Col_Check (" with ");
1320 end if;
1322 Sprint_Node (Record_Extension_Part (Node));
1323 end if;
1325 when N_Designator =>
1326 Sprint_Node (Name (Node));
1327 Write_Char_Sloc ('.');
1328 Write_Id (Identifier (Node));
1330 when N_Digits_Constraint =>
1331 Write_Str_With_Col_Check_Sloc ("digits ");
1332 Sprint_Node (Digits_Expression (Node));
1333 Sprint_Opt_Node (Range_Constraint (Node));
1335 when N_Discriminant_Association =>
1336 Set_Debug_Sloc;
1338 if Present (Selector_Names (Node)) then
1339 Sprint_Bar_List (Selector_Names (Node));
1340 Write_Str (" => ");
1341 end if;
1343 Set_Debug_Sloc;
1344 Sprint_Node (Expression (Node));
1346 when N_Discriminant_Specification =>
1347 Set_Debug_Sloc;
1349 if Write_Identifiers (Node) then
1350 Write_Str (" : ");
1352 if Null_Exclusion_Present (Node) then
1353 Write_Str ("not null ");
1354 end if;
1356 Sprint_Node (Discriminant_Type (Node));
1358 if Present (Expression (Node)) then
1359 Write_Str (" := ");
1360 Sprint_Node (Expression (Node));
1361 end if;
1362 else
1363 Write_Str (", ");
1364 end if;
1366 when N_Elsif_Part =>
1367 Write_Indent_Str_Sloc ("elsif ");
1368 Sprint_Node (Condition (Node));
1369 Write_Str_With_Col_Check (" then");
1370 Sprint_Indented_List (Then_Statements (Node));
1372 when N_Empty =>
1373 null;
1375 when N_Entry_Body =>
1376 Write_Indent_Str_Sloc ("entry ");
1377 Write_Id (Defining_Identifier (Node));
1378 Sprint_Node (Entry_Body_Formal_Part (Node));
1379 Write_Str_With_Col_Check (" is");
1380 Sprint_Indented_List (Declarations (Node));
1381 Write_Indent_Str ("begin");
1382 Sprint_Node (Handled_Statement_Sequence (Node));
1383 Write_Indent_Str ("end ");
1384 Write_Id (Defining_Identifier (Node));
1385 Write_Char (';');
1387 when N_Entry_Body_Formal_Part =>
1388 if Present (Entry_Index_Specification (Node)) then
1389 Write_Str_With_Col_Check_Sloc (" (");
1390 Sprint_Node (Entry_Index_Specification (Node));
1391 Write_Char (')');
1392 end if;
1394 Write_Param_Specs (Node);
1395 Write_Str_With_Col_Check_Sloc (" when ");
1396 Sprint_Node (Condition (Node));
1398 when N_Entry_Call_Alternative =>
1399 Sprint_Node_List (Pragmas_Before (Node));
1400 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1401 Sprint_Node_List (Statements (Node));
1403 when N_Entry_Call_Statement =>
1404 Write_Indent;
1405 Sprint_Node_Sloc (Name (Node));
1406 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1407 Write_Char (';');
1409 when N_Entry_Declaration =>
1410 Write_Indent_Str_Sloc ("entry ");
1411 Write_Id (Defining_Identifier (Node));
1413 if Present (Discrete_Subtype_Definition (Node)) then
1414 Write_Str_With_Col_Check (" (");
1415 Sprint_Node (Discrete_Subtype_Definition (Node));
1416 Write_Char (')');
1417 end if;
1419 Write_Param_Specs (Node);
1420 Write_Char (';');
1422 when N_Entry_Index_Specification =>
1423 Write_Str_With_Col_Check_Sloc ("for ");
1424 Write_Id (Defining_Identifier (Node));
1425 Write_Str_With_Col_Check (" in ");
1426 Sprint_Node (Discrete_Subtype_Definition (Node));
1428 when N_Enumeration_Representation_Clause =>
1429 Write_Indent_Str_Sloc ("for ");
1430 Write_Id (Identifier (Node));
1431 Write_Str_With_Col_Check (" use ");
1432 Sprint_Node (Array_Aggregate (Node));
1433 Write_Char (';');
1435 when N_Enumeration_Type_Definition =>
1436 Set_Debug_Sloc;
1438 -- Skip attempt to print Literals field if it's not there and
1439 -- we are in package Standard (case of Character, which is
1440 -- handled specially (without an explicit literals list).
1442 if Sloc (Node) > Standard_Location
1443 or else Present (Literals (Node))
1444 then
1445 Sprint_Paren_Comma_List (Literals (Node));
1446 end if;
1448 when N_Error =>
1449 Write_Str_With_Col_Check_Sloc ("<error>");
1451 when N_Exception_Declaration =>
1452 if Write_Indent_Identifiers (Node) then
1453 Write_Str_With_Col_Check (" : ");
1455 if Is_Statically_Allocated (Defining_Identifier (Node)) then
1456 Write_Str_With_Col_Check ("static ");
1457 end if;
1459 Write_Str_Sloc ("exception");
1461 if Present (Expression (Node)) then
1462 Write_Str (" := ");
1463 Sprint_Node (Expression (Node));
1464 end if;
1466 Write_Char (';');
1467 end if;
1469 when N_Exception_Handler =>
1470 Write_Indent_Str_Sloc ("when ");
1472 if Present (Choice_Parameter (Node)) then
1473 Sprint_Node (Choice_Parameter (Node));
1474 Write_Str (" : ");
1475 end if;
1477 Sprint_Bar_List (Exception_Choices (Node));
1478 Write_Str (" => ");
1479 Sprint_Indented_List (Statements (Node));
1481 when N_Exception_Renaming_Declaration =>
1482 Write_Indent;
1483 Set_Debug_Sloc;
1484 Sprint_Node (Defining_Identifier (Node));
1485 Write_Str_With_Col_Check (" : exception renames ");
1486 Sprint_Node (Name (Node));
1487 Write_Char (';');
1489 when N_Exit_Statement =>
1490 Write_Indent_Str_Sloc ("exit");
1491 Sprint_Opt_Node (Name (Node));
1493 if Present (Condition (Node)) then
1494 Write_Str_With_Col_Check (" when ");
1495 Sprint_Node (Condition (Node));
1496 end if;
1498 Write_Char (';');
1500 when N_Expanded_Name =>
1501 Sprint_Node (Prefix (Node));
1502 Write_Char_Sloc ('.');
1503 Sprint_Node (Selector_Name (Node));
1505 when N_Explicit_Dereference =>
1506 Sprint_Node (Prefix (Node));
1507 Write_Char_Sloc ('.');
1508 Write_Str_Sloc ("all");
1510 when N_Extended_Return_Statement =>
1511 Write_Indent_Str_Sloc ("return ");
1512 Sprint_Node_List (Return_Object_Declarations (Node));
1514 if Present (Handled_Statement_Sequence (Node)) then
1515 Write_Str_With_Col_Check (" do");
1516 Sprint_Node (Handled_Statement_Sequence (Node));
1517 Write_Indent_Str ("end return;");
1518 else
1519 Write_Indent_Str (";");
1520 end if;
1522 when N_Extension_Aggregate =>
1523 Write_Str_With_Col_Check_Sloc ("(");
1524 Sprint_Node (Ancestor_Part (Node));
1525 Write_Str_With_Col_Check (" with ");
1527 if Null_Record_Present (Node) then
1528 Write_Str_With_Col_Check ("null record");
1529 else
1530 if Present (Expressions (Node)) then
1531 Sprint_Comma_List (Expressions (Node));
1533 if Present (Component_Associations (Node)) then
1534 Write_Str (", ");
1535 end if;
1536 end if;
1538 if Present (Component_Associations (Node)) then
1539 Sprint_Comma_List (Component_Associations (Node));
1540 end if;
1541 end if;
1543 Write_Char (')');
1545 when N_Floating_Point_Definition =>
1546 Write_Str_With_Col_Check_Sloc ("digits ");
1547 Sprint_Node (Digits_Expression (Node));
1548 Sprint_Opt_Node (Real_Range_Specification (Node));
1550 when N_Formal_Decimal_Fixed_Point_Definition =>
1551 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1553 when N_Formal_Derived_Type_Definition =>
1554 Write_Str_With_Col_Check_Sloc ("new ");
1555 Sprint_Node (Subtype_Mark (Node));
1557 if Present (Interface_List (Node)) then
1558 Write_Str_With_Col_Check (" and ");
1559 Sprint_And_List (Interface_List (Node));
1560 end if;
1562 if Private_Present (Node) then
1563 Write_Str_With_Col_Check (" with private");
1564 end if;
1566 when N_Formal_Abstract_Subprogram_Declaration =>
1567 Write_Indent_Str_Sloc ("with ");
1568 Sprint_Node (Specification (Node));
1570 Write_Str_With_Col_Check (" is abstract");
1572 if Box_Present (Node) then
1573 Write_Str_With_Col_Check (" <>");
1574 elsif Present (Default_Name (Node)) then
1575 Write_Str_With_Col_Check (" ");
1576 Sprint_Node (Default_Name (Node));
1577 end if;
1579 Write_Char (';');
1581 when N_Formal_Concrete_Subprogram_Declaration =>
1582 Write_Indent_Str_Sloc ("with ");
1583 Sprint_Node (Specification (Node));
1585 if Box_Present (Node) then
1586 Write_Str_With_Col_Check (" is <>");
1587 elsif Present (Default_Name (Node)) then
1588 Write_Str_With_Col_Check (" is ");
1589 Sprint_Node (Default_Name (Node));
1590 end if;
1592 Write_Char (';');
1594 when N_Formal_Discrete_Type_Definition =>
1595 Write_Str_With_Col_Check_Sloc ("<>");
1597 when N_Formal_Floating_Point_Definition =>
1598 Write_Str_With_Col_Check_Sloc ("digits <>");
1600 when N_Formal_Modular_Type_Definition =>
1601 Write_Str_With_Col_Check_Sloc ("mod <>");
1603 when N_Formal_Object_Declaration =>
1604 Set_Debug_Sloc;
1606 if Write_Indent_Identifiers (Node) then
1607 Write_Str (" : ");
1609 if In_Present (Node) then
1610 Write_Str_With_Col_Check ("in ");
1611 end if;
1613 if Out_Present (Node) then
1614 Write_Str_With_Col_Check ("out ");
1615 end if;
1617 if Present (Subtype_Mark (Node)) then
1619 -- Ada 2005 (AI-423): Formal object with null exclusion
1621 if Null_Exclusion_Present (Node) then
1622 Write_Str ("not null ");
1623 end if;
1625 Sprint_Node (Subtype_Mark (Node));
1627 -- Ada 2005 (AI-423): Formal object with access definition
1629 else
1630 pragma Assert (Present (Access_Definition (Node)));
1632 Sprint_Node (Access_Definition (Node));
1633 end if;
1635 if Present (Default_Expression (Node)) then
1636 Write_Str (" := ");
1637 Sprint_Node (Default_Expression (Node));
1638 end if;
1640 Write_Char (';');
1641 end if;
1643 when N_Formal_Ordinary_Fixed_Point_Definition =>
1644 Write_Str_With_Col_Check_Sloc ("delta <>");
1646 when N_Formal_Package_Declaration =>
1647 Write_Indent_Str_Sloc ("with package ");
1648 Write_Id (Defining_Identifier (Node));
1649 Write_Str_With_Col_Check (" is new ");
1650 Sprint_Node (Name (Node));
1651 Write_Str_With_Col_Check (" (<>);");
1653 when N_Formal_Private_Type_Definition =>
1654 if Abstract_Present (Node) then
1655 Write_Str_With_Col_Check ("abstract ");
1656 end if;
1658 if Tagged_Present (Node) then
1659 Write_Str_With_Col_Check ("tagged ");
1660 end if;
1662 if Limited_Present (Node) then
1663 Write_Str_With_Col_Check ("limited ");
1664 end if;
1666 Write_Str_With_Col_Check_Sloc ("private");
1668 when N_Formal_Signed_Integer_Type_Definition =>
1669 Write_Str_With_Col_Check_Sloc ("range <>");
1671 when N_Formal_Type_Declaration =>
1672 Write_Indent_Str_Sloc ("type ");
1673 Write_Id (Defining_Identifier (Node));
1675 if Present (Discriminant_Specifications (Node)) then
1676 Write_Discr_Specs (Node);
1677 elsif Unknown_Discriminants_Present (Node) then
1678 Write_Str_With_Col_Check ("(<>)");
1679 end if;
1681 Write_Str_With_Col_Check (" is ");
1682 Sprint_Node (Formal_Type_Definition (Node));
1683 Write_Char (';');
1685 when N_Free_Statement =>
1686 Write_Indent_Str_Sloc ("free ");
1687 Sprint_Node (Expression (Node));
1688 Write_Char (';');
1690 when N_Freeze_Entity =>
1691 if Dump_Original_Only then
1692 null;
1694 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1695 Write_Indent;
1696 Write_Rewrite_Str ("<<<");
1697 Write_Str_With_Col_Check_Sloc ("freeze ");
1698 Write_Id (Entity (Node));
1699 Write_Str (" [");
1701 if No (Actions (Node)) then
1702 Write_Char (']');
1704 else
1705 -- Output freeze actions. We increment Freeze_Indent during
1706 -- this output to avoid generating extra blank lines before
1707 -- any procedures included in the freeze actions.
1709 Freeze_Indent := Freeze_Indent + 1;
1710 Sprint_Indented_List (Actions (Node));
1711 Freeze_Indent := Freeze_Indent - 1;
1712 Write_Indent_Str ("]");
1713 end if;
1715 Write_Rewrite_Str (">>>");
1716 end if;
1718 when N_Full_Type_Declaration =>
1719 Write_Indent_Str_Sloc ("type ");
1720 Sprint_Node (Defining_Identifier (Node));
1721 Write_Discr_Specs (Node);
1722 Write_Str_With_Col_Check (" is ");
1723 Sprint_Node (Type_Definition (Node));
1724 Write_Char (';');
1726 when N_Function_Call =>
1727 Set_Debug_Sloc;
1728 Write_Subprogram_Name (Name (Node));
1729 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1731 when N_Function_Instantiation =>
1732 Write_Indent_Str_Sloc ("function ");
1733 Sprint_Node (Defining_Unit_Name (Node));
1734 Write_Str_With_Col_Check (" is new ");
1735 Sprint_Node (Name (Node));
1736 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1737 Write_Char (';');
1739 when N_Function_Specification =>
1740 Write_Str_With_Col_Check_Sloc ("function ");
1741 Sprint_Node (Defining_Unit_Name (Node));
1742 Write_Param_Specs (Node);
1743 Write_Str_With_Col_Check (" return ");
1745 -- Ada 2005 (AI-231)
1747 if Nkind (Result_Definition (Node)) /= N_Access_Definition
1748 and then Null_Exclusion_Present (Node)
1749 then
1750 Write_Str (" not null ");
1751 end if;
1753 Sprint_Node (Result_Definition (Node));
1755 when N_Generic_Association =>
1756 Set_Debug_Sloc;
1758 if Present (Selector_Name (Node)) then
1759 Sprint_Node (Selector_Name (Node));
1760 Write_Str (" => ");
1761 end if;
1763 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1765 when N_Generic_Function_Renaming_Declaration =>
1766 Write_Indent_Str_Sloc ("generic function ");
1767 Sprint_Node (Defining_Unit_Name (Node));
1768 Write_Str_With_Col_Check (" renames ");
1769 Sprint_Node (Name (Node));
1770 Write_Char (';');
1772 when N_Generic_Package_Declaration =>
1773 Extra_Blank_Line;
1774 Write_Indent_Str_Sloc ("generic ");
1775 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1776 Write_Indent;
1777 Sprint_Node (Specification (Node));
1778 Write_Char (';');
1780 when N_Generic_Package_Renaming_Declaration =>
1781 Write_Indent_Str_Sloc ("generic package ");
1782 Sprint_Node (Defining_Unit_Name (Node));
1783 Write_Str_With_Col_Check (" renames ");
1784 Sprint_Node (Name (Node));
1785 Write_Char (';');
1787 when N_Generic_Procedure_Renaming_Declaration =>
1788 Write_Indent_Str_Sloc ("generic procedure ");
1789 Sprint_Node (Defining_Unit_Name (Node));
1790 Write_Str_With_Col_Check (" renames ");
1791 Sprint_Node (Name (Node));
1792 Write_Char (';');
1794 when N_Generic_Subprogram_Declaration =>
1795 Extra_Blank_Line;
1796 Write_Indent_Str_Sloc ("generic ");
1797 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1798 Write_Indent;
1799 Sprint_Node (Specification (Node));
1800 Write_Char (';');
1802 when N_Goto_Statement =>
1803 Write_Indent_Str_Sloc ("goto ");
1804 Sprint_Node (Name (Node));
1805 Write_Char (';');
1807 if Nkind (Next (Node)) = N_Label then
1808 Write_Indent;
1809 end if;
1811 when N_Handled_Sequence_Of_Statements =>
1812 Set_Debug_Sloc;
1813 Sprint_Indented_List (Statements (Node));
1815 if Present (Exception_Handlers (Node)) then
1816 Write_Indent_Str ("exception");
1817 Indent_Begin;
1818 Sprint_Node_List (Exception_Handlers (Node));
1819 Indent_End;
1820 end if;
1822 if Present (At_End_Proc (Node)) then
1823 Write_Indent_Str ("at end");
1824 Indent_Begin;
1825 Write_Indent;
1826 Sprint_Node (At_End_Proc (Node));
1827 Write_Char (';');
1828 Indent_End;
1829 end if;
1831 when N_Identifier =>
1832 Set_Debug_Sloc;
1833 Write_Id (Node);
1835 when N_If_Statement =>
1836 Write_Indent_Str_Sloc ("if ");
1837 Sprint_Node (Condition (Node));
1838 Write_Str_With_Col_Check (" then");
1839 Sprint_Indented_List (Then_Statements (Node));
1840 Sprint_Opt_Node_List (Elsif_Parts (Node));
1842 if Present (Else_Statements (Node)) then
1843 Write_Indent_Str ("else");
1844 Sprint_Indented_List (Else_Statements (Node));
1845 end if;
1847 Write_Indent_Str ("end if;");
1849 when N_Implicit_Label_Declaration =>
1850 if not Dump_Original_Only then
1851 Write_Indent;
1852 Write_Rewrite_Str ("<<<");
1853 Set_Debug_Sloc;
1854 Write_Id (Defining_Identifier (Node));
1855 Write_Str (" : ");
1856 Write_Str_With_Col_Check ("label");
1857 Write_Rewrite_Str (">>>");
1858 end if;
1860 when N_In =>
1861 Sprint_Left_Opnd (Node);
1862 Write_Str_Sloc (" in ");
1864 if Present (Right_Opnd (Node)) then
1865 Sprint_Right_Opnd (Node);
1866 else
1867 Sprint_Bar_List (Alternatives (Node));
1868 end if;
1870 when N_Incomplete_Type_Declaration =>
1871 Write_Indent_Str_Sloc ("type ");
1872 Write_Id (Defining_Identifier (Node));
1874 if Present (Discriminant_Specifications (Node)) then
1875 Write_Discr_Specs (Node);
1876 elsif Unknown_Discriminants_Present (Node) then
1877 Write_Str_With_Col_Check ("(<>)");
1878 end if;
1880 Write_Char (';');
1882 when N_Index_Or_Discriminant_Constraint =>
1883 Set_Debug_Sloc;
1884 Sprint_Paren_Comma_List (Constraints (Node));
1886 when N_Indexed_Component =>
1887 Sprint_Node_Sloc (Prefix (Node));
1888 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1890 when N_Integer_Literal =>
1891 if Print_In_Hex (Node) then
1892 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1893 else
1894 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1895 end if;
1897 when N_Iteration_Scheme =>
1898 if Present (Condition (Node)) then
1899 Write_Str_With_Col_Check_Sloc ("while ");
1900 Sprint_Node (Condition (Node));
1901 else
1902 Write_Str_With_Col_Check_Sloc ("for ");
1903 Sprint_Node (Loop_Parameter_Specification (Node));
1904 end if;
1906 Write_Char (' ');
1908 when N_Itype_Reference =>
1909 Write_Indent_Str_Sloc ("reference ");
1910 Write_Id (Itype (Node));
1912 when N_Label =>
1913 Write_Indent_Str_Sloc ("<<");
1914 Write_Id (Identifier (Node));
1915 Write_Str (">>");
1917 when N_Loop_Parameter_Specification =>
1918 Set_Debug_Sloc;
1919 Write_Id (Defining_Identifier (Node));
1920 Write_Str_With_Col_Check (" in ");
1922 if Reverse_Present (Node) then
1923 Write_Str_With_Col_Check ("reverse ");
1924 end if;
1926 Sprint_Node (Discrete_Subtype_Definition (Node));
1928 when N_Loop_Statement =>
1929 Write_Indent;
1931 if Present (Identifier (Node))
1932 and then (not Has_Created_Identifier (Node)
1933 or else not Dump_Original_Only)
1934 then
1935 Write_Rewrite_Str ("<<<");
1936 Write_Id (Identifier (Node));
1937 Write_Str (" : ");
1938 Write_Rewrite_Str (">>>");
1939 Sprint_Node (Iteration_Scheme (Node));
1940 Write_Str_With_Col_Check_Sloc ("loop");
1941 Sprint_Indented_List (Statements (Node));
1942 Write_Indent_Str ("end loop ");
1943 Write_Rewrite_Str ("<<<");
1944 Write_Id (Identifier (Node));
1945 Write_Rewrite_Str (">>>");
1946 Write_Char (';');
1948 else
1949 Sprint_Node (Iteration_Scheme (Node));
1950 Write_Str_With_Col_Check_Sloc ("loop");
1951 Sprint_Indented_List (Statements (Node));
1952 Write_Indent_Str ("end loop;");
1953 end if;
1955 when N_Mod_Clause =>
1956 Sprint_Node_List (Pragmas_Before (Node));
1957 Write_Str_With_Col_Check_Sloc ("at mod ");
1958 Sprint_Node (Expression (Node));
1960 when N_Modular_Type_Definition =>
1961 Write_Str_With_Col_Check_Sloc ("mod ");
1962 Sprint_Node (Expression (Node));
1964 when N_Not_In =>
1965 Sprint_Left_Opnd (Node);
1966 Write_Str_Sloc (" not in ");
1968 if Present (Right_Opnd (Node)) then
1969 Sprint_Right_Opnd (Node);
1970 else
1971 Sprint_Bar_List (Alternatives (Node));
1972 end if;
1974 when N_Null =>
1975 Write_Str_With_Col_Check_Sloc ("null");
1977 when N_Null_Statement =>
1978 if Comes_From_Source (Node)
1979 or else Dump_Freeze_Null
1980 or else not Is_List_Member (Node)
1981 or else (No (Prev (Node)) and then No (Next (Node)))
1982 then
1983 Write_Indent_Str_Sloc ("null;");
1984 end if;
1986 when N_Number_Declaration =>
1987 Set_Debug_Sloc;
1989 if Write_Indent_Identifiers (Node) then
1990 Write_Str_With_Col_Check (" : constant ");
1991 Write_Str (" := ");
1992 Sprint_Node (Expression (Node));
1993 Write_Char (';');
1994 end if;
1996 when N_Object_Declaration =>
1997 Set_Debug_Sloc;
1999 if Write_Indent_Identifiers (Node) then
2000 declare
2001 Def_Id : constant Entity_Id := Defining_Identifier (Node);
2003 begin
2004 Write_Str_With_Col_Check (" : ");
2006 if Is_Statically_Allocated (Def_Id) then
2007 Write_Str_With_Col_Check ("static ");
2008 end if;
2010 if Aliased_Present (Node) then
2011 Write_Str_With_Col_Check ("aliased ");
2012 end if;
2014 if Constant_Present (Node) then
2015 Write_Str_With_Col_Check ("constant ");
2016 end if;
2018 -- Ada 2005 (AI-231)
2020 if Null_Exclusion_Present (Node) then
2021 Write_Str_With_Col_Check ("not null ");
2022 end if;
2024 Sprint_Node (Object_Definition (Node));
2026 if Present (Expression (Node)) then
2027 Write_Str (" := ");
2028 Sprint_Node (Expression (Node));
2029 end if;
2031 Write_Char (';');
2033 -- Handle implicit importation and implicit exportation of
2034 -- object declarations:
2035 -- $pragma import (Convention_Id, Def_Id, "...");
2036 -- $pragma export (Convention_Id, Def_Id, "...");
2038 if Is_Internal (Def_Id)
2039 and then Present (Interface_Name (Def_Id))
2040 then
2041 Write_Indent_Str_Sloc ("$pragma ");
2043 if Is_Imported (Def_Id) then
2044 Write_Str ("import (");
2046 else pragma Assert (Is_Exported (Def_Id));
2047 Write_Str ("export (");
2048 end if;
2050 declare
2051 Prefix : constant String := "Convention_";
2052 S : constant String := Convention (Def_Id)'Img;
2054 begin
2055 Name_Len := S'Last - Prefix'Last;
2056 Name_Buffer (1 .. Name_Len) :=
2057 S (Prefix'Last + 1 .. S'Last);
2058 Set_Casing (All_Lower_Case);
2059 Write_Str (Name_Buffer (1 .. Name_Len));
2060 end;
2062 Write_Str (", ");
2063 Write_Id (Def_Id);
2064 Write_Str (", ");
2065 Write_String_Table_Entry
2066 (Strval (Interface_Name (Def_Id)));
2067 Write_Str (");");
2068 end if;
2069 end;
2070 end if;
2072 when N_Object_Renaming_Declaration =>
2073 Write_Indent;
2074 Set_Debug_Sloc;
2075 Sprint_Node (Defining_Identifier (Node));
2076 Write_Str (" : ");
2078 -- Ada 2005 (AI-230): Access renamings
2080 if Present (Access_Definition (Node)) then
2081 Sprint_Node (Access_Definition (Node));
2083 elsif Present (Subtype_Mark (Node)) then
2085 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2087 if Null_Exclusion_Present (Node) then
2088 Write_Str ("not null ");
2089 end if;
2091 Sprint_Node (Subtype_Mark (Node));
2093 else
2094 Write_Str (" ??? ");
2095 end if;
2097 Write_Str_With_Col_Check (" renames ");
2098 Sprint_Node (Name (Node));
2099 Write_Char (';');
2101 when N_Op_Abs =>
2102 Write_Operator (Node, "abs ");
2103 Sprint_Right_Opnd (Node);
2105 when N_Op_Add =>
2106 Sprint_Left_Opnd (Node);
2107 Write_Operator (Node, " + ");
2108 Sprint_Right_Opnd (Node);
2110 when N_Op_And =>
2111 Sprint_Left_Opnd (Node);
2112 Write_Operator (Node, " and ");
2113 Sprint_Right_Opnd (Node);
2115 when N_Op_Concat =>
2116 Sprint_Left_Opnd (Node);
2117 Write_Operator (Node, " & ");
2118 Sprint_Right_Opnd (Node);
2120 when N_Op_Divide =>
2121 Sprint_Left_Opnd (Node);
2122 Write_Char (' ');
2123 Process_TFAI_RR_Flags (Node);
2124 Write_Operator (Node, "/ ");
2125 Sprint_Right_Opnd (Node);
2127 when N_Op_Eq =>
2128 Sprint_Left_Opnd (Node);
2129 Write_Operator (Node, " = ");
2130 Sprint_Right_Opnd (Node);
2132 when N_Op_Expon =>
2133 Sprint_Left_Opnd (Node);
2134 Write_Operator (Node, " ** ");
2135 Sprint_Right_Opnd (Node);
2137 when N_Op_Ge =>
2138 Sprint_Left_Opnd (Node);
2139 Write_Operator (Node, " >= ");
2140 Sprint_Right_Opnd (Node);
2142 when N_Op_Gt =>
2143 Sprint_Left_Opnd (Node);
2144 Write_Operator (Node, " > ");
2145 Sprint_Right_Opnd (Node);
2147 when N_Op_Le =>
2148 Sprint_Left_Opnd (Node);
2149 Write_Operator (Node, " <= ");
2150 Sprint_Right_Opnd (Node);
2152 when N_Op_Lt =>
2153 Sprint_Left_Opnd (Node);
2154 Write_Operator (Node, " < ");
2155 Sprint_Right_Opnd (Node);
2157 when N_Op_Minus =>
2158 Write_Operator (Node, "-");
2159 Sprint_Right_Opnd (Node);
2161 when N_Op_Mod =>
2162 Sprint_Left_Opnd (Node);
2164 if Treat_Fixed_As_Integer (Node) then
2165 Write_Str (" #");
2166 end if;
2168 Write_Operator (Node, " mod ");
2169 Sprint_Right_Opnd (Node);
2171 when N_Op_Multiply =>
2172 Sprint_Left_Opnd (Node);
2173 Write_Char (' ');
2174 Process_TFAI_RR_Flags (Node);
2175 Write_Operator (Node, "* ");
2176 Sprint_Right_Opnd (Node);
2178 when N_Op_Ne =>
2179 Sprint_Left_Opnd (Node);
2180 Write_Operator (Node, " /= ");
2181 Sprint_Right_Opnd (Node);
2183 when N_Op_Not =>
2184 Write_Operator (Node, "not ");
2185 Sprint_Right_Opnd (Node);
2187 when N_Op_Or =>
2188 Sprint_Left_Opnd (Node);
2189 Write_Operator (Node, " or ");
2190 Sprint_Right_Opnd (Node);
2192 when N_Op_Plus =>
2193 Write_Operator (Node, "+");
2194 Sprint_Right_Opnd (Node);
2196 when N_Op_Rem =>
2197 Sprint_Left_Opnd (Node);
2199 if Treat_Fixed_As_Integer (Node) then
2200 Write_Str (" #");
2201 end if;
2203 Write_Operator (Node, " rem ");
2204 Sprint_Right_Opnd (Node);
2206 when N_Op_Shift =>
2207 Set_Debug_Sloc;
2208 Write_Id (Node);
2209 Write_Char ('!');
2210 Write_Str_With_Col_Check ("(");
2211 Sprint_Node (Left_Opnd (Node));
2212 Write_Str (", ");
2213 Sprint_Node (Right_Opnd (Node));
2214 Write_Char (')');
2216 when N_Op_Subtract =>
2217 Sprint_Left_Opnd (Node);
2218 Write_Operator (Node, " - ");
2219 Sprint_Right_Opnd (Node);
2221 when N_Op_Xor =>
2222 Sprint_Left_Opnd (Node);
2223 Write_Operator (Node, " xor ");
2224 Sprint_Right_Opnd (Node);
2226 when N_Operator_Symbol =>
2227 Write_Name_With_Col_Check_Sloc (Chars (Node));
2229 when N_Ordinary_Fixed_Point_Definition =>
2230 Write_Str_With_Col_Check_Sloc ("delta ");
2231 Sprint_Node (Delta_Expression (Node));
2232 Sprint_Opt_Node (Real_Range_Specification (Node));
2234 when N_Or_Else =>
2235 Sprint_Left_Opnd (Node);
2236 Write_Str_Sloc (" or else ");
2237 Sprint_Right_Opnd (Node);
2239 when N_Others_Choice =>
2240 if All_Others (Node) then
2241 Write_Str_With_Col_Check ("all ");
2242 end if;
2244 Write_Str_With_Col_Check_Sloc ("others");
2246 when N_Package_Body =>
2247 Extra_Blank_Line;
2248 Write_Indent_Str_Sloc ("package body ");
2249 Sprint_Node (Defining_Unit_Name (Node));
2250 Write_Str (" is");
2251 Sprint_Indented_List (Declarations (Node));
2253 if Present (Handled_Statement_Sequence (Node)) then
2254 Write_Indent_Str ("begin");
2255 Sprint_Node (Handled_Statement_Sequence (Node));
2256 end if;
2258 Write_Indent_Str ("end ");
2259 Sprint_End_Label
2260 (Handled_Statement_Sequence (Node), Defining_Unit_Name (Node));
2261 Write_Char (';');
2263 when N_Package_Body_Stub =>
2264 Write_Indent_Str_Sloc ("package body ");
2265 Sprint_Node (Defining_Identifier (Node));
2266 Write_Str_With_Col_Check (" is separate;");
2268 when N_Package_Declaration =>
2269 Extra_Blank_Line;
2270 Write_Indent;
2271 Sprint_Node_Sloc (Specification (Node));
2272 Write_Char (';');
2274 when N_Package_Instantiation =>
2275 Extra_Blank_Line;
2276 Write_Indent_Str_Sloc ("package ");
2277 Sprint_Node (Defining_Unit_Name (Node));
2278 Write_Str (" is new ");
2279 Sprint_Node (Name (Node));
2280 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2281 Write_Char (';');
2283 when N_Package_Renaming_Declaration =>
2284 Write_Indent_Str_Sloc ("package ");
2285 Sprint_Node (Defining_Unit_Name (Node));
2286 Write_Str_With_Col_Check (" renames ");
2287 Sprint_Node (Name (Node));
2288 Write_Char (';');
2290 when N_Package_Specification =>
2291 Write_Str_With_Col_Check_Sloc ("package ");
2292 Sprint_Node (Defining_Unit_Name (Node));
2293 Write_Str (" is");
2294 Sprint_Indented_List (Visible_Declarations (Node));
2296 if Present (Private_Declarations (Node)) then
2297 Write_Indent_Str ("private");
2298 Sprint_Indented_List (Private_Declarations (Node));
2299 end if;
2301 Write_Indent_Str ("end ");
2302 Sprint_Node (Defining_Unit_Name (Node));
2304 when N_Parameter_Association =>
2305 Sprint_Node_Sloc (Selector_Name (Node));
2306 Write_Str (" => ");
2307 Sprint_Node (Explicit_Actual_Parameter (Node));
2309 when N_Parameter_Specification =>
2310 Set_Debug_Sloc;
2312 if Write_Identifiers (Node) then
2313 Write_Str (" : ");
2315 if In_Present (Node) then
2316 Write_Str_With_Col_Check ("in ");
2317 end if;
2319 if Out_Present (Node) then
2320 Write_Str_With_Col_Check ("out ");
2321 end if;
2323 -- Ada 2005 (AI-231): Parameter specification may carry null
2324 -- exclusion. Do not print it now if this is an access formal,
2325 -- it is emitted when the access definition is displayed.
2327 if Null_Exclusion_Present (Node)
2328 and then Nkind (Parameter_Type (Node))
2329 /= N_Access_Definition
2330 then
2331 Write_Str ("not null ");
2332 end if;
2334 Sprint_Node (Parameter_Type (Node));
2336 if Present (Expression (Node)) then
2337 Write_Str (" := ");
2338 Sprint_Node (Expression (Node));
2339 end if;
2340 else
2341 Write_Str (", ");
2342 end if;
2344 when N_Pop_Constraint_Error_Label =>
2345 Write_Indent_Str ("%pop_constraint_error_label");
2347 when N_Pop_Program_Error_Label =>
2348 Write_Indent_Str ("%pop_program_error_label");
2350 when N_Pop_Storage_Error_Label =>
2351 Write_Indent_Str ("%pop_storage_error_label");
2353 when N_Push_Constraint_Error_Label =>
2354 Write_Indent_Str ("%push_constraint_error_label (");
2356 if Present (Exception_Label (Node)) then
2357 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2358 end if;
2360 Write_Str (")");
2362 when N_Push_Program_Error_Label =>
2363 Write_Indent_Str ("%push_program_error_label (");
2365 if Present (Exception_Label (Node)) then
2366 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2367 end if;
2369 Write_Str (")");
2371 when N_Push_Storage_Error_Label =>
2372 Write_Indent_Str ("%push_storage_error_label (");
2374 if Present (Exception_Label (Node)) then
2375 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2376 end if;
2378 Write_Str (")");
2380 when N_Pragma =>
2381 Write_Indent_Str_Sloc ("pragma ");
2382 Write_Name_With_Col_Check (Pragma_Name (Node));
2384 if Present (Pragma_Argument_Associations (Node)) then
2385 Sprint_Opt_Paren_Comma_List
2386 (Pragma_Argument_Associations (Node));
2387 end if;
2389 Write_Char (';');
2391 when N_Pragma_Argument_Association =>
2392 Set_Debug_Sloc;
2394 if Chars (Node) /= No_Name then
2395 Write_Name_With_Col_Check (Chars (Node));
2396 Write_Str (" => ");
2397 end if;
2399 Sprint_Node (Expression (Node));
2401 when N_Private_Type_Declaration =>
2402 Write_Indent_Str_Sloc ("type ");
2403 Write_Id (Defining_Identifier (Node));
2405 if Present (Discriminant_Specifications (Node)) then
2406 Write_Discr_Specs (Node);
2407 elsif Unknown_Discriminants_Present (Node) then
2408 Write_Str_With_Col_Check ("(<>)");
2409 end if;
2411 Write_Str (" is ");
2413 if Tagged_Present (Node) then
2414 Write_Str_With_Col_Check ("tagged ");
2415 end if;
2417 if Limited_Present (Node) then
2418 Write_Str_With_Col_Check ("limited ");
2419 end if;
2421 Write_Str_With_Col_Check ("private;");
2423 when N_Private_Extension_Declaration =>
2424 Write_Indent_Str_Sloc ("type ");
2425 Write_Id (Defining_Identifier (Node));
2427 if Present (Discriminant_Specifications (Node)) then
2428 Write_Discr_Specs (Node);
2429 elsif Unknown_Discriminants_Present (Node) then
2430 Write_Str_With_Col_Check ("(<>)");
2431 end if;
2433 Write_Str_With_Col_Check (" is new ");
2434 Sprint_Node (Subtype_Indication (Node));
2436 if Present (Interface_List (Node)) then
2437 Write_Str_With_Col_Check (" and ");
2438 Sprint_And_List (Interface_List (Node));
2439 end if;
2441 Write_Str_With_Col_Check (" with private;");
2443 when N_Procedure_Call_Statement =>
2444 Write_Indent;
2445 Set_Debug_Sloc;
2446 Write_Subprogram_Name (Name (Node));
2447 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2448 Write_Char (';');
2450 when N_Procedure_Instantiation =>
2451 Write_Indent_Str_Sloc ("procedure ");
2452 Sprint_Node (Defining_Unit_Name (Node));
2453 Write_Str_With_Col_Check (" is new ");
2454 Sprint_Node (Name (Node));
2455 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2456 Write_Char (';');
2458 when N_Procedure_Specification =>
2459 Write_Str_With_Col_Check_Sloc ("procedure ");
2460 Sprint_Node (Defining_Unit_Name (Node));
2461 Write_Param_Specs (Node);
2463 when N_Protected_Body =>
2464 Write_Indent_Str_Sloc ("protected body ");
2465 Write_Id (Defining_Identifier (Node));
2466 Write_Str (" is");
2467 Sprint_Indented_List (Declarations (Node));
2468 Write_Indent_Str ("end ");
2469 Write_Id (Defining_Identifier (Node));
2470 Write_Char (';');
2472 when N_Protected_Body_Stub =>
2473 Write_Indent_Str_Sloc ("protected body ");
2474 Write_Id (Defining_Identifier (Node));
2475 Write_Str_With_Col_Check (" is separate;");
2477 when N_Protected_Definition =>
2478 Set_Debug_Sloc;
2479 Sprint_Indented_List (Visible_Declarations (Node));
2481 if Present (Private_Declarations (Node)) then
2482 Write_Indent_Str ("private");
2483 Sprint_Indented_List (Private_Declarations (Node));
2484 end if;
2486 Write_Indent_Str ("end ");
2488 when N_Protected_Type_Declaration =>
2489 Write_Indent_Str_Sloc ("protected type ");
2490 Sprint_Node (Defining_Identifier (Node));
2491 Write_Discr_Specs (Node);
2493 if Present (Interface_List (Node)) then
2494 Write_Str (" is new ");
2495 Sprint_And_List (Interface_List (Node));
2496 Write_Str (" with ");
2497 else
2498 Write_Str (" is");
2499 end if;
2501 Sprint_Node (Protected_Definition (Node));
2502 Write_Id (Defining_Identifier (Node));
2503 Write_Char (';');
2505 when N_Qualified_Expression =>
2506 Sprint_Node (Subtype_Mark (Node));
2507 Write_Char_Sloc (''');
2509 -- Print expression, make sure we have at least one level of
2510 -- parentheses around the expression. For cases of qualified
2511 -- expressions in the source, this is always the case, but
2512 -- for generated qualifications, there may be no explicit
2513 -- parentheses present.
2515 if Paren_Count (Expression (Node)) /= 0 then
2516 Sprint_Node (Expression (Node));
2517 else
2518 Write_Char ('(');
2519 Sprint_Node (Expression (Node));
2520 Write_Char (')');
2521 end if;
2523 when N_Raise_Constraint_Error =>
2525 -- This node can be used either as a subexpression or as a
2526 -- statement form. The following test is a reasonably reliable
2527 -- way to distinguish the two cases.
2529 if Is_List_Member (Node)
2530 and then Nkind (Parent (Node)) not in N_Subexpr
2531 then
2532 Write_Indent;
2533 end if;
2535 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2536 Write_Condition_And_Reason (Node);
2538 when N_Raise_Program_Error =>
2540 -- This node can be used either as a subexpression or as a
2541 -- statement form. The following test is a reasonably reliable
2542 -- way to distinguish the two cases.
2544 if Is_List_Member (Node)
2545 and then Nkind (Parent (Node)) not in N_Subexpr
2546 then
2547 Write_Indent;
2548 end if;
2550 Write_Str_With_Col_Check_Sloc ("[program_error");
2551 Write_Condition_And_Reason (Node);
2553 when N_Raise_Storage_Error =>
2555 -- This node can be used either as a subexpression or as a
2556 -- statement form. The following test is a reasonably reliable
2557 -- way to distinguish the two cases.
2559 if Is_List_Member (Node)
2560 and then Nkind (Parent (Node)) not in N_Subexpr
2561 then
2562 Write_Indent;
2563 end if;
2565 Write_Str_With_Col_Check_Sloc ("[storage_error");
2566 Write_Condition_And_Reason (Node);
2568 when N_Raise_Statement =>
2569 Write_Indent_Str_Sloc ("raise ");
2570 Sprint_Node (Name (Node));
2571 Write_Char (';');
2573 when N_Range =>
2574 Sprint_Node (Low_Bound (Node));
2575 Write_Str_Sloc (" .. ");
2576 Sprint_Node (High_Bound (Node));
2577 Update_Itype (Node);
2579 when N_Range_Constraint =>
2580 Write_Str_With_Col_Check_Sloc ("range ");
2581 Sprint_Node (Range_Expression (Node));
2583 when N_Real_Literal =>
2584 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2586 when N_Real_Range_Specification =>
2587 Write_Str_With_Col_Check_Sloc ("range ");
2588 Sprint_Node (Low_Bound (Node));
2589 Write_Str (" .. ");
2590 Sprint_Node (High_Bound (Node));
2592 when N_Record_Definition =>
2593 if Abstract_Present (Node) then
2594 Write_Str_With_Col_Check ("abstract ");
2595 end if;
2597 if Tagged_Present (Node) then
2598 Write_Str_With_Col_Check ("tagged ");
2599 end if;
2601 if Limited_Present (Node) then
2602 Write_Str_With_Col_Check ("limited ");
2603 end if;
2605 if Null_Present (Node) then
2606 Write_Str_With_Col_Check_Sloc ("null record");
2608 else
2609 Write_Str_With_Col_Check_Sloc ("record");
2610 Sprint_Node (Component_List (Node));
2611 Write_Indent_Str ("end record");
2612 end if;
2614 when N_Record_Representation_Clause =>
2615 Write_Indent_Str_Sloc ("for ");
2616 Sprint_Node (Identifier (Node));
2617 Write_Str_With_Col_Check (" use record ");
2619 if Present (Mod_Clause (Node)) then
2620 Sprint_Node (Mod_Clause (Node));
2621 end if;
2623 Sprint_Indented_List (Component_Clauses (Node));
2624 Write_Indent_Str ("end record;");
2626 when N_Reference =>
2627 Sprint_Node (Prefix (Node));
2628 Write_Str_With_Col_Check_Sloc ("'reference");
2630 when N_Requeue_Statement =>
2631 Write_Indent_Str_Sloc ("requeue ");
2632 Sprint_Node (Name (Node));
2634 if Abort_Present (Node) then
2635 Write_Str_With_Col_Check (" with abort");
2636 end if;
2638 Write_Char (';');
2640 -- Don't we want to print more detail???
2642 -- Doc of this extended syntax belongs in sinfo.ads and/or
2643 -- sprint.ads ???
2645 when N_SCIL_Dispatch_Table_Object_Init =>
2646 Write_Indent_Str ("[N_SCIL_Dispatch_Table_Object_Init]");
2648 when N_SCIL_Dispatch_Table_Tag_Init =>
2649 Write_Indent_Str ("[N_SCIL_Dispatch_Table_Tag_Init]");
2651 when N_SCIL_Dispatching_Call =>
2652 Write_Indent_Str ("[N_SCIL_Dispatching_Node]");
2654 when N_SCIL_Tag_Init =>
2655 Write_Indent_Str ("[N_SCIL_Dispatch_Table_Tag_Init]");
2657 when N_Simple_Return_Statement =>
2658 if Present (Expression (Node)) then
2659 Write_Indent_Str_Sloc ("return ");
2660 Sprint_Node (Expression (Node));
2661 Write_Char (';');
2662 else
2663 Write_Indent_Str_Sloc ("return;");
2664 end if;
2666 when N_Selective_Accept =>
2667 Write_Indent_Str_Sloc ("select");
2669 declare
2670 Alt_Node : Node_Id;
2671 begin
2672 Alt_Node := First (Select_Alternatives (Node));
2673 loop
2674 Indent_Begin;
2675 Sprint_Node (Alt_Node);
2676 Indent_End;
2677 Next (Alt_Node);
2678 exit when No (Alt_Node);
2679 Write_Indent_Str ("or");
2680 end loop;
2681 end;
2683 if Present (Else_Statements (Node)) then
2684 Write_Indent_Str ("else");
2685 Sprint_Indented_List (Else_Statements (Node));
2686 end if;
2688 Write_Indent_Str ("end select;");
2690 when N_Signed_Integer_Type_Definition =>
2691 Write_Str_With_Col_Check_Sloc ("range ");
2692 Sprint_Node (Low_Bound (Node));
2693 Write_Str (" .. ");
2694 Sprint_Node (High_Bound (Node));
2696 when N_Single_Protected_Declaration =>
2697 Write_Indent_Str_Sloc ("protected ");
2698 Write_Id (Defining_Identifier (Node));
2699 Write_Str (" is");
2700 Sprint_Node (Protected_Definition (Node));
2701 Write_Id (Defining_Identifier (Node));
2702 Write_Char (';');
2704 when N_Single_Task_Declaration =>
2705 Write_Indent_Str_Sloc ("task ");
2706 Sprint_Node (Defining_Identifier (Node));
2708 if Present (Task_Definition (Node)) then
2709 Write_Str (" is");
2710 Sprint_Node (Task_Definition (Node));
2711 end if;
2713 Write_Char (';');
2715 when N_Selected_Component =>
2716 Sprint_Node (Prefix (Node));
2717 Write_Char_Sloc ('.');
2718 Sprint_Node (Selector_Name (Node));
2720 when N_Slice =>
2721 Set_Debug_Sloc;
2722 Sprint_Node (Prefix (Node));
2723 Write_Str_With_Col_Check (" (");
2724 Sprint_Node (Discrete_Range (Node));
2725 Write_Char (')');
2727 when N_String_Literal =>
2728 if String_Length (Strval (Node)) + Column > Sprint_Line_Limit then
2729 Write_Indent_Str (" ");
2730 end if;
2732 Set_Debug_Sloc;
2733 Write_String_Table_Entry (Strval (Node));
2735 when N_Subprogram_Body =>
2737 -- Output extra blank line unless we are in freeze actions
2739 if Freeze_Indent = 0 then
2740 Extra_Blank_Line;
2741 end if;
2743 Write_Indent;
2744 Sprint_Node_Sloc (Specification (Node));
2745 Write_Str (" is");
2747 Sprint_Indented_List (Declarations (Node));
2748 Write_Indent_Str ("begin");
2749 Sprint_Node (Handled_Statement_Sequence (Node));
2751 Write_Indent_Str ("end ");
2753 Sprint_End_Label
2754 (Handled_Statement_Sequence (Node),
2755 Defining_Unit_Name (Specification (Node)));
2756 Write_Char (';');
2758 if Is_List_Member (Node)
2759 and then Present (Next (Node))
2760 and then Nkind (Next (Node)) /= N_Subprogram_Body
2761 then
2762 Write_Indent;
2763 end if;
2765 when N_Subprogram_Body_Stub =>
2766 Write_Indent;
2767 Sprint_Node_Sloc (Specification (Node));
2768 Write_Str_With_Col_Check (" is separate;");
2770 when N_Subprogram_Declaration =>
2771 Write_Indent;
2772 Sprint_Node_Sloc (Specification (Node));
2774 if Nkind (Specification (Node)) = N_Procedure_Specification
2775 and then Null_Present (Specification (Node))
2776 then
2777 Write_Str_With_Col_Check (" is null");
2778 end if;
2780 Write_Char (';');
2782 when N_Subprogram_Info =>
2783 Sprint_Node (Identifier (Node));
2784 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2786 when N_Subprogram_Renaming_Declaration =>
2787 Write_Indent;
2788 Sprint_Node (Specification (Node));
2789 Write_Str_With_Col_Check_Sloc (" renames ");
2790 Sprint_Node (Name (Node));
2791 Write_Char (';');
2793 when N_Subtype_Declaration =>
2794 Write_Indent_Str_Sloc ("subtype ");
2795 Sprint_Node (Defining_Identifier (Node));
2796 Write_Str (" is ");
2798 -- Ada 2005 (AI-231)
2800 if Null_Exclusion_Present (Node) then
2801 Write_Str ("not null ");
2802 end if;
2804 Sprint_Node (Subtype_Indication (Node));
2805 Write_Char (';');
2807 when N_Subtype_Indication =>
2808 Sprint_Node_Sloc (Subtype_Mark (Node));
2809 Write_Char (' ');
2810 Sprint_Node (Constraint (Node));
2812 when N_Subunit =>
2813 Write_Indent_Str_Sloc ("separate (");
2814 Sprint_Node (Name (Node));
2815 Write_Char (')');
2816 Extra_Blank_Line;
2817 Sprint_Node (Proper_Body (Node));
2819 when N_Task_Body =>
2820 Write_Indent_Str_Sloc ("task body ");
2821 Write_Id (Defining_Identifier (Node));
2822 Write_Str (" is");
2823 Sprint_Indented_List (Declarations (Node));
2824 Write_Indent_Str ("begin");
2825 Sprint_Node (Handled_Statement_Sequence (Node));
2826 Write_Indent_Str ("end ");
2827 Sprint_End_Label
2828 (Handled_Statement_Sequence (Node), Defining_Identifier (Node));
2829 Write_Char (';');
2831 when N_Task_Body_Stub =>
2832 Write_Indent_Str_Sloc ("task body ");
2833 Write_Id (Defining_Identifier (Node));
2834 Write_Str_With_Col_Check (" is separate;");
2836 when N_Task_Definition =>
2837 Set_Debug_Sloc;
2838 Sprint_Indented_List (Visible_Declarations (Node));
2840 if Present (Private_Declarations (Node)) then
2841 Write_Indent_Str ("private");
2842 Sprint_Indented_List (Private_Declarations (Node));
2843 end if;
2845 Write_Indent_Str ("end ");
2846 Sprint_End_Label (Node, Defining_Identifier (Parent (Node)));
2848 when N_Task_Type_Declaration =>
2849 Write_Indent_Str_Sloc ("task type ");
2850 Sprint_Node (Defining_Identifier (Node));
2851 Write_Discr_Specs (Node);
2853 if Present (Interface_List (Node)) then
2854 Write_Str (" is new ");
2855 Sprint_And_List (Interface_List (Node));
2856 end if;
2858 if Present (Task_Definition (Node)) then
2859 if No (Interface_List (Node)) then
2860 Write_Str (" is");
2861 else
2862 Write_Str (" with ");
2863 end if;
2865 Sprint_Node (Task_Definition (Node));
2866 end if;
2868 Write_Char (';');
2870 when N_Terminate_Alternative =>
2871 Sprint_Node_List (Pragmas_Before (Node));
2873 Write_Indent;
2875 if Present (Condition (Node)) then
2876 Write_Str_With_Col_Check ("when ");
2877 Sprint_Node (Condition (Node));
2878 Write_Str (" => ");
2879 end if;
2881 Write_Str_With_Col_Check_Sloc ("terminate;");
2882 Sprint_Node_List (Pragmas_After (Node));
2884 when N_Timed_Entry_Call =>
2885 Write_Indent_Str_Sloc ("select");
2886 Indent_Begin;
2887 Sprint_Node (Entry_Call_Alternative (Node));
2888 Indent_End;
2889 Write_Indent_Str ("or");
2890 Indent_Begin;
2891 Sprint_Node (Delay_Alternative (Node));
2892 Indent_End;
2893 Write_Indent_Str ("end select;");
2895 when N_Triggering_Alternative =>
2896 Sprint_Node_List (Pragmas_Before (Node));
2897 Sprint_Node_Sloc (Triggering_Statement (Node));
2898 Sprint_Node_List (Statements (Node));
2900 when N_Type_Conversion =>
2901 Set_Debug_Sloc;
2902 Sprint_Node (Subtype_Mark (Node));
2903 Col_Check (4);
2905 if Conversion_OK (Node) then
2906 Write_Char ('?');
2907 end if;
2909 if Float_Truncate (Node) then
2910 Write_Char ('^');
2911 end if;
2913 if Rounded_Result (Node) then
2914 Write_Char ('@');
2915 end if;
2917 Write_Char ('(');
2918 Sprint_Node (Expression (Node));
2919 Write_Char (')');
2921 when N_Unchecked_Expression =>
2922 Col_Check (10);
2923 Write_Str ("`(");
2924 Sprint_Node_Sloc (Expression (Node));
2925 Write_Char (')');
2927 when N_Unchecked_Type_Conversion =>
2928 Sprint_Node (Subtype_Mark (Node));
2929 Write_Char ('!');
2930 Write_Str_With_Col_Check ("(");
2931 Sprint_Node_Sloc (Expression (Node));
2932 Write_Char (')');
2934 when N_Unconstrained_Array_Definition =>
2935 Write_Str_With_Col_Check_Sloc ("array (");
2937 declare
2938 Node1 : Node_Id;
2939 begin
2940 Node1 := First (Subtype_Marks (Node));
2941 loop
2942 Sprint_Node (Node1);
2943 Write_Str_With_Col_Check (" range <>");
2944 Next (Node1);
2945 exit when Node1 = Empty;
2946 Write_Str (", ");
2947 end loop;
2948 end;
2950 Write_Str (") of ");
2951 Sprint_Node (Component_Definition (Node));
2953 when N_Unused_At_Start | N_Unused_At_End =>
2954 Write_Indent_Str ("***** Error, unused node encountered *****");
2955 Write_Eol;
2957 when N_Use_Package_Clause =>
2958 Write_Indent_Str_Sloc ("use ");
2959 Sprint_Comma_List (Names (Node));
2960 Write_Char (';');
2962 when N_Use_Type_Clause =>
2963 Write_Indent_Str_Sloc ("use type ");
2964 Sprint_Comma_List (Subtype_Marks (Node));
2965 Write_Char (';');
2967 when N_Validate_Unchecked_Conversion =>
2968 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2969 Sprint_Node (Source_Type (Node));
2970 Write_Str (", ");
2971 Sprint_Node (Target_Type (Node));
2972 Write_Str (");");
2974 when N_Variant =>
2975 Write_Indent_Str_Sloc ("when ");
2976 Sprint_Bar_List (Discrete_Choices (Node));
2977 Write_Str (" => ");
2978 Sprint_Node (Component_List (Node));
2980 when N_Variant_Part =>
2981 Indent_Begin;
2982 Write_Indent_Str_Sloc ("case ");
2983 Sprint_Node (Name (Node));
2984 Write_Str (" is ");
2985 Sprint_Indented_List (Variants (Node));
2986 Write_Indent_Str ("end case");
2987 Indent_End;
2989 when N_With_Clause =>
2991 -- Special test, if we are dumping the original tree only,
2992 -- then we want to eliminate the bogus with clauses that
2993 -- correspond to the non-existent children of Text_IO.
2995 if Dump_Original_Only
2996 and then Is_Text_IO_Kludge_Unit (Name (Node))
2997 then
2998 null;
3000 -- Normal case, output the with clause
3002 else
3003 if First_Name (Node) or else not Dump_Original_Only then
3005 -- Ada 2005 (AI-50217): Print limited with_clauses
3007 if Private_Present (Node) and Limited_Present (Node) then
3008 Write_Indent_Str ("limited private with ");
3010 elsif Private_Present (Node) then
3011 Write_Indent_Str ("private with ");
3013 elsif Limited_Present (Node) then
3014 Write_Indent_Str ("limited with ");
3016 else
3017 Write_Indent_Str ("with ");
3018 end if;
3020 else
3021 Write_Str (", ");
3022 end if;
3024 Sprint_Node_Sloc (Name (Node));
3026 if Last_Name (Node) or else not Dump_Original_Only then
3027 Write_Char (';');
3028 end if;
3029 end if;
3031 end case;
3033 if Nkind (Node) in N_Subexpr
3034 and then Do_Range_Check (Node)
3035 then
3036 Write_Str ("}");
3037 end if;
3039 for J in 1 .. Paren_Count (Node) loop
3040 Write_Char (')');
3041 end loop;
3043 Dump_Node := Save_Dump_Node;
3044 end Sprint_Node_Actual;
3046 ----------------------
3047 -- Sprint_Node_List --
3048 ----------------------
3050 procedure Sprint_Node_List (List : List_Id) is
3051 Node : Node_Id;
3053 begin
3054 if Is_Non_Empty_List (List) then
3055 Node := First (List);
3057 loop
3058 Sprint_Node (Node);
3059 Next (Node);
3060 exit when Node = Empty;
3061 end loop;
3062 end if;
3063 end Sprint_Node_List;
3065 ----------------------
3066 -- Sprint_Node_Sloc --
3067 ----------------------
3069 procedure Sprint_Node_Sloc (Node : Node_Id) is
3070 begin
3071 Sprint_Node (Node);
3073 if Debug_Generated_Code and then Present (Dump_Node) then
3074 Set_Sloc (Dump_Node, Sloc (Node));
3075 Dump_Node := Empty;
3076 end if;
3077 end Sprint_Node_Sloc;
3079 ---------------------
3080 -- Sprint_Opt_Node --
3081 ---------------------
3083 procedure Sprint_Opt_Node (Node : Node_Id) is
3084 begin
3085 if Present (Node) then
3086 Write_Char (' ');
3087 Sprint_Node (Node);
3088 end if;
3089 end Sprint_Opt_Node;
3091 --------------------------
3092 -- Sprint_Opt_Node_List --
3093 --------------------------
3095 procedure Sprint_Opt_Node_List (List : List_Id) is
3096 begin
3097 if Present (List) then
3098 Sprint_Node_List (List);
3099 end if;
3100 end Sprint_Opt_Node_List;
3102 ---------------------------------
3103 -- Sprint_Opt_Paren_Comma_List --
3104 ---------------------------------
3106 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
3107 begin
3108 if Is_Non_Empty_List (List) then
3109 Write_Char (' ');
3110 Sprint_Paren_Comma_List (List);
3111 end if;
3112 end Sprint_Opt_Paren_Comma_List;
3114 -----------------------------
3115 -- Sprint_Paren_Comma_List --
3116 -----------------------------
3118 procedure Sprint_Paren_Comma_List (List : List_Id) is
3119 N : Node_Id;
3120 Node_Exists : Boolean := False;
3122 begin
3124 if Is_Non_Empty_List (List) then
3126 if Dump_Original_Only then
3127 N := First (List);
3128 while Present (N) loop
3129 if not Is_Rewrite_Insertion (N) then
3130 Node_Exists := True;
3131 exit;
3132 end if;
3134 Next (N);
3135 end loop;
3137 if not Node_Exists then
3138 return;
3139 end if;
3140 end if;
3142 Write_Str_With_Col_Check ("(");
3143 Sprint_Comma_List (List);
3144 Write_Char (')');
3145 end if;
3146 end Sprint_Paren_Comma_List;
3148 ----------------------
3149 -- Sprint_Right_Opnd --
3150 ----------------------
3152 procedure Sprint_Right_Opnd (N : Node_Id) is
3153 Opnd : constant Node_Id := Right_Opnd (N);
3155 begin
3156 if Paren_Count (Opnd) /= 0
3157 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
3158 then
3159 Sprint_Node (Opnd);
3161 else
3162 Write_Char ('(');
3163 Sprint_Node (Opnd);
3164 Write_Char (')');
3165 end if;
3166 end Sprint_Right_Opnd;
3168 ------------------
3169 -- Update_Itype --
3170 ------------------
3172 procedure Update_Itype (Node : Node_Id) is
3173 begin
3174 if Present (Etype (Node))
3175 and then Is_Itype (Etype (Node))
3176 and then Debug_Generated_Code
3177 then
3178 Set_Sloc (Etype (Node), Sloc (Node));
3179 end if;
3180 end Update_Itype;
3182 ---------------------
3183 -- Write_Char_Sloc --
3184 ---------------------
3186 procedure Write_Char_Sloc (C : Character) is
3187 begin
3188 if Debug_Generated_Code and then C /= ' ' then
3189 Set_Debug_Sloc;
3190 end if;
3192 Write_Char (C);
3193 end Write_Char_Sloc;
3195 --------------------------------
3196 -- Write_Condition_And_Reason --
3197 --------------------------------
3199 procedure Write_Condition_And_Reason (Node : Node_Id) is
3200 Cond : constant Node_Id := Condition (Node);
3201 Image : constant String := RT_Exception_Code'Image
3202 (RT_Exception_Code'Val
3203 (UI_To_Int (Reason (Node))));
3205 begin
3206 if Present (Cond) then
3208 -- If condition is a single entity, or NOT with a single entity,
3209 -- output all on one line, since it will likely fit just fine.
3211 if Is_Entity_Name (Cond)
3212 or else (Nkind (Cond) = N_Op_Not
3213 and then Is_Entity_Name (Right_Opnd (Cond)))
3214 then
3215 Write_Str_With_Col_Check (" when ");
3216 Sprint_Node (Cond);
3217 Write_Char (' ');
3219 -- Otherwise for more complex condition, multiple lines
3221 else
3222 Write_Str_With_Col_Check (" when");
3223 Indent := Indent + 2;
3224 Write_Indent;
3225 Sprint_Node (Cond);
3226 Write_Indent;
3227 Indent := Indent - 2;
3228 end if;
3230 -- If no condition, just need a space (all on one line)
3232 else
3233 Write_Char (' ');
3234 end if;
3236 -- Write the reason
3238 Write_Char ('"');
3240 for J in 4 .. Image'Last loop
3241 if Image (J) = '_' then
3242 Write_Char (' ');
3243 else
3244 Write_Char (Fold_Lower (Image (J)));
3245 end if;
3246 end loop;
3248 Write_Str ("""]");
3249 end Write_Condition_And_Reason;
3251 --------------------------------
3252 -- Write_Corresponding_Source --
3253 --------------------------------
3255 procedure Write_Corresponding_Source (S : String) is
3256 Loc : Source_Ptr;
3257 Src : Source_Buffer_Ptr;
3259 begin
3260 -- Ignore if not in dump source text mode, or if in freeze actions
3262 if Dump_Source_Text and then Freeze_Indent = 0 then
3264 -- Ignore null string
3266 if S = "" then
3267 return;
3268 end if;
3270 -- Ignore space or semicolon at end of given string
3272 if S (S'Last) = ' ' or else S (S'Last) = ';' then
3273 Write_Corresponding_Source (S (S'First .. S'Last - 1));
3274 return;
3275 end if;
3277 -- Loop to look at next lines not yet printed in source file
3279 for L in
3280 Last_Line_Printed + 1 .. Last_Source_Line (Current_Source_File)
3281 loop
3282 Src := Source_Text (Current_Source_File);
3283 Loc := Line_Start (L, Current_Source_File);
3285 -- If comment, keep looking
3287 if Src (Loc .. Loc + 1) = "--" then
3288 null;
3290 -- Search to first non-blank
3292 else
3293 while Src (Loc) not in Line_Terminator loop
3295 -- Non-blank found
3297 if Src (Loc) /= ' ' and then Src (Loc) /= ASCII.HT then
3299 -- Loop through characters in string to see if we match
3301 for J in S'Range loop
3303 -- If mismatch, then not the case we are looking for
3305 if Src (Loc) /= S (J) then
3306 return;
3307 end if;
3309 Loc := Loc + 1;
3310 end loop;
3312 -- If we fall through, string matched, if white space or
3313 -- semicolon after the matched string, this is the case
3314 -- we are looking for.
3316 if Src (Loc) in Line_Terminator
3317 or else Src (Loc) = ' '
3318 or else Src (Loc) = ASCII.HT
3319 or else Src (Loc) = ';'
3320 then
3321 -- So output source lines up to and including this one
3323 Write_Source_Lines (L);
3324 return;
3325 end if;
3326 end if;
3328 Loc := Loc + 1;
3329 end loop;
3330 end if;
3332 -- Line was all blanks, or a comment line, keep looking
3334 end loop;
3335 end if;
3336 end Write_Corresponding_Source;
3338 -----------------------
3339 -- Write_Discr_Specs --
3340 -----------------------
3342 procedure Write_Discr_Specs (N : Node_Id) is
3343 Specs : List_Id;
3344 Spec : Node_Id;
3346 begin
3347 Specs := Discriminant_Specifications (N);
3349 if Present (Specs) then
3350 Write_Str_With_Col_Check (" (");
3351 Spec := First (Specs);
3353 loop
3354 Sprint_Node (Spec);
3355 Next (Spec);
3356 exit when Spec = Empty;
3358 -- Add semicolon, unless we are printing original tree and the
3359 -- next specification is part of a list (but not the first
3360 -- element of that list)
3362 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3363 Write_Str ("; ");
3364 end if;
3365 end loop;
3367 Write_Char (')');
3368 end if;
3369 end Write_Discr_Specs;
3371 -----------------
3372 -- Write_Ekind --
3373 -----------------
3375 procedure Write_Ekind (E : Entity_Id) is
3376 S : constant String := Entity_Kind'Image (Ekind (E));
3378 begin
3379 Name_Len := S'Length;
3380 Name_Buffer (1 .. Name_Len) := S;
3381 Set_Casing (Mixed_Case);
3382 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3383 end Write_Ekind;
3385 --------------
3386 -- Write_Id --
3387 --------------
3389 procedure Write_Id (N : Node_Id) is
3390 begin
3391 -- Deal with outputting Itype
3393 -- Note: if we are printing the full tree with -gnatds, then we may
3394 -- end up picking up the Associated_Node link from a generic template
3395 -- here which overlaps the Entity field, but as documented, Write_Itype
3396 -- is defended against junk calls.
3398 if Nkind (N) in N_Entity then
3399 Write_Itype (N);
3400 elsif Nkind (N) in N_Has_Entity then
3401 Write_Itype (Entity (N));
3402 end if;
3404 -- Case of a defining identifier
3406 if Nkind (N) = N_Defining_Identifier then
3408 -- If defining identifier has an interface name (and no
3409 -- address clause), then we output the interface name.
3411 if (Is_Imported (N) or else Is_Exported (N))
3412 and then Present (Interface_Name (N))
3413 and then No (Address_Clause (N))
3414 then
3415 String_To_Name_Buffer (Strval (Interface_Name (N)));
3416 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3418 -- If no interface name (or inactive because there was
3419 -- an address clause), then just output the Chars name.
3421 else
3422 Write_Name_With_Col_Check (Chars (N));
3423 end if;
3425 -- Case of selector of an expanded name where the expanded name
3426 -- has an associated entity, output this entity.
3428 elsif Nkind (Parent (N)) = N_Expanded_Name
3429 and then Selector_Name (Parent (N)) = N
3430 and then Present (Entity (Parent (N)))
3431 then
3432 Write_Id (Entity (Parent (N)));
3434 -- For any other node with an associated entity, output it
3436 elsif Nkind (N) in N_Has_Entity
3437 and then Present (Entity_Or_Associated_Node (N))
3438 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
3439 then
3440 Write_Id (Entity (N));
3442 -- All other cases, we just print the Chars field
3444 else
3445 Write_Name_With_Col_Check (Chars (N));
3446 end if;
3447 end Write_Id;
3449 -----------------------
3450 -- Write_Identifiers --
3451 -----------------------
3453 function Write_Identifiers (Node : Node_Id) return Boolean is
3454 begin
3455 Sprint_Node (Defining_Identifier (Node));
3456 Update_Itype (Defining_Identifier (Node));
3458 -- The remainder of the declaration must be printed unless we are
3459 -- printing the original tree and this is not the last identifier
3461 return
3462 not Dump_Original_Only or else not More_Ids (Node);
3464 end Write_Identifiers;
3466 ------------------------
3467 -- Write_Implicit_Def --
3468 ------------------------
3470 procedure Write_Implicit_Def (E : Entity_Id) is
3471 Ind : Node_Id;
3473 begin
3474 case Ekind (E) is
3475 when E_Array_Subtype =>
3476 Write_Str_With_Col_Check ("subtype ");
3477 Write_Id (E);
3478 Write_Str_With_Col_Check (" is ");
3479 Write_Id (Base_Type (E));
3480 Write_Str_With_Col_Check (" (");
3482 Ind := First_Index (E);
3483 while Present (Ind) loop
3484 Sprint_Node (Ind);
3485 Next_Index (Ind);
3487 if Present (Ind) then
3488 Write_Str (", ");
3489 end if;
3490 end loop;
3492 Write_Str (");");
3494 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
3495 Write_Str_With_Col_Check ("subtype ");
3496 Write_Id (E);
3497 Write_Str (" is ");
3498 Write_Id (Etype (E));
3499 Write_Str_With_Col_Check (" range ");
3500 Sprint_Node (Scalar_Range (E));
3501 Write_Str (";");
3503 when others =>
3504 Write_Str_With_Col_Check ("type ");
3505 Write_Id (E);
3506 Write_Str_With_Col_Check (" is <");
3507 Write_Ekind (E);
3508 Write_Str (">;");
3509 end case;
3511 end Write_Implicit_Def;
3513 ------------------
3514 -- Write_Indent --
3515 ------------------
3517 procedure Write_Indent is
3518 Loc : constant Source_Ptr := Sloc (Dump_Node);
3520 begin
3521 if Indent_Annull_Flag then
3522 Indent_Annull_Flag := False;
3523 else
3524 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3525 -- label declarations, since they typically have the sloc of the
3526 -- corresponding label, which really messes up the -gnatL output.
3528 if Dump_Source_Text
3529 and then Loc > No_Location
3530 and then Nkind (Dump_Node) /= N_Implicit_Label_Declaration
3531 then
3532 if Get_Source_File_Index (Loc) = Current_Source_File then
3533 Write_Source_Lines
3534 (Get_Physical_Line_Number (Sloc (Dump_Node)));
3535 end if;
3536 end if;
3538 Write_Eol;
3540 for J in 1 .. Indent loop
3541 Write_Char (' ');
3542 end loop;
3543 end if;
3544 end Write_Indent;
3546 ------------------------------
3547 -- Write_Indent_Identifiers --
3548 ------------------------------
3550 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3551 begin
3552 -- We need to start a new line for every node, except in the case
3553 -- where we are printing the original tree and this is not the first
3554 -- defining identifier in the list.
3556 if not Dump_Original_Only or else not Prev_Ids (Node) then
3557 Write_Indent;
3559 -- If printing original tree and this is not the first defining
3560 -- identifier in the list, then the previous call to this procedure
3561 -- printed only the name, and we add a comma to separate the names.
3563 else
3564 Write_Str (", ");
3565 end if;
3567 Sprint_Node (Defining_Identifier (Node));
3569 -- The remainder of the declaration must be printed unless we are
3570 -- printing the original tree and this is not the last identifier
3572 return
3573 not Dump_Original_Only or else not More_Ids (Node);
3574 end Write_Indent_Identifiers;
3576 -----------------------------------
3577 -- Write_Indent_Identifiers_Sloc --
3578 -----------------------------------
3580 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3581 begin
3582 -- We need to start a new line for every node, except in the case
3583 -- where we are printing the original tree and this is not the first
3584 -- defining identifier in the list.
3586 if not Dump_Original_Only or else not Prev_Ids (Node) then
3587 Write_Indent;
3589 -- If printing original tree and this is not the first defining
3590 -- identifier in the list, then the previous call to this procedure
3591 -- printed only the name, and we add a comma to separate the names.
3593 else
3594 Write_Str (", ");
3595 end if;
3597 Set_Debug_Sloc;
3598 Sprint_Node (Defining_Identifier (Node));
3600 -- The remainder of the declaration must be printed unless we are
3601 -- printing the original tree and this is not the last identifier
3603 return not Dump_Original_Only or else not More_Ids (Node);
3604 end Write_Indent_Identifiers_Sloc;
3606 ----------------------
3607 -- Write_Indent_Str --
3608 ----------------------
3610 procedure Write_Indent_Str (S : String) is
3611 begin
3612 Write_Corresponding_Source (S);
3613 Write_Indent;
3614 Write_Str (S);
3615 end Write_Indent_Str;
3617 ---------------------------
3618 -- Write_Indent_Str_Sloc --
3619 ---------------------------
3621 procedure Write_Indent_Str_Sloc (S : String) is
3622 begin
3623 Write_Corresponding_Source (S);
3624 Write_Indent;
3625 Write_Str_Sloc (S);
3626 end Write_Indent_Str_Sloc;
3628 -----------------
3629 -- Write_Itype --
3630 -----------------
3632 procedure Write_Itype (Typ : Entity_Id) is
3634 procedure Write_Header (T : Boolean := True);
3635 -- Write type if T is True, subtype if T is false
3637 ------------------
3638 -- Write_Header --
3639 ------------------
3641 procedure Write_Header (T : Boolean := True) is
3642 begin
3643 if T then
3644 Write_Str ("[type ");
3645 else
3646 Write_Str ("[subtype ");
3647 end if;
3649 Write_Name_With_Col_Check (Chars (Typ));
3650 Write_Str (" is ");
3651 end Write_Header;
3653 -- Start of processing for Write_Itype
3655 begin
3656 if Nkind (Typ) in N_Entity
3657 and then Is_Itype (Typ)
3658 and then not Itype_Printed (Typ)
3659 then
3660 -- Itype to be printed
3662 declare
3663 B : constant Node_Id := Etype (Typ);
3664 X : Node_Id;
3665 P : constant Node_Id := Parent (Typ);
3667 S : constant Saved_Output_Buffer := Save_Output_Buffer;
3668 -- Save current output buffer
3670 Old_Sloc : Source_Ptr;
3671 -- Save sloc of related node, so it is not modified when
3672 -- printing with -gnatD.
3674 begin
3675 -- Write indentation at start of line
3677 for J in 1 .. Indent loop
3678 Write_Char (' ');
3679 end loop;
3681 -- If we have a constructed declaration for the itype, print it
3683 if Present (P)
3684 and then Nkind (P) in N_Declaration
3685 and then Defining_Entity (P) = Typ
3686 then
3687 -- We must set Itype_Printed true before the recursive call to
3688 -- print the node, otherwise we get an infinite recursion!
3690 Set_Itype_Printed (Typ, True);
3692 -- Write the declaration enclosed in [], avoiding new line
3693 -- at start of declaration, and semicolon at end.
3695 -- Note: The itype may be imported from another unit, in which
3696 -- case we do not want to modify the Sloc of the declaration.
3697 -- Otherwise the itype may appear to be in the current unit,
3698 -- and the back-end will reject a reference out of scope.
3700 Write_Char ('[');
3701 Indent_Annull_Flag := True;
3702 Old_Sloc := Sloc (P);
3703 Sprint_Node (P);
3704 Set_Sloc (P, Old_Sloc);
3705 Write_Erase_Char (';');
3707 -- If no constructed declaration, then we have to concoct the
3708 -- source corresponding to the type entity that we have at hand.
3710 else
3711 case Ekind (Typ) is
3713 -- Access types and subtypes
3715 when Access_Kind =>
3716 Write_Header (Ekind (Typ) = E_Access_Type);
3717 Write_Str ("access ");
3719 if Is_Access_Constant (Typ) then
3720 Write_Str ("constant ");
3721 elsif Can_Never_Be_Null (Typ) then
3722 Write_Str ("not null ");
3723 end if;
3725 Write_Id (Directly_Designated_Type (Typ));
3727 -- Array types and string types
3729 when E_Array_Type | E_String_Type =>
3730 Write_Header;
3731 Write_Str ("array (");
3733 X := First_Index (Typ);
3734 loop
3735 Sprint_Node (X);
3737 if not Is_Constrained (Typ) then
3738 Write_Str (" range <>");
3739 end if;
3741 Next_Index (X);
3742 exit when No (X);
3743 Write_Str (", ");
3744 end loop;
3746 Write_Str (") of ");
3747 X := Component_Type (Typ);
3749 -- Preserve sloc of component type, which is defined
3750 -- elsewhere than the itype (see comment above).
3752 Old_Sloc := Sloc (X);
3753 Sprint_Node (X);
3754 Set_Sloc (X, Old_Sloc);
3756 -- Array subtypes and string subtypes.
3757 -- Preserve Sloc of index subtypes, as above.
3759 when E_Array_Subtype | E_String_Subtype =>
3760 Write_Header (False);
3761 Write_Id (Etype (Typ));
3762 Write_Str (" (");
3764 X := First_Index (Typ);
3765 loop
3766 Old_Sloc := Sloc (X);
3767 Sprint_Node (X);
3768 Set_Sloc (X, Old_Sloc);
3769 Next_Index (X);
3770 exit when No (X);
3771 Write_Str (", ");
3772 end loop;
3774 Write_Char (')');
3776 -- Signed integer types, and modular integer subtypes,
3777 -- and also enumeration subtypes.
3779 when E_Signed_Integer_Type |
3780 E_Signed_Integer_Subtype |
3781 E_Modular_Integer_Subtype |
3782 E_Enumeration_Subtype =>
3784 Write_Header (Ekind (Typ) = E_Signed_Integer_Type);
3786 if Ekind (Typ) = E_Signed_Integer_Type then
3787 Write_Str ("new ");
3788 end if;
3790 Write_Id (B);
3792 -- Print bounds if different from base type
3794 declare
3795 L : constant Node_Id := Type_Low_Bound (Typ);
3796 H : constant Node_Id := Type_High_Bound (Typ);
3797 LE : Node_Id;
3798 HE : Node_Id;
3800 begin
3801 -- B can either be a scalar type, in which case the
3802 -- declaration of Typ may constrain it with different
3803 -- bounds, or a private type, in which case we know
3804 -- that the declaration of Typ cannot have a scalar
3805 -- constraint.
3807 if Is_Scalar_Type (B) then
3808 LE := Type_Low_Bound (B);
3809 HE := Type_High_Bound (B);
3810 else
3811 LE := Empty;
3812 HE := Empty;
3813 end if;
3815 if No (LE)
3816 or else (True
3817 and then Nkind (L) = N_Integer_Literal
3818 and then Nkind (H) = N_Integer_Literal
3819 and then Nkind (LE) = N_Integer_Literal
3820 and then Nkind (HE) = N_Integer_Literal
3821 and then UI_Eq (Intval (L), Intval (LE))
3822 and then UI_Eq (Intval (H), Intval (HE)))
3823 then
3824 null;
3826 else
3827 Write_Str (" range ");
3828 Sprint_Node (Type_Low_Bound (Typ));
3829 Write_Str (" .. ");
3830 Sprint_Node (Type_High_Bound (Typ));
3831 end if;
3832 end;
3834 -- Modular integer types
3836 when E_Modular_Integer_Type =>
3837 Write_Header;
3838 Write_Str (" mod ");
3839 Write_Uint_With_Col_Check (Modulus (Typ), Auto);
3841 -- Floating point types and subtypes
3843 when E_Floating_Point_Type |
3844 E_Floating_Point_Subtype =>
3846 Write_Header (Ekind (Typ) = E_Floating_Point_Type);
3848 if Ekind (Typ) = E_Floating_Point_Type then
3849 Write_Str ("new ");
3850 end if;
3852 Write_Id (Etype (Typ));
3854 if Digits_Value (Typ) /= Digits_Value (Etype (Typ)) then
3855 Write_Str (" digits ");
3856 Write_Uint_With_Col_Check
3857 (Digits_Value (Typ), Decimal);
3858 end if;
3860 -- Print bounds if not different from base type
3862 declare
3863 L : constant Node_Id := Type_Low_Bound (Typ);
3864 H : constant Node_Id := Type_High_Bound (Typ);
3865 LE : constant Node_Id := Type_Low_Bound (B);
3866 HE : constant Node_Id := Type_High_Bound (B);
3868 begin
3869 if Nkind (L) = N_Real_Literal
3870 and then Nkind (H) = N_Real_Literal
3871 and then Nkind (LE) = N_Real_Literal
3872 and then Nkind (HE) = N_Real_Literal
3873 and then UR_Eq (Realval (L), Realval (LE))
3874 and then UR_Eq (Realval (H), Realval (HE))
3875 then
3876 null;
3878 else
3879 Write_Str (" range ");
3880 Sprint_Node (Type_Low_Bound (Typ));
3881 Write_Str (" .. ");
3882 Sprint_Node (Type_High_Bound (Typ));
3883 end if;
3884 end;
3886 -- Record subtypes
3888 when E_Record_Subtype =>
3889 Write_Header (False);
3890 Write_Str ("record");
3891 Indent_Begin;
3893 declare
3894 C : Entity_Id;
3895 begin
3896 C := First_Entity (Typ);
3897 while Present (C) loop
3898 Write_Indent;
3899 Write_Id (C);
3900 Write_Str (" : ");
3901 Write_Id (Etype (C));
3902 Next_Entity (C);
3903 end loop;
3904 end;
3906 Indent_End;
3907 Write_Indent_Str (" end record");
3909 -- Class-Wide types
3911 when E_Class_Wide_Type |
3912 E_Class_Wide_Subtype =>
3913 Write_Header;
3914 Write_Name_With_Col_Check (Chars (Etype (Typ)));
3915 Write_Str ("'Class");
3917 -- Subprogram types
3919 when E_Subprogram_Type =>
3920 Write_Header;
3922 if Etype (Typ) = Standard_Void_Type then
3923 Write_Str ("procedure");
3924 else
3925 Write_Str ("function");
3926 end if;
3928 if Present (First_Entity (Typ)) then
3929 Write_Str (" (");
3931 declare
3932 Param : Entity_Id;
3934 begin
3935 Param := First_Entity (Typ);
3936 loop
3937 Write_Id (Param);
3938 Write_Str (" : ");
3940 if Ekind (Param) = E_In_Out_Parameter then
3941 Write_Str ("in out ");
3942 elsif Ekind (Param) = E_Out_Parameter then
3943 Write_Str ("out ");
3944 end if;
3946 Write_Id (Etype (Param));
3947 Next_Entity (Param);
3948 exit when No (Param);
3949 Write_Str (", ");
3950 end loop;
3952 Write_Char (')');
3953 end;
3954 end if;
3956 if Etype (Typ) /= Standard_Void_Type then
3957 Write_Str (" return ");
3958 Write_Id (Etype (Typ));
3959 end if;
3961 when E_String_Literal_Subtype =>
3962 declare
3963 LB : constant Uint :=
3964 Intval (String_Literal_Low_Bound (Typ));
3965 Len : constant Uint :=
3966 String_Literal_Length (Typ);
3967 begin
3968 Write_Str ("String (");
3969 Write_Int (UI_To_Int (LB));
3970 Write_Str (" .. ");
3971 Write_Int (UI_To_Int (LB + Len) - 1);
3972 Write_Str (");");
3973 end;
3975 -- For all other Itypes, print ??? (fill in later)
3977 when others =>
3978 Write_Header (True);
3979 Write_Str ("???");
3981 end case;
3982 end if;
3984 -- Add terminating bracket and restore output buffer
3986 Write_Char (']');
3987 Write_Eol;
3988 Restore_Output_Buffer (S);
3989 end;
3991 Set_Itype_Printed (Typ);
3992 end if;
3993 end Write_Itype;
3995 -------------------------------
3996 -- Write_Name_With_Col_Check --
3997 -------------------------------
3999 procedure Write_Name_With_Col_Check (N : Name_Id) is
4000 J : Natural;
4001 K : Natural;
4002 L : Natural;
4004 begin
4005 Get_Name_String (N);
4007 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4008 -- upper case letter, nnn is one or more digits and b is a lower case
4009 -- letter by C...b, so that listings do not depend on serial numbers.
4011 if Debug_Flag_II then
4012 J := 1;
4013 while J < Name_Len - 1 loop
4014 if Name_Buffer (J) in 'A' .. 'Z'
4015 and then Name_Buffer (J + 1) in '0' .. '9'
4016 then
4017 K := J + 1;
4018 while K < Name_Len loop
4019 exit when Name_Buffer (K) not in '0' .. '9';
4020 K := K + 1;
4021 end loop;
4023 if Name_Buffer (K) in 'a' .. 'z' then
4024 L := Name_Len - K + 1;
4026 Name_Buffer (J + 4 .. J + L + 3) :=
4027 Name_Buffer (K .. Name_Len);
4028 Name_Buffer (J + 1 .. J + 3) := "...";
4029 Name_Len := J + L + 3;
4030 J := J + 5;
4032 else
4033 J := K;
4034 end if;
4036 else
4037 J := J + 1;
4038 end if;
4039 end loop;
4040 end if;
4042 -- Fall through for normal case
4044 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
4045 end Write_Name_With_Col_Check;
4047 ------------------------------------
4048 -- Write_Name_With_Col_Check_Sloc --
4049 ------------------------------------
4051 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
4052 begin
4053 Get_Name_String (N);
4054 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
4055 end Write_Name_With_Col_Check_Sloc;
4057 --------------------
4058 -- Write_Operator --
4059 --------------------
4061 procedure Write_Operator (N : Node_Id; S : String) is
4062 F : Natural := S'First;
4063 T : Natural := S'Last;
4065 begin
4066 -- If no overflow check, just write string out, and we are done
4068 if not Do_Overflow_Check (N) then
4069 Write_Str_Sloc (S);
4071 -- If overflow check, we want to surround the operator with curly
4072 -- brackets, but not include spaces within the brackets.
4074 else
4075 if S (F) = ' ' then
4076 Write_Char (' ');
4077 F := F + 1;
4078 end if;
4080 if S (T) = ' ' then
4081 T := T - 1;
4082 end if;
4084 Write_Char ('{');
4085 Write_Str_Sloc (S (F .. T));
4086 Write_Char ('}');
4088 if S (S'Last) = ' ' then
4089 Write_Char (' ');
4090 end if;
4091 end if;
4092 end Write_Operator;
4094 -----------------------
4095 -- Write_Param_Specs --
4096 -----------------------
4098 procedure Write_Param_Specs (N : Node_Id) is
4099 Specs : List_Id;
4100 Spec : Node_Id;
4101 Formal : Node_Id;
4103 begin
4104 Specs := Parameter_Specifications (N);
4106 if Is_Non_Empty_List (Specs) then
4107 Write_Str_With_Col_Check (" (");
4108 Spec := First (Specs);
4110 loop
4111 Sprint_Node (Spec);
4112 Formal := Defining_Identifier (Spec);
4113 Next (Spec);
4114 exit when Spec = Empty;
4116 -- Add semicolon, unless we are printing original tree and the
4117 -- next specification is part of a list (but not the first element
4118 -- of that list).
4120 if not Dump_Original_Only or else not Prev_Ids (Spec) then
4121 Write_Str ("; ");
4122 end if;
4123 end loop;
4125 -- Write out any extra formals
4127 while Present (Extra_Formal (Formal)) loop
4128 Formal := Extra_Formal (Formal);
4129 Write_Str ("; ");
4130 Write_Name_With_Col_Check (Chars (Formal));
4131 Write_Str (" : ");
4132 Write_Name_With_Col_Check (Chars (Etype (Formal)));
4133 end loop;
4135 Write_Char (')');
4136 end if;
4137 end Write_Param_Specs;
4139 -----------------------
4140 -- Write_Rewrite_Str --
4141 -----------------------
4143 procedure Write_Rewrite_Str (S : String) is
4144 begin
4145 if not Dump_Generated_Only then
4146 if S'Length = 3 and then S = ">>>" then
4147 Write_Str (">>>");
4148 else
4149 Write_Str_With_Col_Check (S);
4150 end if;
4151 end if;
4152 end Write_Rewrite_Str;
4154 -----------------------
4155 -- Write_Source_Line --
4156 -----------------------
4158 procedure Write_Source_Line (L : Physical_Line_Number) is
4159 Loc : Source_Ptr;
4160 Src : Source_Buffer_Ptr;
4161 Scn : Source_Ptr;
4163 begin
4164 if Dump_Source_Text then
4165 Src := Source_Text (Current_Source_File);
4166 Loc := Line_Start (L, Current_Source_File);
4167 Write_Eol;
4169 -- See if line is a comment line, if not, and if not line one,
4170 -- precede with blank line.
4172 Scn := Loc;
4173 while Src (Scn) = ' ' or else Src (Scn) = ASCII.HT loop
4174 Scn := Scn + 1;
4175 end loop;
4177 if (Src (Scn) in Line_Terminator
4178 or else Src (Scn .. Scn + 1) /= "--")
4179 and then L /= 1
4180 then
4181 Write_Eol;
4182 end if;
4184 -- Now write the source text of the line
4186 Write_Str ("-- ");
4187 Write_Int (Int (L));
4188 Write_Str (": ");
4190 while Src (Loc) not in Line_Terminator loop
4191 Write_Char (Src (Loc));
4192 Loc := Loc + 1;
4193 end loop;
4194 end if;
4195 end Write_Source_Line;
4197 ------------------------
4198 -- Write_Source_Lines --
4199 ------------------------
4201 procedure Write_Source_Lines (L : Physical_Line_Number) is
4202 begin
4203 while Last_Line_Printed < L loop
4204 Last_Line_Printed := Last_Line_Printed + 1;
4205 Write_Source_Line (Last_Line_Printed);
4206 end loop;
4207 end Write_Source_Lines;
4209 --------------------
4210 -- Write_Str_Sloc --
4211 --------------------
4213 procedure Write_Str_Sloc (S : String) is
4214 begin
4215 for J in S'Range loop
4216 Write_Char_Sloc (S (J));
4217 end loop;
4218 end Write_Str_Sloc;
4220 ------------------------------
4221 -- Write_Str_With_Col_Check --
4222 ------------------------------
4224 procedure Write_Str_With_Col_Check (S : String) is
4225 begin
4226 if Int (S'Last) + Column > Sprint_Line_Limit then
4227 Write_Indent_Str (" ");
4229 if S (S'First) = ' ' then
4230 Write_Str (S (S'First + 1 .. S'Last));
4231 else
4232 Write_Str (S);
4233 end if;
4235 else
4236 Write_Str (S);
4237 end if;
4238 end Write_Str_With_Col_Check;
4240 -----------------------------------
4241 -- Write_Str_With_Col_Check_Sloc --
4242 -----------------------------------
4244 procedure Write_Str_With_Col_Check_Sloc (S : String) is
4245 begin
4246 if Int (S'Last) + Column > Sprint_Line_Limit then
4247 Write_Indent_Str (" ");
4249 if S (S'First) = ' ' then
4250 Write_Str_Sloc (S (S'First + 1 .. S'Last));
4251 else
4252 Write_Str_Sloc (S);
4253 end if;
4255 else
4256 Write_Str_Sloc (S);
4257 end if;
4258 end Write_Str_With_Col_Check_Sloc;
4260 ---------------------------
4261 -- Write_Subprogram_Name --
4262 ---------------------------
4264 procedure Write_Subprogram_Name (N : Node_Id) is
4265 begin
4266 if not Comes_From_Source (N)
4267 and then Is_Entity_Name (N)
4268 then
4269 declare
4270 Ent : constant Entity_Id := Entity (N);
4271 begin
4272 if not In_Extended_Main_Source_Unit (Ent)
4273 and then
4274 Is_Predefined_File_Name
4275 (Unit_File_Name (Get_Source_Unit (Ent)))
4276 then
4277 -- Run-time routine name, output name with a preceding dollar
4278 -- making sure that we do not get a line split between them.
4280 Col_Check (Length_Of_Name (Chars (Ent)) + 1);
4281 Write_Char ('$');
4282 Write_Name (Chars (Ent));
4283 return;
4284 end if;
4285 end;
4286 end if;
4288 -- Normal case, not a run-time routine name
4290 Sprint_Node (N);
4291 end Write_Subprogram_Name;
4293 -------------------------------
4294 -- Write_Uint_With_Col_Check --
4295 -------------------------------
4297 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format) is
4298 begin
4299 Col_Check (UI_Decimal_Digits_Hi (U));
4300 UI_Write (U, Format);
4301 end Write_Uint_With_Col_Check;
4303 ------------------------------------
4304 -- Write_Uint_With_Col_Check_Sloc --
4305 ------------------------------------
4307 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
4308 begin
4309 Col_Check (UI_Decimal_Digits_Hi (U));
4310 Set_Debug_Sloc;
4311 UI_Write (U, Format);
4312 end Write_Uint_With_Col_Check_Sloc;
4314 -------------------------------------
4315 -- Write_Ureal_With_Col_Check_Sloc --
4316 -------------------------------------
4318 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
4319 D : constant Uint := Denominator (U);
4320 N : constant Uint := Numerator (U);
4322 begin
4323 Col_Check
4324 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
4325 Set_Debug_Sloc;
4326 UR_Write (U);
4327 end Write_Ureal_With_Col_Check_Sloc;
4329 end Sprint;