re PR fortran/42901 (reading array of structures from namelist fails)
[official-gcc.git] / gcc / ada / sprint.adb
blobcc9d5a081f118b4612fced867dcd23e8aeeebc50
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_Eval; use Sem_Eval;
39 with Sem_Util; use Sem_Util;
40 with Sinfo; use Sinfo;
41 with Sinput; use Sinput;
42 with Sinput.D; use Sinput.D;
43 with Snames; use Snames;
44 with Stand; use Stand;
45 with Stringt; use Stringt;
46 with Uintp; use Uintp;
47 with Uname; use Uname;
48 with Urealp; use Urealp;
50 package body Sprint is
51 Current_Source_File : Source_File_Index;
52 -- Index of source file whose generated code is being dumped
54 Dump_Node : Node_Id := Empty;
55 -- This is set to the current node, used for printing line numbers. In
56 -- Debug_Generated_Code mode, Dump_Node is set to the current node
57 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
58 -- value. The call clears it back to Empty.
60 Debug_Sloc : Source_Ptr;
61 -- Sloc of first byte of line currently being written if we are
62 -- generating a source debug file.
64 Dump_Original_Only : Boolean;
65 -- Set True if the -gnatdo (dump original tree) flag is set
67 Dump_Generated_Only : Boolean;
68 -- Set True if the -gnatG (dump generated tree) debug flag is set
69 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
71 Dump_Freeze_Null : Boolean;
72 -- Set True if freeze nodes and non-source null statements output
74 Freeze_Indent : Int := 0;
75 -- Keep track of freeze indent level (controls output of blank lines before
76 -- procedures within expression freeze actions). Relevant only if we are
77 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
78 -- output these blank lines in any case.
80 Indent : Int := 0;
81 -- Number of columns for current line output indentation
83 Indent_Annull_Flag : Boolean := False;
84 -- Set True if subsequent Write_Indent call to be ignored, gets reset
85 -- by this call, so it is only active to suppress a single indent call.
87 Last_Line_Printed : Physical_Line_Number;
88 -- This keeps track of the physical line number of the last source line
89 -- that has been output. The value is only valid in Dump_Source_Text mode.
91 -------------------------------
92 -- Operator Precedence Table --
93 -------------------------------
95 -- This table is used to decide whether a subexpression needs to be
96 -- parenthesized. The rule is that if an operand of an operator (which
97 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
98 -- with a lower precedence than the operator (or equal precedence if
99 -- appearing as the right operand), then parentheses are required.
101 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
102 (N_Op_And => 1,
103 N_Op_Or => 1,
104 N_Op_Xor => 1,
105 N_And_Then => 1,
106 N_Or_Else => 1,
108 N_In => 2,
109 N_Not_In => 2,
110 N_Op_Eq => 2,
111 N_Op_Ge => 2,
112 N_Op_Gt => 2,
113 N_Op_Le => 2,
114 N_Op_Lt => 2,
115 N_Op_Ne => 2,
117 N_Op_Add => 3,
118 N_Op_Concat => 3,
119 N_Op_Subtract => 3,
120 N_Op_Plus => 3,
121 N_Op_Minus => 3,
123 N_Op_Divide => 4,
124 N_Op_Mod => 4,
125 N_Op_Rem => 4,
126 N_Op_Multiply => 4,
128 N_Op_Expon => 5,
129 N_Op_Abs => 5,
130 N_Op_Not => 5,
132 others => 6);
134 procedure Sprint_Left_Opnd (N : Node_Id);
135 -- Print left operand of operator, parenthesizing if necessary
137 procedure Sprint_Right_Opnd (N : Node_Id);
138 -- Print right operand of operator, parenthesizing if necessary
140 -----------------------
141 -- Local Subprograms --
142 -----------------------
144 procedure Col_Check (N : Nat);
145 -- Check that at least N characters remain on current line, and if not,
146 -- then start an extra line with two characters extra indentation for
147 -- continuing text on the next line.
149 procedure Extra_Blank_Line;
150 -- In some situations we write extra blank lines to separate the generated
151 -- code to make it more readable. However, these extra blank lines are not
152 -- generated in Dump_Source_Text mode, since there the source text lines
153 -- output with preceding blank lines are quite sufficient as separators.
154 -- This procedure writes a blank line if Dump_Source_Text is False.
156 procedure Indent_Annull;
157 -- Causes following call to Write_Indent to be ignored. This is used when
158 -- a higher level node wants to stop a lower level node from starting a
159 -- new line, when it would otherwise be inclined to do so (e.g. the case
160 -- of an accept statement called from an accept alternative with a guard)
162 procedure Indent_Begin;
163 -- Increase indentation level
165 procedure Indent_End;
166 -- Decrease indentation level
168 procedure Print_Debug_Line (S : String);
169 -- Used to print output lines in Debug_Generated_Code mode (this is used
170 -- as the argument for a call to Set_Special_Output in package Output).
172 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
173 -- Given a divide, multiplication or division node, check the flags
174 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
175 -- appropriate special syntax characters (# and @).
177 procedure Set_Debug_Sloc;
178 -- If Dump_Node is non-empty, this routine sets the appropriate value
179 -- in its Sloc field, from the current location in the debug source file
180 -- that is currently being written.
182 procedure Sprint_And_List (List : List_Id);
183 -- Print the given list with items separated by vertical "and"
185 procedure Sprint_Bar_List (List : List_Id);
186 -- Print the given list with items separated by vertical bars
188 procedure Sprint_End_Label
189 (Node : Node_Id;
190 Default : Node_Id);
191 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
192 -- If there is not end label, use the defining identifier of the enclosing
193 -- construct. If the end label is present, treat it as a reference to the
194 -- defining entity of the construct: this guarantees that it carries the
195 -- proper sloc information for debugging purposes.
197 procedure Sprint_Node_Actual (Node : Node_Id);
198 -- This routine prints its node argument. It is a lower level routine than
199 -- Sprint_Node, in that it does not bother about rewritten trees.
201 procedure Sprint_Node_Sloc (Node : Node_Id);
202 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
203 -- sets the Sloc of the current debug node to be a copy of the Sloc
204 -- of the sprinted node Node. Note that this is done after printing
205 -- Node, so that the Sloc is the proper updated value for the debug file.
207 procedure Update_Itype (Node : Node_Id);
208 -- Update the Sloc of an itype that is not attached to the tree, when
209 -- debugging expanded code. This routine is called from nodes whose
210 -- type can be an Itype, such as defining_identifiers that may be of
211 -- an anonymous access type, or ranges in slices.
213 procedure Write_Char_Sloc (C : Character);
214 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
215 -- called to ensure that the current node has a proper Sloc set.
217 procedure Write_Condition_And_Reason (Node : Node_Id);
218 -- Write Condition and Reason codes of Raise_xxx_Error node
220 procedure Write_Corresponding_Source (S : String);
221 -- If S is a string with a single keyword (possibly followed by a space),
222 -- and if the next non-comment non-blank source line matches this keyword,
223 -- then output all source lines up to this matching line.
225 procedure Write_Discr_Specs (N : Node_Id);
226 -- Output discriminant specification for node, which is any of the type
227 -- declarations that can have discriminants.
229 procedure Write_Ekind (E : Entity_Id);
230 -- Write the String corresponding to the Ekind without "E_"
232 procedure Write_Id (N : Node_Id);
233 -- N is a node with a Chars field. This procedure writes the name that
234 -- will be used in the generated code associated with the name. For a
235 -- node with no associated entity, this is simply the Chars field. For
236 -- the case where there is an entity associated with the node, we print
237 -- the name associated with the entity (since it may have been encoded).
238 -- One other special case is that an entity has an active external name
239 -- (i.e. an external name present with no address clause), then this
240 -- external name is output. This procedure also deals with outputting
241 -- declarations of referenced itypes, if not output earlier.
243 function Write_Identifiers (Node : Node_Id) return Boolean;
244 -- Handle node where the grammar has a list of defining identifiers, but
245 -- the tree has a separate declaration for each identifier. Handles the
246 -- printing of the defining identifier, and returns True if the type and
247 -- initialization information is to be printed, False if it is to be
248 -- skipped (the latter case happens when printing defining identifiers
249 -- other than the first in the original tree output case).
251 procedure Write_Implicit_Def (E : Entity_Id);
252 pragma Warnings (Off, Write_Implicit_Def);
253 -- Write the definition of the implicit type E according to its Ekind
254 -- For now a debugging procedure, but might be used in the future.
256 procedure Write_Indent;
257 -- Start a new line and write indentation spacing
259 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
260 -- Like Write_Identifiers except that each new printed declaration
261 -- is at the start of a new line.
263 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
264 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
265 -- mode, the Sloc of the current debug node is set to point to the
266 -- first output identifier.
268 procedure Write_Indent_Str (S : String);
269 -- Start a new line and write indent spacing followed by given string
271 procedure Write_Indent_Str_Sloc (S : String);
272 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
273 -- the Sloc of the current node is set to the first non-blank character
274 -- in the string S.
276 procedure Write_Itype (Typ : Entity_Id);
277 -- If Typ is an Itype that has not been written yet, write it. If Typ is
278 -- any other kind of entity or tree node, the call is ignored.
280 procedure Write_Name_With_Col_Check (N : Name_Id);
281 -- Write name (using Write_Name) with initial column check, and possible
282 -- initial Write_Indent (to get new line) if current line is too full.
284 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
285 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
286 -- mode, sets Sloc of current debug node to first character of name.
288 procedure Write_Operator (N : Node_Id; S : String);
289 -- Like Write_Str_Sloc, used for operators, encloses the string in
290 -- characters {} if the Do_Overflow flag is set on the node N.
292 procedure Write_Param_Specs (N : Node_Id);
293 -- Output parameter specifications for node (which is either a function
294 -- or procedure specification with a Parameter_Specifications field)
296 procedure Write_Rewrite_Str (S : String);
297 -- Writes out a string (typically containing <<< or >>>}) for a node
298 -- created by rewriting the tree. Suppressed if we are outputting the
299 -- generated code only, since in this case we don't specially mark nodes
300 -- created by rewriting).
302 procedure Write_Source_Line (L : Physical_Line_Number);
303 -- If writing of interspersed source lines is enabled, then write the given
304 -- line from the source file, preceded by Eol, then an extra blank line if
305 -- the line has at least one blank, is not a comment and is not line one,
306 -- then "--" and the line number followed by period followed by text of the
307 -- source line (without terminating Eol). If interspersed source line
308 -- output not enabled, then the call has no effect.
310 procedure Write_Source_Lines (L : Physical_Line_Number);
311 -- If writing of interspersed source lines is enabled, then writes source
312 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
313 -- interspersed source line output not enabled, then call has no effect.
315 procedure Write_Str_Sloc (S : String);
316 -- Like Write_Str, but sets debug Sloc of current debug node to first
317 -- non-blank character if a current debug node is active.
319 procedure Write_Str_With_Col_Check (S : String);
320 -- Write string (using Write_Str) with initial column check, and possible
321 -- initial Write_Indent (to get new line) if current line is too full.
323 procedure Write_Str_With_Col_Check_Sloc (S : String);
324 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
325 -- node to first non-blank character if a current debug node is active.
327 procedure Write_Subprogram_Name (N : Node_Id);
328 -- N is the Name field of a function call or procedure statement call.
329 -- The effect of the call is to output the name, preceded by a $ if the
330 -- call is identified as an implicit call to a run time routine.
332 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format);
333 -- Write Uint (using UI_Write) with initial column check, and possible
334 -- initial Write_Indent (to get new line) if current line is too full.
335 -- The format parameter determines the output format (see UI_Write).
337 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
338 -- Write Uint (using UI_Write) with initial column check, and possible
339 -- initial Write_Indent (to get new line) if current line is too full.
340 -- The format parameter determines the output format (see UI_Write).
341 -- In addition, in Debug_Generated_Code mode, sets the current node
342 -- Sloc to the first character of the output value.
344 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
345 -- Write Ureal (using same output format as UR_Write) with column checks
346 -- and a possible initial Write_Indent (to get new line) if current line
347 -- is too full. In addition, in Debug_Generated_Code mode, sets the
348 -- current node Sloc to the first character of the output value.
350 ---------------
351 -- Col_Check --
352 ---------------
354 procedure Col_Check (N : Nat) is
355 begin
356 if N + Column > Sprint_Line_Limit then
357 Write_Indent_Str (" ");
358 end if;
359 end Col_Check;
361 ----------------------
362 -- Extra_Blank_Line --
363 ----------------------
365 procedure Extra_Blank_Line is
366 begin
367 if not Dump_Source_Text then
368 Write_Indent;
369 end if;
370 end Extra_Blank_Line;
372 -------------------
373 -- Indent_Annull --
374 -------------------
376 procedure Indent_Annull is
377 begin
378 Indent_Annull_Flag := True;
379 end Indent_Annull;
381 ------------------
382 -- Indent_Begin --
383 ------------------
385 procedure Indent_Begin is
386 begin
387 Indent := Indent + 3;
388 end Indent_Begin;
390 ----------------
391 -- Indent_End --
392 ----------------
394 procedure Indent_End is
395 begin
396 Indent := Indent - 3;
397 end Indent_End;
399 --------
400 -- pg --
401 --------
403 procedure pg (Arg : Union_Id) is
404 begin
405 Dump_Generated_Only := True;
406 Dump_Original_Only := False;
407 Current_Source_File := No_Source_File;
409 if Arg in List_Range then
410 Sprint_Node_List (List_Id (Arg));
412 elsif Arg in Node_Range then
413 Sprint_Node (Node_Id (Arg));
415 else
416 null;
417 end if;
419 Write_Eol;
420 end pg;
422 --------
423 -- po --
424 --------
426 procedure po (Arg : Union_Id) is
427 begin
428 Dump_Generated_Only := False;
429 Dump_Original_Only := True;
430 Current_Source_File := No_Source_File;
432 if Arg in List_Range then
433 Sprint_Node_List (List_Id (Arg));
435 elsif Arg in Node_Range then
436 Sprint_Node (Node_Id (Arg));
438 else
439 null;
440 end if;
442 Write_Eol;
443 end po;
445 ----------------------
446 -- Print_Debug_Line --
447 ----------------------
449 procedure Print_Debug_Line (S : String) is
450 begin
451 Write_Debug_Line (S, Debug_Sloc);
452 end Print_Debug_Line;
454 ---------------------------
455 -- Process_TFAI_RR_Flags --
456 ---------------------------
458 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
459 begin
460 if Treat_Fixed_As_Integer (Nod) then
461 Write_Char ('#');
462 end if;
464 if Rounded_Result (Nod) then
465 Write_Char ('@');
466 end if;
467 end Process_TFAI_RR_Flags;
469 --------
470 -- ps --
471 --------
473 procedure ps (Arg : Union_Id) is
474 begin
475 Dump_Generated_Only := False;
476 Dump_Original_Only := False;
477 Current_Source_File := No_Source_File;
479 if Arg in List_Range then
480 Sprint_Node_List (List_Id (Arg));
482 elsif Arg in Node_Range then
483 Sprint_Node (Node_Id (Arg));
485 else
486 null;
487 end if;
489 Write_Eol;
490 end ps;
492 --------------------
493 -- Set_Debug_Sloc --
494 --------------------
496 procedure Set_Debug_Sloc is
497 begin
498 if Debug_Generated_Code and then Present (Dump_Node) then
499 Set_Sloc (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1));
500 Dump_Node := Empty;
501 end if;
502 end Set_Debug_Sloc;
504 -----------------
505 -- Source_Dump --
506 -----------------
508 procedure Source_Dump is
510 procedure Underline;
511 -- Put underline under string we just printed
513 ---------------
514 -- Underline --
515 ---------------
517 procedure Underline is
518 Col : constant Int := Column;
520 begin
521 Write_Eol;
523 while Col > Column loop
524 Write_Char ('-');
525 end loop;
527 Write_Eol;
528 end Underline;
530 -- Start of processing for Source_Dump
532 begin
533 Dump_Generated_Only := Debug_Flag_G or
534 Print_Generated_Code or
535 Debug_Generated_Code;
536 Dump_Original_Only := Debug_Flag_O;
537 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
539 -- Note that we turn off the tree dump flags immediately, before
540 -- starting the dump. This avoids generating two copies of the dump
541 -- if an abort occurs after printing the dump, and more importantly,
542 -- avoids an infinite loop if an abort occurs during the dump.
544 if Debug_Flag_Z then
545 Current_Source_File := No_Source_File;
546 Debug_Flag_Z := False;
547 Write_Eol;
548 Write_Eol;
549 Write_Str ("Source recreated from tree of Standard (spec)");
550 Underline;
551 Sprint_Node (Standard_Package_Node);
552 Write_Eol;
553 Write_Eol;
554 end if;
556 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
557 Debug_Flag_G := False;
558 Debug_Flag_O := False;
559 Debug_Flag_S := False;
561 -- Dump requested units
563 for U in Main_Unit .. Last_Unit loop
564 Current_Source_File := Source_Index (U);
566 -- Dump all units if -gnatdf set, otherwise we dump only
567 -- the source files that are in the extended main source.
569 if Debug_Flag_F
570 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
571 then
572 -- If we are generating debug files, setup to write them
574 if Debug_Generated_Code then
575 Set_Special_Output (Print_Debug_Line'Access);
576 Create_Debug_Source (Source_Index (U), Debug_Sloc);
577 Write_Source_Line (1);
578 Last_Line_Printed := 1;
579 Sprint_Node (Cunit (U));
580 Write_Source_Lines (Last_Source_Line (Current_Source_File));
581 Write_Eol;
582 Close_Debug_Source;
583 Set_Special_Output (null);
585 -- Normal output to standard output file
587 else
588 Write_Str ("Source recreated from tree for ");
589 Write_Unit_Name (Unit_Name (U));
590 Underline;
591 Write_Source_Line (1);
592 Last_Line_Printed := 1;
593 Sprint_Node (Cunit (U));
594 Write_Source_Lines (Last_Source_Line (Current_Source_File));
595 Write_Eol;
596 Write_Eol;
597 end if;
598 end if;
599 end loop;
600 end if;
601 end Source_Dump;
603 ---------------------
604 -- Sprint_And_List --
605 ---------------------
607 procedure Sprint_And_List (List : List_Id) is
608 Node : Node_Id;
609 begin
610 if Is_Non_Empty_List (List) then
611 Node := First (List);
612 loop
613 Sprint_Node (Node);
614 Next (Node);
615 exit when Node = Empty;
616 Write_Str (" and ");
617 end loop;
618 end if;
619 end Sprint_And_List;
621 ---------------------
622 -- Sprint_Bar_List --
623 ---------------------
625 procedure Sprint_Bar_List (List : List_Id) is
626 Node : Node_Id;
627 begin
628 if Is_Non_Empty_List (List) then
629 Node := First (List);
630 loop
631 Sprint_Node (Node);
632 Next (Node);
633 exit when Node = Empty;
634 Write_Str (" | ");
635 end loop;
636 end if;
637 end Sprint_Bar_List;
639 ----------------------
640 -- Sprint_End_Label --
641 ----------------------
643 procedure Sprint_End_Label
644 (Node : Node_Id;
645 Default : Node_Id)
647 begin
648 if Present (Node)
649 and then Present (End_Label (Node))
650 and then Is_Entity_Name (End_Label (Node))
651 then
652 Set_Entity (End_Label (Node), Default);
654 -- For a function whose name is an operator, use the qualified name
655 -- created for the defining entity.
657 if Nkind (End_Label (Node)) = N_Operator_Symbol then
658 Set_Chars (End_Label (Node), Chars (Default));
659 end if;
661 Sprint_Node (End_Label (Node));
662 else
663 Sprint_Node (Default);
664 end if;
665 end Sprint_End_Label;
667 -----------------------
668 -- Sprint_Comma_List --
669 -----------------------
671 procedure Sprint_Comma_List (List : List_Id) is
672 Node : Node_Id;
674 begin
675 if Is_Non_Empty_List (List) then
676 Node := First (List);
677 loop
678 Sprint_Node (Node);
679 Next (Node);
680 exit when Node = Empty;
682 if not Is_Rewrite_Insertion (Node)
683 or else not Dump_Original_Only
684 then
685 Write_Str (", ");
686 end if;
687 end loop;
688 end if;
689 end Sprint_Comma_List;
691 --------------------------
692 -- Sprint_Indented_List --
693 --------------------------
695 procedure Sprint_Indented_List (List : List_Id) is
696 begin
697 Indent_Begin;
698 Sprint_Node_List (List);
699 Indent_End;
700 end Sprint_Indented_List;
702 ---------------------
703 -- Sprint_Left_Opnd --
704 ---------------------
706 procedure Sprint_Left_Opnd (N : Node_Id) is
707 Opnd : constant Node_Id := Left_Opnd (N);
709 begin
710 if Paren_Count (Opnd) /= 0
711 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
712 then
713 Sprint_Node (Opnd);
715 else
716 Write_Char ('(');
717 Sprint_Node (Opnd);
718 Write_Char (')');
719 end if;
720 end Sprint_Left_Opnd;
722 -----------------
723 -- Sprint_Node --
724 -----------------
726 procedure Sprint_Node (Node : Node_Id) is
727 begin
728 if Is_Rewrite_Insertion (Node) then
729 if not Dump_Original_Only then
731 -- For special cases of nodes that always output <<< >>>
732 -- do not duplicate the output at this point.
734 if Nkind (Node) = N_Freeze_Entity
735 or else Nkind (Node) = N_Implicit_Label_Declaration
736 then
737 Sprint_Node_Actual (Node);
739 -- Normal case where <<< >>> may be required
741 else
742 Write_Rewrite_Str ("<<<");
743 Sprint_Node_Actual (Node);
744 Write_Rewrite_Str (">>>");
745 end if;
746 end if;
748 elsif Is_Rewrite_Substitution (Node) then
750 -- Case of dump generated only
752 if Dump_Generated_Only then
753 Sprint_Node_Actual (Node);
755 -- Case of dump original only
757 elsif Dump_Original_Only then
758 Sprint_Node_Actual (Original_Node (Node));
760 -- Case of both being dumped
762 else
763 Sprint_Node_Actual (Original_Node (Node));
764 Write_Rewrite_Str ("<<<");
765 Sprint_Node_Actual (Node);
766 Write_Rewrite_Str (">>>");
767 end if;
769 else
770 Sprint_Node_Actual (Node);
771 end if;
772 end Sprint_Node;
774 ------------------------
775 -- Sprint_Node_Actual --
776 ------------------------
778 procedure Sprint_Node_Actual (Node : Node_Id) is
779 Save_Dump_Node : constant Node_Id := Dump_Node;
781 begin
782 if Node = Empty then
783 return;
784 end if;
786 for J in 1 .. Paren_Count (Node) loop
787 Write_Str_With_Col_Check ("(");
788 end loop;
790 -- Setup current dump node
792 Dump_Node := Node;
794 if Nkind (Node) in N_Subexpr
795 and then Do_Range_Check (Node)
796 then
797 Write_Str_With_Col_Check ("{");
798 end if;
800 -- Select print circuit based on node kind
802 case Nkind (Node) is
804 when N_Abort_Statement =>
805 Write_Indent_Str_Sloc ("abort ");
806 Sprint_Comma_List (Names (Node));
807 Write_Char (';');
809 when N_Abortable_Part =>
810 Set_Debug_Sloc;
811 Write_Str_Sloc ("abort ");
812 Sprint_Indented_List (Statements (Node));
814 when N_Abstract_Subprogram_Declaration =>
815 Write_Indent;
816 Sprint_Node (Specification (Node));
817 Write_Str_With_Col_Check (" is ");
818 Write_Str_Sloc ("abstract;");
820 when N_Accept_Alternative =>
821 Sprint_Node_List (Pragmas_Before (Node));
823 if Present (Condition (Node)) then
824 Write_Indent_Str ("when ");
825 Sprint_Node (Condition (Node));
826 Write_Str (" => ");
827 Indent_Annull;
828 end if;
830 Sprint_Node_Sloc (Accept_Statement (Node));
831 Sprint_Node_List (Statements (Node));
833 when N_Accept_Statement =>
834 Write_Indent_Str_Sloc ("accept ");
835 Write_Id (Entry_Direct_Name (Node));
837 if Present (Entry_Index (Node)) then
838 Write_Str_With_Col_Check (" (");
839 Sprint_Node (Entry_Index (Node));
840 Write_Char (')');
841 end if;
843 Write_Param_Specs (Node);
845 if Present (Handled_Statement_Sequence (Node)) then
846 Write_Str_With_Col_Check (" do");
847 Sprint_Node (Handled_Statement_Sequence (Node));
848 Write_Indent_Str ("end ");
849 Write_Id (Entry_Direct_Name (Node));
850 end if;
852 Write_Char (';');
854 when N_Access_Definition =>
856 -- Ada 2005 (AI-254)
858 if Present (Access_To_Subprogram_Definition (Node)) then
859 Sprint_Node (Access_To_Subprogram_Definition (Node));
860 else
861 -- Ada 2005 (AI-231)
863 if Null_Exclusion_Present (Node) then
864 Write_Str ("not null ");
865 end if;
867 Write_Str_With_Col_Check_Sloc ("access ");
869 if All_Present (Node) then
870 Write_Str ("all ");
871 elsif Constant_Present (Node) then
872 Write_Str ("constant ");
873 end if;
875 Sprint_Node (Subtype_Mark (Node));
876 end if;
878 when N_Access_Function_Definition =>
880 -- Ada 2005 (AI-231)
882 if Null_Exclusion_Present (Node) then
883 Write_Str ("not null ");
884 end if;
886 Write_Str_With_Col_Check_Sloc ("access ");
888 if Protected_Present (Node) then
889 Write_Str_With_Col_Check ("protected ");
890 end if;
892 Write_Str_With_Col_Check ("function");
893 Write_Param_Specs (Node);
894 Write_Str_With_Col_Check (" return ");
895 Sprint_Node (Result_Definition (Node));
897 when N_Access_Procedure_Definition =>
899 -- Ada 2005 (AI-231)
901 if Null_Exclusion_Present (Node) then
902 Write_Str ("not null ");
903 end if;
905 Write_Str_With_Col_Check_Sloc ("access ");
907 if Protected_Present (Node) then
908 Write_Str_With_Col_Check ("protected ");
909 end if;
911 Write_Str_With_Col_Check ("procedure");
912 Write_Param_Specs (Node);
914 when N_Access_To_Object_Definition =>
915 Write_Str_With_Col_Check_Sloc ("access ");
917 if All_Present (Node) then
918 Write_Str_With_Col_Check ("all ");
919 elsif Constant_Present (Node) then
920 Write_Str_With_Col_Check ("constant ");
921 end if;
923 -- Ada 2005 (AI-231)
925 if Null_Exclusion_Present (Node) then
926 Write_Str ("not null ");
927 end if;
929 Sprint_Node (Subtype_Indication (Node));
931 when N_Aggregate =>
932 if Null_Record_Present (Node) then
933 Write_Str_With_Col_Check_Sloc ("(null record)");
935 else
936 Write_Str_With_Col_Check_Sloc ("(");
938 if Present (Expressions (Node)) then
939 Sprint_Comma_List (Expressions (Node));
941 if Present (Component_Associations (Node))
942 and then not Is_Empty_List (Component_Associations (Node))
943 then
944 Write_Str (", ");
945 end if;
946 end if;
948 if Present (Component_Associations (Node))
949 and then not Is_Empty_List (Component_Associations (Node))
950 then
951 Indent_Begin;
953 declare
954 Nd : Node_Id;
956 begin
957 Nd := First (Component_Associations (Node));
959 loop
960 Write_Indent;
961 Sprint_Node (Nd);
962 Next (Nd);
963 exit when No (Nd);
965 if not Is_Rewrite_Insertion (Nd)
966 or else not Dump_Original_Only
967 then
968 Write_Str (", ");
969 end if;
970 end loop;
971 end;
973 Indent_End;
974 end if;
976 Write_Char (')');
977 end if;
979 when N_Allocator =>
980 Write_Str_With_Col_Check_Sloc ("new ");
982 -- Ada 2005 (AI-231)
984 if Null_Exclusion_Present (Node) then
985 Write_Str ("not null ");
986 end if;
988 Sprint_Node (Expression (Node));
990 if Present (Storage_Pool (Node)) then
991 Write_Str_With_Col_Check ("[storage_pool = ");
992 Sprint_Node (Storage_Pool (Node));
993 Write_Char (']');
994 end if;
996 when N_And_Then =>
997 Sprint_Left_Opnd (Node);
998 Write_Str_Sloc (" and then ");
999 Sprint_Right_Opnd (Node);
1001 when N_At_Clause =>
1002 Write_Indent_Str_Sloc ("for ");
1003 Write_Id (Identifier (Node));
1004 Write_Str_With_Col_Check (" use at ");
1005 Sprint_Node (Expression (Node));
1006 Write_Char (';');
1008 when N_Assignment_Statement =>
1009 Write_Indent;
1010 Sprint_Node (Name (Node));
1011 Write_Str_Sloc (" := ");
1012 Sprint_Node (Expression (Node));
1013 Write_Char (';');
1015 when N_Asynchronous_Select =>
1016 Write_Indent_Str_Sloc ("select");
1017 Indent_Begin;
1018 Sprint_Node (Triggering_Alternative (Node));
1019 Indent_End;
1021 -- Note: let the printing of Abortable_Part handle outputting
1022 -- the ABORT keyword, so that the Sloc can be set correctly.
1024 Write_Indent_Str ("then ");
1025 Sprint_Node (Abortable_Part (Node));
1026 Write_Indent_Str ("end select;");
1028 when N_Attribute_Definition_Clause =>
1029 Write_Indent_Str_Sloc ("for ");
1030 Sprint_Node (Name (Node));
1031 Write_Char (''');
1032 Write_Name_With_Col_Check (Chars (Node));
1033 Write_Str_With_Col_Check (" use ");
1034 Sprint_Node (Expression (Node));
1035 Write_Char (';');
1037 when N_Attribute_Reference =>
1038 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1039 Write_Indent;
1040 end if;
1042 Sprint_Node (Prefix (Node));
1043 Write_Char_Sloc (''');
1044 Write_Name_With_Col_Check (Attribute_Name (Node));
1045 Sprint_Paren_Comma_List (Expressions (Node));
1047 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1048 Write_Char (';');
1049 end if;
1051 when N_Block_Statement =>
1052 Write_Indent;
1054 if Present (Identifier (Node))
1055 and then (not Has_Created_Identifier (Node)
1056 or else not Dump_Original_Only)
1057 then
1058 Write_Rewrite_Str ("<<<");
1059 Write_Id (Identifier (Node));
1060 Write_Str (" : ");
1061 Write_Rewrite_Str (">>>");
1062 end if;
1064 if Present (Declarations (Node)) then
1065 Write_Str_With_Col_Check_Sloc ("declare");
1066 Sprint_Indented_List (Declarations (Node));
1067 Write_Indent;
1068 end if;
1070 Write_Str_With_Col_Check_Sloc ("begin");
1071 Sprint_Node (Handled_Statement_Sequence (Node));
1072 Write_Indent_Str ("end");
1074 if Present (Identifier (Node))
1075 and then (not Has_Created_Identifier (Node)
1076 or else not Dump_Original_Only)
1077 then
1078 Write_Rewrite_Str ("<<<");
1079 Write_Char (' ');
1080 Write_Id (Identifier (Node));
1081 Write_Rewrite_Str (">>>");
1082 end if;
1084 Write_Char (';');
1086 when N_Case_Statement =>
1087 Write_Indent_Str_Sloc ("case ");
1088 Sprint_Node (Expression (Node));
1089 Write_Str (" is");
1090 Sprint_Indented_List (Alternatives (Node));
1091 Write_Indent_Str ("end case;");
1093 when N_Case_Statement_Alternative =>
1094 Write_Indent_Str_Sloc ("when ");
1095 Sprint_Bar_List (Discrete_Choices (Node));
1096 Write_Str (" => ");
1097 Sprint_Indented_List (Statements (Node));
1099 when N_Character_Literal =>
1100 if Column > Sprint_Line_Limit - 2 then
1101 Write_Indent_Str (" ");
1102 end if;
1104 Write_Char_Sloc (''');
1105 Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
1106 Write_Char (''');
1108 when N_Code_Statement =>
1109 Write_Indent;
1110 Set_Debug_Sloc;
1111 Sprint_Node (Expression (Node));
1112 Write_Char (';');
1114 when N_Compilation_Unit =>
1115 Sprint_Node_List (Context_Items (Node));
1116 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
1118 if Private_Present (Node) then
1119 Write_Indent_Str ("private ");
1120 Indent_Annull;
1121 end if;
1123 Sprint_Node_Sloc (Unit (Node));
1125 if Present (Actions (Aux_Decls_Node (Node)))
1126 or else
1127 Present (Pragmas_After (Aux_Decls_Node (Node)))
1128 then
1129 Write_Indent;
1130 end if;
1132 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
1133 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
1135 when N_Compilation_Unit_Aux =>
1136 null; -- nothing to do, never used, see above
1138 when N_Component_Association =>
1139 Set_Debug_Sloc;
1140 Sprint_Bar_List (Choices (Node));
1141 Write_Str (" => ");
1143 -- Ada 2005 (AI-287): Print the box if present
1145 if Box_Present (Node) then
1146 Write_Str_With_Col_Check ("<>");
1147 else
1148 Sprint_Node (Expression (Node));
1149 end if;
1151 when N_Component_Clause =>
1152 Write_Indent;
1153 Sprint_Node (Component_Name (Node));
1154 Write_Str_Sloc (" at ");
1155 Sprint_Node (Position (Node));
1156 Write_Char (' ');
1157 Write_Str_With_Col_Check ("range ");
1158 Sprint_Node (First_Bit (Node));
1159 Write_Str (" .. ");
1160 Sprint_Node (Last_Bit (Node));
1161 Write_Char (';');
1163 when N_Component_Definition =>
1164 Set_Debug_Sloc;
1166 -- Ada 2005 (AI-230): Access definition components
1168 if Present (Access_Definition (Node)) then
1169 Sprint_Node (Access_Definition (Node));
1171 elsif Present (Subtype_Indication (Node)) then
1172 if Aliased_Present (Node) then
1173 Write_Str_With_Col_Check ("aliased ");
1174 end if;
1176 -- Ada 2005 (AI-231)
1178 if Null_Exclusion_Present (Node) then
1179 Write_Str (" not null ");
1180 end if;
1182 Sprint_Node (Subtype_Indication (Node));
1184 else
1185 Write_Str (" ??? ");
1186 end if;
1188 when N_Component_Declaration =>
1189 if Write_Indent_Identifiers_Sloc (Node) then
1190 Write_Str (" : ");
1191 Sprint_Node (Component_Definition (Node));
1193 if Present (Expression (Node)) then
1194 Write_Str (" := ");
1195 Sprint_Node (Expression (Node));
1196 end if;
1198 Write_Char (';');
1199 end if;
1201 when N_Component_List =>
1202 if Null_Present (Node) then
1203 Indent_Begin;
1204 Write_Indent_Str_Sloc ("null");
1205 Write_Char (';');
1206 Indent_End;
1208 else
1209 Set_Debug_Sloc;
1210 Sprint_Indented_List (Component_Items (Node));
1211 Sprint_Node (Variant_Part (Node));
1212 end if;
1214 when N_Conditional_Entry_Call =>
1215 Write_Indent_Str_Sloc ("select");
1216 Indent_Begin;
1217 Sprint_Node (Entry_Call_Alternative (Node));
1218 Indent_End;
1219 Write_Indent_Str ("else");
1220 Sprint_Indented_List (Else_Statements (Node));
1221 Write_Indent_Str ("end select;");
1223 when N_Conditional_Expression =>
1224 declare
1225 Condition : constant Node_Id := First (Expressions (Node));
1226 Then_Expr : constant Node_Id := Next (Condition);
1227 Else_Expr : constant Node_Id := Next (Then_Expr);
1228 begin
1229 Write_Str_With_Col_Check_Sloc ("(if ");
1230 Sprint_Node (Condition);
1231 Write_Str_With_Col_Check (" then ");
1232 Sprint_Node (Then_Expr);
1233 Write_Str_With_Col_Check (" else ");
1234 Sprint_Node (Else_Expr);
1235 Write_Char (')');
1236 end;
1238 when N_Constrained_Array_Definition =>
1239 Write_Str_With_Col_Check_Sloc ("array ");
1240 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1241 Write_Str (" of ");
1243 Sprint_Node (Component_Definition (Node));
1245 when N_Decimal_Fixed_Point_Definition =>
1246 Write_Str_With_Col_Check_Sloc (" delta ");
1247 Sprint_Node (Delta_Expression (Node));
1248 Write_Str_With_Col_Check ("digits ");
1249 Sprint_Node (Digits_Expression (Node));
1250 Sprint_Opt_Node (Real_Range_Specification (Node));
1252 when N_Defining_Character_Literal =>
1253 Write_Name_With_Col_Check_Sloc (Chars (Node));
1255 when N_Defining_Identifier =>
1256 Set_Debug_Sloc;
1257 Write_Id (Node);
1259 when N_Defining_Operator_Symbol =>
1260 Write_Name_With_Col_Check_Sloc (Chars (Node));
1262 when N_Defining_Program_Unit_Name =>
1263 Set_Debug_Sloc;
1264 Sprint_Node (Name (Node));
1265 Write_Char ('.');
1266 Write_Id (Defining_Identifier (Node));
1268 when N_Delay_Alternative =>
1269 Sprint_Node_List (Pragmas_Before (Node));
1271 if Present (Condition (Node)) then
1272 Write_Indent;
1273 Write_Str_With_Col_Check ("when ");
1274 Sprint_Node (Condition (Node));
1275 Write_Str (" => ");
1276 Indent_Annull;
1277 end if;
1279 Sprint_Node_Sloc (Delay_Statement (Node));
1280 Sprint_Node_List (Statements (Node));
1282 when N_Delay_Relative_Statement =>
1283 Write_Indent_Str_Sloc ("delay ");
1284 Sprint_Node (Expression (Node));
1285 Write_Char (';');
1287 when N_Delay_Until_Statement =>
1288 Write_Indent_Str_Sloc ("delay until ");
1289 Sprint_Node (Expression (Node));
1290 Write_Char (';');
1292 when N_Delta_Constraint =>
1293 Write_Str_With_Col_Check_Sloc ("delta ");
1294 Sprint_Node (Delta_Expression (Node));
1295 Sprint_Opt_Node (Range_Constraint (Node));
1297 when N_Derived_Type_Definition =>
1298 if Abstract_Present (Node) then
1299 Write_Str_With_Col_Check ("abstract ");
1300 end if;
1302 Write_Str_With_Col_Check_Sloc ("new ");
1304 -- Ada 2005 (AI-231)
1306 if Null_Exclusion_Present (Node) then
1307 Write_Str_With_Col_Check ("not null ");
1308 end if;
1310 Sprint_Node (Subtype_Indication (Node));
1312 if Present (Interface_List (Node)) then
1313 Write_Str_With_Col_Check (" and ");
1314 Sprint_And_List (Interface_List (Node));
1315 Write_Str_With_Col_Check (" with ");
1316 end if;
1318 if Present (Record_Extension_Part (Node)) then
1319 if No (Interface_List (Node)) then
1320 Write_Str_With_Col_Check (" with ");
1321 end if;
1323 Sprint_Node (Record_Extension_Part (Node));
1324 end if;
1326 when N_Designator =>
1327 Sprint_Node (Name (Node));
1328 Write_Char_Sloc ('.');
1329 Write_Id (Identifier (Node));
1331 when N_Digits_Constraint =>
1332 Write_Str_With_Col_Check_Sloc ("digits ");
1333 Sprint_Node (Digits_Expression (Node));
1334 Sprint_Opt_Node (Range_Constraint (Node));
1336 when N_Discriminant_Association =>
1337 Set_Debug_Sloc;
1339 if Present (Selector_Names (Node)) then
1340 Sprint_Bar_List (Selector_Names (Node));
1341 Write_Str (" => ");
1342 end if;
1344 Set_Debug_Sloc;
1345 Sprint_Node (Expression (Node));
1347 when N_Discriminant_Specification =>
1348 Set_Debug_Sloc;
1350 if Write_Identifiers (Node) then
1351 Write_Str (" : ");
1353 if Null_Exclusion_Present (Node) then
1354 Write_Str ("not null ");
1355 end if;
1357 Sprint_Node (Discriminant_Type (Node));
1359 if Present (Expression (Node)) then
1360 Write_Str (" := ");
1361 Sprint_Node (Expression (Node));
1362 end if;
1363 else
1364 Write_Str (", ");
1365 end if;
1367 when N_Elsif_Part =>
1368 Write_Indent_Str_Sloc ("elsif ");
1369 Sprint_Node (Condition (Node));
1370 Write_Str_With_Col_Check (" then");
1371 Sprint_Indented_List (Then_Statements (Node));
1373 when N_Empty =>
1374 null;
1376 when N_Entry_Body =>
1377 Write_Indent_Str_Sloc ("entry ");
1378 Write_Id (Defining_Identifier (Node));
1379 Sprint_Node (Entry_Body_Formal_Part (Node));
1380 Write_Str_With_Col_Check (" is");
1381 Sprint_Indented_List (Declarations (Node));
1382 Write_Indent_Str ("begin");
1383 Sprint_Node (Handled_Statement_Sequence (Node));
1384 Write_Indent_Str ("end ");
1385 Write_Id (Defining_Identifier (Node));
1386 Write_Char (';');
1388 when N_Entry_Body_Formal_Part =>
1389 if Present (Entry_Index_Specification (Node)) then
1390 Write_Str_With_Col_Check_Sloc (" (");
1391 Sprint_Node (Entry_Index_Specification (Node));
1392 Write_Char (')');
1393 end if;
1395 Write_Param_Specs (Node);
1396 Write_Str_With_Col_Check_Sloc (" when ");
1397 Sprint_Node (Condition (Node));
1399 when N_Entry_Call_Alternative =>
1400 Sprint_Node_List (Pragmas_Before (Node));
1401 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1402 Sprint_Node_List (Statements (Node));
1404 when N_Entry_Call_Statement =>
1405 Write_Indent;
1406 Sprint_Node_Sloc (Name (Node));
1407 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1408 Write_Char (';');
1410 when N_Entry_Declaration =>
1411 Write_Indent_Str_Sloc ("entry ");
1412 Write_Id (Defining_Identifier (Node));
1414 if Present (Discrete_Subtype_Definition (Node)) then
1415 Write_Str_With_Col_Check (" (");
1416 Sprint_Node (Discrete_Subtype_Definition (Node));
1417 Write_Char (')');
1418 end if;
1420 Write_Param_Specs (Node);
1421 Write_Char (';');
1423 when N_Entry_Index_Specification =>
1424 Write_Str_With_Col_Check_Sloc ("for ");
1425 Write_Id (Defining_Identifier (Node));
1426 Write_Str_With_Col_Check (" in ");
1427 Sprint_Node (Discrete_Subtype_Definition (Node));
1429 when N_Enumeration_Representation_Clause =>
1430 Write_Indent_Str_Sloc ("for ");
1431 Write_Id (Identifier (Node));
1432 Write_Str_With_Col_Check (" use ");
1433 Sprint_Node (Array_Aggregate (Node));
1434 Write_Char (';');
1436 when N_Enumeration_Type_Definition =>
1437 Set_Debug_Sloc;
1439 -- Skip attempt to print Literals field if it's not there and
1440 -- we are in package Standard (case of Character, which is
1441 -- handled specially (without an explicit literals list).
1443 if Sloc (Node) > Standard_Location
1444 or else Present (Literals (Node))
1445 then
1446 Sprint_Paren_Comma_List (Literals (Node));
1447 end if;
1449 when N_Error =>
1450 Write_Str_With_Col_Check_Sloc ("<error>");
1452 when N_Exception_Declaration =>
1453 if Write_Indent_Identifiers (Node) then
1454 Write_Str_With_Col_Check (" : ");
1456 if Is_Statically_Allocated (Defining_Identifier (Node)) then
1457 Write_Str_With_Col_Check ("static ");
1458 end if;
1460 Write_Str_Sloc ("exception");
1462 if Present (Expression (Node)) then
1463 Write_Str (" := ");
1464 Sprint_Node (Expression (Node));
1465 end if;
1467 Write_Char (';');
1468 end if;
1470 when N_Exception_Handler =>
1471 Write_Indent_Str_Sloc ("when ");
1473 if Present (Choice_Parameter (Node)) then
1474 Sprint_Node (Choice_Parameter (Node));
1475 Write_Str (" : ");
1476 end if;
1478 Sprint_Bar_List (Exception_Choices (Node));
1479 Write_Str (" => ");
1480 Sprint_Indented_List (Statements (Node));
1482 when N_Exception_Renaming_Declaration =>
1483 Write_Indent;
1484 Set_Debug_Sloc;
1485 Sprint_Node (Defining_Identifier (Node));
1486 Write_Str_With_Col_Check (" : exception renames ");
1487 Sprint_Node (Name (Node));
1488 Write_Char (';');
1490 when N_Exit_Statement =>
1491 Write_Indent_Str_Sloc ("exit");
1492 Sprint_Opt_Node (Name (Node));
1494 if Present (Condition (Node)) then
1495 Write_Str_With_Col_Check (" when ");
1496 Sprint_Node (Condition (Node));
1497 end if;
1499 Write_Char (';');
1501 when N_Expanded_Name =>
1502 Sprint_Node (Prefix (Node));
1503 Write_Char_Sloc ('.');
1504 Sprint_Node (Selector_Name (Node));
1506 when N_Explicit_Dereference =>
1507 Sprint_Node (Prefix (Node));
1508 Write_Char_Sloc ('.');
1509 Write_Str_Sloc ("all");
1511 when N_Extended_Return_Statement =>
1512 Write_Indent_Str_Sloc ("return ");
1513 Sprint_Node_List (Return_Object_Declarations (Node));
1515 if Present (Handled_Statement_Sequence (Node)) then
1516 Write_Str_With_Col_Check (" do");
1517 Sprint_Node (Handled_Statement_Sequence (Node));
1518 Write_Indent_Str ("end return;");
1519 else
1520 Write_Indent_Str (";");
1521 end if;
1523 when N_Extension_Aggregate =>
1524 Write_Str_With_Col_Check_Sloc ("(");
1525 Sprint_Node (Ancestor_Part (Node));
1526 Write_Str_With_Col_Check (" with ");
1528 if Null_Record_Present (Node) then
1529 Write_Str_With_Col_Check ("null record");
1530 else
1531 if Present (Expressions (Node)) then
1532 Sprint_Comma_List (Expressions (Node));
1534 if Present (Component_Associations (Node)) then
1535 Write_Str (", ");
1536 end if;
1537 end if;
1539 if Present (Component_Associations (Node)) then
1540 Sprint_Comma_List (Component_Associations (Node));
1541 end if;
1542 end if;
1544 Write_Char (')');
1546 when N_Floating_Point_Definition =>
1547 Write_Str_With_Col_Check_Sloc ("digits ");
1548 Sprint_Node (Digits_Expression (Node));
1549 Sprint_Opt_Node (Real_Range_Specification (Node));
1551 when N_Formal_Decimal_Fixed_Point_Definition =>
1552 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1554 when N_Formal_Derived_Type_Definition =>
1555 Write_Str_With_Col_Check_Sloc ("new ");
1556 Sprint_Node (Subtype_Mark (Node));
1558 if Present (Interface_List (Node)) then
1559 Write_Str_With_Col_Check (" and ");
1560 Sprint_And_List (Interface_List (Node));
1561 end if;
1563 if Private_Present (Node) then
1564 Write_Str_With_Col_Check (" with private");
1565 end if;
1567 when N_Formal_Abstract_Subprogram_Declaration =>
1568 Write_Indent_Str_Sloc ("with ");
1569 Sprint_Node (Specification (Node));
1571 Write_Str_With_Col_Check (" is abstract");
1573 if Box_Present (Node) then
1574 Write_Str_With_Col_Check (" <>");
1575 elsif Present (Default_Name (Node)) then
1576 Write_Str_With_Col_Check (" ");
1577 Sprint_Node (Default_Name (Node));
1578 end if;
1580 Write_Char (';');
1582 when N_Formal_Concrete_Subprogram_Declaration =>
1583 Write_Indent_Str_Sloc ("with ");
1584 Sprint_Node (Specification (Node));
1586 if Box_Present (Node) then
1587 Write_Str_With_Col_Check (" is <>");
1588 elsif Present (Default_Name (Node)) then
1589 Write_Str_With_Col_Check (" is ");
1590 Sprint_Node (Default_Name (Node));
1591 end if;
1593 Write_Char (';');
1595 when N_Formal_Discrete_Type_Definition =>
1596 Write_Str_With_Col_Check_Sloc ("<>");
1598 when N_Formal_Floating_Point_Definition =>
1599 Write_Str_With_Col_Check_Sloc ("digits <>");
1601 when N_Formal_Modular_Type_Definition =>
1602 Write_Str_With_Col_Check_Sloc ("mod <>");
1604 when N_Formal_Object_Declaration =>
1605 Set_Debug_Sloc;
1607 if Write_Indent_Identifiers (Node) then
1608 Write_Str (" : ");
1610 if In_Present (Node) then
1611 Write_Str_With_Col_Check ("in ");
1612 end if;
1614 if Out_Present (Node) then
1615 Write_Str_With_Col_Check ("out ");
1616 end if;
1618 if Present (Subtype_Mark (Node)) then
1620 -- Ada 2005 (AI-423): Formal object with null exclusion
1622 if Null_Exclusion_Present (Node) then
1623 Write_Str ("not null ");
1624 end if;
1626 Sprint_Node (Subtype_Mark (Node));
1628 -- Ada 2005 (AI-423): Formal object with access definition
1630 else
1631 pragma Assert (Present (Access_Definition (Node)));
1633 Sprint_Node (Access_Definition (Node));
1634 end if;
1636 if Present (Default_Expression (Node)) then
1637 Write_Str (" := ");
1638 Sprint_Node (Default_Expression (Node));
1639 end if;
1641 Write_Char (';');
1642 end if;
1644 when N_Formal_Ordinary_Fixed_Point_Definition =>
1645 Write_Str_With_Col_Check_Sloc ("delta <>");
1647 when N_Formal_Package_Declaration =>
1648 Write_Indent_Str_Sloc ("with package ");
1649 Write_Id (Defining_Identifier (Node));
1650 Write_Str_With_Col_Check (" is new ");
1651 Sprint_Node (Name (Node));
1652 Write_Str_With_Col_Check (" (<>);");
1654 when N_Formal_Private_Type_Definition =>
1655 if Abstract_Present (Node) then
1656 Write_Str_With_Col_Check ("abstract ");
1657 end if;
1659 if Tagged_Present (Node) then
1660 Write_Str_With_Col_Check ("tagged ");
1661 end if;
1663 if Limited_Present (Node) then
1664 Write_Str_With_Col_Check ("limited ");
1665 end if;
1667 Write_Str_With_Col_Check_Sloc ("private");
1669 when N_Formal_Signed_Integer_Type_Definition =>
1670 Write_Str_With_Col_Check_Sloc ("range <>");
1672 when N_Formal_Type_Declaration =>
1673 Write_Indent_Str_Sloc ("type ");
1674 Write_Id (Defining_Identifier (Node));
1676 if Present (Discriminant_Specifications (Node)) then
1677 Write_Discr_Specs (Node);
1678 elsif Unknown_Discriminants_Present (Node) then
1679 Write_Str_With_Col_Check ("(<>)");
1680 end if;
1682 Write_Str_With_Col_Check (" is ");
1683 Sprint_Node (Formal_Type_Definition (Node));
1684 Write_Char (';');
1686 when N_Free_Statement =>
1687 Write_Indent_Str_Sloc ("free ");
1688 Sprint_Node (Expression (Node));
1689 Write_Char (';');
1691 when N_Freeze_Entity =>
1692 if Dump_Original_Only then
1693 null;
1695 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1696 Write_Indent;
1697 Write_Rewrite_Str ("<<<");
1698 Write_Str_With_Col_Check_Sloc ("freeze ");
1699 Write_Id (Entity (Node));
1700 Write_Str (" [");
1702 if No (Actions (Node)) then
1703 Write_Char (']');
1705 else
1706 -- Output freeze actions. We increment Freeze_Indent during
1707 -- this output to avoid generating extra blank lines before
1708 -- any procedures included in the freeze actions.
1710 Freeze_Indent := Freeze_Indent + 1;
1711 Sprint_Indented_List (Actions (Node));
1712 Freeze_Indent := Freeze_Indent - 1;
1713 Write_Indent_Str ("]");
1714 end if;
1716 Write_Rewrite_Str (">>>");
1717 end if;
1719 when N_Full_Type_Declaration =>
1720 Write_Indent_Str_Sloc ("type ");
1721 Sprint_Node (Defining_Identifier (Node));
1722 Write_Discr_Specs (Node);
1723 Write_Str_With_Col_Check (" is ");
1724 Sprint_Node (Type_Definition (Node));
1725 Write_Char (';');
1727 when N_Function_Call =>
1728 Set_Debug_Sloc;
1729 Write_Subprogram_Name (Name (Node));
1730 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1732 when N_Function_Instantiation =>
1733 Write_Indent_Str_Sloc ("function ");
1734 Sprint_Node (Defining_Unit_Name (Node));
1735 Write_Str_With_Col_Check (" is new ");
1736 Sprint_Node (Name (Node));
1737 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1738 Write_Char (';');
1740 when N_Function_Specification =>
1741 Write_Str_With_Col_Check_Sloc ("function ");
1742 Sprint_Node (Defining_Unit_Name (Node));
1743 Write_Param_Specs (Node);
1744 Write_Str_With_Col_Check (" return ");
1746 -- Ada 2005 (AI-231)
1748 if Nkind (Result_Definition (Node)) /= N_Access_Definition
1749 and then Null_Exclusion_Present (Node)
1750 then
1751 Write_Str (" not null ");
1752 end if;
1754 Sprint_Node (Result_Definition (Node));
1756 when N_Generic_Association =>
1757 Set_Debug_Sloc;
1759 if Present (Selector_Name (Node)) then
1760 Sprint_Node (Selector_Name (Node));
1761 Write_Str (" => ");
1762 end if;
1764 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1766 when N_Generic_Function_Renaming_Declaration =>
1767 Write_Indent_Str_Sloc ("generic function ");
1768 Sprint_Node (Defining_Unit_Name (Node));
1769 Write_Str_With_Col_Check (" renames ");
1770 Sprint_Node (Name (Node));
1771 Write_Char (';');
1773 when N_Generic_Package_Declaration =>
1774 Extra_Blank_Line;
1775 Write_Indent_Str_Sloc ("generic ");
1776 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1777 Write_Indent;
1778 Sprint_Node (Specification (Node));
1779 Write_Char (';');
1781 when N_Generic_Package_Renaming_Declaration =>
1782 Write_Indent_Str_Sloc ("generic package ");
1783 Sprint_Node (Defining_Unit_Name (Node));
1784 Write_Str_With_Col_Check (" renames ");
1785 Sprint_Node (Name (Node));
1786 Write_Char (';');
1788 when N_Generic_Procedure_Renaming_Declaration =>
1789 Write_Indent_Str_Sloc ("generic procedure ");
1790 Sprint_Node (Defining_Unit_Name (Node));
1791 Write_Str_With_Col_Check (" renames ");
1792 Sprint_Node (Name (Node));
1793 Write_Char (';');
1795 when N_Generic_Subprogram_Declaration =>
1796 Extra_Blank_Line;
1797 Write_Indent_Str_Sloc ("generic ");
1798 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1799 Write_Indent;
1800 Sprint_Node (Specification (Node));
1801 Write_Char (';');
1803 when N_Goto_Statement =>
1804 Write_Indent_Str_Sloc ("goto ");
1805 Sprint_Node (Name (Node));
1806 Write_Char (';');
1808 if Nkind (Next (Node)) = N_Label then
1809 Write_Indent;
1810 end if;
1812 when N_Handled_Sequence_Of_Statements =>
1813 Set_Debug_Sloc;
1814 Sprint_Indented_List (Statements (Node));
1816 if Present (Exception_Handlers (Node)) then
1817 Write_Indent_Str ("exception");
1818 Indent_Begin;
1819 Sprint_Node_List (Exception_Handlers (Node));
1820 Indent_End;
1821 end if;
1823 if Present (At_End_Proc (Node)) then
1824 Write_Indent_Str ("at end");
1825 Indent_Begin;
1826 Write_Indent;
1827 Sprint_Node (At_End_Proc (Node));
1828 Write_Char (';');
1829 Indent_End;
1830 end if;
1832 when N_Identifier =>
1833 Set_Debug_Sloc;
1834 Write_Id (Node);
1836 when N_If_Statement =>
1837 Write_Indent_Str_Sloc ("if ");
1838 Sprint_Node (Condition (Node));
1839 Write_Str_With_Col_Check (" then");
1840 Sprint_Indented_List (Then_Statements (Node));
1841 Sprint_Opt_Node_List (Elsif_Parts (Node));
1843 if Present (Else_Statements (Node)) then
1844 Write_Indent_Str ("else");
1845 Sprint_Indented_List (Else_Statements (Node));
1846 end if;
1848 Write_Indent_Str ("end if;");
1850 when N_Implicit_Label_Declaration =>
1851 if not Dump_Original_Only then
1852 Write_Indent;
1853 Write_Rewrite_Str ("<<<");
1854 Set_Debug_Sloc;
1855 Write_Id (Defining_Identifier (Node));
1856 Write_Str (" : ");
1857 Write_Str_With_Col_Check ("label");
1858 Write_Rewrite_Str (">>>");
1859 end if;
1861 when N_In =>
1862 Sprint_Left_Opnd (Node);
1863 Write_Str_Sloc (" in ");
1865 if Present (Right_Opnd (Node)) then
1866 Sprint_Right_Opnd (Node);
1867 else
1868 Sprint_Bar_List (Alternatives (Node));
1869 end if;
1871 when N_Incomplete_Type_Declaration =>
1872 Write_Indent_Str_Sloc ("type ");
1873 Write_Id (Defining_Identifier (Node));
1875 if Present (Discriminant_Specifications (Node)) then
1876 Write_Discr_Specs (Node);
1877 elsif Unknown_Discriminants_Present (Node) then
1878 Write_Str_With_Col_Check ("(<>)");
1879 end if;
1881 Write_Char (';');
1883 when N_Index_Or_Discriminant_Constraint =>
1884 Set_Debug_Sloc;
1885 Sprint_Paren_Comma_List (Constraints (Node));
1887 when N_Indexed_Component =>
1888 Sprint_Node_Sloc (Prefix (Node));
1889 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1891 when N_Integer_Literal =>
1892 if Print_In_Hex (Node) then
1893 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1894 else
1895 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1896 end if;
1898 when N_Iteration_Scheme =>
1899 if Present (Condition (Node)) then
1900 Write_Str_With_Col_Check_Sloc ("while ");
1901 Sprint_Node (Condition (Node));
1902 else
1903 Write_Str_With_Col_Check_Sloc ("for ");
1904 Sprint_Node (Loop_Parameter_Specification (Node));
1905 end if;
1907 Write_Char (' ');
1909 when N_Itype_Reference =>
1910 Write_Indent_Str_Sloc ("reference ");
1911 Write_Id (Itype (Node));
1913 when N_Label =>
1914 Write_Indent_Str_Sloc ("<<");
1915 Write_Id (Identifier (Node));
1916 Write_Str (">>");
1918 when N_Loop_Parameter_Specification =>
1919 Set_Debug_Sloc;
1920 Write_Id (Defining_Identifier (Node));
1921 Write_Str_With_Col_Check (" in ");
1923 if Reverse_Present (Node) then
1924 Write_Str_With_Col_Check ("reverse ");
1925 end if;
1927 Sprint_Node (Discrete_Subtype_Definition (Node));
1929 when N_Loop_Statement =>
1930 Write_Indent;
1932 if Present (Identifier (Node))
1933 and then (not Has_Created_Identifier (Node)
1934 or else not Dump_Original_Only)
1935 then
1936 Write_Rewrite_Str ("<<<");
1937 Write_Id (Identifier (Node));
1938 Write_Str (" : ");
1939 Write_Rewrite_Str (">>>");
1940 Sprint_Node (Iteration_Scheme (Node));
1941 Write_Str_With_Col_Check_Sloc ("loop");
1942 Sprint_Indented_List (Statements (Node));
1943 Write_Indent_Str ("end loop ");
1944 Write_Rewrite_Str ("<<<");
1945 Write_Id (Identifier (Node));
1946 Write_Rewrite_Str (">>>");
1947 Write_Char (';');
1949 else
1950 Sprint_Node (Iteration_Scheme (Node));
1951 Write_Str_With_Col_Check_Sloc ("loop");
1952 Sprint_Indented_List (Statements (Node));
1953 Write_Indent_Str ("end loop;");
1954 end if;
1956 when N_Mod_Clause =>
1957 Sprint_Node_List (Pragmas_Before (Node));
1958 Write_Str_With_Col_Check_Sloc ("at mod ");
1959 Sprint_Node (Expression (Node));
1961 when N_Modular_Type_Definition =>
1962 Write_Str_With_Col_Check_Sloc ("mod ");
1963 Sprint_Node (Expression (Node));
1965 when N_Not_In =>
1966 Sprint_Left_Opnd (Node);
1967 Write_Str_Sloc (" not in ");
1969 if Present (Right_Opnd (Node)) then
1970 Sprint_Right_Opnd (Node);
1971 else
1972 Sprint_Bar_List (Alternatives (Node));
1973 end if;
1975 when N_Null =>
1976 Write_Str_With_Col_Check_Sloc ("null");
1978 when N_Null_Statement =>
1979 if Comes_From_Source (Node)
1980 or else Dump_Freeze_Null
1981 or else not Is_List_Member (Node)
1982 or else (No (Prev (Node)) and then No (Next (Node)))
1983 then
1984 Write_Indent_Str_Sloc ("null;");
1985 end if;
1987 when N_Number_Declaration =>
1988 Set_Debug_Sloc;
1990 if Write_Indent_Identifiers (Node) then
1991 Write_Str_With_Col_Check (" : constant ");
1992 Write_Str (" := ");
1993 Sprint_Node (Expression (Node));
1994 Write_Char (';');
1995 end if;
1997 when N_Object_Declaration =>
1998 Set_Debug_Sloc;
2000 if Write_Indent_Identifiers (Node) then
2001 declare
2002 Def_Id : constant Entity_Id := Defining_Identifier (Node);
2004 begin
2005 Write_Str_With_Col_Check (" : ");
2007 if Is_Statically_Allocated (Def_Id) then
2008 Write_Str_With_Col_Check ("static ");
2009 end if;
2011 if Aliased_Present (Node) then
2012 Write_Str_With_Col_Check ("aliased ");
2013 end if;
2015 if Constant_Present (Node) then
2016 Write_Str_With_Col_Check ("constant ");
2017 end if;
2019 -- Ada 2005 (AI-231)
2021 if Null_Exclusion_Present (Node) then
2022 Write_Str_With_Col_Check ("not null ");
2023 end if;
2025 Sprint_Node (Object_Definition (Node));
2027 if Present (Expression (Node)) then
2028 Write_Str (" := ");
2029 Sprint_Node (Expression (Node));
2030 end if;
2032 Write_Char (';');
2034 -- Handle implicit importation and implicit exportation of
2035 -- object declarations:
2036 -- $pragma import (Convention_Id, Def_Id, "...");
2037 -- $pragma export (Convention_Id, Def_Id, "...");
2039 if Is_Internal (Def_Id)
2040 and then Present (Interface_Name (Def_Id))
2041 then
2042 Write_Indent_Str_Sloc ("$pragma ");
2044 if Is_Imported (Def_Id) then
2045 Write_Str ("import (");
2047 else pragma Assert (Is_Exported (Def_Id));
2048 Write_Str ("export (");
2049 end if;
2051 declare
2052 Prefix : constant String := "Convention_";
2053 S : constant String := Convention (Def_Id)'Img;
2055 begin
2056 Name_Len := S'Last - Prefix'Last;
2057 Name_Buffer (1 .. Name_Len) :=
2058 S (Prefix'Last + 1 .. S'Last);
2059 Set_Casing (All_Lower_Case);
2060 Write_Str (Name_Buffer (1 .. Name_Len));
2061 end;
2063 Write_Str (", ");
2064 Write_Id (Def_Id);
2065 Write_Str (", ");
2066 Write_String_Table_Entry
2067 (Strval (Interface_Name (Def_Id)));
2068 Write_Str (");");
2069 end if;
2070 end;
2071 end if;
2073 when N_Object_Renaming_Declaration =>
2074 Write_Indent;
2075 Set_Debug_Sloc;
2076 Sprint_Node (Defining_Identifier (Node));
2077 Write_Str (" : ");
2079 -- Ada 2005 (AI-230): Access renamings
2081 if Present (Access_Definition (Node)) then
2082 Sprint_Node (Access_Definition (Node));
2084 elsif Present (Subtype_Mark (Node)) then
2086 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2088 if Null_Exclusion_Present (Node) then
2089 Write_Str ("not null ");
2090 end if;
2092 Sprint_Node (Subtype_Mark (Node));
2094 else
2095 Write_Str (" ??? ");
2096 end if;
2098 Write_Str_With_Col_Check (" renames ");
2099 Sprint_Node (Name (Node));
2100 Write_Char (';');
2102 when N_Op_Abs =>
2103 Write_Operator (Node, "abs ");
2104 Sprint_Right_Opnd (Node);
2106 when N_Op_Add =>
2107 Sprint_Left_Opnd (Node);
2108 Write_Operator (Node, " + ");
2109 Sprint_Right_Opnd (Node);
2111 when N_Op_And =>
2112 Sprint_Left_Opnd (Node);
2113 Write_Operator (Node, " and ");
2114 Sprint_Right_Opnd (Node);
2116 when N_Op_Concat =>
2117 Sprint_Left_Opnd (Node);
2118 Write_Operator (Node, " & ");
2119 Sprint_Right_Opnd (Node);
2121 when N_Op_Divide =>
2122 Sprint_Left_Opnd (Node);
2123 Write_Char (' ');
2124 Process_TFAI_RR_Flags (Node);
2125 Write_Operator (Node, "/ ");
2126 Sprint_Right_Opnd (Node);
2128 when N_Op_Eq =>
2129 Sprint_Left_Opnd (Node);
2130 Write_Operator (Node, " = ");
2131 Sprint_Right_Opnd (Node);
2133 when N_Op_Expon =>
2134 Sprint_Left_Opnd (Node);
2135 Write_Operator (Node, " ** ");
2136 Sprint_Right_Opnd (Node);
2138 when N_Op_Ge =>
2139 Sprint_Left_Opnd (Node);
2140 Write_Operator (Node, " >= ");
2141 Sprint_Right_Opnd (Node);
2143 when N_Op_Gt =>
2144 Sprint_Left_Opnd (Node);
2145 Write_Operator (Node, " > ");
2146 Sprint_Right_Opnd (Node);
2148 when N_Op_Le =>
2149 Sprint_Left_Opnd (Node);
2150 Write_Operator (Node, " <= ");
2151 Sprint_Right_Opnd (Node);
2153 when N_Op_Lt =>
2154 Sprint_Left_Opnd (Node);
2155 Write_Operator (Node, " < ");
2156 Sprint_Right_Opnd (Node);
2158 when N_Op_Minus =>
2159 Write_Operator (Node, "-");
2160 Sprint_Right_Opnd (Node);
2162 when N_Op_Mod =>
2163 Sprint_Left_Opnd (Node);
2165 if Treat_Fixed_As_Integer (Node) then
2166 Write_Str (" #");
2167 end if;
2169 Write_Operator (Node, " mod ");
2170 Sprint_Right_Opnd (Node);
2172 when N_Op_Multiply =>
2173 Sprint_Left_Opnd (Node);
2174 Write_Char (' ');
2175 Process_TFAI_RR_Flags (Node);
2176 Write_Operator (Node, "* ");
2177 Sprint_Right_Opnd (Node);
2179 when N_Op_Ne =>
2180 Sprint_Left_Opnd (Node);
2181 Write_Operator (Node, " /= ");
2182 Sprint_Right_Opnd (Node);
2184 when N_Op_Not =>
2185 Write_Operator (Node, "not ");
2186 Sprint_Right_Opnd (Node);
2188 when N_Op_Or =>
2189 Sprint_Left_Opnd (Node);
2190 Write_Operator (Node, " or ");
2191 Sprint_Right_Opnd (Node);
2193 when N_Op_Plus =>
2194 Write_Operator (Node, "+");
2195 Sprint_Right_Opnd (Node);
2197 when N_Op_Rem =>
2198 Sprint_Left_Opnd (Node);
2200 if Treat_Fixed_As_Integer (Node) then
2201 Write_Str (" #");
2202 end if;
2204 Write_Operator (Node, " rem ");
2205 Sprint_Right_Opnd (Node);
2207 when N_Op_Shift =>
2208 Set_Debug_Sloc;
2209 Write_Id (Node);
2210 Write_Char ('!');
2211 Write_Str_With_Col_Check ("(");
2212 Sprint_Node (Left_Opnd (Node));
2213 Write_Str (", ");
2214 Sprint_Node (Right_Opnd (Node));
2215 Write_Char (')');
2217 when N_Op_Subtract =>
2218 Sprint_Left_Opnd (Node);
2219 Write_Operator (Node, " - ");
2220 Sprint_Right_Opnd (Node);
2222 when N_Op_Xor =>
2223 Sprint_Left_Opnd (Node);
2224 Write_Operator (Node, " xor ");
2225 Sprint_Right_Opnd (Node);
2227 when N_Operator_Symbol =>
2228 Write_Name_With_Col_Check_Sloc (Chars (Node));
2230 when N_Ordinary_Fixed_Point_Definition =>
2231 Write_Str_With_Col_Check_Sloc ("delta ");
2232 Sprint_Node (Delta_Expression (Node));
2233 Sprint_Opt_Node (Real_Range_Specification (Node));
2235 when N_Or_Else =>
2236 Sprint_Left_Opnd (Node);
2237 Write_Str_Sloc (" or else ");
2238 Sprint_Right_Opnd (Node);
2240 when N_Others_Choice =>
2241 if All_Others (Node) then
2242 Write_Str_With_Col_Check ("all ");
2243 end if;
2245 Write_Str_With_Col_Check_Sloc ("others");
2247 when N_Package_Body =>
2248 Extra_Blank_Line;
2249 Write_Indent_Str_Sloc ("package body ");
2250 Sprint_Node (Defining_Unit_Name (Node));
2251 Write_Str (" is");
2252 Sprint_Indented_List (Declarations (Node));
2254 if Present (Handled_Statement_Sequence (Node)) then
2255 Write_Indent_Str ("begin");
2256 Sprint_Node (Handled_Statement_Sequence (Node));
2257 end if;
2259 Write_Indent_Str ("end ");
2260 Sprint_End_Label
2261 (Handled_Statement_Sequence (Node), Defining_Unit_Name (Node));
2262 Write_Char (';');
2264 when N_Package_Body_Stub =>
2265 Write_Indent_Str_Sloc ("package body ");
2266 Sprint_Node (Defining_Identifier (Node));
2267 Write_Str_With_Col_Check (" is separate;");
2269 when N_Package_Declaration =>
2270 Extra_Blank_Line;
2271 Write_Indent;
2272 Sprint_Node_Sloc (Specification (Node));
2273 Write_Char (';');
2275 when N_Package_Instantiation =>
2276 Extra_Blank_Line;
2277 Write_Indent_Str_Sloc ("package ");
2278 Sprint_Node (Defining_Unit_Name (Node));
2279 Write_Str (" is new ");
2280 Sprint_Node (Name (Node));
2281 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2282 Write_Char (';');
2284 when N_Package_Renaming_Declaration =>
2285 Write_Indent_Str_Sloc ("package ");
2286 Sprint_Node (Defining_Unit_Name (Node));
2287 Write_Str_With_Col_Check (" renames ");
2288 Sprint_Node (Name (Node));
2289 Write_Char (';');
2291 when N_Package_Specification =>
2292 Write_Str_With_Col_Check_Sloc ("package ");
2293 Sprint_Node (Defining_Unit_Name (Node));
2294 Write_Str (" is");
2295 Sprint_Indented_List (Visible_Declarations (Node));
2297 if Present (Private_Declarations (Node)) then
2298 Write_Indent_Str ("private");
2299 Sprint_Indented_List (Private_Declarations (Node));
2300 end if;
2302 Write_Indent_Str ("end ");
2303 Sprint_Node (Defining_Unit_Name (Node));
2305 when N_Parameter_Association =>
2306 Sprint_Node_Sloc (Selector_Name (Node));
2307 Write_Str (" => ");
2308 Sprint_Node (Explicit_Actual_Parameter (Node));
2310 when N_Parameter_Specification =>
2311 Set_Debug_Sloc;
2313 if Write_Identifiers (Node) then
2314 Write_Str (" : ");
2316 if In_Present (Node) then
2317 Write_Str_With_Col_Check ("in ");
2318 end if;
2320 if Out_Present (Node) then
2321 Write_Str_With_Col_Check ("out ");
2322 end if;
2324 -- Ada 2005 (AI-231): Parameter specification may carry null
2325 -- exclusion. Do not print it now if this is an access formal,
2326 -- it is emitted when the access definition is displayed.
2328 if Null_Exclusion_Present (Node)
2329 and then Nkind (Parameter_Type (Node))
2330 /= N_Access_Definition
2331 then
2332 Write_Str ("not null ");
2333 end if;
2335 Sprint_Node (Parameter_Type (Node));
2337 if Present (Expression (Node)) then
2338 Write_Str (" := ");
2339 Sprint_Node (Expression (Node));
2340 end if;
2341 else
2342 Write_Str (", ");
2343 end if;
2345 when N_Pop_Constraint_Error_Label =>
2346 Write_Indent_Str ("%pop_constraint_error_label");
2348 when N_Pop_Program_Error_Label =>
2349 Write_Indent_Str ("%pop_program_error_label");
2351 when N_Pop_Storage_Error_Label =>
2352 Write_Indent_Str ("%pop_storage_error_label");
2354 when N_Push_Constraint_Error_Label =>
2355 Write_Indent_Str ("%push_constraint_error_label (");
2357 if Present (Exception_Label (Node)) then
2358 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2359 end if;
2361 Write_Str (")");
2363 when N_Push_Program_Error_Label =>
2364 Write_Indent_Str ("%push_program_error_label (");
2366 if Present (Exception_Label (Node)) then
2367 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2368 end if;
2370 Write_Str (")");
2372 when N_Push_Storage_Error_Label =>
2373 Write_Indent_Str ("%push_storage_error_label (");
2375 if Present (Exception_Label (Node)) then
2376 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2377 end if;
2379 Write_Str (")");
2381 when N_Pragma =>
2382 Write_Indent_Str_Sloc ("pragma ");
2383 Write_Name_With_Col_Check (Pragma_Name (Node));
2385 if Present (Pragma_Argument_Associations (Node)) then
2386 Sprint_Opt_Paren_Comma_List
2387 (Pragma_Argument_Associations (Node));
2388 end if;
2390 Write_Char (';');
2392 when N_Pragma_Argument_Association =>
2393 Set_Debug_Sloc;
2395 if Chars (Node) /= No_Name then
2396 Write_Name_With_Col_Check (Chars (Node));
2397 Write_Str (" => ");
2398 end if;
2400 Sprint_Node (Expression (Node));
2402 when N_Private_Type_Declaration =>
2403 Write_Indent_Str_Sloc ("type ");
2404 Write_Id (Defining_Identifier (Node));
2406 if Present (Discriminant_Specifications (Node)) then
2407 Write_Discr_Specs (Node);
2408 elsif Unknown_Discriminants_Present (Node) then
2409 Write_Str_With_Col_Check ("(<>)");
2410 end if;
2412 Write_Str (" is ");
2414 if Tagged_Present (Node) then
2415 Write_Str_With_Col_Check ("tagged ");
2416 end if;
2418 if Limited_Present (Node) then
2419 Write_Str_With_Col_Check ("limited ");
2420 end if;
2422 Write_Str_With_Col_Check ("private;");
2424 when N_Private_Extension_Declaration =>
2425 Write_Indent_Str_Sloc ("type ");
2426 Write_Id (Defining_Identifier (Node));
2428 if Present (Discriminant_Specifications (Node)) then
2429 Write_Discr_Specs (Node);
2430 elsif Unknown_Discriminants_Present (Node) then
2431 Write_Str_With_Col_Check ("(<>)");
2432 end if;
2434 Write_Str_With_Col_Check (" is new ");
2435 Sprint_Node (Subtype_Indication (Node));
2437 if Present (Interface_List (Node)) then
2438 Write_Str_With_Col_Check (" and ");
2439 Sprint_And_List (Interface_List (Node));
2440 end if;
2442 Write_Str_With_Col_Check (" with private;");
2444 when N_Procedure_Call_Statement =>
2445 Write_Indent;
2446 Set_Debug_Sloc;
2447 Write_Subprogram_Name (Name (Node));
2448 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2449 Write_Char (';');
2451 when N_Procedure_Instantiation =>
2452 Write_Indent_Str_Sloc ("procedure ");
2453 Sprint_Node (Defining_Unit_Name (Node));
2454 Write_Str_With_Col_Check (" is new ");
2455 Sprint_Node (Name (Node));
2456 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2457 Write_Char (';');
2459 when N_Procedure_Specification =>
2460 Write_Str_With_Col_Check_Sloc ("procedure ");
2461 Sprint_Node (Defining_Unit_Name (Node));
2462 Write_Param_Specs (Node);
2464 when N_Protected_Body =>
2465 Write_Indent_Str_Sloc ("protected body ");
2466 Write_Id (Defining_Identifier (Node));
2467 Write_Str (" is");
2468 Sprint_Indented_List (Declarations (Node));
2469 Write_Indent_Str ("end ");
2470 Write_Id (Defining_Identifier (Node));
2471 Write_Char (';');
2473 when N_Protected_Body_Stub =>
2474 Write_Indent_Str_Sloc ("protected body ");
2475 Write_Id (Defining_Identifier (Node));
2476 Write_Str_With_Col_Check (" is separate;");
2478 when N_Protected_Definition =>
2479 Set_Debug_Sloc;
2480 Sprint_Indented_List (Visible_Declarations (Node));
2482 if Present (Private_Declarations (Node)) then
2483 Write_Indent_Str ("private");
2484 Sprint_Indented_List (Private_Declarations (Node));
2485 end if;
2487 Write_Indent_Str ("end ");
2489 when N_Protected_Type_Declaration =>
2490 Write_Indent_Str_Sloc ("protected type ");
2491 Sprint_Node (Defining_Identifier (Node));
2492 Write_Discr_Specs (Node);
2494 if Present (Interface_List (Node)) then
2495 Write_Str (" is new ");
2496 Sprint_And_List (Interface_List (Node));
2497 Write_Str (" with ");
2498 else
2499 Write_Str (" is");
2500 end if;
2502 Sprint_Node (Protected_Definition (Node));
2503 Write_Id (Defining_Identifier (Node));
2504 Write_Char (';');
2506 when N_Qualified_Expression =>
2507 Sprint_Node (Subtype_Mark (Node));
2508 Write_Char_Sloc (''');
2510 -- Print expression, make sure we have at least one level of
2511 -- parentheses around the expression. For cases of qualified
2512 -- expressions in the source, this is always the case, but
2513 -- for generated qualifications, there may be no explicit
2514 -- parentheses present.
2516 if Paren_Count (Expression (Node)) /= 0 then
2517 Sprint_Node (Expression (Node));
2518 else
2519 Write_Char ('(');
2520 Sprint_Node (Expression (Node));
2521 Write_Char (')');
2522 end if;
2524 when N_Raise_Constraint_Error =>
2526 -- This node can be used either as a subexpression or as a
2527 -- statement form. The following test is a reasonably reliable
2528 -- way to distinguish the two cases.
2530 if Is_List_Member (Node)
2531 and then Nkind (Parent (Node)) not in N_Subexpr
2532 then
2533 Write_Indent;
2534 end if;
2536 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2537 Write_Condition_And_Reason (Node);
2539 when N_Raise_Program_Error =>
2541 -- This node can be used either as a subexpression or as a
2542 -- statement form. The following test is a reasonably reliable
2543 -- way to distinguish the two cases.
2545 if Is_List_Member (Node)
2546 and then Nkind (Parent (Node)) not in N_Subexpr
2547 then
2548 Write_Indent;
2549 end if;
2551 Write_Str_With_Col_Check_Sloc ("[program_error");
2552 Write_Condition_And_Reason (Node);
2554 when N_Raise_Storage_Error =>
2556 -- This node can be used either as a subexpression or as a
2557 -- statement form. The following test is a reasonably reliable
2558 -- way to distinguish the two cases.
2560 if Is_List_Member (Node)
2561 and then Nkind (Parent (Node)) not in N_Subexpr
2562 then
2563 Write_Indent;
2564 end if;
2566 Write_Str_With_Col_Check_Sloc ("[storage_error");
2567 Write_Condition_And_Reason (Node);
2569 when N_Raise_Statement =>
2570 Write_Indent_Str_Sloc ("raise ");
2571 Sprint_Node (Name (Node));
2572 Write_Char (';');
2574 when N_Range =>
2575 Sprint_Node (Low_Bound (Node));
2576 Write_Str_Sloc (" .. ");
2577 Sprint_Node (High_Bound (Node));
2578 Update_Itype (Node);
2580 when N_Range_Constraint =>
2581 Write_Str_With_Col_Check_Sloc ("range ");
2582 Sprint_Node (Range_Expression (Node));
2584 when N_Real_Literal =>
2585 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2587 when N_Real_Range_Specification =>
2588 Write_Str_With_Col_Check_Sloc ("range ");
2589 Sprint_Node (Low_Bound (Node));
2590 Write_Str (" .. ");
2591 Sprint_Node (High_Bound (Node));
2593 when N_Record_Definition =>
2594 if Abstract_Present (Node) then
2595 Write_Str_With_Col_Check ("abstract ");
2596 end if;
2598 if Tagged_Present (Node) then
2599 Write_Str_With_Col_Check ("tagged ");
2600 end if;
2602 if Limited_Present (Node) then
2603 Write_Str_With_Col_Check ("limited ");
2604 end if;
2606 if Null_Present (Node) then
2607 Write_Str_With_Col_Check_Sloc ("null record");
2609 else
2610 Write_Str_With_Col_Check_Sloc ("record");
2611 Sprint_Node (Component_List (Node));
2612 Write_Indent_Str ("end record");
2613 end if;
2615 when N_Record_Representation_Clause =>
2616 Write_Indent_Str_Sloc ("for ");
2617 Sprint_Node (Identifier (Node));
2618 Write_Str_With_Col_Check (" use record ");
2620 if Present (Mod_Clause (Node)) then
2621 Sprint_Node (Mod_Clause (Node));
2622 end if;
2624 Sprint_Indented_List (Component_Clauses (Node));
2625 Write_Indent_Str ("end record;");
2627 when N_Reference =>
2628 Sprint_Node (Prefix (Node));
2629 Write_Str_With_Col_Check_Sloc ("'reference");
2631 when N_Requeue_Statement =>
2632 Write_Indent_Str_Sloc ("requeue ");
2633 Sprint_Node (Name (Node));
2635 if Abort_Present (Node) then
2636 Write_Str_With_Col_Check (" with abort");
2637 end if;
2639 Write_Char (';');
2641 -- Don't we want to print more detail???
2643 -- Doc of this extended syntax belongs in sinfo.ads and/or
2644 -- sprint.ads ???
2646 when N_SCIL_Dispatch_Table_Object_Init =>
2647 Write_Indent_Str ("[N_SCIL_Dispatch_Table_Object_Init]");
2649 when N_SCIL_Dispatch_Table_Tag_Init =>
2650 Write_Indent_Str ("[N_SCIL_Dispatch_Table_Tag_Init]");
2652 when N_SCIL_Dispatching_Call =>
2653 Write_Indent_Str ("[N_SCIL_Dispatching_Node]");
2655 when N_SCIL_Membership_Test =>
2656 Write_Indent_Str ("[N_SCIL_Membership_Test]");
2658 when N_SCIL_Tag_Init =>
2659 Write_Indent_Str ("[N_SCIL_Dispatch_Table_Tag_Init]");
2661 when N_Simple_Return_Statement =>
2662 if Present (Expression (Node)) then
2663 Write_Indent_Str_Sloc ("return ");
2664 Sprint_Node (Expression (Node));
2665 Write_Char (';');
2666 else
2667 Write_Indent_Str_Sloc ("return;");
2668 end if;
2670 when N_Selective_Accept =>
2671 Write_Indent_Str_Sloc ("select");
2673 declare
2674 Alt_Node : Node_Id;
2675 begin
2676 Alt_Node := First (Select_Alternatives (Node));
2677 loop
2678 Indent_Begin;
2679 Sprint_Node (Alt_Node);
2680 Indent_End;
2681 Next (Alt_Node);
2682 exit when No (Alt_Node);
2683 Write_Indent_Str ("or");
2684 end loop;
2685 end;
2687 if Present (Else_Statements (Node)) then
2688 Write_Indent_Str ("else");
2689 Sprint_Indented_List (Else_Statements (Node));
2690 end if;
2692 Write_Indent_Str ("end select;");
2694 when N_Signed_Integer_Type_Definition =>
2695 Write_Str_With_Col_Check_Sloc ("range ");
2696 Sprint_Node (Low_Bound (Node));
2697 Write_Str (" .. ");
2698 Sprint_Node (High_Bound (Node));
2700 when N_Single_Protected_Declaration =>
2701 Write_Indent_Str_Sloc ("protected ");
2702 Write_Id (Defining_Identifier (Node));
2703 Write_Str (" is");
2704 Sprint_Node (Protected_Definition (Node));
2705 Write_Id (Defining_Identifier (Node));
2706 Write_Char (';');
2708 when N_Single_Task_Declaration =>
2709 Write_Indent_Str_Sloc ("task ");
2710 Sprint_Node (Defining_Identifier (Node));
2712 if Present (Task_Definition (Node)) then
2713 Write_Str (" is");
2714 Sprint_Node (Task_Definition (Node));
2715 end if;
2717 Write_Char (';');
2719 when N_Selected_Component =>
2720 Sprint_Node (Prefix (Node));
2721 Write_Char_Sloc ('.');
2722 Sprint_Node (Selector_Name (Node));
2724 when N_Slice =>
2725 Set_Debug_Sloc;
2726 Sprint_Node (Prefix (Node));
2727 Write_Str_With_Col_Check (" (");
2728 Sprint_Node (Discrete_Range (Node));
2729 Write_Char (')');
2731 when N_String_Literal =>
2732 if String_Length (Strval (Node)) + Column > Sprint_Line_Limit then
2733 Write_Indent_Str (" ");
2734 end if;
2736 Set_Debug_Sloc;
2737 Write_String_Table_Entry (Strval (Node));
2739 when N_Subprogram_Body =>
2741 -- Output extra blank line unless we are in freeze actions
2743 if Freeze_Indent = 0 then
2744 Extra_Blank_Line;
2745 end if;
2747 Write_Indent;
2748 Sprint_Node_Sloc (Specification (Node));
2749 Write_Str (" is");
2751 Sprint_Indented_List (Declarations (Node));
2752 Write_Indent_Str ("begin");
2753 Sprint_Node (Handled_Statement_Sequence (Node));
2755 Write_Indent_Str ("end ");
2757 Sprint_End_Label
2758 (Handled_Statement_Sequence (Node),
2759 Defining_Unit_Name (Specification (Node)));
2760 Write_Char (';');
2762 if Is_List_Member (Node)
2763 and then Present (Next (Node))
2764 and then Nkind (Next (Node)) /= N_Subprogram_Body
2765 then
2766 Write_Indent;
2767 end if;
2769 when N_Subprogram_Body_Stub =>
2770 Write_Indent;
2771 Sprint_Node_Sloc (Specification (Node));
2772 Write_Str_With_Col_Check (" is separate;");
2774 when N_Subprogram_Declaration =>
2775 Write_Indent;
2776 Sprint_Node_Sloc (Specification (Node));
2778 if Nkind (Specification (Node)) = N_Procedure_Specification
2779 and then Null_Present (Specification (Node))
2780 then
2781 Write_Str_With_Col_Check (" is null");
2782 end if;
2784 Write_Char (';');
2786 when N_Subprogram_Info =>
2787 Sprint_Node (Identifier (Node));
2788 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2790 when N_Subprogram_Renaming_Declaration =>
2791 Write_Indent;
2792 Sprint_Node (Specification (Node));
2793 Write_Str_With_Col_Check_Sloc (" renames ");
2794 Sprint_Node (Name (Node));
2795 Write_Char (';');
2797 when N_Subtype_Declaration =>
2798 Write_Indent_Str_Sloc ("subtype ");
2799 Sprint_Node (Defining_Identifier (Node));
2800 Write_Str (" is ");
2802 -- Ada 2005 (AI-231)
2804 if Null_Exclusion_Present (Node) then
2805 Write_Str ("not null ");
2806 end if;
2808 Sprint_Node (Subtype_Indication (Node));
2809 Write_Char (';');
2811 when N_Subtype_Indication =>
2812 Sprint_Node_Sloc (Subtype_Mark (Node));
2813 Write_Char (' ');
2814 Sprint_Node (Constraint (Node));
2816 when N_Subunit =>
2817 Write_Indent_Str_Sloc ("separate (");
2818 Sprint_Node (Name (Node));
2819 Write_Char (')');
2820 Extra_Blank_Line;
2821 Sprint_Node (Proper_Body (Node));
2823 when N_Task_Body =>
2824 Write_Indent_Str_Sloc ("task body ");
2825 Write_Id (Defining_Identifier (Node));
2826 Write_Str (" is");
2827 Sprint_Indented_List (Declarations (Node));
2828 Write_Indent_Str ("begin");
2829 Sprint_Node (Handled_Statement_Sequence (Node));
2830 Write_Indent_Str ("end ");
2831 Sprint_End_Label
2832 (Handled_Statement_Sequence (Node), Defining_Identifier (Node));
2833 Write_Char (';');
2835 when N_Task_Body_Stub =>
2836 Write_Indent_Str_Sloc ("task body ");
2837 Write_Id (Defining_Identifier (Node));
2838 Write_Str_With_Col_Check (" is separate;");
2840 when N_Task_Definition =>
2841 Set_Debug_Sloc;
2842 Sprint_Indented_List (Visible_Declarations (Node));
2844 if Present (Private_Declarations (Node)) then
2845 Write_Indent_Str ("private");
2846 Sprint_Indented_List (Private_Declarations (Node));
2847 end if;
2849 Write_Indent_Str ("end ");
2850 Sprint_End_Label (Node, Defining_Identifier (Parent (Node)));
2852 when N_Task_Type_Declaration =>
2853 Write_Indent_Str_Sloc ("task type ");
2854 Sprint_Node (Defining_Identifier (Node));
2855 Write_Discr_Specs (Node);
2857 if Present (Interface_List (Node)) then
2858 Write_Str (" is new ");
2859 Sprint_And_List (Interface_List (Node));
2860 end if;
2862 if Present (Task_Definition (Node)) then
2863 if No (Interface_List (Node)) then
2864 Write_Str (" is");
2865 else
2866 Write_Str (" with ");
2867 end if;
2869 Sprint_Node (Task_Definition (Node));
2870 end if;
2872 Write_Char (';');
2874 when N_Terminate_Alternative =>
2875 Sprint_Node_List (Pragmas_Before (Node));
2877 Write_Indent;
2879 if Present (Condition (Node)) then
2880 Write_Str_With_Col_Check ("when ");
2881 Sprint_Node (Condition (Node));
2882 Write_Str (" => ");
2883 end if;
2885 Write_Str_With_Col_Check_Sloc ("terminate;");
2886 Sprint_Node_List (Pragmas_After (Node));
2888 when N_Timed_Entry_Call =>
2889 Write_Indent_Str_Sloc ("select");
2890 Indent_Begin;
2891 Sprint_Node (Entry_Call_Alternative (Node));
2892 Indent_End;
2893 Write_Indent_Str ("or");
2894 Indent_Begin;
2895 Sprint_Node (Delay_Alternative (Node));
2896 Indent_End;
2897 Write_Indent_Str ("end select;");
2899 when N_Triggering_Alternative =>
2900 Sprint_Node_List (Pragmas_Before (Node));
2901 Sprint_Node_Sloc (Triggering_Statement (Node));
2902 Sprint_Node_List (Statements (Node));
2904 when N_Type_Conversion =>
2905 Set_Debug_Sloc;
2906 Sprint_Node (Subtype_Mark (Node));
2907 Col_Check (4);
2909 if Conversion_OK (Node) then
2910 Write_Char ('?');
2911 end if;
2913 if Float_Truncate (Node) then
2914 Write_Char ('^');
2915 end if;
2917 if Rounded_Result (Node) then
2918 Write_Char ('@');
2919 end if;
2921 Write_Char ('(');
2922 Sprint_Node (Expression (Node));
2923 Write_Char (')');
2925 when N_Unchecked_Expression =>
2926 Col_Check (10);
2927 Write_Str ("`(");
2928 Sprint_Node_Sloc (Expression (Node));
2929 Write_Char (')');
2931 when N_Unchecked_Type_Conversion =>
2932 Sprint_Node (Subtype_Mark (Node));
2933 Write_Char ('!');
2934 Write_Str_With_Col_Check ("(");
2935 Sprint_Node_Sloc (Expression (Node));
2936 Write_Char (')');
2938 when N_Unconstrained_Array_Definition =>
2939 Write_Str_With_Col_Check_Sloc ("array (");
2941 declare
2942 Node1 : Node_Id;
2943 begin
2944 Node1 := First (Subtype_Marks (Node));
2945 loop
2946 Sprint_Node (Node1);
2947 Write_Str_With_Col_Check (" range <>");
2948 Next (Node1);
2949 exit when Node1 = Empty;
2950 Write_Str (", ");
2951 end loop;
2952 end;
2954 Write_Str (") of ");
2955 Sprint_Node (Component_Definition (Node));
2957 when N_Unused_At_Start | N_Unused_At_End =>
2958 Write_Indent_Str ("***** Error, unused node encountered *****");
2959 Write_Eol;
2961 when N_Use_Package_Clause =>
2962 Write_Indent_Str_Sloc ("use ");
2963 Sprint_Comma_List (Names (Node));
2964 Write_Char (';');
2966 when N_Use_Type_Clause =>
2967 Write_Indent_Str_Sloc ("use type ");
2968 Sprint_Comma_List (Subtype_Marks (Node));
2969 Write_Char (';');
2971 when N_Validate_Unchecked_Conversion =>
2972 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2973 Sprint_Node (Source_Type (Node));
2974 Write_Str (", ");
2975 Sprint_Node (Target_Type (Node));
2976 Write_Str (");");
2978 when N_Variant =>
2979 Write_Indent_Str_Sloc ("when ");
2980 Sprint_Bar_List (Discrete_Choices (Node));
2981 Write_Str (" => ");
2982 Sprint_Node (Component_List (Node));
2984 when N_Variant_Part =>
2985 Indent_Begin;
2986 Write_Indent_Str_Sloc ("case ");
2987 Sprint_Node (Name (Node));
2988 Write_Str (" is ");
2989 Sprint_Indented_List (Variants (Node));
2990 Write_Indent_Str ("end case");
2991 Indent_End;
2993 when N_With_Clause =>
2995 -- Special test, if we are dumping the original tree only,
2996 -- then we want to eliminate the bogus with clauses that
2997 -- correspond to the non-existent children of Text_IO.
2999 if Dump_Original_Only
3000 and then Is_Text_IO_Kludge_Unit (Name (Node))
3001 then
3002 null;
3004 -- Normal case, output the with clause
3006 else
3007 if First_Name (Node) or else not Dump_Original_Only then
3009 -- Ada 2005 (AI-50217): Print limited with_clauses
3011 if Private_Present (Node) and Limited_Present (Node) then
3012 Write_Indent_Str ("limited private with ");
3014 elsif Private_Present (Node) then
3015 Write_Indent_Str ("private with ");
3017 elsif Limited_Present (Node) then
3018 Write_Indent_Str ("limited with ");
3020 else
3021 Write_Indent_Str ("with ");
3022 end if;
3024 else
3025 Write_Str (", ");
3026 end if;
3028 Sprint_Node_Sloc (Name (Node));
3030 if Last_Name (Node) or else not Dump_Original_Only then
3031 Write_Char (';');
3032 end if;
3033 end if;
3035 end case;
3037 if Nkind (Node) in N_Subexpr
3038 and then Do_Range_Check (Node)
3039 then
3040 Write_Str ("}");
3041 end if;
3043 for J in 1 .. Paren_Count (Node) loop
3044 Write_Char (')');
3045 end loop;
3047 Dump_Node := Save_Dump_Node;
3048 end Sprint_Node_Actual;
3050 ----------------------
3051 -- Sprint_Node_List --
3052 ----------------------
3054 procedure Sprint_Node_List (List : List_Id) is
3055 Node : Node_Id;
3057 begin
3058 if Is_Non_Empty_List (List) then
3059 Node := First (List);
3061 loop
3062 Sprint_Node (Node);
3063 Next (Node);
3064 exit when Node = Empty;
3065 end loop;
3066 end if;
3067 end Sprint_Node_List;
3069 ----------------------
3070 -- Sprint_Node_Sloc --
3071 ----------------------
3073 procedure Sprint_Node_Sloc (Node : Node_Id) is
3074 begin
3075 Sprint_Node (Node);
3077 if Debug_Generated_Code and then Present (Dump_Node) then
3078 Set_Sloc (Dump_Node, Sloc (Node));
3079 Dump_Node := Empty;
3080 end if;
3081 end Sprint_Node_Sloc;
3083 ---------------------
3084 -- Sprint_Opt_Node --
3085 ---------------------
3087 procedure Sprint_Opt_Node (Node : Node_Id) is
3088 begin
3089 if Present (Node) then
3090 Write_Char (' ');
3091 Sprint_Node (Node);
3092 end if;
3093 end Sprint_Opt_Node;
3095 --------------------------
3096 -- Sprint_Opt_Node_List --
3097 --------------------------
3099 procedure Sprint_Opt_Node_List (List : List_Id) is
3100 begin
3101 if Present (List) then
3102 Sprint_Node_List (List);
3103 end if;
3104 end Sprint_Opt_Node_List;
3106 ---------------------------------
3107 -- Sprint_Opt_Paren_Comma_List --
3108 ---------------------------------
3110 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
3111 begin
3112 if Is_Non_Empty_List (List) then
3113 Write_Char (' ');
3114 Sprint_Paren_Comma_List (List);
3115 end if;
3116 end Sprint_Opt_Paren_Comma_List;
3118 -----------------------------
3119 -- Sprint_Paren_Comma_List --
3120 -----------------------------
3122 procedure Sprint_Paren_Comma_List (List : List_Id) is
3123 N : Node_Id;
3124 Node_Exists : Boolean := False;
3126 begin
3128 if Is_Non_Empty_List (List) then
3130 if Dump_Original_Only then
3131 N := First (List);
3132 while Present (N) loop
3133 if not Is_Rewrite_Insertion (N) then
3134 Node_Exists := True;
3135 exit;
3136 end if;
3138 Next (N);
3139 end loop;
3141 if not Node_Exists then
3142 return;
3143 end if;
3144 end if;
3146 Write_Str_With_Col_Check ("(");
3147 Sprint_Comma_List (List);
3148 Write_Char (')');
3149 end if;
3150 end Sprint_Paren_Comma_List;
3152 ----------------------
3153 -- Sprint_Right_Opnd --
3154 ----------------------
3156 procedure Sprint_Right_Opnd (N : Node_Id) is
3157 Opnd : constant Node_Id := Right_Opnd (N);
3159 begin
3160 if Paren_Count (Opnd) /= 0
3161 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
3162 then
3163 Sprint_Node (Opnd);
3165 else
3166 Write_Char ('(');
3167 Sprint_Node (Opnd);
3168 Write_Char (')');
3169 end if;
3170 end Sprint_Right_Opnd;
3172 ------------------
3173 -- Update_Itype --
3174 ------------------
3176 procedure Update_Itype (Node : Node_Id) is
3177 begin
3178 if Present (Etype (Node))
3179 and then Is_Itype (Etype (Node))
3180 and then Debug_Generated_Code
3181 then
3182 Set_Sloc (Etype (Node), Sloc (Node));
3183 end if;
3184 end Update_Itype;
3186 ---------------------
3187 -- Write_Char_Sloc --
3188 ---------------------
3190 procedure Write_Char_Sloc (C : Character) is
3191 begin
3192 if Debug_Generated_Code and then C /= ' ' then
3193 Set_Debug_Sloc;
3194 end if;
3196 Write_Char (C);
3197 end Write_Char_Sloc;
3199 --------------------------------
3200 -- Write_Condition_And_Reason --
3201 --------------------------------
3203 procedure Write_Condition_And_Reason (Node : Node_Id) is
3204 Cond : constant Node_Id := Condition (Node);
3205 Image : constant String := RT_Exception_Code'Image
3206 (RT_Exception_Code'Val
3207 (UI_To_Int (Reason (Node))));
3209 begin
3210 if Present (Cond) then
3212 -- If condition is a single entity, or NOT with a single entity,
3213 -- output all on one line, since it will likely fit just fine.
3215 if Is_Entity_Name (Cond)
3216 or else (Nkind (Cond) = N_Op_Not
3217 and then Is_Entity_Name (Right_Opnd (Cond)))
3218 then
3219 Write_Str_With_Col_Check (" when ");
3220 Sprint_Node (Cond);
3221 Write_Char (' ');
3223 -- Otherwise for more complex condition, multiple lines
3225 else
3226 Write_Str_With_Col_Check (" when");
3227 Indent := Indent + 2;
3228 Write_Indent;
3229 Sprint_Node (Cond);
3230 Write_Indent;
3231 Indent := Indent - 2;
3232 end if;
3234 -- If no condition, just need a space (all on one line)
3236 else
3237 Write_Char (' ');
3238 end if;
3240 -- Write the reason
3242 Write_Char ('"');
3244 for J in 4 .. Image'Last loop
3245 if Image (J) = '_' then
3246 Write_Char (' ');
3247 else
3248 Write_Char (Fold_Lower (Image (J)));
3249 end if;
3250 end loop;
3252 Write_Str ("""]");
3253 end Write_Condition_And_Reason;
3255 --------------------------------
3256 -- Write_Corresponding_Source --
3257 --------------------------------
3259 procedure Write_Corresponding_Source (S : String) is
3260 Loc : Source_Ptr;
3261 Src : Source_Buffer_Ptr;
3263 begin
3264 -- Ignore if not in dump source text mode, or if in freeze actions
3266 if Dump_Source_Text and then Freeze_Indent = 0 then
3268 -- Ignore null string
3270 if S = "" then
3271 return;
3272 end if;
3274 -- Ignore space or semicolon at end of given string
3276 if S (S'Last) = ' ' or else S (S'Last) = ';' then
3277 Write_Corresponding_Source (S (S'First .. S'Last - 1));
3278 return;
3279 end if;
3281 -- Loop to look at next lines not yet printed in source file
3283 for L in
3284 Last_Line_Printed + 1 .. Last_Source_Line (Current_Source_File)
3285 loop
3286 Src := Source_Text (Current_Source_File);
3287 Loc := Line_Start (L, Current_Source_File);
3289 -- If comment, keep looking
3291 if Src (Loc .. Loc + 1) = "--" then
3292 null;
3294 -- Search to first non-blank
3296 else
3297 while Src (Loc) not in Line_Terminator loop
3299 -- Non-blank found
3301 if Src (Loc) /= ' ' and then Src (Loc) /= ASCII.HT then
3303 -- Loop through characters in string to see if we match
3305 for J in S'Range loop
3307 -- If mismatch, then not the case we are looking for
3309 if Src (Loc) /= S (J) then
3310 return;
3311 end if;
3313 Loc := Loc + 1;
3314 end loop;
3316 -- If we fall through, string matched, if white space or
3317 -- semicolon after the matched string, this is the case
3318 -- we are looking for.
3320 if Src (Loc) in Line_Terminator
3321 or else Src (Loc) = ' '
3322 or else Src (Loc) = ASCII.HT
3323 or else Src (Loc) = ';'
3324 then
3325 -- So output source lines up to and including this one
3327 Write_Source_Lines (L);
3328 return;
3329 end if;
3330 end if;
3332 Loc := Loc + 1;
3333 end loop;
3334 end if;
3336 -- Line was all blanks, or a comment line, keep looking
3338 end loop;
3339 end if;
3340 end Write_Corresponding_Source;
3342 -----------------------
3343 -- Write_Discr_Specs --
3344 -----------------------
3346 procedure Write_Discr_Specs (N : Node_Id) is
3347 Specs : List_Id;
3348 Spec : Node_Id;
3350 begin
3351 Specs := Discriminant_Specifications (N);
3353 if Present (Specs) then
3354 Write_Str_With_Col_Check (" (");
3355 Spec := First (Specs);
3357 loop
3358 Sprint_Node (Spec);
3359 Next (Spec);
3360 exit when Spec = Empty;
3362 -- Add semicolon, unless we are printing original tree and the
3363 -- next specification is part of a list (but not the first
3364 -- element of that list)
3366 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3367 Write_Str ("; ");
3368 end if;
3369 end loop;
3371 Write_Char (')');
3372 end if;
3373 end Write_Discr_Specs;
3375 -----------------
3376 -- Write_Ekind --
3377 -----------------
3379 procedure Write_Ekind (E : Entity_Id) is
3380 S : constant String := Entity_Kind'Image (Ekind (E));
3382 begin
3383 Name_Len := S'Length;
3384 Name_Buffer (1 .. Name_Len) := S;
3385 Set_Casing (Mixed_Case);
3386 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3387 end Write_Ekind;
3389 --------------
3390 -- Write_Id --
3391 --------------
3393 procedure Write_Id (N : Node_Id) is
3394 begin
3395 -- Deal with outputting Itype
3397 -- Note: if we are printing the full tree with -gnatds, then we may
3398 -- end up picking up the Associated_Node link from a generic template
3399 -- here which overlaps the Entity field, but as documented, Write_Itype
3400 -- is defended against junk calls.
3402 if Nkind (N) in N_Entity then
3403 Write_Itype (N);
3404 elsif Nkind (N) in N_Has_Entity then
3405 Write_Itype (Entity (N));
3406 end if;
3408 -- Case of a defining identifier
3410 if Nkind (N) = N_Defining_Identifier then
3412 -- If defining identifier has an interface name (and no
3413 -- address clause), then we output the interface name.
3415 if (Is_Imported (N) or else Is_Exported (N))
3416 and then Present (Interface_Name (N))
3417 and then No (Address_Clause (N))
3418 then
3419 String_To_Name_Buffer (Strval (Interface_Name (N)));
3420 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3422 -- If no interface name (or inactive because there was
3423 -- an address clause), then just output the Chars name.
3425 else
3426 Write_Name_With_Col_Check (Chars (N));
3427 end if;
3429 -- Case of selector of an expanded name where the expanded name
3430 -- has an associated entity, output this entity.
3432 elsif Nkind (Parent (N)) = N_Expanded_Name
3433 and then Selector_Name (Parent (N)) = N
3434 and then Present (Entity (Parent (N)))
3435 then
3436 Write_Id (Entity (Parent (N)));
3438 -- For any other node with an associated entity, output it
3440 elsif Nkind (N) in N_Has_Entity
3441 and then Present (Entity_Or_Associated_Node (N))
3442 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
3443 then
3444 Write_Id (Entity (N));
3446 -- All other cases, we just print the Chars field
3448 else
3449 Write_Name_With_Col_Check (Chars (N));
3450 end if;
3451 end Write_Id;
3453 -----------------------
3454 -- Write_Identifiers --
3455 -----------------------
3457 function Write_Identifiers (Node : Node_Id) return Boolean is
3458 begin
3459 Sprint_Node (Defining_Identifier (Node));
3460 Update_Itype (Defining_Identifier (Node));
3462 -- The remainder of the declaration must be printed unless we are
3463 -- printing the original tree and this is not the last identifier
3465 return
3466 not Dump_Original_Only or else not More_Ids (Node);
3468 end Write_Identifiers;
3470 ------------------------
3471 -- Write_Implicit_Def --
3472 ------------------------
3474 procedure Write_Implicit_Def (E : Entity_Id) is
3475 Ind : Node_Id;
3477 begin
3478 case Ekind (E) is
3479 when E_Array_Subtype =>
3480 Write_Str_With_Col_Check ("subtype ");
3481 Write_Id (E);
3482 Write_Str_With_Col_Check (" is ");
3483 Write_Id (Base_Type (E));
3484 Write_Str_With_Col_Check (" (");
3486 Ind := First_Index (E);
3487 while Present (Ind) loop
3488 Sprint_Node (Ind);
3489 Next_Index (Ind);
3491 if Present (Ind) then
3492 Write_Str (", ");
3493 end if;
3494 end loop;
3496 Write_Str (");");
3498 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
3499 Write_Str_With_Col_Check ("subtype ");
3500 Write_Id (E);
3501 Write_Str (" is ");
3502 Write_Id (Etype (E));
3503 Write_Str_With_Col_Check (" range ");
3504 Sprint_Node (Scalar_Range (E));
3505 Write_Str (";");
3507 when others =>
3508 Write_Str_With_Col_Check ("type ");
3509 Write_Id (E);
3510 Write_Str_With_Col_Check (" is <");
3511 Write_Ekind (E);
3512 Write_Str (">;");
3513 end case;
3515 end Write_Implicit_Def;
3517 ------------------
3518 -- Write_Indent --
3519 ------------------
3521 procedure Write_Indent is
3522 Loc : constant Source_Ptr := Sloc (Dump_Node);
3524 begin
3525 if Indent_Annull_Flag then
3526 Indent_Annull_Flag := False;
3527 else
3528 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3529 -- label declarations, since they typically have the sloc of the
3530 -- corresponding label, which really messes up the -gnatL output.
3532 if Dump_Source_Text
3533 and then Loc > No_Location
3534 and then Nkind (Dump_Node) /= N_Implicit_Label_Declaration
3535 then
3536 if Get_Source_File_Index (Loc) = Current_Source_File then
3537 Write_Source_Lines
3538 (Get_Physical_Line_Number (Sloc (Dump_Node)));
3539 end if;
3540 end if;
3542 Write_Eol;
3544 for J in 1 .. Indent loop
3545 Write_Char (' ');
3546 end loop;
3547 end if;
3548 end Write_Indent;
3550 ------------------------------
3551 -- Write_Indent_Identifiers --
3552 ------------------------------
3554 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3555 begin
3556 -- We need to start a new line for every node, except in the case
3557 -- where we are printing the original tree and this is not the first
3558 -- defining identifier in the list.
3560 if not Dump_Original_Only or else not Prev_Ids (Node) then
3561 Write_Indent;
3563 -- If printing original tree and this is not the first defining
3564 -- identifier in the list, then the previous call to this procedure
3565 -- printed only the name, and we add a comma to separate the names.
3567 else
3568 Write_Str (", ");
3569 end if;
3571 Sprint_Node (Defining_Identifier (Node));
3573 -- The remainder of the declaration must be printed unless we are
3574 -- printing the original tree and this is not the last identifier
3576 return
3577 not Dump_Original_Only or else not More_Ids (Node);
3578 end Write_Indent_Identifiers;
3580 -----------------------------------
3581 -- Write_Indent_Identifiers_Sloc --
3582 -----------------------------------
3584 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3585 begin
3586 -- We need to start a new line for every node, except in the case
3587 -- where we are printing the original tree and this is not the first
3588 -- defining identifier in the list.
3590 if not Dump_Original_Only or else not Prev_Ids (Node) then
3591 Write_Indent;
3593 -- If printing original tree and this is not the first defining
3594 -- identifier in the list, then the previous call to this procedure
3595 -- printed only the name, and we add a comma to separate the names.
3597 else
3598 Write_Str (", ");
3599 end if;
3601 Set_Debug_Sloc;
3602 Sprint_Node (Defining_Identifier (Node));
3604 -- The remainder of the declaration must be printed unless we are
3605 -- printing the original tree and this is not the last identifier
3607 return not Dump_Original_Only or else not More_Ids (Node);
3608 end Write_Indent_Identifiers_Sloc;
3610 ----------------------
3611 -- Write_Indent_Str --
3612 ----------------------
3614 procedure Write_Indent_Str (S : String) is
3615 begin
3616 Write_Corresponding_Source (S);
3617 Write_Indent;
3618 Write_Str (S);
3619 end Write_Indent_Str;
3621 ---------------------------
3622 -- Write_Indent_Str_Sloc --
3623 ---------------------------
3625 procedure Write_Indent_Str_Sloc (S : String) is
3626 begin
3627 Write_Corresponding_Source (S);
3628 Write_Indent;
3629 Write_Str_Sloc (S);
3630 end Write_Indent_Str_Sloc;
3632 -----------------
3633 -- Write_Itype --
3634 -----------------
3636 procedure Write_Itype (Typ : Entity_Id) is
3638 procedure Write_Header (T : Boolean := True);
3639 -- Write type if T is True, subtype if T is false
3641 ------------------
3642 -- Write_Header --
3643 ------------------
3645 procedure Write_Header (T : Boolean := True) is
3646 begin
3647 if T then
3648 Write_Str ("[type ");
3649 else
3650 Write_Str ("[subtype ");
3651 end if;
3653 Write_Name_With_Col_Check (Chars (Typ));
3654 Write_Str (" is ");
3655 end Write_Header;
3657 -- Start of processing for Write_Itype
3659 begin
3660 if Nkind (Typ) in N_Entity
3661 and then Is_Itype (Typ)
3662 and then not Itype_Printed (Typ)
3663 then
3664 -- Itype to be printed
3666 declare
3667 B : constant Node_Id := Etype (Typ);
3668 X : Node_Id;
3669 P : constant Node_Id := Parent (Typ);
3671 S : constant Saved_Output_Buffer := Save_Output_Buffer;
3672 -- Save current output buffer
3674 Old_Sloc : Source_Ptr;
3675 -- Save sloc of related node, so it is not modified when
3676 -- printing with -gnatD.
3678 begin
3679 -- Write indentation at start of line
3681 for J in 1 .. Indent loop
3682 Write_Char (' ');
3683 end loop;
3685 -- If we have a constructed declaration for the itype, print it
3687 if Present (P)
3688 and then Nkind (P) in N_Declaration
3689 and then Defining_Entity (P) = Typ
3690 then
3691 -- We must set Itype_Printed true before the recursive call to
3692 -- print the node, otherwise we get an infinite recursion!
3694 Set_Itype_Printed (Typ, True);
3696 -- Write the declaration enclosed in [], avoiding new line
3697 -- at start of declaration, and semicolon at end.
3699 -- Note: The itype may be imported from another unit, in which
3700 -- case we do not want to modify the Sloc of the declaration.
3701 -- Otherwise the itype may appear to be in the current unit,
3702 -- and the back-end will reject a reference out of scope.
3704 Write_Char ('[');
3705 Indent_Annull_Flag := True;
3706 Old_Sloc := Sloc (P);
3707 Sprint_Node (P);
3708 Set_Sloc (P, Old_Sloc);
3709 Write_Erase_Char (';');
3711 -- If no constructed declaration, then we have to concoct the
3712 -- source corresponding to the type entity that we have at hand.
3714 else
3715 case Ekind (Typ) is
3717 -- Access types and subtypes
3719 when Access_Kind =>
3720 Write_Header (Ekind (Typ) = E_Access_Type);
3721 Write_Str ("access ");
3723 if Is_Access_Constant (Typ) then
3724 Write_Str ("constant ");
3725 elsif Can_Never_Be_Null (Typ) then
3726 Write_Str ("not null ");
3727 end if;
3729 Write_Id (Directly_Designated_Type (Typ));
3731 -- Array types and string types
3733 when E_Array_Type | E_String_Type =>
3734 Write_Header;
3735 Write_Str ("array (");
3737 X := First_Index (Typ);
3738 loop
3739 Sprint_Node (X);
3741 if not Is_Constrained (Typ) then
3742 Write_Str (" range <>");
3743 end if;
3745 Next_Index (X);
3746 exit when No (X);
3747 Write_Str (", ");
3748 end loop;
3750 Write_Str (") of ");
3751 X := Component_Type (Typ);
3753 -- Preserve sloc of component type, which is defined
3754 -- elsewhere than the itype (see comment above).
3756 Old_Sloc := Sloc (X);
3757 Sprint_Node (X);
3758 Set_Sloc (X, Old_Sloc);
3760 -- Array subtypes and string subtypes.
3761 -- Preserve Sloc of index subtypes, as above.
3763 when E_Array_Subtype | E_String_Subtype =>
3764 Write_Header (False);
3765 Write_Id (Etype (Typ));
3766 Write_Str (" (");
3768 X := First_Index (Typ);
3769 loop
3770 Old_Sloc := Sloc (X);
3771 Sprint_Node (X);
3772 Set_Sloc (X, Old_Sloc);
3773 Next_Index (X);
3774 exit when No (X);
3775 Write_Str (", ");
3776 end loop;
3778 Write_Char (')');
3780 -- Signed integer types, and modular integer subtypes,
3781 -- and also enumeration subtypes.
3783 when E_Signed_Integer_Type |
3784 E_Signed_Integer_Subtype |
3785 E_Modular_Integer_Subtype |
3786 E_Enumeration_Subtype =>
3788 Write_Header (Ekind (Typ) = E_Signed_Integer_Type);
3790 if Ekind (Typ) = E_Signed_Integer_Type then
3791 Write_Str ("new ");
3792 end if;
3794 Write_Id (B);
3796 -- Print bounds if different from base type
3798 declare
3799 L : constant Node_Id := Type_Low_Bound (Typ);
3800 H : constant Node_Id := Type_High_Bound (Typ);
3801 LE : Node_Id;
3802 HE : Node_Id;
3804 begin
3805 -- B can either be a scalar type, in which case the
3806 -- declaration of Typ may constrain it with different
3807 -- bounds, or a private type, in which case we know
3808 -- that the declaration of Typ cannot have a scalar
3809 -- constraint.
3811 if Is_Scalar_Type (B) then
3812 LE := Type_Low_Bound (B);
3813 HE := Type_High_Bound (B);
3814 else
3815 LE := Empty;
3816 HE := Empty;
3817 end if;
3819 if No (LE)
3820 or else (True
3821 and then Nkind (L) = N_Integer_Literal
3822 and then Nkind (H) = N_Integer_Literal
3823 and then Nkind (LE) = N_Integer_Literal
3824 and then Nkind (HE) = N_Integer_Literal
3825 and then UI_Eq (Intval (L), Intval (LE))
3826 and then UI_Eq (Intval (H), Intval (HE)))
3827 then
3828 null;
3830 else
3831 Write_Str (" range ");
3832 Sprint_Node (Type_Low_Bound (Typ));
3833 Write_Str (" .. ");
3834 Sprint_Node (Type_High_Bound (Typ));
3835 end if;
3836 end;
3838 -- Modular integer types
3840 when E_Modular_Integer_Type =>
3841 Write_Header;
3842 Write_Str (" mod ");
3843 Write_Uint_With_Col_Check (Modulus (Typ), Auto);
3845 -- Floating point types and subtypes
3847 when E_Floating_Point_Type |
3848 E_Floating_Point_Subtype =>
3850 Write_Header (Ekind (Typ) = E_Floating_Point_Type);
3852 if Ekind (Typ) = E_Floating_Point_Type then
3853 Write_Str ("new ");
3854 end if;
3856 Write_Id (Etype (Typ));
3858 if Digits_Value (Typ) /= Digits_Value (Etype (Typ)) then
3859 Write_Str (" digits ");
3860 Write_Uint_With_Col_Check
3861 (Digits_Value (Typ), Decimal);
3862 end if;
3864 -- Print bounds if not different from base type
3866 declare
3867 L : constant Node_Id := Type_Low_Bound (Typ);
3868 H : constant Node_Id := Type_High_Bound (Typ);
3869 LE : constant Node_Id := Type_Low_Bound (B);
3870 HE : constant Node_Id := Type_High_Bound (B);
3872 begin
3873 if Nkind (L) = N_Real_Literal
3874 and then Nkind (H) = N_Real_Literal
3875 and then Nkind (LE) = N_Real_Literal
3876 and then Nkind (HE) = N_Real_Literal
3877 and then UR_Eq (Realval (L), Realval (LE))
3878 and then UR_Eq (Realval (H), Realval (HE))
3879 then
3880 null;
3882 else
3883 Write_Str (" range ");
3884 Sprint_Node (Type_Low_Bound (Typ));
3885 Write_Str (" .. ");
3886 Sprint_Node (Type_High_Bound (Typ));
3887 end if;
3888 end;
3890 -- Record subtypes
3892 when E_Record_Subtype =>
3893 Write_Header (False);
3894 Write_Str ("record");
3895 Indent_Begin;
3897 declare
3898 C : Entity_Id;
3899 begin
3900 C := First_Entity (Typ);
3901 while Present (C) loop
3902 Write_Indent;
3903 Write_Id (C);
3904 Write_Str (" : ");
3905 Write_Id (Etype (C));
3906 Next_Entity (C);
3907 end loop;
3908 end;
3910 Indent_End;
3911 Write_Indent_Str (" end record");
3913 -- Class-Wide types
3915 when E_Class_Wide_Type |
3916 E_Class_Wide_Subtype =>
3917 Write_Header;
3918 Write_Name_With_Col_Check (Chars (Etype (Typ)));
3919 Write_Str ("'Class");
3921 -- Subprogram types
3923 when E_Subprogram_Type =>
3924 Write_Header;
3926 if Etype (Typ) = Standard_Void_Type then
3927 Write_Str ("procedure");
3928 else
3929 Write_Str ("function");
3930 end if;
3932 if Present (First_Entity (Typ)) then
3933 Write_Str (" (");
3935 declare
3936 Param : Entity_Id;
3938 begin
3939 Param := First_Entity (Typ);
3940 loop
3941 Write_Id (Param);
3942 Write_Str (" : ");
3944 if Ekind (Param) = E_In_Out_Parameter then
3945 Write_Str ("in out ");
3946 elsif Ekind (Param) = E_Out_Parameter then
3947 Write_Str ("out ");
3948 end if;
3950 Write_Id (Etype (Param));
3951 Next_Entity (Param);
3952 exit when No (Param);
3953 Write_Str (", ");
3954 end loop;
3956 Write_Char (')');
3957 end;
3958 end if;
3960 if Etype (Typ) /= Standard_Void_Type then
3961 Write_Str (" return ");
3962 Write_Id (Etype (Typ));
3963 end if;
3965 when E_String_Literal_Subtype =>
3966 declare
3967 LB : constant Uint :=
3968 Expr_Value (String_Literal_Low_Bound (Typ));
3969 Len : constant Uint :=
3970 String_Literal_Length (Typ);
3971 begin
3972 Write_Str ("String (");
3973 Write_Int (UI_To_Int (LB));
3974 Write_Str (" .. ");
3975 Write_Int (UI_To_Int (LB + Len) - 1);
3976 Write_Str (");");
3977 end;
3979 -- For all other Itypes, print ??? (fill in later)
3981 when others =>
3982 Write_Header (True);
3983 Write_Str ("???");
3985 end case;
3986 end if;
3988 -- Add terminating bracket and restore output buffer
3990 Write_Char (']');
3991 Write_Eol;
3992 Restore_Output_Buffer (S);
3993 end;
3995 Set_Itype_Printed (Typ);
3996 end if;
3997 end Write_Itype;
3999 -------------------------------
4000 -- Write_Name_With_Col_Check --
4001 -------------------------------
4003 procedure Write_Name_With_Col_Check (N : Name_Id) is
4004 J : Natural;
4005 K : Natural;
4006 L : Natural;
4008 begin
4009 Get_Name_String (N);
4011 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4012 -- upper case letter, nnn is one or more digits and b is a lower case
4013 -- letter by C...b, so that listings do not depend on serial numbers.
4015 if Debug_Flag_II then
4016 J := 1;
4017 while J < Name_Len - 1 loop
4018 if Name_Buffer (J) in 'A' .. 'Z'
4019 and then Name_Buffer (J + 1) in '0' .. '9'
4020 then
4021 K := J + 1;
4022 while K < Name_Len loop
4023 exit when Name_Buffer (K) not in '0' .. '9';
4024 K := K + 1;
4025 end loop;
4027 if Name_Buffer (K) in 'a' .. 'z' then
4028 L := Name_Len - K + 1;
4030 Name_Buffer (J + 4 .. J + L + 3) :=
4031 Name_Buffer (K .. Name_Len);
4032 Name_Buffer (J + 1 .. J + 3) := "...";
4033 Name_Len := J + L + 3;
4034 J := J + 5;
4036 else
4037 J := K;
4038 end if;
4040 else
4041 J := J + 1;
4042 end if;
4043 end loop;
4044 end if;
4046 -- Fall through for normal case
4048 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
4049 end Write_Name_With_Col_Check;
4051 ------------------------------------
4052 -- Write_Name_With_Col_Check_Sloc --
4053 ------------------------------------
4055 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
4056 begin
4057 Get_Name_String (N);
4058 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
4059 end Write_Name_With_Col_Check_Sloc;
4061 --------------------
4062 -- Write_Operator --
4063 --------------------
4065 procedure Write_Operator (N : Node_Id; S : String) is
4066 F : Natural := S'First;
4067 T : Natural := S'Last;
4069 begin
4070 -- If no overflow check, just write string out, and we are done
4072 if not Do_Overflow_Check (N) then
4073 Write_Str_Sloc (S);
4075 -- If overflow check, we want to surround the operator with curly
4076 -- brackets, but not include spaces within the brackets.
4078 else
4079 if S (F) = ' ' then
4080 Write_Char (' ');
4081 F := F + 1;
4082 end if;
4084 if S (T) = ' ' then
4085 T := T - 1;
4086 end if;
4088 Write_Char ('{');
4089 Write_Str_Sloc (S (F .. T));
4090 Write_Char ('}');
4092 if S (S'Last) = ' ' then
4093 Write_Char (' ');
4094 end if;
4095 end if;
4096 end Write_Operator;
4098 -----------------------
4099 -- Write_Param_Specs --
4100 -----------------------
4102 procedure Write_Param_Specs (N : Node_Id) is
4103 Specs : List_Id;
4104 Spec : Node_Id;
4105 Formal : Node_Id;
4107 begin
4108 Specs := Parameter_Specifications (N);
4110 if Is_Non_Empty_List (Specs) then
4111 Write_Str_With_Col_Check (" (");
4112 Spec := First (Specs);
4114 loop
4115 Sprint_Node (Spec);
4116 Formal := Defining_Identifier (Spec);
4117 Next (Spec);
4118 exit when Spec = Empty;
4120 -- Add semicolon, unless we are printing original tree and the
4121 -- next specification is part of a list (but not the first element
4122 -- of that list).
4124 if not Dump_Original_Only or else not Prev_Ids (Spec) then
4125 Write_Str ("; ");
4126 end if;
4127 end loop;
4129 -- Write out any extra formals
4131 while Present (Extra_Formal (Formal)) loop
4132 Formal := Extra_Formal (Formal);
4133 Write_Str ("; ");
4134 Write_Name_With_Col_Check (Chars (Formal));
4135 Write_Str (" : ");
4136 Write_Name_With_Col_Check (Chars (Etype (Formal)));
4137 end loop;
4139 Write_Char (')');
4140 end if;
4141 end Write_Param_Specs;
4143 -----------------------
4144 -- Write_Rewrite_Str --
4145 -----------------------
4147 procedure Write_Rewrite_Str (S : String) is
4148 begin
4149 if not Dump_Generated_Only then
4150 if S'Length = 3 and then S = ">>>" then
4151 Write_Str (">>>");
4152 else
4153 Write_Str_With_Col_Check (S);
4154 end if;
4155 end if;
4156 end Write_Rewrite_Str;
4158 -----------------------
4159 -- Write_Source_Line --
4160 -----------------------
4162 procedure Write_Source_Line (L : Physical_Line_Number) is
4163 Loc : Source_Ptr;
4164 Src : Source_Buffer_Ptr;
4165 Scn : Source_Ptr;
4167 begin
4168 if Dump_Source_Text then
4169 Src := Source_Text (Current_Source_File);
4170 Loc := Line_Start (L, Current_Source_File);
4171 Write_Eol;
4173 -- See if line is a comment line, if not, and if not line one,
4174 -- precede with blank line.
4176 Scn := Loc;
4177 while Src (Scn) = ' ' or else Src (Scn) = ASCII.HT loop
4178 Scn := Scn + 1;
4179 end loop;
4181 if (Src (Scn) in Line_Terminator
4182 or else Src (Scn .. Scn + 1) /= "--")
4183 and then L /= 1
4184 then
4185 Write_Eol;
4186 end if;
4188 -- Now write the source text of the line
4190 Write_Str ("-- ");
4191 Write_Int (Int (L));
4192 Write_Str (": ");
4194 while Src (Loc) not in Line_Terminator loop
4195 Write_Char (Src (Loc));
4196 Loc := Loc + 1;
4197 end loop;
4198 end if;
4199 end Write_Source_Line;
4201 ------------------------
4202 -- Write_Source_Lines --
4203 ------------------------
4205 procedure Write_Source_Lines (L : Physical_Line_Number) is
4206 begin
4207 while Last_Line_Printed < L loop
4208 Last_Line_Printed := Last_Line_Printed + 1;
4209 Write_Source_Line (Last_Line_Printed);
4210 end loop;
4211 end Write_Source_Lines;
4213 --------------------
4214 -- Write_Str_Sloc --
4215 --------------------
4217 procedure Write_Str_Sloc (S : String) is
4218 begin
4219 for J in S'Range loop
4220 Write_Char_Sloc (S (J));
4221 end loop;
4222 end Write_Str_Sloc;
4224 ------------------------------
4225 -- Write_Str_With_Col_Check --
4226 ------------------------------
4228 procedure Write_Str_With_Col_Check (S : String) is
4229 begin
4230 if Int (S'Last) + Column > Sprint_Line_Limit then
4231 Write_Indent_Str (" ");
4233 if S (S'First) = ' ' then
4234 Write_Str (S (S'First + 1 .. S'Last));
4235 else
4236 Write_Str (S);
4237 end if;
4239 else
4240 Write_Str (S);
4241 end if;
4242 end Write_Str_With_Col_Check;
4244 -----------------------------------
4245 -- Write_Str_With_Col_Check_Sloc --
4246 -----------------------------------
4248 procedure Write_Str_With_Col_Check_Sloc (S : String) is
4249 begin
4250 if Int (S'Last) + Column > Sprint_Line_Limit then
4251 Write_Indent_Str (" ");
4253 if S (S'First) = ' ' then
4254 Write_Str_Sloc (S (S'First + 1 .. S'Last));
4255 else
4256 Write_Str_Sloc (S);
4257 end if;
4259 else
4260 Write_Str_Sloc (S);
4261 end if;
4262 end Write_Str_With_Col_Check_Sloc;
4264 ---------------------------
4265 -- Write_Subprogram_Name --
4266 ---------------------------
4268 procedure Write_Subprogram_Name (N : Node_Id) is
4269 begin
4270 if not Comes_From_Source (N)
4271 and then Is_Entity_Name (N)
4272 then
4273 declare
4274 Ent : constant Entity_Id := Entity (N);
4275 begin
4276 if not In_Extended_Main_Source_Unit (Ent)
4277 and then
4278 Is_Predefined_File_Name
4279 (Unit_File_Name (Get_Source_Unit (Ent)))
4280 then
4281 -- Run-time routine name, output name with a preceding dollar
4282 -- making sure that we do not get a line split between them.
4284 Col_Check (Length_Of_Name (Chars (Ent)) + 1);
4285 Write_Char ('$');
4286 Write_Name (Chars (Ent));
4287 return;
4288 end if;
4289 end;
4290 end if;
4292 -- Normal case, not a run-time routine name
4294 Sprint_Node (N);
4295 end Write_Subprogram_Name;
4297 -------------------------------
4298 -- Write_Uint_With_Col_Check --
4299 -------------------------------
4301 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format) is
4302 begin
4303 Col_Check (UI_Decimal_Digits_Hi (U));
4304 UI_Write (U, Format);
4305 end Write_Uint_With_Col_Check;
4307 ------------------------------------
4308 -- Write_Uint_With_Col_Check_Sloc --
4309 ------------------------------------
4311 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
4312 begin
4313 Col_Check (UI_Decimal_Digits_Hi (U));
4314 Set_Debug_Sloc;
4315 UI_Write (U, Format);
4316 end Write_Uint_With_Col_Check_Sloc;
4318 -------------------------------------
4319 -- Write_Ureal_With_Col_Check_Sloc --
4320 -------------------------------------
4322 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
4323 D : constant Uint := Denominator (U);
4324 N : constant Uint := Numerator (U);
4326 begin
4327 Col_Check
4328 (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
4329 Set_Debug_Sloc;
4330 UR_Write (U);
4331 end Write_Ureal_With_Col_Check_Sloc;
4333 end Sprint;