Print cgraph_uid in function header
[official-gcc.git] / gcc-4_6-mobile-vtable-security / gcc / ada / sprint.adb
blobe984b5bc85d7d9738ea7723b1b9bcf3298bc098b
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-2010, 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 freeze nodes and non-source null statements output
75 Freeze_Indent : Int := 0;
76 -- Keep track of freeze indent level (controls output of blank lines before
77 -- procedures within expression freeze actions). Relevant only if we are
78 -- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't
79 -- output these blank lines in any case.
81 Indent : Int := 0;
82 -- Number of columns for current line output indentation
84 Indent_Annull_Flag : Boolean := False;
85 -- Set True if subsequent Write_Indent call to be ignored, gets reset
86 -- by this call, so it is only active to suppress a single indent call.
88 Last_Line_Printed : Physical_Line_Number;
89 -- This keeps track of the physical line number of the last source line
90 -- that has been output. The value is only valid in Dump_Source_Text mode.
92 -------------------------------
93 -- Operator Precedence Table --
94 -------------------------------
96 -- This table is used to decide whether a subexpression needs to be
97 -- parenthesized. The rule is that if an operand of an operator (which
98 -- for this purpose includes AND THEN and OR ELSE) is itself an operator
99 -- with a lower precedence than the operator (or equal precedence if
100 -- appearing as the right operand), then parentheses are required.
102 Op_Prec : constant array (N_Subexpr) of Short_Short_Integer :=
103 (N_Op_And => 1,
104 N_Op_Or => 1,
105 N_Op_Xor => 1,
106 N_And_Then => 1,
107 N_Or_Else => 1,
109 N_In => 2,
110 N_Not_In => 2,
111 N_Op_Eq => 2,
112 N_Op_Ge => 2,
113 N_Op_Gt => 2,
114 N_Op_Le => 2,
115 N_Op_Lt => 2,
116 N_Op_Ne => 2,
118 N_Op_Add => 3,
119 N_Op_Concat => 3,
120 N_Op_Subtract => 3,
121 N_Op_Plus => 3,
122 N_Op_Minus => 3,
124 N_Op_Divide => 4,
125 N_Op_Mod => 4,
126 N_Op_Rem => 4,
127 N_Op_Multiply => 4,
129 N_Op_Expon => 5,
130 N_Op_Abs => 5,
131 N_Op_Not => 5,
133 others => 6);
135 procedure Sprint_Left_Opnd (N : Node_Id);
136 -- Print left operand of operator, parenthesizing if necessary
138 procedure Sprint_Right_Opnd (N : Node_Id);
139 -- Print right operand of operator, parenthesizing if necessary
141 -----------------------
142 -- Local Subprograms --
143 -----------------------
145 procedure Col_Check (N : Nat);
146 -- Check that at least N characters remain on current line, and if not,
147 -- then start an extra line with two characters extra indentation for
148 -- continuing text on the next line.
150 procedure Extra_Blank_Line;
151 -- In some situations we write extra blank lines to separate the generated
152 -- code to make it more readable. However, these extra blank lines are not
153 -- generated in Dump_Source_Text mode, since there the source text lines
154 -- output with preceding blank lines are quite sufficient as separators.
155 -- This procedure writes a blank line if Dump_Source_Text is False.
157 procedure Indent_Annull;
158 -- Causes following call to Write_Indent to be ignored. This is used when
159 -- a higher level node wants to stop a lower level node from starting a
160 -- new line, when it would otherwise be inclined to do so (e.g. the case
161 -- of an accept statement called from an accept alternative with a guard)
163 procedure Indent_Begin;
164 -- Increase indentation level
166 procedure Indent_End;
167 -- Decrease indentation level
169 procedure Print_Debug_Line (S : String);
170 -- Used to print output lines in Debug_Generated_Code mode (this is used
171 -- as the argument for a call to Set_Special_Output in package Output).
173 procedure Process_TFAI_RR_Flags (Nod : Node_Id);
174 -- Given a divide, multiplication or division node, check the flags
175 -- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
176 -- appropriate special syntax characters (# and @).
178 procedure Set_Debug_Sloc;
179 -- If Dump_Node is non-empty, this routine sets the appropriate value
180 -- in its Sloc field, from the current location in the debug source file
181 -- that is currently being written.
183 procedure Sprint_And_List (List : List_Id);
184 -- Print the given list with items separated by vertical "and"
186 procedure Sprint_Aspect_Specifications (Node : Node_Id);
187 -- Node is a declaration node that has aspect specifications (Has_Aspects
188 -- flag set True). It is called after outputting the terminating semicolon
189 -- for the related node. The effect is to remove the semicolon and print
190 -- the aspect specifications, followed by a terminating semicolon.
192 procedure Sprint_Bar_List (List : List_Id);
193 -- Print the given list with items separated by vertical bars
195 procedure Sprint_End_Label
196 (Node : Node_Id;
197 Default : Node_Id);
198 -- Print the end label for a Handled_Sequence_Of_Statements in a body.
199 -- If there is not end label, use the defining identifier of the enclosing
200 -- construct. If the end label is present, treat it as a reference to the
201 -- defining entity of the construct: this guarantees that it carries the
202 -- proper sloc information for debugging purposes.
204 procedure Sprint_Node_Actual (Node : Node_Id);
205 -- This routine prints its node argument. It is a lower level routine than
206 -- Sprint_Node, in that it does not bother about rewritten trees.
208 procedure Sprint_Node_Sloc (Node : Node_Id);
209 -- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
210 -- sets the Sloc of the current debug node to be a copy of the Sloc
211 -- of the sprinted node Node. Note that this is done after printing
212 -- Node, so that the Sloc is the proper updated value for the debug file.
214 procedure Update_Itype (Node : Node_Id);
215 -- Update the Sloc of an itype that is not attached to the tree, when
216 -- debugging expanded code. This routine is called from nodes whose
217 -- type can be an Itype, such as defining_identifiers that may be of
218 -- an anonymous access type, or ranges in slices.
220 procedure Write_Char_Sloc (C : Character);
221 -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
222 -- called to ensure that the current node has a proper Sloc set.
224 procedure Write_Condition_And_Reason (Node : Node_Id);
225 -- Write Condition and Reason codes of Raise_xxx_Error node
227 procedure Write_Corresponding_Source (S : String);
228 -- If S is a string with a single keyword (possibly followed by a space),
229 -- and if the next non-comment non-blank source line matches this keyword,
230 -- then output all source lines up to this matching line.
232 procedure Write_Discr_Specs (N : Node_Id);
233 -- Output discriminant specification for node, which is any of the type
234 -- declarations that can have discriminants.
236 procedure Write_Ekind (E : Entity_Id);
237 -- Write the String corresponding to the Ekind without "E_"
239 procedure Write_Id (N : Node_Id);
240 -- N is a node with a Chars field. This procedure writes the name that
241 -- will be used in the generated code associated with the name. For a
242 -- node with no associated entity, this is simply the Chars field. For
243 -- the case where there is an entity associated with the node, we print
244 -- the name associated with the entity (since it may have been encoded).
245 -- One other special case is that an entity has an active external name
246 -- (i.e. an external name present with no address clause), then this
247 -- external name is output. This procedure also deals with outputting
248 -- declarations of referenced itypes, if not output earlier.
250 function Write_Identifiers (Node : Node_Id) return Boolean;
251 -- Handle node where the grammar has a list of defining identifiers, but
252 -- the tree has a separate declaration for each identifier. Handles the
253 -- printing of the defining identifier, and returns True if the type and
254 -- initialization information is to be printed, False if it is to be
255 -- skipped (the latter case happens when printing defining identifiers
256 -- other than the first in the original tree output case).
258 procedure Write_Implicit_Def (E : Entity_Id);
259 pragma Warnings (Off, Write_Implicit_Def);
260 -- Write the definition of the implicit type E according to its Ekind
261 -- For now a debugging procedure, but might be used in the future.
263 procedure Write_Indent;
264 -- Start a new line and write indentation spacing
266 function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
267 -- Like Write_Identifiers except that each new printed declaration
268 -- is at the start of a new line.
270 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
271 -- Like Write_Indent_Identifiers except that in Debug_Generated_Code
272 -- mode, the Sloc of the current debug node is set to point to the
273 -- first output identifier.
275 procedure Write_Indent_Str (S : String);
276 -- Start a new line and write indent spacing followed by given string
278 procedure Write_Indent_Str_Sloc (S : String);
279 -- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
280 -- the Sloc of the current node is set to the first non-blank character
281 -- in the string S.
283 procedure Write_Itype (Typ : Entity_Id);
284 -- If Typ is an Itype that has not been written yet, write it. If Typ is
285 -- any other kind of entity or tree node, the call is ignored.
287 procedure Write_Name_With_Col_Check (N : Name_Id);
288 -- Write name (using Write_Name) with initial column check, and possible
289 -- initial Write_Indent (to get new line) if current line is too full.
291 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
292 -- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
293 -- mode, sets Sloc of current debug node to first character of name.
295 procedure Write_Operator (N : Node_Id; S : String);
296 -- Like Write_Str_Sloc, used for operators, encloses the string in
297 -- characters {} if the Do_Overflow flag is set on the node N.
299 procedure Write_Param_Specs (N : Node_Id);
300 -- Output parameter specifications for node (which is either a function
301 -- or procedure specification with a Parameter_Specifications field)
303 procedure Write_Rewrite_Str (S : String);
304 -- Writes out a string (typically containing <<< or >>>}) for a node
305 -- created by rewriting the tree. Suppressed if we are outputting the
306 -- generated code only, since in this case we don't specially mark nodes
307 -- created by rewriting).
309 procedure Write_Source_Line (L : Physical_Line_Number);
310 -- If writing of interspersed source lines is enabled, then write the given
311 -- line from the source file, preceded by Eol, then an extra blank line if
312 -- the line has at least one blank, is not a comment and is not line one,
313 -- then "--" and the line number followed by period followed by text of the
314 -- source line (without terminating Eol). If interspersed source line
315 -- output not enabled, then the call has no effect.
317 procedure Write_Source_Lines (L : Physical_Line_Number);
318 -- If writing of interspersed source lines is enabled, then writes source
319 -- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If
320 -- interspersed source line output not enabled, then call has no effect.
322 procedure Write_Str_Sloc (S : String);
323 -- Like Write_Str, but sets debug Sloc of current debug node to first
324 -- non-blank character if a current debug node is active.
326 procedure Write_Str_With_Col_Check (S : String);
327 -- Write string (using Write_Str) with initial column check, and possible
328 -- initial Write_Indent (to get new line) if current line is too full.
330 procedure Write_Str_With_Col_Check_Sloc (S : String);
331 -- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug
332 -- node to first non-blank character if a current debug node is active.
334 procedure Write_Subprogram_Name (N : Node_Id);
335 -- N is the Name field of a function call or procedure statement call.
336 -- The effect of the call is to output the name, preceded by a $ if the
337 -- call is identified as an implicit call to a run time routine.
339 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format);
340 -- Write Uint (using UI_Write) with initial column check, and possible
341 -- initial Write_Indent (to get new line) if current line is too full.
342 -- The format parameter determines the output format (see UI_Write).
344 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
345 -- Write Uint (using UI_Write) with initial column check, and possible
346 -- initial Write_Indent (to get new line) if current line is too full.
347 -- The format parameter determines the output format (see UI_Write).
348 -- In addition, in Debug_Generated_Code mode, sets the current node
349 -- Sloc to the first character of the output value.
351 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
352 -- Write Ureal (using same output format as UR_Write) with column checks
353 -- and a possible initial Write_Indent (to get new line) if current line
354 -- is too full. In addition, in Debug_Generated_Code mode, sets the
355 -- current node Sloc to the first character of the output value.
357 ---------------
358 -- Col_Check --
359 ---------------
361 procedure Col_Check (N : Nat) is
362 begin
363 if N + Column > Sprint_Line_Limit then
364 Write_Indent_Str (" ");
365 end if;
366 end Col_Check;
368 ----------------------
369 -- Extra_Blank_Line --
370 ----------------------
372 procedure Extra_Blank_Line is
373 begin
374 if not Dump_Source_Text then
375 Write_Indent;
376 end if;
377 end Extra_Blank_Line;
379 -------------------
380 -- Indent_Annull --
381 -------------------
383 procedure Indent_Annull is
384 begin
385 Indent_Annull_Flag := True;
386 end Indent_Annull;
388 ------------------
389 -- Indent_Begin --
390 ------------------
392 procedure Indent_Begin is
393 begin
394 Indent := Indent + 3;
395 end Indent_Begin;
397 ----------------
398 -- Indent_End --
399 ----------------
401 procedure Indent_End is
402 begin
403 Indent := Indent - 3;
404 end Indent_End;
406 --------
407 -- pg --
408 --------
410 procedure pg (Arg : Union_Id) is
411 begin
412 Dump_Generated_Only := True;
413 Dump_Original_Only := False;
414 Dump_Freeze_Null := True;
415 Current_Source_File := No_Source_File;
417 if Arg in List_Range then
418 Sprint_Node_List (List_Id (Arg));
420 elsif Arg in Node_Range then
421 Sprint_Node (Node_Id (Arg));
423 else
424 null;
425 end if;
427 Write_Eol;
428 end pg;
430 --------
431 -- po --
432 --------
434 procedure po (Arg : Union_Id) is
435 begin
436 Dump_Generated_Only := False;
437 Dump_Original_Only := True;
438 Current_Source_File := No_Source_File;
440 if Arg in List_Range then
441 Sprint_Node_List (List_Id (Arg));
443 elsif Arg in Node_Range then
444 Sprint_Node (Node_Id (Arg));
446 else
447 null;
448 end if;
450 Write_Eol;
451 end po;
453 ----------------------
454 -- Print_Debug_Line --
455 ----------------------
457 procedure Print_Debug_Line (S : String) is
458 begin
459 Write_Debug_Line (S, Debug_Sloc);
460 end Print_Debug_Line;
462 ---------------------------
463 -- Process_TFAI_RR_Flags --
464 ---------------------------
466 procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
467 begin
468 if Treat_Fixed_As_Integer (Nod) then
469 Write_Char ('#');
470 end if;
472 if Rounded_Result (Nod) then
473 Write_Char ('@');
474 end if;
475 end Process_TFAI_RR_Flags;
477 --------
478 -- ps --
479 --------
481 procedure ps (Arg : Union_Id) is
482 begin
483 Dump_Generated_Only := False;
484 Dump_Original_Only := False;
485 Current_Source_File := No_Source_File;
487 if Arg in List_Range then
488 Sprint_Node_List (List_Id (Arg));
490 elsif Arg in Node_Range then
491 Sprint_Node (Node_Id (Arg));
493 else
494 null;
495 end if;
497 Write_Eol;
498 end ps;
500 --------------------
501 -- Set_Debug_Sloc --
502 --------------------
504 procedure Set_Debug_Sloc is
505 begin
506 if Debug_Generated_Code and then Present (Dump_Node) then
507 Set_Sloc (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1));
508 Dump_Node := Empty;
509 end if;
510 end Set_Debug_Sloc;
512 -----------------
513 -- Source_Dump --
514 -----------------
516 procedure Source_Dump is
518 procedure Underline;
519 -- Put underline under string we just printed
521 ---------------
522 -- Underline --
523 ---------------
525 procedure Underline is
526 Col : constant Int := Column;
528 begin
529 Write_Eol;
531 while Col > Column loop
532 Write_Char ('-');
533 end loop;
535 Write_Eol;
536 end Underline;
538 -- Start of processing for Source_Dump
540 begin
541 Dump_Generated_Only := Debug_Flag_G or
542 Print_Generated_Code or
543 Debug_Generated_Code;
544 Dump_Original_Only := Debug_Flag_O;
545 Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
547 -- Note that we turn off the tree dump flags immediately, before
548 -- starting the dump. This avoids generating two copies of the dump
549 -- if an abort occurs after printing the dump, and more importantly,
550 -- avoids an infinite loop if an abort occurs during the dump.
552 if Debug_Flag_Z then
553 Current_Source_File := No_Source_File;
554 Debug_Flag_Z := False;
555 Write_Eol;
556 Write_Eol;
557 Write_Str ("Source recreated from tree of Standard (spec)");
558 Underline;
559 Sprint_Node (Standard_Package_Node);
560 Write_Eol;
561 Write_Eol;
562 end if;
564 if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
565 Debug_Flag_G := False;
566 Debug_Flag_O := False;
567 Debug_Flag_S := False;
569 -- Dump requested units
571 for U in Main_Unit .. Last_Unit loop
572 Current_Source_File := Source_Index (U);
574 -- Dump all units if -gnatdf set, otherwise we dump only
575 -- the source files that are in the extended main source.
577 if Debug_Flag_F
578 or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
579 then
580 -- If we are generating debug files, setup to write them
582 if Debug_Generated_Code then
583 Set_Special_Output (Print_Debug_Line'Access);
584 Create_Debug_Source (Source_Index (U), Debug_Sloc);
585 Write_Source_Line (1);
586 Last_Line_Printed := 1;
587 Sprint_Node (Cunit (U));
588 Write_Source_Lines (Last_Source_Line (Current_Source_File));
589 Write_Eol;
590 Close_Debug_Source;
591 Set_Special_Output (null);
593 -- Normal output to standard output file
595 else
596 Write_Str ("Source recreated from tree for ");
597 Write_Unit_Name (Unit_Name (U));
598 Underline;
599 Write_Source_Line (1);
600 Last_Line_Printed := 1;
601 Sprint_Node (Cunit (U));
602 Write_Source_Lines (Last_Source_Line (Current_Source_File));
603 Write_Eol;
604 Write_Eol;
605 end if;
606 end if;
607 end loop;
608 end if;
609 end Source_Dump;
611 ---------------------
612 -- Sprint_And_List --
613 ---------------------
615 procedure Sprint_And_List (List : List_Id) is
616 Node : Node_Id;
617 begin
618 if Is_Non_Empty_List (List) then
619 Node := First (List);
620 loop
621 Sprint_Node (Node);
622 Next (Node);
623 exit when Node = Empty;
624 Write_Str (" and ");
625 end loop;
626 end if;
627 end Sprint_And_List;
629 ----------------------------------
630 -- Sprint_Aspect_Specifications --
631 ----------------------------------
633 procedure Sprint_Aspect_Specifications (Node : Node_Id) is
634 AS : constant List_Id := Aspect_Specifications (Node);
635 A : Node_Id;
637 begin
638 Write_Erase_Char (';');
639 Indent := Indent + 2;
640 Write_Indent;
641 Write_Str ("with ");
642 Indent := Indent + 5;
644 A := First (AS);
645 loop
646 Sprint_Node (Identifier (A));
648 if Class_Present (A) then
649 Write_Str ("'Class");
650 end if;
652 if Present (Expression (A)) then
653 Write_Str (" => ");
654 Sprint_Node (Expression (A));
655 end if;
657 Next (A);
659 exit when No (A);
660 Write_Char (',');
661 Write_Indent;
662 end loop;
664 Indent := Indent - 7;
665 Write_Char (';');
666 end Sprint_Aspect_Specifications;
668 ---------------------
669 -- Sprint_Bar_List --
670 ---------------------
672 procedure Sprint_Bar_List (List : List_Id) is
673 Node : Node_Id;
674 begin
675 if Is_Non_Empty_List (List) then
676 Node := First (List);
677 loop
678 Sprint_Node (Node);
679 Next (Node);
680 exit when Node = Empty;
681 Write_Str (" | ");
682 end loop;
683 end if;
684 end Sprint_Bar_List;
686 ----------------------
687 -- Sprint_End_Label --
688 ----------------------
690 procedure Sprint_End_Label
691 (Node : Node_Id;
692 Default : Node_Id)
694 begin
695 if Present (Node)
696 and then Present (End_Label (Node))
697 and then Is_Entity_Name (End_Label (Node))
698 then
699 Set_Entity (End_Label (Node), Default);
701 -- For a function whose name is an operator, use the qualified name
702 -- created for the defining entity.
704 if Nkind (End_Label (Node)) = N_Operator_Symbol then
705 Set_Chars (End_Label (Node), Chars (Default));
706 end if;
708 Sprint_Node (End_Label (Node));
709 else
710 Sprint_Node (Default);
711 end if;
712 end Sprint_End_Label;
714 -----------------------
715 -- Sprint_Comma_List --
716 -----------------------
718 procedure Sprint_Comma_List (List : List_Id) is
719 Node : Node_Id;
721 begin
722 if Is_Non_Empty_List (List) then
723 Node := First (List);
724 loop
725 Sprint_Node (Node);
726 Next (Node);
727 exit when Node = Empty;
729 if not Is_Rewrite_Insertion (Node)
730 or else not Dump_Original_Only
731 then
732 Write_Str (", ");
733 end if;
734 end loop;
735 end if;
736 end Sprint_Comma_List;
738 --------------------------
739 -- Sprint_Indented_List --
740 --------------------------
742 procedure Sprint_Indented_List (List : List_Id) is
743 begin
744 Indent_Begin;
745 Sprint_Node_List (List);
746 Indent_End;
747 end Sprint_Indented_List;
749 ---------------------
750 -- Sprint_Left_Opnd --
751 ---------------------
753 procedure Sprint_Left_Opnd (N : Node_Id) is
754 Opnd : constant Node_Id := Left_Opnd (N);
756 begin
757 if Paren_Count (Opnd) /= 0
758 or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
759 then
760 Sprint_Node (Opnd);
762 else
763 Write_Char ('(');
764 Sprint_Node (Opnd);
765 Write_Char (')');
766 end if;
767 end Sprint_Left_Opnd;
769 -----------------
770 -- Sprint_Node --
771 -----------------
773 procedure Sprint_Node (Node : Node_Id) is
774 begin
775 if Is_Rewrite_Insertion (Node) then
776 if not Dump_Original_Only then
778 -- For special cases of nodes that always output <<< >>>
779 -- do not duplicate the output at this point.
781 if Nkind (Node) = N_Freeze_Entity
782 or else Nkind (Node) = N_Implicit_Label_Declaration
783 then
784 Sprint_Node_Actual (Node);
786 -- Normal case where <<< >>> may be required
788 else
789 Write_Rewrite_Str ("<<<");
790 Sprint_Node_Actual (Node);
791 Write_Rewrite_Str (">>>");
792 end if;
793 end if;
795 elsif Is_Rewrite_Substitution (Node) then
797 -- Case of dump generated only
799 if Dump_Generated_Only then
800 Sprint_Node_Actual (Node);
802 -- Case of dump original only
804 elsif Dump_Original_Only then
805 Sprint_Node_Actual (Original_Node (Node));
807 -- Case of both being dumped
809 else
810 Sprint_Node_Actual (Original_Node (Node));
811 Write_Rewrite_Str ("<<<");
812 Sprint_Node_Actual (Node);
813 Write_Rewrite_Str (">>>");
814 end if;
816 else
817 Sprint_Node_Actual (Node);
818 end if;
819 end Sprint_Node;
821 ------------------------
822 -- Sprint_Node_Actual --
823 ------------------------
825 procedure Sprint_Node_Actual (Node : Node_Id) is
826 Save_Dump_Node : constant Node_Id := Dump_Node;
828 begin
829 if Node = Empty then
830 return;
831 end if;
833 for J in 1 .. Paren_Count (Node) loop
834 Write_Str_With_Col_Check ("(");
835 end loop;
837 -- Setup current dump node
839 Dump_Node := Node;
841 if Nkind (Node) in N_Subexpr
842 and then Do_Range_Check (Node)
843 then
844 Write_Str_With_Col_Check ("{");
845 end if;
847 -- Select print circuit based on node kind
849 case Nkind (Node) is
850 when N_Abort_Statement =>
851 Write_Indent_Str_Sloc ("abort ");
852 Sprint_Comma_List (Names (Node));
853 Write_Char (';');
855 when N_Abortable_Part =>
856 Set_Debug_Sloc;
857 Write_Str_Sloc ("abort ");
858 Sprint_Indented_List (Statements (Node));
860 when N_Abstract_Subprogram_Declaration =>
861 Write_Indent;
862 Sprint_Node (Specification (Node));
863 Write_Str_With_Col_Check (" is ");
864 Write_Str_Sloc ("abstract;");
866 when N_Accept_Alternative =>
867 Sprint_Node_List (Pragmas_Before (Node));
869 if Present (Condition (Node)) then
870 Write_Indent_Str ("when ");
871 Sprint_Node (Condition (Node));
872 Write_Str (" => ");
873 Indent_Annull;
874 end if;
876 Sprint_Node_Sloc (Accept_Statement (Node));
877 Sprint_Node_List (Statements (Node));
879 when N_Accept_Statement =>
880 Write_Indent_Str_Sloc ("accept ");
881 Write_Id (Entry_Direct_Name (Node));
883 if Present (Entry_Index (Node)) then
884 Write_Str_With_Col_Check (" (");
885 Sprint_Node (Entry_Index (Node));
886 Write_Char (')');
887 end if;
889 Write_Param_Specs (Node);
891 if Present (Handled_Statement_Sequence (Node)) then
892 Write_Str_With_Col_Check (" do");
893 Sprint_Node (Handled_Statement_Sequence (Node));
894 Write_Indent_Str ("end ");
895 Write_Id (Entry_Direct_Name (Node));
896 end if;
898 Write_Char (';');
900 when N_Access_Definition =>
902 -- Ada 2005 (AI-254)
904 if Present (Access_To_Subprogram_Definition (Node)) then
905 Sprint_Node (Access_To_Subprogram_Definition (Node));
906 else
907 -- Ada 2005 (AI-231)
909 if Null_Exclusion_Present (Node) then
910 Write_Str ("not null ");
911 end if;
913 Write_Str_With_Col_Check_Sloc ("access ");
915 if All_Present (Node) then
916 Write_Str ("all ");
917 elsif Constant_Present (Node) then
918 Write_Str ("constant ");
919 end if;
921 Sprint_Node (Subtype_Mark (Node));
922 end if;
924 when N_Access_Function_Definition =>
926 -- Ada 2005 (AI-231)
928 if Null_Exclusion_Present (Node) then
929 Write_Str ("not null ");
930 end if;
932 Write_Str_With_Col_Check_Sloc ("access ");
934 if Protected_Present (Node) then
935 Write_Str_With_Col_Check ("protected ");
936 end if;
938 Write_Str_With_Col_Check ("function");
939 Write_Param_Specs (Node);
940 Write_Str_With_Col_Check (" return ");
941 Sprint_Node (Result_Definition (Node));
943 when N_Access_Procedure_Definition =>
945 -- Ada 2005 (AI-231)
947 if Null_Exclusion_Present (Node) then
948 Write_Str ("not null ");
949 end if;
951 Write_Str_With_Col_Check_Sloc ("access ");
953 if Protected_Present (Node) then
954 Write_Str_With_Col_Check ("protected ");
955 end if;
957 Write_Str_With_Col_Check ("procedure");
958 Write_Param_Specs (Node);
960 when N_Access_To_Object_Definition =>
961 Write_Str_With_Col_Check_Sloc ("access ");
963 if All_Present (Node) then
964 Write_Str_With_Col_Check ("all ");
965 elsif Constant_Present (Node) then
966 Write_Str_With_Col_Check ("constant ");
967 end if;
969 -- Ada 2005 (AI-231)
971 if Null_Exclusion_Present (Node) then
972 Write_Str ("not null ");
973 end if;
975 Sprint_Node (Subtype_Indication (Node));
977 when N_Aggregate =>
978 if Null_Record_Present (Node) then
979 Write_Str_With_Col_Check_Sloc ("(null record)");
981 else
982 Write_Str_With_Col_Check_Sloc ("(");
984 if Present (Expressions (Node)) then
985 Sprint_Comma_List (Expressions (Node));
987 if Present (Component_Associations (Node))
988 and then not Is_Empty_List (Component_Associations (Node))
989 then
990 Write_Str (", ");
991 end if;
992 end if;
994 if Present (Component_Associations (Node))
995 and then not Is_Empty_List (Component_Associations (Node))
996 then
997 Indent_Begin;
999 declare
1000 Nd : Node_Id;
1002 begin
1003 Nd := First (Component_Associations (Node));
1005 loop
1006 Write_Indent;
1007 Sprint_Node (Nd);
1008 Next (Nd);
1009 exit when No (Nd);
1011 if not Is_Rewrite_Insertion (Nd)
1012 or else not Dump_Original_Only
1013 then
1014 Write_Str (", ");
1015 end if;
1016 end loop;
1017 end;
1019 Indent_End;
1020 end if;
1022 Write_Char (')');
1023 end if;
1025 when N_Allocator =>
1026 Write_Str_With_Col_Check_Sloc ("new ");
1028 -- Ada 2005 (AI-231)
1030 if Null_Exclusion_Present (Node) then
1031 Write_Str ("not null ");
1032 end if;
1034 Sprint_Node (Expression (Node));
1036 if Present (Storage_Pool (Node)) then
1037 Write_Str_With_Col_Check ("[storage_pool = ");
1038 Sprint_Node (Storage_Pool (Node));
1039 Write_Char (']');
1040 end if;
1042 when N_And_Then =>
1043 Sprint_Left_Opnd (Node);
1044 Write_Str_Sloc (" and then ");
1045 Sprint_Right_Opnd (Node);
1047 when N_Aspect_Specification =>
1048 raise Program_Error;
1050 when N_Assignment_Statement =>
1051 Write_Indent;
1052 Sprint_Node (Name (Node));
1053 Write_Str_Sloc (" := ");
1054 Sprint_Node (Expression (Node));
1055 Write_Char (';');
1057 when N_Asynchronous_Select =>
1058 Write_Indent_Str_Sloc ("select");
1059 Indent_Begin;
1060 Sprint_Node (Triggering_Alternative (Node));
1061 Indent_End;
1063 -- Note: let the printing of Abortable_Part handle outputting
1064 -- the ABORT keyword, so that the Sloc can be set correctly.
1066 Write_Indent_Str ("then ");
1067 Sprint_Node (Abortable_Part (Node));
1068 Write_Indent_Str ("end select;");
1070 when N_At_Clause =>
1071 Write_Indent_Str_Sloc ("for ");
1072 Write_Id (Identifier (Node));
1073 Write_Str_With_Col_Check (" use at ");
1074 Sprint_Node (Expression (Node));
1075 Write_Char (';');
1077 when N_Attribute_Definition_Clause =>
1078 Write_Indent_Str_Sloc ("for ");
1079 Sprint_Node (Name (Node));
1080 Write_Char (''');
1081 Write_Name_With_Col_Check (Chars (Node));
1082 Write_Str_With_Col_Check (" use ");
1083 Sprint_Node (Expression (Node));
1084 Write_Char (';');
1086 when N_Attribute_Reference =>
1087 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1088 Write_Indent;
1089 end if;
1091 Sprint_Node (Prefix (Node));
1092 Write_Char_Sloc (''');
1093 Write_Name_With_Col_Check (Attribute_Name (Node));
1094 Sprint_Paren_Comma_List (Expressions (Node));
1096 if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
1097 Write_Char (';');
1098 end if;
1100 when N_Block_Statement =>
1101 Write_Indent;
1103 if Present (Identifier (Node))
1104 and then (not Has_Created_Identifier (Node)
1105 or else not Dump_Original_Only)
1106 then
1107 Write_Rewrite_Str ("<<<");
1108 Write_Id (Identifier (Node));
1109 Write_Str (" : ");
1110 Write_Rewrite_Str (">>>");
1111 end if;
1113 if Present (Declarations (Node)) then
1114 Write_Str_With_Col_Check_Sloc ("declare");
1115 Sprint_Indented_List (Declarations (Node));
1116 Write_Indent;
1117 end if;
1119 Write_Str_With_Col_Check_Sloc ("begin");
1120 Sprint_Node (Handled_Statement_Sequence (Node));
1121 Write_Indent_Str ("end");
1123 if Present (Identifier (Node))
1124 and then (not Has_Created_Identifier (Node)
1125 or else not Dump_Original_Only)
1126 then
1127 Write_Rewrite_Str ("<<<");
1128 Write_Char (' ');
1129 Write_Id (Identifier (Node));
1130 Write_Rewrite_Str (">>>");
1131 end if;
1133 Write_Char (';');
1135 when N_Case_Expression =>
1136 declare
1137 Alt : Node_Id;
1139 begin
1140 Write_Str_With_Col_Check_Sloc ("(case ");
1141 Sprint_Node (Expression (Node));
1142 Write_Str_With_Col_Check (" is");
1144 Alt := First (Alternatives (Node));
1145 loop
1146 Sprint_Node (Alt);
1147 Next (Alt);
1148 exit when No (Alt);
1149 Write_Char (',');
1150 end loop;
1152 Write_Char (')');
1153 end;
1155 when N_Case_Expression_Alternative =>
1156 Write_Str_With_Col_Check (" when ");
1157 Sprint_Bar_List (Discrete_Choices (Node));
1158 Write_Str (" => ");
1159 Sprint_Node (Expression (Node));
1161 when N_Case_Statement =>
1162 Write_Indent_Str_Sloc ("case ");
1163 Sprint_Node (Expression (Node));
1164 Write_Str (" is");
1165 Sprint_Indented_List (Alternatives (Node));
1166 Write_Indent_Str ("end case;");
1168 when N_Case_Statement_Alternative =>
1169 Write_Indent_Str_Sloc ("when ");
1170 Sprint_Bar_List (Discrete_Choices (Node));
1171 Write_Str (" => ");
1172 Sprint_Indented_List (Statements (Node));
1174 when N_Character_Literal =>
1175 if Column > Sprint_Line_Limit - 2 then
1176 Write_Indent_Str (" ");
1177 end if;
1179 Write_Char_Sloc (''');
1180 Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
1181 Write_Char (''');
1183 when N_Code_Statement =>
1184 Write_Indent;
1185 Set_Debug_Sloc;
1186 Sprint_Node (Expression (Node));
1187 Write_Char (';');
1189 when N_Compilation_Unit =>
1190 Sprint_Node_List (Context_Items (Node));
1191 Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
1193 if Private_Present (Node) then
1194 Write_Indent_Str ("private ");
1195 Indent_Annull;
1196 end if;
1198 Sprint_Node_Sloc (Unit (Node));
1200 if Present (Actions (Aux_Decls_Node (Node)))
1201 or else
1202 Present (Pragmas_After (Aux_Decls_Node (Node)))
1203 then
1204 Write_Indent;
1205 end if;
1207 Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
1208 Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
1210 when N_Compilation_Unit_Aux =>
1211 null; -- nothing to do, never used, see above
1213 when N_Component_Association =>
1214 Set_Debug_Sloc;
1215 Sprint_Bar_List (Choices (Node));
1216 Write_Str (" => ");
1218 -- Ada 2005 (AI-287): Print the box if present
1220 if Box_Present (Node) then
1221 Write_Str_With_Col_Check ("<>");
1222 else
1223 Sprint_Node (Expression (Node));
1224 end if;
1226 when N_Component_Clause =>
1227 Write_Indent;
1228 Sprint_Node (Component_Name (Node));
1229 Write_Str_Sloc (" at ");
1230 Sprint_Node (Position (Node));
1231 Write_Char (' ');
1232 Write_Str_With_Col_Check ("range ");
1233 Sprint_Node (First_Bit (Node));
1234 Write_Str (" .. ");
1235 Sprint_Node (Last_Bit (Node));
1236 Write_Char (';');
1238 when N_Component_Definition =>
1239 Set_Debug_Sloc;
1241 -- Ada 2005 (AI-230): Access definition components
1243 if Present (Access_Definition (Node)) then
1244 Sprint_Node (Access_Definition (Node));
1246 elsif Present (Subtype_Indication (Node)) then
1247 if Aliased_Present (Node) then
1248 Write_Str_With_Col_Check ("aliased ");
1249 end if;
1251 -- Ada 2005 (AI-231)
1253 if Null_Exclusion_Present (Node) then
1254 Write_Str (" not null ");
1255 end if;
1257 Sprint_Node (Subtype_Indication (Node));
1259 else
1260 Write_Str (" ??? ");
1261 end if;
1263 when N_Component_Declaration =>
1264 if Write_Indent_Identifiers_Sloc (Node) then
1265 Write_Str (" : ");
1266 Sprint_Node (Component_Definition (Node));
1268 if Present (Expression (Node)) then
1269 Write_Str (" := ");
1270 Sprint_Node (Expression (Node));
1271 end if;
1273 Write_Char (';');
1274 end if;
1276 when N_Component_List =>
1277 if Null_Present (Node) then
1278 Indent_Begin;
1279 Write_Indent_Str_Sloc ("null");
1280 Write_Char (';');
1281 Indent_End;
1283 else
1284 Set_Debug_Sloc;
1285 Sprint_Indented_List (Component_Items (Node));
1286 Sprint_Node (Variant_Part (Node));
1287 end if;
1289 when N_Conditional_Entry_Call =>
1290 Write_Indent_Str_Sloc ("select");
1291 Indent_Begin;
1292 Sprint_Node (Entry_Call_Alternative (Node));
1293 Indent_End;
1294 Write_Indent_Str ("else");
1295 Sprint_Indented_List (Else_Statements (Node));
1296 Write_Indent_Str ("end select;");
1298 when N_Conditional_Expression =>
1299 declare
1300 Condition : constant Node_Id := First (Expressions (Node));
1301 Then_Expr : constant Node_Id := Next (Condition);
1303 begin
1304 Write_Str_With_Col_Check_Sloc ("(if ");
1305 Sprint_Node (Condition);
1306 Write_Str_With_Col_Check (" then ");
1308 -- Defense against junk here!
1310 if Present (Then_Expr) then
1311 Sprint_Node (Then_Expr);
1312 Write_Str_With_Col_Check (" else ");
1313 Sprint_Node (Next (Then_Expr));
1314 end if;
1316 Write_Char (')');
1317 end;
1319 when N_Constrained_Array_Definition =>
1320 Write_Str_With_Col_Check_Sloc ("array ");
1321 Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1322 Write_Str (" of ");
1324 Sprint_Node (Component_Definition (Node));
1326 when N_Decimal_Fixed_Point_Definition =>
1327 Write_Str_With_Col_Check_Sloc (" delta ");
1328 Sprint_Node (Delta_Expression (Node));
1329 Write_Str_With_Col_Check ("digits ");
1330 Sprint_Node (Digits_Expression (Node));
1331 Sprint_Opt_Node (Real_Range_Specification (Node));
1333 when N_Defining_Character_Literal =>
1334 Write_Name_With_Col_Check_Sloc (Chars (Node));
1336 when N_Defining_Identifier =>
1337 Set_Debug_Sloc;
1338 Write_Id (Node);
1340 when N_Defining_Operator_Symbol =>
1341 Write_Name_With_Col_Check_Sloc (Chars (Node));
1343 when N_Defining_Program_Unit_Name =>
1344 Set_Debug_Sloc;
1345 Sprint_Node (Name (Node));
1346 Write_Char ('.');
1347 Write_Id (Defining_Identifier (Node));
1349 when N_Delay_Alternative =>
1350 Sprint_Node_List (Pragmas_Before (Node));
1352 if Present (Condition (Node)) then
1353 Write_Indent;
1354 Write_Str_With_Col_Check ("when ");
1355 Sprint_Node (Condition (Node));
1356 Write_Str (" => ");
1357 Indent_Annull;
1358 end if;
1360 Sprint_Node_Sloc (Delay_Statement (Node));
1361 Sprint_Node_List (Statements (Node));
1363 when N_Delay_Relative_Statement =>
1364 Write_Indent_Str_Sloc ("delay ");
1365 Sprint_Node (Expression (Node));
1366 Write_Char (';');
1368 when N_Delay_Until_Statement =>
1369 Write_Indent_Str_Sloc ("delay until ");
1370 Sprint_Node (Expression (Node));
1371 Write_Char (';');
1373 when N_Delta_Constraint =>
1374 Write_Str_With_Col_Check_Sloc ("delta ");
1375 Sprint_Node (Delta_Expression (Node));
1376 Sprint_Opt_Node (Range_Constraint (Node));
1378 when N_Derived_Type_Definition =>
1379 if Abstract_Present (Node) then
1380 Write_Str_With_Col_Check ("abstract ");
1381 end if;
1383 Write_Str_With_Col_Check ("new ");
1385 -- Ada 2005 (AI-231)
1387 if Null_Exclusion_Present (Node) then
1388 Write_Str_With_Col_Check ("not null ");
1389 end if;
1391 Sprint_Node (Subtype_Indication (Node));
1393 if Present (Interface_List (Node)) then
1394 Write_Str_With_Col_Check (" and ");
1395 Sprint_And_List (Interface_List (Node));
1396 Write_Str_With_Col_Check (" with ");
1397 end if;
1399 if Present (Record_Extension_Part (Node)) then
1400 if No (Interface_List (Node)) then
1401 Write_Str_With_Col_Check (" with ");
1402 end if;
1404 Sprint_Node (Record_Extension_Part (Node));
1405 end if;
1407 when N_Designator =>
1408 Sprint_Node (Name (Node));
1409 Write_Char_Sloc ('.');
1410 Write_Id (Identifier (Node));
1412 when N_Digits_Constraint =>
1413 Write_Str_With_Col_Check_Sloc ("digits ");
1414 Sprint_Node (Digits_Expression (Node));
1415 Sprint_Opt_Node (Range_Constraint (Node));
1417 when N_Discriminant_Association =>
1418 Set_Debug_Sloc;
1420 if Present (Selector_Names (Node)) then
1421 Sprint_Bar_List (Selector_Names (Node));
1422 Write_Str (" => ");
1423 end if;
1425 Set_Debug_Sloc;
1426 Sprint_Node (Expression (Node));
1428 when N_Discriminant_Specification =>
1429 Set_Debug_Sloc;
1431 if Write_Identifiers (Node) then
1432 Write_Str (" : ");
1434 if Null_Exclusion_Present (Node) then
1435 Write_Str ("not null ");
1436 end if;
1438 Sprint_Node (Discriminant_Type (Node));
1440 if Present (Expression (Node)) then
1441 Write_Str (" := ");
1442 Sprint_Node (Expression (Node));
1443 end if;
1444 else
1445 Write_Str (", ");
1446 end if;
1448 when N_Elsif_Part =>
1449 Write_Indent_Str_Sloc ("elsif ");
1450 Sprint_Node (Condition (Node));
1451 Write_Str_With_Col_Check (" then");
1452 Sprint_Indented_List (Then_Statements (Node));
1454 when N_Empty =>
1455 null;
1457 when N_Entry_Body =>
1458 Write_Indent_Str_Sloc ("entry ");
1459 Write_Id (Defining_Identifier (Node));
1460 Sprint_Node (Entry_Body_Formal_Part (Node));
1461 Write_Str_With_Col_Check (" is");
1462 Sprint_Indented_List (Declarations (Node));
1463 Write_Indent_Str ("begin");
1464 Sprint_Node (Handled_Statement_Sequence (Node));
1465 Write_Indent_Str ("end ");
1466 Write_Id (Defining_Identifier (Node));
1467 Write_Char (';');
1469 when N_Entry_Body_Formal_Part =>
1470 if Present (Entry_Index_Specification (Node)) then
1471 Write_Str_With_Col_Check_Sloc (" (");
1472 Sprint_Node (Entry_Index_Specification (Node));
1473 Write_Char (')');
1474 end if;
1476 Write_Param_Specs (Node);
1477 Write_Str_With_Col_Check_Sloc (" when ");
1478 Sprint_Node (Condition (Node));
1480 when N_Entry_Call_Alternative =>
1481 Sprint_Node_List (Pragmas_Before (Node));
1482 Sprint_Node_Sloc (Entry_Call_Statement (Node));
1483 Sprint_Node_List (Statements (Node));
1485 when N_Entry_Call_Statement =>
1486 Write_Indent;
1487 Sprint_Node_Sloc (Name (Node));
1488 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1489 Write_Char (';');
1491 when N_Entry_Declaration =>
1492 Write_Indent_Str_Sloc ("entry ");
1493 Write_Id (Defining_Identifier (Node));
1495 if Present (Discrete_Subtype_Definition (Node)) then
1496 Write_Str_With_Col_Check (" (");
1497 Sprint_Node (Discrete_Subtype_Definition (Node));
1498 Write_Char (')');
1499 end if;
1501 Write_Param_Specs (Node);
1502 Write_Char (';');
1504 when N_Entry_Index_Specification =>
1505 Write_Str_With_Col_Check_Sloc ("for ");
1506 Write_Id (Defining_Identifier (Node));
1507 Write_Str_With_Col_Check (" in ");
1508 Sprint_Node (Discrete_Subtype_Definition (Node));
1510 when N_Enumeration_Representation_Clause =>
1511 Write_Indent_Str_Sloc ("for ");
1512 Write_Id (Identifier (Node));
1513 Write_Str_With_Col_Check (" use ");
1514 Sprint_Node (Array_Aggregate (Node));
1515 Write_Char (';');
1517 when N_Enumeration_Type_Definition =>
1518 Set_Debug_Sloc;
1520 -- Skip attempt to print Literals field if it's not there and
1521 -- we are in package Standard (case of Character, which is
1522 -- handled specially (without an explicit literals list).
1524 if Sloc (Node) > Standard_Location
1525 or else Present (Literals (Node))
1526 then
1527 Sprint_Paren_Comma_List (Literals (Node));
1528 end if;
1530 when N_Error =>
1531 Write_Str_With_Col_Check_Sloc ("<error>");
1533 when N_Exception_Declaration =>
1534 if Write_Indent_Identifiers (Node) then
1535 Write_Str_With_Col_Check (" : ");
1537 if Is_Statically_Allocated (Defining_Identifier (Node)) then
1538 Write_Str_With_Col_Check ("static ");
1539 end if;
1541 Write_Str_Sloc ("exception");
1543 if Present (Expression (Node)) then
1544 Write_Str (" := ");
1545 Sprint_Node (Expression (Node));
1546 end if;
1548 Write_Char (';');
1549 end if;
1551 when N_Exception_Handler =>
1552 Write_Indent_Str_Sloc ("when ");
1554 if Present (Choice_Parameter (Node)) then
1555 Sprint_Node (Choice_Parameter (Node));
1556 Write_Str (" : ");
1557 end if;
1559 Sprint_Bar_List (Exception_Choices (Node));
1560 Write_Str (" => ");
1561 Sprint_Indented_List (Statements (Node));
1563 when N_Exception_Renaming_Declaration =>
1564 Write_Indent;
1565 Set_Debug_Sloc;
1566 Sprint_Node (Defining_Identifier (Node));
1567 Write_Str_With_Col_Check (" : exception renames ");
1568 Sprint_Node (Name (Node));
1569 Write_Char (';');
1571 when N_Exit_Statement =>
1572 Write_Indent_Str_Sloc ("exit");
1573 Sprint_Opt_Node (Name (Node));
1575 if Present (Condition (Node)) then
1576 Write_Str_With_Col_Check (" when ");
1577 Sprint_Node (Condition (Node));
1578 end if;
1580 Write_Char (';');
1582 when N_Expanded_Name =>
1583 Sprint_Node (Prefix (Node));
1584 Write_Char_Sloc ('.');
1585 Sprint_Node (Selector_Name (Node));
1587 when N_Explicit_Dereference =>
1588 Sprint_Node (Prefix (Node));
1589 Write_Char_Sloc ('.');
1590 Write_Str_Sloc ("all");
1592 when N_Expression_With_Actions =>
1593 Indent_Begin;
1594 Write_Indent_Str_Sloc ("do ");
1595 Indent_Begin;
1596 Sprint_Node_List (Actions (Node));
1597 Indent_End;
1598 Write_Indent;
1599 Write_Str_With_Col_Check_Sloc ("in ");
1600 Sprint_Node (Expression (Node));
1601 Write_Str_With_Col_Check (" end");
1602 Indent_End;
1603 Write_Indent;
1605 when N_Extended_Return_Statement =>
1606 Write_Indent_Str_Sloc ("return ");
1607 Sprint_Node_List (Return_Object_Declarations (Node));
1609 if Present (Handled_Statement_Sequence (Node)) then
1610 Write_Str_With_Col_Check (" do");
1611 Sprint_Node (Handled_Statement_Sequence (Node));
1612 Write_Indent_Str ("end return;");
1613 else
1614 Write_Indent_Str (";");
1615 end if;
1617 when N_Extension_Aggregate =>
1618 Write_Str_With_Col_Check_Sloc ("(");
1619 Sprint_Node (Ancestor_Part (Node));
1620 Write_Str_With_Col_Check (" with ");
1622 if Null_Record_Present (Node) then
1623 Write_Str_With_Col_Check ("null record");
1624 else
1625 if Present (Expressions (Node)) then
1626 Sprint_Comma_List (Expressions (Node));
1628 if Present (Component_Associations (Node)) then
1629 Write_Str (", ");
1630 end if;
1631 end if;
1633 if Present (Component_Associations (Node)) then
1634 Sprint_Comma_List (Component_Associations (Node));
1635 end if;
1636 end if;
1638 Write_Char (')');
1640 when N_Floating_Point_Definition =>
1641 Write_Str_With_Col_Check_Sloc ("digits ");
1642 Sprint_Node (Digits_Expression (Node));
1643 Sprint_Opt_Node (Real_Range_Specification (Node));
1645 when N_Formal_Decimal_Fixed_Point_Definition =>
1646 Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1648 when N_Formal_Derived_Type_Definition =>
1649 Write_Str_With_Col_Check_Sloc ("new ");
1650 Sprint_Node (Subtype_Mark (Node));
1652 if Present (Interface_List (Node)) then
1653 Write_Str_With_Col_Check (" and ");
1654 Sprint_And_List (Interface_List (Node));
1655 end if;
1657 if Private_Present (Node) then
1658 Write_Str_With_Col_Check (" with private");
1659 end if;
1661 when N_Formal_Abstract_Subprogram_Declaration =>
1662 Write_Indent_Str_Sloc ("with ");
1663 Sprint_Node (Specification (Node));
1665 Write_Str_With_Col_Check (" is abstract");
1667 if Box_Present (Node) then
1668 Write_Str_With_Col_Check (" <>");
1669 elsif Present (Default_Name (Node)) then
1670 Write_Str_With_Col_Check (" ");
1671 Sprint_Node (Default_Name (Node));
1672 end if;
1674 Write_Char (';');
1676 when N_Formal_Concrete_Subprogram_Declaration =>
1677 Write_Indent_Str_Sloc ("with ");
1678 Sprint_Node (Specification (Node));
1680 if Box_Present (Node) then
1681 Write_Str_With_Col_Check (" is <>");
1682 elsif Present (Default_Name (Node)) then
1683 Write_Str_With_Col_Check (" is ");
1684 Sprint_Node (Default_Name (Node));
1685 end if;
1687 Write_Char (';');
1689 when N_Formal_Discrete_Type_Definition =>
1690 Write_Str_With_Col_Check_Sloc ("<>");
1692 when N_Formal_Floating_Point_Definition =>
1693 Write_Str_With_Col_Check_Sloc ("digits <>");
1695 when N_Formal_Modular_Type_Definition =>
1696 Write_Str_With_Col_Check_Sloc ("mod <>");
1698 when N_Formal_Object_Declaration =>
1699 Set_Debug_Sloc;
1701 if Write_Indent_Identifiers (Node) then
1702 Write_Str (" : ");
1704 if In_Present (Node) then
1705 Write_Str_With_Col_Check ("in ");
1706 end if;
1708 if Out_Present (Node) then
1709 Write_Str_With_Col_Check ("out ");
1710 end if;
1712 if Present (Subtype_Mark (Node)) then
1714 -- Ada 2005 (AI-423): Formal object with null exclusion
1716 if Null_Exclusion_Present (Node) then
1717 Write_Str ("not null ");
1718 end if;
1720 Sprint_Node (Subtype_Mark (Node));
1722 -- Ada 2005 (AI-423): Formal object with access definition
1724 else
1725 pragma Assert (Present (Access_Definition (Node)));
1727 Sprint_Node (Access_Definition (Node));
1728 end if;
1730 if Present (Default_Expression (Node)) then
1731 Write_Str (" := ");
1732 Sprint_Node (Default_Expression (Node));
1733 end if;
1735 Write_Char (';');
1736 end if;
1738 when N_Formal_Ordinary_Fixed_Point_Definition =>
1739 Write_Str_With_Col_Check_Sloc ("delta <>");
1741 when N_Formal_Package_Declaration =>
1742 Write_Indent_Str_Sloc ("with package ");
1743 Write_Id (Defining_Identifier (Node));
1744 Write_Str_With_Col_Check (" is new ");
1745 Sprint_Node (Name (Node));
1746 Write_Str_With_Col_Check (" (<>);");
1748 when N_Formal_Private_Type_Definition =>
1749 if Abstract_Present (Node) then
1750 Write_Str_With_Col_Check ("abstract ");
1751 end if;
1753 if Tagged_Present (Node) then
1754 Write_Str_With_Col_Check ("tagged ");
1755 end if;
1757 if Limited_Present (Node) then
1758 Write_Str_With_Col_Check ("limited ");
1759 end if;
1761 Write_Str_With_Col_Check_Sloc ("private");
1763 when N_Formal_Signed_Integer_Type_Definition =>
1764 Write_Str_With_Col_Check_Sloc ("range <>");
1766 when N_Formal_Type_Declaration =>
1767 Write_Indent_Str_Sloc ("type ");
1768 Write_Id (Defining_Identifier (Node));
1770 if Present (Discriminant_Specifications (Node)) then
1771 Write_Discr_Specs (Node);
1772 elsif Unknown_Discriminants_Present (Node) then
1773 Write_Str_With_Col_Check ("(<>)");
1774 end if;
1776 Write_Str_With_Col_Check (" is ");
1777 Sprint_Node (Formal_Type_Definition (Node));
1778 Write_Char (';');
1780 when N_Free_Statement =>
1781 Write_Indent_Str_Sloc ("free ");
1782 Sprint_Node (Expression (Node));
1783 Write_Char (';');
1785 when N_Freeze_Entity =>
1786 if Dump_Original_Only then
1787 null;
1789 elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1790 Write_Indent;
1791 Write_Rewrite_Str ("<<<");
1792 Write_Str_With_Col_Check_Sloc ("freeze ");
1793 Write_Id (Entity (Node));
1794 Write_Str (" [");
1796 if No (Actions (Node)) then
1797 Write_Char (']');
1799 else
1800 -- Output freeze actions. We increment Freeze_Indent during
1801 -- this output to avoid generating extra blank lines before
1802 -- any procedures included in the freeze actions.
1804 Freeze_Indent := Freeze_Indent + 1;
1805 Sprint_Indented_List (Actions (Node));
1806 Freeze_Indent := Freeze_Indent - 1;
1807 Write_Indent_Str ("]");
1808 end if;
1810 Write_Rewrite_Str (">>>");
1811 end if;
1813 when N_Full_Type_Declaration =>
1814 Write_Indent_Str_Sloc ("type ");
1815 Sprint_Node (Defining_Identifier (Node));
1816 Write_Discr_Specs (Node);
1817 Write_Str_With_Col_Check (" is ");
1818 Sprint_Node (Type_Definition (Node));
1819 Write_Char (';');
1821 when N_Function_Call =>
1822 Set_Debug_Sloc;
1823 Write_Subprogram_Name (Name (Node));
1824 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1826 when N_Function_Instantiation =>
1827 Write_Indent_Str_Sloc ("function ");
1828 Sprint_Node (Defining_Unit_Name (Node));
1829 Write_Str_With_Col_Check (" is new ");
1830 Sprint_Node (Name (Node));
1831 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1832 Write_Char (';');
1834 when N_Function_Specification =>
1835 Write_Str_With_Col_Check_Sloc ("function ");
1836 Sprint_Node (Defining_Unit_Name (Node));
1837 Write_Param_Specs (Node);
1838 Write_Str_With_Col_Check (" return ");
1840 -- Ada 2005 (AI-231)
1842 if Nkind (Result_Definition (Node)) /= N_Access_Definition
1843 and then Null_Exclusion_Present (Node)
1844 then
1845 Write_Str (" not null ");
1846 end if;
1848 Sprint_Node (Result_Definition (Node));
1850 when N_Generic_Association =>
1851 Set_Debug_Sloc;
1853 if Present (Selector_Name (Node)) then
1854 Sprint_Node (Selector_Name (Node));
1855 Write_Str (" => ");
1856 end if;
1858 Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1860 when N_Generic_Function_Renaming_Declaration =>
1861 Write_Indent_Str_Sloc ("generic function ");
1862 Sprint_Node (Defining_Unit_Name (Node));
1863 Write_Str_With_Col_Check (" renames ");
1864 Sprint_Node (Name (Node));
1865 Write_Char (';');
1867 when N_Generic_Package_Declaration =>
1868 Extra_Blank_Line;
1869 Write_Indent_Str_Sloc ("generic ");
1870 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1871 Write_Indent;
1872 Sprint_Node (Specification (Node));
1873 Write_Char (';');
1875 when N_Generic_Package_Renaming_Declaration =>
1876 Write_Indent_Str_Sloc ("generic package ");
1877 Sprint_Node (Defining_Unit_Name (Node));
1878 Write_Str_With_Col_Check (" renames ");
1879 Sprint_Node (Name (Node));
1880 Write_Char (';');
1882 when N_Generic_Procedure_Renaming_Declaration =>
1883 Write_Indent_Str_Sloc ("generic procedure ");
1884 Sprint_Node (Defining_Unit_Name (Node));
1885 Write_Str_With_Col_Check (" renames ");
1886 Sprint_Node (Name (Node));
1887 Write_Char (';');
1889 when N_Generic_Subprogram_Declaration =>
1890 Extra_Blank_Line;
1891 Write_Indent_Str_Sloc ("generic ");
1892 Sprint_Indented_List (Generic_Formal_Declarations (Node));
1893 Write_Indent;
1894 Sprint_Node (Specification (Node));
1895 Write_Char (';');
1897 when N_Goto_Statement =>
1898 Write_Indent_Str_Sloc ("goto ");
1899 Sprint_Node (Name (Node));
1900 Write_Char (';');
1902 if Nkind (Next (Node)) = N_Label then
1903 Write_Indent;
1904 end if;
1906 when N_Handled_Sequence_Of_Statements =>
1907 Set_Debug_Sloc;
1908 Sprint_Indented_List (Statements (Node));
1910 if Present (Exception_Handlers (Node)) then
1911 Write_Indent_Str ("exception");
1912 Indent_Begin;
1913 Sprint_Node_List (Exception_Handlers (Node));
1914 Indent_End;
1915 end if;
1917 if Present (At_End_Proc (Node)) then
1918 Write_Indent_Str ("at end");
1919 Indent_Begin;
1920 Write_Indent;
1921 Sprint_Node (At_End_Proc (Node));
1922 Write_Char (';');
1923 Indent_End;
1924 end if;
1926 when N_Identifier =>
1927 Set_Debug_Sloc;
1928 Write_Id (Node);
1930 when N_If_Statement =>
1931 Write_Indent_Str_Sloc ("if ");
1932 Sprint_Node (Condition (Node));
1933 Write_Str_With_Col_Check (" then");
1934 Sprint_Indented_List (Then_Statements (Node));
1935 Sprint_Opt_Node_List (Elsif_Parts (Node));
1937 if Present (Else_Statements (Node)) then
1938 Write_Indent_Str ("else");
1939 Sprint_Indented_List (Else_Statements (Node));
1940 end if;
1942 Write_Indent_Str ("end if;");
1944 when N_Implicit_Label_Declaration =>
1945 if not Dump_Original_Only then
1946 Write_Indent;
1947 Write_Rewrite_Str ("<<<");
1948 Set_Debug_Sloc;
1949 Write_Id (Defining_Identifier (Node));
1950 Write_Str (" : ");
1951 Write_Str_With_Col_Check ("label");
1952 Write_Rewrite_Str (">>>");
1953 end if;
1955 when N_In =>
1956 Sprint_Left_Opnd (Node);
1957 Write_Str_Sloc (" in ");
1959 if Present (Right_Opnd (Node)) then
1960 Sprint_Right_Opnd (Node);
1961 else
1962 Sprint_Bar_List (Alternatives (Node));
1963 end if;
1965 when N_Incomplete_Type_Declaration =>
1966 Write_Indent_Str_Sloc ("type ");
1967 Write_Id (Defining_Identifier (Node));
1969 if Present (Discriminant_Specifications (Node)) then
1970 Write_Discr_Specs (Node);
1971 elsif Unknown_Discriminants_Present (Node) then
1972 Write_Str_With_Col_Check ("(<>)");
1973 end if;
1975 Write_Char (';');
1977 when N_Index_Or_Discriminant_Constraint =>
1978 Set_Debug_Sloc;
1979 Sprint_Paren_Comma_List (Constraints (Node));
1981 when N_Indexed_Component =>
1982 Sprint_Node_Sloc (Prefix (Node));
1983 Sprint_Opt_Paren_Comma_List (Expressions (Node));
1985 when N_Integer_Literal =>
1986 if Print_In_Hex (Node) then
1987 Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1988 else
1989 Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1990 end if;
1992 when N_Iteration_Scheme =>
1993 if Present (Condition (Node)) then
1994 Write_Str_With_Col_Check_Sloc ("while ");
1995 Sprint_Node (Condition (Node));
1996 else
1997 Write_Str_With_Col_Check_Sloc ("for ");
1999 if Present (Iterator_Specification (Node)) then
2000 Sprint_Node (Iterator_Specification (Node));
2001 else
2002 Sprint_Node (Loop_Parameter_Specification (Node));
2003 end if;
2004 end if;
2006 Write_Char (' ');
2008 when N_Iterator_Specification =>
2009 Set_Debug_Sloc;
2010 Write_Id (Defining_Identifier (Node));
2012 if Present (Subtype_Indication (Node)) then
2013 Write_Str_With_Col_Check (" : ");
2014 Sprint_Node (Subtype_Indication (Node));
2015 end if;
2017 if Of_Present (Node) then
2018 Write_Str_With_Col_Check (" of ");
2019 else
2020 Write_Str_With_Col_Check (" in ");
2021 end if;
2023 if Reverse_Present (Node) then
2024 Write_Str_With_Col_Check ("reverse ");
2025 end if;
2027 Sprint_Node (Name (Node));
2029 when N_Itype_Reference =>
2030 Write_Indent_Str_Sloc ("reference ");
2031 Write_Id (Itype (Node));
2033 when N_Label =>
2034 Write_Indent_Str_Sloc ("<<");
2035 Write_Id (Identifier (Node));
2036 Write_Str (">>");
2038 when N_Loop_Parameter_Specification =>
2039 Set_Debug_Sloc;
2040 Write_Id (Defining_Identifier (Node));
2041 Write_Str_With_Col_Check (" in ");
2043 if Reverse_Present (Node) then
2044 Write_Str_With_Col_Check ("reverse ");
2045 end if;
2047 Sprint_Node (Discrete_Subtype_Definition (Node));
2049 when N_Loop_Statement =>
2050 Write_Indent;
2052 if Present (Identifier (Node))
2053 and then (not Has_Created_Identifier (Node)
2054 or else not Dump_Original_Only)
2055 then
2056 Write_Rewrite_Str ("<<<");
2057 Write_Id (Identifier (Node));
2058 Write_Str (" : ");
2059 Write_Rewrite_Str (">>>");
2060 Sprint_Node (Iteration_Scheme (Node));
2061 Write_Str_With_Col_Check_Sloc ("loop");
2062 Sprint_Indented_List (Statements (Node));
2063 Write_Indent_Str ("end loop ");
2064 Write_Rewrite_Str ("<<<");
2065 Write_Id (Identifier (Node));
2066 Write_Rewrite_Str (">>>");
2067 Write_Char (';');
2069 else
2070 Sprint_Node (Iteration_Scheme (Node));
2071 Write_Str_With_Col_Check_Sloc ("loop");
2072 Sprint_Indented_List (Statements (Node));
2073 Write_Indent_Str ("end loop;");
2074 end if;
2076 when N_Mod_Clause =>
2077 Sprint_Node_List (Pragmas_Before (Node));
2078 Write_Str_With_Col_Check_Sloc ("at mod ");
2079 Sprint_Node (Expression (Node));
2081 when N_Modular_Type_Definition =>
2082 Write_Str_With_Col_Check_Sloc ("mod ");
2083 Sprint_Node (Expression (Node));
2085 when N_Not_In =>
2086 Sprint_Left_Opnd (Node);
2087 Write_Str_Sloc (" not in ");
2089 if Present (Right_Opnd (Node)) then
2090 Sprint_Right_Opnd (Node);
2091 else
2092 Sprint_Bar_List (Alternatives (Node));
2093 end if;
2095 when N_Null =>
2096 Write_Str_With_Col_Check_Sloc ("null");
2098 when N_Null_Statement =>
2099 if Comes_From_Source (Node)
2100 or else Dump_Freeze_Null
2101 or else not Is_List_Member (Node)
2102 or else (No (Prev (Node)) and then No (Next (Node)))
2103 then
2104 Write_Indent_Str_Sloc ("null;");
2105 end if;
2107 when N_Number_Declaration =>
2108 Set_Debug_Sloc;
2110 if Write_Indent_Identifiers (Node) then
2111 Write_Str_With_Col_Check (" : constant ");
2112 Write_Str (" := ");
2113 Sprint_Node (Expression (Node));
2114 Write_Char (';');
2115 end if;
2117 when N_Object_Declaration =>
2118 Set_Debug_Sloc;
2120 if Write_Indent_Identifiers (Node) then
2121 declare
2122 Def_Id : constant Entity_Id := Defining_Identifier (Node);
2124 begin
2125 Write_Str_With_Col_Check (" : ");
2127 if Is_Statically_Allocated (Def_Id) then
2128 Write_Str_With_Col_Check ("static ");
2129 end if;
2131 if Aliased_Present (Node) then
2132 Write_Str_With_Col_Check ("aliased ");
2133 end if;
2135 if Constant_Present (Node) then
2136 Write_Str_With_Col_Check ("constant ");
2137 end if;
2139 -- Ada 2005 (AI-231)
2141 if Null_Exclusion_Present (Node) then
2142 Write_Str_With_Col_Check ("not null ");
2143 end if;
2145 Sprint_Node (Object_Definition (Node));
2147 if Present (Expression (Node)) then
2148 Write_Str (" := ");
2149 Sprint_Node (Expression (Node));
2150 end if;
2152 Write_Char (';');
2154 -- Handle implicit importation and implicit exportation of
2155 -- object declarations:
2156 -- $pragma import (Convention_Id, Def_Id, "...");
2157 -- $pragma export (Convention_Id, Def_Id, "...");
2159 if Is_Internal (Def_Id)
2160 and then Present (Interface_Name (Def_Id))
2161 then
2162 Write_Indent_Str_Sloc ("$pragma ");
2164 if Is_Imported (Def_Id) then
2165 Write_Str ("import (");
2167 else pragma Assert (Is_Exported (Def_Id));
2168 Write_Str ("export (");
2169 end if;
2171 declare
2172 Prefix : constant String := "Convention_";
2173 S : constant String := Convention (Def_Id)'Img;
2175 begin
2176 Name_Len := S'Last - Prefix'Last;
2177 Name_Buffer (1 .. Name_Len) :=
2178 S (Prefix'Last + 1 .. S'Last);
2179 Set_Casing (All_Lower_Case);
2180 Write_Str (Name_Buffer (1 .. Name_Len));
2181 end;
2183 Write_Str (", ");
2184 Write_Id (Def_Id);
2185 Write_Str (", ");
2186 Write_String_Table_Entry
2187 (Strval (Interface_Name (Def_Id)));
2188 Write_Str (");");
2189 end if;
2190 end;
2191 end if;
2193 when N_Object_Renaming_Declaration =>
2194 Write_Indent;
2195 Set_Debug_Sloc;
2196 Sprint_Node (Defining_Identifier (Node));
2197 Write_Str (" : ");
2199 -- Ada 2005 (AI-230): Access renamings
2201 if Present (Access_Definition (Node)) then
2202 Sprint_Node (Access_Definition (Node));
2204 elsif Present (Subtype_Mark (Node)) then
2206 -- Ada 2005 (AI-423): Object renaming with a null exclusion
2208 if Null_Exclusion_Present (Node) then
2209 Write_Str ("not null ");
2210 end if;
2212 Sprint_Node (Subtype_Mark (Node));
2214 else
2215 Write_Str (" ??? ");
2216 end if;
2218 Write_Str_With_Col_Check (" renames ");
2219 Sprint_Node (Name (Node));
2220 Write_Char (';');
2222 when N_Op_Abs =>
2223 Write_Operator (Node, "abs ");
2224 Sprint_Right_Opnd (Node);
2226 when N_Op_Add =>
2227 Sprint_Left_Opnd (Node);
2228 Write_Operator (Node, " + ");
2229 Sprint_Right_Opnd (Node);
2231 when N_Op_And =>
2232 Sprint_Left_Opnd (Node);
2233 Write_Operator (Node, " and ");
2234 Sprint_Right_Opnd (Node);
2236 when N_Op_Concat =>
2237 Sprint_Left_Opnd (Node);
2238 Write_Operator (Node, " & ");
2239 Sprint_Right_Opnd (Node);
2241 when N_Op_Divide =>
2242 Sprint_Left_Opnd (Node);
2243 Write_Char (' ');
2244 Process_TFAI_RR_Flags (Node);
2245 Write_Operator (Node, "/ ");
2246 Sprint_Right_Opnd (Node);
2248 when N_Op_Eq =>
2249 Sprint_Left_Opnd (Node);
2250 Write_Operator (Node, " = ");
2251 Sprint_Right_Opnd (Node);
2253 when N_Op_Expon =>
2254 Sprint_Left_Opnd (Node);
2255 Write_Operator (Node, " ** ");
2256 Sprint_Right_Opnd (Node);
2258 when N_Op_Ge =>
2259 Sprint_Left_Opnd (Node);
2260 Write_Operator (Node, " >= ");
2261 Sprint_Right_Opnd (Node);
2263 when N_Op_Gt =>
2264 Sprint_Left_Opnd (Node);
2265 Write_Operator (Node, " > ");
2266 Sprint_Right_Opnd (Node);
2268 when N_Op_Le =>
2269 Sprint_Left_Opnd (Node);
2270 Write_Operator (Node, " <= ");
2271 Sprint_Right_Opnd (Node);
2273 when N_Op_Lt =>
2274 Sprint_Left_Opnd (Node);
2275 Write_Operator (Node, " < ");
2276 Sprint_Right_Opnd (Node);
2278 when N_Op_Minus =>
2279 Write_Operator (Node, "-");
2280 Sprint_Right_Opnd (Node);
2282 when N_Op_Mod =>
2283 Sprint_Left_Opnd (Node);
2285 if Treat_Fixed_As_Integer (Node) then
2286 Write_Str (" #");
2287 end if;
2289 Write_Operator (Node, " mod ");
2290 Sprint_Right_Opnd (Node);
2292 when N_Op_Multiply =>
2293 Sprint_Left_Opnd (Node);
2294 Write_Char (' ');
2295 Process_TFAI_RR_Flags (Node);
2296 Write_Operator (Node, "* ");
2297 Sprint_Right_Opnd (Node);
2299 when N_Op_Ne =>
2300 Sprint_Left_Opnd (Node);
2301 Write_Operator (Node, " /= ");
2302 Sprint_Right_Opnd (Node);
2304 when N_Op_Not =>
2305 Write_Operator (Node, "not ");
2306 Sprint_Right_Opnd (Node);
2308 when N_Op_Or =>
2309 Sprint_Left_Opnd (Node);
2310 Write_Operator (Node, " or ");
2311 Sprint_Right_Opnd (Node);
2313 when N_Op_Plus =>
2314 Write_Operator (Node, "+");
2315 Sprint_Right_Opnd (Node);
2317 when N_Op_Rem =>
2318 Sprint_Left_Opnd (Node);
2320 if Treat_Fixed_As_Integer (Node) then
2321 Write_Str (" #");
2322 end if;
2324 Write_Operator (Node, " rem ");
2325 Sprint_Right_Opnd (Node);
2327 when N_Op_Shift =>
2328 Set_Debug_Sloc;
2329 Write_Id (Node);
2330 Write_Char ('!');
2331 Write_Str_With_Col_Check ("(");
2332 Sprint_Node (Left_Opnd (Node));
2333 Write_Str (", ");
2334 Sprint_Node (Right_Opnd (Node));
2335 Write_Char (')');
2337 when N_Op_Subtract =>
2338 Sprint_Left_Opnd (Node);
2339 Write_Operator (Node, " - ");
2340 Sprint_Right_Opnd (Node);
2342 when N_Op_Xor =>
2343 Sprint_Left_Opnd (Node);
2344 Write_Operator (Node, " xor ");
2345 Sprint_Right_Opnd (Node);
2347 when N_Operator_Symbol =>
2348 Write_Name_With_Col_Check_Sloc (Chars (Node));
2350 when N_Ordinary_Fixed_Point_Definition =>
2351 Write_Str_With_Col_Check_Sloc ("delta ");
2352 Sprint_Node (Delta_Expression (Node));
2353 Sprint_Opt_Node (Real_Range_Specification (Node));
2355 when N_Or_Else =>
2356 Sprint_Left_Opnd (Node);
2357 Write_Str_Sloc (" or else ");
2358 Sprint_Right_Opnd (Node);
2360 when N_Others_Choice =>
2361 if All_Others (Node) then
2362 Write_Str_With_Col_Check ("all ");
2363 end if;
2365 Write_Str_With_Col_Check_Sloc ("others");
2367 when N_Package_Body =>
2368 Extra_Blank_Line;
2369 Write_Indent_Str_Sloc ("package body ");
2370 Sprint_Node (Defining_Unit_Name (Node));
2371 Write_Str (" is");
2372 Sprint_Indented_List (Declarations (Node));
2374 if Present (Handled_Statement_Sequence (Node)) then
2375 Write_Indent_Str ("begin");
2376 Sprint_Node (Handled_Statement_Sequence (Node));
2377 end if;
2379 Write_Indent_Str ("end ");
2380 Sprint_End_Label
2381 (Handled_Statement_Sequence (Node), Defining_Unit_Name (Node));
2382 Write_Char (';');
2384 when N_Package_Body_Stub =>
2385 Write_Indent_Str_Sloc ("package body ");
2386 Sprint_Node (Defining_Identifier (Node));
2387 Write_Str_With_Col_Check (" is separate;");
2389 when N_Package_Declaration =>
2390 Extra_Blank_Line;
2391 Write_Indent;
2392 Sprint_Node_Sloc (Specification (Node));
2393 Write_Char (';');
2395 when N_Package_Instantiation =>
2396 Extra_Blank_Line;
2397 Write_Indent_Str_Sloc ("package ");
2398 Sprint_Node (Defining_Unit_Name (Node));
2399 Write_Str (" is new ");
2400 Sprint_Node (Name (Node));
2401 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2402 Write_Char (';');
2404 when N_Package_Renaming_Declaration =>
2405 Write_Indent_Str_Sloc ("package ");
2406 Sprint_Node (Defining_Unit_Name (Node));
2407 Write_Str_With_Col_Check (" renames ");
2408 Sprint_Node (Name (Node));
2409 Write_Char (';');
2411 when N_Package_Specification =>
2412 Write_Str_With_Col_Check_Sloc ("package ");
2413 Sprint_Node (Defining_Unit_Name (Node));
2414 Write_Str (" is");
2415 Sprint_Indented_List (Visible_Declarations (Node));
2417 if Present (Private_Declarations (Node)) then
2418 Write_Indent_Str ("private");
2419 Sprint_Indented_List (Private_Declarations (Node));
2420 end if;
2422 Write_Indent_Str ("end ");
2423 Sprint_Node (Defining_Unit_Name (Node));
2425 when N_Parameter_Association =>
2426 Sprint_Node_Sloc (Selector_Name (Node));
2427 Write_Str (" => ");
2428 Sprint_Node (Explicit_Actual_Parameter (Node));
2430 when N_Parameter_Specification =>
2431 Set_Debug_Sloc;
2433 if Write_Identifiers (Node) then
2434 Write_Str (" : ");
2436 if In_Present (Node) then
2437 Write_Str_With_Col_Check ("in ");
2438 end if;
2440 if Out_Present (Node) then
2441 Write_Str_With_Col_Check ("out ");
2442 end if;
2444 -- Ada 2005 (AI-231): Parameter specification may carry null
2445 -- exclusion. Do not print it now if this is an access formal,
2446 -- it is emitted when the access definition is displayed.
2448 if Null_Exclusion_Present (Node)
2449 and then Nkind (Parameter_Type (Node))
2450 /= N_Access_Definition
2451 then
2452 Write_Str ("not null ");
2453 end if;
2455 Sprint_Node (Parameter_Type (Node));
2457 if Present (Expression (Node)) then
2458 Write_Str (" := ");
2459 Sprint_Node (Expression (Node));
2460 end if;
2461 else
2462 Write_Str (", ");
2463 end if;
2465 when N_Parameterized_Expression =>
2466 Write_Indent;
2467 Sprint_Node_Sloc (Specification (Node));
2469 Write_Str (" is");
2470 Indent_Begin;
2471 Write_Indent;
2472 Sprint_Node (Expression (Node));
2473 Write_Char (';');
2474 Indent_End;
2476 when N_Pop_Constraint_Error_Label =>
2477 Write_Indent_Str ("%pop_constraint_error_label");
2479 when N_Pop_Program_Error_Label =>
2480 Write_Indent_Str ("%pop_program_error_label");
2482 when N_Pop_Storage_Error_Label =>
2483 Write_Indent_Str ("%pop_storage_error_label");
2485 when N_Private_Extension_Declaration =>
2486 Write_Indent_Str_Sloc ("type ");
2487 Write_Id (Defining_Identifier (Node));
2489 if Present (Discriminant_Specifications (Node)) then
2490 Write_Discr_Specs (Node);
2491 elsif Unknown_Discriminants_Present (Node) then
2492 Write_Str_With_Col_Check ("(<>)");
2493 end if;
2495 Write_Str_With_Col_Check (" is new ");
2496 Sprint_Node (Subtype_Indication (Node));
2498 if Present (Interface_List (Node)) then
2499 Write_Str_With_Col_Check (" and ");
2500 Sprint_And_List (Interface_List (Node));
2501 end if;
2503 Write_Str_With_Col_Check (" with private;");
2505 when N_Private_Type_Declaration =>
2506 Write_Indent_Str_Sloc ("type ");
2507 Write_Id (Defining_Identifier (Node));
2509 if Present (Discriminant_Specifications (Node)) then
2510 Write_Discr_Specs (Node);
2511 elsif Unknown_Discriminants_Present (Node) then
2512 Write_Str_With_Col_Check ("(<>)");
2513 end if;
2515 Write_Str (" is ");
2517 if Tagged_Present (Node) then
2518 Write_Str_With_Col_Check ("tagged ");
2519 end if;
2521 if Limited_Present (Node) then
2522 Write_Str_With_Col_Check ("limited ");
2523 end if;
2525 Write_Str_With_Col_Check ("private;");
2527 when N_Push_Constraint_Error_Label =>
2528 Write_Indent_Str ("%push_constraint_error_label (");
2530 if Present (Exception_Label (Node)) then
2531 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2532 end if;
2534 Write_Str (")");
2536 when N_Push_Program_Error_Label =>
2537 Write_Indent_Str ("%push_program_error_label (");
2539 if Present (Exception_Label (Node)) then
2540 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2541 end if;
2543 Write_Str (")");
2545 when N_Push_Storage_Error_Label =>
2546 Write_Indent_Str ("%push_storage_error_label (");
2548 if Present (Exception_Label (Node)) then
2549 Write_Name_With_Col_Check (Chars (Exception_Label (Node)));
2550 end if;
2552 Write_Str (")");
2554 when N_Pragma =>
2555 Write_Indent_Str_Sloc ("pragma ");
2556 Write_Name_With_Col_Check (Pragma_Name (Node));
2558 if Present (Pragma_Argument_Associations (Node)) then
2559 Sprint_Opt_Paren_Comma_List
2560 (Pragma_Argument_Associations (Node));
2561 end if;
2563 Write_Char (';');
2565 when N_Pragma_Argument_Association =>
2566 Set_Debug_Sloc;
2568 if Chars (Node) /= No_Name then
2569 Write_Name_With_Col_Check (Chars (Node));
2570 Write_Str (" => ");
2571 end if;
2573 Sprint_Node (Expression (Node));
2575 when N_Procedure_Call_Statement =>
2576 Write_Indent;
2577 Set_Debug_Sloc;
2578 Write_Subprogram_Name (Name (Node));
2579 Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2580 Write_Char (';');
2582 when N_Procedure_Instantiation =>
2583 Write_Indent_Str_Sloc ("procedure ");
2584 Sprint_Node (Defining_Unit_Name (Node));
2585 Write_Str_With_Col_Check (" is new ");
2586 Sprint_Node (Name (Node));
2587 Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2588 Write_Char (';');
2590 when N_Procedure_Specification =>
2591 Write_Str_With_Col_Check_Sloc ("procedure ");
2592 Sprint_Node (Defining_Unit_Name (Node));
2593 Write_Param_Specs (Node);
2595 when N_Protected_Body =>
2596 Write_Indent_Str_Sloc ("protected body ");
2597 Write_Id (Defining_Identifier (Node));
2598 Write_Str (" is");
2599 Sprint_Indented_List (Declarations (Node));
2600 Write_Indent_Str ("end ");
2601 Write_Id (Defining_Identifier (Node));
2602 Write_Char (';');
2604 when N_Protected_Body_Stub =>
2605 Write_Indent_Str_Sloc ("protected body ");
2606 Write_Id (Defining_Identifier (Node));
2607 Write_Str_With_Col_Check (" is separate;");
2609 when N_Protected_Definition =>
2610 Set_Debug_Sloc;
2611 Sprint_Indented_List (Visible_Declarations (Node));
2613 if Present (Private_Declarations (Node)) then
2614 Write_Indent_Str ("private");
2615 Sprint_Indented_List (Private_Declarations (Node));
2616 end if;
2618 Write_Indent_Str ("end ");
2620 when N_Protected_Type_Declaration =>
2621 Write_Indent_Str_Sloc ("protected type ");
2622 Sprint_Node (Defining_Identifier (Node));
2623 Write_Discr_Specs (Node);
2625 if Present (Interface_List (Node)) then
2626 Write_Str (" is new ");
2627 Sprint_And_List (Interface_List (Node));
2628 Write_Str (" with ");
2629 else
2630 Write_Str (" is");
2631 end if;
2633 Sprint_Node (Protected_Definition (Node));
2634 Write_Id (Defining_Identifier (Node));
2635 Write_Char (';');
2637 when N_Qualified_Expression =>
2638 Sprint_Node (Subtype_Mark (Node));
2639 Write_Char_Sloc (''');
2641 -- Print expression, make sure we have at least one level of
2642 -- parentheses around the expression. For cases of qualified
2643 -- expressions in the source, this is always the case, but
2644 -- for generated qualifications, there may be no explicit
2645 -- parentheses present.
2647 if Paren_Count (Expression (Node)) /= 0 then
2648 Sprint_Node (Expression (Node));
2649 else
2650 Write_Char ('(');
2651 Sprint_Node (Expression (Node));
2652 Write_Char (')');
2653 end if;
2655 when N_Quantified_Expression =>
2656 Write_Str (" for");
2658 if All_Present (Node) then
2659 Write_Str (" all ");
2660 else
2661 Write_Str (" some ");
2662 end if;
2664 Sprint_Node (Loop_Parameter_Specification (Node));
2665 Write_Str (" => ");
2666 Sprint_Node (Condition (Node));
2668 when N_Raise_Constraint_Error =>
2670 -- This node can be used either as a subexpression or as a
2671 -- statement form. The following test is a reasonably reliable
2672 -- way to distinguish the two cases.
2674 if Is_List_Member (Node)
2675 and then Nkind (Parent (Node)) not in N_Subexpr
2676 then
2677 Write_Indent;
2678 end if;
2680 Write_Str_With_Col_Check_Sloc ("[constraint_error");
2681 Write_Condition_And_Reason (Node);
2683 when N_Raise_Program_Error =>
2685 -- This node can be used either as a subexpression or as a
2686 -- statement form. The following test is a reasonably reliable
2687 -- way to distinguish the two cases.
2689 if Is_List_Member (Node)
2690 and then Nkind (Parent (Node)) not in N_Subexpr
2691 then
2692 Write_Indent;
2693 end if;
2695 Write_Str_With_Col_Check_Sloc ("[program_error");
2696 Write_Condition_And_Reason (Node);
2698 when N_Raise_Storage_Error =>
2700 -- This node can be used either as a subexpression or as a
2701 -- statement form. The following test is a reasonably reliable
2702 -- way to distinguish the two cases.
2704 if Is_List_Member (Node)
2705 and then Nkind (Parent (Node)) not in N_Subexpr
2706 then
2707 Write_Indent;
2708 end if;
2710 Write_Str_With_Col_Check_Sloc ("[storage_error");
2711 Write_Condition_And_Reason (Node);
2713 when N_Raise_Statement =>
2714 Write_Indent_Str_Sloc ("raise ");
2715 Sprint_Node (Name (Node));
2716 Write_Char (';');
2718 when N_Range =>
2719 Sprint_Node (Low_Bound (Node));
2720 Write_Str_Sloc (" .. ");
2721 Sprint_Node (High_Bound (Node));
2722 Update_Itype (Node);
2724 when N_Range_Constraint =>
2725 Write_Str_With_Col_Check_Sloc ("range ");
2726 Sprint_Node (Range_Expression (Node));
2728 when N_Real_Literal =>
2729 Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2731 when N_Real_Range_Specification =>
2732 Write_Str_With_Col_Check_Sloc ("range ");
2733 Sprint_Node (Low_Bound (Node));
2734 Write_Str (" .. ");
2735 Sprint_Node (High_Bound (Node));
2737 when N_Record_Definition =>
2738 if Abstract_Present (Node) then
2739 Write_Str_With_Col_Check ("abstract ");
2740 end if;
2742 if Tagged_Present (Node) then
2743 Write_Str_With_Col_Check ("tagged ");
2744 end if;
2746 if Limited_Present (Node) then
2747 Write_Str_With_Col_Check ("limited ");
2748 end if;
2750 if Null_Present (Node) then
2751 Write_Str_With_Col_Check_Sloc ("null record");
2753 else
2754 Write_Str_With_Col_Check_Sloc ("record");
2755 Sprint_Node (Component_List (Node));
2756 Write_Indent_Str ("end record");
2757 end if;
2759 when N_Record_Representation_Clause =>
2760 Write_Indent_Str_Sloc ("for ");
2761 Sprint_Node (Identifier (Node));
2762 Write_Str_With_Col_Check (" use record ");
2764 if Present (Mod_Clause (Node)) then
2765 Sprint_Node (Mod_Clause (Node));
2766 end if;
2768 Sprint_Indented_List (Component_Clauses (Node));
2769 Write_Indent_Str ("end record;");
2771 when N_Reference =>
2772 Sprint_Node (Prefix (Node));
2773 Write_Str_With_Col_Check_Sloc ("'reference");
2775 when N_Requeue_Statement =>
2776 Write_Indent_Str_Sloc ("requeue ");
2777 Sprint_Node (Name (Node));
2779 if Abort_Present (Node) then
2780 Write_Str_With_Col_Check (" with abort");
2781 end if;
2783 Write_Char (';');
2785 -- Don't we want to print more detail???
2787 -- Doc of this extended syntax belongs in sinfo.ads and/or
2788 -- sprint.ads ???
2790 when N_SCIL_Dispatch_Table_Tag_Init =>
2791 Write_Indent_Str ("[N_SCIL_Dispatch_Table_Tag_Init]");
2793 when N_SCIL_Dispatching_Call =>
2794 Write_Indent_Str ("[N_SCIL_Dispatching_Node]");
2796 when N_SCIL_Membership_Test =>
2797 Write_Indent_Str ("[N_SCIL_Membership_Test]");
2799 when N_Simple_Return_Statement =>
2800 if Present (Expression (Node)) then
2801 Write_Indent_Str_Sloc ("return ");
2802 Sprint_Node (Expression (Node));
2803 Write_Char (';');
2804 else
2805 Write_Indent_Str_Sloc ("return;");
2806 end if;
2808 when N_Selective_Accept =>
2809 Write_Indent_Str_Sloc ("select");
2811 declare
2812 Alt_Node : Node_Id;
2813 begin
2814 Alt_Node := First (Select_Alternatives (Node));
2815 loop
2816 Indent_Begin;
2817 Sprint_Node (Alt_Node);
2818 Indent_End;
2819 Next (Alt_Node);
2820 exit when No (Alt_Node);
2821 Write_Indent_Str ("or");
2822 end loop;
2823 end;
2825 if Present (Else_Statements (Node)) then
2826 Write_Indent_Str ("else");
2827 Sprint_Indented_List (Else_Statements (Node));
2828 end if;
2830 Write_Indent_Str ("end select;");
2832 when N_Signed_Integer_Type_Definition =>
2833 Write_Str_With_Col_Check_Sloc ("range ");
2834 Sprint_Node (Low_Bound (Node));
2835 Write_Str (" .. ");
2836 Sprint_Node (High_Bound (Node));
2838 when N_Single_Protected_Declaration =>
2839 Write_Indent_Str_Sloc ("protected ");
2840 Write_Id (Defining_Identifier (Node));
2841 Write_Str (" is");
2842 Sprint_Node (Protected_Definition (Node));
2843 Write_Id (Defining_Identifier (Node));
2844 Write_Char (';');
2846 when N_Single_Task_Declaration =>
2847 Write_Indent_Str_Sloc ("task ");
2848 Sprint_Node (Defining_Identifier (Node));
2850 if Present (Task_Definition (Node)) then
2851 Write_Str (" is");
2852 Sprint_Node (Task_Definition (Node));
2853 end if;
2855 Write_Char (';');
2857 when N_Selected_Component =>
2858 Sprint_Node (Prefix (Node));
2859 Write_Char_Sloc ('.');
2860 Sprint_Node (Selector_Name (Node));
2862 when N_Slice =>
2863 Set_Debug_Sloc;
2864 Sprint_Node (Prefix (Node));
2865 Write_Str_With_Col_Check (" (");
2866 Sprint_Node (Discrete_Range (Node));
2867 Write_Char (')');
2869 when N_String_Literal =>
2870 if String_Length (Strval (Node)) + Column > Sprint_Line_Limit then
2871 Write_Indent_Str (" ");
2872 end if;
2874 Set_Debug_Sloc;
2875 Write_String_Table_Entry (Strval (Node));
2877 when N_Subprogram_Body =>
2879 -- Output extra blank line unless we are in freeze actions
2881 if Freeze_Indent = 0 then
2882 Extra_Blank_Line;
2883 end if;
2885 Write_Indent;
2887 if Present (Corresponding_Spec (Node)) then
2888 Sprint_Node_Sloc (Parent (Corresponding_Spec (Node)));
2889 else
2890 Sprint_Node_Sloc (Specification (Node));
2891 end if;
2893 Write_Str (" is");
2895 Sprint_Indented_List (Declarations (Node));
2896 Write_Indent_Str ("begin");
2897 Sprint_Node (Handled_Statement_Sequence (Node));
2899 Write_Indent_Str ("end ");
2901 Sprint_End_Label
2902 (Handled_Statement_Sequence (Node),
2903 Defining_Unit_Name (Specification (Node)));
2904 Write_Char (';');
2906 if Is_List_Member (Node)
2907 and then Present (Next (Node))
2908 and then Nkind (Next (Node)) /= N_Subprogram_Body
2909 then
2910 Write_Indent;
2911 end if;
2913 when N_Subprogram_Body_Stub =>
2914 Write_Indent;
2915 Sprint_Node_Sloc (Specification (Node));
2916 Write_Str_With_Col_Check (" is separate;");
2918 when N_Subprogram_Declaration =>
2919 Write_Indent;
2920 Sprint_Node_Sloc (Specification (Node));
2922 if Nkind (Specification (Node)) = N_Procedure_Specification
2923 and then Null_Present (Specification (Node))
2924 then
2925 Write_Str_With_Col_Check (" is null");
2926 end if;
2928 Write_Char (';');
2930 when N_Subprogram_Info =>
2931 Sprint_Node (Identifier (Node));
2932 Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2934 when N_Subprogram_Renaming_Declaration =>
2935 Write_Indent;
2936 Sprint_Node (Specification (Node));
2937 Write_Str_With_Col_Check_Sloc (" renames ");
2938 Sprint_Node (Name (Node));
2939 Write_Char (';');
2941 when N_Subtype_Declaration =>
2942 Write_Indent_Str_Sloc ("subtype ");
2943 Sprint_Node (Defining_Identifier (Node));
2944 Write_Str (" is ");
2946 -- Ada 2005 (AI-231)
2948 if Null_Exclusion_Present (Node) then
2949 Write_Str ("not null ");
2950 end if;
2952 Sprint_Node (Subtype_Indication (Node));
2953 Write_Char (';');
2955 when N_Subtype_Indication =>
2956 Sprint_Node_Sloc (Subtype_Mark (Node));
2957 Write_Char (' ');
2958 Sprint_Node (Constraint (Node));
2960 when N_Subunit =>
2961 Write_Indent_Str_Sloc ("separate (");
2962 Sprint_Node (Name (Node));
2963 Write_Char (')');
2964 Extra_Blank_Line;
2965 Sprint_Node (Proper_Body (Node));
2967 when N_Task_Body =>
2968 Write_Indent_Str_Sloc ("task body ");
2969 Write_Id (Defining_Identifier (Node));
2970 Write_Str (" is");
2971 Sprint_Indented_List (Declarations (Node));
2972 Write_Indent_Str ("begin");
2973 Sprint_Node (Handled_Statement_Sequence (Node));
2974 Write_Indent_Str ("end ");
2975 Sprint_End_Label
2976 (Handled_Statement_Sequence (Node), Defining_Identifier (Node));
2977 Write_Char (';');
2979 when N_Task_Body_Stub =>
2980 Write_Indent_Str_Sloc ("task body ");
2981 Write_Id (Defining_Identifier (Node));
2982 Write_Str_With_Col_Check (" is separate;");
2984 when N_Task_Definition =>
2985 Set_Debug_Sloc;
2986 Sprint_Indented_List (Visible_Declarations (Node));
2988 if Present (Private_Declarations (Node)) then
2989 Write_Indent_Str ("private");
2990 Sprint_Indented_List (Private_Declarations (Node));
2991 end if;
2993 Write_Indent_Str ("end ");
2994 Sprint_End_Label (Node, Defining_Identifier (Parent (Node)));
2996 when N_Task_Type_Declaration =>
2997 Write_Indent_Str_Sloc ("task type ");
2998 Sprint_Node (Defining_Identifier (Node));
2999 Write_Discr_Specs (Node);
3001 if Present (Interface_List (Node)) then
3002 Write_Str (" is new ");
3003 Sprint_And_List (Interface_List (Node));
3004 end if;
3006 if Present (Task_Definition (Node)) then
3007 if No (Interface_List (Node)) then
3008 Write_Str (" is");
3009 else
3010 Write_Str (" with ");
3011 end if;
3013 Sprint_Node (Task_Definition (Node));
3014 end if;
3016 Write_Char (';');
3018 when N_Terminate_Alternative =>
3019 Sprint_Node_List (Pragmas_Before (Node));
3020 Write_Indent;
3022 if Present (Condition (Node)) then
3023 Write_Str_With_Col_Check ("when ");
3024 Sprint_Node (Condition (Node));
3025 Write_Str (" => ");
3026 end if;
3028 Write_Str_With_Col_Check_Sloc ("terminate;");
3029 Sprint_Node_List (Pragmas_After (Node));
3031 when N_Timed_Entry_Call =>
3032 Write_Indent_Str_Sloc ("select");
3033 Indent_Begin;
3034 Sprint_Node (Entry_Call_Alternative (Node));
3035 Indent_End;
3036 Write_Indent_Str ("or");
3037 Indent_Begin;
3038 Sprint_Node (Delay_Alternative (Node));
3039 Indent_End;
3040 Write_Indent_Str ("end select;");
3042 when N_Triggering_Alternative =>
3043 Sprint_Node_List (Pragmas_Before (Node));
3044 Sprint_Node_Sloc (Triggering_Statement (Node));
3045 Sprint_Node_List (Statements (Node));
3047 when N_Type_Conversion =>
3048 Set_Debug_Sloc;
3049 Sprint_Node (Subtype_Mark (Node));
3050 Col_Check (4);
3052 if Conversion_OK (Node) then
3053 Write_Char ('?');
3054 end if;
3056 if Float_Truncate (Node) then
3057 Write_Char ('^');
3058 end if;
3060 if Rounded_Result (Node) then
3061 Write_Char ('@');
3062 end if;
3064 Write_Char ('(');
3065 Sprint_Node (Expression (Node));
3066 Write_Char (')');
3068 when N_Unchecked_Expression =>
3069 Col_Check (10);
3070 Write_Str ("`(");
3071 Sprint_Node_Sloc (Expression (Node));
3072 Write_Char (')');
3074 when N_Unchecked_Type_Conversion =>
3075 Sprint_Node (Subtype_Mark (Node));
3076 Write_Char ('!');
3077 Write_Str_With_Col_Check ("(");
3078 Sprint_Node_Sloc (Expression (Node));
3079 Write_Char (')');
3081 when N_Unconstrained_Array_Definition =>
3082 Write_Str_With_Col_Check_Sloc ("array (");
3084 declare
3085 Node1 : Node_Id;
3086 begin
3087 Node1 := First (Subtype_Marks (Node));
3088 loop
3089 Sprint_Node (Node1);
3090 Write_Str_With_Col_Check (" range <>");
3091 Next (Node1);
3092 exit when Node1 = Empty;
3093 Write_Str (", ");
3094 end loop;
3095 end;
3097 Write_Str (") of ");
3098 Sprint_Node (Component_Definition (Node));
3100 when N_Unused_At_Start | N_Unused_At_End =>
3101 Write_Indent_Str ("***** Error, unused node encountered *****");
3102 Write_Eol;
3104 when N_Use_Package_Clause =>
3105 Write_Indent_Str_Sloc ("use ");
3106 Sprint_Comma_List (Names (Node));
3107 Write_Char (';');
3109 when N_Use_Type_Clause =>
3110 Write_Indent_Str_Sloc ("use type ");
3111 Sprint_Comma_List (Subtype_Marks (Node));
3112 Write_Char (';');
3114 when N_Validate_Unchecked_Conversion =>
3115 Write_Indent_Str_Sloc ("validate unchecked_conversion (");
3116 Sprint_Node (Source_Type (Node));
3117 Write_Str (", ");
3118 Sprint_Node (Target_Type (Node));
3119 Write_Str (");");
3121 when N_Variant =>
3122 Write_Indent_Str_Sloc ("when ");
3123 Sprint_Bar_List (Discrete_Choices (Node));
3124 Write_Str (" => ");
3125 Sprint_Node (Component_List (Node));
3127 when N_Variant_Part =>
3128 Indent_Begin;
3129 Write_Indent_Str_Sloc ("case ");
3130 Sprint_Node (Name (Node));
3131 Write_Str (" is ");
3132 Sprint_Indented_List (Variants (Node));
3133 Write_Indent_Str ("end case");
3134 Indent_End;
3136 when N_With_Clause =>
3138 -- Special test, if we are dumping the original tree only,
3139 -- then we want to eliminate the bogus with clauses that
3140 -- correspond to the non-existent children of Text_IO.
3142 if Dump_Original_Only
3143 and then Is_Text_IO_Kludge_Unit (Name (Node))
3144 then
3145 null;
3147 -- Normal case, output the with clause
3149 else
3150 if First_Name (Node) or else not Dump_Original_Only then
3152 -- Ada 2005 (AI-50217): Print limited with_clauses
3154 if Private_Present (Node) and Limited_Present (Node) then
3155 Write_Indent_Str ("limited private with ");
3157 elsif Private_Present (Node) then
3158 Write_Indent_Str ("private with ");
3160 elsif Limited_Present (Node) then
3161 Write_Indent_Str ("limited with ");
3163 else
3164 Write_Indent_Str ("with ");
3165 end if;
3167 else
3168 Write_Str (", ");
3169 end if;
3171 Sprint_Node_Sloc (Name (Node));
3173 if Last_Name (Node) or else not Dump_Original_Only then
3174 Write_Char (';');
3175 end if;
3176 end if;
3177 end case;
3179 if Has_Aspects (Node) then
3180 Sprint_Aspect_Specifications (Node);
3181 end if;
3183 if Nkind (Node) in N_Subexpr
3184 and then Do_Range_Check (Node)
3185 then
3186 Write_Str ("}");
3187 end if;
3189 for J in 1 .. Paren_Count (Node) loop
3190 Write_Char (')');
3191 end loop;
3193 Dump_Node := Save_Dump_Node;
3194 end Sprint_Node_Actual;
3196 ----------------------
3197 -- Sprint_Node_List --
3198 ----------------------
3200 procedure Sprint_Node_List (List : List_Id) is
3201 Node : Node_Id;
3203 begin
3204 if Is_Non_Empty_List (List) then
3205 Node := First (List);
3207 loop
3208 Sprint_Node (Node);
3209 Next (Node);
3210 exit when Node = Empty;
3211 end loop;
3212 end if;
3213 end Sprint_Node_List;
3215 ----------------------
3216 -- Sprint_Node_Sloc --
3217 ----------------------
3219 procedure Sprint_Node_Sloc (Node : Node_Id) is
3220 begin
3221 Sprint_Node (Node);
3223 if Debug_Generated_Code and then Present (Dump_Node) then
3224 Set_Sloc (Dump_Node, Sloc (Node));
3225 Dump_Node := Empty;
3226 end if;
3227 end Sprint_Node_Sloc;
3229 ---------------------
3230 -- Sprint_Opt_Node --
3231 ---------------------
3233 procedure Sprint_Opt_Node (Node : Node_Id) is
3234 begin
3235 if Present (Node) then
3236 Write_Char (' ');
3237 Sprint_Node (Node);
3238 end if;
3239 end Sprint_Opt_Node;
3241 --------------------------
3242 -- Sprint_Opt_Node_List --
3243 --------------------------
3245 procedure Sprint_Opt_Node_List (List : List_Id) is
3246 begin
3247 if Present (List) then
3248 Sprint_Node_List (List);
3249 end if;
3250 end Sprint_Opt_Node_List;
3252 ---------------------------------
3253 -- Sprint_Opt_Paren_Comma_List --
3254 ---------------------------------
3256 procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
3257 begin
3258 if Is_Non_Empty_List (List) then
3259 Write_Char (' ');
3260 Sprint_Paren_Comma_List (List);
3261 end if;
3262 end Sprint_Opt_Paren_Comma_List;
3264 -----------------------------
3265 -- Sprint_Paren_Comma_List --
3266 -----------------------------
3268 procedure Sprint_Paren_Comma_List (List : List_Id) is
3269 N : Node_Id;
3270 Node_Exists : Boolean := False;
3272 begin
3274 if Is_Non_Empty_List (List) then
3276 if Dump_Original_Only then
3277 N := First (List);
3278 while Present (N) loop
3279 if not Is_Rewrite_Insertion (N) then
3280 Node_Exists := True;
3281 exit;
3282 end if;
3284 Next (N);
3285 end loop;
3287 if not Node_Exists then
3288 return;
3289 end if;
3290 end if;
3292 Write_Str_With_Col_Check ("(");
3293 Sprint_Comma_List (List);
3294 Write_Char (')');
3295 end if;
3296 end Sprint_Paren_Comma_List;
3298 ----------------------
3299 -- Sprint_Right_Opnd --
3300 ----------------------
3302 procedure Sprint_Right_Opnd (N : Node_Id) is
3303 Opnd : constant Node_Id := Right_Opnd (N);
3305 begin
3306 if Paren_Count (Opnd) /= 0
3307 or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
3308 then
3309 Sprint_Node (Opnd);
3311 else
3312 Write_Char ('(');
3313 Sprint_Node (Opnd);
3314 Write_Char (')');
3315 end if;
3316 end Sprint_Right_Opnd;
3318 ------------------
3319 -- Update_Itype --
3320 ------------------
3322 procedure Update_Itype (Node : Node_Id) is
3323 begin
3324 if Present (Etype (Node))
3325 and then Is_Itype (Etype (Node))
3326 and then Debug_Generated_Code
3327 then
3328 Set_Sloc (Etype (Node), Sloc (Node));
3329 end if;
3330 end Update_Itype;
3332 ---------------------
3333 -- Write_Char_Sloc --
3334 ---------------------
3336 procedure Write_Char_Sloc (C : Character) is
3337 begin
3338 if Debug_Generated_Code and then C /= ' ' then
3339 Set_Debug_Sloc;
3340 end if;
3342 Write_Char (C);
3343 end Write_Char_Sloc;
3345 --------------------------------
3346 -- Write_Condition_And_Reason --
3347 --------------------------------
3349 procedure Write_Condition_And_Reason (Node : Node_Id) is
3350 Cond : constant Node_Id := Condition (Node);
3351 Image : constant String := RT_Exception_Code'Image
3352 (RT_Exception_Code'Val
3353 (UI_To_Int (Reason (Node))));
3355 begin
3356 if Present (Cond) then
3358 -- If condition is a single entity, or NOT with a single entity,
3359 -- output all on one line, since it will likely fit just fine.
3361 if Is_Entity_Name (Cond)
3362 or else (Nkind (Cond) = N_Op_Not
3363 and then Is_Entity_Name (Right_Opnd (Cond)))
3364 then
3365 Write_Str_With_Col_Check (" when ");
3366 Sprint_Node (Cond);
3367 Write_Char (' ');
3369 -- Otherwise for more complex condition, multiple lines
3371 else
3372 Write_Str_With_Col_Check (" when");
3373 Indent := Indent + 2;
3374 Write_Indent;
3375 Sprint_Node (Cond);
3376 Write_Indent;
3377 Indent := Indent - 2;
3378 end if;
3380 -- If no condition, just need a space (all on one line)
3382 else
3383 Write_Char (' ');
3384 end if;
3386 -- Write the reason
3388 Write_Char ('"');
3390 for J in 4 .. Image'Last loop
3391 if Image (J) = '_' then
3392 Write_Char (' ');
3393 else
3394 Write_Char (Fold_Lower (Image (J)));
3395 end if;
3396 end loop;
3398 Write_Str ("""]");
3399 end Write_Condition_And_Reason;
3401 --------------------------------
3402 -- Write_Corresponding_Source --
3403 --------------------------------
3405 procedure Write_Corresponding_Source (S : String) is
3406 Loc : Source_Ptr;
3407 Src : Source_Buffer_Ptr;
3409 begin
3410 -- Ignore if not in dump source text mode, or if in freeze actions
3412 if Dump_Source_Text and then Freeze_Indent = 0 then
3414 -- Ignore null string
3416 if S = "" then
3417 return;
3418 end if;
3420 -- Ignore space or semicolon at end of given string
3422 if S (S'Last) = ' ' or else S (S'Last) = ';' then
3423 Write_Corresponding_Source (S (S'First .. S'Last - 1));
3424 return;
3425 end if;
3427 -- Loop to look at next lines not yet printed in source file
3429 for L in
3430 Last_Line_Printed + 1 .. Last_Source_Line (Current_Source_File)
3431 loop
3432 Src := Source_Text (Current_Source_File);
3433 Loc := Line_Start (L, Current_Source_File);
3435 -- If comment, keep looking
3437 if Src (Loc .. Loc + 1) = "--" then
3438 null;
3440 -- Search to first non-blank
3442 else
3443 while Src (Loc) not in Line_Terminator loop
3445 -- Non-blank found
3447 if Src (Loc) /= ' ' and then Src (Loc) /= ASCII.HT then
3449 -- Loop through characters in string to see if we match
3451 for J in S'Range loop
3453 -- If mismatch, then not the case we are looking for
3455 if Src (Loc) /= S (J) then
3456 return;
3457 end if;
3459 Loc := Loc + 1;
3460 end loop;
3462 -- If we fall through, string matched, if white space or
3463 -- semicolon after the matched string, this is the case
3464 -- we are looking for.
3466 if Src (Loc) in Line_Terminator
3467 or else Src (Loc) = ' '
3468 or else Src (Loc) = ASCII.HT
3469 or else Src (Loc) = ';'
3470 then
3471 -- So output source lines up to and including this one
3473 Write_Source_Lines (L);
3474 return;
3475 end if;
3476 end if;
3478 Loc := Loc + 1;
3479 end loop;
3480 end if;
3482 -- Line was all blanks, or a comment line, keep looking
3484 end loop;
3485 end if;
3486 end Write_Corresponding_Source;
3488 -----------------------
3489 -- Write_Discr_Specs --
3490 -----------------------
3492 procedure Write_Discr_Specs (N : Node_Id) is
3493 Specs : List_Id;
3494 Spec : Node_Id;
3496 begin
3497 Specs := Discriminant_Specifications (N);
3499 if Present (Specs) then
3500 Write_Str_With_Col_Check (" (");
3501 Spec := First (Specs);
3503 loop
3504 Sprint_Node (Spec);
3505 Next (Spec);
3506 exit when Spec = Empty;
3508 -- Add semicolon, unless we are printing original tree and the
3509 -- next specification is part of a list (but not the first
3510 -- element of that list)
3512 if not Dump_Original_Only or else not Prev_Ids (Spec) then
3513 Write_Str ("; ");
3514 end if;
3515 end loop;
3517 Write_Char (')');
3518 end if;
3519 end Write_Discr_Specs;
3521 -----------------
3522 -- Write_Ekind --
3523 -----------------
3525 procedure Write_Ekind (E : Entity_Id) is
3526 S : constant String := Entity_Kind'Image (Ekind (E));
3528 begin
3529 Name_Len := S'Length;
3530 Name_Buffer (1 .. Name_Len) := S;
3531 Set_Casing (Mixed_Case);
3532 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3533 end Write_Ekind;
3535 --------------
3536 -- Write_Id --
3537 --------------
3539 procedure Write_Id (N : Node_Id) is
3540 begin
3541 -- Deal with outputting Itype
3543 -- Note: if we are printing the full tree with -gnatds, then we may
3544 -- end up picking up the Associated_Node link from a generic template
3545 -- here which overlaps the Entity field, but as documented, Write_Itype
3546 -- is defended against junk calls.
3548 if Nkind (N) in N_Entity then
3549 Write_Itype (N);
3550 elsif Nkind (N) in N_Has_Entity then
3551 Write_Itype (Entity (N));
3552 end if;
3554 -- Case of a defining identifier
3556 if Nkind (N) = N_Defining_Identifier then
3558 -- If defining identifier has an interface name (and no
3559 -- address clause), then we output the interface name.
3561 if (Is_Imported (N) or else Is_Exported (N))
3562 and then Present (Interface_Name (N))
3563 and then No (Address_Clause (N))
3564 then
3565 String_To_Name_Buffer (Strval (Interface_Name (N)));
3566 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3568 -- If no interface name (or inactive because there was
3569 -- an address clause), then just output the Chars name.
3571 else
3572 Write_Name_With_Col_Check (Chars (N));
3573 end if;
3575 -- Case of selector of an expanded name where the expanded name
3576 -- has an associated entity, output this entity. Check that the
3577 -- entity or associated node is of the right kind, see above.
3579 elsif Nkind (Parent (N)) = N_Expanded_Name
3580 and then Selector_Name (Parent (N)) = N
3581 and then Present (Entity_Or_Associated_Node (Parent (N)))
3582 and then Nkind (Entity (Parent (N))) in N_Entity
3583 then
3584 Write_Id (Entity (Parent (N)));
3586 -- For any other node with an associated entity, output it
3588 elsif Nkind (N) in N_Has_Entity
3589 and then Present (Entity_Or_Associated_Node (N))
3590 and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
3591 then
3592 Write_Id (Entity (N));
3594 -- All other cases, we just print the Chars field
3596 else
3597 Write_Name_With_Col_Check (Chars (N));
3598 end if;
3599 end Write_Id;
3601 -----------------------
3602 -- Write_Identifiers --
3603 -----------------------
3605 function Write_Identifiers (Node : Node_Id) return Boolean is
3606 begin
3607 Sprint_Node (Defining_Identifier (Node));
3608 Update_Itype (Defining_Identifier (Node));
3610 -- The remainder of the declaration must be printed unless we are
3611 -- printing the original tree and this is not the last identifier
3613 return
3614 not Dump_Original_Only or else not More_Ids (Node);
3616 end Write_Identifiers;
3618 ------------------------
3619 -- Write_Implicit_Def --
3620 ------------------------
3622 procedure Write_Implicit_Def (E : Entity_Id) is
3623 Ind : Node_Id;
3625 begin
3626 case Ekind (E) is
3627 when E_Array_Subtype =>
3628 Write_Str_With_Col_Check ("subtype ");
3629 Write_Id (E);
3630 Write_Str_With_Col_Check (" is ");
3631 Write_Id (Base_Type (E));
3632 Write_Str_With_Col_Check (" (");
3634 Ind := First_Index (E);
3635 while Present (Ind) loop
3636 Sprint_Node (Ind);
3637 Next_Index (Ind);
3639 if Present (Ind) then
3640 Write_Str (", ");
3641 end if;
3642 end loop;
3644 Write_Str (");");
3646 when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
3647 Write_Str_With_Col_Check ("subtype ");
3648 Write_Id (E);
3649 Write_Str (" is ");
3650 Write_Id (Etype (E));
3651 Write_Str_With_Col_Check (" range ");
3652 Sprint_Node (Scalar_Range (E));
3653 Write_Str (";");
3655 when others =>
3656 Write_Str_With_Col_Check ("type ");
3657 Write_Id (E);
3658 Write_Str_With_Col_Check (" is <");
3659 Write_Ekind (E);
3660 Write_Str (">;");
3661 end case;
3663 end Write_Implicit_Def;
3665 ------------------
3666 -- Write_Indent --
3667 ------------------
3669 procedure Write_Indent is
3670 Loc : constant Source_Ptr := Sloc (Dump_Node);
3672 begin
3673 if Indent_Annull_Flag then
3674 Indent_Annull_Flag := False;
3675 else
3676 -- Deal with Dump_Source_Text output. Note that we ignore implicit
3677 -- label declarations, since they typically have the sloc of the
3678 -- corresponding label, which really messes up the -gnatL output.
3680 if Dump_Source_Text
3681 and then Loc > No_Location
3682 and then Nkind (Dump_Node) /= N_Implicit_Label_Declaration
3683 then
3684 if Get_Source_File_Index (Loc) = Current_Source_File then
3685 Write_Source_Lines
3686 (Get_Physical_Line_Number (Sloc (Dump_Node)));
3687 end if;
3688 end if;
3690 Write_Eol;
3692 for J in 1 .. Indent loop
3693 Write_Char (' ');
3694 end loop;
3695 end if;
3696 end Write_Indent;
3698 ------------------------------
3699 -- Write_Indent_Identifiers --
3700 ------------------------------
3702 function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3703 begin
3704 -- We need to start a new line for every node, except in the case
3705 -- where we are printing the original tree and this is not the first
3706 -- defining identifier in the list.
3708 if not Dump_Original_Only or else not Prev_Ids (Node) then
3709 Write_Indent;
3711 -- If printing original tree and this is not the first defining
3712 -- identifier in the list, then the previous call to this procedure
3713 -- printed only the name, and we add a comma to separate the names.
3715 else
3716 Write_Str (", ");
3717 end if;
3719 Sprint_Node (Defining_Identifier (Node));
3721 -- The remainder of the declaration must be printed unless we are
3722 -- printing the original tree and this is not the last identifier
3724 return
3725 not Dump_Original_Only or else not More_Ids (Node);
3726 end Write_Indent_Identifiers;
3728 -----------------------------------
3729 -- Write_Indent_Identifiers_Sloc --
3730 -----------------------------------
3732 function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3733 begin
3734 -- We need to start a new line for every node, except in the case
3735 -- where we are printing the original tree and this is not the first
3736 -- defining identifier in the list.
3738 if not Dump_Original_Only or else not Prev_Ids (Node) then
3739 Write_Indent;
3741 -- If printing original tree and this is not the first defining
3742 -- identifier in the list, then the previous call to this procedure
3743 -- printed only the name, and we add a comma to separate the names.
3745 else
3746 Write_Str (", ");
3747 end if;
3749 Set_Debug_Sloc;
3750 Sprint_Node (Defining_Identifier (Node));
3752 -- The remainder of the declaration must be printed unless we are
3753 -- printing the original tree and this is not the last identifier
3755 return not Dump_Original_Only or else not More_Ids (Node);
3756 end Write_Indent_Identifiers_Sloc;
3758 ----------------------
3759 -- Write_Indent_Str --
3760 ----------------------
3762 procedure Write_Indent_Str (S : String) is
3763 begin
3764 Write_Corresponding_Source (S);
3765 Write_Indent;
3766 Write_Str (S);
3767 end Write_Indent_Str;
3769 ---------------------------
3770 -- Write_Indent_Str_Sloc --
3771 ---------------------------
3773 procedure Write_Indent_Str_Sloc (S : String) is
3774 begin
3775 Write_Corresponding_Source (S);
3776 Write_Indent;
3777 Write_Str_Sloc (S);
3778 end Write_Indent_Str_Sloc;
3780 -----------------
3781 -- Write_Itype --
3782 -----------------
3784 procedure Write_Itype (Typ : Entity_Id) is
3786 procedure Write_Header (T : Boolean := True);
3787 -- Write type if T is True, subtype if T is false
3789 ------------------
3790 -- Write_Header --
3791 ------------------
3793 procedure Write_Header (T : Boolean := True) is
3794 begin
3795 if T then
3796 Write_Str ("[type ");
3797 else
3798 Write_Str ("[subtype ");
3799 end if;
3801 Write_Name_With_Col_Check (Chars (Typ));
3802 Write_Str (" is ");
3803 end Write_Header;
3805 -- Start of processing for Write_Itype
3807 begin
3808 if Nkind (Typ) in N_Entity
3809 and then Is_Itype (Typ)
3810 and then not Itype_Printed (Typ)
3811 then
3812 -- Itype to be printed
3814 declare
3815 B : constant Node_Id := Etype (Typ);
3816 X : Node_Id;
3817 P : constant Node_Id := Parent (Typ);
3819 S : constant Saved_Output_Buffer := Save_Output_Buffer;
3820 -- Save current output buffer
3822 Old_Sloc : Source_Ptr;
3823 -- Save sloc of related node, so it is not modified when
3824 -- printing with -gnatD.
3826 begin
3827 -- Write indentation at start of line
3829 for J in 1 .. Indent loop
3830 Write_Char (' ');
3831 end loop;
3833 -- If we have a constructed declaration for the itype, print it
3835 if Present (P)
3836 and then Nkind (P) in N_Declaration
3837 and then Defining_Entity (P) = Typ
3838 then
3839 -- We must set Itype_Printed true before the recursive call to
3840 -- print the node, otherwise we get an infinite recursion!
3842 Set_Itype_Printed (Typ, True);
3844 -- Write the declaration enclosed in [], avoiding new line
3845 -- at start of declaration, and semicolon at end.
3847 -- Note: The itype may be imported from another unit, in which
3848 -- case we do not want to modify the Sloc of the declaration.
3849 -- Otherwise the itype may appear to be in the current unit,
3850 -- and the back-end will reject a reference out of scope.
3852 Write_Char ('[');
3853 Indent_Annull_Flag := True;
3854 Old_Sloc := Sloc (P);
3855 Sprint_Node (P);
3856 Set_Sloc (P, Old_Sloc);
3857 Write_Erase_Char (';');
3859 -- If no constructed declaration, then we have to concoct the
3860 -- source corresponding to the type entity that we have at hand.
3862 else
3863 case Ekind (Typ) is
3865 -- Access types and subtypes
3867 when Access_Kind =>
3868 Write_Header (Ekind (Typ) = E_Access_Type);
3870 if Can_Never_Be_Null (Typ) then
3871 Write_Str ("not null ");
3872 end if;
3874 Write_Str ("access ");
3876 if Is_Access_Constant (Typ) then
3877 Write_Str ("constant ");
3878 end if;
3880 Write_Id (Directly_Designated_Type (Typ));
3882 -- Array types and string types
3884 when E_Array_Type | E_String_Type =>
3885 Write_Header;
3886 Write_Str ("array (");
3888 X := First_Index (Typ);
3889 loop
3890 Sprint_Node (X);
3892 if not Is_Constrained (Typ) then
3893 Write_Str (" range <>");
3894 end if;
3896 Next_Index (X);
3897 exit when No (X);
3898 Write_Str (", ");
3899 end loop;
3901 Write_Str (") of ");
3902 X := Component_Type (Typ);
3904 -- Preserve sloc of component type, which is defined
3905 -- elsewhere than the itype (see comment above).
3907 Old_Sloc := Sloc (X);
3908 Sprint_Node (X);
3909 Set_Sloc (X, Old_Sloc);
3911 -- Array subtypes and string subtypes.
3912 -- Preserve Sloc of index subtypes, as above.
3914 when E_Array_Subtype | E_String_Subtype =>
3915 Write_Header (False);
3916 Write_Id (Etype (Typ));
3917 Write_Str (" (");
3919 X := First_Index (Typ);
3920 loop
3921 Old_Sloc := Sloc (X);
3922 Sprint_Node (X);
3923 Set_Sloc (X, Old_Sloc);
3924 Next_Index (X);
3925 exit when No (X);
3926 Write_Str (", ");
3927 end loop;
3929 Write_Char (')');
3931 -- Signed integer types, and modular integer subtypes,
3932 -- and also enumeration subtypes.
3934 when E_Signed_Integer_Type |
3935 E_Signed_Integer_Subtype |
3936 E_Modular_Integer_Subtype |
3937 E_Enumeration_Subtype =>
3939 Write_Header (Ekind (Typ) = E_Signed_Integer_Type);
3941 if Ekind (Typ) = E_Signed_Integer_Type then
3942 Write_Str ("new ");
3943 end if;
3945 Write_Id (B);
3947 -- Print bounds if different from base type
3949 declare
3950 L : constant Node_Id := Type_Low_Bound (Typ);
3951 H : constant Node_Id := Type_High_Bound (Typ);
3952 LE : Node_Id;
3953 HE : Node_Id;
3955 begin
3956 -- B can either be a scalar type, in which case the
3957 -- declaration of Typ may constrain it with different
3958 -- bounds, or a private type, in which case we know
3959 -- that the declaration of Typ cannot have a scalar
3960 -- constraint.
3962 if Is_Scalar_Type (B) then
3963 LE := Type_Low_Bound (B);
3964 HE := Type_High_Bound (B);
3965 else
3966 LE := Empty;
3967 HE := Empty;
3968 end if;
3970 if No (LE)
3971 or else (True
3972 and then Nkind (L) = N_Integer_Literal
3973 and then Nkind (H) = N_Integer_Literal
3974 and then Nkind (LE) = N_Integer_Literal
3975 and then Nkind (HE) = N_Integer_Literal
3976 and then UI_Eq (Intval (L), Intval (LE))
3977 and then UI_Eq (Intval (H), Intval (HE)))
3978 then
3979 null;
3981 else
3982 Write_Str (" range ");
3983 Sprint_Node (Type_Low_Bound (Typ));
3984 Write_Str (" .. ");
3985 Sprint_Node (Type_High_Bound (Typ));
3986 end if;
3987 end;
3989 -- Modular integer types
3991 when E_Modular_Integer_Type =>
3992 Write_Header;
3993 Write_Str (" mod ");
3994 Write_Uint_With_Col_Check (Modulus (Typ), Auto);
3996 -- Floating point types and subtypes
3998 when E_Floating_Point_Type |
3999 E_Floating_Point_Subtype =>
4001 Write_Header (Ekind (Typ) = E_Floating_Point_Type);
4003 if Ekind (Typ) = E_Floating_Point_Type then
4004 Write_Str ("new ");
4005 end if;
4007 Write_Id (Etype (Typ));
4009 if Digits_Value (Typ) /= Digits_Value (Etype (Typ)) then
4010 Write_Str (" digits ");
4011 Write_Uint_With_Col_Check
4012 (Digits_Value (Typ), Decimal);
4013 end if;
4015 -- Print bounds if not different from base type
4017 declare
4018 L : constant Node_Id := Type_Low_Bound (Typ);
4019 H : constant Node_Id := Type_High_Bound (Typ);
4020 LE : constant Node_Id := Type_Low_Bound (B);
4021 HE : constant Node_Id := Type_High_Bound (B);
4023 begin
4024 if Nkind (L) = N_Real_Literal
4025 and then Nkind (H) = N_Real_Literal
4026 and then Nkind (LE) = N_Real_Literal
4027 and then Nkind (HE) = N_Real_Literal
4028 and then UR_Eq (Realval (L), Realval (LE))
4029 and then UR_Eq (Realval (H), Realval (HE))
4030 then
4031 null;
4033 else
4034 Write_Str (" range ");
4035 Sprint_Node (Type_Low_Bound (Typ));
4036 Write_Str (" .. ");
4037 Sprint_Node (Type_High_Bound (Typ));
4038 end if;
4039 end;
4041 -- Record subtypes
4043 when E_Record_Subtype =>
4044 Write_Header (False);
4045 Write_Str ("record");
4046 Indent_Begin;
4048 declare
4049 C : Entity_Id;
4050 begin
4051 C := First_Entity (Typ);
4052 while Present (C) loop
4053 Write_Indent;
4054 Write_Id (C);
4055 Write_Str (" : ");
4056 Write_Id (Etype (C));
4057 Next_Entity (C);
4058 end loop;
4059 end;
4061 Indent_End;
4062 Write_Indent_Str (" end record");
4064 -- Class-Wide types
4066 when E_Class_Wide_Type |
4067 E_Class_Wide_Subtype =>
4068 Write_Header;
4069 Write_Name_With_Col_Check (Chars (Etype (Typ)));
4070 Write_Str ("'Class");
4072 -- Subprogram types
4074 when E_Subprogram_Type =>
4075 Write_Header;
4077 if Etype (Typ) = Standard_Void_Type then
4078 Write_Str ("procedure");
4079 else
4080 Write_Str ("function");
4081 end if;
4083 if Present (First_Entity (Typ)) then
4084 Write_Str (" (");
4086 declare
4087 Param : Entity_Id;
4089 begin
4090 Param := First_Entity (Typ);
4091 loop
4092 Write_Id (Param);
4093 Write_Str (" : ");
4095 if Ekind (Param) = E_In_Out_Parameter then
4096 Write_Str ("in out ");
4097 elsif Ekind (Param) = E_Out_Parameter then
4098 Write_Str ("out ");
4099 end if;
4101 Write_Id (Etype (Param));
4102 Next_Entity (Param);
4103 exit when No (Param);
4104 Write_Str (", ");
4105 end loop;
4107 Write_Char (')');
4108 end;
4109 end if;
4111 if Etype (Typ) /= Standard_Void_Type then
4112 Write_Str (" return ");
4113 Write_Id (Etype (Typ));
4114 end if;
4116 when E_String_Literal_Subtype =>
4117 declare
4118 LB : constant Uint :=
4119 Expr_Value (String_Literal_Low_Bound (Typ));
4120 Len : constant Uint :=
4121 String_Literal_Length (Typ);
4122 begin
4123 Write_Str ("String (");
4124 Write_Int (UI_To_Int (LB));
4125 Write_Str (" .. ");
4126 Write_Int (UI_To_Int (LB + Len) - 1);
4127 Write_Str (");");
4128 end;
4130 -- For all other Itypes, print ??? (fill in later)
4132 when others =>
4133 Write_Header (True);
4134 Write_Str ("???");
4136 end case;
4137 end if;
4139 -- Add terminating bracket and restore output buffer
4141 Write_Char (']');
4142 Write_Eol;
4143 Restore_Output_Buffer (S);
4144 end;
4146 Set_Itype_Printed (Typ);
4147 end if;
4148 end Write_Itype;
4150 -------------------------------
4151 -- Write_Name_With_Col_Check --
4152 -------------------------------
4154 procedure Write_Name_With_Col_Check (N : Name_Id) is
4155 J : Natural;
4156 K : Natural;
4157 L : Natural;
4159 begin
4160 Get_Name_String (N);
4162 -- Deal with -gnatdI which replaces any sequence Cnnnb where C is an
4163 -- upper case letter, nnn is one or more digits and b is a lower case
4164 -- letter by C...b, so that listings do not depend on serial numbers.
4166 if Debug_Flag_II then
4167 J := 1;
4168 while J < Name_Len - 1 loop
4169 if Name_Buffer (J) in 'A' .. 'Z'
4170 and then Name_Buffer (J + 1) in '0' .. '9'
4171 then
4172 K := J + 1;
4173 while K < Name_Len loop
4174 exit when Name_Buffer (K) not in '0' .. '9';
4175 K := K + 1;
4176 end loop;
4178 if Name_Buffer (K) in 'a' .. 'z' then
4179 L := Name_Len - K + 1;
4181 Name_Buffer (J + 4 .. J + L + 3) :=
4182 Name_Buffer (K .. Name_Len);
4183 Name_Buffer (J + 1 .. J + 3) := "...";
4184 Name_Len := J + L + 3;
4185 J := J + 5;
4187 else
4188 J := K;
4189 end if;
4191 else
4192 J := J + 1;
4193 end if;
4194 end loop;
4195 end if;
4197 -- Fall through for normal case
4199 Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
4200 end Write_Name_With_Col_Check;
4202 ------------------------------------
4203 -- Write_Name_With_Col_Check_Sloc --
4204 ------------------------------------
4206 procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
4207 begin
4208 Get_Name_String (N);
4209 Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
4210 end Write_Name_With_Col_Check_Sloc;
4212 --------------------
4213 -- Write_Operator --
4214 --------------------
4216 procedure Write_Operator (N : Node_Id; S : String) is
4217 F : Natural := S'First;
4218 T : Natural := S'Last;
4220 begin
4221 -- If no overflow check, just write string out, and we are done
4223 if not Do_Overflow_Check (N) then
4224 Write_Str_Sloc (S);
4226 -- If overflow check, we want to surround the operator with curly
4227 -- brackets, but not include spaces within the brackets.
4229 else
4230 if S (F) = ' ' then
4231 Write_Char (' ');
4232 F := F + 1;
4233 end if;
4235 if S (T) = ' ' then
4236 T := T - 1;
4237 end if;
4239 Write_Char ('{');
4240 Write_Str_Sloc (S (F .. T));
4241 Write_Char ('}');
4243 if S (S'Last) = ' ' then
4244 Write_Char (' ');
4245 end if;
4246 end if;
4247 end Write_Operator;
4249 -----------------------
4250 -- Write_Param_Specs --
4251 -----------------------
4253 procedure Write_Param_Specs (N : Node_Id) is
4254 Specs : List_Id;
4255 Spec : Node_Id;
4256 Formal : Node_Id;
4258 begin
4259 Specs := Parameter_Specifications (N);
4261 if Is_Non_Empty_List (Specs) then
4262 Write_Str_With_Col_Check (" (");
4263 Spec := First (Specs);
4265 loop
4266 Sprint_Node (Spec);
4267 Formal := Defining_Identifier (Spec);
4268 Next (Spec);
4269 exit when Spec = Empty;
4271 -- Add semicolon, unless we are printing original tree and the
4272 -- next specification is part of a list (but not the first element
4273 -- of that list).
4275 if not Dump_Original_Only or else not Prev_Ids (Spec) then
4276 Write_Str ("; ");
4277 end if;
4278 end loop;
4280 -- Write out any extra formals
4282 while Present (Extra_Formal (Formal)) loop
4283 Formal := Extra_Formal (Formal);
4284 Write_Str ("; ");
4285 Write_Name_With_Col_Check (Chars (Formal));
4286 Write_Str (" : ");
4287 Write_Name_With_Col_Check (Chars (Etype (Formal)));
4288 end loop;
4290 Write_Char (')');
4291 end if;
4292 end Write_Param_Specs;
4294 -----------------------
4295 -- Write_Rewrite_Str --
4296 -----------------------
4298 procedure Write_Rewrite_Str (S : String) is
4299 begin
4300 if not Dump_Generated_Only then
4301 if S'Length = 3 and then S = ">>>" then
4302 Write_Str (">>>");
4303 else
4304 Write_Str_With_Col_Check (S);
4305 end if;
4306 end if;
4307 end Write_Rewrite_Str;
4309 -----------------------
4310 -- Write_Source_Line --
4311 -----------------------
4313 procedure Write_Source_Line (L : Physical_Line_Number) is
4314 Loc : Source_Ptr;
4315 Src : Source_Buffer_Ptr;
4316 Scn : Source_Ptr;
4318 begin
4319 if Dump_Source_Text then
4320 Src := Source_Text (Current_Source_File);
4321 Loc := Line_Start (L, Current_Source_File);
4322 Write_Eol;
4324 -- See if line is a comment line, if not, and if not line one,
4325 -- precede with blank line.
4327 Scn := Loc;
4328 while Src (Scn) = ' ' or else Src (Scn) = ASCII.HT loop
4329 Scn := Scn + 1;
4330 end loop;
4332 if (Src (Scn) in Line_Terminator
4333 or else Src (Scn .. Scn + 1) /= "--")
4334 and then L /= 1
4335 then
4336 Write_Eol;
4337 end if;
4339 -- Now write the source text of the line
4341 Write_Str ("-- ");
4342 Write_Int (Int (L));
4343 Write_Str (": ");
4345 while Src (Loc) not in Line_Terminator loop
4346 Write_Char (Src (Loc));
4347 Loc := Loc + 1;
4348 end loop;
4349 end if;
4350 end Write_Source_Line;
4352 ------------------------
4353 -- Write_Source_Lines --
4354 ------------------------
4356 procedure Write_Source_Lines (L : Physical_Line_Number) is
4357 begin
4358 while Last_Line_Printed < L loop
4359 Last_Line_Printed := Last_Line_Printed + 1;
4360 Write_Source_Line (Last_Line_Printed);
4361 end loop;
4362 end Write_Source_Lines;
4364 --------------------
4365 -- Write_Str_Sloc --
4366 --------------------
4368 procedure Write_Str_Sloc (S : String) is
4369 begin
4370 for J in S'Range loop
4371 Write_Char_Sloc (S (J));
4372 end loop;
4373 end Write_Str_Sloc;
4375 ------------------------------
4376 -- Write_Str_With_Col_Check --
4377 ------------------------------
4379 procedure Write_Str_With_Col_Check (S : String) is
4380 begin
4381 if Int (S'Last) + Column > Sprint_Line_Limit then
4382 Write_Indent_Str (" ");
4384 if S (S'First) = ' ' then
4385 Write_Str (S (S'First + 1 .. S'Last));
4386 else
4387 Write_Str (S);
4388 end if;
4390 else
4391 Write_Str (S);
4392 end if;
4393 end Write_Str_With_Col_Check;
4395 -----------------------------------
4396 -- Write_Str_With_Col_Check_Sloc --
4397 -----------------------------------
4399 procedure Write_Str_With_Col_Check_Sloc (S : String) is
4400 begin
4401 if Int (S'Last) + Column > Sprint_Line_Limit then
4402 Write_Indent_Str (" ");
4404 if S (S'First) = ' ' then
4405 Write_Str_Sloc (S (S'First + 1 .. S'Last));
4406 else
4407 Write_Str_Sloc (S);
4408 end if;
4410 else
4411 Write_Str_Sloc (S);
4412 end if;
4413 end Write_Str_With_Col_Check_Sloc;
4415 ---------------------------
4416 -- Write_Subprogram_Name --
4417 ---------------------------
4419 procedure Write_Subprogram_Name (N : Node_Id) is
4420 begin
4421 if not Comes_From_Source (N)
4422 and then Is_Entity_Name (N)
4423 then
4424 declare
4425 Ent : constant Entity_Id := Entity (N);
4426 begin
4427 if not In_Extended_Main_Source_Unit (Ent)
4428 and then
4429 Is_Predefined_File_Name
4430 (Unit_File_Name (Get_Source_Unit (Ent)))
4431 then
4432 -- Run-time routine name, output name with a preceding dollar
4433 -- making sure that we do not get a line split between them.
4435 Col_Check (Length_Of_Name (Chars (Ent)) + 1);
4436 Write_Char ('$');
4437 Write_Name (Chars (Ent));
4438 return;
4439 end if;
4440 end;
4441 end if;
4443 -- Normal case, not a run-time routine name
4445 Sprint_Node (N);
4446 end Write_Subprogram_Name;
4448 -------------------------------
4449 -- Write_Uint_With_Col_Check --
4450 -------------------------------
4452 procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format) is
4453 begin
4454 Col_Check (UI_Decimal_Digits_Hi (U));
4455 UI_Write (U, Format);
4456 end Write_Uint_With_Col_Check;
4458 ------------------------------------
4459 -- Write_Uint_With_Col_Check_Sloc --
4460 ------------------------------------
4462 procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
4463 begin
4464 Col_Check (UI_Decimal_Digits_Hi (U));
4465 Set_Debug_Sloc;
4466 UI_Write (U, Format);
4467 end Write_Uint_With_Col_Check_Sloc;
4469 -------------------------------------
4470 -- Write_Ureal_With_Col_Check_Sloc --
4471 -------------------------------------
4473 procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
4474 D : constant Uint := Denominator (U);
4475 N : constant Uint := Numerator (U);
4476 begin
4477 Col_Check (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
4478 Set_Debug_Sloc;
4479 UR_Write (U, Brackets => True);
4480 end Write_Ureal_With_Col_Check_Sloc;
4482 end Sprint;