[gcc/]
[official-gcc.git] / gcc / ada / sprint.adb
blob55669c7f3b513455db8ee59df0e3e625b5b3373a
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-2014, 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 Aspects; use Aspects;
27 with Atree; use Atree;
28 with Casing; use Casing;
29 with Csets; use Csets;
30 with Debug; use Debug;
31 with Einfo; use Einfo;
32 with Fname; use Fname;
33 with Lib; use Lib;
34 with Namet; use Namet;
35 with Nlists; use Nlists;
36 with Opt; use Opt;
37 with Output; use Output;
38 with Rtsfind; use Rtsfind;
39 with Sem_Eval; use Sem_Eval;
40 with Sem_Util; use Sem_Util;
41 with Sinfo; use Sinfo;
42 with Sinput; use Sinput;
43 with Sinput.D; use Sinput.D;
44 with Snames; use Snames;
45 with Stand; use Stand;
46 with Stringt; use Stringt;
47 with Uintp; use Uintp;
48 with Uname; use Uname;
49 with Urealp; use Urealp;
51 package body Sprint is
52 Current_Source_File : Source_File_Index;
53 -- Index of source file whose generated code is being dumped
55 Dump_Node : Node_Id := Empty;
56 -- This is set to the current node, used for printing line numbers. In
57 -- Debug_Generated_Code mode, Dump_Node is set to the current node
58 -- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper
59 -- value. The call clears it back to Empty.
61 Debug_Sloc : Source_Ptr;
62 -- Sloc of first byte of line currently being written if we are
63 -- generating a source debug file.
65 Dump_Original_Only : Boolean;
66 -- Set True if the -gnatdo (dump original tree) flag is set
68 Dump_Generated_Only : Boolean;
69 -- Set True if the -gnatdG (dump generated tree) debug flag is set
70 -- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD).
72 Dump_Freeze_Null : Boolean;
73 -- Set True if empty freeze nodes and non-source null statements output.
74 -- Note that freeze nodes containing freeze actions are always output,
75 -- as are freeze nodes for itypes, which in general have the effect of
76 -- causing elaboration of the itype.
78 Freeze_Indent : Int := 0;
79 -- Keep track of freeze indent level (controls output of blank lines before
80 -- procedures within expression freeze actions). Relevant only if we are
81 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
82 -- output these blank lines in any case.
84 Indent : Int := 0;
85 -- Number of columns for current line output indentation
87 Indent_Annull_Flag : Boolean := False;
88 -- Set True if subsequent Write_Indent call to be ignored, gets reset
89 -- by this call, so it is only active to suppress a single indent call.
91 Last_Line_Printed : Physical_Line_Number;
92 -- This keeps track of the physical line number of the last source line
93 -- that has been output. The value is only valid in Dump_Source_Text mode.
95 -------------------------------
96 -- Operator Precedence Table --
97 -------------------------------
99 -- This table is used to decide whether a subexpression needs to be
100 -- parenthesized. The rule is that if an operand of an operator (which
101 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
102 -- with a lower precedence than the operator (or equal precedence if
103 -- appearing as the right operand), then parentheses are required.
105 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
106 (N_Op_And => 1,
107 N_Op_Or => 1,
108 N_Op_Xor => 1,
109 N_And_Then => 1,
110 N_Or_Else => 1,
112 N_In => 2,
113 N_Not_In => 2,
114 N_Op_Eq => 2,
115 N_Op_Ge => 2,
116 N_Op_Gt => 2,
117 N_Op_Le => 2,
118 N_Op_Lt => 2,
119 N_Op_Ne => 2,
121 N_Op_Add => 3,
122 N_Op_Concat => 3,
123 N_Op_Subtract => 3,
124 N_Op_Plus => 3,
125 N_Op_Minus => 3,
127 N_Op_Divide => 4,
128 N_Op_Mod => 4,
129 N_Op_Rem => 4,
130 N_Op_Multiply => 4,
132 N_Op_Expon => 5,
133 N_Op_Abs => 5,
134 N_Op_Not => 5,
136 others => 6);
138 procedure Sprint_Left_Opnd (N : Node_Id);
139 -- Print left operand of operator, parenthesizing if necessary
141 procedure Sprint_Right_Opnd (N : Node_Id);
142 -- Print right operand of operator, parenthesizing if necessary
144 -----------------------
145 -- Local Subprograms --
146 -----------------------
148 procedure Col_Check (N : Nat);
149 -- Check that at least N characters remain on current line, and if not,
150 -- then start an extra line with two characters extra indentation for
151 -- continuing text on the next line.
153 procedure Extra_Blank_Line;
154 -- In some situations we write extra blank lines to separate the generated
155 -- code to make it more readable. However, these extra blank lines are not
156 -- generated in Dump_Source_Text mode, since there the source text lines
157 -- output with preceding blank lines are quite sufficient as separators.
158 -- This procedure writes a blank line if Dump_Source_Text is False.
160 procedure Indent_Annull;
161 -- Causes following call to Write_Indent to be ignored. This is used when
162 -- a higher level node wants to stop a lower level node from starting a
163 -- new line, when it would otherwise be inclined to do so (e.g. the case
164 -- of an accept statement called from an accept alternative with a guard)
166 procedure Indent_Begin;
167 -- Increase indentation level
169 procedure Indent_End;
170 -- Decrease indentation level
172 procedure Print_Debug_Line (S : String);
173 -- Used to print output lines in Debug_Generated_Code mode (this is used
174 -- as the argument for a call to Set_Special_Output in package Output).
176 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
177 -- Given a divide, multiplication or division node, check the flags
178 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
179 -- appropriate special syntax characters (# and @).
181 procedure Set_Debug_Sloc;
182 -- If Dump_Node is non-empty, this routine sets the appropriate value
183 -- in its Sloc field, from the current location in the debug source file
184 -- that is currently being written.
186 procedure Sprint_And_List (List : List_Id);
187 -- Print the given list with items separated by vertical "and"
189 procedure Sprint_Aspect_Specifications
190 (Node : Node_Id;
191 Semicolon : Boolean);
192 -- Node is a declaration node that has aspect specifications (Has_Aspects
193 -- flag set True). It outputs the aspect specifications. For the case
194 -- of Semicolon = True, it is called after outputting the terminating
195 -- semicolon for the related node. The effect is to remove the semicolon
196 -- and print the aspect specifications followed by a terminating semicolon.
197 -- For the case of Semicolon False, no semicolon is removed or output, and
198 -- all the aspects are printed on a single line.
200 procedure Sprint_Bar_List (List : List_Id);
201 -- Print the given list with items separated by vertical bars
203 procedure Sprint_End_Label
204 (Node : Node_Id;
205 Default : Node_Id);
206 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
207 -- If there is no end label, use the defining identifier of the enclosing
208 -- construct. If the end label is present, treat it as a reference to the
209 -- defining entity of the construct: this guarantees that it carries the
210 -- proper sloc information for debugging purposes.
212 procedure Sprint_Node_Actual (Node : Node_Id);
213 -- This routine prints its node argument. It is a lower level routine than
214 -- Sprint_Node, in that it does not bother about rewritten trees.
216 procedure Sprint_Node_Sloc (Node : Node_Id);
217 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
218 -- sets the Sloc of the current debug node to be a copy of the Sloc
219 -- of the sprinted node Node. Note that this is done after printing
220 -- Node, so that the Sloc is the proper updated value for the debug file.
222 procedure Update_Itype (Node : Node_Id);
223 -- Update the Sloc of an itype that is not attached to the tree, when
224 -- debugging expanded code. This routine is called from nodes whose
225 -- type can be an Itype, such as defining_identifiers that may be of
226 -- an anonymous access type, or ranges in slices.
228 procedure Write_Char_Sloc (C : Character);
229 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
230 -- called to ensure that the current node has a proper Sloc set.
232 procedure Write_Condition_And_Reason (Node : Node_Id);
233 -- Write Condition and Reason codes of Raise_xxx_Error node
235 procedure Write_Corresponding_Source (S : String);
236 -- If S is a string with a single keyword (possibly followed by a space),
237 -- and if the next non-comment non-blank source line matches this keyword,
238 -- then output all source lines up to this matching line.
240 procedure Write_Discr_Specs (N : Node_Id);
241 -- Output discriminant specification for node, which is any of the type
242 -- declarations that can have discriminants.
244 procedure Write_Ekind (E : Entity_Id);
245 -- Write the String corresponding to the Ekind without "E_"
247 procedure Write_Id (N : Node_Id);
248 -- N is a node with a Chars field. This procedure writes the name that
249 -- will be used in the generated code associated with the name. For a
250 -- node with no associated entity, this is simply the Chars field. For
251 -- the case where there is an entity associated with the node, we print
252 -- the name associated with the entity (since it may have been encoded).
253 -- One other special case is that an entity has an active external name
254 -- (i.e. an external name present with no address clause), then this
255 -- external name is output. This procedure also deals with outputting
256 -- declarations of referenced itypes, if not output earlier.
258 function Write_Identifiers (Node : Node_Id) return Boolean;
259 -- Handle node where the grammar has a list of defining identifiers, but
260 -- the tree has a separate declaration for each identifier. Handles the
261 -- printing of the defining identifier, and returns True if the type and
262 -- initialization information is to be printed, False if it is to be
263 -- skipped (the latter case happens when printing defining identifiers
264 -- other than the first in the original tree output case).
266 procedure Write_Implicit_Def (E : Entity_Id);
267 pragma Warnings (Off, Write_Implicit_Def);
268 -- Write the definition of the implicit type E according to its Ekind
269 -- For now a debugging procedure, but might be used in the future.
271 procedure Write_Indent;
272 -- Start a new line and write indentation spacing
274 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
275 -- Like Write_Identifiers except that each new printed declaration
276 -- is at the start of a new line.
278 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
279 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
280 -- mode, the Sloc of the current debug node is set to point to the
281 -- first output identifier.
283 procedure Write_Indent_Str (S : String);
284 -- Start a new line and write indent spacing followed by given string
286 procedure Write_Indent_Str_Sloc (S : String);
287 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
288 -- the Sloc of the current node is set to the first non-blank character
289 -- in the string S.
291 procedure Write_Itype (Typ : Entity_Id);
292 -- If Typ is an Itype that has not been written yet, write it. If Typ is
293 -- any other kind of entity or tree node, the call is ignored.
295 procedure Write_Name_With_Col_Check (N : Name_Id);
296 -- Write name (using Write_Name) with initial column check, and possible
297 -- initial Write_Indent (to get new line) if current line is too full.
299 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
300 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
301 -- mode, sets Sloc of current debug node to first character of name.
303 procedure Write_Operator (N : Node_Id; S : String);
304 -- Like Write_Str_Sloc, used for operators, encloses the string in
305 -- characters {} if the Do_Overflow flag is set on the node N.
307 procedure Write_Param_Specs (N : Node_Id);
308 -- Output parameter specifications for node (which is either a function
309 -- or procedure specification with a Parameter_Specifications field)
311 procedure Write_Rewrite_Str (S : String);
312 -- Writes out a string (typically containing <<< or >>>}) for a node
313 -- created by rewriting the tree. Suppressed if we are outputting the
314 -- generated code only, since in this case we don't specially mark nodes
315 -- created by rewriting).
317 procedure Write_Source_Line (L : Physical_Line_Number);
318 -- If writing of interspersed source lines is enabled, then write the given
319 -- line from the source file, preceded by Eol, then an extra blank line if
320 -- the line has at least one blank, is not a comment and is not line one,
321 -- then "--" and the line number followed by period followed by text of the
322 -- source line (without terminating Eol). If interspersed source line
323 -- output not enabled, then the call has no effect.
325 procedure Write_Source_Lines (L : Physical_Line_Number);
326 -- If writing of interspersed source lines is enabled, then writes source
327 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
328 -- interspersed source line output not enabled, then call has no effect.
330 procedure Write_Str_Sloc (S : String);
331 -- Like Write_Str, but sets debug Sloc of current debug node to first
332 -- non-blank character if a current debug node is active.
334 procedure Write_Str_With_Col_Check (S : String);
335 -- Write string (using Write_Str) with initial column check, and possible
336 -- initial Write_Indent (to get new line) if current line is too full.
338 procedure Write_Str_With_Col_Check_Sloc (S : String);
339 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
340 -- node to first non-blank character if a current debug node is active.
342 procedure Write_Subprogram_Name (N : Node_Id);
343 -- N is the Name field of a function call or procedure statement call.
344 -- The effect of the call is to output the name, preceded by a $ if the
345 -- call is identified as an implicit call to a run time routine.
347 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format);
348 -- Write Uint (using UI_Write) with initial column check, and possible
349 -- initial Write_Indent (to get new line) if current line is too full.
350 -- The format parameter determines the output format (see UI_Write).
352 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
353 -- Write Uint (using UI_Write) with initial column check, and possible
354 -- initial Write_Indent (to get new line) if current line is too full.
355 -- The format parameter determines the output format (see UI_Write).
356 -- In addition, in Debug_Generated_Code mode, sets the current node
357 -- Sloc to the first character of the output value.
359 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
360 -- Write Ureal (using same output format as UR_Write) with column checks
361 -- and a possible initial Write_Indent (to get new line) if current line
362 -- is too full. In addition, in Debug_Generated_Code mode, sets the
363 -- current node Sloc to the first character of the output value.
365 ---------------
366 -- Col_Check --
367 ---------------
369 procedure Col_Check (N : Nat) is
370 begin
371 if N + Column > Sprint_Line_Limit then
372 Write_Indent_Str (" ");
373 end if;
374 end Col_Check;
376 ----------------------
377 -- Extra_Blank_Line --
378 ----------------------
380 procedure Extra_Blank_Line is
381 begin
382 if not Dump_Source_Text then
383 Write_Indent;
384 end if;
385 end Extra_Blank_Line;
387 -------------------
388 -- Indent_Annull --
389 -------------------
391 procedure Indent_Annull is
392 begin
393 Indent_Annull_Flag := True;
394 end Indent_Annull;
396 ------------------
397 -- Indent_Begin --
398 ------------------
400 procedure Indent_Begin is
401 begin
402 Indent := Indent + 3;
403 end Indent_Begin;
405 ----------------
406 -- Indent_End --
407 ----------------
409 procedure Indent_End is
410 begin
411 Indent := Indent - 3;
412 end Indent_End;
414 --------
415 -- pg --
416 --------
418 procedure pg (Arg : Union_Id) is
419 begin
420 Dump_Generated_Only := True;
421 Dump_Original_Only := False;
422 Dump_Freeze_Null := True;
423 Current_Source_File := No_Source_File;
425 if Arg in List_Range then
426 Sprint_Node_List (List_Id (Arg), New_Lines => True);
428 elsif Arg in Node_Range then
429 Sprint_Node (Node_Id (Arg));
431 else
432 null;
433 end if;
435 Write_Eol;
436 end pg;
438 --------
439 -- po --
440 --------
442 procedure po (Arg : Union_Id) is
443 begin
444 Dump_Generated_Only := False;
445 Dump_Original_Only := True;
446 Current_Source_File := No_Source_File;
448 if Arg in List_Range then
449 Sprint_Node_List (List_Id (Arg), New_Lines => True);
451 elsif Arg in Node_Range then
452 Sprint_Node (Node_Id (Arg));
454 else
455 null;
456 end if;
458 Write_Eol;
459 end po;
461 ----------------------
462 -- Print_Debug_Line --
463 ----------------------
465 procedure Print_Debug_Line (S : String) is
466 begin
467 Write_Debug_Line (S, Debug_Sloc);
468 end Print_Debug_Line;
470 ---------------------------
471 -- Process_TFAI_RR_Flags --
472 ---------------------------
474 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
475 begin
476 if Treat_Fixed_As_Integer (Nod) then
477 Write_Char ('#');
478 end if;
480 if Rounded_Result (Nod) then
481 Write_Char ('@');
482 end if;
483 end Process_TFAI_RR_Flags;
485 --------
486 -- ps --
487 --------
489 procedure ps (Arg : Union_Id) is
490 begin
491 Dump_Generated_Only := False;
492 Dump_Original_Only := False;
493 Current_Source_File := No_Source_File;
495 if Arg in List_Range then
496 Sprint_Node_List (List_Id (Arg), New_Lines => True);
498 elsif Arg in Node_Range then
499 Sprint_Node (Node_Id (Arg));
501 else
502 null;
503 end if;
505 Write_Eol;
506 end ps;
508 --------------------
509 -- Set_Debug_Sloc --
510 --------------------
512 procedure Set_Debug_Sloc is
513 begin
514 if Debug_Generated_Code and then Present (Dump_Node) then
515 Set_Sloc (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1));
517 -- We do not know the actual end location in the generated code and
518 -- it could be much closer than in the source code, so play safe.
520 if Nkind_In (Dump_Node, N_Case_Statement, N_If_Statement) then
521 Set_End_Location (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1));
522 end if;
524 Dump_Node := Empty;
525 end if;
526 end Set_Debug_Sloc;
528 -----------------
529 -- Source_Dump --
530 -----------------
532 procedure Source_Dump is
534 procedure Underline;
535 -- Put underline under string we just printed
537 ---------------
538 -- Underline --
539 ---------------
541 procedure Underline is
542 Col : constant Int := Column;
544 begin
545 Write_Eol;
547 while Col > Column loop
548 Write_Char ('-');
549 end loop;
551 Write_Eol;
552 end Underline;
554 -- Start of processing for Source_Dump
556 begin
557 Dump_Generated_Only := Debug_Flag_G or
558 Print_Generated_Code or
559 Debug_Generated_Code;
560 Dump_Original_Only := Debug_Flag_O;
561 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
563 -- Note that we turn off the tree dump flags immediately, before
564 -- starting the dump. This avoids generating two copies of the dump
565 -- if an abort occurs after printing the dump, and more importantly,
566 -- avoids an infinite loop if an abort occurs during the dump.
568 if Debug_Flag_Z then
569 Current_Source_File := No_Source_File;
570 Debug_Flag_Z := False;
571 Write_Eol;
572 Write_Eol;
573 Write_Str ("Source recreated from tree of Standard (spec)");
574 Underline;
575 Sprint_Node (Standard_Package_Node);
576 Write_Eol;
577 Write_Eol;
578 end if;
580 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
581 Debug_Flag_G := False;
582 Debug_Flag_O := False;
583 Debug_Flag_S := False;
585 -- Dump requested units
587 for U in Main_Unit .. Last_Unit loop
588 Current_Source_File := Source_Index (U);
590 -- Dump all units if -gnatdf set, otherwise we dump only
591 -- the source files that are in the extended main source.
593 if Debug_Flag_F
594 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
595 then
596 -- If we are generating debug files, setup to write them
598 if Debug_Generated_Code then
599 Set_Special_Output (Print_Debug_Line'Access);
600 Create_Debug_Source (Source_Index (U), Debug_Sloc);
601 Write_Source_Line (1);
602 Last_Line_Printed := 1;
603 Sprint_Node (Cunit (U));
604 Write_Source_Lines (Last_Source_Line (Current_Source_File));
605 Write_Eol;
606 Close_Debug_Source;
607 Set_Special_Output (null);
609 -- Normal output to standard output file
611 else
612 Write_Str ("Source recreated from tree for ");
613 Write_Unit_Name (Unit_Name (U));
614 Underline;
615 Write_Source_Line (1);
616 Last_Line_Printed := 1;
617 Sprint_Node (Cunit (U));
618 Write_Source_Lines (Last_Source_Line (Current_Source_File));
619 Write_Eol;
620 Write_Eol;
621 end if;
622 end if;
623 end loop;
624 end if;
625 end Source_Dump;
627 ---------------------
628 -- Sprint_And_List --
629 ---------------------
631 procedure Sprint_And_List (List : List_Id) is
632 Node : Node_Id;
633 begin
634 if Is_Non_Empty_List (List) then
635 Node := First (List);
636 loop
637 Sprint_Node (Node);
638 Next (Node);
639 exit when Node = Empty;
640 Write_Str (" and ");
641 end loop;
642 end if;
643 end Sprint_And_List;
645 ----------------------------------
646 -- Sprint_Aspect_Specifications --
647 ----------------------------------
649 procedure Sprint_Aspect_Specifications
650 (Node : Node_Id;
651 Semicolon : Boolean)
653 AS : constant List_Id := Aspect_Specifications (Node);
654 A : Node_Id;
656 begin
657 if Semicolon then
658 Write_Erase_Char (';');
659 Indent := Indent + 2;
660 Write_Indent;
661 Write_Str ("with ");
662 Indent := Indent + 5;
664 else
665 Write_Str (" with ");
666 end if;
668 A := First (AS);
669 loop
670 Sprint_Node (Identifier (A));
672 if Class_Present (A) then
673 Write_Str ("'Class");
674 end if;
676 if Present (Expression (A)) then
677 Write_Str (" => ");
678 Sprint_Node (Expression (A));
679 end if;
681 Next (A);
683 exit when No (A);
684 Write_Char (',');
686 if Semicolon then
687 Write_Indent;
688 end if;
689 end loop;
691 if Semicolon then
692 Indent := Indent - 7;
693 Write_Char (';');
694 end if;
695 end Sprint_Aspect_Specifications;
697 ---------------------
698 -- Sprint_Bar_List --
699 ---------------------
701 procedure Sprint_Bar_List (List : List_Id) is
702 Node : Node_Id;
703 begin
704 if Is_Non_Empty_List (List) then
705 Node := First (List);
706 loop
707 Sprint_Node (Node);
708 Next (Node);
709 exit when Node = Empty;
710 Write_Str (" | ");
711 end loop;
712 end if;
713 end Sprint_Bar_List;
715 ----------------------
716 -- Sprint_End_Label --
717 ----------------------
719 procedure Sprint_End_Label
720 (Node : Node_Id;
721 Default : Node_Id)
723 begin
724 if Present (Node)
725 and then Present (End_Label (Node))
726 and then Is_Entity_Name (End_Label (Node))
727 then
728 Set_Entity (End_Label (Node), Default);
730 -- For a function whose name is an operator, use the qualified name
731 -- created for the defining entity.
733 if Nkind (End_Label (Node)) = N_Operator_Symbol then
734 Set_Chars (End_Label (Node), Chars (Default));
735 end if;
737 Sprint_Node (End_Label (Node));
738 else
739 Sprint_Node (Default);
740 end if;
741 end Sprint_End_Label;
743 -----------------------
744 -- Sprint_Comma_List --
745 -----------------------
747 procedure Sprint_Comma_List (List : List_Id) is
748 Node : Node_Id;
750 begin
751 if Is_Non_Empty_List (List) then
752 Node := First (List);
753 loop
754 Sprint_Node (Node);
755 Next (Node);
756 exit when Node = Empty;
758 if not Is_Rewrite_Insertion (Node)
759 or else not Dump_Original_Only
760 then
761 Write_Str (", ");
762 end if;
763 end loop;
764 end if;
765 end Sprint_Comma_List;
767 --------------------------
768 -- Sprint_Indented_List --
769 --------------------------
771 procedure Sprint_Indented_List (List : List_Id) is
772 begin
773 Indent_Begin;
774 Sprint_Node_List (List);
775 Indent_End;
776 end Sprint_Indented_List;
778 ---------------------
779 -- Sprint_Left_Opnd --
780 ---------------------
782 procedure Sprint_Left_Opnd (N : Node_Id) is
783 Opnd : constant Node_Id := Left_Opnd (N);
785 begin
786 if Paren_Count (Opnd) /= 0
787 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
788 then
789 Sprint_Node (Opnd);
791 else
792 Write_Char ('(');
793 Sprint_Node (Opnd);
794 Write_Char (')');
795 end if;
796 end Sprint_Left_Opnd;
798 -----------------
799 -- Sprint_Node --
800 -----------------
802 procedure Sprint_Node (Node : Node_Id) is
803 begin
804 if Is_Rewrite_Insertion (Node) then
805 if not Dump_Original_Only then
807 -- For special cases of nodes that always output <<< >>>
808 -- do not duplicate the output at this point.
810 if Nkind (Node) = N_Freeze_Entity
811 or else Nkind (Node) = N_Freeze_Generic_Entity
812 or else Nkind (Node) = N_Implicit_Label_Declaration
813 then
814 Sprint_Node_Actual (Node);
816 -- Normal case where <<< >>> may be required
818 else
819 Write_Rewrite_Str ("<<<");
820 Sprint_Node_Actual (Node);
821 Write_Rewrite_Str (">>>");
822 end if;
823 end if;
825 elsif Is_Rewrite_Substitution (Node) then
827 -- Case of dump generated only
829 if Dump_Generated_Only then
830 Sprint_Node_Actual (Node);
832 -- Case of dump original only
834 elsif Dump_Original_Only then
835 Sprint_Node_Actual (Original_Node (Node));
837 -- Case of both being dumped
839 else
840 Sprint_Node_Actual (Original_Node (Node));
841 Write_Rewrite_Str ("<<<");
842 Sprint_Node_Actual (Node);
843 Write_Rewrite_Str (">>>");
844 end if;
846 else
847 Sprint_Node_Actual (Node);
848 end if;
849 end Sprint_Node;
851 ------------------------
852 -- Sprint_Node_Actual --
853 ------------------------
855 procedure Sprint_Node_Actual (Node : Node_Id) is
856 Save_Dump_Node : constant Node_Id := Dump_Node;
858 begin
859 if Node = Empty then
860 return;
861 end if;
863 for J in 1 .. Paren_Count (Node) loop
864 Write_Str_With_Col_Check ("(");
865 end loop;
867 -- Setup current dump node
869 Dump_Node := Node;
871 if Nkind (Node) in N_Subexpr
872 and then Do_Range_Check (Node)
873 then
874 Write_Str_With_Col_Check ("{");
875 end if;
877 -- Select print circuit based on node kind
879 case Nkind (Node) is
880 when N_Abort_Statement =>
881 Write_Indent_Str_Sloc ("abort ");
882 Sprint_Comma_List (Names (Node));
883 Write_Char (';');
885 when N_Abortable_Part =>
886 Set_Debug_Sloc;
887 Write_Str_Sloc ("abort ");
888 Sprint_Indented_List (Statements (Node));
890 when N_Abstract_Subprogram_Declaration =>
891 Write_Indent;
892 Sprint_Node (Specification (Node));
893 Write_Str_With_Col_Check (" is ");
894 Write_Str_Sloc ("abstract;");
896 when N_Accept_Alternative =>
897 Sprint_Node_List (Pragmas_Before (Node));
899 if Present (Condition (Node)) then
900 Write_Indent_Str ("when ");
901 Sprint_Node (Condition (Node));
902 Write_Str (" => ");
903 Indent_Annull;
904 end if;
906 Sprint_Node_Sloc (Accept_Statement (Node));
907 Sprint_Node_List (Statements (Node));
909 when N_Accept_Statement =>
910 Write_Indent_Str_Sloc ("accept ");
911 Write_Id (Entry_Direct_Name (Node));
913 if Present (Entry_Index (Node)) then
914 Write_Str_With_Col_Check (" (");
915 Sprint_Node (Entry_Index (Node));
916 Write_Char (')');
917 end if;
919 Write_Param_Specs (Node);
921 if Present (Handled_Statement_Sequence (Node)) then
922 Write_Str_With_Col_Check (" do");
923 Sprint_Node (Handled_Statement_Sequence (Node));
924 Write_Indent_Str ("end ");
925 Write_Id (Entry_Direct_Name (Node));
926 end if;
928 Write_Char (';');
930 when N_Access_Definition =>
932 -- Ada 2005 (AI-254)
934 if Present (Access_To_Subprogram_Definition (Node)) then
935 Sprint_Node (Access_To_Subprogram_Definition (Node));
936 else
937 -- Ada 2005 (AI-231)
939 if Null_Exclusion_Present (Node) then
940 Write_Str ("not null ");
941 end if;
943 Write_Str_With_Col_Check_Sloc ("access ");
945 if All_Present (Node) then
946 Write_Str ("all ");
947 elsif Constant_Present (Node) then
948 Write_Str ("constant ");
949 end if;
951 Sprint_Node (Subtype_Mark (Node));
952 end if;
954 when N_Access_Function_Definition =>
956 -- Ada 2005 (AI-231)
958 if Null_Exclusion_Present (Node) then
959 Write_Str ("not null ");
960 end if;
962 Write_Str_With_Col_Check_Sloc ("access ");
964 if Protected_Present (Node) then
965 Write_Str_With_Col_Check ("protected ");
966 end if;
968 Write_Str_With_Col_Check ("function");
969 Write_Param_Specs (Node);
970 Write_Str_With_Col_Check (" return ");
971 Sprint_Node (Result_Definition (Node));
973 when N_Access_Procedure_Definition =>
975 -- Ada 2005 (AI-231)
977 if Null_Exclusion_Present (Node) then
978 Write_Str ("not null ");
979 end if;
981 Write_Str_With_Col_Check_Sloc ("access ");
983 if Protected_Present (Node) then
984 Write_Str_With_Col_Check ("protected ");
985 end if;
987 Write_Str_With_Col_Check ("procedure");
988 Write_Param_Specs (Node);
990 when N_Access_To_Object_Definition =>
991 Write_Str_With_Col_Check_Sloc ("access ");
993 if All_Present (Node) then
994 Write_Str_With_Col_Check ("all ");
995 elsif Constant_Present (Node) then
996 Write_Str_With_Col_Check ("constant ");
997 end if;
999 -- Ada 2005 (AI-231)
1001 if Null_Exclusion_Present (Node) then
1002 Write_Str ("not null ");
1003 end if;
1005 Sprint_Node (Subtype_Indication (Node));
1007 when N_Aggregate =>
1008 if Null_Record_Present (Node) then
1009 Write_Str_With_Col_Check_Sloc ("(null record)");
1011 else
1012 Write_Str_With_Col_Check_Sloc ("(");
1014 if Present (Expressions (Node)) then
1015 Sprint_Comma_List (Expressions (Node));
1017 if Present (Component_Associations (Node))
1018 and then not Is_Empty_List (Component_Associations (Node))
1019 then
1020 Write_Str (", ");
1021 end if;
1022 end if;
1024 if Present (Component_Associations (Node))
1025 and then not Is_Empty_List (Component_Associations (Node))
1026 then
1027 Indent_Begin;
1029 declare
1030 Nd : Node_Id;
1032 begin
1033 Nd := First (Component_Associations (Node));
1035 loop
1036 Write_Indent;
1037 Sprint_Node (Nd);
1038 Next (Nd);
1039 exit when No (Nd);
1041 if not Is_Rewrite_Insertion (Nd)
1042 or else not Dump_Original_Only
1043 then
1044 Write_Str (", ");
1045 end if;
1046 end loop;
1047 end;
1049 Indent_End;
1050 end if;
1052 Write_Char (')');
1053 end if;
1055 when N_Allocator =>
1056 Write_Str_With_Col_Check_Sloc ("new ");
1058 -- Ada 2005 (AI-231)
1060 if Null_Exclusion_Present (Node) then
1061 Write_Str ("not null ");
1062 end if;
1064 Sprint_Node (Expression (Node));
1066 if Present (Storage_Pool (Node)) then
1067 Write_Str_With_Col_Check ("[storage_pool = ");
1068 Sprint_Node (Storage_Pool (Node));
1069 Write_Char (']');
1070 end if;
1072 when N_And_Then =>
1073 Sprint_Left_Opnd (Node);
1074 Write_Str_Sloc (" and then ");
1075 Sprint_Right_Opnd (Node);
1077 -- Note: the following code for N_Aspect_Specification is not
1078 -- normally used, since we deal with aspects as part of a
1079 -- declaration, but it is here in case we deliberately try
1080 -- to print an N_Aspect_Speficiation node (e.g. from GDB).
1082 when N_Aspect_Specification =>
1083 Sprint_Node (Identifier (Node));
1084 Write_Str (" => ");
1085 Sprint_Node (Expression (Node));
1087 when N_Assignment_Statement =>
1088 Write_Indent;
1089 Sprint_Node (Name (Node));
1090 Write_Str_Sloc (" := ");
1091 Sprint_Node (Expression (Node));
1092 Write_Char (';');
1094 when N_Asynchronous_Select =>
1095 Write_Indent_Str_Sloc ("select");
1096 Indent_Begin;
1097 Sprint_Node (Triggering_Alternative (Node));
1098 Indent_End;
1100 -- Note: let the printing of Abortable_Part handle outputting
1101 -- the ABORT keyword, so that the Sloc can be set correctly.
1103 Write_Indent_Str ("then ");
1104 Sprint_Node (Abortable_Part (Node));
1105 Write_Indent_Str ("end select;");
1107 when N_At_Clause =>
1108 Write_Indent_Str_Sloc ("for ");
1109 Write_Id (Identifier (Node));
1110 Write_Str_With_Col_Check (" use at ");
1111 Sprint_Node (Expression (Node));
1112 Write_Char (';');
1114 when N_Attribute_Definition_Clause =>
1115 Write_Indent_Str_Sloc ("for ");
1116 Sprint_Node (Name (Node));
1117 Write_Char (''');
1118 Write_Name_With_Col_Check (Chars (Node));
1119 Write_Str_With_Col_Check (" use ");
1120 Sprint_Node (Expression (Node));
1121 Write_Char (';');
1123 when N_Attribute_Reference =>
1124 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1125 Write_Indent;
1126 end if;
1128 Sprint_Node (Prefix (Node));
1129 Write_Char_Sloc (''');
1130 Write_Name_With_Col_Check (Attribute_Name (Node));
1131 Sprint_Paren_Comma_List (Expressions (Node));
1133 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1134 Write_Char (';');
1135 end if;
1137 when N_Block_Statement =>
1138 Write_Indent;
1140 if Present (Identifier (Node))
1141 and then (not Has_Created_Identifier (Node)
1142 or else not Dump_Original_Only)
1143 then
1144 Write_Rewrite_Str ("<<<");
1145 Write_Id (Identifier (Node));
1146 Write_Str (" : ");
1147 Write_Rewrite_Str (">>>");
1148 end if;
1150 if Present (Declarations (Node)) then
1151 Write_Str_With_Col_Check_Sloc ("declare");
1152 Sprint_Indented_List (Declarations (Node));
1153 Write_Indent;
1154 end if;
1156 Write_Str_With_Col_Check_Sloc ("begin");
1157 Sprint_Node (Handled_Statement_Sequence (Node));
1158 Write_Indent_Str ("end");
1160 if Present (Identifier (Node))
1161 and then (not Has_Created_Identifier (Node)
1162 or else not Dump_Original_Only)
1163 then
1164 Write_Rewrite_Str ("<<<");
1165 Write_Char (' ');
1166 Write_Id (Identifier (Node));
1167 Write_Rewrite_Str (">>>");
1168 end if;
1170 Write_Char (';');
1172 when N_Case_Expression =>
1173 declare
1174 Has_Parens : constant Boolean := Paren_Count (Node) > 0;
1175 Alt : Node_Id;
1177 begin
1178 -- The syntax for case_expression does not include parentheses,
1179 -- but sometimes parentheses are required, so unconditionally
1180 -- generate them here unless already present.
1182 if not Has_Parens then
1183 Write_Char ('(');
1184 end if;
1186 Write_Str_With_Col_Check_Sloc ("case ");
1187 Sprint_Node (Expression (Node));
1188 Write_Str_With_Col_Check (" is");
1190 Alt := First (Alternatives (Node));
1191 loop
1192 Sprint_Node (Alt);
1193 Next (Alt);
1194 exit when No (Alt);
1195 Write_Char (',');
1196 end loop;
1198 if not Has_Parens then
1199 Write_Char (')');
1200 end if;
1201 end;
1203 when N_Case_Expression_Alternative =>
1204 Write_Str_With_Col_Check (" when ");
1205 Sprint_Bar_List (Discrete_Choices (Node));
1206 Write_Str (" => ");
1207 Sprint_Node (Expression (Node));
1209 when N_Case_Statement =>
1210 Write_Indent_Str_Sloc ("case ");
1211 Sprint_Node (Expression (Node));
1212 Write_Str (" is");
1213 Sprint_Indented_List (Alternatives (Node));
1214 Write_Indent_Str ("end case;");
1216 when N_Case_Statement_Alternative =>
1217 Write_Indent_Str_Sloc ("when ");
1218 Sprint_Bar_List (Discrete_Choices (Node));
1219 Write_Str (" => ");
1220 Sprint_Indented_List (Statements (Node));
1222 when N_Character_Literal =>
1223 if Column > Sprint_Line_Limit - 2 then
1224 Write_Indent_Str (" ");
1225 end if;
1227 Write_Char_Sloc (''');
1228 Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
1229 Write_Char (''');
1231 when N_Code_Statement =>
1232 Write_Indent;
1233 Set_Debug_Sloc;
1234 Sprint_Node (Expression (Node));
1235 Write_Char (';');
1237 when N_Compilation_Unit =>
1238 Sprint_Node_List (Context_Items (Node));
1239 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
1241 if Private_Present (Node) then
1242 Write_Indent_Str ("private ");
1243 Indent_Annull;
1244 end if;
1246 Sprint_Node_Sloc (Unit (Node));
1248 if Present (Actions (Aux_Decls_Node (Node)))
1249 or else
1250 Present (Pragmas_After (Aux_Decls_Node (Node)))
1251 then
1252 Write_Indent;
1253 end if;
1255 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
1256 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
1258 when N_Compilation_Unit_Aux =>
1259 null; -- nothing to do, never used, see above
1261 when N_Component_Association =>
1262 Set_Debug_Sloc;
1263 Sprint_Bar_List (Choices (Node));
1264 Write_Str (" => ");
1266 -- Ada 2005 (AI-287): Print the box if present
1268 if Box_Present (Node) then
1269 Write_Str_With_Col_Check ("<>");
1270 else
1271 Sprint_Node (Expression (Node));
1272 end if;
1274 when N_Component_Clause =>
1275 Write_Indent;
1276 Sprint_Node (Component_Name (Node));
1277 Write_Str_Sloc (" at ");
1278 Sprint_Node (Position (Node));
1279 Write_Char (' ');
1280 Write_Str_With_Col_Check ("range ");
1281 Sprint_Node (First_Bit (Node));
1282 Write_Str (" .. ");
1283 Sprint_Node (Last_Bit (Node));
1284 Write_Char (';');
1286 when N_Component_Definition =>
1287 Set_Debug_Sloc;
1289 -- Ada 2005 (AI-230): Access definition components
1291 if Present (Access_Definition (Node)) then
1292 Sprint_Node (Access_Definition (Node));
1294 elsif Present (Subtype_Indication (Node)) then
1295 if Aliased_Present (Node) then
1296 Write_Str_With_Col_Check ("aliased ");
1297 end if;
1299 -- Ada 2005 (AI-231)
1301 if Null_Exclusion_Present (Node) then
1302 Write_Str (" not null ");
1303 end if;
1305 Sprint_Node (Subtype_Indication (Node));
1307 else
1308 Write_Str (" ??? ");
1309 end if;
1311 when N_Component_Declaration =>
1312 if Write_Indent_Identifiers_Sloc (Node) then
1313 Write_Str (" : ");
1314 Sprint_Node (Component_Definition (Node));
1316 if Present (Expression (Node)) then
1317 Write_Str (" := ");
1318 Sprint_Node (Expression (Node));
1319 end if;
1321 Write_Char (';');
1322 end if;
1324 when N_Component_List =>
1325 if Null_Present (Node) then
1326 Indent_Begin;
1327 Write_Indent_Str_Sloc ("null");
1328 Write_Char (';');
1329 Indent_End;
1331 else
1332 Set_Debug_Sloc;
1333 Sprint_Indented_List (Component_Items (Node));
1334 Sprint_Node (Variant_Part (Node));
1335 end if;
1337 when N_Compound_Statement =>
1338 Write_Indent_Str ("do");
1339 Indent_Begin;
1340 Sprint_Node_List (Actions (Node));
1341 Indent_End;
1342 Write_Indent_Str ("end;");
1344 when N_Conditional_Entry_Call =>
1345 Write_Indent_Str_Sloc ("select");
1346 Indent_Begin;
1347 Sprint_Node (Entry_Call_Alternative (Node));
1348 Indent_End;
1349 Write_Indent_Str ("else");
1350 Sprint_Indented_List (Else_Statements (Node));
1351 Write_Indent_Str ("end select;");
1353 when N_Constrained_Array_Definition =>
1354 Write_Str_With_Col_Check_Sloc ("array ");
1355 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1356 Write_Str (" of ");
1358 Sprint_Node (Component_Definition (Node));
1360 -- A contract node should not appear in the tree. It is a semantic
1361 -- node attached to entry and [generic] subprogram entities.
1363 when N_Contract =>
1364 raise Program_Error;
1366 when N_Decimal_Fixed_Point_Definition =>
1367 Write_Str_With_Col_Check_Sloc (" delta ");
1368 Sprint_Node (Delta_Expression (Node));
1369 Write_Str_With_Col_Check ("digits ");
1370 Sprint_Node (Digits_Expression (Node));
1371 Sprint_Opt_Node (Real_Range_Specification (Node));
1373 when N_Defining_Character_Literal =>
1374 Write_Name_With_Col_Check_Sloc (Chars (Node));
1376 when N_Defining_Identifier =>
1377 Set_Debug_Sloc;
1378 Write_Id (Node);
1380 when N_Defining_Operator_Symbol =>
1381 Write_Name_With_Col_Check_Sloc (Chars (Node));
1383 when N_Defining_Program_Unit_Name =>
1384 Set_Debug_Sloc;
1385 Sprint_Node (Name (Node));
1386 Write_Char ('.');
1387 Write_Id (Defining_Identifier (Node));
1389 when N_Delay_Alternative =>
1390 Sprint_Node_List (Pragmas_Before (Node));
1392 if Present (Condition (Node)) then
1393 Write_Indent;
1394 Write_Str_With_Col_Check ("when ");
1395 Sprint_Node (Condition (Node));
1396 Write_Str (" => ");
1397 Indent_Annull;
1398 end if;
1400 Sprint_Node_Sloc (Delay_Statement (Node));
1401 Sprint_Node_List (Statements (Node));
1403 when N_Delay_Relative_Statement =>
1404 Write_Indent_Str_Sloc ("delay ");
1405 Sprint_Node (Expression (Node));
1406 Write_Char (';');
1408 when N_Delay_Until_Statement =>
1409 Write_Indent_Str_Sloc ("delay until ");
1410 Sprint_Node (Expression (Node));
1411 Write_Char (';');
1413 when N_Delta_Constraint =>
1414 Write_Str_With_Col_Check_Sloc ("delta ");
1415 Sprint_Node (Delta_Expression (Node));
1416 Sprint_Opt_Node (Range_Constraint (Node));
1418 when N_Derived_Type_Definition =>
1419 if Abstract_Present (Node) then
1420 Write_Str_With_Col_Check ("abstract ");
1421 end if;
1423 Write_Str_With_Col_Check ("new ");
1425 -- Ada 2005 (AI-231)
1427 if Null_Exclusion_Present (Node) then
1428 Write_Str_With_Col_Check ("not null ");
1429 end if;
1431 Sprint_Node (Subtype_Indication (Node));
1433 if Present (Interface_List (Node)) then
1434 Write_Str_With_Col_Check (" and ");
1435 Sprint_And_List (Interface_List (Node));
1436 Write_Str_With_Col_Check (" with ");
1437 end if;
1439 if Present (Record_Extension_Part (Node)) then
1440 if No (Interface_List (Node)) then
1441 Write_Str_With_Col_Check (" with ");
1442 end if;
1444 Sprint_Node (Record_Extension_Part (Node));
1445 end if;
1447 when N_Designator =>
1448 Sprint_Node (Name (Node));
1449 Write_Char_Sloc ('.');
1450 Write_Id (Identifier (Node));
1452 when N_Digits_Constraint =>
1453 Write_Str_With_Col_Check_Sloc ("digits ");
1454 Sprint_Node (Digits_Expression (Node));
1455 Sprint_Opt_Node (Range_Constraint (Node));
1457 when N_Discriminant_Association =>
1458 Set_Debug_Sloc;
1460 if Present (Selector_Names (Node)) then
1461 Sprint_Bar_List (Selector_Names (Node));
1462 Write_Str (" => ");
1463 end if;
1465 Set_Debug_Sloc;
1466 Sprint_Node (Expression (Node));
1468 when N_Discriminant_Specification =>
1469 Set_Debug_Sloc;
1471 if Write_Identifiers (Node) then
1472 Write_Str (" : ");
1474 if Null_Exclusion_Present (Node) then
1475 Write_Str ("not null ");
1476 end if;
1478 Sprint_Node (Discriminant_Type (Node));
1480 if Present (Expression (Node)) then
1481 Write_Str (" := ");
1482 Sprint_Node (Expression (Node));
1483 end if;
1484 else
1485 Write_Str (", ");
1486 end if;
1488 when N_Elsif_Part =>
1489 Write_Indent_Str_Sloc ("elsif ");
1490 Sprint_Node (Condition (Node));
1491 Write_Str_With_Col_Check (" then");
1492 Sprint_Indented_List (Then_Statements (Node));
1494 when N_Empty =>
1495 null;
1497 when N_Entry_Body =>
1498 Write_Indent_Str_Sloc ("entry ");
1499 Write_Id (Defining_Identifier (Node));
1500 Sprint_Node (Entry_Body_Formal_Part (Node));
1501 Write_Str_With_Col_Check (" is");
1502 Sprint_Indented_List (Declarations (Node));
1503 Write_Indent_Str ("begin");
1504 Sprint_Node (Handled_Statement_Sequence (Node));
1505 Write_Indent_Str ("end ");
1506 Write_Id (Defining_Identifier (Node));
1507 Write_Char (';');
1509 when N_Entry_Body_Formal_Part =>
1510 if Present (Entry_Index_Specification (Node)) then
1511 Write_Str_With_Col_Check_Sloc (" (");
1512 Sprint_Node (Entry_Index_Specification (Node));
1513 Write_Char (')');
1514 end if;
1516 Write_Param_Specs (Node);
1517 Write_Str_With_Col_Check_Sloc (" when ");
1518 Sprint_Node (Condition (Node));
1520 when N_Entry_Call_Alternative =>
1521 Sprint_Node_List (Pragmas_Before (Node));
1522 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1523 Sprint_Node_List (Statements (Node));
1525 when N_Entry_Call_Statement =>
1526 Write_Indent;
1527 Sprint_Node_Sloc (Name (Node));
1528 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1529 Write_Char (';');
1531 when N_Entry_Declaration =>
1532 Write_Indent_Str_Sloc ("entry ");
1533 Write_Id (Defining_Identifier (Node));
1535 if Present (Discrete_Subtype_Definition (Node)) then
1536 Write_Str_With_Col_Check (" (");
1537 Sprint_Node (Discrete_Subtype_Definition (Node));
1538 Write_Char (')');
1539 end if;
1541 Write_Param_Specs (Node);
1542 Write_Char (';');
1544 when N_Entry_Index_Specification =>
1545 Write_Str_With_Col_Check_Sloc ("for ");
1546 Write_Id (Defining_Identifier (Node));
1547 Write_Str_With_Col_Check (" in ");
1548 Sprint_Node (Discrete_Subtype_Definition (Node));
1550 when N_Enumeration_Representation_Clause =>
1551 Write_Indent_Str_Sloc ("for ");
1552 Write_Id (Identifier (Node));
1553 Write_Str_With_Col_Check (" use ");
1554 Sprint_Node (Array_Aggregate (Node));
1555 Write_Char (';');
1557 when N_Enumeration_Type_Definition =>
1558 Set_Debug_Sloc;
1560 -- Skip attempt to print Literals field if it's not there and
1561 -- we are in package Standard (case of Character, which is
1562 -- handled specially (without an explicit literals list).
1564 if Sloc (Node) > Standard_Location
1565 or else Present (Literals (Node))
1566 then
1567 Sprint_Paren_Comma_List (Literals (Node));
1568 end if;
1570 when N_Error =>
1571 Write_Str_With_Col_Check_Sloc ("<error>");
1573 when N_Exception_Declaration =>
1574 if Write_Indent_Identifiers (Node) then
1575 Write_Str_With_Col_Check (" : ");
1577 if Is_Statically_Allocated (Defining_Identifier (Node)) then
1578 Write_Str_With_Col_Check ("static ");
1579 end if;
1581 Write_Str_Sloc ("exception");
1583 if Present (Expression (Node)) then
1584 Write_Str (" := ");
1585 Sprint_Node (Expression (Node));
1586 end if;
1588 Write_Char (';');
1589 end if;
1591 when N_Exception_Handler =>
1592 Write_Indent_Str_Sloc ("when ");
1594 if Present (Choice_Parameter (Node)) then
1595 Sprint_Node (Choice_Parameter (Node));
1596 Write_Str (" : ");
1597 end if;
1599 Sprint_Bar_List (Exception_Choices (Node));
1600 Write_Str (" => ");
1601 Sprint_Indented_List (Statements (Node));
1603 when N_Exception_Renaming_Declaration =>
1604 Write_Indent;
1605 Set_Debug_Sloc;
1606 Sprint_Node (Defining_Identifier (Node));
1607 Write_Str_With_Col_Check (" : exception renames ");
1608 Sprint_Node (Name (Node));
1609 Write_Char (';');
1611 when N_Exit_Statement =>
1612 Write_Indent_Str_Sloc ("exit");
1613 Sprint_Opt_Node (Name (Node));
1615 if Present (Condition (Node)) then
1616 Write_Str_With_Col_Check (" when ");
1617 Sprint_Node (Condition (Node));
1618 end if;
1620 Write_Char (';');
1622 when N_Expanded_Name =>
1623 Sprint_Node (Prefix (Node));
1624 Write_Char_Sloc ('.');
1625 Sprint_Node (Selector_Name (Node));
1627 when N_Explicit_Dereference =>
1628 Sprint_Node (Prefix (Node));
1629 Write_Char_Sloc ('.');
1630 Write_Str_Sloc ("all");
1632 when N_Expression_With_Actions =>
1633 Indent_Begin;
1634 Write_Indent_Str_Sloc ("do ");
1635 Indent_Begin;
1636 Sprint_Node_List (Actions (Node));
1637 Indent_End;
1638 Write_Indent;
1639 Write_Str_With_Col_Check_Sloc ("in ");
1640 Sprint_Node (Expression (Node));
1641 Write_Str_With_Col_Check (" end");
1642 Indent_End;
1643 Write_Indent;
1645 when N_Expression_Function =>
1646 Write_Indent;
1647 Sprint_Node_Sloc (Specification (Node));
1648 Write_Str (" is");
1649 Indent_Begin;
1650 Write_Indent;
1651 Sprint_Node (Expression (Node));
1652 Write_Char (';');
1653 Indent_End;
1655 when N_Extended_Return_Statement =>
1656 Write_Indent_Str_Sloc ("return ");
1657 Sprint_Node_List (Return_Object_Declarations (Node));
1659 if Present (Handled_Statement_Sequence (Node)) then
1660 Write_Str_With_Col_Check (" do");
1661 Sprint_Node (Handled_Statement_Sequence (Node));
1662 Write_Indent_Str ("end return;");
1663 else
1664 Write_Indent_Str (";");
1665 end if;
1667 when N_Extension_Aggregate =>
1668 Write_Str_With_Col_Check_Sloc ("(");
1669 Sprint_Node (Ancestor_Part (Node));
1670 Write_Str_With_Col_Check (" with ");
1672 if Null_Record_Present (Node) then
1673 Write_Str_With_Col_Check ("null record");
1674 else
1675 if Present (Expressions (Node)) then
1676 Sprint_Comma_List (Expressions (Node));
1678 if Present (Component_Associations (Node)) then
1679 Write_Str (", ");
1680 end if;
1681 end if;
1683 if Present (Component_Associations (Node)) then
1684 Sprint_Comma_List (Component_Associations (Node));
1685 end if;
1686 end if;
1688 Write_Char (')');
1690 when N_Floating_Point_Definition =>
1691 Write_Str_With_Col_Check_Sloc ("digits ");
1692 Sprint_Node (Digits_Expression (Node));
1693 Sprint_Opt_Node (Real_Range_Specification (Node));
1695 when N_Formal_Decimal_Fixed_Point_Definition =>
1696 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1698 when N_Formal_Derived_Type_Definition =>
1699 Write_Str_With_Col_Check_Sloc ("new ");
1700 Sprint_Node (Subtype_Mark (Node));
1702 if Present (Interface_List (Node)) then
1703 Write_Str_With_Col_Check (" and ");
1704 Sprint_And_List (Interface_List (Node));
1705 end if;
1707 if Private_Present (Node) then
1708 Write_Str_With_Col_Check (" with private");
1709 end if;
1711 when N_Formal_Abstract_Subprogram_Declaration =>
1712 Write_Indent_Str_Sloc ("with ");
1713 Sprint_Node (Specification (Node));
1715 Write_Str_With_Col_Check (" is abstract");
1717 if Box_Present (Node) then
1718 Write_Str_With_Col_Check (" <>");
1719 elsif Present (Default_Name (Node)) then
1720 Write_Str_With_Col_Check (" ");
1721 Sprint_Node (Default_Name (Node));
1722 end if;
1724 Write_Char (';');
1726 when N_Formal_Concrete_Subprogram_Declaration =>
1727 Write_Indent_Str_Sloc ("with ");
1728 Sprint_Node (Specification (Node));
1730 if Box_Present (Node) then
1731 Write_Str_With_Col_Check (" is <>");
1732 elsif Present (Default_Name (Node)) then
1733 Write_Str_With_Col_Check (" is ");
1734 Sprint_Node (Default_Name (Node));
1735 end if;
1737 Write_Char (';');
1739 when N_Formal_Discrete_Type_Definition =>
1740 Write_Str_With_Col_Check_Sloc ("<>");
1742 when N_Formal_Floating_Point_Definition =>
1743 Write_Str_With_Col_Check_Sloc ("digits <>");
1745 when N_Formal_Modular_Type_Definition =>
1746 Write_Str_With_Col_Check_Sloc ("mod <>");
1748 when N_Formal_Object_Declaration =>
1749 Set_Debug_Sloc;
1751 if Write_Indent_Identifiers (Node) then
1752 Write_Str (" : ");
1754 if In_Present (Node) then
1755 Write_Str_With_Col_Check ("in ");
1756 end if;
1758 if Out_Present (Node) then
1759 Write_Str_With_Col_Check ("out ");
1760 end if;
1762 if Present (Subtype_Mark (Node)) then
1764 -- Ada 2005 (AI-423): Formal object with null exclusion
1766 if Null_Exclusion_Present (Node) then
1767 Write_Str ("not null ");
1768 end if;
1770 Sprint_Node (Subtype_Mark (Node));
1772 -- Ada 2005 (AI-423): Formal object with access definition
1774 else
1775 pragma Assert (Present (Access_Definition (Node)));
1777 Sprint_Node (Access_Definition (Node));
1778 end if;
1780 if Present (Default_Expression (Node)) then
1781 Write_Str (" := ");
1782 Sprint_Node (Default_Expression (Node));
1783 end if;
1785 Write_Char (';');
1786 end if;
1788 when N_Formal_Ordinary_Fixed_Point_Definition =>
1789 Write_Str_With_Col_Check_Sloc ("delta <>");
1791 when N_Formal_Package_Declaration =>
1792 Write_Indent_Str_Sloc ("with package ");
1793 Write_Id (Defining_Identifier (Node));
1794 Write_Str_With_Col_Check (" is new ");
1795 Sprint_Node (Name (Node));
1796 Write_Str_With_Col_Check (" (<>);");
1798 when N_Formal_Private_Type_Definition =>
1799 if Abstract_Present (Node) then
1800 Write_Str_With_Col_Check ("abstract ");
1801 end if;
1803 if Tagged_Present (Node) then
1804 Write_Str_With_Col_Check ("tagged ");
1805 end if;
1807 if Limited_Present (Node) then
1808 Write_Str_With_Col_Check ("limited ");
1809 end if;
1811 Write_Str_With_Col_Check_Sloc ("private");
1813 when N_Formal_Incomplete_Type_Definition =>
1814 if Tagged_Present (Node) then
1815 Write_Str_With_Col_Check ("is tagged ");
1816 end if;
1818 when N_Formal_Signed_Integer_Type_Definition =>
1819 Write_Str_With_Col_Check_Sloc ("range <>");
1821 when N_Formal_Type_Declaration =>
1822 Write_Indent_Str_Sloc ("type ");
1823 Write_Id (Defining_Identifier (Node));
1825 if Present (Discriminant_Specifications (Node)) then
1826 Write_Discr_Specs (Node);
1827 elsif Unknown_Discriminants_Present (Node) then
1828 Write_Str_With_Col_Check ("(<>)");
1829 end if;
1831 if Nkind (Formal_Type_Definition (Node)) /=
1832 N_Formal_Incomplete_Type_Definition
1833 then
1834 Write_Str_With_Col_Check (" is ");
1835 end if;
1837 Sprint_Node (Formal_Type_Definition (Node));
1838 Write_Char (';');
1840 when N_Free_Statement =>
1841 Write_Indent_Str_Sloc ("free ");
1842 Sprint_Node (Expression (Node));
1843 Write_Char (';');
1845 when N_Freeze_Entity =>
1846 if Dump_Original_Only then
1847 null;
1849 -- A freeze node is output if it has some effect (i.e. non-empty
1850 -- actions, or freeze node for an itype, which causes elaboration
1851 -- of the itype), and is also always output if Dump_Freeze_Null
1852 -- is set True.
1854 elsif Present (Actions (Node))
1855 or else Is_Itype (Entity (Node))
1856 or else Dump_Freeze_Null
1857 then
1858 Write_Indent;
1859 Write_Rewrite_Str ("<<<");
1860 Write_Str_With_Col_Check_Sloc ("freeze ");
1861 Write_Id (Entity (Node));
1862 Write_Str (" [");
1864 if No (Actions (Node)) then
1865 Write_Char (']');
1867 else
1868 -- Output freeze actions. We increment Freeze_Indent during
1869 -- this output to avoid generating extra blank lines before
1870 -- any procedures included in the freeze actions.
1872 Freeze_Indent := Freeze_Indent + 1;
1873 Sprint_Indented_List (Actions (Node));
1874 Freeze_Indent := Freeze_Indent - 1;
1875 Write_Indent_Str ("]");
1876 end if;
1878 Write_Rewrite_Str (">>>");
1879 end if;
1881 when N_Freeze_Generic_Entity =>
1882 if Dump_Original_Only then
1883 null;
1885 else
1886 Write_Indent;
1887 Write_Str_With_Col_Check_Sloc ("freeze_generic ");
1888 Write_Id (Entity (Node));
1889 end if;
1891 when N_Full_Type_Declaration =>
1892 Write_Indent_Str_Sloc ("type ");
1893 Sprint_Node (Defining_Identifier (Node));
1894 Write_Discr_Specs (Node);
1895 Write_Str_With_Col_Check (" is ");
1896 Sprint_Node (Type_Definition (Node));
1897 Write_Char (';');
1899 when N_Function_Call =>
1900 Set_Debug_Sloc;
1901 Write_Subprogram_Name (Name (Node));
1902 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1904 when N_Function_Instantiation =>
1905 Write_Indent_Str_Sloc ("function ");
1906 Sprint_Node (Defining_Unit_Name (Node));
1907 Write_Str_With_Col_Check (" is new ");
1908 Sprint_Node (Name (Node));
1909 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1910 Write_Char (';');
1912 when N_Function_Specification =>
1913 Write_Str_With_Col_Check_Sloc ("function ");
1914 Sprint_Node (Defining_Unit_Name (Node));
1915 Write_Param_Specs (Node);
1916 Write_Str_With_Col_Check (" return ");
1918 -- Ada 2005 (AI-231)
1920 if Nkind (Result_Definition (Node)) /= N_Access_Definition
1921 and then Null_Exclusion_Present (Node)
1922 then
1923 Write_Str (" not null ");
1924 end if;
1926 Sprint_Node (Result_Definition (Node));
1928 when N_Generic_Association =>
1929 Set_Debug_Sloc;
1931 if Present (Selector_Name (Node)) then
1932 Sprint_Node (Selector_Name (Node));
1933 Write_Str (" => ");
1934 end if;
1936 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1938 when N_Generic_Function_Renaming_Declaration =>
1939 Write_Indent_Str_Sloc ("generic function ");
1940 Sprint_Node (Defining_Unit_Name (Node));
1941 Write_Str_With_Col_Check (" renames ");
1942 Sprint_Node (Name (Node));
1943 Write_Char (';');
1945 when N_Generic_Package_Declaration =>
1946 Extra_Blank_Line;
1947 Write_Indent_Str_Sloc ("generic ");
1948 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1949 Write_Indent;
1950 Sprint_Node (Specification (Node));
1951 Write_Char (';');
1953 when N_Generic_Package_Renaming_Declaration =>
1954 Write_Indent_Str_Sloc ("generic package ");
1955 Sprint_Node (Defining_Unit_Name (Node));
1956 Write_Str_With_Col_Check (" renames ");
1957 Sprint_Node (Name (Node));
1958 Write_Char (';');
1960 when N_Generic_Procedure_Renaming_Declaration =>
1961 Write_Indent_Str_Sloc ("generic procedure ");
1962 Sprint_Node (Defining_Unit_Name (Node));
1963 Write_Str_With_Col_Check (" renames ");
1964 Sprint_Node (Name (Node));
1965 Write_Char (';');
1967 when N_Generic_Subprogram_Declaration =>
1968 Extra_Blank_Line;
1969 Write_Indent_Str_Sloc ("generic ");
1970 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1971 Write_Indent;
1972 Sprint_Node (Specification (Node));
1973 Write_Char (';');
1975 when N_Goto_Statement =>
1976 Write_Indent_Str_Sloc ("goto ");
1977 Sprint_Node (Name (Node));
1978 Write_Char (';');
1980 if Nkind (Next (Node)) = N_Label then
1981 Write_Indent;
1982 end if;
1984 when N_Handled_Sequence_Of_Statements =>
1985 Set_Debug_Sloc;
1986 Sprint_Indented_List (Statements (Node));
1988 if Present (Exception_Handlers (Node)) then
1989 Write_Indent_Str ("exception");
1990 Indent_Begin;
1991 Sprint_Node_List (Exception_Handlers (Node));
1992 Indent_End;
1993 end if;
1995 if Present (At_End_Proc (Node)) then
1996 Write_Indent_Str ("at end");
1997 Indent_Begin;
1998 Write_Indent;
1999 Sprint_Node (At_End_Proc (Node));
2000 Write_Char (';');
2001 Indent_End;
2002 end if;
2004 when N_Identifier =>
2005 Set_Debug_Sloc;
2006 Write_Id (Node);
2008 when N_If_Expression =>
2009 declare
2010 Has_Parens : constant Boolean := Paren_Count (Node) > 0;
2011 Condition : constant Node_Id := First (Expressions (Node));
2012 Then_Expr : constant Node_Id := Next (Condition);
2014 begin
2015 -- The syntax for if_expression does not include parentheses,
2016 -- but sometimes parentheses are required, so unconditionally
2017 -- generate them here unless already present.
2019 if not Has_Parens then
2020 Write_Char ('(');
2021 end if;
2023 Write_Str_With_Col_Check_Sloc ("if ");
2024 Sprint_Node (Condition);
2025 Write_Str_With_Col_Check (" then ");
2027 -- Defense against junk here
2029 if Present (Then_Expr) then
2030 Sprint_Node (Then_Expr);
2032 if Present (Next (Then_Expr)) then
2033 Write_Str_With_Col_Check (" else ");
2034 Sprint_Node (Next (Then_Expr));
2035 end if;
2036 end if;
2038 if not Has_Parens then
2039 Write_Char (')');
2040 end if;
2041 end;
2043 when N_If_Statement =>
2044 Write_Indent_Str_Sloc ("if ");
2045 Sprint_Node (Condition (Node));
2046 Write_Str_With_Col_Check (" then");
2047 Sprint_Indented_List (Then_Statements (Node));
2048 Sprint_Opt_Node_List (Elsif_Parts (Node));
2050 if Present (Else_Statements (Node)) then
2051 Write_Indent_Str ("else");
2052 Sprint_Indented_List (Else_Statements (Node));
2053 end if;
2055 Write_Indent_Str ("end if;");
2057 when N_Implicit_Label_Declaration =>
2058 if not Dump_Original_Only then
2059 Write_Indent;
2060 Write_Rewrite_Str ("<<<");
2061 Set_Debug_Sloc;
2062 Write_Id (Defining_Identifier (Node));
2063 Write_Str (" : ");
2064 Write_Str_With_Col_Check ("label");
2065 Write_Rewrite_Str (">>>");
2066 end if;
2068 when N_In =>
2069 Sprint_Left_Opnd (Node);
2070 Write_Str_Sloc (" in ");
2072 if Present (Right_Opnd (Node)) then
2073 Sprint_Right_Opnd (Node);
2074 else
2075 Sprint_Bar_List (Alternatives (Node));
2076 end if;
2078 when N_Incomplete_Type_Declaration =>
2079 Write_Indent_Str_Sloc ("type ");
2080 Write_Id (Defining_Identifier (Node));
2082 if Present (Discriminant_Specifications (Node)) then
2083 Write_Discr_Specs (Node);
2084 elsif Unknown_Discriminants_Present (Node) then
2085 Write_Str_With_Col_Check ("(<>)");
2086 end if;
2088 Write_Char (';');
2090 when N_Index_Or_Discriminant_Constraint =>
2091 Set_Debug_Sloc;
2092 Sprint_Paren_Comma_List (Constraints (Node));
2094 when N_Indexed_Component =>
2095 Sprint_Node_Sloc (Prefix (Node));
2096 Sprint_Opt_Paren_Comma_List (Expressions (Node));
2098 when N_Integer_Literal =>
2099 if Print_In_Hex (Node) then
2100 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
2101 else
2102 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
2103 end if;
2105 when N_Iteration_Scheme =>
2106 if Present (Condition (Node)) then
2107 Write_Str_With_Col_Check_Sloc ("while ");
2108 Sprint_Node (Condition (Node));
2109 else
2110 Write_Str_With_Col_Check_Sloc ("for ");
2112 if Present (Iterator_Specification (Node)) then
2113 Sprint_Node (Iterator_Specification (Node));
2114 else
2115 Sprint_Node (Loop_Parameter_Specification (Node));
2116 end if;
2117 end if;
2119 Write_Char (' ');
2121 when N_Iterator_Specification =>
2122 Set_Debug_Sloc;
2123 Write_Id (Defining_Identifier (Node));
2125 if Present (Subtype_Indication (Node)) then
2126 Write_Str_With_Col_Check (" : ");
2127 Sprint_Node (Subtype_Indication (Node));
2128 end if;
2130 if Of_Present (Node) then
2131 Write_Str_With_Col_Check (" of ");
2132 else
2133 Write_Str_With_Col_Check (" in ");
2134 end if;
2136 if Reverse_Present (Node) then
2137 Write_Str_With_Col_Check ("reverse ");
2138 end if;
2140 Sprint_Node (Name (Node));
2142 when N_Itype_Reference =>
2143 Write_Indent_Str_Sloc ("reference ");
2144 Write_Id (Itype (Node));
2146 when N_Label =>
2147 Write_Indent_Str_Sloc ("<<");
2148 Write_Id (Identifier (Node));
2149 Write_Str (">>");
2151 when N_Loop_Parameter_Specification =>
2152 Set_Debug_Sloc;
2153 Write_Id (Defining_Identifier (Node));
2154 Write_Str_With_Col_Check (" in ");
2156 if Reverse_Present (Node) then
2157 Write_Str_With_Col_Check ("reverse ");
2158 end if;
2160 Sprint_Node (Discrete_Subtype_Definition (Node));
2162 when N_Loop_Statement =>
2163 Write_Indent;
2165 if Present (Identifier (Node))
2166 and then (not Has_Created_Identifier (Node)
2167 or else not Dump_Original_Only)
2168 then
2169 Write_Rewrite_Str ("<<<");
2170 Write_Id (Identifier (Node));
2171 Write_Str (" : ");
2172 Write_Rewrite_Str (">>>");
2173 Sprint_Node (Iteration_Scheme (Node));
2174 Write_Str_With_Col_Check_Sloc ("loop");
2175 Sprint_Indented_List (Statements (Node));
2176 Write_Indent_Str ("end loop ");
2177 Write_Rewrite_Str ("<<<");
2178 Write_Id (Identifier (Node));
2179 Write_Rewrite_Str (">>>");
2180 Write_Char (';');
2182 else
2183 Sprint_Node (Iteration_Scheme (Node));
2184 Write_Str_With_Col_Check_Sloc ("loop");
2185 Sprint_Indented_List (Statements (Node));
2186 Write_Indent_Str ("end loop;");
2187 end if;
2189 when N_Mod_Clause =>
2190 Sprint_Node_List (Pragmas_Before (Node));
2191 Write_Str_With_Col_Check_Sloc ("at mod ");
2192 Sprint_Node (Expression (Node));
2194 when N_Modular_Type_Definition =>
2195 Write_Str_With_Col_Check_Sloc ("mod ");
2196 Sprint_Node (Expression (Node));
2198 when N_Not_In =>
2199 Sprint_Left_Opnd (Node);
2200 Write_Str_Sloc (" not in ");
2202 if Present (Right_Opnd (Node)) then
2203 Sprint_Right_Opnd (Node);
2204 else
2205 Sprint_Bar_List (Alternatives (Node));
2206 end if;
2208 when N_Null =>
2209 Write_Str_With_Col_Check_Sloc ("null");
2211 when N_Null_Statement =>
2212 if Comes_From_Source (Node)
2213 or else Dump_Freeze_Null
2214 or else not Is_List_Member (Node)
2215 or else (No (Prev (Node)) and then No (Next (Node)))
2216 then
2217 Write_Indent_Str_Sloc ("null;");
2218 end if;
2220 when N_Number_Declaration =>
2221 Set_Debug_Sloc;
2223 if Write_Indent_Identifiers (Node) then
2224 Write_Str_With_Col_Check (" : constant ");
2225 Write_Str (" := ");
2226 Sprint_Node (Expression (Node));
2227 Write_Char (';');
2228 end if;
2230 when N_Object_Declaration =>
2231 Set_Debug_Sloc;
2233 if Write_Indent_Identifiers (Node) then
2234 declare
2235 Def_Id : constant Entity_Id := Defining_Identifier (Node);
2237 begin
2238 Write_Str_With_Col_Check (" : ");
2240 if Is_Statically_Allocated (Def_Id) then
2241 Write_Str_With_Col_Check ("static ");
2242 end if;
2244 if Aliased_Present (Node) then
2245 Write_Str_With_Col_Check ("aliased ");
2246 end if;
2248 if Constant_Present (Node) then
2249 Write_Str_With_Col_Check ("constant ");
2250 end if;
2252 -- Ada 2005 (AI-231)
2254 if Null_Exclusion_Present (Node) then
2255 Write_Str_With_Col_Check ("not null ");
2256 end if;
2258 -- Print type. We used to print the Object_Definition from
2259 -- the node, but it is much more useful to print the Etype
2260 -- of the defining identifier for the case where the nominal
2261 -- type is an unconstrained array type. For example, this
2262 -- will be a clear reference to the Itype with the bounds
2263 -- in the case of a type like String. The object after
2264 -- all is constrained, even if its nominal subtype is
2265 -- unconstrained.
2267 declare
2268 Odef : constant Node_Id := Object_Definition (Node);
2270 begin
2271 if Nkind (Odef) = N_Identifier
2272 and then Present (Etype (Odef))
2273 and then Is_Array_Type (Etype (Odef))
2274 and then not Is_Constrained (Etype (Odef))
2275 and then Present (Etype (Def_Id))
2276 then
2277 Sprint_Node (Etype (Def_Id));
2279 -- In other cases, the nominal type is fine to print
2281 else
2282 Sprint_Node (Odef);
2283 end if;
2284 end;
2286 if Present (Expression (Node)) then
2287 Write_Str (" := ");
2288 Sprint_Node (Expression (Node));
2289 end if;
2291 Write_Char (';');
2293 -- Handle implicit importation and implicit exportation of
2294 -- object declarations:
2295 -- $pragma import (Convention_Id, Def_Id, "...");
2296 -- $pragma export (Convention_Id, Def_Id, "...");
2298 if Is_Internal (Def_Id)
2299 and then Present (Interface_Name (Def_Id))
2300 then
2301 Write_Indent_Str_Sloc ("$pragma ");
2303 if Is_Imported (Def_Id) then
2304 Write_Str ("import (");
2306 else pragma Assert (Is_Exported (Def_Id));
2307 Write_Str ("export (");
2308 end if;
2310 declare
2311 Prefix : constant String := "Convention_";
2312 S : constant String := Convention (Def_Id)'Img;
2314 begin
2315 Name_Len := S'Last - Prefix'Last;
2316 Name_Buffer (1 .. Name_Len) :=
2317 S (Prefix'Last + 1 .. S'Last);
2318 Set_Casing (All_Lower_Case);
2319 Write_Str (Name_Buffer (1 .. Name_Len));
2320 end;
2322 Write_Str (", ");
2323 Write_Id (Def_Id);
2324 Write_Str (", ");
2325 Write_String_Table_Entry
2326 (Strval (Interface_Name (Def_Id)));
2327 Write_Str (");");
2328 end if;
2329 end;
2330 end if;
2332 when N_Object_Renaming_Declaration =>
2333 Write_Indent;
2334 Set_Debug_Sloc;
2335 Sprint_Node (Defining_Identifier (Node));
2336 Write_Str (" : ");
2338 -- Ada 2005 (AI-230): Access renamings
2340 if Present (Access_Definition (Node)) then
2341 Sprint_Node (Access_Definition (Node));
2343 elsif Present (Subtype_Mark (Node)) then
2345 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2347 if Null_Exclusion_Present (Node) then
2348 Write_Str ("not null ");
2349 end if;
2351 Sprint_Node (Subtype_Mark (Node));
2353 else
2354 Write_Str (" ??? ");
2355 end if;
2357 Write_Str_With_Col_Check (" renames ");
2358 Sprint_Node (Name (Node));
2359 Write_Char (';');
2361 when N_Op_Abs =>
2362 Write_Operator (Node, "abs ");
2363 Sprint_Right_Opnd (Node);
2365 when N_Op_Add =>
2366 Sprint_Left_Opnd (Node);
2367 Write_Operator (Node, " + ");
2368 Sprint_Right_Opnd (Node);
2370 when N_Op_And =>
2371 Sprint_Left_Opnd (Node);
2372 Write_Operator (Node, " and ");
2373 Sprint_Right_Opnd (Node);
2375 when N_Op_Concat =>
2376 Sprint_Left_Opnd (Node);
2377 Write_Operator (Node, " & ");
2378 Sprint_Right_Opnd (Node);
2380 when N_Op_Divide =>
2381 Sprint_Left_Opnd (Node);
2382 Write_Char (' ');
2383 Process_TFAI_RR_Flags (Node);
2384 Write_Operator (Node, "/ ");
2385 Sprint_Right_Opnd (Node);
2387 when N_Op_Eq =>
2388 Sprint_Left_Opnd (Node);
2389 Write_Operator (Node, " = ");
2390 Sprint_Right_Opnd (Node);
2392 when N_Op_Expon =>
2393 Sprint_Left_Opnd (Node);
2394 Write_Operator (Node, " ** ");
2395 Sprint_Right_Opnd (Node);
2397 when N_Op_Ge =>
2398 Sprint_Left_Opnd (Node);
2399 Write_Operator (Node, " >= ");
2400 Sprint_Right_Opnd (Node);
2402 when N_Op_Gt =>
2403 Sprint_Left_Opnd (Node);
2404 Write_Operator (Node, " > ");
2405 Sprint_Right_Opnd (Node);
2407 when N_Op_Le =>
2408 Sprint_Left_Opnd (Node);
2409 Write_Operator (Node, " <= ");
2410 Sprint_Right_Opnd (Node);
2412 when N_Op_Lt =>
2413 Sprint_Left_Opnd (Node);
2414 Write_Operator (Node, " < ");
2415 Sprint_Right_Opnd (Node);
2417 when N_Op_Minus =>
2418 Write_Operator (Node, "-");
2419 Sprint_Right_Opnd (Node);
2421 when N_Op_Mod =>
2422 Sprint_Left_Opnd (Node);
2424 if Treat_Fixed_As_Integer (Node) then
2425 Write_Str (" #");
2426 end if;
2428 Write_Operator (Node, " mod ");
2429 Sprint_Right_Opnd (Node);
2431 when N_Op_Multiply =>
2432 Sprint_Left_Opnd (Node);
2433 Write_Char (' ');
2434 Process_TFAI_RR_Flags (Node);
2435 Write_Operator (Node, "* ");
2436 Sprint_Right_Opnd (Node);
2438 when N_Op_Ne =>
2439 Sprint_Left_Opnd (Node);
2440 Write_Operator (Node, " /= ");
2441 Sprint_Right_Opnd (Node);
2443 when N_Op_Not =>
2444 Write_Operator (Node, "not ");
2445 Sprint_Right_Opnd (Node);
2447 when N_Op_Or =>
2448 Sprint_Left_Opnd (Node);
2449 Write_Operator (Node, " or ");
2450 Sprint_Right_Opnd (Node);
2452 when N_Op_Plus =>
2453 Write_Operator (Node, "+");
2454 Sprint_Right_Opnd (Node);
2456 when N_Op_Rem =>
2457 Sprint_Left_Opnd (Node);
2459 if Treat_Fixed_As_Integer (Node) then
2460 Write_Str (" #");
2461 end if;
2463 Write_Operator (Node, " rem ");
2464 Sprint_Right_Opnd (Node);
2466 when N_Op_Shift =>
2467 Set_Debug_Sloc;
2468 Write_Id (Node);
2469 Write_Char ('!');
2470 Write_Str_With_Col_Check ("(");
2471 Sprint_Node (Left_Opnd (Node));
2472 Write_Str (", ");
2473 Sprint_Node (Right_Opnd (Node));
2474 Write_Char (')');
2476 when N_Op_Subtract =>
2477 Sprint_Left_Opnd (Node);
2478 Write_Operator (Node, " - ");
2479 Sprint_Right_Opnd (Node);
2481 when N_Op_Xor =>
2482 Sprint_Left_Opnd (Node);
2483 Write_Operator (Node, " xor ");
2484 Sprint_Right_Opnd (Node);
2486 when N_Operator_Symbol =>
2487 Write_Name_With_Col_Check_Sloc (Chars (Node));
2489 when N_Ordinary_Fixed_Point_Definition =>
2490 Write_Str_With_Col_Check_Sloc ("delta ");
2491 Sprint_Node (Delta_Expression (Node));
2492 Sprint_Opt_Node (Real_Range_Specification (Node));
2494 when N_Or_Else =>
2495 Sprint_Left_Opnd (Node);
2496 Write_Str_Sloc (" or else ");
2497 Sprint_Right_Opnd (Node);
2499 when N_Others_Choice =>
2500 if All_Others (Node) then
2501 Write_Str_With_Col_Check ("all ");
2502 end if;
2504 Write_Str_With_Col_Check_Sloc ("others");
2506 when N_Package_Body =>
2507 Extra_Blank_Line;
2508 Write_Indent_Str_Sloc ("package body ");
2509 Sprint_Node (Defining_Unit_Name (Node));
2510 Write_Str (" is");
2511 Sprint_Indented_List (Declarations (Node));
2513 if Present (Handled_Statement_Sequence (Node)) then
2514 Write_Indent_Str ("begin");
2515 Sprint_Node (Handled_Statement_Sequence (Node));
2516 end if;
2518 Write_Indent_Str ("end ");
2519 Sprint_End_Label
2520 (Handled_Statement_Sequence (Node), Defining_Unit_Name (Node));
2521 Write_Char (';');
2523 when N_Package_Body_Stub =>
2524 Write_Indent_Str_Sloc ("package body ");
2525 Sprint_Node (Defining_Identifier (Node));
2526 Write_Str_With_Col_Check (" is separate;");
2528 when N_Package_Declaration =>
2529 Extra_Blank_Line;
2530 Write_Indent;
2531 Sprint_Node_Sloc (Specification (Node));
2532 Write_Char (';');
2534 -- If this is an instantiation, get the aspects from the original
2535 -- instantiation node.
2537 if Is_Generic_Instance (Defining_Entity (Node))
2538 and then Has_Aspects
2539 (Package_Instantiation (Defining_Entity (Node)))
2540 then
2541 Sprint_Aspect_Specifications
2542 (Package_Instantiation (Defining_Entity (Node)),
2543 Semicolon => True);
2544 end if;
2546 when N_Package_Instantiation =>
2547 Extra_Blank_Line;
2548 Write_Indent_Str_Sloc ("package ");
2549 Sprint_Node (Defining_Unit_Name (Node));
2550 Write_Str (" is new ");
2551 Sprint_Node (Name (Node));
2552 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2553 Write_Char (';');
2555 when N_Package_Renaming_Declaration =>
2556 Write_Indent_Str_Sloc ("package ");
2557 Sprint_Node (Defining_Unit_Name (Node));
2558 Write_Str_With_Col_Check (" renames ");
2559 Sprint_Node (Name (Node));
2560 Write_Char (';');
2562 when N_Package_Specification =>
2563 Write_Str_With_Col_Check_Sloc ("package ");
2564 Sprint_Node (Defining_Unit_Name (Node));
2566 if Nkind (Parent (Node)) = N_Generic_Package_Declaration
2567 and then Has_Aspects (Parent (Node))
2568 then
2569 Sprint_Aspect_Specifications
2570 (Parent (Node), Semicolon => False);
2572 -- An instantiation is rewritten as a package declaration, but
2573 -- the aspects belong to the instantiation node.
2575 elsif Nkind (Parent (Node)) = N_Package_Declaration then
2576 declare
2577 Pack : constant Entity_Id := Defining_Entity (Node);
2579 begin
2580 if not Is_Generic_Instance (Pack) then
2581 if Has_Aspects (Parent (Node)) then
2582 Sprint_Aspect_Specifications
2583 (Parent (Node), Semicolon => False);
2584 end if;
2585 end if;
2586 end;
2587 end if;
2589 Write_Str (" is");
2590 Sprint_Indented_List (Visible_Declarations (Node));
2592 if Present (Private_Declarations (Node)) then
2593 Write_Indent_Str ("private");
2594 Sprint_Indented_List (Private_Declarations (Node));
2595 end if;
2597 Write_Indent_Str ("end ");
2598 Sprint_Node (Defining_Unit_Name (Node));
2600 when N_Parameter_Association =>
2601 Sprint_Node_Sloc (Selector_Name (Node));
2602 Write_Str (" => ");
2603 Sprint_Node (Explicit_Actual_Parameter (Node));
2605 when N_Parameter_Specification =>
2606 Set_Debug_Sloc;
2608 if Write_Identifiers (Node) then
2609 Write_Str (" : ");
2611 if In_Present (Node) then
2612 Write_Str_With_Col_Check ("in ");
2613 end if;
2615 if Out_Present (Node) then
2616 Write_Str_With_Col_Check ("out ");
2617 end if;
2619 -- Ada 2005 (AI-231): Parameter specification may carry null
2620 -- exclusion. Do not print it now if this is an access formal,
2621 -- it is emitted when the access definition is displayed.
2623 if Null_Exclusion_Present (Node)
2624 and then Nkind (Parameter_Type (Node))
2625 /= N_Access_Definition
2626 then
2627 Write_Str ("not null ");
2628 end if;
2630 Sprint_Node (Parameter_Type (Node));
2632 if Present (Expression (Node)) then
2633 Write_Str (" := ");
2634 Sprint_Node (Expression (Node));
2635 end if;
2636 else
2637 Write_Str (", ");
2638 end if;
2640 when N_Pop_Constraint_Error_Label =>
2641 Write_Indent_Str ("%pop_constraint_error_label");
2643 when N_Pop_Program_Error_Label =>
2644 Write_Indent_Str ("%pop_program_error_label");
2646 when N_Pop_Storage_Error_Label =>
2647 Write_Indent_Str ("%pop_storage_error_label");
2649 when N_Private_Extension_Declaration =>
2650 Write_Indent_Str_Sloc ("type ");
2651 Write_Id (Defining_Identifier (Node));
2653 if Present (Discriminant_Specifications (Node)) then
2654 Write_Discr_Specs (Node);
2655 elsif Unknown_Discriminants_Present (Node) then
2656 Write_Str_With_Col_Check ("(<>)");
2657 end if;
2659 Write_Str_With_Col_Check (" is new ");
2660 Sprint_Node (Subtype_Indication (Node));
2662 if Present (Interface_List (Node)) then
2663 Write_Str_With_Col_Check (" and ");
2664 Sprint_And_List (Interface_List (Node));
2665 end if;
2667 Write_Str_With_Col_Check (" with private;");
2669 when N_Private_Type_Declaration =>
2670 Write_Indent_Str_Sloc ("type ");
2671 Write_Id (Defining_Identifier (Node));
2673 if Present (Discriminant_Specifications (Node)) then
2674 Write_Discr_Specs (Node);
2675 elsif Unknown_Discriminants_Present (Node) then
2676 Write_Str_With_Col_Check ("(<>)");
2677 end if;
2679 Write_Str (" is ");
2681 if Tagged_Present (Node) then
2682 Write_Str_With_Col_Check ("tagged ");
2683 end if;
2685 if Limited_Present (Node) then
2686 Write_Str_With_Col_Check ("limited ");
2687 end if;
2689 Write_Str_With_Col_Check ("private;");
2691 when N_Push_Constraint_Error_Label =>
2692 Write_Indent_Str ("%push_constraint_error_label (");
2694 if Present (Exception_Label (Node)) then
2695 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2696 end if;
2698 Write_Str (")");
2700 when N_Push_Program_Error_Label =>
2701 Write_Indent_Str ("%push_program_error_label (");
2703 if Present (Exception_Label (Node)) then
2704 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2705 end if;
2707 Write_Str (")");
2709 when N_Push_Storage_Error_Label =>
2710 Write_Indent_Str ("%push_storage_error_label (");
2712 if Present (Exception_Label (Node)) then
2713 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2714 end if;
2716 Write_Str (")");
2718 when N_Pragma =>
2719 Write_Indent_Str_Sloc ("pragma ");
2720 Write_Name_With_Col_Check (Pragma_Name (Node));
2722 if Present (Pragma_Argument_Associations (Node)) then
2723 Sprint_Opt_Paren_Comma_List
2724 (Pragma_Argument_Associations (Node));
2725 end if;
2727 Write_Char (';');
2729 when N_Pragma_Argument_Association =>
2730 Set_Debug_Sloc;
2732 if Chars (Node) /= No_Name then
2733 Write_Name_With_Col_Check (Chars (Node));
2734 Write_Str (" => ");
2735 end if;
2737 Sprint_Node (Expression (Node));
2739 when N_Procedure_Call_Statement =>
2740 Write_Indent;
2741 Set_Debug_Sloc;
2742 Write_Subprogram_Name (Name (Node));
2743 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2744 Write_Char (';');
2746 when N_Procedure_Instantiation =>
2747 Write_Indent_Str_Sloc ("procedure ");
2748 Sprint_Node (Defining_Unit_Name (Node));
2749 Write_Str_With_Col_Check (" is new ");
2750 Sprint_Node (Name (Node));
2751 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2752 Write_Char (';');
2754 when N_Procedure_Specification =>
2755 Write_Str_With_Col_Check_Sloc ("procedure ");
2756 Sprint_Node (Defining_Unit_Name (Node));
2757 Write_Param_Specs (Node);
2759 when N_Protected_Body =>
2760 Write_Indent_Str_Sloc ("protected body ");
2761 Write_Id (Defining_Identifier (Node));
2762 Write_Str (" is");
2763 Sprint_Indented_List (Declarations (Node));
2764 Write_Indent_Str ("end ");
2765 Write_Id (Defining_Identifier (Node));
2766 Write_Char (';');
2768 when N_Protected_Body_Stub =>
2769 Write_Indent_Str_Sloc ("protected body ");
2770 Write_Id (Defining_Identifier (Node));
2771 Write_Str_With_Col_Check (" is separate;");
2773 when N_Protected_Definition =>
2774 Set_Debug_Sloc;
2775 Sprint_Indented_List (Visible_Declarations (Node));
2777 if Present (Private_Declarations (Node)) then
2778 Write_Indent_Str ("private");
2779 Sprint_Indented_List (Private_Declarations (Node));
2780 end if;
2782 Write_Indent_Str ("end ");
2784 when N_Protected_Type_Declaration =>
2785 Write_Indent_Str_Sloc ("protected type ");
2786 Sprint_Node (Defining_Identifier (Node));
2787 Write_Discr_Specs (Node);
2789 if Present (Interface_List (Node)) then
2790 Write_Str (" is new ");
2791 Sprint_And_List (Interface_List (Node));
2792 Write_Str (" with ");
2793 else
2794 Write_Str (" is");
2795 end if;
2797 Sprint_Node (Protected_Definition (Node));
2798 Write_Id (Defining_Identifier (Node));
2799 Write_Char (';');
2801 when N_Qualified_Expression =>
2802 Sprint_Node (Subtype_Mark (Node));
2803 Write_Char_Sloc (''');
2805 -- Print expression, make sure we have at least one level of
2806 -- parentheses around the expression. For cases of qualified
2807 -- expressions in the source, this is always the case, but
2808 -- for generated qualifications, there may be no explicit
2809 -- parentheses present.
2811 if Paren_Count (Expression (Node)) /= 0 then
2812 Sprint_Node (Expression (Node));
2814 else
2815 Write_Char ('(');
2816 Sprint_Node (Expression (Node));
2818 -- Odd case, for the qualified expressions used in machine
2819 -- code the argument may be a procedure call, resulting in
2820 -- a junk semicolon before the right parent, get rid of it.
2822 Write_Erase_Char (';');
2824 -- Now we can add the terminating right paren
2826 Write_Char (')');
2827 end if;
2829 when N_Quantified_Expression =>
2830 Write_Str (" for");
2832 if All_Present (Node) then
2833 Write_Str (" all ");
2834 else
2835 Write_Str (" some ");
2836 end if;
2838 if Present (Iterator_Specification (Node)) then
2839 Sprint_Node (Iterator_Specification (Node));
2840 else
2841 Sprint_Node (Loop_Parameter_Specification (Node));
2842 end if;
2844 Write_Str (" => ");
2845 Sprint_Node (Condition (Node));
2847 when N_Raise_Expression =>
2848 declare
2849 Has_Parens : constant Boolean := Paren_Count (Node) > 0;
2851 begin
2852 -- The syntax for raise_expression does not include parentheses
2853 -- but sometimes parentheses are required, so unconditionally
2854 -- generate them here unless already present.
2856 if not Has_Parens then
2857 Write_Char ('(');
2858 end if;
2860 Write_Str_With_Col_Check_Sloc ("raise ");
2861 Sprint_Node (Name (Node));
2863 if Present (Expression (Node)) then
2864 Write_Str_With_Col_Check (" with ");
2865 Sprint_Node (Expression (Node));
2866 end if;
2868 if not Has_Parens then
2869 Write_Char (')');
2870 end if;
2871 end;
2873 when N_Raise_Constraint_Error =>
2875 -- This node can be used either as a subexpression or as a
2876 -- statement form. The following test is a reasonably reliable
2877 -- way to distinguish the two cases.
2879 if Is_List_Member (Node)
2880 and then Nkind (Parent (Node)) not in N_Subexpr
2881 then
2882 Write_Indent;
2883 end if;
2885 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2886 Write_Condition_And_Reason (Node);
2888 when N_Raise_Program_Error =>
2890 -- This node can be used either as a subexpression or as a
2891 -- statement form. The following test is a reasonably reliable
2892 -- way to distinguish the two cases.
2894 if Is_List_Member (Node)
2895 and then Nkind (Parent (Node)) not in N_Subexpr
2896 then
2897 Write_Indent;
2898 end if;
2900 Write_Str_With_Col_Check_Sloc ("[program_error");
2901 Write_Condition_And_Reason (Node);
2903 when N_Raise_Storage_Error =>
2905 -- This node can be used either as a subexpression or as a
2906 -- statement form. The following test is a reasonably reliable
2907 -- way to distinguish the two cases.
2909 if Is_List_Member (Node)
2910 and then Nkind (Parent (Node)) not in N_Subexpr
2911 then
2912 Write_Indent;
2913 end if;
2915 Write_Str_With_Col_Check_Sloc ("[storage_error");
2916 Write_Condition_And_Reason (Node);
2918 when N_Raise_Statement =>
2919 Write_Indent_Str_Sloc ("raise ");
2920 Sprint_Node (Name (Node));
2921 Write_Char (';');
2923 when N_Range =>
2924 Sprint_Node (Low_Bound (Node));
2925 Write_Str_Sloc (" .. ");
2926 Sprint_Node (High_Bound (Node));
2927 Update_Itype (Node);
2929 when N_Range_Constraint =>
2930 Write_Str_With_Col_Check_Sloc ("range ");
2931 Sprint_Node (Range_Expression (Node));
2933 when N_Real_Literal =>
2934 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2936 when N_Real_Range_Specification =>
2937 Write_Str_With_Col_Check_Sloc ("range ");
2938 Sprint_Node (Low_Bound (Node));
2939 Write_Str (" .. ");
2940 Sprint_Node (High_Bound (Node));
2942 when N_Record_Definition =>
2943 if Abstract_Present (Node) then
2944 Write_Str_With_Col_Check ("abstract ");
2945 end if;
2947 if Tagged_Present (Node) then
2948 Write_Str_With_Col_Check ("tagged ");
2949 end if;
2951 if Limited_Present (Node) then
2952 Write_Str_With_Col_Check ("limited ");
2953 end if;
2955 if Null_Present (Node) then
2956 Write_Str_With_Col_Check_Sloc ("null record");
2958 else
2959 Write_Str_With_Col_Check_Sloc ("record");
2960 Sprint_Node (Component_List (Node));
2961 Write_Indent_Str ("end record");
2962 end if;
2964 when N_Record_Representation_Clause =>
2965 Write_Indent_Str_Sloc ("for ");
2966 Sprint_Node (Identifier (Node));
2967 Write_Str_With_Col_Check (" use record ");
2969 if Present (Mod_Clause (Node)) then
2970 Sprint_Node (Mod_Clause (Node));
2971 end if;
2973 Sprint_Indented_List (Component_Clauses (Node));
2974 Write_Indent_Str ("end record;");
2976 when N_Reference =>
2977 Sprint_Node (Prefix (Node));
2978 Write_Str_With_Col_Check_Sloc ("'reference");
2980 when N_Requeue_Statement =>
2981 Write_Indent_Str_Sloc ("requeue ");
2982 Sprint_Node (Name (Node));
2984 if Abort_Present (Node) then
2985 Write_Str_With_Col_Check (" with abort");
2986 end if;
2988 Write_Char (';');
2990 -- Don't we want to print more detail???
2992 -- Doc of this extended syntax belongs in sinfo.ads and/or
2993 -- sprint.ads ???
2995 when N_SCIL_Dispatch_Table_Tag_Init =>
2996 Write_Indent_Str ("[N_SCIL_Dispatch_Table_Tag_Init]");
2998 when N_SCIL_Dispatching_Call =>
2999 Write_Indent_Str ("[N_SCIL_Dispatching_Node]");
3001 when N_SCIL_Membership_Test =>
3002 Write_Indent_Str ("[N_SCIL_Membership_Test]");
3004 when N_Simple_Return_Statement =>
3005 if Present (Expression (Node)) then
3006 Write_Indent_Str_Sloc ("return ");
3007 Sprint_Node (Expression (Node));
3008 Write_Char (';');
3009 else
3010 Write_Indent_Str_Sloc ("return;");
3011 end if;
3013 when N_Selective_Accept =>
3014 Write_Indent_Str_Sloc ("select");
3016 declare
3017 Alt_Node : Node_Id;
3018 begin
3019 Alt_Node := First (Select_Alternatives (Node));
3020 loop
3021 Indent_Begin;
3022 Sprint_Node (Alt_Node);
3023 Indent_End;
3024 Next (Alt_Node);
3025 exit when No (Alt_Node);
3026 Write_Indent_Str ("or");
3027 end loop;
3028 end;
3030 if Present (Else_Statements (Node)) then
3031 Write_Indent_Str ("else");
3032 Sprint_Indented_List (Else_Statements (Node));
3033 end if;
3035 Write_Indent_Str ("end select;");
3037 when N_Signed_Integer_Type_Definition =>
3038 Write_Str_With_Col_Check_Sloc ("range ");
3039 Sprint_Node (Low_Bound (Node));
3040 Write_Str (" .. ");
3041 Sprint_Node (High_Bound (Node));
3043 when N_Single_Protected_Declaration =>
3044 Write_Indent_Str_Sloc ("protected ");
3045 Write_Id (Defining_Identifier (Node));
3046 Write_Str (" is");
3047 Sprint_Node (Protected_Definition (Node));
3048 Write_Id (Defining_Identifier (Node));
3049 Write_Char (';');
3051 when N_Single_Task_Declaration =>
3052 Write_Indent_Str_Sloc ("task ");
3053 Sprint_Node (Defining_Identifier (Node));
3055 if Present (Task_Definition (Node)) then
3056 Write_Str (" is");
3057 Sprint_Node (Task_Definition (Node));
3058 end if;
3060 Write_Char (';');
3062 when N_Selected_Component =>
3063 Sprint_Node (Prefix (Node));
3064 Write_Char_Sloc ('.');
3065 Sprint_Node (Selector_Name (Node));
3067 when N_Slice =>
3068 Set_Debug_Sloc;
3069 Sprint_Node (Prefix (Node));
3070 Write_Str_With_Col_Check (" (");
3071 Sprint_Node (Discrete_Range (Node));
3072 Write_Char (')');
3074 when N_String_Literal =>
3075 if String_Length (Strval (Node)) + Column > Sprint_Line_Limit then
3076 Write_Indent_Str (" ");
3077 end if;
3079 Set_Debug_Sloc;
3080 Write_String_Table_Entry (Strval (Node));
3082 when N_Subprogram_Body =>
3084 -- Output extra blank line unless we are in freeze actions
3086 if Freeze_Indent = 0 then
3087 Extra_Blank_Line;
3088 end if;
3090 Write_Indent;
3092 if Present (Corresponding_Spec (Node)) then
3093 Sprint_Node_Sloc (Parent (Corresponding_Spec (Node)));
3094 else
3095 Sprint_Node_Sloc (Specification (Node));
3096 end if;
3098 Write_Str (" is");
3100 Sprint_Indented_List (Declarations (Node));
3101 Write_Indent_Str ("begin");
3102 Sprint_Node (Handled_Statement_Sequence (Node));
3104 Write_Indent_Str ("end ");
3106 Sprint_End_Label
3107 (Handled_Statement_Sequence (Node),
3108 Defining_Unit_Name (Specification (Node)));
3109 Write_Char (';');
3111 if Is_List_Member (Node)
3112 and then Present (Next (Node))
3113 and then Nkind (Next (Node)) /= N_Subprogram_Body
3114 then
3115 Write_Indent;
3116 end if;
3118 when N_Subprogram_Body_Stub =>
3119 Write_Indent;
3120 Sprint_Node_Sloc (Specification (Node));
3121 Write_Str_With_Col_Check (" is separate;");
3123 when N_Subprogram_Declaration =>
3124 Write_Indent;
3125 Sprint_Node_Sloc (Specification (Node));
3127 if Nkind (Specification (Node)) = N_Procedure_Specification
3128 and then Null_Present (Specification (Node))
3129 then
3130 Write_Str_With_Col_Check (" is null");
3131 end if;
3133 Write_Char (';');
3135 when N_Subprogram_Renaming_Declaration =>
3136 Write_Indent;
3137 Sprint_Node (Specification (Node));
3138 Write_Str_With_Col_Check_Sloc (" renames ");
3139 Sprint_Node (Name (Node));
3140 Write_Char (';');
3142 when N_Subtype_Declaration =>
3143 Write_Indent_Str_Sloc ("subtype ");
3144 Sprint_Node (Defining_Identifier (Node));
3145 Write_Str (" is ");
3147 -- Ada 2005 (AI-231)
3149 if Null_Exclusion_Present (Node) then
3150 Write_Str ("not null ");
3151 end if;
3153 Sprint_Node (Subtype_Indication (Node));
3154 Write_Char (';');
3156 when N_Subtype_Indication =>
3157 Sprint_Node_Sloc (Subtype_Mark (Node));
3158 Write_Char (' ');
3159 Sprint_Node (Constraint (Node));
3161 when N_Subunit =>
3162 Write_Indent_Str_Sloc ("separate (");
3163 Sprint_Node (Name (Node));
3164 Write_Char (')');
3165 Extra_Blank_Line;
3166 Sprint_Node (Proper_Body (Node));
3168 when N_Task_Body =>
3169 Write_Indent_Str_Sloc ("task body ");
3170 Write_Id (Defining_Identifier (Node));
3171 Write_Str (" is");
3172 Sprint_Indented_List (Declarations (Node));
3173 Write_Indent_Str ("begin");
3174 Sprint_Node (Handled_Statement_Sequence (Node));
3175 Write_Indent_Str ("end ");
3176 Sprint_End_Label
3177 (Handled_Statement_Sequence (Node), Defining_Identifier (Node));
3178 Write_Char (';');
3180 when N_Task_Body_Stub =>
3181 Write_Indent_Str_Sloc ("task body ");
3182 Write_Id (Defining_Identifier (Node));
3183 Write_Str_With_Col_Check (" is separate;");
3185 when N_Task_Definition =>
3186 Set_Debug_Sloc;
3187 Sprint_Indented_List (Visible_Declarations (Node));
3189 if Present (Private_Declarations (Node)) then
3190 Write_Indent_Str ("private");
3191 Sprint_Indented_List (Private_Declarations (Node));
3192 end if;
3194 Write_Indent_Str ("end ");
3195 Sprint_End_Label (Node, Defining_Identifier (Parent (Node)));
3197 when N_Task_Type_Declaration =>
3198 Write_Indent_Str_Sloc ("task type ");
3199 Sprint_Node (Defining_Identifier (Node));
3200 Write_Discr_Specs (Node);
3202 if Present (Interface_List (Node)) then
3203 Write_Str (" is new ");
3204 Sprint_And_List (Interface_List (Node));
3205 end if;
3207 if Present (Task_Definition (Node)) then
3208 if No (Interface_List (Node)) then
3209 Write_Str (" is");
3210 else
3211 Write_Str (" with ");
3212 end if;
3214 Sprint_Node (Task_Definition (Node));
3215 end if;
3217 Write_Char (';');
3219 when N_Terminate_Alternative =>
3220 Sprint_Node_List (Pragmas_Before (Node));
3221 Write_Indent;
3223 if Present (Condition (Node)) then
3224 Write_Str_With_Col_Check ("when ");
3225 Sprint_Node (Condition (Node));
3226 Write_Str (" => ");
3227 end if;
3229 Write_Str_With_Col_Check_Sloc ("terminate;");
3230 Sprint_Node_List (Pragmas_After (Node));
3232 when N_Timed_Entry_Call =>
3233 Write_Indent_Str_Sloc ("select");
3234 Indent_Begin;
3235 Sprint_Node (Entry_Call_Alternative (Node));
3236 Indent_End;
3237 Write_Indent_Str ("or");
3238 Indent_Begin;
3239 Sprint_Node (Delay_Alternative (Node));
3240 Indent_End;
3241 Write_Indent_Str ("end select;");
3243 when N_Triggering_Alternative =>
3244 Sprint_Node_List (Pragmas_Before (Node));
3245 Sprint_Node_Sloc (Triggering_Statement (Node));
3246 Sprint_Node_List (Statements (Node));
3248 when N_Type_Conversion =>
3249 Set_Debug_Sloc;
3250 Sprint_Node (Subtype_Mark (Node));
3251 Col_Check (4);
3253 if Conversion_OK (Node) then
3254 Write_Char ('?');
3255 end if;
3257 if Float_Truncate (Node) then
3258 Write_Char ('^');
3259 end if;
3261 if Rounded_Result (Node) then
3262 Write_Char ('@');
3263 end if;
3265 Write_Char ('(');
3266 Sprint_Node (Expression (Node));
3267 Write_Char (')');
3269 when N_Unchecked_Expression =>
3270 Col_Check (10);
3271 Write_Str ("`(");
3272 Sprint_Node_Sloc (Expression (Node));
3273 Write_Char (')');
3275 when N_Unchecked_Type_Conversion =>
3276 Sprint_Node (Subtype_Mark (Node));
3277 Write_Char ('!');
3278 Write_Str_With_Col_Check ("(");
3279 Sprint_Node_Sloc (Expression (Node));
3280 Write_Char (')');
3282 when N_Unconstrained_Array_Definition =>
3283 Write_Str_With_Col_Check_Sloc ("array (");
3285 declare
3286 Node1 : Node_Id;
3287 begin
3288 Node1 := First (Subtype_Marks (Node));
3289 loop
3290 Sprint_Node (Node1);
3291 Write_Str_With_Col_Check (" range <>");
3292 Next (Node1);
3293 exit when Node1 = Empty;
3294 Write_Str (", ");
3295 end loop;
3296 end;
3298 Write_Str (") of ");
3299 Sprint_Node (Component_Definition (Node));
3301 when N_Unused_At_Start | N_Unused_At_End =>
3302 Write_Indent_Str ("***** Error, unused node encountered *****");
3303 Write_Eol;
3305 when N_Use_Package_Clause =>
3306 Write_Indent_Str_Sloc ("use ");
3307 Sprint_Comma_List (Names (Node));
3308 Write_Char (';');
3310 when N_Use_Type_Clause =>
3311 Write_Indent_Str_Sloc ("use type ");
3312 Sprint_Comma_List (Subtype_Marks (Node));
3313 Write_Char (';');
3315 when N_Validate_Unchecked_Conversion =>
3316 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
3317 Sprint_Node (Source_Type (Node));
3318 Write_Str (", ");
3319 Sprint_Node (Target_Type (Node));
3320 Write_Str (");");
3322 when N_Variant =>
3323 Write_Indent_Str_Sloc ("when ");
3324 Sprint_Bar_List (Discrete_Choices (Node));
3325 Write_Str (" => ");
3326 Sprint_Node (Component_List (Node));
3328 when N_Variant_Part =>
3329 Indent_Begin;
3330 Write_Indent_Str_Sloc ("case ");
3331 Sprint_Node (Name (Node));
3332 Write_Str (" is ");
3333 Sprint_Indented_List (Variants (Node));
3334 Write_Indent_Str ("end case");
3335 Indent_End;
3337 when N_With_Clause =>
3339 -- Special test, if we are dumping the original tree only,
3340 -- then we want to eliminate the bogus with clauses that
3341 -- correspond to the non-existent children of Text_IO.
3343 if Dump_Original_Only
3344 and then Is_Text_IO_Special_Unit (Name (Node))
3345 then
3346 null;
3348 -- Normal case, output the with clause
3350 else
3351 if First_Name (Node) or else not Dump_Original_Only then
3353 -- Ada 2005 (AI-50217): Print limited with_clauses
3355 if Private_Present (Node) and Limited_Present (Node) then
3356 Write_Indent_Str ("limited private with ");
3358 elsif Private_Present (Node) then
3359 Write_Indent_Str ("private with ");
3361 elsif Limited_Present (Node) then
3362 Write_Indent_Str ("limited with ");
3364 else
3365 Write_Indent_Str ("with ");
3366 end if;
3368 else
3369 Write_Str (", ");
3370 end if;
3372 Sprint_Node_Sloc (Name (Node));
3374 if Last_Name (Node) or else not Dump_Original_Only then
3375 Write_Char (';');
3376 end if;
3377 end if;
3378 end case;
3380 -- Print aspects, except for special case of package declaration,
3381 -- where the aspects are printed inside the package specification.
3383 if Has_Aspects (Node)
3384 and then not Nkind_In (Node, N_Package_Declaration,
3385 N_Generic_Package_Declaration)
3386 then
3387 Sprint_Aspect_Specifications (Node, Semicolon => True);
3388 end if;
3390 if Nkind (Node) in N_Subexpr
3391 and then Do_Range_Check (Node)
3392 then
3393 Write_Str ("}");
3394 end if;
3396 for J in 1 .. Paren_Count (Node) loop
3397 Write_Char (')');
3398 end loop;
3400 Dump_Node := Save_Dump_Node;
3401 end Sprint_Node_Actual;
3403 ----------------------
3404 -- Sprint_Node_List --
3405 ----------------------
3407 procedure Sprint_Node_List (List : List_Id; New_Lines : Boolean := False) is
3408 Node : Node_Id;
3410 begin
3411 if Is_Non_Empty_List (List) then
3412 Node := First (List);
3414 loop
3415 Sprint_Node (Node);
3416 Next (Node);
3417 exit when Node = Empty;
3418 end loop;
3419 end if;
3421 if New_Lines and then Column /= 1 then
3422 Write_Eol;
3423 end if;
3424 end Sprint_Node_List;
3426 ----------------------
3427 -- Sprint_Node_Sloc --
3428 ----------------------
3430 procedure Sprint_Node_Sloc (Node : Node_Id) is
3431 begin
3432 Sprint_Node (Node);
3434 if Debug_Generated_Code and then Present (Dump_Node) then
3435 Set_Sloc (Dump_Node, Sloc (Node));
3436 Dump_Node := Empty;
3437 end if;
3438 end Sprint_Node_Sloc;
3440 ---------------------
3441 -- Sprint_Opt_Node --
3442 ---------------------
3444 procedure Sprint_Opt_Node (Node : Node_Id) is
3445 begin
3446 if Present (Node) then
3447 Write_Char (' ');
3448 Sprint_Node (Node);
3449 end if;
3450 end Sprint_Opt_Node;
3452 --------------------------
3453 -- Sprint_Opt_Node_List --
3454 --------------------------
3456 procedure Sprint_Opt_Node_List (List : List_Id) is
3457 begin
3458 if Present (List) then
3459 Sprint_Node_List (List);
3460 end if;
3461 end Sprint_Opt_Node_List;
3463 ---------------------------------
3464 -- Sprint_Opt_Paren_Comma_List --
3465 ---------------------------------
3467 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
3468 begin
3469 if Is_Non_Empty_List (List) then
3470 Write_Char (' ');
3471 Sprint_Paren_Comma_List (List);
3472 end if;
3473 end Sprint_Opt_Paren_Comma_List;
3475 -----------------------------
3476 -- Sprint_Paren_Comma_List --
3477 -----------------------------
3479 procedure Sprint_Paren_Comma_List (List : List_Id) is
3480 N : Node_Id;
3481 Node_Exists : Boolean := False;
3483 begin
3485 if Is_Non_Empty_List (List) then
3487 if Dump_Original_Only then
3488 N := First (List);
3489 while Present (N) loop
3490 if not Is_Rewrite_Insertion (N) then
3491 Node_Exists := True;
3492 exit;
3493 end if;
3495 Next (N);
3496 end loop;
3498 if not Node_Exists then
3499 return;
3500 end if;
3501 end if;
3503 Write_Str_With_Col_Check ("(");
3504 Sprint_Comma_List (List);
3505 Write_Char (')');
3506 end if;
3507 end Sprint_Paren_Comma_List;
3509 ----------------------
3510 -- Sprint_Right_Opnd --
3511 ----------------------
3513 procedure Sprint_Right_Opnd (N : Node_Id) is
3514 Opnd : constant Node_Id := Right_Opnd (N);
3516 begin
3517 if Paren_Count (Opnd) /= 0
3518 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
3519 then
3520 Sprint_Node (Opnd);
3522 else
3523 Write_Char ('(');
3524 Sprint_Node (Opnd);
3525 Write_Char (')');
3526 end if;
3527 end Sprint_Right_Opnd;
3529 ------------------
3530 -- Update_Itype --
3531 ------------------
3533 procedure Update_Itype (Node : Node_Id) is
3534 begin
3535 if Present (Etype (Node))
3536 and then Is_Itype (Etype (Node))
3537 and then Debug_Generated_Code
3538 then
3539 Set_Sloc (Etype (Node), Sloc (Node));
3540 end if;
3541 end Update_Itype;
3543 ---------------------
3544 -- Write_Char_Sloc --
3545 ---------------------
3547 procedure Write_Char_Sloc (C : Character) is
3548 begin
3549 if Debug_Generated_Code and then C /= ' ' then
3550 Set_Debug_Sloc;
3551 end if;
3553 Write_Char (C);
3554 end Write_Char_Sloc;
3556 --------------------------------
3557 -- Write_Condition_And_Reason --
3558 --------------------------------
3560 procedure Write_Condition_And_Reason (Node : Node_Id) is
3561 Cond : constant Node_Id := Condition (Node);
3562 Image : constant String := RT_Exception_Code'Image
3563 (RT_Exception_Code'Val
3564 (UI_To_Int (Reason (Node))));
3566 begin
3567 if Present (Cond) then
3569 -- If condition is a single entity, or NOT with a single entity,
3570 -- output all on one line, since it will likely fit just fine.
3572 if Is_Entity_Name (Cond)
3573 or else (Nkind (Cond) = N_Op_Not
3574 and then Is_Entity_Name (Right_Opnd (Cond)))
3575 then
3576 Write_Str_With_Col_Check (" when ");
3577 Sprint_Node (Cond);
3578 Write_Char (' ');
3580 -- Otherwise for more complex condition, multiple lines
3582 else
3583 Write_Str_With_Col_Check (" when");
3584 Indent := Indent + 2;
3585 Write_Indent;
3586 Sprint_Node (Cond);
3587 Write_Indent;
3588 Indent := Indent - 2;
3589 end if;
3591 -- If no condition, just need a space (all on one line)
3593 else
3594 Write_Char (' ');
3595 end if;
3597 -- Write the reason
3599 Write_Char ('"');
3601 for J in 4 .. Image'Last loop
3602 if Image (J) = '_' then
3603 Write_Char (' ');
3604 else
3605 Write_Char (Fold_Lower (Image (J)));
3606 end if;
3607 end loop;
3609 Write_Str ("""]");
3610 end Write_Condition_And_Reason;
3612 --------------------------------
3613 -- Write_Corresponding_Source --
3614 --------------------------------
3616 procedure Write_Corresponding_Source (S : String) is
3617 Loc : Source_Ptr;
3618 Src : Source_Buffer_Ptr;
3620 begin
3621 -- Ignore if not in dump source text mode, or if in freeze actions
3623 if Dump_Source_Text and then Freeze_Indent = 0 then
3625 -- Ignore null string
3627 if S = "" then
3628 return;
3629 end if;
3631 -- Ignore space or semicolon at end of given string
3633 if S (S'Last) = ' ' or else S (S'Last) = ';' then
3634 Write_Corresponding_Source (S (S'First .. S'Last - 1));
3635 return;
3636 end if;
3638 -- Loop to look at next lines not yet printed in source file
3640 for L in
3641 Last_Line_Printed + 1 .. Last_Source_Line (Current_Source_File)
3642 loop
3643 Src := Source_Text (Current_Source_File);
3644 Loc := Line_Start (L, Current_Source_File);
3646 -- If comment, keep looking
3648 if Src (Loc .. Loc + 1) = "--" then
3649 null;
3651 -- Search to first non-blank
3653 else
3654 while Src (Loc) not in Line_Terminator loop
3656 -- Non-blank found
3658 if Src (Loc) /= ' ' and then Src (Loc) /= ASCII.HT then
3660 -- Loop through characters in string to see if we match
3662 for J in S'Range loop
3664 -- If mismatch, then not the case we are looking for
3666 if Src (Loc) /= S (J) then
3667 return;
3668 end if;
3670 Loc := Loc + 1;
3671 end loop;
3673 -- If we fall through, string matched, if white space or
3674 -- semicolon after the matched string, this is the case
3675 -- we are looking for.
3677 if Src (Loc) in Line_Terminator
3678 or else Src (Loc) = ' '
3679 or else Src (Loc) = ASCII.HT
3680 or else Src (Loc) = ';'
3681 then
3682 -- So output source lines up to and including this one
3684 Write_Source_Lines (L);
3685 return;
3686 end if;
3687 end if;
3689 Loc := Loc + 1;
3690 end loop;
3691 end if;
3693 -- Line was all blanks, or a comment line, keep looking
3695 end loop;
3696 end if;
3697 end Write_Corresponding_Source;
3699 -----------------------
3700 -- Write_Discr_Specs --
3701 -----------------------
3703 procedure Write_Discr_Specs (N : Node_Id) is
3704 Specs : List_Id;
3705 Spec : Node_Id;
3707 begin
3708 Specs := Discriminant_Specifications (N);
3710 if Present (Specs) then
3711 Write_Str_With_Col_Check (" (");
3712 Spec := First (Specs);
3714 loop
3715 Sprint_Node (Spec);
3716 Next (Spec);
3717 exit when Spec = Empty;
3719 -- Add semicolon, unless we are printing original tree and the
3720 -- next specification is part of a list (but not the first
3721 -- element of that list)
3723 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3724 Write_Str ("; ");
3725 end if;
3726 end loop;
3728 Write_Char (')');
3729 end if;
3730 end Write_Discr_Specs;
3732 -----------------
3733 -- Write_Ekind --
3734 -----------------
3736 procedure Write_Ekind (E : Entity_Id) is
3737 S : constant String := Entity_Kind'Image (Ekind (E));
3739 begin
3740 Name_Len := S'Length;
3741 Name_Buffer (1 .. Name_Len) := S;
3742 Set_Casing (Mixed_Case);
3743 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3744 end Write_Ekind;
3746 --------------
3747 -- Write_Id --
3748 --------------
3750 procedure Write_Id (N : Node_Id) is
3751 begin
3752 -- Deal with outputting Itype
3754 -- Note: if we are printing the full tree with -gnatds, then we may
3755 -- end up picking up the Associated_Node link from a generic template
3756 -- here which overlaps the Entity field, but as documented, Write_Itype
3757 -- is defended against junk calls.
3759 if Nkind (N) in N_Entity then
3760 Write_Itype (N);
3761 elsif Nkind (N) in N_Has_Entity then
3762 Write_Itype (Entity (N));
3763 end if;
3765 -- Case of a defining identifier
3767 if Nkind (N) = N_Defining_Identifier then
3769 -- If defining identifier has an interface name (and no
3770 -- address clause), then we output the interface name.
3772 if (Is_Imported (N) or else Is_Exported (N))
3773 and then Present (Interface_Name (N))
3774 and then No (Address_Clause (N))
3775 then
3776 String_To_Name_Buffer (Strval (Interface_Name (N)));
3777 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3779 -- If no interface name (or inactive because there was
3780 -- an address clause), then just output the Chars name.
3782 else
3783 Write_Name_With_Col_Check (Chars (N));
3784 end if;
3786 -- Case of selector of an expanded name where the expanded name
3787 -- has an associated entity, output this entity. Check that the
3788 -- entity or associated node is of the right kind, see above.
3790 elsif Nkind (Parent (N)) = N_Expanded_Name
3791 and then Selector_Name (Parent (N)) = N
3792 and then Present (Entity_Or_Associated_Node (Parent (N)))
3793 and then Nkind (Entity (Parent (N))) in N_Entity
3794 then
3795 Write_Id (Entity (Parent (N)));
3797 -- For any other node with an associated entity, output it
3799 elsif Nkind (N) in N_Has_Entity
3800 and then Present (Entity_Or_Associated_Node (N))
3801 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
3802 then
3803 Write_Id (Entity (N));
3805 -- All other cases, we just print the Chars field
3807 else
3808 Write_Name_With_Col_Check (Chars (N));
3809 end if;
3810 end Write_Id;
3812 -----------------------
3813 -- Write_Identifiers --
3814 -----------------------
3816 function Write_Identifiers (Node : Node_Id) return Boolean is
3817 begin
3818 Sprint_Node (Defining_Identifier (Node));
3819 Update_Itype (Defining_Identifier (Node));
3821 -- The remainder of the declaration must be printed unless we are
3822 -- printing the original tree and this is not the last identifier
3824 return
3825 not Dump_Original_Only or else not More_Ids (Node);
3827 end Write_Identifiers;
3829 ------------------------
3830 -- Write_Implicit_Def --
3831 ------------------------
3833 procedure Write_Implicit_Def (E : Entity_Id) is
3834 Ind : Node_Id;
3836 begin
3837 case Ekind (E) is
3838 when E_Array_Subtype =>
3839 Write_Str_With_Col_Check ("subtype ");
3840 Write_Id (E);
3841 Write_Str_With_Col_Check (" is ");
3842 Write_Id (Base_Type (E));
3843 Write_Str_With_Col_Check (" (");
3845 Ind := First_Index (E);
3846 while Present (Ind) loop
3847 Sprint_Node (Ind);
3848 Next_Index (Ind);
3850 if Present (Ind) then
3851 Write_Str (", ");
3852 end if;
3853 end loop;
3855 Write_Str (");");
3857 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
3858 Write_Str_With_Col_Check ("subtype ");
3859 Write_Id (E);
3860 Write_Str (" is ");
3861 Write_Id (Etype (E));
3862 Write_Str_With_Col_Check (" range ");
3863 Sprint_Node (Scalar_Range (E));
3864 Write_Str (";");
3866 when others =>
3867 Write_Str_With_Col_Check ("type ");
3868 Write_Id (E);
3869 Write_Str_With_Col_Check (" is <");
3870 Write_Ekind (E);
3871 Write_Str (">;");
3872 end case;
3874 end Write_Implicit_Def;
3876 ------------------
3877 -- Write_Indent --
3878 ------------------
3880 procedure Write_Indent is
3881 Loc : constant Source_Ptr := Sloc (Dump_Node);
3883 begin
3884 if Indent_Annull_Flag then
3885 Indent_Annull_Flag := False;
3886 else
3887 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3888 -- label declarations, since they typically have the sloc of the
3889 -- corresponding label, which really messes up the -gnatL output.
3891 if Dump_Source_Text
3892 and then Loc > No_Location
3893 and then Nkind (Dump_Node) /= N_Implicit_Label_Declaration
3894 then
3895 if Get_Source_File_Index (Loc) = Current_Source_File then
3896 Write_Source_Lines
3897 (Get_Physical_Line_Number (Sloc (Dump_Node)));
3898 end if;
3899 end if;
3901 Write_Eol;
3903 for J in 1 .. Indent loop
3904 Write_Char (' ');
3905 end loop;
3906 end if;
3907 end Write_Indent;
3909 ------------------------------
3910 -- Write_Indent_Identifiers --
3911 ------------------------------
3913 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3914 begin
3915 -- We need to start a new line for every node, except in the case
3916 -- where we are printing the original tree and this is not the first
3917 -- defining identifier in the list.
3919 if not Dump_Original_Only or else not Prev_Ids (Node) then
3920 Write_Indent;
3922 -- If printing original tree and this is not the first defining
3923 -- identifier in the list, then the previous call to this procedure
3924 -- printed only the name, and we add a comma to separate the names.
3926 else
3927 Write_Str (", ");
3928 end if;
3930 Sprint_Node (Defining_Identifier (Node));
3932 -- The remainder of the declaration must be printed unless we are
3933 -- printing the original tree and this is not the last identifier
3935 return
3936 not Dump_Original_Only or else not More_Ids (Node);
3937 end Write_Indent_Identifiers;
3939 -----------------------------------
3940 -- Write_Indent_Identifiers_Sloc --
3941 -----------------------------------
3943 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3944 begin
3945 -- We need to start a new line for every node, except in the case
3946 -- where we are printing the original tree and this is not the first
3947 -- defining identifier in the list.
3949 if not Dump_Original_Only or else not Prev_Ids (Node) then
3950 Write_Indent;
3952 -- If printing original tree and this is not the first defining
3953 -- identifier in the list, then the previous call to this procedure
3954 -- printed only the name, and we add a comma to separate the names.
3956 else
3957 Write_Str (", ");
3958 end if;
3960 Set_Debug_Sloc;
3961 Sprint_Node (Defining_Identifier (Node));
3963 -- The remainder of the declaration must be printed unless we are
3964 -- printing the original tree and this is not the last identifier
3966 return not Dump_Original_Only or else not More_Ids (Node);
3967 end Write_Indent_Identifiers_Sloc;
3969 ----------------------
3970 -- Write_Indent_Str --
3971 ----------------------
3973 procedure Write_Indent_Str (S : String) is
3974 begin
3975 Write_Corresponding_Source (S);
3976 Write_Indent;
3977 Write_Str (S);
3978 end Write_Indent_Str;
3980 ---------------------------
3981 -- Write_Indent_Str_Sloc --
3982 ---------------------------
3984 procedure Write_Indent_Str_Sloc (S : String) is
3985 begin
3986 Write_Corresponding_Source (S);
3987 Write_Indent;
3988 Write_Str_Sloc (S);
3989 end Write_Indent_Str_Sloc;
3991 -----------------
3992 -- Write_Itype --
3993 -----------------
3995 procedure Write_Itype (Typ : Entity_Id) is
3997 procedure Write_Header (T : Boolean := True);
3998 -- Write type if T is True, subtype if T is false
4000 ------------------
4001 -- Write_Header --
4002 ------------------
4004 procedure Write_Header (T : Boolean := True) is
4005 begin
4006 if T then
4007 Write_Str ("[type ");
4008 else
4009 Write_Str ("[subtype ");
4010 end if;
4012 Write_Name_With_Col_Check (Chars (Typ));
4013 Write_Str (" is ");
4014 end Write_Header;
4016 -- Start of processing for Write_Itype
4018 begin
4019 if Nkind (Typ) in N_Entity
4020 and then Is_Itype (Typ)
4021 and then not Itype_Printed (Typ)
4022 then
4023 -- Itype to be printed
4025 declare
4026 B : constant Node_Id := Etype (Typ);
4027 X : Node_Id;
4028 P : constant Node_Id := Parent (Typ);
4030 S : constant Saved_Output_Buffer := Save_Output_Buffer;
4031 -- Save current output buffer
4033 Old_Sloc : Source_Ptr;
4034 -- Save sloc of related node, so it is not modified when
4035 -- printing with -gnatD.
4037 begin
4038 -- Write indentation at start of line
4040 for J in 1 .. Indent loop
4041 Write_Char (' ');
4042 end loop;
4044 -- If we have a constructed declaration for the itype, print it
4046 if Present (P)
4047 and then Nkind (P) in N_Declaration
4048 and then Defining_Entity (P) = Typ
4049 then
4050 -- We must set Itype_Printed true before the recursive call to
4051 -- print the node, otherwise we get an infinite recursion.
4053 Set_Itype_Printed (Typ, True);
4055 -- Write the declaration enclosed in [], avoiding new line
4056 -- at start of declaration, and semicolon at end.
4058 -- Note: The itype may be imported from another unit, in which
4059 -- case we do not want to modify the Sloc of the declaration.
4060 -- Otherwise the itype may appear to be in the current unit,
4061 -- and the back-end will reject a reference out of scope.
4063 Write_Char ('[');
4064 Indent_Annull_Flag := True;
4065 Old_Sloc := Sloc (P);
4066 Sprint_Node (P);
4067 Set_Sloc (P, Old_Sloc);
4068 Write_Erase_Char (';');
4070 -- If no constructed declaration, then we have to concoct the
4071 -- source corresponding to the type entity that we have at hand.
4073 else
4074 case Ekind (Typ) is
4076 -- Access types and subtypes
4078 when Access_Kind =>
4079 Write_Header (Ekind (Typ) = E_Access_Type);
4081 if Can_Never_Be_Null (Typ) then
4082 Write_Str ("not null ");
4083 end if;
4085 Write_Str ("access ");
4087 if Is_Access_Constant (Typ) then
4088 Write_Str ("constant ");
4089 end if;
4091 Write_Id (Directly_Designated_Type (Typ));
4093 -- Array types and string types
4095 when E_Array_Type =>
4096 Write_Header;
4097 Write_Str ("array (");
4099 X := First_Index (Typ);
4100 loop
4101 Sprint_Node (X);
4103 if not Is_Constrained (Typ) then
4104 Write_Str (" range <>");
4105 end if;
4107 Next_Index (X);
4108 exit when No (X);
4109 Write_Str (", ");
4110 end loop;
4112 Write_Str (") of ");
4113 X := Component_Type (Typ);
4115 -- Preserve sloc of component type, which is defined
4116 -- elsewhere than the itype (see comment above).
4118 Old_Sloc := Sloc (X);
4119 Sprint_Node (X);
4120 Set_Sloc (X, Old_Sloc);
4122 -- Array subtypes and string subtypes.
4123 -- Preserve Sloc of index subtypes, as above.
4125 when E_Array_Subtype | E_String_Subtype =>
4126 Write_Header (False);
4127 Write_Id (Etype (Typ));
4128 Write_Str (" (");
4130 X := First_Index (Typ);
4131 loop
4132 Old_Sloc := Sloc (X);
4133 Sprint_Node (X);
4134 Set_Sloc (X, Old_Sloc);
4135 Next_Index (X);
4136 exit when No (X);
4137 Write_Str (", ");
4138 end loop;
4140 Write_Char (')');
4142 -- Signed integer types, and modular integer subtypes,
4143 -- and also enumeration subtypes.
4145 when E_Signed_Integer_Type |
4146 E_Signed_Integer_Subtype |
4147 E_Modular_Integer_Subtype |
4148 E_Enumeration_Subtype =>
4150 Write_Header (Ekind (Typ) = E_Signed_Integer_Type);
4152 if Ekind (Typ) = E_Signed_Integer_Type then
4153 Write_Str ("new ");
4154 end if;
4156 Write_Id (B);
4158 -- Print bounds if different from base type
4160 declare
4161 L : constant Node_Id := Type_Low_Bound (Typ);
4162 H : constant Node_Id := Type_High_Bound (Typ);
4163 LE : Node_Id;
4164 HE : Node_Id;
4166 begin
4167 -- B can either be a scalar type, in which case the
4168 -- declaration of Typ may constrain it with different
4169 -- bounds, or a private type, in which case we know
4170 -- that the declaration of Typ cannot have a scalar
4171 -- constraint.
4173 if Is_Scalar_Type (B) then
4174 LE := Type_Low_Bound (B);
4175 HE := Type_High_Bound (B);
4176 else
4177 LE := Empty;
4178 HE := Empty;
4179 end if;
4181 if No (LE)
4182 or else (True
4183 and then Nkind (L) = N_Integer_Literal
4184 and then Nkind (H) = N_Integer_Literal
4185 and then Nkind (LE) = N_Integer_Literal
4186 and then Nkind (HE) = N_Integer_Literal
4187 and then UI_Eq (Intval (L), Intval (LE))
4188 and then UI_Eq (Intval (H), Intval (HE)))
4189 then
4190 null;
4192 else
4193 Write_Str (" range ");
4194 Sprint_Node (Type_Low_Bound (Typ));
4195 Write_Str (" .. ");
4196 Sprint_Node (Type_High_Bound (Typ));
4197 end if;
4198 end;
4200 -- Modular integer types
4202 when E_Modular_Integer_Type =>
4203 Write_Header;
4204 Write_Str ("mod ");
4205 Write_Uint_With_Col_Check (Modulus (Typ), Auto);
4207 -- Floating point types and subtypes
4209 when E_Floating_Point_Type |
4210 E_Floating_Point_Subtype =>
4212 Write_Header (Ekind (Typ) = E_Floating_Point_Type);
4214 if Ekind (Typ) = E_Floating_Point_Type then
4215 Write_Str ("new ");
4216 end if;
4218 Write_Id (Etype (Typ));
4220 if Digits_Value (Typ) /= Digits_Value (Etype (Typ)) then
4221 Write_Str (" digits ");
4222 Write_Uint_With_Col_Check
4223 (Digits_Value (Typ), Decimal);
4224 end if;
4226 -- Print bounds if not different from base type
4228 declare
4229 L : constant Node_Id := Type_Low_Bound (Typ);
4230 H : constant Node_Id := Type_High_Bound (Typ);
4231 LE : constant Node_Id := Type_Low_Bound (B);
4232 HE : constant Node_Id := Type_High_Bound (B);
4234 begin
4235 if Nkind (L) = N_Real_Literal
4236 and then Nkind (H) = N_Real_Literal
4237 and then Nkind (LE) = N_Real_Literal
4238 and then Nkind (HE) = N_Real_Literal
4239 and then UR_Eq (Realval (L), Realval (LE))
4240 and then UR_Eq (Realval (H), Realval (HE))
4241 then
4242 null;
4244 else
4245 Write_Str (" range ");
4246 Sprint_Node (Type_Low_Bound (Typ));
4247 Write_Str (" .. ");
4248 Sprint_Node (Type_High_Bound (Typ));
4249 end if;
4250 end;
4252 -- Record subtypes
4254 when E_Record_Subtype | E_Record_Subtype_With_Private =>
4255 Write_Header (False);
4256 Write_Str ("record");
4257 Indent_Begin;
4259 declare
4260 C : Entity_Id;
4261 begin
4262 C := First_Entity (Typ);
4263 while Present (C) loop
4264 Write_Indent;
4265 Write_Id (C);
4266 Write_Str (" : ");
4267 Write_Id (Etype (C));
4268 Next_Entity (C);
4269 end loop;
4270 end;
4272 Indent_End;
4273 Write_Indent_Str (" end record");
4275 -- Class-Wide types
4277 when E_Class_Wide_Type |
4278 E_Class_Wide_Subtype =>
4279 Write_Header (Ekind (Typ) = E_Class_Wide_Type);
4280 Write_Name_With_Col_Check (Chars (Etype (Typ)));
4281 Write_Str ("'Class");
4283 -- Subprogram types
4285 when E_Subprogram_Type =>
4286 Write_Header;
4288 if Etype (Typ) = Standard_Void_Type then
4289 Write_Str ("procedure");
4290 else
4291 Write_Str ("function");
4292 end if;
4294 if Present (First_Entity (Typ)) then
4295 Write_Str (" (");
4297 declare
4298 Param : Entity_Id;
4300 begin
4301 Param := First_Entity (Typ);
4302 loop
4303 Write_Id (Param);
4304 Write_Str (" : ");
4306 if Ekind (Param) = E_In_Out_Parameter then
4307 Write_Str ("in out ");
4308 elsif Ekind (Param) = E_Out_Parameter then
4309 Write_Str ("out ");
4310 end if;
4312 Write_Id (Etype (Param));
4313 Next_Entity (Param);
4314 exit when No (Param);
4315 Write_Str (", ");
4316 end loop;
4318 Write_Char (')');
4319 end;
4320 end if;
4322 if Etype (Typ) /= Standard_Void_Type then
4323 Write_Str (" return ");
4324 Write_Id (Etype (Typ));
4325 end if;
4327 when E_String_Literal_Subtype =>
4328 declare
4329 LB : constant Uint :=
4330 Expr_Value (String_Literal_Low_Bound (Typ));
4331 Len : constant Uint :=
4332 String_Literal_Length (Typ);
4333 begin
4334 Write_Header (False);
4335 Write_Str ("String (");
4336 Write_Int (UI_To_Int (LB));
4337 Write_Str (" .. ");
4338 Write_Int (UI_To_Int (LB + Len) - 1);
4339 Write_Str (");");
4340 end;
4342 -- For all other Itypes, print ??? (fill in later)
4344 when others =>
4345 Write_Header (True);
4346 Write_Str ("???");
4348 end case;
4349 end if;
4351 -- Add terminating bracket and restore output buffer
4353 Write_Char (']');
4354 Write_Eol;
4355 Restore_Output_Buffer (S);
4356 end;
4358 Set_Itype_Printed (Typ);
4359 end if;
4360 end Write_Itype;
4362 -------------------------------
4363 -- Write_Name_With_Col_Check --
4364 -------------------------------
4366 procedure Write_Name_With_Col_Check (N : Name_Id) is
4367 J : Natural;
4368 K : Natural;
4369 L : Natural;
4371 begin
4372 Get_Name_String (N);
4374 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4375 -- upper case letter, nnn is one or more digits and b is a lower case
4376 -- letter by C...b, so that listings do not depend on serial numbers.
4378 if Debug_Flag_II then
4379 J := 1;
4380 while J < Name_Len - 1 loop
4381 if Name_Buffer (J) in 'A' .. 'Z'
4382 and then Name_Buffer (J + 1) in '0' .. '9'
4383 then
4384 K := J + 1;
4385 while K < Name_Len loop
4386 exit when Name_Buffer (K) not in '0' .. '9';
4387 K := K + 1;
4388 end loop;
4390 if Name_Buffer (K) in 'a' .. 'z' then
4391 L := Name_Len - K + 1;
4393 Name_Buffer (J + 4 .. J + L + 3) :=
4394 Name_Buffer (K .. Name_Len);
4395 Name_Buffer (J + 1 .. J + 3) := "...";
4396 Name_Len := J + L + 3;
4397 J := J + 5;
4399 else
4400 J := K;
4401 end if;
4403 else
4404 J := J + 1;
4405 end if;
4406 end loop;
4407 end if;
4409 -- Fall through for normal case
4411 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
4412 end Write_Name_With_Col_Check;
4414 ------------------------------------
4415 -- Write_Name_With_Col_Check_Sloc --
4416 ------------------------------------
4418 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
4419 begin
4420 Get_Name_String (N);
4421 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
4422 end Write_Name_With_Col_Check_Sloc;
4424 --------------------
4425 -- Write_Operator --
4426 --------------------
4428 procedure Write_Operator (N : Node_Id; S : String) is
4429 F : Natural := S'First;
4430 T : Natural := S'Last;
4432 begin
4433 -- If no overflow check, just write string out, and we are done
4435 if not Do_Overflow_Check (N) then
4436 Write_Str_Sloc (S);
4438 -- If overflow check, we want to surround the operator with curly
4439 -- brackets, but not include spaces within the brackets.
4441 else
4442 if S (F) = ' ' then
4443 Write_Char (' ');
4444 F := F + 1;
4445 end if;
4447 if S (T) = ' ' then
4448 T := T - 1;
4449 end if;
4451 Write_Char ('{');
4452 Write_Str_Sloc (S (F .. T));
4453 Write_Char ('}');
4455 if S (S'Last) = ' ' then
4456 Write_Char (' ');
4457 end if;
4458 end if;
4459 end Write_Operator;
4461 -----------------------
4462 -- Write_Param_Specs --
4463 -----------------------
4465 procedure Write_Param_Specs (N : Node_Id) is
4466 Specs : List_Id;
4467 Spec : Node_Id;
4468 Formal : Node_Id;
4470 begin
4471 Specs := Parameter_Specifications (N);
4473 if Is_Non_Empty_List (Specs) then
4474 Write_Str_With_Col_Check (" (");
4475 Spec := First (Specs);
4477 loop
4478 Sprint_Node (Spec);
4479 Formal := Defining_Identifier (Spec);
4480 Next (Spec);
4481 exit when Spec = Empty;
4483 -- Add semicolon, unless we are printing original tree and the
4484 -- next specification is part of a list (but not the first element
4485 -- of that list).
4487 if not Dump_Original_Only or else not Prev_Ids (Spec) then
4488 Write_Str ("; ");
4489 end if;
4490 end loop;
4492 -- Write out any extra formals
4494 while Present (Extra_Formal (Formal)) loop
4495 Formal := Extra_Formal (Formal);
4496 Write_Str ("; ");
4497 Write_Name_With_Col_Check (Chars (Formal));
4498 Write_Str (" : ");
4499 Write_Name_With_Col_Check (Chars (Etype (Formal)));
4500 end loop;
4502 Write_Char (')');
4503 end if;
4504 end Write_Param_Specs;
4506 -----------------------
4507 -- Write_Rewrite_Str --
4508 -----------------------
4510 procedure Write_Rewrite_Str (S : String) is
4511 begin
4512 if not Dump_Generated_Only then
4513 if S'Length = 3 and then S = ">>>" then
4514 Write_Str (">>>");
4515 else
4516 Write_Str_With_Col_Check (S);
4517 end if;
4518 end if;
4519 end Write_Rewrite_Str;
4521 -----------------------
4522 -- Write_Source_Line --
4523 -----------------------
4525 procedure Write_Source_Line (L : Physical_Line_Number) is
4526 Loc : Source_Ptr;
4527 Src : Source_Buffer_Ptr;
4528 Scn : Source_Ptr;
4530 begin
4531 if Dump_Source_Text then
4532 Src := Source_Text (Current_Source_File);
4533 Loc := Line_Start (L, Current_Source_File);
4534 Write_Eol;
4536 -- See if line is a comment line, if not, and if not line one,
4537 -- precede with blank line.
4539 Scn := Loc;
4540 while Src (Scn) = ' ' or else Src (Scn) = ASCII.HT loop
4541 Scn := Scn + 1;
4542 end loop;
4544 if (Src (Scn) in Line_Terminator
4545 or else Src (Scn .. Scn + 1) /= "--")
4546 and then L /= 1
4547 then
4548 Write_Eol;
4549 end if;
4551 -- Now write the source text of the line
4553 Write_Str ("-- ");
4554 Write_Int (Int (L));
4555 Write_Str (": ");
4557 while Src (Loc) not in Line_Terminator loop
4558 Write_Char (Src (Loc));
4559 Loc := Loc + 1;
4560 end loop;
4561 end if;
4562 end Write_Source_Line;
4564 ------------------------
4565 -- Write_Source_Lines --
4566 ------------------------
4568 procedure Write_Source_Lines (L : Physical_Line_Number) is
4569 begin
4570 while Last_Line_Printed < L loop
4571 Last_Line_Printed := Last_Line_Printed + 1;
4572 Write_Source_Line (Last_Line_Printed);
4573 end loop;
4574 end Write_Source_Lines;
4576 --------------------
4577 -- Write_Str_Sloc --
4578 --------------------
4580 procedure Write_Str_Sloc (S : String) is
4581 begin
4582 for J in S'Range loop
4583 Write_Char_Sloc (S (J));
4584 end loop;
4585 end Write_Str_Sloc;
4587 ------------------------------
4588 -- Write_Str_With_Col_Check --
4589 ------------------------------
4591 procedure Write_Str_With_Col_Check (S : String) is
4592 begin
4593 if Int (S'Last) + Column > Sprint_Line_Limit then
4594 Write_Indent_Str (" ");
4596 if S (S'First) = ' ' then
4597 Write_Str (S (S'First + 1 .. S'Last));
4598 else
4599 Write_Str (S);
4600 end if;
4602 else
4603 Write_Str (S);
4604 end if;
4605 end Write_Str_With_Col_Check;
4607 -----------------------------------
4608 -- Write_Str_With_Col_Check_Sloc --
4609 -----------------------------------
4611 procedure Write_Str_With_Col_Check_Sloc (S : String) is
4612 begin
4613 if Int (S'Last) + Column > Sprint_Line_Limit then
4614 Write_Indent_Str (" ");
4616 if S (S'First) = ' ' then
4617 Write_Str_Sloc (S (S'First + 1 .. S'Last));
4618 else
4619 Write_Str_Sloc (S);
4620 end if;
4622 else
4623 Write_Str_Sloc (S);
4624 end if;
4625 end Write_Str_With_Col_Check_Sloc;
4627 ---------------------------
4628 -- Write_Subprogram_Name --
4629 ---------------------------
4631 procedure Write_Subprogram_Name (N : Node_Id) is
4632 begin
4633 if not Comes_From_Source (N)
4634 and then Is_Entity_Name (N)
4635 then
4636 declare
4637 Ent : constant Entity_Id := Entity (N);
4638 begin
4639 if not In_Extended_Main_Source_Unit (Ent)
4640 and then
4641 Is_Predefined_File_Name
4642 (Unit_File_Name (Get_Source_Unit (Ent)))
4643 then
4644 -- Run-time routine name, output name with a preceding dollar
4645 -- making sure that we do not get a line split between them.
4647 Col_Check (Length_Of_Name (Chars (Ent)) + 1);
4648 Write_Char ('$');
4649 Write_Name (Chars (Ent));
4650 return;
4651 end if;
4652 end;
4653 end if;
4655 -- Normal case, not a run-time routine name
4657 Sprint_Node (N);
4658 end Write_Subprogram_Name;
4660 -------------------------------
4661 -- Write_Uint_With_Col_Check --
4662 -------------------------------
4664 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format) is
4665 begin
4666 Col_Check (UI_Decimal_Digits_Hi (U));
4667 UI_Write (U, Format);
4668 end Write_Uint_With_Col_Check;
4670 ------------------------------------
4671 -- Write_Uint_With_Col_Check_Sloc --
4672 ------------------------------------
4674 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
4675 begin
4676 Col_Check (UI_Decimal_Digits_Hi (U));
4677 Set_Debug_Sloc;
4678 UI_Write (U, Format);
4679 end Write_Uint_With_Col_Check_Sloc;
4681 -------------------------------------
4682 -- Write_Ureal_With_Col_Check_Sloc --
4683 -------------------------------------
4685 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
4686 D : constant Uint := Denominator (U);
4687 N : constant Uint := Numerator (U);
4688 begin
4689 Col_Check (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
4690 Set_Debug_Sloc;
4691 UR_Write (U, Brackets => True);
4692 end Write_Ureal_With_Col_Check_Sloc;
4694 end Sprint;