| 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-2025, 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 |
------------------------------------------------------------------------------ |
| 25 |
|
| 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 Einfo.Entities; use Einfo.Entities; |
| 33 |
with Einfo.Utils; use Einfo.Utils; |
| 34 |
with Lib; use Lib; |
| 35 |
with Namet; use Namet; |
| 36 |
with Nlists; use Nlists; |
| 37 |
with Opt; use Opt; |
| 38 |
with Output; use Output; |
| 39 |
with Rtsfind; use Rtsfind; |
| 40 |
with Sem_Eval; use Sem_Eval; |
| 41 |
with Sem_Util; use Sem_Util; |
| 42 |
with Sinfo; use Sinfo; |
| 43 |
with Sinfo.Nodes; use Sinfo.Nodes; |
| 44 |
with Sinfo.Utils; use Sinfo.Utils; |
| 45 |
with Sinput; use Sinput; |
| 46 |
with Sinput.D; use Sinput.D; |
| 47 |
with Snames; use Snames; |
| 48 |
with Stand; use Stand; |
| 49 |
with Stringt; use Stringt; |
| 50 |
with Uintp; use Uintp; |
| 51 |
with Uname; use Uname; |
| 52 |
with Urealp; use Urealp; |
| 53 |
|
| 54 |
package body Sprint is |
| 55 |
Current_Source_File : Source_File_Index; |
| 56 |
-- Index of source file whose generated code is being dumped |
| 57 |
|
| 58 |
Dump_Node : Node_Id := Empty; |
| 59 |
-- This is set to the current node, used for printing line numbers. In |
| 60 |
-- Debug_Generated_Code mode, Dump_Node is set to the current node |
| 61 |
-- requiring Sloc fixup, until Set_Debug_Sloc is called to set the proper |
| 62 |
-- value. The call clears it back to Empty. |
| 63 |
|
| 64 |
First_Debug_Sloc : Source_Ptr; |
| 65 |
-- Sloc of first byte of the current output file if we are generating a |
| 66 |
-- source debug file. |
| 67 |
|
| 68 |
Debug_Sloc : Source_Ptr; |
| 69 |
-- Sloc of first byte of line currently being written if we are |
| 70 |
-- generating a source debug file. |
| 71 |
|
| 72 |
Dump_Original_Only : Boolean; |
| 73 |
-- Set True if the -gnatdo (dump original tree) flag is set |
| 74 |
|
| 75 |
Dump_Generated_Only : Boolean; |
| 76 |
-- Set True if the -gnatdG (dump generated tree) debug flag is set |
| 77 |
-- or for Print_Generated_Code (-gnatG) or Dump_Generated_Code (-gnatD). |
| 78 |
|
| 79 |
Dump_Freeze_Null : Boolean; |
| 80 |
-- Set True if empty freeze nodes and non-source null statements output. |
| 81 |
-- Note that freeze nodes containing freeze actions are always output, |
| 82 |
-- as are freeze nodes for itypes, which in general have the effect of |
| 83 |
-- causing elaboration of the itype. |
| 84 |
|
| 85 |
Freeze_Indent : Int := 0; |
| 86 |
-- Keep track of freeze indent level (controls output of blank lines before |
| 87 |
-- procedures within expression freeze actions). Relevant only if we are |
| 88 |
-- not in Dump_Source_Text mode, since in Dump_Source_Text mode we don't |
| 89 |
-- output these blank lines in any case. |
| 90 |
|
| 91 |
Indent : Int := 0; |
| 92 |
-- Number of columns for current line output indentation |
| 93 |
|
| 94 |
Indent_Annull_Flag : Boolean := False; |
| 95 |
-- Set True if subsequent Write_Indent call to be ignored, gets reset |
| 96 |
-- by this call, so it is only active to suppress a single indent call. |
| 97 |
|
| 98 |
Last_Line_Printed : Physical_Line_Number; |
| 99 |
-- This keeps track of the physical line number of the last source line |
| 100 |
-- that has been output. The value is only valid in Dump_Source_Text mode. |
| 101 |
|
| 102 |
------------------------------- |
| 103 |
-- Operator Precedence Table -- |
| 104 |
------------------------------- |
| 105 |
|
| 106 |
-- This table is used to decide whether a subexpression needs to be |
| 107 |
-- parenthesized. The rule is that if an operand of an operator (which |
| 108 |
-- for this purpose includes AND THEN and OR ELSE) is itself an operator |
| 109 |
-- with a lower precedence than the operator (or equal precedence if |
| 110 |
-- appearing as the right operand), then parentheses are required. |
| 111 |
|
| 112 |
Op_Prec : constant array (N_Subexpr) of Short_Short_Integer := |
| 113 |
(N_Op_And => 1, |
| 114 |
N_Op_Or => 1, |
| 115 |
N_Op_Xor => 1, |
| 116 |
N_And_Then => 1, |
| 117 |
N_Or_Else => 1, |
| 118 |
|
| 119 |
N_In => 2, |
| 120 |
N_Not_In => 2, |
| 121 |
N_Op_Eq => 2, |
| 122 |
N_Op_Ge => 2, |
| 123 |
N_Op_Gt => 2, |
| 124 |
N_Op_Le => 2, |
| 125 |
N_Op_Lt => 2, |
| 126 |
N_Op_Ne => 2, |
| 127 |
|
| 128 |
N_Op_Add => 3, |
| 129 |
N_Op_Concat => 3, |
| 130 |
N_Op_Subtract => 3, |
| 131 |
N_Op_Plus => 3, |
| 132 |
N_Op_Minus => 3, |
| 133 |
|
| 134 |
N_Op_Divide => 4, |
| 135 |
N_Op_Mod => 4, |
| 136 |
N_Op_Rem => 4, |
| 137 |
N_Op_Multiply => 4, |
| 138 |
|
| 139 |
N_Op_Expon => 5, |
| 140 |
N_Op_Abs => 5, |
| 141 |
N_Op_Not => 5, |
| 142 |
|
| 143 |
others => 6); |
| 144 |
|
| 145 |
procedure Sprint_Left_Opnd (N : Node_Id); |
| 146 |
-- Print left operand of operator, parenthesizing if necessary |
| 147 |
|
| 148 |
procedure Sprint_Right_Opnd (N : Node_Id); |
| 149 |
-- Print right operand of operator, parenthesizing if necessary |
| 150 |
|
| 151 |
----------------------- |
| 152 |
-- Local Subprograms -- |
| 153 |
----------------------- |
| 154 |
|
| 155 |
procedure Col_Check (N : Nat); |
| 156 |
-- Check that at least N characters remain on current line, and if not, |
| 157 |
-- then start an extra line with two characters extra indentation for |
| 158 |
-- continuing text on the next line. |
| 159 |
|
| 160 |
procedure Extra_Blank_Line; |
| 161 |
-- In some situations we write extra blank lines to separate the generated |
| 162 |
-- code to make it more readable. However, these extra blank lines are not |
| 163 |
-- generated in Dump_Source_Text mode, since there the source text lines |
| 164 |
-- output with preceding blank lines are quite sufficient as separators. |
| 165 |
-- This procedure writes a blank line if Dump_Source_Text is False. |
| 166 |
|
| 167 |
procedure Indent_Annull; |
| 168 |
-- Causes following call to Write_Indent to be ignored. This is used when |
| 169 |
-- a higher level node wants to stop a lower level node from starting a |
| 170 |
-- new line, when it would otherwise be inclined to do so (e.g. the case |
| 171 |
-- of an accept statement called from an accept alternative with a guard) |
| 172 |
|
| 173 |
procedure Indent_Begin; |
| 174 |
-- Increase indentation level |
| 175 |
|
| 176 |
procedure Indent_End; |
| 177 |
-- Decrease indentation level |
| 178 |
|
| 179 |
procedure Print_Debug_Line (S : String); |
| 180 |
-- Used to print output lines in Debug_Generated_Code mode (this is used |
| 181 |
-- as the argument for a call to Set_Special_Output in package Output). |
| 182 |
|
| 183 |
procedure Set_Debug_Sloc; |
| 184 |
-- If Dump_Node is non-empty, this routine sets the appropriate value |
| 185 |
-- in its Sloc field, from the current location in the debug source file |
| 186 |
-- that is currently being written. |
| 187 |
|
| 188 |
procedure Sprint_And_List (List : List_Id); |
| 189 |
-- Print the given list with items separated by vertical "and" |
| 190 |
|
| 191 |
procedure Sprint_Aspect_Specifications |
| 192 |
(Node : Node_Id; |
| 193 |
Semicolon : Boolean); |
| 194 |
-- Node is a declaration node that has aspect specifications (Has_Aspects |
| 195 |
-- flag set True). It outputs the aspect specifications. For the case |
| 196 |
-- of Semicolon = True, it is called after outputting the terminating |
| 197 |
-- semicolon for the related node. The effect is to remove the semicolon |
| 198 |
-- and print the aspect specifications followed by a terminating semicolon. |
| 199 |
-- For the case of Semicolon False, no semicolon is removed or output, and |
| 200 |
-- all the aspects are printed on a single line. |
| 201 |
|
| 202 |
procedure Sprint_At_End_Proc (Node : Node_Id); |
| 203 |
-- Print At_End_Proc attribute if present |
| 204 |
|
| 205 |
procedure Sprint_Bar_List (List : List_Id); |
| 206 |
-- Print the given list with items separated by vertical bars |
| 207 |
|
| 208 |
procedure Sprint_End_Label |
| 209 |
(Node : Node_Id; |
| 210 |
Default : Node_Id); |
| 211 |
-- Print the end label for a Handled_Sequence_Of_Statements in a body. |
| 212 |
-- If there is no end label, use the defining identifier of the enclosing |
| 213 |
-- construct. If the end label is present, treat it as a reference to the |
| 214 |
-- defining entity of the construct: this guarantees that it carries the |
| 215 |
-- proper sloc information for debugging purposes. |
| 216 |
|
| 217 |
procedure Sprint_Node_Actual (Node : Node_Id); |
| 218 |
-- This routine prints its node argument. It is a lower level routine than |
| 219 |
-- Sprint_Node, in that it does not bother about rewritten trees. |
| 220 |
|
| 221 |
procedure Sprint_Node_Sloc (Node : Node_Id); |
| 222 |
-- Like Sprint_Node, but in addition, in Debug_Generated_Code mode, |
| 223 |
-- sets the Sloc of the current debug node to be a copy of the Sloc |
| 224 |
-- of the sprinted node Node. Note that this is done after printing |
| 225 |
-- Node, so that the Sloc is the proper updated value for the debug file. |
| 226 |
|
| 227 |
procedure Update_Itype (Node : Node_Id); |
| 228 |
-- Update the Sloc of an itype that is not attached to the tree, when |
| 229 |
-- debugging expanded code. This routine is called from nodes whose |
| 230 |
-- type can be an Itype, such as defining_identifiers that may be of |
| 231 |
-- an anonymous access type, or ranges in slices. |
| 232 |
|
| 233 |
procedure Write_Char_Sloc (C : Character); |
| 234 |
-- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is |
| 235 |
-- called to ensure that the current node has a proper Sloc set. |
| 236 |
|
| 237 |
procedure Write_Condition_And_Reason (Node : Node_Id); |
| 238 |
-- Write Condition and Reason codes of Raise_xxx_Error node |
| 239 |
|
| 240 |
procedure Write_Corresponding_Source (S : String); |
| 241 |
-- If S is a string with a single keyword (possibly followed by a space), |
| 242 |
-- and if the next non-comment non-blank source line matches this keyword, |
| 243 |
-- then output all source lines up to this matching line. |
| 244 |
|
| 245 |
procedure Write_Discr_Specs (N : Node_Id); |
| 246 |
-- Output discriminant specification for node, which is any of the type |
| 247 |
-- declarations that can have discriminants. |
| 248 |
|
| 249 |
procedure Write_Ekind (E : Entity_Id); |
| 250 |
-- Write the String corresponding to the Ekind without "E_" |
| 251 |
|
| 252 |
procedure Write_Id (N : Node_Id); |
| 253 |
-- N is a node with a Chars field. This procedure writes the name that |
| 254 |
-- will be used in the generated code associated with the name. For a |
| 255 |
-- node with no associated entity, this is simply the Chars field. For |
| 256 |
-- the case where there is an entity associated with the node, we print |
| 257 |
-- the name associated with the entity (since it may have been encoded). |
| 258 |
-- One other special case is that an entity has an active external name |
| 259 |
-- (i.e. an external name present with no address clause), then this |
| 260 |
-- external name is output. This procedure also deals with outputting |
| 261 |
-- declarations of referenced itypes, if not output earlier. |
| 262 |
|
| 263 |
function Write_Identifiers (Node : Node_Id) return Boolean; |
| 264 |
-- Handle node where the grammar has a list of defining identifiers, but |
| 265 |
-- the tree has a separate declaration for each identifier. Handles the |
| 266 |
-- printing of the defining identifier, and returns True if the type and |
| 267 |
-- initialization information is to be printed, False if it is to be |
| 268 |
-- skipped (the latter case happens when printing defining identifiers |
| 269 |
-- other than the first in the original tree output case). |
| 270 |
|
| 271 |
procedure Write_Implicit_Def (E : Entity_Id); |
| 272 |
pragma Warnings (Off, Write_Implicit_Def); |
| 273 |
-- Write the definition of the implicit type E according to its Ekind |
| 274 |
-- For now a debugging procedure, but might be used in the future. |
| 275 |
|
| 276 |
procedure Write_Indent; |
| 277 |
-- Start a new line and write indentation spacing |
| 278 |
|
| 279 |
function Write_Indent_Identifiers (Node : Node_Id) return Boolean; |
| 280 |
-- Like Write_Identifiers except that each new printed declaration |
| 281 |
-- is at the start of a new line. |
| 282 |
|
| 283 |
function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean; |
| 284 |
-- Like Write_Indent_Identifiers except that in Debug_Generated_Code |
| 285 |
-- mode, the Sloc of the current debug node is set to point to the |
| 286 |
-- first output identifier. |
| 287 |
|
| 288 |
procedure Write_Indent_Str (S : String); |
| 289 |
-- Start a new line and write indent spacing followed by given string |
| 290 |
|
| 291 |
procedure Write_Indent_Str_Sloc (S : String); |
| 292 |
-- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode, |
| 293 |
-- the Sloc of the current node is set to the first non-blank character |
| 294 |
-- in the string S. |
| 295 |
|
| 296 |
procedure Write_Itype (Typ : Entity_Id); |
| 297 |
-- If Typ is an Itype that has not been written yet, write it. If Typ is |
| 298 |
-- any other kind of entity or tree node, the call is ignored. |
| 299 |
|
| 300 |
procedure Write_Name_With_Col_Check (N : Name_Id); |
| 301 |
-- Write name (using Write_Name) with initial column check, and possible |
| 302 |
-- initial Write_Indent (to get new line) if current line is too full. |
| 303 |
|
| 304 |
procedure Write_Name_With_Col_Check_Sloc (N : Name_Id); |
| 305 |
-- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code |
| 306 |
-- mode, sets Sloc of current debug node to first character of name. |
| 307 |
|
| 308 |
procedure Write_Operator (N : Node_Id; S : String); |
| 309 |
-- Like Write_Str_Sloc, used for operators, encloses the string in |
| 310 |
-- characters {} if the Do_Overflow flag is set on the node N. |
| 311 |
|
| 312 |
procedure Write_Param_Specs (N : Node_Id); |
| 313 |
-- Output parameter specifications for node N (which is a subprogram, or |
| 314 |
-- entry or entry family or access-subprogram-definition, all of which |
| 315 |
-- have a Parameter_Specifications field). |
| 316 |
|
| 317 |
procedure Write_Rewrite_Str (S : String); |
| 318 |
-- Writes out a string (typically containing <<< or >>>}) for a node |
| 319 |
-- created by rewriting the tree. Suppressed if we are outputting the |
| 320 |
-- generated code only, since in this case we don't specially mark nodes |
| 321 |
-- created by rewriting). |
| 322 |
|
| 323 |
procedure Write_Source_Line (L : Physical_Line_Number); |
| 324 |
-- If writing of interspersed source lines is enabled, then write the given |
| 325 |
-- line from the source file, preceded by Eol, then an extra blank line if |
| 326 |
-- the line has at least one blank, is not a comment and is not line one, |
| 327 |
-- then "--" and the line number followed by period followed by text of the |
| 328 |
-- source line (without terminating Eol). If interspersed source line |
| 329 |
-- output not enabled, then the call has no effect. |
| 330 |
|
| 331 |
procedure Write_Source_Lines (L : Physical_Line_Number); |
| 332 |
-- If writing of interspersed source lines is enabled, then writes source |
| 333 |
-- lines Last_Line_Printed + 1 .. L, and updates Last_Line_Printed. If |
| 334 |
-- interspersed source line output not enabled, then call has no effect. |
| 335 |
|
| 336 |
procedure Write_Str_Sloc (S : String); |
| 337 |
-- Like Write_Str, but sets debug Sloc of current debug node to first |
| 338 |
-- non-blank character if a current debug node is active. |
| 339 |
|
| 340 |
procedure Write_Str_With_Col_Check (S : String); |
| 341 |
-- Write string (using Write_Str) with initial column check, and possible |
| 342 |
-- initial Write_Indent (to get new line) if current line is too full. |
| 343 |
|
| 344 |
procedure Write_Str_With_Col_Check_Sloc (S : String); |
| 345 |
-- Like Write_Str_With_Col_Check, but sets debug Sloc of current debug |
| 346 |
-- node to first non-blank character if a current debug node is active. |
| 347 |
|
| 348 |
procedure Write_Subprogram_Name (N : Node_Id); |
| 349 |
-- N is the Name field of a function call or procedure statement call. |
| 350 |
-- The effect of the call is to output the name, preceded by a $ if the |
| 351 |
-- call is identified as an implicit call to a run time routine. |
| 352 |
|
| 353 |
procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format); |
| 354 |
-- Write Uint (using UI_Write) with initial column check, and possible |
| 355 |
-- initial Write_Indent (to get new line) if current line is too full. |
| 356 |
-- The format parameter determines the output format (see UI_Write). |
| 357 |
|
| 358 |
procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format); |
| 359 |
-- Write Uint (using UI_Write) with initial column check, and possible |
| 360 |
-- initial Write_Indent (to get new line) if current line is too full. |
| 361 |
-- The format parameter determines the output format (see UI_Write). |
| 362 |
-- In addition, in Debug_Generated_Code mode, sets the current node |
| 363 |
-- Sloc to the first character of the output value. |
| 364 |
|
| 365 |
procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal); |
| 366 |
-- Write Ureal (using same output format as UR_Write) with column checks |
| 367 |
-- and a possible initial Write_Indent (to get new line) if current line |
| 368 |
-- is too full. In addition, in Debug_Generated_Code mode, sets the |
| 369 |
-- current node Sloc to the first character of the output value. |
| 370 |
|
| 371 |
--------------- |
| 372 |
-- Col_Check -- |
| 373 |
--------------- |
| 374 |
|
| 375 |
procedure Col_Check (N : Nat) is |
| 376 |
begin |
| 377 |
if N + Column > Sprint_Line_Limit then |
| 378 |
Write_Indent_Str (" "); |
| 379 |
end if; |
| 380 |
end Col_Check; |
| 381 |
|
| 382 |
---------------------- |
| 383 |
-- Extra_Blank_Line -- |
| 384 |
---------------------- |
| 385 |
|
| 386 |
procedure Extra_Blank_Line is |
| 387 |
begin |
| 388 |
if not Dump_Source_Text then |
| 389 |
Write_Indent; |
| 390 |
end if; |
| 391 |
end Extra_Blank_Line; |
| 392 |
|
| 393 |
------------------- |
| 394 |
-- Indent_Annull -- |
| 395 |
------------------- |
| 396 |
|
| 397 |
procedure Indent_Annull is |
| 398 |
begin |
| 399 |
Indent_Annull_Flag := True; |
| 400 |
end Indent_Annull; |
| 401 |
|
| 402 |
------------------ |
| 403 |
-- Indent_Begin -- |
| 404 |
------------------ |
| 405 |
|
| 406 |
procedure Indent_Begin is |
| 407 |
begin |
| 408 |
Indent := Indent + 3; |
| 409 |
end Indent_Begin; |
| 410 |
|
| 411 |
---------------- |
| 412 |
-- Indent_End -- |
| 413 |
---------------- |
| 414 |
|
| 415 |
procedure Indent_End is |
| 416 |
begin |
| 417 |
Indent := Indent - 3; |
| 418 |
end Indent_End; |
| 419 |
|
| 420 |
-------- |
| 421 |
-- pg -- |
| 422 |
-------- |
| 423 |
|
| 424 |
procedure pg (Arg : Union_Id) is |
| 425 |
begin |
| 426 |
Dump_Generated_Only := True; |
| 427 |
Dump_Original_Only := False; |
| 428 |
Dump_Freeze_Null := True; |
| 429 |
Current_Source_File := No_Source_File; |
| 430 |
Push_Output; |
| 431 |
Set_Standard_Output; |
| 432 |
|
| 433 |
if Arg in List_Range then |
| 434 |
Sprint_Node_List (List_Id (Arg), New_Lines => True); |
| 435 |
|
| 436 |
elsif Arg in Node_Range then |
| 437 |
Sprint_Node (Node_Id (Arg)); |
| 438 |
|
| 439 |
else |
| 440 |
null; |
| 441 |
end if; |
| 442 |
|
| 443 |
Write_Eol; |
| 444 |
Pop_Output; |
| 445 |
end pg; |
| 446 |
|
| 447 |
-------- |
| 448 |
-- po -- |
| 449 |
-------- |
| 450 |
|
| 451 |
procedure po (Arg : Union_Id) is |
| 452 |
begin |
| 453 |
Dump_Generated_Only := False; |
| 454 |
Dump_Original_Only := True; |
| 455 |
Dump_Freeze_Null := False; |
| 456 |
Current_Source_File := No_Source_File; |
| 457 |
Push_Output; |
| 458 |
Set_Standard_Output; |
| 459 |
|
| 460 |
if Arg in List_Range then |
| 461 |
Sprint_Node_List (List_Id (Arg), New_Lines => True); |
| 462 |
|
| 463 |
elsif Arg in Node_Range then |
| 464 |
Sprint_Node (Node_Id (Arg)); |
| 465 |
|
| 466 |
else |
| 467 |
null; |
| 468 |
end if; |
| 469 |
|
| 470 |
Write_Eol; |
| 471 |
Pop_Output; |
| 472 |
end po; |
| 473 |
|
| 474 |
---------------------- |
| 475 |
-- Print_Debug_Line -- |
| 476 |
---------------------- |
| 477 |
|
| 478 |
procedure Print_Debug_Line (S : String) is |
| 479 |
begin |
| 480 |
Write_Debug_Line (S, Debug_Sloc); |
| 481 |
end Print_Debug_Line; |
| 482 |
|
| 483 |
-------- |
| 484 |
-- ps -- |
| 485 |
-------- |
| 486 |
|
| 487 |
procedure ps (Arg : Union_Id) is |
| 488 |
begin |
| 489 |
Dump_Generated_Only := False; |
| 490 |
Dump_Original_Only := False; |
| 491 |
Dump_Freeze_Null := False; |
| 492 |
Current_Source_File := No_Source_File; |
| 493 |
Push_Output; |
| 494 |
Set_Standard_Output; |
| 495 |
|
| 496 |
if Arg in List_Range then |
| 497 |
Sprint_Node_List (List_Id (Arg), New_Lines => True); |
| 498 |
|
| 499 |
elsif Arg in Node_Range then |
| 500 |
Sprint_Node (Node_Id (Arg)); |
| 501 |
|
| 502 |
else |
| 503 |
null; |
| 504 |
end if; |
| 505 |
|
| 506 |
Write_Eol; |
| 507 |
Pop_Output; |
| 508 |
end ps; |
| 509 |
|
| 510 |
-------------------- |
| 511 |
-- Set_Debug_Sloc -- |
| 512 |
-------------------- |
| 513 |
|
| 514 |
procedure Set_Debug_Sloc is |
| 515 |
begin |
| 516 |
if Debug_Generated_Code and then Present (Dump_Node) then |
| 517 |
declare |
| 518 |
Loc : constant Source_Ptr := Sloc (Dump_Node); |
| 519 |
|
| 520 |
begin |
| 521 |
-- Do not change the location of nodes defined in package Standard |
| 522 |
-- and nodes of pragmas scanned by Targparm. |
| 523 |
|
| 524 |
if Loc <= Standard_Location then |
| 525 |
null; |
| 526 |
|
| 527 |
-- Update the location of a node which is part of the current .dg |
| 528 |
-- output. This situation occurs in comma separated parameter |
| 529 |
-- declarations since each parameter references the same parameter |
| 530 |
-- type node (ie. obj1, obj2 : <param-type>). |
| 531 |
|
| 532 |
-- Note: This case is needed here since we cannot use the routine |
| 533 |
-- In_Extended_Main_Code_Unit with nodes whose location is a .dg |
| 534 |
-- file. |
| 535 |
|
| 536 |
elsif Loc >= First_Debug_Sloc then |
| 537 |
Set_Sloc (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1)); |
| 538 |
|
| 539 |
-- Do not change the location of nodes which are not part of the |
| 540 |
-- generated code |
| 541 |
|
| 542 |
elsif not In_Extended_Main_Code_Unit (Loc) then |
| 543 |
null; |
| 544 |
|
| 545 |
else |
| 546 |
Set_Sloc (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1)); |
| 547 |
end if; |
| 548 |
end; |
| 549 |
|
| 550 |
-- We do not know the actual end location in the generated code and |
| 551 |
-- it could be much closer than in the source code, so play safe. |
| 552 |
|
| 553 |
if Nkind (Dump_Node) in N_Case_Statement | N_If_Statement then |
| 554 |
Set_End_Location (Dump_Node, Debug_Sloc + Source_Ptr (Column - 1)); |
| 555 |
end if; |
| 556 |
|
| 557 |
Dump_Node := Empty; |
| 558 |
end if; |
| 559 |
end Set_Debug_Sloc; |
| 560 |
|
| 561 |
----------------- |
| 562 |
-- Source_Dump -- |
| 563 |
----------------- |
| 564 |
|
| 565 |
procedure Source_Dump is |
| 566 |
|
| 567 |
procedure Underline; |
| 568 |
-- Put underline under string we just printed |
| 569 |
|
| 570 |
--------------- |
| 571 |
-- Underline -- |
| 572 |
--------------- |
| 573 |
|
| 574 |
procedure Underline is |
| 575 |
Col : constant Int := Column; |
| 576 |
|
| 577 |
begin |
| 578 |
Write_Eol; |
| 579 |
|
| 580 |
while Col > Column loop |
| 581 |
Write_Char ('-'); |
| 582 |
end loop; |
| 583 |
|
| 584 |
Write_Eol; |
| 585 |
end Underline; |
| 586 |
|
| 587 |
-- Start of processing for Source_Dump |
| 588 |
|
| 589 |
begin |
| 590 |
Dump_Generated_Only := Debug_Flag_G or |
| 591 |
Print_Generated_Code or |
| 592 |
Debug_Generated_Code; |
| 593 |
Dump_Original_Only := Debug_Flag_O; |
| 594 |
Dump_Freeze_Null := Debug_Flag_S or Dump_Generated_Only; |
| 595 |
|
| 596 |
-- Note that we turn off the tree dump flags immediately, before |
| 597 |
-- starting the dump. This avoids generating two copies of the dump |
| 598 |
-- if an abort occurs after printing the dump, and more importantly, |
| 599 |
-- avoids an infinite loop if an abort occurs during the dump. |
| 600 |
|
| 601 |
if Debug_Flag_Z then |
| 602 |
Current_Source_File := No_Source_File; |
| 603 |
Debug_Flag_Z := False; |
| 604 |
Write_Eol; |
| 605 |
Write_Eol; |
| 606 |
Write_Str ("Source recreated from tree of Standard (spec)"); |
| 607 |
Underline; |
| 608 |
Sprint_Node (Standard_Package_Node); |
| 609 |
Write_Eol; |
| 610 |
Write_Eol; |
| 611 |
end if; |
| 612 |
|
| 613 |
if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then |
| 614 |
Debug_Flag_G := False; |
| 615 |
Debug_Flag_O := False; |
| 616 |
Debug_Flag_S := False; |
| 617 |
First_Debug_Sloc := No_Location; |
| 618 |
|
| 619 |
-- Dump requested units |
| 620 |
|
| 621 |
for U in Main_Unit .. Last_Unit loop |
| 622 |
Current_Source_File := Source_Index (U); |
| 623 |
|
| 624 |
-- Dump all units if -gnatdf set, otherwise dump only the source |
| 625 |
-- files that are in the extended main source. Note that, if we |
| 626 |
-- are generating debug files, generating that of the main unit |
| 627 |
-- has an effect on the outcome of In_Extended_Main_Source_Unit |
| 628 |
-- because slocs are rewritten, so we also test for equality of |
| 629 |
-- Cunit_Entity to work around this effect. |
| 630 |
|
| 631 |
if Debug_Flag_F |
| 632 |
or else In_Extended_Main_Source_Unit (Cunit_Entity (U)) |
| 633 |
or else Cunit_Entity (U) = Cunit_Entity (Main_Unit) |
| 634 |
then |
| 635 |
-- If we are generating debug files, setup to write them |
| 636 |
|
| 637 |
if Debug_Generated_Code then |
| 638 |
Set_Special_Output (Print_Debug_Line'Access); |
| 639 |
Create_Debug_Source (Source_Index (U), Debug_Sloc); |
| 640 |
First_Debug_Sloc := Debug_Sloc; |
| 641 |
Write_Source_Line (1); |
| 642 |
Last_Line_Printed := 1; |
| 643 |
|
| 644 |
-- If this unit has the same entity as the main unit, for |
| 645 |
-- example is the spec of a stand-alone instantiation of |
| 646 |
-- a package and the main unit is the body, its debug file |
| 647 |
-- will also be the same. Therefore, we need to print again |
| 648 |
-- the main unit to have both units in the debug file. |
| 649 |
|
| 650 |
if U /= Main_Unit |
| 651 |
and then Cunit_Entity (U) = Cunit_Entity (Main_Unit) |
| 652 |
then |
| 653 |
Sprint_Node (Cunit (Main_Unit)); |
| 654 |
Write_Eol; |
| 655 |
end if; |
| 656 |
|
| 657 |
Sprint_Node (Cunit (U)); |
| 658 |
Write_Source_Lines (Last_Source_Line (Current_Source_File)); |
| 659 |
Write_Eol; |
| 660 |
Close_Debug_Source; |
| 661 |
Cancel_Special_Output; |
| 662 |
|
| 663 |
-- Normal output to standard output file |
| 664 |
|
| 665 |
else |
| 666 |
Write_Str ("Source recreated from tree for "); |
| 667 |
Write_Unit_Name (Unit_Name (U)); |
| 668 |
Underline; |
| 669 |
Write_Source_Line (1); |
| 670 |
Last_Line_Printed := 1; |
| 671 |
Sprint_Node (Cunit (U)); |
| 672 |
Write_Source_Lines (Last_Source_Line (Current_Source_File)); |
| 673 |
Write_Eol; |
| 674 |
Write_Eol; |
| 675 |
end if; |
| 676 |
end if; |
| 677 |
end loop; |
| 678 |
end if; |
| 679 |
|
| 680 |
-- See above for the rationale, but we cannot do it earlier for them |
| 681 |
|
| 682 |
Print_Generated_Code := False; |
| 683 |
Debug_Generated_Code := False; |
| 684 |
end Source_Dump; |
| 685 |
|
| 686 |
--------------------- |
| 687 |
-- Sprint_And_List -- |
| 688 |
--------------------- |
| 689 |
|
| 690 |
procedure Sprint_And_List (List : List_Id) is |
| 691 |
Node : Node_Id; |
| 692 |
begin |
| 693 |
if Is_Non_Empty_List (List) then |
| 694 |
Node := First (List); |
| 695 |
loop |
| 696 |
Sprint_Node (Node); |
| 697 |
Next (Node); |
| 698 |
exit when Node = Empty; |
| 699 |
Write_Str (" and "); |
| 700 |
end loop; |
| 701 |
end if; |
| 702 |
end Sprint_And_List; |
| 703 |
|
| 704 |
---------------------------------- |
| 705 |
-- Sprint_Aspect_Specifications -- |
| 706 |
---------------------------------- |
| 707 |
|
| 708 |
procedure Sprint_Aspect_Specifications |
| 709 |
(Node : Node_Id; |
| 710 |
Semicolon : Boolean) |
| 711 |
is |
| 712 |
AS : constant List_Id := Aspect_Specifications (Node); |
| 713 |
A : Node_Id; |
| 714 |
|
| 715 |
begin |
| 716 |
if Semicolon then |
| 717 |
Write_Erase_Char (';'); |
| 718 |
Indent := Indent + 2; |
| 719 |
Write_Indent; |
| 720 |
Write_Str ("with "); |
| 721 |
Indent := Indent + 5; |
| 722 |
|
| 723 |
else |
| 724 |
Write_Str (" with "); |
| 725 |
end if; |
| 726 |
|
| 727 |
A := First (AS); |
| 728 |
loop |
| 729 |
Sprint_Node (Identifier (A)); |
| 730 |
|
| 731 |
if Class_Present (A) then |
| 732 |
Write_Str ("'Class"); |
| 733 |
end if; |
| 734 |
|
| 735 |
if Present (Expression (A)) then |
| 736 |
Write_Str (" => "); |
| 737 |
Sprint_Node (Expression (A)); |
| 738 |
end if; |
| 739 |
|
| 740 |
Next (A); |
| 741 |
|
| 742 |
exit when No (A); |
| 743 |
Write_Char (','); |
| 744 |
|
| 745 |
if Semicolon then |
| 746 |
Write_Indent; |
| 747 |
end if; |
| 748 |
end loop; |
| 749 |
|
| 750 |
if Semicolon then |
| 751 |
Indent := Indent - 7; |
| 752 |
Write_Char (';'); |
| 753 |
end if; |
| 754 |
end Sprint_Aspect_Specifications; |
| 755 |
|
| 756 |
------------------------ |
| 757 |
-- Sprint_At_End_Proc -- |
| 758 |
------------------------ |
| 759 |
|
| 760 |
procedure Sprint_At_End_Proc (Node : Node_Id) is |
| 761 |
begin |
| 762 |
if Present (At_End_Proc (Node)) then |
| 763 |
Write_Indent_Str ("at end"); |
| 764 |
Indent_Begin; |
| 765 |
Write_Indent; |
| 766 |
Sprint_Node (At_End_Proc (Node)); |
| 767 |
Write_Char (';'); |
| 768 |
Indent_End; |
| 769 |
end if; |
| 770 |
end Sprint_At_End_Proc; |
| 771 |
|
| 772 |
--------------------- |
| 773 |
-- Sprint_Bar_List -- |
| 774 |
--------------------- |
| 775 |
|
| 776 |
procedure Sprint_Bar_List (List : List_Id) is |
| 777 |
Node : Node_Id; |
| 778 |
begin |
| 779 |
if Is_Non_Empty_List (List) then |
| 780 |
Node := First (List); |
| 781 |
loop |
| 782 |
Sprint_Node (Node); |
| 783 |
Next (Node); |
| 784 |
exit when Node = Empty; |
| 785 |
Write_Str (" | "); |
| 786 |
end loop; |
| 787 |
end if; |
| 788 |
end Sprint_Bar_List; |
| 789 |
|
| 790 |
---------------------- |
| 791 |
-- Sprint_End_Label -- |
| 792 |
---------------------- |
| 793 |
|
| 794 |
procedure Sprint_End_Label |
| 795 |
(Node : Node_Id; |
| 796 |
Default : Node_Id) |
| 797 |
is |
| 798 |
begin |
| 799 |
if Present (Node) |
| 800 |
and then Present (End_Label (Node)) |
| 801 |
and then Is_Entity_Name (End_Label (Node)) |
| 802 |
then |
| 803 |
Set_Entity (End_Label (Node), Default); |
| 804 |
|
| 805 |
-- For a function whose name is an operator, use the qualified name |
| 806 |
-- created for the defining entity. |
| 807 |
|
| 808 |
if Nkind (End_Label (Node)) = N_Operator_Symbol then |
| 809 |
Set_Chars (End_Label (Node), Chars (Default)); |
| 810 |
end if; |
| 811 |
|
| 812 |
Sprint_Node (End_Label (Node)); |
| 813 |
else |
| 814 |
Sprint_Node (Default); |
| 815 |
end if; |
| 816 |
end Sprint_End_Label; |
| 817 |
|
| 818 |
----------------------- |
| 819 |
-- Sprint_Comma_List -- |
| 820 |
----------------------- |
| 821 |
|
| 822 |
procedure Sprint_Comma_List (List : List_Id) is |
| 823 |
Node : Node_Id; |
| 824 |
|
| 825 |
begin |
| 826 |
if Is_Non_Empty_List (List) then |
| 827 |
Node := First (List); |
| 828 |
loop |
| 829 |
Sprint_Node (Node); |
| 830 |
Next (Node); |
| 831 |
exit when Node = Empty; |
| 832 |
|
| 833 |
if not Is_Rewrite_Insertion (Node) |
| 834 |
or else not Dump_Original_Only |
| 835 |
then |
| 836 |
Write_Str (", "); |
| 837 |
end if; |
| 838 |
end loop; |
| 839 |
end if; |
| 840 |
end Sprint_Comma_List; |
| 841 |
|
| 842 |
-------------------------- |
| 843 |
-- Sprint_Indented_List -- |
| 844 |
-------------------------- |
| 845 |
|
| 846 |
procedure Sprint_Indented_List (List : List_Id) is |
| 847 |
begin |
| 848 |
Indent_Begin; |
| 849 |
Sprint_Node_List (List); |
| 850 |
Indent_End; |
| 851 |
end Sprint_Indented_List; |
| 852 |
|
| 853 |
--------------------- |
| 854 |
-- Sprint_Left_Opnd -- |
| 855 |
--------------------- |
| 856 |
|
| 857 |
procedure Sprint_Left_Opnd (N : Node_Id) is |
| 858 |
Opnd : constant Node_Id := Left_Opnd (N); |
| 859 |
|
| 860 |
begin |
| 861 |
if Paren_Count (Opnd) /= 0 |
| 862 |
or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N)) |
| 863 |
then |
| 864 |
Sprint_Node (Opnd); |
| 865 |
|
| 866 |
else |
| 867 |
Write_Char ('('); |
| 868 |
Sprint_Node (Opnd); |
| 869 |
Write_Char (')'); |
| 870 |
end if; |
| 871 |
end Sprint_Left_Opnd; |
| 872 |
|
| 873 |
----------------- |
| 874 |
-- Sprint_Node -- |
| 875 |
----------------- |
| 876 |
|
| 877 |
procedure Sprint_Node (Node : Node_Id) is |
| 878 |
begin |
| 879 |
if Is_Rewrite_Insertion (Node) then |
| 880 |
if not Dump_Original_Only then |
| 881 |
|
| 882 |
-- For special cases of nodes that always output <<< >>> |
| 883 |
-- do not duplicate the output at this point. |
| 884 |
|
| 885 |
if Nkind (Node) = N_Freeze_Entity |
| 886 |
or else Nkind (Node) = N_Freeze_Generic_Entity |
| 887 |
or else Nkind (Node) = N_Implicit_Label_Declaration |
| 888 |
then |
| 889 |
Sprint_Node_Actual (Node); |
| 890 |
|
| 891 |
-- Normal case where <<< >>> may be required |
| 892 |
|
| 893 |
else |
| 894 |
Write_Rewrite_Str ("<<<"); |
| 895 |
Sprint_Node_Actual (Node); |
| 896 |
Write_Rewrite_Str (">>>"); |
| 897 |
end if; |
| 898 |
end if; |
| 899 |
|
| 900 |
elsif Is_Rewrite_Substitution (Node) then |
| 901 |
|
| 902 |
-- Case of dump generated only |
| 903 |
|
| 904 |
if Dump_Generated_Only then |
| 905 |
Sprint_Node_Actual (Node); |
| 906 |
|
| 907 |
-- Case of dump original only |
| 908 |
|
| 909 |
elsif Dump_Original_Only then |
| 910 |
Sprint_Node_Actual (Original_Node (Node)); |
| 911 |
|
| 912 |
-- Case of both being dumped |
| 913 |
|
| 914 |
else |
| 915 |
Sprint_Node_Actual (Original_Node (Node)); |
| 916 |
Write_Rewrite_Str ("<<<"); |
| 917 |
Sprint_Node_Actual (Node); |
| 918 |
Write_Rewrite_Str (">>>"); |
| 919 |
end if; |
| 920 |
|
| 921 |
else |
| 922 |
Sprint_Node_Actual (Node); |
| 923 |
end if; |
| 924 |
end Sprint_Node; |
| 925 |
|
| 926 |
------------------------ |
| 927 |
-- Sprint_Node_Actual -- |
| 928 |
------------------------ |
| 929 |
|
| 930 |
procedure Sprint_Node_Actual (Node : Node_Id) is |
| 931 |
Save_Dump_Node : constant Node_Id := Dump_Node; |
| 932 |
|
| 933 |
begin |
| 934 |
if Node = Empty then |
| 935 |
return; |
| 936 |
end if; |
| 937 |
|
| 938 |
for J in 1 .. Paren_Count (Node) loop |
| 939 |
Write_Str_With_Col_Check ("("); |
| 940 |
end loop; |
| 941 |
|
| 942 |
-- Setup current dump node |
| 943 |
|
| 944 |
Dump_Node := Node; |
| 945 |
|
| 946 |
if Nkind (Node) in N_Subexpr |
| 947 |
and then Do_Range_Check (Node) |
| 948 |
then |
| 949 |
Write_Str_With_Col_Check ("{"); |
| 950 |
end if; |
| 951 |
|
| 952 |
-- Select print circuit based on node kind |
| 953 |
|
| 954 |
case Nkind (Node) is |
| 955 |
when N_Abort_Statement => |
| 956 |
Write_Indent_Str_Sloc ("abort "); |
| 957 |
Sprint_Comma_List (Names (Node)); |
| 958 |
Write_Char (';'); |
| 959 |
|
| 960 |
when N_Abortable_Part => |
| 961 |
Set_Debug_Sloc; |
| 962 |
Write_Str_Sloc ("abort "); |
| 963 |
Sprint_Indented_List (Statements (Node)); |
| 964 |
|
| 965 |
when N_Abstract_Subprogram_Declaration => |
| 966 |
Write_Indent; |
| 967 |
Sprint_Node (Specification (Node)); |
| 968 |
Write_Str_With_Col_Check (" is "); |
| 969 |
Write_Str_Sloc ("abstract;"); |
| 970 |
|
| 971 |
when N_Accept_Alternative => |
| 972 |
Sprint_Node_List (Pragmas_Before (Node)); |
| 973 |
|
| 974 |
if Present (Condition (Node)) then |
| 975 |
Write_Indent_Str ("when "); |
| 976 |
Sprint_Node (Condition (Node)); |
| 977 |
Write_Str (" => "); |
| 978 |
Indent_Annull; |
| 979 |
end if; |
| 980 |
|
| 981 |
Sprint_Node_Sloc (Accept_Statement (Node)); |
| 982 |
Sprint_Node_List (Statements (Node)); |
| 983 |
|
| 984 |
when N_Accept_Statement => |
| 985 |
Write_Indent_Str_Sloc ("accept "); |
| 986 |
Write_Id (Entry_Direct_Name (Node)); |
| 987 |
|
| 988 |
if Present (Entry_Index (Node)) then |
| 989 |
Write_Str_With_Col_Check (" ("); |
| 990 |
Sprint_Node (Entry_Index (Node)); |
| 991 |
Write_Char (')'); |
| 992 |
end if; |
| 993 |
|
| 994 |
Write_Param_Specs (Node); |
| 995 |
|
| 996 |
if Present (Handled_Statement_Sequence (Node)) then |
| 997 |
Write_Str_With_Col_Check (" do"); |
| 998 |
Sprint_Node (Handled_Statement_Sequence (Node)); |
| 999 |
Write_Indent_Str ("end "); |
| 1000 |
Write_Id (Entry_Direct_Name (Node)); |
| 1001 |
end if; |
| 1002 |
|
| 1003 |
Write_Char (';'); |
| 1004 |
|
| 1005 |
when N_Access_Definition => |
| 1006 |
|
| 1007 |
-- Ada 2005 (AI-254) |
| 1008 |
|
| 1009 |
if Present (Access_To_Subprogram_Definition (Node)) then |
| 1010 |
Sprint_Node (Access_To_Subprogram_Definition (Node)); |
| 1011 |
else |
| 1012 |
-- Ada 2005 (AI-231) |
| 1013 |
|
| 1014 |
if Null_Exclusion_Present (Node) then |
| 1015 |
Write_Str ("not null "); |
| 1016 |
end if; |
| 1017 |
|
| 1018 |
Write_Str_With_Col_Check_Sloc ("access "); |
| 1019 |
|
| 1020 |
if All_Present (Node) then |
| 1021 |
Write_Str ("all "); |
| 1022 |
elsif Constant_Present (Node) then |
| 1023 |
Write_Str ("constant "); |
| 1024 |
end if; |
| 1025 |
|
| 1026 |
Sprint_Node (Subtype_Mark (Node)); |
| 1027 |
end if; |
| 1028 |
|
| 1029 |
when N_Access_Function_Definition => |
| 1030 |
|
| 1031 |
-- Ada 2005 (AI-231) |
| 1032 |
|
| 1033 |
if Null_Exclusion_Present (Node) then |
| 1034 |
Write_Str ("not null "); |
| 1035 |
end if; |
| 1036 |
|
| 1037 |
Write_Str_With_Col_Check_Sloc ("access "); |
| 1038 |
|
| 1039 |
if Protected_Present (Node) then |
| 1040 |
Write_Str_With_Col_Check ("protected "); |
| 1041 |
end if; |
| 1042 |
|
| 1043 |
Write_Str_With_Col_Check ("function"); |
| 1044 |
Write_Param_Specs (Node); |
| 1045 |
Write_Str_With_Col_Check (" return "); |
| 1046 |
Sprint_Node (Result_Definition (Node)); |
| 1047 |
|
| 1048 |
when N_Access_Procedure_Definition => |
| 1049 |
|
| 1050 |
-- Ada 2005 (AI-231) |
| 1051 |
|
| 1052 |
if Null_Exclusion_Present (Node) then |
| 1053 |
Write_Str ("not null "); |
| 1054 |
end if; |
| 1055 |
|
| 1056 |
Write_Str_With_Col_Check_Sloc ("access "); |
| 1057 |
|
| 1058 |
if Protected_Present (Node) then |
| 1059 |
Write_Str_With_Col_Check ("protected "); |
| 1060 |
end if; |
| 1061 |
|
| 1062 |
Write_Str_With_Col_Check ("procedure"); |
| 1063 |
Write_Param_Specs (Node); |
| 1064 |
|
| 1065 |
when N_Access_To_Object_Definition => |
| 1066 |
Write_Str_With_Col_Check_Sloc ("access "); |
| 1067 |
|
| 1068 |
if All_Present (Node) then |
| 1069 |
Write_Str_With_Col_Check ("all "); |
| 1070 |
elsif Constant_Present (Node) then |
| 1071 |
Write_Str_With_Col_Check ("constant "); |
| 1072 |
end if; |
| 1073 |
|
| 1074 |
-- Ada 2005 (AI-231) |
| 1075 |
|
| 1076 |
if Null_Exclusion_Present (Node) then |
| 1077 |
Write_Str ("not null "); |
| 1078 |
end if; |
| 1079 |
|
| 1080 |
Sprint_Node (Subtype_Indication (Node)); |
| 1081 |
|
| 1082 |
when N_Aggregate => |
| 1083 |
if Null_Record_Present (Node) then |
| 1084 |
Write_Str_With_Col_Check_Sloc ("(null record)"); |
| 1085 |
|
| 1086 |
else |
| 1087 |
Write_Str_With_Col_Check_Sloc |
| 1088 |
(if Is_Homogeneous_Aggregate (Node) then "[" else "("); |
| 1089 |
|
| 1090 |
if Present (Expressions (Node)) then |
| 1091 |
Sprint_Comma_List (Expressions (Node)); |
| 1092 |
|
| 1093 |
if not Is_Empty_List (Component_Associations (Node)) then |
| 1094 |
Write_Str (", "); |
| 1095 |
end if; |
| 1096 |
end if; |
| 1097 |
|
| 1098 |
if not Is_Empty_List (Component_Associations (Node)) then |
| 1099 |
Indent_Begin; |
| 1100 |
|
| 1101 |
declare |
| 1102 |
Nd : Node_Id; |
| 1103 |
|
| 1104 |
begin |
| 1105 |
Nd := First (Component_Associations (Node)); |
| 1106 |
|
| 1107 |
loop |
| 1108 |
Write_Indent; |
| 1109 |
Sprint_Node (Nd); |
| 1110 |
Next (Nd); |
| 1111 |
exit when No (Nd); |
| 1112 |
|
| 1113 |
if not Is_Rewrite_Insertion (Nd) |
| 1114 |
or else not Dump_Original_Only |
| 1115 |
then |
| 1116 |
Write_Str (", "); |
| 1117 |
end if; |
| 1118 |
end loop; |
| 1119 |
end; |
| 1120 |
|
| 1121 |
Indent_End; |
| 1122 |
end if; |
| 1123 |
|
| 1124 |
Write_Char |
| 1125 |
(if Is_Homogeneous_Aggregate (Node) then ']' else ')'); |
| 1126 |
end if; |
| 1127 |
|
| 1128 |
when N_Allocator => |
| 1129 |
Write_Str_With_Col_Check_Sloc ("new "); |
| 1130 |
|
| 1131 |
-- Ada 2005 (AI-231) |
| 1132 |
|
| 1133 |
if Null_Exclusion_Present (Node) then |
| 1134 |
Write_Str ("not null "); |
| 1135 |
end if; |
| 1136 |
|
| 1137 |
Sprint_Node (Expression (Node)); |
| 1138 |
|
| 1139 |
if Present (Storage_Pool (Node)) then |
| 1140 |
Write_Str_With_Col_Check ("[storage_pool = "); |
| 1141 |
Sprint_Node (Storage_Pool (Node)); |
| 1142 |
Write_Char (']'); |
| 1143 |
end if; |
| 1144 |
|
| 1145 |
if Present (Procedure_To_Call (Node)) then |
| 1146 |
Write_Str_With_Col_Check ("[procedure_to_call = "); |
| 1147 |
Sprint_Node (Procedure_To_Call (Node)); |
| 1148 |
Write_Char (']'); |
| 1149 |
end if; |
| 1150 |
|
| 1151 |
when N_And_Then => |
| 1152 |
Sprint_Left_Opnd (Node); |
| 1153 |
Write_Str_Sloc (" and then "); |
| 1154 |
Sprint_Right_Opnd (Node); |
| 1155 |
|
| 1156 |
-- Note: the following code for N_Aspect_Specification is not |
| 1157 |
-- normally used, since we deal with aspects as part of a |
| 1158 |
-- declaration, but it is here in case we deliberately try |
| 1159 |
-- to print an N_Aspect_Specification node (e.g. from GDB). |
| 1160 |
|
| 1161 |
when N_Aspect_Specification => |
| 1162 |
Sprint_Node (Identifier (Node)); |
| 1163 |
Write_Str (" => "); |
| 1164 |
Sprint_Node (Expression (Node)); |
| 1165 |
|
| 1166 |
when N_Assignment_Statement => |
| 1167 |
Write_Indent; |
| 1168 |
Sprint_Node (Name (Node)); |
| 1169 |
Write_Str_Sloc (" := "); |
| 1170 |
Sprint_Node (Expression (Node)); |
| 1171 |
Write_Char (';'); |
| 1172 |
|
| 1173 |
when N_Asynchronous_Select => |
| 1174 |
Write_Indent_Str_Sloc ("select"); |
| 1175 |
Indent_Begin; |
| 1176 |
Sprint_Node (Triggering_Alternative (Node)); |
| 1177 |
Indent_End; |
| 1178 |
|
| 1179 |
-- Note: let the printing of Abortable_Part handle outputting |
| 1180 |
-- the ABORT keyword, so that the Sloc can be set correctly. |
| 1181 |
|
| 1182 |
Write_Indent_Str ("then "); |
| 1183 |
Sprint_Node (Abortable_Part (Node)); |
| 1184 |
Write_Indent_Str ("end select;"); |
| 1185 |
|
| 1186 |
when N_At_Clause => |
| 1187 |
Write_Indent_Str_Sloc ("for "); |
| 1188 |
Write_Id (Identifier (Node)); |
| 1189 |
Write_Str_With_Col_Check (" use at "); |
| 1190 |
Sprint_Node (Expression (Node)); |
| 1191 |
Write_Char (';'); |
| 1192 |
|
| 1193 |
when N_Attribute_Definition_Clause => |
| 1194 |
Write_Indent_Str_Sloc ("for "); |
| 1195 |
Sprint_Node (Name (Node)); |
| 1196 |
Write_Char ('''); |
| 1197 |
Write_Name_With_Col_Check (Chars (Node)); |
| 1198 |
Write_Str_With_Col_Check (" use "); |
| 1199 |
Sprint_Node (Expression (Node)); |
| 1200 |
Write_Char (';'); |
| 1201 |
|
| 1202 |
when N_Attribute_Reference => |
| 1203 |
if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then |
| 1204 |
Write_Indent; |
| 1205 |
end if; |
| 1206 |
|
| 1207 |
Sprint_Node (Prefix (Node)); |
| 1208 |
Write_Char_Sloc ('''); |
| 1209 |
Write_Name_With_Col_Check (Attribute_Name (Node)); |
| 1210 |
Sprint_Paren_Comma_List (Expressions (Node)); |
| 1211 |
|
| 1212 |
if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then |
| 1213 |
Write_Char (';'); |
| 1214 |
end if; |
| 1215 |
|
| 1216 |
when N_Block_Statement => |
| 1217 |
Write_Indent; |
| 1218 |
|
| 1219 |
if Present (Identifier (Node)) |
| 1220 |
and then (not Has_Created_Identifier (Node) |
| 1221 |
or else not Dump_Original_Only) |
| 1222 |
then |
| 1223 |
Write_Rewrite_Str ("<<<"); |
| 1224 |
Write_Id (Identifier (Node)); |
| 1225 |
Write_Str (" : "); |
| 1226 |
Write_Rewrite_Str (">>>"); |
| 1227 |
end if; |
| 1228 |
|
| 1229 |
if Present (Declarations (Node)) then |
| 1230 |
Write_Str_With_Col_Check_Sloc ("declare"); |
| 1231 |
Sprint_Indented_List (Declarations (Node)); |
| 1232 |
Write_Indent; |
| 1233 |
end if; |
| 1234 |
|
| 1235 |
Write_Str_With_Col_Check_Sloc ("begin"); |
| 1236 |
Sprint_Node (Handled_Statement_Sequence (Node)); |
| 1237 |
Write_Indent_Str ("end"); |
| 1238 |
|
| 1239 |
if Present (Identifier (Node)) |
| 1240 |
and then (not Has_Created_Identifier (Node) |
| 1241 |
or else not Dump_Original_Only) |
| 1242 |
then |
| 1243 |
Write_Rewrite_Str ("<<<"); |
| 1244 |
Write_Char (' '); |
| 1245 |
Write_Id (Identifier (Node)); |
| 1246 |
Write_Rewrite_Str (">>>"); |
| 1247 |
end if; |
| 1248 |
|
| 1249 |
Write_Char (';'); |
| 1250 |
Sprint_At_End_Proc (Node); |
| 1251 |
|
| 1252 |
when N_Call_Marker => |
| 1253 |
null; |
| 1254 |
|
| 1255 |
-- Enable the following code for debugging purposes only |
| 1256 |
|
| 1257 |
-- Write_Indent_Str ("#"); |
| 1258 |
-- Write_Id (Target (Node)); |
| 1259 |
-- Write_Char ('#'); |
| 1260 |
|
| 1261 |
when N_Case_Expression => |
| 1262 |
declare |
| 1263 |
Has_Parens : constant Boolean := Paren_Count (Node) > 0; |
| 1264 |
Alt : Node_Id; |
| 1265 |
|
| 1266 |
begin |
| 1267 |
-- The syntax for case_expression does not include parentheses, |
| 1268 |
-- but sometimes parentheses are required, so unconditionally |
| 1269 |
-- generate them here unless already present. |
| 1270 |
|
| 1271 |
if not Has_Parens then |
| 1272 |
Write_Char ('('); |
| 1273 |
end if; |
| 1274 |
|
| 1275 |
Write_Str_With_Col_Check_Sloc ("case "); |
| 1276 |
Sprint_Node (Expression (Node)); |
| 1277 |
Write_Str_With_Col_Check (" is"); |
| 1278 |
|
| 1279 |
Alt := First (Alternatives (Node)); |
| 1280 |
loop |
| 1281 |
Sprint_Node (Alt); |
| 1282 |
Next (Alt); |
| 1283 |
exit when No (Alt); |
| 1284 |
Write_Char (','); |
| 1285 |
end loop; |
| 1286 |
|
| 1287 |
if not Has_Parens then |
| 1288 |
Write_Char (')'); |
| 1289 |
end if; |
| 1290 |
end; |
| 1291 |
|
| 1292 |
when N_Case_Expression_Alternative => |
| 1293 |
Write_Str_With_Col_Check (" when "); |
| 1294 |
Sprint_Bar_List (Discrete_Choices (Node)); |
| 1295 |
Write_Str (" => "); |
| 1296 |
Sprint_Node (Expression (Node)); |
| 1297 |
|
| 1298 |
when N_Case_Statement => |
| 1299 |
Write_Indent_Str_Sloc ("case "); |
| 1300 |
Sprint_Node (Expression (Node)); |
| 1301 |
Write_Str (" is"); |
| 1302 |
Sprint_Indented_List (Alternatives (Node)); |
| 1303 |
Write_Indent_Str ("end case;"); |
| 1304 |
|
| 1305 |
when N_Case_Statement_Alternative => |
| 1306 |
Write_Indent_Str_Sloc ("when "); |
| 1307 |
Sprint_Bar_List (Discrete_Choices (Node)); |
| 1308 |
Write_Str (" => "); |
| 1309 |
Sprint_Indented_List (Statements (Node)); |
| 1310 |
|
| 1311 |
when N_Character_Literal => |
| 1312 |
if Column > Sprint_Line_Limit - 2 then |
| 1313 |
Write_Indent_Str (" "); |
| 1314 |
end if; |
| 1315 |
|
| 1316 |
Write_Char_Sloc ('''); |
| 1317 |
Write_Char_Code (UI_To_CC (Char_Literal_Value (Node))); |
| 1318 |
Write_Char ('''); |
| 1319 |
|
| 1320 |
when N_Code_Statement => |
| 1321 |
Write_Indent; |
| 1322 |
Set_Debug_Sloc; |
| 1323 |
Sprint_Node (Expression (Node)); |
| 1324 |
Write_Char (';'); |
| 1325 |
|
| 1326 |
when N_Compilation_Unit => |
| 1327 |
Sprint_Node_List (Context_Items (Node)); |
| 1328 |
Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node))); |
| 1329 |
|
| 1330 |
if Private_Present (Node) then |
| 1331 |
Write_Indent_Str ("private "); |
| 1332 |
Indent_Annull; |
| 1333 |
end if; |
| 1334 |
|
| 1335 |
Sprint_Node_Sloc (Unit (Node)); |
| 1336 |
|
| 1337 |
if Present (Actions (Aux_Decls_Node (Node))) |
| 1338 |
or else |
| 1339 |
Present (Pragmas_After (Aux_Decls_Node (Node))) |
| 1340 |
then |
| 1341 |
Write_Indent; |
| 1342 |
end if; |
| 1343 |
|
| 1344 |
Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node))); |
| 1345 |
Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node))); |
| 1346 |
|
| 1347 |
when N_Compilation_Unit_Aux => |
| 1348 |
null; -- nothing to do, never used, see above |
| 1349 |
|
| 1350 |
when N_Component_Association => |
| 1351 |
Set_Debug_Sloc; |
| 1352 |
Sprint_Bar_List (Choices (Node)); |
| 1353 |
Write_Str (" => "); |
| 1354 |
|
| 1355 |
-- Ada 2005 (AI-287): Print the box if present |
| 1356 |
|
| 1357 |
if Box_Present (Node) then |
| 1358 |
Write_Str_With_Col_Check ("<>"); |
| 1359 |
else |
| 1360 |
Sprint_Node (Expression (Node)); |
| 1361 |
end if; |
| 1362 |
|
| 1363 |
when N_Iterated_Component_Association => |
| 1364 |
Set_Debug_Sloc; |
| 1365 |
Write_Str (" for "); |
| 1366 |
if Present (Iterator_Specification (Node)) then |
| 1367 |
Sprint_Node (Iterator_Specification (Node)); |
| 1368 |
else |
| 1369 |
Write_Id (Defining_Identifier (Node)); |
| 1370 |
Write_Str (" in "); |
| 1371 |
Sprint_Bar_List (Discrete_Choices (Node)); |
| 1372 |
end if; |
| 1373 |
Write_Str (" => "); |
| 1374 |
Sprint_Node (Expression (Node)); |
| 1375 |
|
| 1376 |
when N_Iterated_Element_Association => |
| 1377 |
Set_Debug_Sloc; |
| 1378 |
if Present (Iterator_Specification (Node)) then |
| 1379 |
Sprint_Node (Iterator_Specification (Node)); |
| 1380 |
else |
| 1381 |
Sprint_Node (Loop_Parameter_Specification (Node)); |
| 1382 |
end if; |
| 1383 |
|
| 1384 |
if Present (Key_Expression (Node)) then |
| 1385 |
Write_Str (" use "); |
| 1386 |
Sprint_Node (Key_Expression (Node)); |
| 1387 |
end if; |
| 1388 |
|
| 1389 |
Write_Str (" => "); |
| 1390 |
Sprint_Node (Expression (Node)); |
| 1391 |
|
| 1392 |
when N_Component_Clause => |
| 1393 |
Write_Indent; |
| 1394 |
Sprint_Node (Component_Name (Node)); |
| 1395 |
Write_Str_Sloc (" at "); |
| 1396 |
Sprint_Node (Position (Node)); |
| 1397 |
Write_Char (' '); |
| 1398 |
Write_Str_With_Col_Check ("range "); |
| 1399 |
Sprint_Node (First_Bit (Node)); |
| 1400 |
Write_Str (" .. "); |
| 1401 |
Sprint_Node (Last_Bit (Node)); |
| 1402 |
Write_Char (';'); |
| 1403 |
|
| 1404 |
when N_Component_Definition => |
| 1405 |
Set_Debug_Sloc; |
| 1406 |
|
| 1407 |
-- Ada 2005 (AI-230): Access definition components |
| 1408 |
|
| 1409 |
if Present (Access_Definition (Node)) then |
| 1410 |
Sprint_Node (Access_Definition (Node)); |
| 1411 |
|
| 1412 |
elsif Present (Subtype_Indication (Node)) then |
| 1413 |
if Aliased_Present (Node) then |
| 1414 |
Write_Str_With_Col_Check ("aliased "); |
| 1415 |
end if; |
| 1416 |
|
| 1417 |
-- Ada 2005 (AI-231) |
| 1418 |
|
| 1419 |
if Null_Exclusion_Present (Node) then |
| 1420 |
Write_Str (" not null "); |
| 1421 |
end if; |
| 1422 |
|
| 1423 |
Sprint_Node (Subtype_Indication (Node)); |
| 1424 |
|
| 1425 |
else |
| 1426 |
Write_Str (" ??? "); |
| 1427 |
end if; |
| 1428 |
|
| 1429 |
when N_Component_Declaration => |
| 1430 |
if Write_Indent_Identifiers_Sloc (Node) then |
| 1431 |
Write_Str (" : "); |
| 1432 |
Sprint_Node (Component_Definition (Node)); |
| 1433 |
|
| 1434 |
if Present (Expression (Node)) then |
| 1435 |
Write_Str (" := "); |
| 1436 |
Sprint_Node (Expression (Node)); |
| 1437 |
end if; |
| 1438 |
|
| 1439 |
Write_Char (';'); |
| 1440 |
end if; |
| 1441 |
|
| 1442 |
when N_Component_List => |
| 1443 |
if Null_Present (Node) then |
| 1444 |
Indent_Begin; |
| 1445 |
Write_Indent_Str_Sloc ("null"); |
| 1446 |
Write_Char (';'); |
| 1447 |
Indent_End; |
| 1448 |
|
| 1449 |
else |
| 1450 |
Set_Debug_Sloc; |
| 1451 |
Sprint_Indented_List (Component_Items (Node)); |
| 1452 |
Sprint_Node (Variant_Part (Node)); |
| 1453 |
end if; |
| 1454 |
|
| 1455 |
when N_Compound_Statement => |
| 1456 |
Write_Indent_Str ("do"); |
| 1457 |
Indent_Begin; |
| 1458 |
Sprint_Node_List (Actions (Node)); |
| 1459 |
Indent_End; |
| 1460 |
Write_Indent_Str ("end;"); |
| 1461 |
|
| 1462 |
when N_Conditional_Entry_Call => |
| 1463 |
Write_Indent_Str_Sloc ("select"); |
| 1464 |
Indent_Begin; |
| 1465 |
Sprint_Node (Entry_Call_Alternative (Node)); |
| 1466 |
Indent_End; |
| 1467 |
Write_Indent_Str ("else"); |
| 1468 |
Sprint_Indented_List (Else_Statements (Node)); |
| 1469 |
Write_Indent_Str ("end select;"); |
| 1470 |
|
| 1471 |
when N_Constrained_Array_Definition => |
| 1472 |
Write_Str_With_Col_Check_Sloc ("array "); |
| 1473 |
Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node)); |
| 1474 |
Write_Str (" of "); |
| 1475 |
|
| 1476 |
Sprint_Node (Component_Definition (Node)); |
| 1477 |
|
| 1478 |
-- A contract node should not appear in the tree. It is a semantic |
| 1479 |
-- node attached to entry and [generic] subprogram entities. But we |
| 1480 |
-- still provide meaningful output, in case called from the debugger. |
| 1481 |
|
| 1482 |
when N_Contract => |
| 1483 |
declare |
| 1484 |
P : Node_Id; |
| 1485 |
|
| 1486 |
begin |
| 1487 |
Indent_Begin; |
| 1488 |
Write_Str ("N_Contract node"); |
| 1489 |
Write_Eol; |
| 1490 |
|
| 1491 |
Write_Indent_Str ("Pre_Post_Conditions"); |
| 1492 |
Indent_Begin; |
| 1493 |
|
| 1494 |
P := Pre_Post_Conditions (Node); |
| 1495 |
while Present (P) loop |
| 1496 |
Sprint_Node (P); |
| 1497 |
P := Next_Pragma (P); |
| 1498 |
end loop; |
| 1499 |
|
| 1500 |
Write_Eol; |
| 1501 |
Indent_End; |
| 1502 |
|
| 1503 |
Write_Indent_Str ("Contract_Test_Cases"); |
| 1504 |
Indent_Begin; |
| 1505 |
|
| 1506 |
P := Contract_Test_Cases (Node); |
| 1507 |
while Present (P) loop |
| 1508 |
Sprint_Node (P); |
| 1509 |
P := Next_Pragma (P); |
| 1510 |
end loop; |
| 1511 |
|
| 1512 |
Write_Eol; |
| 1513 |
Indent_End; |
| 1514 |
|
| 1515 |
Write_Indent_Str ("Classifications"); |
| 1516 |
Indent_Begin; |
| 1517 |
|
| 1518 |
P := Classifications (Node); |
| 1519 |
while Present (P) loop |
| 1520 |
Sprint_Node (P); |
| 1521 |
P := Next_Pragma (P); |
| 1522 |
end loop; |
| 1523 |
|
| 1524 |
Write_Eol; |
| 1525 |
Indent_End; |
| 1526 |
Indent_End; |
| 1527 |
end; |
| 1528 |
|
| 1529 |
when N_Decimal_Fixed_Point_Definition => |
| 1530 |
Write_Str_With_Col_Check_Sloc ("delta "); |
| 1531 |
Sprint_Node (Delta_Expression (Node)); |
| 1532 |
Write_Str_With_Col_Check (" digits "); |
| 1533 |
Sprint_Node (Digits_Expression (Node)); |
| 1534 |
Sprint_Opt_Node (Real_Range_Specification (Node)); |
| 1535 |
|
| 1536 |
when N_Defining_Character_Literal => |
| 1537 |
Write_Name_With_Col_Check_Sloc (Chars (Node)); |
| 1538 |
|
| 1539 |
when N_Defining_Identifier => |
| 1540 |
Set_Debug_Sloc; |
| 1541 |
Write_Id (Node); |
| 1542 |
|
| 1543 |
when N_Defining_Operator_Symbol => |
| 1544 |
Write_Name_With_Col_Check_Sloc (Chars (Node)); |
| 1545 |
|
| 1546 |
when N_Defining_Program_Unit_Name => |
| 1547 |
Set_Debug_Sloc; |
| 1548 |
Sprint_Node (Name (Node)); |
| 1549 |
Write_Char ('.'); |
| 1550 |
Write_Id (Defining_Identifier (Node)); |
| 1551 |
|
| 1552 |
when N_Delay_Alternative => |
| 1553 |
Sprint_Node_List (Pragmas_Before (Node)); |
| 1554 |
|
| 1555 |
if Present (Condition (Node)) then |
| 1556 |
Write_Indent; |
| 1557 |
Write_Str_With_Col_Check ("when "); |
| 1558 |
Sprint_Node (Condition (Node)); |
| 1559 |
Write_Str (" => "); |
| 1560 |
Indent_Annull; |
| 1561 |
end if; |
| 1562 |
|
| 1563 |
Sprint_Node_Sloc (Delay_Statement (Node)); |
| 1564 |
Sprint_Node_List (Statements (Node)); |
| 1565 |
|
| 1566 |
when N_Delay_Relative_Statement => |
| 1567 |
Write_Indent_Str_Sloc ("delay "); |
| 1568 |
Sprint_Node (Expression (Node)); |
| 1569 |
Write_Char (';'); |
| 1570 |
|
| 1571 |
when N_Delay_Until_Statement => |
| 1572 |
Write_Indent_Str_Sloc ("delay until "); |
| 1573 |
Sprint_Node (Expression (Node)); |
| 1574 |
Write_Char (';'); |
| 1575 |
|
| 1576 |
when N_Delta_Constraint => |
| 1577 |
Write_Str_With_Col_Check_Sloc ("delta "); |
| 1578 |
Sprint_Node (Delta_Expression (Node)); |
| 1579 |
Sprint_Opt_Node (Range_Constraint (Node)); |
| 1580 |
|
| 1581 |
when N_Derived_Type_Definition => |
| 1582 |
if Abstract_Present (Node) then |
| 1583 |
Write_Str_With_Col_Check ("abstract "); |
| 1584 |
end if; |
| 1585 |
|
| 1586 |
Write_Str_With_Col_Check ("new "); |
| 1587 |
|
| 1588 |
-- Ada 2005 (AI-231) |
| 1589 |
|
| 1590 |
if Null_Exclusion_Present (Node) then |
| 1591 |
Write_Str_With_Col_Check ("not null "); |
| 1592 |
end if; |
| 1593 |
|
| 1594 |
Sprint_Node (Subtype_Indication (Node)); |
| 1595 |
|
| 1596 |
if Present (Interface_List (Node)) then |
| 1597 |
Write_Str_With_Col_Check (" and "); |
| 1598 |
Sprint_And_List (Interface_List (Node)); |
| 1599 |
Write_Str_With_Col_Check (" with "); |
| 1600 |
end if; |
| 1601 |
|
| 1602 |
if Present (Record_Extension_Part (Node)) then |
| 1603 |
if No (Interface_List (Node)) then |
| 1604 |
Write_Str_With_Col_Check (" with "); |
| 1605 |
end if; |
| 1606 |
|
| 1607 |
Sprint_Node (Record_Extension_Part (Node)); |
| 1608 |
end if; |
| 1609 |
|
| 1610 |
when N_Designator => |
| 1611 |
Sprint_Node (Name (Node)); |
| 1612 |
Write_Char_Sloc ('.'); |
| 1613 |
Write_Id (Identifier (Node)); |
| 1614 |
|
| 1615 |
when N_Digits_Constraint => |
| 1616 |
Write_Str_With_Col_Check_Sloc ("digits "); |
| 1617 |
Sprint_Node (Digits_Expression (Node)); |
| 1618 |
Sprint_Opt_Node (Range_Constraint (Node)); |
| 1619 |
|
| 1620 |
when N_Discriminant_Association => |
| 1621 |
Set_Debug_Sloc; |
| 1622 |
|
| 1623 |
if Present (Selector_Names (Node)) then |
| 1624 |
Sprint_Bar_List (Selector_Names (Node)); |
| 1625 |
Write_Str (" => "); |
| 1626 |
end if; |
| 1627 |
|
| 1628 |
Set_Debug_Sloc; |
| 1629 |
Sprint_Node (Expression (Node)); |
| 1630 |
|
| 1631 |
when N_Discriminant_Specification => |
| 1632 |
Set_Debug_Sloc; |
| 1633 |
|
| 1634 |
if Write_Identifiers (Node) then |
| 1635 |
Write_Str (" : "); |
| 1636 |
|
| 1637 |
if Null_Exclusion_Present (Node) then |
| 1638 |
Write_Str ("not null "); |
| 1639 |
end if; |
| 1640 |
|
| 1641 |
Sprint_Node (Discriminant_Type (Node)); |
| 1642 |
|
| 1643 |
if Present (Expression (Node)) then |
| 1644 |
Write_Str (" := "); |
| 1645 |
Sprint_Node (Expression (Node)); |
| 1646 |
end if; |
| 1647 |
else |
| 1648 |
Write_Str (", "); |
| 1649 |
end if; |
| 1650 |
|
| 1651 |
when N_Elsif_Part => |
| 1652 |
Write_Indent_Str_Sloc ("elsif "); |
| 1653 |
Sprint_Node (Condition (Node)); |
| 1654 |
Write_Str_With_Col_Check (" then"); |
| 1655 |
Sprint_Indented_List (Then_Statements (Node)); |
| 1656 |
|
| 1657 |
when N_Empty => |
| 1658 |
null; |
| 1659 |
|
| 1660 |
when N_Entry_Body => |
| 1661 |
Write_Indent_Str_Sloc ("entry "); |
| 1662 |
Write_Id (Defining_Identifier (Node)); |
| 1663 |
Sprint_Node (Entry_Body_Formal_Part (Node)); |
| 1664 |
Write_Str_With_Col_Check (" is"); |
| 1665 |
Sprint_Indented_List (Declarations (Node)); |
| 1666 |
Write_Indent_Str ("begin"); |
| 1667 |
Sprint_Node (Handled_Statement_Sequence (Node)); |
| 1668 |
Write_Indent_Str ("end "); |
| 1669 |
Write_Id (Defining_Identifier (Node)); |
| 1670 |
Write_Char (';'); |
| 1671 |
Sprint_At_End_Proc (Node); |
| 1672 |
|
| 1673 |
when N_Entry_Body_Formal_Part => |
| 1674 |
if Present (Entry_Index_Specification (Node)) then |
| 1675 |
Write_Str_With_Col_Check_Sloc (" ("); |
| 1676 |
Sprint_Node (Entry_Index_Specification (Node)); |
| 1677 |
Write_Char (')'); |
| 1678 |
end if; |
| 1679 |
|
| 1680 |
Write_Param_Specs (Node); |
| 1681 |
Write_Str_With_Col_Check_Sloc (" when "); |
| 1682 |
Sprint_Node (Condition (Node)); |
| 1683 |
|
| 1684 |
when N_Entry_Call_Alternative => |
| 1685 |
Sprint_Node_List (Pragmas_Before (Node)); |
| 1686 |
Sprint_Node_Sloc (Entry_Call_Statement (Node)); |
| 1687 |
Sprint_Node_List (Statements (Node)); |
| 1688 |
|
| 1689 |
when N_Entry_Call_Statement => |
| 1690 |
Write_Indent; |
| 1691 |
Sprint_Node_Sloc (Name (Node)); |
| 1692 |
Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node)); |
| 1693 |
Write_Char (';'); |
| 1694 |
|
| 1695 |
when N_Entry_Declaration => |
| 1696 |
Write_Indent_Str_Sloc ("entry "); |
| 1697 |
Write_Id (Defining_Identifier (Node)); |
| 1698 |
|
| 1699 |
if Present (Discrete_Subtype_Definition (Node)) then |
| 1700 |
Write_Str_With_Col_Check (" ("); |
| 1701 |
Sprint_Node (Discrete_Subtype_Definition (Node)); |
| 1702 |
Write_Char (')'); |
| 1703 |
end if; |
| 1704 |
|
| 1705 |
Write_Param_Specs (Node); |
| 1706 |
Write_Char (';'); |
| 1707 |
|
| 1708 |
when N_Entry_Index_Specification => |
| 1709 |
Write_Str_With_Col_Check_Sloc ("for "); |
| 1710 |
Write_Id (Defining_Identifier (Node)); |
| 1711 |
Write_Str_With_Col_Check (" in "); |
| 1712 |
Sprint_Node (Discrete_Subtype_Definition (Node)); |
| 1713 |
|
| 1714 |
when N_Enumeration_Representation_Clause => |
| 1715 |
Write_Indent_Str_Sloc ("for "); |
| 1716 |
Write_Id (Identifier (Node)); |
| 1717 |
Write_Str_With_Col_Check (" use "); |
| 1718 |
Sprint_Node (Array_Aggregate (Node)); |
| 1719 |
Write_Char (';'); |
| 1720 |
|
| 1721 |
when N_Enumeration_Type_Definition => |
| 1722 |
Set_Debug_Sloc; |
| 1723 |
|
| 1724 |
-- Skip attempt to print Literals field if it's not there and |
| 1725 |
-- we are in package Standard (case of Character, which is |
| 1726 |
-- handled specially (without an explicit literals list). |
| 1727 |
|
| 1728 |
if Sloc (Node) > Standard_Location |
| 1729 |
or else Present (Literals (Node)) |
| 1730 |
then |
| 1731 |
Sprint_Paren_Comma_List (Literals (Node)); |
| 1732 |
end if; |
| 1733 |
|
| 1734 |
when N_Error => |
| 1735 |
Write_Str_With_Col_Check_Sloc ("<error>"); |
| 1736 |
|
| 1737 |
when N_Exception_Declaration => |
| 1738 |
if Write_Indent_Identifiers (Node) then |
| 1739 |
Write_Str_With_Col_Check (" : "); |
| 1740 |
|
| 1741 |
if Is_Statically_Allocated (Defining_Identifier (Node)) then |
| 1742 |
Write_Str_With_Col_Check ("static "); |
| 1743 |
end if; |
| 1744 |
|
| 1745 |
Write_Str_Sloc ("exception"); |
| 1746 |
|
| 1747 |
if Present (Expression (Node)) then |
| 1748 |
Write_Str (" := "); |
| 1749 |
Sprint_Node (Expression (Node)); |
| 1750 |
end if; |
| 1751 |
|
| 1752 |
Write_Char (';'); |
| 1753 |
end if; |
| 1754 |
|
| 1755 |
when N_Exception_Handler => |
| 1756 |
Write_Indent_Str_Sloc ("when "); |
| 1757 |
|
| 1758 |
if Present (Choice_Parameter (Node)) then |
| 1759 |
Sprint_Node (Choice_Parameter (Node)); |
| 1760 |
Write_Str (" : "); |
| 1761 |
end if; |
| 1762 |
|
| 1763 |
Sprint_Bar_List (Exception_Choices (Node)); |
| 1764 |
Write_Str (" => "); |
| 1765 |
Sprint_Indented_List (Statements (Node)); |
| 1766 |
|
| 1767 |
when N_Exception_Renaming_Declaration => |
| 1768 |
Write_Indent; |
| 1769 |
Set_Debug_Sloc; |
| 1770 |
Sprint_Node (Defining_Identifier (Node)); |
| 1771 |
Write_Str_With_Col_Check (" : exception renames "); |
| 1772 |
Sprint_Node (Name (Node)); |
| 1773 |
Write_Char (';'); |
| 1774 |
|
| 1775 |
when N_Exit_Statement => |
| 1776 |
Write_Indent_Str_Sloc ("exit"); |
| 1777 |
Sprint_Opt_Node (Name (Node)); |
| 1778 |
|
| 1779 |
if Present (Condition (Node)) then |
| 1780 |
Write_Str_With_Col_Check (" when "); |
| 1781 |
Sprint_Node (Condition (Node)); |
| 1782 |
end if; |
| 1783 |
|
| 1784 |
Write_Char (';'); |
| 1785 |
|
| 1786 |
when N_Expanded_Name => |
| 1787 |
Sprint_Node (Prefix (Node)); |
| 1788 |
Write_Char_Sloc ('.'); |
| 1789 |
Sprint_Node (Selector_Name (Node)); |
| 1790 |
|
| 1791 |
when N_Explicit_Dereference => |
| 1792 |
Sprint_Node (Prefix (Node)); |
| 1793 |
Write_Char_Sloc ('.'); |
| 1794 |
Write_Str_Sloc ("all"); |
| 1795 |
|
| 1796 |
when N_Expression_With_Actions => |
| 1797 |
Indent_Begin; |
| 1798 |
Write_Indent_Str_Sloc ("do "); |
| 1799 |
Indent_Begin; |
| 1800 |
Sprint_Node_List (Actions (Node)); |
| 1801 |
Indent_End; |
| 1802 |
Write_Indent; |
| 1803 |
Write_Str_With_Col_Check_Sloc ("in "); |
| 1804 |
Sprint_Node (Expression (Node)); |
| 1805 |
Write_Str_With_Col_Check (" end"); |
| 1806 |
Indent_End; |
| 1807 |
Write_Indent; |
| 1808 |
|
| 1809 |
when N_Expression_Function => |
| 1810 |
Write_Indent; |
| 1811 |
Sprint_Node_Sloc (Specification (Node)); |
| 1812 |
Write_Str (" is"); |
| 1813 |
Indent_Begin; |
| 1814 |
Write_Indent; |
| 1815 |
Sprint_Node (Expression (Node)); |
| 1816 |
Write_Char (';'); |
| 1817 |
Indent_End; |
| 1818 |
|
| 1819 |
when N_Extended_Return_Statement => |
| 1820 |
Write_Indent_Str_Sloc ("return "); |
| 1821 |
Sprint_Node_List (Return_Object_Declarations (Node)); |
| 1822 |
|
| 1823 |
if Present (Handled_Statement_Sequence (Node)) then |
| 1824 |
Write_Str_With_Col_Check (" do"); |
| 1825 |
Sprint_Node (Handled_Statement_Sequence (Node)); |
| 1826 |
Write_Indent_Str ("end return"); |
| 1827 |
end if; |
| 1828 |
|
| 1829 |
if Present (Storage_Pool (Node)) then |
| 1830 |
Write_Str_With_Col_Check ("[storage_pool = "); |
| 1831 |
Sprint_Node (Storage_Pool (Node)); |
| 1832 |
Write_Char (']'); |
| 1833 |
end if; |
| 1834 |
|
| 1835 |
if Present (Procedure_To_Call (Node)) then |
| 1836 |
Write_Str_With_Col_Check ("[procedure_to_call = "); |
| 1837 |
Sprint_Node (Procedure_To_Call (Node)); |
| 1838 |
Write_Char (']'); |
| 1839 |
end if; |
| 1840 |
|
| 1841 |
Write_Char (';'); |
| 1842 |
|
| 1843 |
when N_External_Initializer => |
| 1844 |
null; |
| 1845 |
|
| 1846 |
when N_Delta_Aggregate => |
| 1847 |
Write_Str_With_Col_Check_Sloc ("("); |
| 1848 |
Sprint_Node (Expression (Node)); |
| 1849 |
Write_Str_With_Col_Check (" with delta "); |
| 1850 |
Sprint_Comma_List (Component_Associations (Node)); |
| 1851 |
Write_Char (')'); |
| 1852 |
|
| 1853 |
when N_Extension_Aggregate => |
| 1854 |
Write_Str_With_Col_Check_Sloc ("("); |
| 1855 |
Sprint_Node (Ancestor_Part (Node)); |
| 1856 |
Write_Str_With_Col_Check (" with "); |
| 1857 |
|
| 1858 |
if Null_Record_Present (Node) then |
| 1859 |
Write_Str_With_Col_Check ("null record"); |
| 1860 |
else |
| 1861 |
if Present (Expressions (Node)) then |
| 1862 |
Sprint_Comma_List (Expressions (Node)); |
| 1863 |
|
| 1864 |
if Present (Component_Associations (Node)) then |
| 1865 |
Write_Str (", "); |
| 1866 |
end if; |
| 1867 |
end if; |
| 1868 |
|
| 1869 |
if Present (Component_Associations (Node)) then |
| 1870 |
Sprint_Comma_List (Component_Associations (Node)); |
| 1871 |
end if; |
| 1872 |
end if; |
| 1873 |
|
| 1874 |
Write_Char (')'); |
| 1875 |
|
| 1876 |
when N_Floating_Point_Definition => |
| 1877 |
Write_Str_With_Col_Check_Sloc ("digits "); |
| 1878 |
Sprint_Node (Digits_Expression (Node)); |
| 1879 |
Sprint_Opt_Node (Real_Range_Specification (Node)); |
| 1880 |
|
| 1881 |
when N_Formal_Decimal_Fixed_Point_Definition => |
| 1882 |
Write_Str_With_Col_Check_Sloc ("delta <> digits <>"); |
| 1883 |
|
| 1884 |
when N_Formal_Derived_Type_Definition => |
| 1885 |
Write_Str_With_Col_Check_Sloc ("new "); |
| 1886 |
Sprint_Node (Subtype_Mark (Node)); |
| 1887 |
|
| 1888 |
if Present (Interface_List (Node)) then |
| 1889 |
Write_Str_With_Col_Check (" and "); |
| 1890 |
Sprint_And_List (Interface_List (Node)); |
| 1891 |
end if; |
| 1892 |
|
| 1893 |
if Private_Present (Node) then |
| 1894 |
Write_Str_With_Col_Check (" with private"); |
| 1895 |
end if; |
| 1896 |
|
| 1897 |
when N_Formal_Abstract_Subprogram_Declaration => |
| 1898 |
Write_Indent_Str_Sloc ("with "); |
| 1899 |
Sprint_Node (Specification (Node)); |
| 1900 |
|
| 1901 |
Write_Str_With_Col_Check (" is abstract"); |
| 1902 |
|
| 1903 |
if Box_Present (Node) then |
| 1904 |
Write_Str_With_Col_Check (" <>"); |
| 1905 |
elsif Present (Default_Name (Node)) then |
| 1906 |
Write_Str_With_Col_Check (" "); |
| 1907 |
Sprint_Node (Default_Name (Node)); |
| 1908 |
end if; |
| 1909 |
|
| 1910 |
Write_Char (';'); |
| 1911 |
|
| 1912 |
when N_Formal_Concrete_Subprogram_Declaration => |
| 1913 |
Write_Indent_Str_Sloc ("with "); |
| 1914 |
Sprint_Node (Specification (Node)); |
| 1915 |
|
| 1916 |
if Box_Present (Node) then |
| 1917 |
Write_Str_With_Col_Check (" is <>"); |
| 1918 |
elsif Present (Default_Name (Node)) then |
| 1919 |
Write_Str_With_Col_Check (" is "); |
| 1920 |
Sprint_Node (Default_Name (Node)); |
| 1921 |
end if; |
| 1922 |
|
| 1923 |
Write_Char (';'); |
| 1924 |
|
| 1925 |
when N_Formal_Discrete_Type_Definition => |
| 1926 |
Write_Str_With_Col_Check_Sloc ("<>"); |
| 1927 |
|
| 1928 |
when N_Formal_Floating_Point_Definition => |
| 1929 |
Write_Str_With_Col_Check_Sloc ("digits <>"); |
| 1930 |
|
| 1931 |
when N_Formal_Modular_Type_Definition => |
| 1932 |
Write_Str_With_Col_Check_Sloc ("mod <>"); |
| 1933 |
|
| 1934 |
when N_Formal_Object_Declaration => |
| 1935 |
Set_Debug_Sloc; |
| 1936 |
|
| 1937 |
if Write_Indent_Identifiers (Node) then |
| 1938 |
Write_Str (" : "); |
| 1939 |
|
| 1940 |
if In_Present (Node) then |
| 1941 |
Write_Str_With_Col_Check ("in "); |
| 1942 |
end if; |
| 1943 |
|
| 1944 |
if Out_Present (Node) then |
| 1945 |
Write_Str_With_Col_Check ("out "); |
| 1946 |
end if; |
| 1947 |
|
| 1948 |
if Present (Subtype_Mark (Node)) then |
| 1949 |
|
| 1950 |
-- Ada 2005 (AI-423): Formal object with null exclusion |
| 1951 |
|
| 1952 |
if Null_Exclusion_Present (Node) then |
| 1953 |
Write_Str ("not null "); |
| 1954 |
end if; |
| 1955 |
|
| 1956 |
Sprint_Node (Subtype_Mark (Node)); |
| 1957 |
|
| 1958 |
-- Ada 2005 (AI-423): Formal object with access definition |
| 1959 |
|
| 1960 |
else |
| 1961 |
pragma Assert (Present (Access_Definition (Node))); |
| 1962 |
|
| 1963 |
Sprint_Node (Access_Definition (Node)); |
| 1964 |
end if; |
| 1965 |
|
| 1966 |
if Present (Default_Expression (Node)) then |
| 1967 |
Write_Str (" := "); |
| 1968 |
Sprint_Node (Default_Expression (Node)); |
| 1969 |
end if; |
| 1970 |
|
| 1971 |
Write_Char (';'); |
| 1972 |
end if; |
| 1973 |
|
| 1974 |
when N_Formal_Ordinary_Fixed_Point_Definition => |
| 1975 |
Write_Str_With_Col_Check_Sloc ("delta <>"); |
| 1976 |
|
| 1977 |
when N_Formal_Package_Declaration => |
| 1978 |
Write_Indent_Str_Sloc ("with package "); |
| 1979 |
Write_Id (Defining_Identifier (Node)); |
| 1980 |
Write_Str_With_Col_Check (" is new "); |
| 1981 |
Sprint_Node (Name (Node)); |
| 1982 |
Write_Str_With_Col_Check (" (<>);"); |
| 1983 |
|
| 1984 |
when N_Formal_Private_Type_Definition => |
| 1985 |
if Abstract_Present (Node) then |
| 1986 |
Write_Str_With_Col_Check ("abstract "); |
| 1987 |
end if; |
| 1988 |
|
| 1989 |
if Tagged_Present (Node) then |
| 1990 |
Write_Str_With_Col_Check ("tagged "); |
| 1991 |
end if; |
| 1992 |
|
| 1993 |
if Limited_Present (Node) then |
| 1994 |
Write_Str_With_Col_Check ("limited "); |
| 1995 |
end if; |
| 1996 |
|
| 1997 |
Write_Str_With_Col_Check_Sloc ("private"); |
| 1998 |
|
| 1999 |
when N_Formal_Incomplete_Type_Definition => |
| 2000 |
if Tagged_Present (Node) then |
| 2001 |
Write_Str_With_Col_Check ("is tagged "); |
| 2002 |
end if; |
| 2003 |
|
| 2004 |
when N_Formal_Signed_Integer_Type_Definition => |
| 2005 |
Write_Str_With_Col_Check_Sloc ("range <>"); |
| 2006 |
|
| 2007 |
when N_Formal_Type_Declaration => |
| 2008 |
Write_Indent_Str_Sloc ("type "); |
| 2009 |
Write_Id (Defining_Identifier (Node)); |
| 2010 |
|
| 2011 |
if Present (Discriminant_Specifications (Node)) then |
| 2012 |
Write_Discr_Specs (Node); |
| 2013 |
elsif Unknown_Discriminants_Present (Node) then |
| 2014 |
Write_Str_With_Col_Check ("(<>)"); |
| 2015 |
end if; |
| 2016 |
|
| 2017 |
if Nkind (Formal_Type_Definition (Node)) /= |
| 2018 |
N_Formal_Incomplete_Type_Definition |
| 2019 |
then |
| 2020 |
Write_Str_With_Col_Check (" is "); |
| 2021 |
end if; |
| 2022 |
|
| 2023 |
Sprint_Node (Formal_Type_Definition (Node)); |
| 2024 |
Write_Char (';'); |
| 2025 |
|
| 2026 |
when N_Free_Statement => |
| 2027 |
Write_Indent_Str_Sloc ("free "); |
| 2028 |
Sprint_Node (Expression (Node)); |
| 2029 |
|
| 2030 |
if Present (Storage_Pool (Node)) then |
| 2031 |
Write_Str_With_Col_Check ("[storage_pool = "); |
| 2032 |
Sprint_Node (Storage_Pool (Node)); |
| 2033 |
Write_Char (']'); |
| 2034 |
end if; |
| 2035 |
|
| 2036 |
if Present (Procedure_To_Call (Node)) then |
| 2037 |
Write_Str_With_Col_Check ("[procedure_to_call = "); |
| 2038 |
Sprint_Node (Procedure_To_Call (Node)); |
| 2039 |
Write_Char (']'); |
| 2040 |
end if; |
| 2041 |
|
| 2042 |
Write_Char (';'); |
| 2043 |
|
| 2044 |
when N_Freeze_Entity => |
| 2045 |
if Dump_Original_Only then |
| 2046 |
null; |
| 2047 |
|
| 2048 |
-- A freeze node is output if it has some effect (i.e. non-empty |
| 2049 |
-- actions, or freeze node for an itype, which causes elaboration |
| 2050 |
-- of the itype), and is also always output if Dump_Freeze_Null |
| 2051 |
-- is set True. |
| 2052 |
|
| 2053 |
elsif Present (Actions (Node)) |
| 2054 |
or else Is_Itype (Entity (Node)) |
| 2055 |
or else Dump_Freeze_Null |
| 2056 |
then |
| 2057 |
Write_Indent; |
| 2058 |
Write_Rewrite_Str ("<<<"); |
| 2059 |
Write_Str_With_Col_Check_Sloc ("freeze "); |
| 2060 |
Write_Id (Entity (Node)); |
| 2061 |
Write_Str (" ["); |
| 2062 |
|
| 2063 |
if No (Actions (Node)) then |
| 2064 |
Write_Char (']'); |
| 2065 |
|
| 2066 |
else |
| 2067 |
-- Output freeze actions. We increment Freeze_Indent during |
| 2068 |
-- this output to avoid generating extra blank lines before |
| 2069 |
-- any procedures included in the freeze actions. |
| 2070 |
|
| 2071 |
Freeze_Indent := Freeze_Indent + 1; |
| 2072 |
Sprint_Indented_List (Actions (Node)); |
| 2073 |
Freeze_Indent := Freeze_Indent - 1; |
| 2074 |
Write_Indent_Str ("]"); |
| 2075 |
end if; |
| 2076 |
|
| 2077 |
Write_Rewrite_Str (">>>"); |
| 2078 |
end if; |
| 2079 |
|
| 2080 |
when N_Freeze_Generic_Entity => |
| 2081 |
if Dump_Original_Only then |
| 2082 |
null; |
| 2083 |
|
| 2084 |
else |
| 2085 |
Write_Indent; |
| 2086 |
Write_Str_With_Col_Check_Sloc ("freeze_generic "); |
| 2087 |
Write_Id (Entity (Node)); |
| 2088 |
end if; |
| 2089 |
|
| 2090 |
when N_Full_Type_Declaration => |
| 2091 |
Write_Indent_Str_Sloc ("type "); |
| 2092 |
Sprint_Node (Defining_Identifier (Node)); |
| 2093 |
Write_Discr_Specs (Node); |
| 2094 |
Write_Str_With_Col_Check (" is "); |
| 2095 |
Sprint_Node (Type_Definition (Node)); |
| 2096 |
Write_Char (';'); |
| 2097 |
|
| 2098 |
when N_Function_Call => |
| 2099 |
Set_Debug_Sloc; |
| 2100 |
Write_Subprogram_Name (Name (Node)); |
| 2101 |
Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node)); |
| 2102 |
|
| 2103 |
when N_Function_Instantiation => |
| 2104 |
Write_Indent_Str_Sloc ("function "); |
| 2105 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2106 |
Write_Str_With_Col_Check (" is new "); |
| 2107 |
Sprint_Node (Name (Node)); |
| 2108 |
Sprint_Opt_Paren_Comma_List (Generic_Associations (Node)); |
| 2109 |
Write_Char (';'); |
| 2110 |
|
| 2111 |
when N_Function_Specification => |
| 2112 |
Write_Str_With_Col_Check_Sloc ("function "); |
| 2113 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2114 |
Write_Param_Specs (Node); |
| 2115 |
Write_Str_With_Col_Check (" return "); |
| 2116 |
|
| 2117 |
-- Ada 2005 (AI-231) |
| 2118 |
|
| 2119 |
if Nkind (Result_Definition (Node)) /= N_Access_Definition |
| 2120 |
and then Null_Exclusion_Present (Node) |
| 2121 |
then |
| 2122 |
Write_Str (" not null "); |
| 2123 |
end if; |
| 2124 |
|
| 2125 |
Sprint_Node (Result_Definition (Node)); |
| 2126 |
|
| 2127 |
when N_Generic_Association => |
| 2128 |
Set_Debug_Sloc; |
| 2129 |
|
| 2130 |
if Present (Selector_Name (Node)) then |
| 2131 |
Sprint_Node (Selector_Name (Node)); |
| 2132 |
Write_Str (" => "); |
| 2133 |
end if; |
| 2134 |
|
| 2135 |
Sprint_Node (Explicit_Generic_Actual_Parameter (Node)); |
| 2136 |
|
| 2137 |
when N_Generic_Function_Renaming_Declaration => |
| 2138 |
Write_Indent_Str_Sloc ("generic function "); |
| 2139 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2140 |
Write_Str_With_Col_Check (" renames "); |
| 2141 |
Sprint_Node (Name (Node)); |
| 2142 |
Write_Char (';'); |
| 2143 |
|
| 2144 |
when N_Generic_Declaration => |
| 2145 |
Extra_Blank_Line; |
| 2146 |
Write_Indent_Str_Sloc ("generic "); |
| 2147 |
Sprint_Indented_List (Generic_Formal_Declarations (Node)); |
| 2148 |
Write_Indent; |
| 2149 |
Sprint_Node (Specification (Node)); |
| 2150 |
Write_Char (';'); |
| 2151 |
|
| 2152 |
when N_Generic_Package_Renaming_Declaration => |
| 2153 |
Write_Indent_Str_Sloc ("generic package "); |
| 2154 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2155 |
Write_Str_With_Col_Check (" renames "); |
| 2156 |
Sprint_Node (Name (Node)); |
| 2157 |
Write_Char (';'); |
| 2158 |
|
| 2159 |
when N_Generic_Procedure_Renaming_Declaration => |
| 2160 |
Write_Indent_Str_Sloc ("generic procedure "); |
| 2161 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2162 |
Write_Str_With_Col_Check (" renames "); |
| 2163 |
Sprint_Node (Name (Node)); |
| 2164 |
Write_Char (';'); |
| 2165 |
|
| 2166 |
when N_Goto_Statement => |
| 2167 |
Write_Indent_Str_Sloc ("goto "); |
| 2168 |
Sprint_Node (Name (Node)); |
| 2169 |
Write_Char (';'); |
| 2170 |
|
| 2171 |
if Nkind (Next (Node)) = N_Label then |
| 2172 |
Write_Indent; |
| 2173 |
end if; |
| 2174 |
|
| 2175 |
when N_Goto_When_Statement => |
| 2176 |
Write_Indent_Str_Sloc ("goto "); |
| 2177 |
Sprint_Node (Name (Node)); |
| 2178 |
Write_Str (" when "); |
| 2179 |
Sprint_Node (Condition (Node)); |
| 2180 |
Write_Char (';'); |
| 2181 |
|
| 2182 |
when N_Handled_Sequence_Of_Statements => |
| 2183 |
Set_Debug_Sloc; |
| 2184 |
Sprint_Indented_List (Statements (Node)); |
| 2185 |
|
| 2186 |
if Present (Exception_Handlers (Node)) then |
| 2187 |
Write_Indent_Str ("exception"); |
| 2188 |
Indent_Begin; |
| 2189 |
Sprint_Node_List (Exception_Handlers (Node)); |
| 2190 |
Indent_End; |
| 2191 |
end if; |
| 2192 |
|
| 2193 |
Sprint_At_End_Proc (Node); |
| 2194 |
|
| 2195 |
when N_Identifier => |
| 2196 |
Set_Debug_Sloc; |
| 2197 |
Write_Id (Node); |
| 2198 |
|
| 2199 |
when N_If_Expression => |
| 2200 |
declare |
| 2201 |
Has_Parens : constant Boolean := Paren_Count (Node) > 0; |
| 2202 |
Condition : constant Node_Id := First (Expressions (Node)); |
| 2203 |
Then_Expr : constant Node_Id := Next (Condition); |
| 2204 |
|
| 2205 |
begin |
| 2206 |
-- The syntax for if_expression does not include parentheses, |
| 2207 |
-- but sometimes parentheses are required, so unconditionally |
| 2208 |
-- generate them here unless already present. |
| 2209 |
|
| 2210 |
if not Has_Parens then |
| 2211 |
Write_Char ('('); |
| 2212 |
end if; |
| 2213 |
|
| 2214 |
Write_Str_With_Col_Check_Sloc ("if "); |
| 2215 |
Sprint_Node (Condition); |
| 2216 |
Write_Str_With_Col_Check (" then "); |
| 2217 |
|
| 2218 |
-- Defense against junk here |
| 2219 |
|
| 2220 |
if Present (Then_Expr) then |
| 2221 |
Sprint_Node (Then_Expr); |
| 2222 |
|
| 2223 |
if Present (Next (Then_Expr)) then |
| 2224 |
Write_Str_With_Col_Check (" else "); |
| 2225 |
Sprint_Node (Next (Then_Expr)); |
| 2226 |
end if; |
| 2227 |
end if; |
| 2228 |
|
| 2229 |
if not Has_Parens then |
| 2230 |
Write_Char (')'); |
| 2231 |
end if; |
| 2232 |
end; |
| 2233 |
|
| 2234 |
when N_If_Statement => |
| 2235 |
Write_Indent_Str_Sloc ("if "); |
| 2236 |
Sprint_Node (Condition (Node)); |
| 2237 |
Write_Str_With_Col_Check (" then"); |
| 2238 |
Sprint_Indented_List (Then_Statements (Node)); |
| 2239 |
Sprint_Opt_Node_List (Elsif_Parts (Node)); |
| 2240 |
|
| 2241 |
if Present (Else_Statements (Node)) then |
| 2242 |
Write_Indent_Str ("else"); |
| 2243 |
Sprint_Indented_List (Else_Statements (Node)); |
| 2244 |
end if; |
| 2245 |
|
| 2246 |
Write_Indent_Str ("end if;"); |
| 2247 |
|
| 2248 |
when N_Implicit_Label_Declaration => |
| 2249 |
if not Dump_Original_Only then |
| 2250 |
Write_Indent; |
| 2251 |
Write_Rewrite_Str ("<<<"); |
| 2252 |
Set_Debug_Sloc; |
| 2253 |
Write_Id (Defining_Identifier (Node)); |
| 2254 |
Write_Str (" : "); |
| 2255 |
Write_Str_With_Col_Check ("label"); |
| 2256 |
Write_Rewrite_Str (">>>"); |
| 2257 |
end if; |
| 2258 |
|
| 2259 |
when N_In => |
| 2260 |
Sprint_Left_Opnd (Node); |
| 2261 |
Write_Str_Sloc (" in "); |
| 2262 |
|
| 2263 |
if Present (Right_Opnd (Node)) then |
| 2264 |
Sprint_Right_Opnd (Node); |
| 2265 |
else |
| 2266 |
Sprint_Bar_List (Alternatives (Node)); |
| 2267 |
end if; |
| 2268 |
|
| 2269 |
when N_Incomplete_Type_Declaration => |
| 2270 |
Write_Indent_Str_Sloc ("type "); |
| 2271 |
Write_Id (Defining_Identifier (Node)); |
| 2272 |
|
| 2273 |
if Present (Discriminant_Specifications (Node)) then |
| 2274 |
Write_Discr_Specs (Node); |
| 2275 |
elsif Unknown_Discriminants_Present (Node) then |
| 2276 |
Write_Str_With_Col_Check ("(<>)"); |
| 2277 |
end if; |
| 2278 |
|
| 2279 |
Write_Char (';'); |
| 2280 |
|
| 2281 |
when N_Index_Or_Discriminant_Constraint => |
| 2282 |
Set_Debug_Sloc; |
| 2283 |
Sprint_Paren_Comma_List (Constraints (Node)); |
| 2284 |
|
| 2285 |
when N_Indexed_Component => |
| 2286 |
Sprint_Node_Sloc (Prefix (Node)); |
| 2287 |
Sprint_Opt_Paren_Comma_List (Expressions (Node)); |
| 2288 |
|
| 2289 |
when N_Integer_Literal => |
| 2290 |
if Print_In_Hex (Node) then |
| 2291 |
Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex); |
| 2292 |
else |
| 2293 |
Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto); |
| 2294 |
end if; |
| 2295 |
|
| 2296 |
when N_Iteration_Scheme => |
| 2297 |
if Present (Condition (Node)) then |
| 2298 |
Write_Str_With_Col_Check_Sloc ("while "); |
| 2299 |
Sprint_Node (Condition (Node)); |
| 2300 |
else |
| 2301 |
Write_Str_With_Col_Check_Sloc ("for "); |
| 2302 |
|
| 2303 |
if Present (Iterator_Specification (Node)) then |
| 2304 |
Sprint_Node (Iterator_Specification (Node)); |
| 2305 |
else |
| 2306 |
Sprint_Node (Loop_Parameter_Specification (Node)); |
| 2307 |
end if; |
| 2308 |
end if; |
| 2309 |
|
| 2310 |
Write_Char (' '); |
| 2311 |
|
| 2312 |
when N_Iterator_Specification => |
| 2313 |
Set_Debug_Sloc; |
| 2314 |
Write_Id (Defining_Identifier (Node)); |
| 2315 |
|
| 2316 |
if Present (Subtype_Indication (Node)) then |
| 2317 |
Write_Str_With_Col_Check (" : "); |
| 2318 |
Sprint_Node (Subtype_Indication (Node)); |
| 2319 |
end if; |
| 2320 |
|
| 2321 |
if Of_Present (Node) then |
| 2322 |
Write_Str_With_Col_Check (" of "); |
| 2323 |
else |
| 2324 |
Write_Str_With_Col_Check (" in "); |
| 2325 |
end if; |
| 2326 |
|
| 2327 |
if Reverse_Present (Node) then |
| 2328 |
Write_Str_With_Col_Check ("reverse "); |
| 2329 |
end if; |
| 2330 |
|
| 2331 |
Sprint_Node (Name (Node)); |
| 2332 |
|
| 2333 |
if Present (Iterator_Filter (Node)) then |
| 2334 |
Write_Str (" when "); |
| 2335 |
Sprint_Node (Iterator_Filter (Node)); |
| 2336 |
end if; |
| 2337 |
|
| 2338 |
when N_Itype_Reference => |
| 2339 |
Write_Indent_Str_Sloc ("reference "); |
| 2340 |
Write_Id (Itype (Node)); |
| 2341 |
|
| 2342 |
when N_Label => |
| 2343 |
Write_Indent_Str_Sloc ("<<"); |
| 2344 |
Write_Id (Identifier (Node)); |
| 2345 |
Write_Str (">>"); |
| 2346 |
|
| 2347 |
when N_Loop_Parameter_Specification => |
| 2348 |
Set_Debug_Sloc; |
| 2349 |
Write_Id (Defining_Identifier (Node)); |
| 2350 |
Write_Str_With_Col_Check (" in "); |
| 2351 |
|
| 2352 |
if Reverse_Present (Node) then |
| 2353 |
Write_Str_With_Col_Check ("reverse "); |
| 2354 |
end if; |
| 2355 |
|
| 2356 |
Sprint_Node (Discrete_Subtype_Definition (Node)); |
| 2357 |
|
| 2358 |
when N_Loop_Statement => |
| 2359 |
Write_Indent; |
| 2360 |
|
| 2361 |
if Present (Identifier (Node)) |
| 2362 |
and then (not Has_Created_Identifier (Node) |
| 2363 |
or else not Dump_Original_Only) |
| 2364 |
then |
| 2365 |
Write_Rewrite_Str ("<<<"); |
| 2366 |
Write_Id (Identifier (Node)); |
| 2367 |
Write_Str (" : "); |
| 2368 |
Write_Rewrite_Str (">>>"); |
| 2369 |
Sprint_Node (Iteration_Scheme (Node)); |
| 2370 |
Write_Str_With_Col_Check_Sloc ("loop"); |
| 2371 |
Sprint_Indented_List (Statements (Node)); |
| 2372 |
Write_Indent_Str ("end loop "); |
| 2373 |
Write_Rewrite_Str ("<<<"); |
| 2374 |
Write_Id (Identifier (Node)); |
| 2375 |
Write_Rewrite_Str (">>>"); |
| 2376 |
Write_Char (';'); |
| 2377 |
|
| 2378 |
else |
| 2379 |
Sprint_Node (Iteration_Scheme (Node)); |
| 2380 |
Write_Str_With_Col_Check_Sloc ("loop"); |
| 2381 |
Sprint_Indented_List (Statements (Node)); |
| 2382 |
Write_Indent_Str ("end loop;"); |
| 2383 |
end if; |
| 2384 |
|
| 2385 |
when N_Mod_Clause => |
| 2386 |
Sprint_Node_List (Pragmas_Before (Node)); |
| 2387 |
Write_Str_With_Col_Check_Sloc ("at mod "); |
| 2388 |
Sprint_Node (Expression (Node)); |
| 2389 |
|
| 2390 |
when N_Modular_Type_Definition => |
| 2391 |
Write_Str_With_Col_Check_Sloc ("mod "); |
| 2392 |
Sprint_Node (Expression (Node)); |
| 2393 |
|
| 2394 |
when N_Not_In => |
| 2395 |
Sprint_Left_Opnd (Node); |
| 2396 |
Write_Str_Sloc (" not in "); |
| 2397 |
|
| 2398 |
if Present (Right_Opnd (Node)) then |
| 2399 |
Sprint_Right_Opnd (Node); |
| 2400 |
else |
| 2401 |
Sprint_Bar_List (Alternatives (Node)); |
| 2402 |
end if; |
| 2403 |
|
| 2404 |
when N_Null => |
| 2405 |
Write_Str_With_Col_Check_Sloc ("null"); |
| 2406 |
|
| 2407 |
when N_Null_Statement => |
| 2408 |
if Comes_From_Source (Node) |
| 2409 |
or else Dump_Freeze_Null |
| 2410 |
or else not Is_List_Member (Node) |
| 2411 |
or else (No (Prev (Node)) and then No (Next (Node))) |
| 2412 |
then |
| 2413 |
Write_Indent_Str_Sloc ("null;"); |
| 2414 |
end if; |
| 2415 |
|
| 2416 |
when N_Number_Declaration => |
| 2417 |
Set_Debug_Sloc; |
| 2418 |
|
| 2419 |
if Write_Indent_Identifiers (Node) then |
| 2420 |
Write_Str_With_Col_Check (" : constant "); |
| 2421 |
Write_Str (" := "); |
| 2422 |
Sprint_Node (Expression (Node)); |
| 2423 |
Write_Char (';'); |
| 2424 |
end if; |
| 2425 |
|
| 2426 |
when N_Object_Declaration => |
| 2427 |
Set_Debug_Sloc; |
| 2428 |
|
| 2429 |
if Write_Indent_Identifiers (Node) then |
| 2430 |
declare |
| 2431 |
Def_Id : constant Entity_Id := Defining_Identifier (Node); |
| 2432 |
|
| 2433 |
begin |
| 2434 |
Write_Str_With_Col_Check (" : "); |
| 2435 |
|
| 2436 |
if Is_Statically_Allocated (Def_Id) then |
| 2437 |
Write_Str_With_Col_Check ("static "); |
| 2438 |
end if; |
| 2439 |
|
| 2440 |
if Aliased_Present (Node) then |
| 2441 |
Write_Str_With_Col_Check ("aliased "); |
| 2442 |
end if; |
| 2443 |
|
| 2444 |
if Constant_Present (Node) then |
| 2445 |
Write_Str_With_Col_Check ("constant "); |
| 2446 |
end if; |
| 2447 |
|
| 2448 |
-- Ada 2005 (AI-231) |
| 2449 |
|
| 2450 |
if Null_Exclusion_Present (Node) then |
| 2451 |
Write_Str_With_Col_Check ("not null "); |
| 2452 |
end if; |
| 2453 |
|
| 2454 |
-- Print type. We used to print the Object_Definition from |
| 2455 |
-- the node, but it is much more useful to print the Etype |
| 2456 |
-- of the defining identifier for the case where the nominal |
| 2457 |
-- type is an unconstrained array type. For example, this |
| 2458 |
-- will be a clear reference to the Itype with the bounds |
| 2459 |
-- in the case of a type like String. The object after |
| 2460 |
-- all is constrained, even if its nominal subtype is |
| 2461 |
-- unconstrained. |
| 2462 |
|
| 2463 |
declare |
| 2464 |
Odef : constant Node_Id := Object_Definition (Node); |
| 2465 |
|
| 2466 |
begin |
| 2467 |
if Nkind (Odef) = N_Identifier |
| 2468 |
and then Present (Etype (Odef)) |
| 2469 |
and then Is_Array_Type (Etype (Odef)) |
| 2470 |
and then not Is_Constrained (Etype (Odef)) |
| 2471 |
and then Present (Etype (Def_Id)) |
| 2472 |
then |
| 2473 |
Sprint_Node (Etype (Def_Id)); |
| 2474 |
|
| 2475 |
-- In other cases, the nominal type is fine to print |
| 2476 |
|
| 2477 |
else |
| 2478 |
Sprint_Node (Odef); |
| 2479 |
end if; |
| 2480 |
end; |
| 2481 |
|
| 2482 |
if Present (Expression (Node)) |
| 2483 |
and then Expression (Node) /= Error |
| 2484 |
and then not No_Initialization (Node) |
| 2485 |
then |
| 2486 |
Write_Str (" := "); |
| 2487 |
Sprint_Node (Expression (Node)); |
| 2488 |
end if; |
| 2489 |
|
| 2490 |
Write_Char (';'); |
| 2491 |
|
| 2492 |
-- Handle implicit importation and implicit exportation of |
| 2493 |
-- object declarations: |
| 2494 |
-- $pragma import (Convention_Id, Def_Id, "..."); |
| 2495 |
-- $pragma export (Convention_Id, Def_Id, "..."); |
| 2496 |
|
| 2497 |
if Is_Internal (Def_Id) |
| 2498 |
and then Present (Interface_Name (Def_Id)) |
| 2499 |
then |
| 2500 |
Write_Indent_Str_Sloc ("$pragma "); |
| 2501 |
|
| 2502 |
if Is_Imported (Def_Id) then |
| 2503 |
Write_Str ("import ("); |
| 2504 |
|
| 2505 |
else pragma Assert (Is_Exported (Def_Id)); |
| 2506 |
Write_Str ("export ("); |
| 2507 |
end if; |
| 2508 |
|
| 2509 |
declare |
| 2510 |
Prefix : constant String := "Convention_"; |
| 2511 |
S : constant String := Convention (Def_Id)'Img; |
| 2512 |
|
| 2513 |
begin |
| 2514 |
Name_Len := S'Last - Prefix'Last; |
| 2515 |
Name_Buffer (1 .. Name_Len) := |
| 2516 |
S (Prefix'Last + 1 .. S'Last); |
| 2517 |
Set_Casing (All_Lower_Case); |
| 2518 |
Write_Str (Name_Buffer (1 .. Name_Len)); |
| 2519 |
end; |
| 2520 |
|
| 2521 |
Write_Str (", "); |
| 2522 |
Write_Id (Def_Id); |
| 2523 |
Write_Str (", "); |
| 2524 |
Write_String_Table_Entry |
| 2525 |
(Strval (Interface_Name (Def_Id))); |
| 2526 |
Write_Str (");"); |
| 2527 |
end if; |
| 2528 |
end; |
| 2529 |
end if; |
| 2530 |
|
| 2531 |
when N_Object_Renaming_Declaration => |
| 2532 |
Write_Indent; |
| 2533 |
Set_Debug_Sloc; |
| 2534 |
Sprint_Node (Defining_Identifier (Node)); |
| 2535 |
|
| 2536 |
-- Ada 2005 (AI-230): Access renamings |
| 2537 |
|
| 2538 |
if Present (Access_Definition (Node)) then |
| 2539 |
Write_Str (" : "); |
| 2540 |
Sprint_Node (Access_Definition (Node)); |
| 2541 |
|
| 2542 |
elsif Present (Subtype_Mark (Node)) then |
| 2543 |
Write_Str (" : "); |
| 2544 |
|
| 2545 |
-- Ada 2005 (AI-423): Object renaming with a null exclusion |
| 2546 |
|
| 2547 |
if Null_Exclusion_Present (Node) then |
| 2548 |
Write_Str ("not null "); |
| 2549 |
end if; |
| 2550 |
|
| 2551 |
Sprint_Node (Subtype_Mark (Node)); |
| 2552 |
|
| 2553 |
-- AI12-0275: Object_Renaming_Declaration without explicit subtype |
| 2554 |
|
| 2555 |
elsif Ada_Version >= Ada_2022 then |
| 2556 |
null; |
| 2557 |
|
| 2558 |
else |
| 2559 |
Write_Str (" : ??? "); |
| 2560 |
end if; |
| 2561 |
|
| 2562 |
Write_Str_With_Col_Check (" renames "); |
| 2563 |
Sprint_Node (Name (Node)); |
| 2564 |
Write_Char (';'); |
| 2565 |
|
| 2566 |
when N_Op_Abs => |
| 2567 |
Write_Operator (Node, "abs "); |
| 2568 |
Sprint_Right_Opnd (Node); |
| 2569 |
|
| 2570 |
when N_Op_Add => |
| 2571 |
Sprint_Left_Opnd (Node); |
| 2572 |
Write_Operator (Node, " + "); |
| 2573 |
Sprint_Right_Opnd (Node); |
| 2574 |
|
| 2575 |
when N_Op_And => |
| 2576 |
Sprint_Left_Opnd (Node); |
| 2577 |
Write_Operator (Node, " and "); |
| 2578 |
Sprint_Right_Opnd (Node); |
| 2579 |
|
| 2580 |
when N_Op_Concat => |
| 2581 |
Sprint_Left_Opnd (Node); |
| 2582 |
Write_Operator (Node, " & "); |
| 2583 |
Sprint_Right_Opnd (Node); |
| 2584 |
|
| 2585 |
when N_Op_Divide => |
| 2586 |
Sprint_Left_Opnd (Node); |
| 2587 |
Write_Char (' '); |
| 2588 |
if Rounded_Result (Node) then |
| 2589 |
Write_Char ('@'); |
| 2590 |
end if; |
| 2591 |
Write_Operator (Node, "/ "); |
| 2592 |
Sprint_Right_Opnd (Node); |
| 2593 |
|
| 2594 |
when N_Op_Eq => |
| 2595 |
Sprint_Left_Opnd (Node); |
| 2596 |
Write_Operator (Node, " = "); |
| 2597 |
Sprint_Right_Opnd (Node); |
| 2598 |
|
| 2599 |
when N_Op_Expon => |
| 2600 |
Sprint_Left_Opnd (Node); |
| 2601 |
Write_Operator (Node, " ** "); |
| 2602 |
Sprint_Right_Opnd (Node); |
| 2603 |
|
| 2604 |
when N_Op_Ge => |
| 2605 |
Sprint_Left_Opnd (Node); |
| 2606 |
Write_Operator (Node, " >= "); |
| 2607 |
Sprint_Right_Opnd (Node); |
| 2608 |
|
| 2609 |
when N_Op_Gt => |
| 2610 |
Sprint_Left_Opnd (Node); |
| 2611 |
Write_Operator (Node, " > "); |
| 2612 |
Sprint_Right_Opnd (Node); |
| 2613 |
|
| 2614 |
when N_Op_Le => |
| 2615 |
Sprint_Left_Opnd (Node); |
| 2616 |
Write_Operator (Node, " <= "); |
| 2617 |
Sprint_Right_Opnd (Node); |
| 2618 |
|
| 2619 |
when N_Op_Lt => |
| 2620 |
Sprint_Left_Opnd (Node); |
| 2621 |
Write_Operator (Node, " < "); |
| 2622 |
Sprint_Right_Opnd (Node); |
| 2623 |
|
| 2624 |
when N_Op_Minus => |
| 2625 |
Write_Operator (Node, "-"); |
| 2626 |
Sprint_Right_Opnd (Node); |
| 2627 |
|
| 2628 |
when N_Op_Mod => |
| 2629 |
Sprint_Left_Opnd (Node); |
| 2630 |
Write_Operator (Node, " mod "); |
| 2631 |
Sprint_Right_Opnd (Node); |
| 2632 |
|
| 2633 |
when N_Op_Multiply => |
| 2634 |
Sprint_Left_Opnd (Node); |
| 2635 |
Write_Char (' '); |
| 2636 |
if Rounded_Result (Node) then |
| 2637 |
Write_Char ('@'); |
| 2638 |
end if; |
| 2639 |
Write_Operator (Node, "* "); |
| 2640 |
Sprint_Right_Opnd (Node); |
| 2641 |
|
| 2642 |
when N_Op_Ne => |
| 2643 |
Sprint_Left_Opnd (Node); |
| 2644 |
Write_Operator (Node, " /= "); |
| 2645 |
Sprint_Right_Opnd (Node); |
| 2646 |
|
| 2647 |
when N_Op_Not => |
| 2648 |
Write_Operator (Node, "not "); |
| 2649 |
Sprint_Right_Opnd (Node); |
| 2650 |
|
| 2651 |
when N_Op_Or => |
| 2652 |
Sprint_Left_Opnd (Node); |
| 2653 |
Write_Operator (Node, " or "); |
| 2654 |
Sprint_Right_Opnd (Node); |
| 2655 |
|
| 2656 |
when N_Op_Plus => |
| 2657 |
Write_Operator (Node, "+"); |
| 2658 |
Sprint_Right_Opnd (Node); |
| 2659 |
|
| 2660 |
when N_Op_Rem => |
| 2661 |
Sprint_Left_Opnd (Node); |
| 2662 |
Write_Operator (Node, " rem "); |
| 2663 |
Sprint_Right_Opnd (Node); |
| 2664 |
|
| 2665 |
when N_Op_Shift => |
| 2666 |
Set_Debug_Sloc; |
| 2667 |
Write_Id (Node); |
| 2668 |
Write_Char ('!'); |
| 2669 |
Write_Str_With_Col_Check ("("); |
| 2670 |
Sprint_Node (Left_Opnd (Node)); |
| 2671 |
Write_Str (", "); |
| 2672 |
Sprint_Node (Right_Opnd (Node)); |
| 2673 |
Write_Char (')'); |
| 2674 |
|
| 2675 |
when N_Op_Subtract => |
| 2676 |
Sprint_Left_Opnd (Node); |
| 2677 |
Write_Operator (Node, " - "); |
| 2678 |
Sprint_Right_Opnd (Node); |
| 2679 |
|
| 2680 |
when N_Op_Xor => |
| 2681 |
Sprint_Left_Opnd (Node); |
| 2682 |
Write_Operator (Node, " xor "); |
| 2683 |
Sprint_Right_Opnd (Node); |
| 2684 |
|
| 2685 |
when N_Operator_Symbol => |
| 2686 |
Write_Name_With_Col_Check_Sloc (Chars (Node)); |
| 2687 |
|
| 2688 |
when N_Ordinary_Fixed_Point_Definition => |
| 2689 |
Write_Str_With_Col_Check_Sloc ("delta "); |
| 2690 |
Sprint_Node (Delta_Expression (Node)); |
| 2691 |
Sprint_Opt_Node (Real_Range_Specification (Node)); |
| 2692 |
|
| 2693 |
when N_Or_Else => |
| 2694 |
Sprint_Left_Opnd (Node); |
| 2695 |
Write_Str_Sloc (" or else "); |
| 2696 |
Sprint_Right_Opnd (Node); |
| 2697 |
|
| 2698 |
when N_Others_Choice => |
| 2699 |
if All_Others (Node) then |
| 2700 |
Write_Str_With_Col_Check ("all "); |
| 2701 |
end if; |
| 2702 |
|
| 2703 |
Write_Str_With_Col_Check_Sloc ("others"); |
| 2704 |
|
| 2705 |
when N_Package_Body => |
| 2706 |
Extra_Blank_Line; |
| 2707 |
Write_Indent_Str_Sloc ("package body "); |
| 2708 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2709 |
Write_Str (" is"); |
| 2710 |
Sprint_Indented_List (Declarations (Node)); |
| 2711 |
|
| 2712 |
if Present (Handled_Statement_Sequence (Node)) then |
| 2713 |
Write_Indent_Str ("begin"); |
| 2714 |
Sprint_Node (Handled_Statement_Sequence (Node)); |
| 2715 |
end if; |
| 2716 |
|
| 2717 |
Write_Indent_Str ("end "); |
| 2718 |
Sprint_End_Label |
| 2719 |
(Handled_Statement_Sequence (Node), Defining_Unit_Name (Node)); |
| 2720 |
Write_Char (';'); |
| 2721 |
Sprint_At_End_Proc (Node); |
| 2722 |
|
| 2723 |
when N_Package_Body_Stub => |
| 2724 |
Write_Indent_Str_Sloc ("package body "); |
| 2725 |
Sprint_Node (Defining_Identifier (Node)); |
| 2726 |
Write_Str_With_Col_Check (" is separate;"); |
| 2727 |
|
| 2728 |
when N_Package_Declaration => |
| 2729 |
Extra_Blank_Line; |
| 2730 |
Write_Indent; |
| 2731 |
Sprint_Node_Sloc (Specification (Node)); |
| 2732 |
Write_Char (';'); |
| 2733 |
|
| 2734 |
-- If this is an instantiation, get the aspects from the original |
| 2735 |
-- instantiation node. |
| 2736 |
|
| 2737 |
if Is_Generic_Instance (Defining_Entity (Node)) |
| 2738 |
and then Has_Aspects |
| 2739 |
(Package_Instantiation (Defining_Entity (Node))) |
| 2740 |
then |
| 2741 |
Sprint_Aspect_Specifications |
| 2742 |
(Package_Instantiation (Defining_Entity (Node)), |
| 2743 |
Semicolon => True); |
| 2744 |
end if; |
| 2745 |
|
| 2746 |
when N_Package_Instantiation => |
| 2747 |
Extra_Blank_Line; |
| 2748 |
Write_Indent_Str_Sloc ("package "); |
| 2749 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2750 |
Write_Str (" is new "); |
| 2751 |
Sprint_Node (Name (Node)); |
| 2752 |
Sprint_Opt_Paren_Comma_List (Generic_Associations (Node)); |
| 2753 |
Write_Char (';'); |
| 2754 |
|
| 2755 |
when N_Package_Renaming_Declaration => |
| 2756 |
Write_Indent_Str_Sloc ("package "); |
| 2757 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2758 |
Write_Str_With_Col_Check (" renames "); |
| 2759 |
Sprint_Node (Name (Node)); |
| 2760 |
Write_Char (';'); |
| 2761 |
|
| 2762 |
when N_Package_Specification => |
| 2763 |
Write_Str_With_Col_Check_Sloc ("package "); |
| 2764 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2765 |
|
| 2766 |
if Nkind (Parent (Node)) = N_Generic_Package_Declaration |
| 2767 |
and then Has_Aspects (Parent (Node)) |
| 2768 |
then |
| 2769 |
Sprint_Aspect_Specifications |
| 2770 |
(Parent (Node), Semicolon => False); |
| 2771 |
|
| 2772 |
-- An instantiation is rewritten as a package declaration, but |
| 2773 |
-- the aspects belong to the instantiation node. |
| 2774 |
|
| 2775 |
elsif Nkind (Parent (Node)) = N_Package_Declaration then |
| 2776 |
declare |
| 2777 |
Pack : constant Entity_Id := Defining_Entity (Node); |
| 2778 |
|
| 2779 |
begin |
| 2780 |
if not Is_Generic_Instance (Pack) then |
| 2781 |
if Has_Aspects (Parent (Node)) then |
| 2782 |
Sprint_Aspect_Specifications |
| 2783 |
(Parent (Node), Semicolon => False); |
| 2784 |
end if; |
| 2785 |
end if; |
| 2786 |
end; |
| 2787 |
end if; |
| 2788 |
|
| 2789 |
Write_Str (" is"); |
| 2790 |
Sprint_Indented_List (Visible_Declarations (Node)); |
| 2791 |
|
| 2792 |
if Present (Private_Declarations (Node)) then |
| 2793 |
Write_Indent_Str ("private"); |
| 2794 |
Sprint_Indented_List (Private_Declarations (Node)); |
| 2795 |
end if; |
| 2796 |
|
| 2797 |
Write_Indent_Str ("end "); |
| 2798 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2799 |
|
| 2800 |
when N_Parameter_Association => |
| 2801 |
Sprint_Node_Sloc (Selector_Name (Node)); |
| 2802 |
Write_Str (" => "); |
| 2803 |
Sprint_Node (Explicit_Actual_Parameter (Node)); |
| 2804 |
|
| 2805 |
when N_Parameter_Specification => |
| 2806 |
Set_Debug_Sloc; |
| 2807 |
|
| 2808 |
if Write_Identifiers (Node) then |
| 2809 |
Write_Str (" : "); |
| 2810 |
|
| 2811 |
if In_Present (Node) then |
| 2812 |
Write_Str_With_Col_Check ("in "); |
| 2813 |
end if; |
| 2814 |
|
| 2815 |
if Out_Present (Node) then |
| 2816 |
Write_Str_With_Col_Check ("out "); |
| 2817 |
end if; |
| 2818 |
|
| 2819 |
-- Ada 2005 (AI-231): Parameter specification may carry null |
| 2820 |
-- exclusion. Do not print it now if this is an access formal, |
| 2821 |
-- it is emitted when the access definition is displayed. |
| 2822 |
|
| 2823 |
if Null_Exclusion_Present (Node) |
| 2824 |
and then Nkind (Parameter_Type (Node)) /= N_Access_Definition |
| 2825 |
then |
| 2826 |
Write_Str ("not null "); |
| 2827 |
end if; |
| 2828 |
|
| 2829 |
if Aliased_Present (Node) then |
| 2830 |
Write_Str ("aliased "); |
| 2831 |
end if; |
| 2832 |
|
| 2833 |
Sprint_Node (Parameter_Type (Node)); |
| 2834 |
|
| 2835 |
if Present (Expression (Node)) then |
| 2836 |
Write_Str (" := "); |
| 2837 |
Sprint_Node (Expression (Node)); |
| 2838 |
end if; |
| 2839 |
else |
| 2840 |
Write_Str (", "); |
| 2841 |
end if; |
| 2842 |
|
| 2843 |
when N_Pop_Constraint_Error_Label => |
| 2844 |
Write_Indent_Str ("%pop_constraint_error_label"); |
| 2845 |
|
| 2846 |
when N_Pop_Program_Error_Label => |
| 2847 |
Write_Indent_Str ("%pop_program_error_label"); |
| 2848 |
|
| 2849 |
when N_Pop_Storage_Error_Label => |
| 2850 |
Write_Indent_Str ("%pop_storage_error_label"); |
| 2851 |
|
| 2852 |
when N_Private_Extension_Declaration => |
| 2853 |
Write_Indent_Str_Sloc ("type "); |
| 2854 |
Write_Id (Defining_Identifier (Node)); |
| 2855 |
|
| 2856 |
if Present (Discriminant_Specifications (Node)) then |
| 2857 |
Write_Discr_Specs (Node); |
| 2858 |
elsif Unknown_Discriminants_Present (Node) then |
| 2859 |
Write_Str_With_Col_Check ("(<>)"); |
| 2860 |
end if; |
| 2861 |
|
| 2862 |
Write_Str_With_Col_Check (" is new "); |
| 2863 |
Sprint_Node (Subtype_Indication (Node)); |
| 2864 |
|
| 2865 |
if Present (Interface_List (Node)) then |
| 2866 |
Write_Str_With_Col_Check (" and "); |
| 2867 |
Sprint_And_List (Interface_List (Node)); |
| 2868 |
end if; |
| 2869 |
|
| 2870 |
Write_Str_With_Col_Check (" with private;"); |
| 2871 |
|
| 2872 |
when N_Private_Type_Declaration => |
| 2873 |
Write_Indent_Str_Sloc ("type "); |
| 2874 |
Write_Id (Defining_Identifier (Node)); |
| 2875 |
|
| 2876 |
if Present (Discriminant_Specifications (Node)) then |
| 2877 |
Write_Discr_Specs (Node); |
| 2878 |
elsif Unknown_Discriminants_Present (Node) then |
| 2879 |
Write_Str_With_Col_Check ("(<>)"); |
| 2880 |
end if; |
| 2881 |
|
| 2882 |
Write_Str (" is "); |
| 2883 |
|
| 2884 |
if Tagged_Present (Node) then |
| 2885 |
Write_Str_With_Col_Check ("tagged "); |
| 2886 |
end if; |
| 2887 |
|
| 2888 |
if Limited_Present (Node) then |
| 2889 |
Write_Str_With_Col_Check ("limited "); |
| 2890 |
end if; |
| 2891 |
|
| 2892 |
Write_Str_With_Col_Check ("private;"); |
| 2893 |
|
| 2894 |
when N_Push_Constraint_Error_Label => |
| 2895 |
Write_Indent_Str ("%push_constraint_error_label ("); |
| 2896 |
|
| 2897 |
if Present (Exception_Label (Node)) then |
| 2898 |
Write_Name_With_Col_Check (Chars (Exception_Label (Node))); |
| 2899 |
end if; |
| 2900 |
|
| 2901 |
Write_Str (")"); |
| 2902 |
|
| 2903 |
when N_Push_Program_Error_Label => |
| 2904 |
Write_Indent_Str ("%push_program_error_label ("); |
| 2905 |
|
| 2906 |
if Present (Exception_Label (Node)) then |
| 2907 |
Write_Name_With_Col_Check (Chars (Exception_Label (Node))); |
| 2908 |
end if; |
| 2909 |
|
| 2910 |
Write_Str (")"); |
| 2911 |
|
| 2912 |
when N_Push_Storage_Error_Label => |
| 2913 |
Write_Indent_Str ("%push_storage_error_label ("); |
| 2914 |
|
| 2915 |
if Present (Exception_Label (Node)) then |
| 2916 |
Write_Name_With_Col_Check (Chars (Exception_Label (Node))); |
| 2917 |
end if; |
| 2918 |
|
| 2919 |
Write_Str (")"); |
| 2920 |
|
| 2921 |
when N_Pragma => |
| 2922 |
Write_Indent_Str_Sloc ("pragma "); |
| 2923 |
Write_Name_With_Col_Check (Pragma_Name_Unmapped (Node)); |
| 2924 |
|
| 2925 |
if Present (Pragma_Argument_Associations (Node)) then |
| 2926 |
Sprint_Opt_Paren_Comma_List |
| 2927 |
(Pragma_Argument_Associations (Node)); |
| 2928 |
end if; |
| 2929 |
|
| 2930 |
Write_Char (';'); |
| 2931 |
|
| 2932 |
when N_Pragma_Argument_Association => |
| 2933 |
Set_Debug_Sloc; |
| 2934 |
|
| 2935 |
if Chars (Node) /= No_Name then |
| 2936 |
Write_Name_With_Col_Check (Chars (Node)); |
| 2937 |
Write_Str (" => "); |
| 2938 |
end if; |
| 2939 |
|
| 2940 |
Sprint_Node (Expression (Node)); |
| 2941 |
|
| 2942 |
when N_Procedure_Call_Statement => |
| 2943 |
Write_Indent; |
| 2944 |
Set_Debug_Sloc; |
| 2945 |
Write_Subprogram_Name (Name (Node)); |
| 2946 |
Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node)); |
| 2947 |
Write_Char (';'); |
| 2948 |
|
| 2949 |
when N_Procedure_Instantiation => |
| 2950 |
Write_Indent_Str_Sloc ("procedure "); |
| 2951 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2952 |
Write_Str_With_Col_Check (" is new "); |
| 2953 |
Sprint_Node (Name (Node)); |
| 2954 |
Sprint_Opt_Paren_Comma_List (Generic_Associations (Node)); |
| 2955 |
Write_Char (';'); |
| 2956 |
|
| 2957 |
when N_Procedure_Specification => |
| 2958 |
Write_Str_With_Col_Check_Sloc ("procedure "); |
| 2959 |
Sprint_Node (Defining_Unit_Name (Node)); |
| 2960 |
Write_Param_Specs (Node); |
| 2961 |
|
| 2962 |
when N_Protected_Body => |
| 2963 |
Write_Indent_Str_Sloc ("protected body "); |
| 2964 |
Write_Id (Defining_Identifier (Node)); |
| 2965 |
Write_Str (" is"); |
| 2966 |
Sprint_Indented_List (Declarations (Node)); |
| 2967 |
Write_Indent_Str ("end "); |
| 2968 |
Write_Id (Defining_Identifier (Node)); |
| 2969 |
Write_Char (';'); |
| 2970 |
|
| 2971 |
when N_Protected_Body_Stub => |
| 2972 |
Write_Indent_Str_Sloc ("protected body "); |
| 2973 |
Write_Id (Defining_Identifier (Node)); |
| 2974 |
Write_Str_With_Col_Check (" is separate;"); |
| 2975 |
|
| 2976 |
when N_Protected_Definition => |
| 2977 |
Set_Debug_Sloc; |
| 2978 |
Sprint_Indented_List (Visible_Declarations (Node)); |
| 2979 |
|
| 2980 |
if Present (Private_Declarations (Node)) then |
| 2981 |
Write_Indent_Str ("private"); |
| 2982 |
Sprint_Indented_List (Private_Declarations (Node)); |
| 2983 |
end if; |
| 2984 |
|
| 2985 |
Write_Indent_Str ("end "); |
| 2986 |
|
| 2987 |
when N_Protected_Type_Declaration => |
| 2988 |
Write_Indent_Str_Sloc ("protected type "); |
| 2989 |
Sprint_Node (Defining_Identifier (Node)); |
| 2990 |
Write_Discr_Specs (Node); |
| 2991 |
|
| 2992 |
if Present (Interface_List (Node)) then |
| 2993 |
Write_Str (" is new "); |
| 2994 |
Sprint_And_List (Interface_List (Node)); |
| 2995 |
Write_Str (" with "); |
| 2996 |
else |
| 2997 |
Write_Str (" is"); |
| 2998 |
end if; |
| 2999 |
|
| 3000 |
Sprint_Node (Protected_Definition (Node)); |
| 3001 |
Write_Id (Defining_Identifier (Node)); |
| 3002 |
Write_Char (';'); |
| 3003 |
|
| 3004 |
when N_Qualified_Expression => |
| 3005 |
Sprint_Node (Subtype_Mark (Node)); |
| 3006 |
Write_Char_Sloc ('''); |
| 3007 |
|
| 3008 |
-- Print expression, make sure we have at least one level of |
| 3009 |
-- parentheses around the expression. For cases of qualified |
| 3010 |
-- expressions in the source, this is always the case, but |
| 3011 |
-- for generated qualifications, there may be no explicit |
| 3012 |
-- parentheses present. |
| 3013 |
|
| 3014 |
if Paren_Count (Expression (Node)) /= 0 then |
| 3015 |
Sprint_Node (Expression (Node)); |
| 3016 |
|
| 3017 |
else |
| 3018 |
Write_Char ('('); |
| 3019 |
Sprint_Node (Expression (Node)); |
| 3020 |
|
| 3021 |
-- Odd case, for the qualified expressions used in machine |
| 3022 |
-- code the argument may be a procedure call, resulting in |
| 3023 |
-- a junk semicolon before the right parent, get rid of it. |
| 3024 |
|
| 3025 |
Write_Erase_Char (';'); |
| 3026 |
|
| 3027 |
-- Now we can add the terminating right paren |
| 3028 |
|
| 3029 |
Write_Char (')'); |
| 3030 |
end if; |
| 3031 |
|
| 3032 |
when N_Quantified_Expression => |
| 3033 |
Write_Str (" for"); |
| 3034 |
|
| 3035 |
if All_Present (Node) then |
| 3036 |
Write_Str (" all "); |
| 3037 |
else |
| 3038 |
Write_Str (" some "); |
| 3039 |
end if; |
| 3040 |
|
| 3041 |
if Present (Iterator_Specification (Node)) then |
| 3042 |
Sprint_Node (Iterator_Specification (Node)); |
| 3043 |
else |
| 3044 |
Sprint_Node (Loop_Parameter_Specification (Node)); |
| 3045 |
end if; |
| 3046 |
|
| 3047 |
Write_Str (" => "); |
| 3048 |
Sprint_Node (Condition (Node)); |
| 3049 |
|
| 3050 |
when N_Raise_Expression => |
| 3051 |
declare |
| 3052 |
Has_Parens : constant Boolean := Paren_Count (Node) > 0; |
| 3053 |
|
| 3054 |
begin |
| 3055 |
-- The syntax for raise_expression does not include parentheses |
| 3056 |
-- but sometimes parentheses are required, so unconditionally |
| 3057 |
-- generate them here unless already present. |
| 3058 |
|
| 3059 |
if not Has_Parens then |
| 3060 |
Write_Char ('('); |
| 3061 |
end if; |
| 3062 |
|
| 3063 |
Write_Str_With_Col_Check_Sloc ("raise "); |
| 3064 |
Sprint_Node (Name (Node)); |
| 3065 |
|
| 3066 |
if Present (Expression (Node)) then |
| 3067 |
Write_Str_With_Col_Check (" with "); |
| 3068 |
Sprint_Node (Expression (Node)); |
| 3069 |
end if; |
| 3070 |
|
| 3071 |
if not Has_Parens then |
| 3072 |
Write_Char (')'); |
| 3073 |
end if; |
| 3074 |
end; |
| 3075 |
|
| 3076 |
when N_Raise_Constraint_Error => |
| 3077 |
|
| 3078 |
-- This node can be used either as a subexpression or as a |
| 3079 |
-- statement form. The following test is a reasonably reliable |
| 3080 |
-- way to distinguish the two cases. |
| 3081 |
|
| 3082 |
if Is_List_Member (Node) |
| 3083 |
and then Nkind (Parent (Node)) not in N_Subexpr |
| 3084 |
then |
| 3085 |
Write_Indent; |
| 3086 |
end if; |
| 3087 |
|
| 3088 |
Write_Str_With_Col_Check_Sloc ("[constraint_error"); |
| 3089 |
Write_Condition_And_Reason (Node); |
| 3090 |
|
| 3091 |
when N_Raise_Program_Error => |
| 3092 |
|
| 3093 |
-- This node can be used either as a subexpression or as a |
| 3094 |
-- statement form. The following test is a reasonably reliable |
| 3095 |
-- way to distinguish the two cases. |
| 3096 |
|
| 3097 |
if Is_List_Member (Node) |
| 3098 |
and then Nkind (Parent (Node)) not in N_Subexpr |
| 3099 |
then |
| 3100 |
Write_Indent; |
| 3101 |
end if; |
| 3102 |
|
| 3103 |
Write_Str_With_Col_Check_Sloc ("[program_error"); |
| 3104 |
Write_Condition_And_Reason (Node); |
| 3105 |
|
| 3106 |
when N_Raise_Storage_Error => |
| 3107 |
|
| 3108 |
-- This node can be used either as a subexpression or as a |
| 3109 |
-- statement form. The following test is a reasonably reliable |
| 3110 |
-- way to distinguish the two cases. |
| 3111 |
|
| 3112 |
if Is_List_Member (Node) |
| 3113 |
and then Nkind (Parent (Node)) not in N_Subexpr |
| 3114 |
then |
| 3115 |
Write_Indent; |
| 3116 |
end if; |
| 3117 |
|
| 3118 |
Write_Str_With_Col_Check_Sloc ("[storage_error"); |
| 3119 |
Write_Condition_And_Reason (Node); |
| 3120 |
|
| 3121 |
when N_Raise_Statement => |
| 3122 |
if Present (Name (Node)) then |
| 3123 |
Write_Indent_Str_Sloc ("raise "); |
| 3124 |
Sprint_Node (Name (Node)); |
| 3125 |
else |
| 3126 |
Write_Indent_Str_Sloc ("raise"); |
| 3127 |
end if; |
| 3128 |
|
| 3129 |
if Present (Expression (Node)) then |
| 3130 |
Write_Str_With_Col_Check_Sloc (" with "); |
| 3131 |
Sprint_Node (Expression (Node)); |
| 3132 |
end if; |
| 3133 |
|
| 3134 |
Write_Char (';'); |
| 3135 |
|
| 3136 |
when N_Raise_When_Statement => |
| 3137 |
if Present (Name (Node)) then |
| 3138 |
Write_Indent_Str_Sloc ("raise "); |
| 3139 |
Sprint_Node (Name (Node)); |
| 3140 |
else |
| 3141 |
Write_Indent_Str_Sloc ("raise"); |
| 3142 |
end if; |
| 3143 |
Write_Str (" when "); |
| 3144 |
Sprint_Node (Condition (Node)); |
| 3145 |
|
| 3146 |
if Present (Expression (Node)) then |
| 3147 |
Write_Str_With_Col_Check_Sloc (" with "); |
| 3148 |
Sprint_Node (Expression (Node)); |
| 3149 |
end if; |
| 3150 |
|
| 3151 |
Write_Char (';'); |
| 3152 |
|
| 3153 |
when N_Range => |
| 3154 |
Sprint_Node (Low_Bound (Node)); |
| 3155 |
Write_Str_Sloc (" .. "); |
| 3156 |
if Present (Etype (Node)) |
| 3157 |
and then Is_Fixed_Lower_Bound_Index_Subtype (Etype (Node)) |
| 3158 |
then |
| 3159 |
Write_Str ("<>"); |
| 3160 |
else |
| 3161 |
Sprint_Node (High_Bound (Node)); |
| 3162 |
end if; |
| 3163 |
Update_Itype (Node); |
| 3164 |
|
| 3165 |
when N_Range_Constraint => |
| 3166 |
Write_Str_With_Col_Check_Sloc ("range "); |
| 3167 |
Sprint_Node (Range_Expression (Node)); |
| 3168 |
|
| 3169 |
when N_Real_Literal => |
| 3170 |
Write_Ureal_With_Col_Check_Sloc (Realval (Node)); |
| 3171 |
|
| 3172 |
when N_Real_Range_Specification |
| 3173 |
| N_Signed_Integer_Type_Definition |
| 3174 |
=> |
| 3175 |
Write_Str_With_Col_Check_Sloc ("range "); |
| 3176 |
Sprint_Node (Low_Bound (Node)); |
| 3177 |
Write_Str (" .. "); |
| 3178 |
Sprint_Node (High_Bound (Node)); |
| 3179 |
|
| 3180 |
when N_Record_Definition => |
| 3181 |
if Abstract_Present (Node) then |
| 3182 |
Write_Str_With_Col_Check ("abstract "); |
| 3183 |
end if; |
| 3184 |
|
| 3185 |
if Tagged_Present (Node) then |
| 3186 |
Write_Str_With_Col_Check ("tagged "); |
| 3187 |
end if; |
| 3188 |
|
| 3189 |
if Limited_Present (Node) then |
| 3190 |
Write_Str_With_Col_Check ("limited "); |
| 3191 |
end if; |
| 3192 |
|
| 3193 |
if Null_Present (Node) then |
| 3194 |
Write_Str_With_Col_Check_Sloc ("null record"); |
| 3195 |
|
| 3196 |
else |
| 3197 |
Write_Str_With_Col_Check_Sloc ("record"); |
| 3198 |
Sprint_Node (Component_List (Node)); |
| 3199 |
Write_Indent_Str ("end record"); |
| 3200 |
end if; |
| 3201 |
|
| 3202 |
when N_Record_Representation_Clause => |
| 3203 |
Write_Indent_Str_Sloc ("for "); |
| 3204 |
Sprint_Node (Identifier (Node)); |
| 3205 |
Write_Str_With_Col_Check (" use record "); |
| 3206 |
|
| 3207 |
if Present (Mod_Clause (Node)) then |
| 3208 |
Sprint_Node (Mod_Clause (Node)); |
| 3209 |
end if; |
| 3210 |
|
| 3211 |
Sprint_Indented_List (Component_Clauses (Node)); |
| 3212 |
Write_Indent_Str ("end record;"); |
| 3213 |
|
| 3214 |
when N_Reference => |
| 3215 |
Sprint_Node (Prefix (Node)); |
| 3216 |
Write_Str_With_Col_Check_Sloc ("'reference"); |
| 3217 |
|
| 3218 |
when N_Requeue_Statement => |
| 3219 |
Write_Indent_Str_Sloc ("requeue "); |
| 3220 |
Sprint_Node (Name (Node)); |
| 3221 |
|
| 3222 |
if Abort_Present (Node) then |
| 3223 |
Write_Str_With_Col_Check (" with abort"); |
| 3224 |
end if; |
| 3225 |
|
| 3226 |
Write_Char (';'); |
| 3227 |
|
| 3228 |
when N_Return_When_Statement => |
| 3229 |
Write_Indent_Str_Sloc ("return "); |
| 3230 |
Sprint_Node (Expression (Node)); |
| 3231 |
Write_Str (" when "); |
| 3232 |
Sprint_Node (Condition (Node)); |
| 3233 |
Write_Char (';'); |
| 3234 |
|
| 3235 |
when N_SCIL_Dispatch_Table_Tag_Init => |
| 3236 |
Write_Indent_Str ("[N_SCIL_Dispatch_Table_Tag_Init]"); |
| 3237 |
|
| 3238 |
when N_SCIL_Dispatching_Call => |
| 3239 |
Write_Indent_Str ("[N_SCIL_Dispatching_Node]"); |
| 3240 |
|
| 3241 |
when N_SCIL_Membership_Test => |
| 3242 |
Write_Indent_Str ("[N_SCIL_Membership_Test]"); |
| 3243 |
|
| 3244 |
when N_Simple_Return_Statement => |
| 3245 |
if Present (Expression (Node)) then |
| 3246 |
Write_Indent_Str_Sloc ("return "); |
| 3247 |
Sprint_Node (Expression (Node)); |
| 3248 |
else |
| 3249 |
Write_Indent_Str_Sloc ("return"); |
| 3250 |
end if; |
| 3251 |
|
| 3252 |
if Present (Storage_Pool (Node)) then |
| 3253 |
Write_Str_With_Col_Check ("[storage_pool = "); |
| 3254 |
Sprint_Node (Storage_Pool (Node)); |
| 3255 |
Write_Char (']'); |
| 3256 |
end if; |
| 3257 |
|
| 3258 |
if Present (Procedure_To_Call (Node)) then |
| 3259 |
Write_Str_With_Col_Check ("[procedure_to_call = "); |
| 3260 |
Sprint_Node (Procedure_To_Call (Node)); |
| 3261 |
Write_Char (']'); |
| 3262 |
end if; |
| 3263 |
|
| 3264 |
Write_Char (';'); |
| 3265 |
|
| 3266 |
when N_Selective_Accept => |
| 3267 |
Write_Indent_Str_Sloc ("select"); |
| 3268 |
|
| 3269 |
declare |
| 3270 |
Alt_Node : Node_Id; |
| 3271 |
begin |
| 3272 |
Alt_Node := First (Select_Alternatives (Node)); |
| 3273 |
loop |
| 3274 |
Indent_Begin; |
| 3275 |
Sprint_Node (Alt_Node); |
| 3276 |
Indent_End; |
| 3277 |
Next (Alt_Node); |
| 3278 |
exit when No (Alt_Node); |
| 3279 |
Write_Indent_Str ("or"); |
| 3280 |
end loop; |
| 3281 |
end; |
| 3282 |
|
| 3283 |
if Present (Else_Statements (Node)) then |
| 3284 |
Write_Indent_Str ("else"); |
| 3285 |
Sprint_Indented_List (Else_Statements (Node)); |
| 3286 |
end if; |
| 3287 |
|
| 3288 |
Write_Indent_Str ("end select;"); |
| 3289 |
|
| 3290 |
when N_Single_Protected_Declaration => |
| 3291 |
Write_Indent_Str_Sloc ("protected "); |
| 3292 |
Write_Id (Defining_Identifier (Node)); |
| 3293 |
Write_Str (" is"); |
| 3294 |
Sprint_Node (Protected_Definition (Node)); |
| 3295 |
Write_Id (Defining_Identifier (Node)); |
| 3296 |
Write_Char (';'); |
| 3297 |
|
| 3298 |
when N_Single_Task_Declaration => |
| 3299 |
Write_Indent_Str_Sloc ("task "); |
| 3300 |
Sprint_Node (Defining_Identifier (Node)); |
| 3301 |
|
| 3302 |
if Present (Task_Definition (Node)) then |
| 3303 |
Write_Str (" is"); |
| 3304 |
Sprint_Node (Task_Definition (Node)); |
| 3305 |
end if; |
| 3306 |
|
| 3307 |
Write_Char (';'); |
| 3308 |
|
| 3309 |
when N_Selected_Component => |
| 3310 |
Sprint_Node (Prefix (Node)); |
| 3311 |
Write_Char_Sloc ('.'); |
| 3312 |
Sprint_Node (Selector_Name (Node)); |
| 3313 |
|
| 3314 |
when N_Slice => |
| 3315 |
Set_Debug_Sloc; |
| 3316 |
Sprint_Node (Prefix (Node)); |
| 3317 |
Write_Str_With_Col_Check (" ("); |
| 3318 |
Sprint_Node (Discrete_Range (Node)); |
| 3319 |
Write_Char (')'); |
| 3320 |
|
| 3321 |
when N_String_Literal => |
| 3322 |
if String_Length (Strval (Node)) + Column > Sprint_Line_Limit then |
| 3323 |
Write_Indent_Str (" "); |
| 3324 |
end if; |
| 3325 |
|
| 3326 |
Set_Debug_Sloc; |
| 3327 |
Write_String_Table_Entry (Strval (Node)); |
| 3328 |
|
| 3329 |
when N_Interpolated_String_Literal => |
| 3330 |
Write_Char ('{'); |
| 3331 |
|
| 3332 |
declare |
| 3333 |
Str_Elem : Node_Id := First (Expressions (Node)); |
| 3334 |
Is_First : Boolean := True; |
| 3335 |
|
| 3336 |
begin |
| 3337 |
while Present (Str_Elem) loop |
| 3338 |
if not Is_First then |
| 3339 |
Write_Str (" & "); |
| 3340 |
end if; |
| 3341 |
|
| 3342 |
if Nkind (Str_Elem) = N_String_Literal then |
| 3343 |
Sprint_Node (Str_Elem); |
| 3344 |
|
| 3345 |
else |
| 3346 |
Write_Char ('"'); |
| 3347 |
Write_Char ('{'); |
| 3348 |
Sprint_Node (Str_Elem); |
| 3349 |
Write_Char ('}'); |
| 3350 |
Write_Char ('"'); |
| 3351 |
end if; |
| 3352 |
|
| 3353 |
Is_First := False; |
| 3354 |
|
| 3355 |
Next (Str_Elem); |
| 3356 |
end loop; |
| 3357 |
end; |
| 3358 |
|
| 3359 |
Write_Char ('}'); |
| 3360 |
|
| 3361 |
when N_Subprogram_Body => |
| 3362 |
|
| 3363 |
-- Output extra blank line unless we are in freeze actions |
| 3364 |
|
| 3365 |
if Freeze_Indent = 0 then |
| 3366 |
Extra_Blank_Line; |
| 3367 |
end if; |
| 3368 |
|
| 3369 |
Write_Indent; |
| 3370 |
|
| 3371 |
if Present (Corresponding_Spec (Node)) then |
| 3372 |
Sprint_Node_Sloc (Parent (Corresponding_Spec (Node))); |
| 3373 |
else |
| 3374 |
Sprint_Node_Sloc (Specification (Node)); |
| 3375 |
end if; |
| 3376 |
|
| 3377 |
Write_Str (" is"); |
| 3378 |
|
| 3379 |
Sprint_Indented_List (Declarations (Node)); |
| 3380 |
Write_Indent_Str ("begin"); |
| 3381 |
Sprint_Node (Handled_Statement_Sequence (Node)); |
| 3382 |
|
| 3383 |
Write_Indent_Str ("end "); |
| 3384 |
|
| 3385 |
Sprint_End_Label |
| 3386 |
(Handled_Statement_Sequence (Node), |
| 3387 |
Defining_Unit_Name (Specification (Node))); |
| 3388 |
Write_Char (';'); |
| 3389 |
Sprint_At_End_Proc (Node); |
| 3390 |
|
| 3391 |
if Is_List_Member (Node) |
| 3392 |
and then Present (Next (Node)) |
| 3393 |
and then Nkind (Next (Node)) /= N_Subprogram_Body |
| 3394 |
then |
| 3395 |
Write_Indent; |
| 3396 |
end if; |
| 3397 |
|
| 3398 |
when N_Subprogram_Body_Stub => |
| 3399 |
Write_Indent; |
| 3400 |
Sprint_Node_Sloc (Specification (Node)); |
| 3401 |
Write_Str_With_Col_Check (" is separate;"); |
| 3402 |
|
| 3403 |
when N_Subprogram_Declaration => |
| 3404 |
Write_Indent; |
| 3405 |
Sprint_Node_Sloc (Specification (Node)); |
| 3406 |
|
| 3407 |
if Nkind (Specification (Node)) = N_Procedure_Specification |
| 3408 |
and then Null_Present (Specification (Node)) |
| 3409 |
then |
| 3410 |
Write_Str_With_Col_Check (" is null"); |
| 3411 |
end if; |
| 3412 |
|
| 3413 |
Write_Char (';'); |
| 3414 |
|
| 3415 |
when N_Subprogram_Renaming_Declaration => |
| 3416 |
Write_Indent; |
| 3417 |
Sprint_Node (Specification (Node)); |
| 3418 |
Write_Str_With_Col_Check_Sloc (" renames "); |
| 3419 |
Sprint_Node (Name (Node)); |
| 3420 |
Write_Char (';'); |
| 3421 |
|
| 3422 |
when N_Subtype_Declaration => |
| 3423 |
Write_Indent_Str_Sloc ("subtype "); |
| 3424 |
Sprint_Node (Defining_Identifier (Node)); |
| 3425 |
Write_Str (" is "); |
| 3426 |
|
| 3427 |
-- Ada 2005 (AI-231) |
| 3428 |
|
| 3429 |
if Null_Exclusion_Present (Node) then |
| 3430 |
Write_Str ("not null "); |
| 3431 |
end if; |
| 3432 |
|
| 3433 |
Sprint_Node (Subtype_Indication (Node)); |
| 3434 |
Write_Char (';'); |
| 3435 |
|
| 3436 |
when N_Subtype_Indication => |
| 3437 |
Sprint_Node_Sloc (Subtype_Mark (Node)); |
| 3438 |
Write_Char (' '); |
| 3439 |
Sprint_Node (Constraint (Node)); |
| 3440 |
|
| 3441 |
when N_Subunit => |
| 3442 |
Write_Indent_Str_Sloc ("separate ("); |
| 3443 |
Sprint_Node (Name (Node)); |
| 3444 |
Write_Char (')'); |
| 3445 |
Extra_Blank_Line; |
| 3446 |
Sprint_Node (Proper_Body (Node)); |
| 3447 |
|
| 3448 |
when N_Target_Name => |
| 3449 |
Write_Char ('@'); |
| 3450 |
|
| 3451 |
when N_Task_Body => |
| 3452 |
Write_Indent_Str_Sloc ("task body "); |
| 3453 |
Write_Id (Defining_Identifier (Node)); |
| 3454 |
Write_Str (" is"); |
| 3455 |
Sprint_Indented_List (Declarations (Node)); |
| 3456 |
Write_Indent_Str ("begin"); |
| 3457 |
Sprint_Node (Handled_Statement_Sequence (Node)); |
| 3458 |
Write_Indent_Str ("end "); |
| 3459 |
Sprint_End_Label |
| 3460 |
(Handled_Statement_Sequence (Node), Defining_Identifier (Node)); |
| 3461 |
Write_Char (';'); |
| 3462 |
Sprint_At_End_Proc (Node); |
| 3463 |
|
| 3464 |
when N_Task_Body_Stub => |
| 3465 |
Write_Indent_Str_Sloc ("task body "); |
| 3466 |
Write_Id (Defining_Identifier (Node)); |
| 3467 |
Write_Str_With_Col_Check (" is separate;"); |
| 3468 |
|
| 3469 |
when N_Task_Definition => |
| 3470 |
Set_Debug_Sloc; |
| 3471 |
Sprint_Indented_List (Visible_Declarations (Node)); |
| 3472 |
|
| 3473 |
if Present (Private_Declarations (Node)) then |
| 3474 |
Write_Indent_Str ("private"); |
| 3475 |
Sprint_Indented_List (Private_Declarations (Node)); |
| 3476 |
end if; |
| 3477 |
|
| 3478 |
Write_Indent_Str ("end "); |
| 3479 |
Sprint_End_Label (Node, Defining_Identifier (Parent (Node))); |
| 3480 |
|
| 3481 |
when N_Task_Type_Declaration => |
| 3482 |
Write_Indent_Str_Sloc ("task type "); |
| 3483 |
Sprint_Node (Defining_Identifier (Node)); |
| 3484 |
Write_Discr_Specs (Node); |
| 3485 |
|
| 3486 |
if Present (Interface_List (Node)) then |
| 3487 |
Write_Str (" is new "); |
| 3488 |
Sprint_And_List (Interface_List (Node)); |
| 3489 |
end if; |
| 3490 |
|
| 3491 |
if Present (Task_Definition (Node)) then |
| 3492 |
if No (Interface_List (Node)) then |
| 3493 |
Write_Str (" is"); |
| 3494 |
else |
| 3495 |
Write_Str (" with "); |
| 3496 |
end if; |
| 3497 |
|
| 3498 |
Sprint_Node (Task_Definition (Node)); |
| 3499 |
end if; |
| 3500 |
|
| 3501 |
Write_Char (';'); |
| 3502 |
|
| 3503 |
when N_Terminate_Alternative => |
| 3504 |
Sprint_Node_List (Pragmas_Before (Node)); |
| 3505 |
Write_Indent; |
| 3506 |
|
| 3507 |
if Present (Condition (Node)) then |
| 3508 |
Write_Str_With_Col_Check ("when "); |
| 3509 |
Sprint_Node (Condition (Node)); |
| 3510 |
Write_Str (" => "); |
| 3511 |
end if; |
| 3512 |
|
| 3513 |
Write_Str_With_Col_Check_Sloc ("terminate;"); |
| 3514 |
Sprint_Node_List (Pragmas_After (Node)); |
| 3515 |
|
| 3516 |
when N_Timed_Entry_Call => |
| 3517 |
Write_Indent_Str_Sloc ("select"); |
| 3518 |
Indent_Begin; |
| 3519 |
Sprint_Node (Entry_Call_Alternative (Node)); |
| 3520 |
Indent_End; |
| 3521 |
Write_Indent_Str ("or"); |
| 3522 |
Indent_Begin; |
| 3523 |
Sprint_Node (Delay_Alternative (Node)); |
| 3524 |
Indent_End; |
| 3525 |
Write_Indent_Str ("end select;"); |
| 3526 |
|
| 3527 |
when N_Triggering_Alternative => |
| 3528 |
Sprint_Node_List (Pragmas_Before (Node)); |
| 3529 |
Sprint_Node_Sloc (Triggering_Statement (Node)); |
| 3530 |
Sprint_Node_List (Statements (Node)); |
| 3531 |
|
| 3532 |
when N_Type_Conversion => |
| 3533 |
Set_Debug_Sloc; |
| 3534 |
Sprint_Node (Subtype_Mark (Node)); |
| 3535 |
Col_Check (4); |
| 3536 |
|
| 3537 |
if Conversion_OK (Node) then |
| 3538 |
Write_Char ('?'); |
| 3539 |
end if; |
| 3540 |
|
| 3541 |
if Float_Truncate (Node) then |
| 3542 |
Write_Char ('^'); |
| 3543 |
end if; |
| 3544 |
|
| 3545 |
if Rounded_Result (Node) then |
| 3546 |
Write_Char ('@'); |
| 3547 |
end if; |
| 3548 |
|
| 3549 |
Write_Char ('('); |
| 3550 |
Sprint_Node (Expression (Node)); |
| 3551 |
Write_Char (')'); |
| 3552 |
|
| 3553 |
when N_Unchecked_Type_Conversion => |
| 3554 |
Sprint_Node (Subtype_Mark (Node)); |
| 3555 |
Write_Char ('!'); |
| 3556 |
Write_Str_With_Col_Check ("("); |
| 3557 |
Sprint_Node_Sloc (Expression (Node)); |
| 3558 |
Write_Char (')'); |
| 3559 |
|
| 3560 |
when N_Unconstrained_Array_Definition => |
| 3561 |
Write_Str_With_Col_Check_Sloc ("array ("); |
| 3562 |
|
| 3563 |
declare |
| 3564 |
Node1 : Node_Id; |
| 3565 |
begin |
| 3566 |
Node1 := First (Subtype_Marks (Node)); |
| 3567 |
loop |
| 3568 |
Sprint_Node (Node1); |
| 3569 |
Write_Str_With_Col_Check (" range <>"); |
| 3570 |
Next (Node1); |
| 3571 |
exit when Node1 = Empty; |
| 3572 |
Write_Str (", "); |
| 3573 |
end loop; |
| 3574 |
end; |
| 3575 |
|
| 3576 |
Write_Str (") of "); |
| 3577 |
Sprint_Node (Component_Definition (Node)); |
| 3578 |
|
| 3579 |
when N_Unused_At_Start | N_Unused_At_End => |
| 3580 |
Write_Indent_Str ("***** Error, unused node encountered *****"); |
| 3581 |
Write_Eol; |
| 3582 |
|
| 3583 |
when N_Use_Package_Clause => |
| 3584 |
Write_Indent_Str_Sloc ("use "); |
| 3585 |
Sprint_Node_Sloc (Name (Node)); |
| 3586 |
Write_Char (';'); |
| 3587 |
|
| 3588 |
when N_Use_Type_Clause => |
| 3589 |
Write_Indent_Str_Sloc ("use type "); |
| 3590 |
Sprint_Node_Sloc (Subtype_Mark (Node)); |
| 3591 |
Write_Char (';'); |
| 3592 |
|
| 3593 |
when N_Validate_Unchecked_Conversion => |
| 3594 |
Write_Indent_Str_Sloc ("validate unchecked_conversion ("); |
| 3595 |
Sprint_Node (Source_Type (Node)); |
| 3596 |
Write_Str (", "); |
| 3597 |
Sprint_Node (Target_Type (Node)); |
| 3598 |
Write_Str (");"); |
| 3599 |
|
| 3600 |
when N_Variable_Reference_Marker => |
| 3601 |
null; |
| 3602 |
|
| 3603 |
-- Enable the following code for debugging purposes only |
| 3604 |
|
| 3605 |
-- if Is_Read (Node) and then Is_Write (Node) then |
| 3606 |
-- Write_Indent_Str ("rw#"); |
| 3607 |
|
| 3608 |
-- elsif Is_Read (Node) then |
| 3609 |
-- Write_Indent_Str ("r#"); |
| 3610 |
|
| 3611 |
-- else |
| 3612 |
-- pragma Assert (Is_Write (Node)); |
| 3613 |
-- Write_Indent_Str ("w#"); |
| 3614 |
-- end if; |
| 3615 |
|
| 3616 |
-- Write_Id (Target (Node)); |
| 3617 |
-- Write_Char ('#'); |
| 3618 |
|
| 3619 |
when N_Variant => |
| 3620 |
Write_Indent_Str_Sloc ("when "); |
| 3621 |
Sprint_Bar_List (Discrete_Choices (Node)); |
| 3622 |
Write_Str (" => "); |
| 3623 |
Sprint_Node (Component_List (Node)); |
| 3624 |
|
| 3625 |
when N_Variant_Part => |
| 3626 |
Indent_Begin; |
| 3627 |
Write_Indent_Str_Sloc ("case "); |
| 3628 |
Sprint_Node (Name (Node)); |
| 3629 |
Write_Str (" is "); |
| 3630 |
Sprint_Indented_List (Variants (Node)); |
| 3631 |
Write_Indent_Str ("end case"); |
| 3632 |
Indent_End; |
| 3633 |
|
| 3634 |
when N_With_Clause => |
| 3635 |
|
| 3636 |
-- Special test, if we are dumping the original tree only, |
| 3637 |
-- then we want to eliminate the bogus with clauses that |
| 3638 |
-- correspond to the non-existent children of Text_IO. |
| 3639 |
|
| 3640 |
if Dump_Original_Only |
| 3641 |
and then Is_Text_IO_Special_Unit (Name (Node)) |
| 3642 |
then |
| 3643 |
null; |
| 3644 |
|
| 3645 |
-- Normal case, output the with clause |
| 3646 |
|
| 3647 |
else |
| 3648 |
if First_Name (Node) or else not Dump_Original_Only then |
| 3649 |
|
| 3650 |
-- Ada 2005 (AI-50217): Print limited with_clauses |
| 3651 |
|
| 3652 |
if Private_Present (Node) and Limited_Present (Node) then |
| 3653 |
Write_Indent_Str ("limited private with "); |
| 3654 |
|
| 3655 |
elsif Private_Present (Node) then |
| 3656 |
Write_Indent_Str ("private with "); |
| 3657 |
|
| 3658 |
elsif Limited_Present (Node) then |
| 3659 |
Write_Indent_Str ("limited with "); |
| 3660 |
|
| 3661 |
else |
| 3662 |
Write_Indent_Str ("with "); |
| 3663 |
end if; |
| 3664 |
|
| 3665 |
else |
| 3666 |
Write_Str (", "); |
| 3667 |
end if; |
| 3668 |
|
| 3669 |
Sprint_Node_Sloc (Name (Node)); |
| 3670 |
|
| 3671 |
if Last_Name (Node) or else not Dump_Original_Only then |
| 3672 |
Write_Char (';'); |
| 3673 |
end if; |
| 3674 |
end if; |
| 3675 |
end case; |
| 3676 |
|
| 3677 |
-- Print aspects, except for special case of package declaration, |
| 3678 |
-- where the aspects are printed inside the package specification. |
| 3679 |
|
| 3680 |
if Has_Aspects (Node) |
| 3681 |
and then Nkind (Node) not in |
| 3682 |
N_Generic_Package_Declaration | N_Package_Declaration |
| 3683 |
and then not Is_Empty_List (Aspect_Specifications (Node)) |
| 3684 |
then |
| 3685 |
Sprint_Aspect_Specifications (Node, Semicolon => True); |
| 3686 |
end if; |
| 3687 |
|
| 3688 |
if Nkind (Node) in N_Subexpr and then Do_Range_Check (Node) then |
| 3689 |
Write_Str ("}"); |
| 3690 |
end if; |
| 3691 |
|
| 3692 |
for J in 1 .. Paren_Count (Node) loop |
| 3693 |
Write_Char (')'); |
| 3694 |
end loop; |
| 3695 |
|
| 3696 |
Dump_Node := Save_Dump_Node; |
| 3697 |
end Sprint_Node_Actual; |
| 3698 |
|
| 3699 |
---------------------- |
| 3700 |
-- Sprint_Node_List -- |
| 3701 |
---------------------- |
| 3702 |
|
| 3703 |
procedure Sprint_Node_List (List : List_Id; New_Lines : Boolean := False) is |
| 3704 |
Node : Node_Id; |
| 3705 |
|
| 3706 |
begin |
| 3707 |
if Is_Non_Empty_List (List) then |
| 3708 |
Node := First (List); |
| 3709 |
|
| 3710 |
loop |
| 3711 |
Sprint_Node (Node); |
| 3712 |
Next (Node); |
| 3713 |
exit when Node = Empty; |
| 3714 |
end loop; |
| 3715 |
end if; |
| 3716 |
|
| 3717 |
if New_Lines and then Column /= 1 then |
| 3718 |
Write_Eol; |
| 3719 |
end if; |
| 3720 |
end Sprint_Node_List; |
| 3721 |
|
| 3722 |
---------------------- |
| 3723 |
-- Sprint_Node_Sloc -- |
| 3724 |
---------------------- |
| 3725 |
|
| 3726 |
procedure Sprint_Node_Sloc (Node : Node_Id) is |
| 3727 |
begin |
| 3728 |
Sprint_Node (Node); |
| 3729 |
|
| 3730 |
if Debug_Generated_Code and then Present (Dump_Node) then |
| 3731 |
Set_Sloc (Dump_Node, Sloc (Node)); |
| 3732 |
Dump_Node := Empty; |
| 3733 |
end if; |
| 3734 |
end Sprint_Node_Sloc; |
| 3735 |
|
| 3736 |
--------------------- |
| 3737 |
-- Sprint_Opt_Node -- |
| 3738 |
--------------------- |
| 3739 |
|
| 3740 |
procedure Sprint_Opt_Node (Node : Node_Id) is |
| 3741 |
begin |
| 3742 |
if Present (Node) then |
| 3743 |
Write_Char (' '); |
| 3744 |
Sprint_Node (Node); |
| 3745 |
end if; |
| 3746 |
end Sprint_Opt_Node; |
| 3747 |
|
| 3748 |
-------------------------- |
| 3749 |
-- Sprint_Opt_Node_List -- |
| 3750 |
-------------------------- |
| 3751 |
|
| 3752 |
procedure Sprint_Opt_Node_List (List : List_Id) is |
| 3753 |
begin |
| 3754 |
if Present (List) then |
| 3755 |
Sprint_Node_List (List); |
| 3756 |
end if; |
| 3757 |
end Sprint_Opt_Node_List; |
| 3758 |
|
| 3759 |
--------------------------------- |
| 3760 |
-- Sprint_Opt_Paren_Comma_List -- |
| 3761 |
--------------------------------- |
| 3762 |
|
| 3763 |
procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is |
| 3764 |
begin |
| 3765 |
if Is_Non_Empty_List (List) then |
| 3766 |
Write_Char (' '); |
| 3767 |
Sprint_Paren_Comma_List (List); |
| 3768 |
end if; |
| 3769 |
end Sprint_Opt_Paren_Comma_List; |
| 3770 |
|
| 3771 |
----------------------------- |
| 3772 |
-- Sprint_Paren_Comma_List -- |
| 3773 |
----------------------------- |
| 3774 |
|
| 3775 |
procedure Sprint_Paren_Comma_List (List : List_Id) is |
| 3776 |
N : Node_Id; |
| 3777 |
Node_Exists : Boolean := False; |
| 3778 |
|
| 3779 |
begin |
| 3780 |
if Is_Non_Empty_List (List) then |
| 3781 |
|
| 3782 |
if Dump_Original_Only then |
| 3783 |
N := First (List); |
| 3784 |
while Present (N) loop |
| 3785 |
if not Is_Rewrite_Insertion (N) then |
| 3786 |
Node_Exists := True; |
| 3787 |
exit; |
| 3788 |
end if; |
| 3789 |
|
| 3790 |
Next (N); |
| 3791 |
end loop; |
| 3792 |
|
| 3793 |
if not Node_Exists then |
| 3794 |
return; |
| 3795 |
end if; |
| 3796 |
end if; |
| 3797 |
|
| 3798 |
Write_Str_With_Col_Check ("("); |
| 3799 |
Sprint_Comma_List (List); |
| 3800 |
Write_Char (')'); |
| 3801 |
end if; |
| 3802 |
end Sprint_Paren_Comma_List; |
| 3803 |
|
| 3804 |
---------------------- |
| 3805 |
-- Sprint_Right_Opnd -- |
| 3806 |
---------------------- |
| 3807 |
|
| 3808 |
procedure Sprint_Right_Opnd (N : Node_Id) is |
| 3809 |
Opnd : constant Node_Id := Right_Opnd (N); |
| 3810 |
|
| 3811 |
begin |
| 3812 |
if Paren_Count (Opnd) /= 0 |
| 3813 |
or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N)) |
| 3814 |
then |
| 3815 |
Sprint_Node (Opnd); |
| 3816 |
|
| 3817 |
else |
| 3818 |
Write_Char ('('); |
| 3819 |
Sprint_Node (Opnd); |
| 3820 |
Write_Char (')'); |
| 3821 |
end if; |
| 3822 |
end Sprint_Right_Opnd; |
| 3823 |
|
| 3824 |
------------------ |
| 3825 |
-- Update_Itype -- |
| 3826 |
------------------ |
| 3827 |
|
| 3828 |
procedure Update_Itype (Node : Node_Id) is |
| 3829 |
begin |
| 3830 |
if Present (Etype (Node)) |
| 3831 |
and then Is_Itype (Etype (Node)) |
| 3832 |
and then Debug_Generated_Code |
| 3833 |
then |
| 3834 |
Set_Sloc (Etype (Node), Sloc (Node)); |
| 3835 |
end if; |
| 3836 |
end Update_Itype; |
| 3837 |
|
| 3838 |
--------------------- |
| 3839 |
-- Write_Char_Sloc -- |
| 3840 |
--------------------- |
| 3841 |
|
| 3842 |
procedure Write_Char_Sloc (C : Character) is |
| 3843 |
begin |
| 3844 |
if Debug_Generated_Code and then C /= ' ' then |
| 3845 |
Set_Debug_Sloc; |
| 3846 |
end if; |
| 3847 |
|
| 3848 |
Write_Char (C); |
| 3849 |
end Write_Char_Sloc; |
| 3850 |
|
| 3851 |
-------------------------------- |
| 3852 |
-- Write_Condition_And_Reason -- |
| 3853 |
-------------------------------- |
| 3854 |
|
| 3855 |
procedure Write_Condition_And_Reason (Node : Node_Id) is |
| 3856 |
Cond : constant Node_Id := Condition (Node); |
| 3857 |
Image : constant String := RT_Exception_Code'Image |
| 3858 |
(RT_Exception_Code'Val |
| 3859 |
(UI_To_Int (Reason (Node)))); |
| 3860 |
|
| 3861 |
begin |
| 3862 |
if Present (Cond) then |
| 3863 |
|
| 3864 |
-- If condition is a single entity, or NOT with a single entity, |
| 3865 |
-- output all on one line, since it will likely fit just fine. |
| 3866 |
|
| 3867 |
if Is_Entity_Name (Cond) |
| 3868 |
or else (Nkind (Cond) = N_Op_Not |
| 3869 |
and then Is_Entity_Name (Right_Opnd (Cond))) |
| 3870 |
then |
| 3871 |
Write_Str_With_Col_Check (" when "); |
| 3872 |
Sprint_Node (Cond); |
| 3873 |
Write_Char (' '); |
| 3874 |
|
| 3875 |
-- Otherwise for more complex condition, multiple lines |
| 3876 |
|
| 3877 |
else |
| 3878 |
Write_Str_With_Col_Check (" when"); |
| 3879 |
Indent := Indent + 2; |
| 3880 |
Write_Indent; |
| 3881 |
Sprint_Node (Cond); |
| 3882 |
Write_Indent; |
| 3883 |
Indent := Indent - 2; |
| 3884 |
end if; |
| 3885 |
|
| 3886 |
-- If no condition, just need a space (all on one line) |
| 3887 |
|
| 3888 |
else |
| 3889 |
Write_Char (' '); |
| 3890 |
end if; |
| 3891 |
|
| 3892 |
-- Write the reason |
| 3893 |
|
| 3894 |
Write_Char ('"'); |
| 3895 |
|
| 3896 |
for J in 4 .. Image'Last loop |
| 3897 |
if Image (J) = '_' then |
| 3898 |
Write_Char (' '); |
| 3899 |
else |
| 3900 |
Write_Char (Fold_Lower (Image (J))); |
| 3901 |
end if; |
| 3902 |
end loop; |
| 3903 |
|
| 3904 |
Write_Str ("""]"); |
| 3905 |
end Write_Condition_And_Reason; |
| 3906 |
|
| 3907 |
-------------------------------- |
| 3908 |
-- Write_Corresponding_Source -- |
| 3909 |
-------------------------------- |
| 3910 |
|
| 3911 |
procedure Write_Corresponding_Source (S : String) is |
| 3912 |
Loc : Source_Ptr; |
| 3913 |
Src : Source_Buffer_Ptr; |
| 3914 |
|
| 3915 |
begin |
| 3916 |
-- Ignore if there is no current source file, or we're not in dump |
| 3917 |
-- source text mode, or if in freeze actions. |
| 3918 |
|
| 3919 |
if Current_Source_File > No_Source_File |
| 3920 |
and then Dump_Source_Text |
| 3921 |
and then Freeze_Indent = 0 |
| 3922 |
then |
| 3923 |
|
| 3924 |
-- Ignore null string |
| 3925 |
|
| 3926 |
if S = "" then |
| 3927 |
return; |
| 3928 |
end if; |
| 3929 |
|
| 3930 |
-- Ignore space or semicolon at end of given string |
| 3931 |
|
| 3932 |
if S (S'Last) = ' ' or else S (S'Last) = ';' then |
| 3933 |
Write_Corresponding_Source (S (S'First .. S'Last - 1)); |
| 3934 |
return; |
| 3935 |
end if; |
| 3936 |
|
| 3937 |
-- Loop to look at next lines not yet printed in source file |
| 3938 |
|
| 3939 |
for L in |
| 3940 |
Last_Line_Printed + 1 .. Last_Source_Line (Current_Source_File) |
| 3941 |
loop |
| 3942 |
Src := Source_Text (Current_Source_File); |
| 3943 |
Loc := Line_Start (L, Current_Source_File); |
| 3944 |
|
| 3945 |
-- If comment, keep looking |
| 3946 |
|
| 3947 |
if Src (Loc .. Loc + 1) = "--" then |
| 3948 |
null; |
| 3949 |
|
| 3950 |
-- Search to first non-blank |
| 3951 |
|
| 3952 |
else |
| 3953 |
while Src (Loc) not in Line_Terminator loop |
| 3954 |
|
| 3955 |
-- Non-blank found |
| 3956 |
|
| 3957 |
if Src (Loc) /= ' ' and then Src (Loc) /= ASCII.HT then |
| 3958 |
|
| 3959 |
-- Loop through characters in string to see if we match |
| 3960 |
|
| 3961 |
for J in S'Range loop |
| 3962 |
|
| 3963 |
-- If mismatch, then not the case we are looking for |
| 3964 |
|
| 3965 |
if Src (Loc) /= S (J) then |
| 3966 |
return; |
| 3967 |
end if; |
| 3968 |
|
| 3969 |
Loc := Loc + 1; |
| 3970 |
end loop; |
| 3971 |
|
| 3972 |
-- If we fall through, string matched, if white space or |
| 3973 |
-- semicolon after the matched string, this is the case |
| 3974 |
-- we are looking for. |
| 3975 |
|
| 3976 |
if Src (Loc) in Line_Terminator |
| 3977 |
or else Src (Loc) = ' ' |
| 3978 |
or else Src (Loc) = ASCII.HT |
| 3979 |
or else Src (Loc) = ';' |
| 3980 |
then |
| 3981 |
-- So output source lines up to and including this one |
| 3982 |
|
| 3983 |
Write_Source_Lines (L); |
| 3984 |
return; |
| 3985 |
end if; |
| 3986 |
end if; |
| 3987 |
|
| 3988 |
Loc := Loc + 1; |
| 3989 |
end loop; |
| 3990 |
end if; |
| 3991 |
|
| 3992 |
-- Line was all blanks, or a comment line, keep looking |
| 3993 |
|
| 3994 |
end loop; |
| 3995 |
end if; |
| 3996 |
end Write_Corresponding_Source; |
| 3997 |
|
| 3998 |
----------------------- |
| 3999 |
-- Write_Discr_Specs -- |
| 4000 |
----------------------- |
| 4001 |
|
| 4002 |
procedure Write_Discr_Specs (N : Node_Id) is |
| 4003 |
Specs : List_Id; |
| 4004 |
Spec : Node_Id; |
| 4005 |
|
| 4006 |
begin |
| 4007 |
Specs := Discriminant_Specifications (N); |
| 4008 |
|
| 4009 |
if Present (Specs) then |
| 4010 |
Write_Str_With_Col_Check (" ("); |
| 4011 |
Spec := First (Specs); |
| 4012 |
|
| 4013 |
loop |
| 4014 |
Sprint_Node (Spec); |
| 4015 |
Next (Spec); |
| 4016 |
exit when Spec = Empty; |
| 4017 |
|
| 4018 |
-- Add semicolon, unless we are printing original tree and the |
| 4019 |
-- next specification is part of a list (but not the first |
| 4020 |
-- element of that list) |
| 4021 |
|
| 4022 |
if not Dump_Original_Only or else not Prev_Ids (Spec) then |
| 4023 |
Write_Str ("; "); |
| 4024 |
end if; |
| 4025 |
end loop; |
| 4026 |
|
| 4027 |
Write_Char (')'); |
| 4028 |
end if; |
| 4029 |
end Write_Discr_Specs; |
| 4030 |
|
| 4031 |
----------------- |
| 4032 |
-- Write_Ekind -- |
| 4033 |
----------------- |
| 4034 |
|
| 4035 |
procedure Write_Ekind (E : Entity_Id) is |
| 4036 |
S : constant String := Entity_Kind'Image (Ekind (E)); |
| 4037 |
|
| 4038 |
begin |
| 4039 |
Name_Len := S'Length; |
| 4040 |
Name_Buffer (1 .. Name_Len) := S; |
| 4041 |
Set_Casing (Mixed_Case); |
| 4042 |
Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len)); |
| 4043 |
end Write_Ekind; |
| 4044 |
|
| 4045 |
-------------- |
| 4046 |
-- Write_Id -- |
| 4047 |
-------------- |
| 4048 |
|
| 4049 |
procedure Write_Id (N : Node_Id) is |
| 4050 |
begin |
| 4051 |
-- Deal with outputting Itype |
| 4052 |
|
| 4053 |
-- Note: if we are printing the full tree with -gnatds, then we may |
| 4054 |
-- end up picking up the Associated_Node link from a generic template |
| 4055 |
-- here which overlaps the Entity field, but as documented, Write_Itype |
| 4056 |
-- is defended against junk calls. |
| 4057 |
|
| 4058 |
if Nkind (N) in N_Entity then |
| 4059 |
Write_Itype (N); |
| 4060 |
elsif Nkind (N) in N_Has_Entity then |
| 4061 |
Write_Itype (Entity (N)); |
| 4062 |
end if; |
| 4063 |
|
| 4064 |
-- Case of a defining identifier |
| 4065 |
|
| 4066 |
if Nkind (N) = N_Defining_Identifier then |
| 4067 |
|
| 4068 |
-- If defining identifier has an interface name (and no |
| 4069 |
-- address clause), then we output the interface name. |
| 4070 |
|
| 4071 |
if (Is_Imported (N) or else Is_Exported (N)) |
| 4072 |
and then Present (Interface_Name (N)) |
| 4073 |
and then No (Address_Clause (N)) |
| 4074 |
then |
| 4075 |
String_To_Name_Buffer (Strval (Interface_Name (N))); |
| 4076 |
Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len)); |
| 4077 |
|
| 4078 |
-- If no interface name (or inactive because there was |
| 4079 |
-- an address clause), then just output the Chars name. |
| 4080 |
|
| 4081 |
else |
| 4082 |
Write_Name_With_Col_Check (Chars (N)); |
| 4083 |
end if; |
| 4084 |
|
| 4085 |
-- Case of selector of an expanded name where the expanded name |
| 4086 |
-- has an associated entity, output this entity. Check that the |
| 4087 |
-- entity or associated node is of the right kind, see above. |
| 4088 |
|
| 4089 |
elsif Nkind (Parent (N)) = N_Expanded_Name |
| 4090 |
and then Selector_Name (Parent (N)) = N |
| 4091 |
and then Present (Entity_Or_Associated_Node (Parent (N))) |
| 4092 |
and then Nkind (Entity (Parent (N))) in N_Entity |
| 4093 |
then |
| 4094 |
Write_Id (Entity (Parent (N))); |
| 4095 |
|
| 4096 |
-- For any other node with an associated entity, output it |
| 4097 |
|
| 4098 |
elsif Nkind (N) in N_Has_Entity |
| 4099 |
and then Present (Entity_Or_Associated_Node (N)) |
| 4100 |
and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity |
| 4101 |
then |
| 4102 |
Write_Id (Entity (N)); |
| 4103 |
|
| 4104 |
-- All other cases, we just print the Chars field |
| 4105 |
|
| 4106 |
else |
| 4107 |
Write_Name_With_Col_Check (Chars (N)); |
| 4108 |
end if; |
| 4109 |
end Write_Id; |
| 4110 |
|
| 4111 |
----------------------- |
| 4112 |
-- Write_Identifiers -- |
| 4113 |
----------------------- |
| 4114 |
|
| 4115 |
function Write_Identifiers (Node : Node_Id) return Boolean is |
| 4116 |
begin |
| 4117 |
Sprint_Node (Defining_Identifier (Node)); |
| 4118 |
Update_Itype (Defining_Identifier (Node)); |
| 4119 |
|
| 4120 |
-- The remainder of the declaration must be printed unless we are |
| 4121 |
-- printing the original tree and this is not the last identifier |
| 4122 |
|
| 4123 |
return |
| 4124 |
not Dump_Original_Only or else not More_Ids (Node); |
| 4125 |
|
| 4126 |
end Write_Identifiers; |
| 4127 |
|
| 4128 |
------------------------ |
| 4129 |
-- Write_Implicit_Def -- |
| 4130 |
------------------------ |
| 4131 |
|
| 4132 |
procedure Write_Implicit_Def (E : Entity_Id) is |
| 4133 |
Ind : Node_Id; |
| 4134 |
|
| 4135 |
begin |
| 4136 |
case Ekind (E) is |
| 4137 |
when E_Array_Subtype => |
| 4138 |
Write_Str_With_Col_Check ("subtype "); |
| 4139 |
Write_Id (E); |
| 4140 |
Write_Str_With_Col_Check (" is "); |
| 4141 |
Write_Id (Base_Type (E)); |
| 4142 |
Write_Str_With_Col_Check (" ("); |
| 4143 |
|
| 4144 |
Ind := First_Index (E); |
| 4145 |
while Present (Ind) loop |
| 4146 |
Sprint_Node (Ind); |
| 4147 |
Next_Index (Ind); |
| 4148 |
|
| 4149 |
if Present (Ind) then |
| 4150 |
Write_Str (", "); |
| 4151 |
end if; |
| 4152 |
end loop; |
| 4153 |
|
| 4154 |
Write_Str (");"); |
| 4155 |
|
| 4156 |
when E_Enumeration_Subtype |
| 4157 |
| E_Signed_Integer_Subtype |
| 4158 |
=> |
| 4159 |
Write_Str_With_Col_Check ("subtype "); |
| 4160 |
Write_Id (E); |
| 4161 |
Write_Str (" is "); |
| 4162 |
Write_Id (Etype (E)); |
| 4163 |
Write_Str_With_Col_Check (" range "); |
| 4164 |
Sprint_Node (Scalar_Range (E)); |
| 4165 |
Write_Str (";"); |
| 4166 |
|
| 4167 |
when others => |
| 4168 |
Write_Str_With_Col_Check ("type "); |
| 4169 |
Write_Id (E); |
| 4170 |
Write_Str_With_Col_Check (" is <"); |
| 4171 |
Write_Ekind (E); |
| 4172 |
Write_Str (">;"); |
| 4173 |
end case; |
| 4174 |
end Write_Implicit_Def; |
| 4175 |
|
| 4176 |
------------------ |
| 4177 |
-- Write_Indent -- |
| 4178 |
------------------ |
| 4179 |
|
| 4180 |
procedure Write_Indent is |
| 4181 |
Loc : constant Source_Ptr := Sloc (Dump_Node); |
| 4182 |
|
| 4183 |
begin |
| 4184 |
if Indent_Annull_Flag then |
| 4185 |
Indent_Annull_Flag := False; |
| 4186 |
else |
| 4187 |
-- Deal with Dump_Source_Text output. Note that we ignore implicit |
| 4188 |
-- label declarations, since they typically have the sloc of the |
| 4189 |
-- corresponding label, which really messes up the -gnatL output. |
| 4190 |
|
| 4191 |
if Dump_Source_Text |
| 4192 |
and then Loc > No_Location |
| 4193 |
and then Nkind (Dump_Node) /= N_Implicit_Label_Declaration |
| 4194 |
then |
| 4195 |
if Get_Source_File_Index (Loc) = Current_Source_File then |
| 4196 |
Write_Source_Lines |
| 4197 |
(Get_Physical_Line_Number (Sloc (Dump_Node))); |
| 4198 |
end if; |
| 4199 |
end if; |
| 4200 |
|
| 4201 |
Write_Eol; |
| 4202 |
|
| 4203 |
for J in 1 .. Indent loop |
| 4204 |
Write_Char (' '); |
| 4205 |
end loop; |
| 4206 |
end if; |
| 4207 |
end Write_Indent; |
| 4208 |
|
| 4209 |
------------------------------ |
| 4210 |
-- Write_Indent_Identifiers -- |
| 4211 |
------------------------------ |
| 4212 |
|
| 4213 |
function Write_Indent_Identifiers (Node : Node_Id) return Boolean is |
| 4214 |
begin |
| 4215 |
-- We need to start a new line for every node, except in the case |
| 4216 |
-- where we are printing the original tree and this is not the first |
| 4217 |
-- defining identifier in the list. |
| 4218 |
|
| 4219 |
if not Dump_Original_Only or else not Prev_Ids (Node) then |
| 4220 |
Write_Indent; |
| 4221 |
|
| 4222 |
-- If printing original tree and this is not the first defining |
| 4223 |
-- identifier in the list, then the previous call to this procedure |
| 4224 |
-- printed only the name, and we add a comma to separate the names. |
| 4225 |
|
| 4226 |
else |
| 4227 |
Write_Str (", "); |
| 4228 |
end if; |
| 4229 |
|
| 4230 |
Sprint_Node (Defining_Identifier (Node)); |
| 4231 |
|
| 4232 |
-- The remainder of the declaration must be printed unless we are |
| 4233 |
-- printing the original tree and this is not the last identifier |
| 4234 |
|
| 4235 |
return |
| 4236 |
not Dump_Original_Only or else not More_Ids (Node); |
| 4237 |
end Write_Indent_Identifiers; |
| 4238 |
|
| 4239 |
----------------------------------- |
| 4240 |
-- Write_Indent_Identifiers_Sloc -- |
| 4241 |
----------------------------------- |
| 4242 |
|
| 4243 |
function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is |
| 4244 |
begin |
| 4245 |
-- We need to start a new line for every node, except in the case |
| 4246 |
-- where we are printing the original tree and this is not the first |
| 4247 |
-- defining identifier in the list. |
| 4248 |
|
| 4249 |
if not Dump_Original_Only or else not Prev_Ids (Node) then |
| 4250 |
Write_Indent; |
| 4251 |
|
| 4252 |
-- If printing original tree and this is not the first defining |
| 4253 |
-- identifier in the list, then the previous call to this procedure |
| 4254 |
-- printed only the name, and we add a comma to separate the names. |
| 4255 |
|
| 4256 |
else |
| 4257 |
Write_Str (", "); |
| 4258 |
end if; |
| 4259 |
|
| 4260 |
Set_Debug_Sloc; |
| 4261 |
Sprint_Node (Defining_Identifier (Node)); |
| 4262 |
|
| 4263 |
-- The remainder of the declaration must be printed unless we are |
| 4264 |
-- printing the original tree and this is not the last identifier |
| 4265 |
|
| 4266 |
return not Dump_Original_Only or else not More_Ids (Node); |
| 4267 |
end Write_Indent_Identifiers_Sloc; |
| 4268 |
|
| 4269 |
---------------------- |
| 4270 |
-- Write_Indent_Str -- |
| 4271 |
---------------------- |
| 4272 |
|
| 4273 |
procedure Write_Indent_Str (S : String) is |
| 4274 |
begin |
| 4275 |
Write_Corresponding_Source (S); |
| 4276 |
Write_Indent; |
| 4277 |
Write_Str (S); |
| 4278 |
end Write_Indent_Str; |
| 4279 |
|
| 4280 |
--------------------------- |
| 4281 |
-- Write_Indent_Str_Sloc -- |
| 4282 |
--------------------------- |
| 4283 |
|
| 4284 |
procedure Write_Indent_Str_Sloc (S : String) is |
| 4285 |
begin |
| 4286 |
Write_Corresponding_Source (S); |
| 4287 |
Write_Indent; |
| 4288 |
Write_Str_Sloc (S); |
| 4289 |
end Write_Indent_Str_Sloc; |
| 4290 |
|
| 4291 |
----------------- |
| 4292 |
-- Write_Itype -- |
| 4293 |
----------------- |
| 4294 |
|
| 4295 |
procedure Write_Itype (Typ : Entity_Id) is |
| 4296 |
|
| 4297 |
procedure Write_Header (T : Boolean := True); |
| 4298 |
-- Write type if T is True, subtype if T is false |
| 4299 |
|
| 4300 |
------------------ |
| 4301 |
-- Write_Header -- |
| 4302 |
------------------ |
| 4303 |
|
| 4304 |
procedure Write_Header (T : Boolean := True) is |
| 4305 |
begin |
| 4306 |
if T then |
| 4307 |
Write_Str ("[type "); |
| 4308 |
else |
| 4309 |
Write_Str ("[subtype "); |
| 4310 |
end if; |
| 4311 |
|
| 4312 |
Write_Name_With_Col_Check (Chars (Typ)); |
| 4313 |
Write_Str (" is "); |
| 4314 |
end Write_Header; |
| 4315 |
|
| 4316 |
-- Start of processing for Write_Itype |
| 4317 |
|
| 4318 |
begin |
| 4319 |
if Nkind (Typ) in N_Entity |
| 4320 |
and then Is_Itype (Typ) |
| 4321 |
and then not Itype_Printed (Typ) |
| 4322 |
then |
| 4323 |
-- Itype to be printed |
| 4324 |
|
| 4325 |
declare |
| 4326 |
B : constant Entity_Id := Etype (Typ); |
| 4327 |
P : constant Node_Id := Parent (Typ); |
| 4328 |
S : constant Saved_Output_Buffer := Save_Output_Buffer; |
| 4329 |
-- Save current output buffer |
| 4330 |
|
| 4331 |
Old_Sloc : Source_Ptr; |
| 4332 |
-- Save sloc of related node, so it is not modified when |
| 4333 |
-- printing with -gnatD. |
| 4334 |
|
| 4335 |
X : Node_Id; |
| 4336 |
|
| 4337 |
begin |
| 4338 |
-- Write indentation at start of line |
| 4339 |
|
| 4340 |
for J in 1 .. Indent loop |
| 4341 |
Write_Char (' '); |
| 4342 |
end loop; |
| 4343 |
|
| 4344 |
-- If we have a constructed declaration for the itype, print it |
| 4345 |
|
| 4346 |
if Present (P) |
| 4347 |
and then Nkind (P) in N_Declaration |
| 4348 |
and then Defining_Entity (P) = Typ |
| 4349 |
then |
| 4350 |
-- We must set Itype_Printed true before the recursive call to |
| 4351 |
-- print the node, otherwise we get an infinite recursion. |
| 4352 |
|
| 4353 |
Set_Itype_Printed (Typ, True); |
| 4354 |
|
| 4355 |
-- Write the declaration enclosed in [], avoiding new line |
| 4356 |
-- at start of declaration, and semicolon at end. |
| 4357 |
|
| 4358 |
-- Note: The itype may be imported from another unit, in which |
| 4359 |
-- case we do not want to modify the Sloc of the declaration. |
| 4360 |
-- Otherwise the itype may appear to be in the current unit, |
| 4361 |
-- and the back-end will reject a reference out of scope. |
| 4362 |
|
| 4363 |
Write_Char ('['); |
| 4364 |
Indent_Annull_Flag := True; |
| 4365 |
Old_Sloc := Sloc (P); |
| 4366 |
Sprint_Node (P); |
| 4367 |
Set_Sloc (P, Old_Sloc); |
| 4368 |
Write_Erase_Char (';'); |
| 4369 |
|
| 4370 |
-- If no constructed declaration, then we have to concoct the |
| 4371 |
-- source corresponding to the type entity that we have at hand. |
| 4372 |
|
| 4373 |
else |
| 4374 |
case Ekind (Typ) is |
| 4375 |
|
| 4376 |
-- Access types and subtypes |
| 4377 |
|
| 4378 |
when Access_Kind => |
| 4379 |
Write_Header (Ekind (Typ) = E_Access_Type); |
| 4380 |
|
| 4381 |
if Can_Never_Be_Null (Typ) then |
| 4382 |
Write_Str ("not null "); |
| 4383 |
end if; |
| 4384 |
|
| 4385 |
Write_Str ("access "); |
| 4386 |
|
| 4387 |
if Is_Access_Constant (Typ) then |
| 4388 |
Write_Str ("constant "); |
| 4389 |
end if; |
| 4390 |
|
| 4391 |
Write_Id (Directly_Designated_Type (Typ)); |
| 4392 |
|
| 4393 |
-- Array types |
| 4394 |
|
| 4395 |
when E_Array_Type => |
| 4396 |
Write_Header; |
| 4397 |
Write_Str ("array ("); |
| 4398 |
|
| 4399 |
X := First_Index (Typ); |
| 4400 |
loop |
| 4401 |
Sprint_Node (X); |
| 4402 |
|
| 4403 |
if not Is_Constrained (Typ) then |
| 4404 |
Write_Str (" range <>"); |
| 4405 |
end if; |
| 4406 |
|
| 4407 |
Next_Index (X); |
| 4408 |
exit when No (X); |
| 4409 |
Write_Str (", "); |
| 4410 |
end loop; |
| 4411 |
|
| 4412 |
Write_Str (") of "); |
| 4413 |
X := Component_Type (Typ); |
| 4414 |
|
| 4415 |
-- Preserve sloc of component type, which is defined |
| 4416 |
-- elsewhere than the itype (see comment above). |
| 4417 |
|
| 4418 |
Old_Sloc := Sloc (X); |
| 4419 |
Sprint_Node (X); |
| 4420 |
Set_Sloc (X, Old_Sloc); |
| 4421 |
|
| 4422 |
-- Array subtypes |
| 4423 |
|
| 4424 |
-- Preserve Sloc of index subtypes, as above |
| 4425 |
|
| 4426 |
when E_Array_Subtype => |
| 4427 |
Write_Header (False); |
| 4428 |
Write_Id (Etype (Typ)); |
| 4429 |
Write_Str (" ("); |
| 4430 |
|
| 4431 |
X := First_Index (Typ); |
| 4432 |
loop |
| 4433 |
Old_Sloc := Sloc (X); |
| 4434 |
Sprint_Node (X); |
| 4435 |
Set_Sloc (X, Old_Sloc); |
| 4436 |
Next_Index (X); |
| 4437 |
exit when No (X); |
| 4438 |
Write_Str (", "); |
| 4439 |
end loop; |
| 4440 |
|
| 4441 |
Write_Char (')'); |
| 4442 |
|
| 4443 |
-- Signed integer types, and modular integer subtypes, |
| 4444 |
-- and also enumeration subtypes. |
| 4445 |
|
| 4446 |
when E_Enumeration_Subtype |
| 4447 |
| E_Modular_Integer_Subtype |
| 4448 |
| E_Signed_Integer_Subtype |
| 4449 |
| E_Signed_Integer_Type |
| 4450 |
=> |
| 4451 |
Write_Header (Ekind (Typ) = E_Signed_Integer_Type); |
| 4452 |
|
| 4453 |
if Ekind (Typ) = E_Signed_Integer_Type then |
| 4454 |
Write_Str ("new "); |
| 4455 |
end if; |
| 4456 |
|
| 4457 |
Write_Id (B); |
| 4458 |
|
| 4459 |
-- Print bounds if different from base type |
| 4460 |
|
| 4461 |
declare |
| 4462 |
L : constant Node_Id := Type_Low_Bound (Typ); |
| 4463 |
H : constant Node_Id := Type_High_Bound (Typ); |
| 4464 |
BL : Node_Id; |
| 4465 |
BH : Node_Id; |
| 4466 |
|
| 4467 |
begin |
| 4468 |
-- B can either be a scalar type, in which case the |
| 4469 |
-- declaration of Typ may constrain it with different |
| 4470 |
-- bounds, or a private type, in which case we know |
| 4471 |
-- that the declaration of Typ cannot have a scalar |
| 4472 |
-- constraint. |
| 4473 |
|
| 4474 |
if Is_Scalar_Type (B) then |
| 4475 |
BL := Type_Low_Bound (B); |
| 4476 |
BH := Type_High_Bound (B); |
| 4477 |
else |
| 4478 |
BL := Empty; |
| 4479 |
BH := Empty; |
| 4480 |
end if; |
| 4481 |
|
| 4482 |
if No (BL) |
| 4483 |
or else (True |
| 4484 |
and then Nkind (L) = N_Integer_Literal |
| 4485 |
and then Nkind (H) = N_Integer_Literal |
| 4486 |
and then Nkind (BL) = N_Integer_Literal |
| 4487 |
and then Nkind (BH) = N_Integer_Literal |
| 4488 |
and then UI_Eq (Intval (L), Intval (BL)) |
| 4489 |
and then UI_Eq (Intval (H), Intval (BH))) |
| 4490 |
then |
| 4491 |
null; |
| 4492 |
|
| 4493 |
else |
| 4494 |
Write_Str (" range "); |
| 4495 |
Sprint_Node (L); |
| 4496 |
Write_Str (" .. "); |
| 4497 |
Sprint_Node (H); |
| 4498 |
end if; |
| 4499 |
end; |
| 4500 |
|
| 4501 |
-- Modular integer types |
| 4502 |
|
| 4503 |
when E_Modular_Integer_Type => |
| 4504 |
Write_Header; |
| 4505 |
Write_Str ("mod "); |
| 4506 |
|
| 4507 |
if No (Modulus (Typ)) then |
| 4508 |
Write_Uint_With_Col_Check (Uint_0, Auto); |
| 4509 |
else |
| 4510 |
Write_Uint_With_Col_Check (Modulus (Typ), Auto); |
| 4511 |
end if; |
| 4512 |
|
| 4513 |
-- Floating-point types and subtypes |
| 4514 |
|
| 4515 |
when E_Floating_Point_Subtype |
| 4516 |
| E_Floating_Point_Type |
| 4517 |
=> |
| 4518 |
Write_Header (Ekind (Typ) = E_Floating_Point_Type); |
| 4519 |
|
| 4520 |
if Ekind (Typ) = E_Floating_Point_Type then |
| 4521 |
Write_Str ("new "); |
| 4522 |
end if; |
| 4523 |
|
| 4524 |
Write_Id (B); |
| 4525 |
|
| 4526 |
if Digits_Value (Typ) /= Digits_Value (B) then |
| 4527 |
Write_Str (" digits "); |
| 4528 |
Write_Uint_With_Col_Check |
| 4529 |
(Digits_Value (Typ), Decimal); |
| 4530 |
end if; |
| 4531 |
|
| 4532 |
-- Print bounds if not different from base type |
| 4533 |
|
| 4534 |
declare |
| 4535 |
L : constant Node_Id := Type_Low_Bound (Typ); |
| 4536 |
H : constant Node_Id := Type_High_Bound (Typ); |
| 4537 |
BL : constant Node_Id := Type_Low_Bound (B); |
| 4538 |
BH : constant Node_Id := Type_High_Bound (B); |
| 4539 |
|
| 4540 |
begin |
| 4541 |
if True |
| 4542 |
and then Nkind (L) = N_Real_Literal |
| 4543 |
and then Nkind (H) = N_Real_Literal |
| 4544 |
and then Nkind (BL) = N_Real_Literal |
| 4545 |
and then Nkind (BH) = N_Real_Literal |
| 4546 |
and then UR_Eq (Realval (L), Realval (BL)) |
| 4547 |
and then UR_Eq (Realval (H), Realval (BH)) |
| 4548 |
then |
| 4549 |
null; |
| 4550 |
|
| 4551 |
else |
| 4552 |
Write_Str (" range "); |
| 4553 |
Sprint_Node (L); |
| 4554 |
Write_Str (" .. "); |
| 4555 |
Sprint_Node (H); |
| 4556 |
end if; |
| 4557 |
end; |
| 4558 |
|
| 4559 |
-- Ordinary fixed-point types and subtypes |
| 4560 |
|
| 4561 |
when E_Ordinary_Fixed_Point_Subtype |
| 4562 |
| E_Ordinary_Fixed_Point_Type |
| 4563 |
=> |
| 4564 |
Write_Header (Ekind (Typ) = E_Ordinary_Fixed_Point_Type); |
| 4565 |
|
| 4566 |
Write_Str ("delta "); |
| 4567 |
Write_Ureal_With_Col_Check_Sloc (Delta_Value (Typ)); |
| 4568 |
Write_Str (" range "); |
| 4569 |
Sprint_Node (Type_Low_Bound (Typ)); |
| 4570 |
Write_Str (" .. "); |
| 4571 |
Sprint_Node (Type_High_Bound (Typ)); |
| 4572 |
|
| 4573 |
-- Decimal fixed-point types and subtypes |
| 4574 |
|
| 4575 |
when E_Decimal_Fixed_Point_Subtype |
| 4576 |
| E_Decimal_Fixed_Point_Type |
| 4577 |
=> |
| 4578 |
Write_Header (Ekind (Typ) = E_Decimal_Fixed_Point_Type); |
| 4579 |
|
| 4580 |
Write_Str ("delta "); |
| 4581 |
Write_Ureal_With_Col_Check_Sloc (Delta_Value (Typ)); |
| 4582 |
Write_Str (" digits "); |
| 4583 |
Write_Uint_With_Col_Check (Digits_Value (Typ), Decimal); |
| 4584 |
|
| 4585 |
-- Record subtypes |
| 4586 |
|
| 4587 |
when E_Record_Subtype |
| 4588 |
| E_Record_Subtype_With_Private |
| 4589 |
=> |
| 4590 |
Write_Header (False); |
| 4591 |
Write_Str ("record"); |
| 4592 |
Indent_Begin; |
| 4593 |
|
| 4594 |
declare |
| 4595 |
C : Entity_Id; |
| 4596 |
begin |
| 4597 |
C := First_Entity (Typ); |
| 4598 |
while Present (C) loop |
| 4599 |
Write_Indent; |
| 4600 |
Write_Id (C); |
| 4601 |
Write_Str (" : "); |
| 4602 |
Write_Id (Etype (C)); |
| 4603 |
Next_Entity (C); |
| 4604 |
end loop; |
| 4605 |
end; |
| 4606 |
|
| 4607 |
Indent_End; |
| 4608 |
Write_Indent_Str (" end record"); |
| 4609 |
|
| 4610 |
-- Class-Wide types |
| 4611 |
|
| 4612 |
when E_Class_Wide_Subtype |
| 4613 |
| E_Class_Wide_Type |
| 4614 |
=> |
| 4615 |
Write_Header (Ekind (Typ) = E_Class_Wide_Type); |
| 4616 |
Write_Name_With_Col_Check (Chars (Etype (Typ))); |
| 4617 |
Write_Str ("'Class"); |
| 4618 |
|
| 4619 |
-- Subprogram types |
| 4620 |
|
| 4621 |
when E_Subprogram_Type => |
| 4622 |
Write_Header; |
| 4623 |
|
| 4624 |
if Etype (Typ) = Standard_Void_Type then |
| 4625 |
Write_Str ("procedure"); |
| 4626 |
else |
| 4627 |
Write_Str ("function"); |
| 4628 |
end if; |
| 4629 |
|
| 4630 |
if Present (First_Entity (Typ)) then |
| 4631 |
Write_Str (" ("); |
| 4632 |
|
| 4633 |
declare |
| 4634 |
Param : Entity_Id; |
| 4635 |
|
| 4636 |
begin |
| 4637 |
Param := First_Formal (Typ); |
| 4638 |
loop |
| 4639 |
Write_Id (Param); |
| 4640 |
Write_Str (" : "); |
| 4641 |
|
| 4642 |
if Ekind (Param) = E_In_Out_Parameter then |
| 4643 |
Write_Str ("in out "); |
| 4644 |
elsif Ekind (Param) = E_Out_Parameter then |
| 4645 |
Write_Str ("out "); |
| 4646 |
end if; |
| 4647 |
|
| 4648 |
Write_Id (Etype (Param)); |
| 4649 |
Next_Formal (Param); |
| 4650 |
exit when No (Param); |
| 4651 |
Write_Str (", "); |
| 4652 |
end loop; |
| 4653 |
|
| 4654 |
if Present (Extra_Formals (Typ)) then |
| 4655 |
Param := Extra_Formals (Typ); |
| 4656 |
|
| 4657 |
while Present (Param) loop |
| 4658 |
Write_Str (", "); |
| 4659 |
Write_Id (Param); |
| 4660 |
Write_Str (" : "); |
| 4661 |
Write_Id (Etype (Param)); |
| 4662 |
|
| 4663 |
Param := Extra_Formal (Param); |
| 4664 |
end loop; |
| 4665 |
end if; |
| 4666 |
|
| 4667 |
Write_Char (')'); |
| 4668 |
end; |
| 4669 |
|
| 4670 |
elsif Present (Extra_Formals (Typ)) then |
| 4671 |
declare |
| 4672 |
Param : Entity_Id; |
| 4673 |
|
| 4674 |
begin |
| 4675 |
Write_Str (" ("); |
| 4676 |
|
| 4677 |
Param := Extra_Formals (Typ); |
| 4678 |
|
| 4679 |
while Present (Param) loop |
| 4680 |
Write_Id (Param); |
| 4681 |
Write_Str (" : "); |
| 4682 |
Write_Id (Etype (Param)); |
| 4683 |
|
| 4684 |
if Present (Extra_Formal (Param)) then |
| 4685 |
Write_Str (", "); |
| 4686 |
end if; |
| 4687 |
|
| 4688 |
Param := Extra_Formal (Param); |
| 4689 |
end loop; |
| 4690 |
|
| 4691 |
Write_Char (')'); |
| 4692 |
end; |
| 4693 |
end if; |
| 4694 |
|
| 4695 |
if Etype (Typ) /= Standard_Void_Type then |
| 4696 |
Write_Str (" return "); |
| 4697 |
Write_Id (Etype (Typ)); |
| 4698 |
end if; |
| 4699 |
|
| 4700 |
when E_String_Literal_Subtype => |
| 4701 |
declare |
| 4702 |
L : constant Uint := |
| 4703 |
Expr_Value (String_Literal_Low_Bound (Typ)); |
| 4704 |
Len : constant Uint := |
| 4705 |
String_Literal_Length (Typ); |
| 4706 |
begin |
| 4707 |
Write_Header (False); |
| 4708 |
Write_Str ("String ("); |
| 4709 |
Write_Int (UI_To_Int (L)); |
| 4710 |
Write_Str (" .. "); |
| 4711 |
Write_Int (UI_To_Int (L + Len) - 1); |
| 4712 |
Write_Str (");"); |
| 4713 |
end; |
| 4714 |
|
| 4715 |
when E_Private_Subtype => |
| 4716 |
Write_Header (False); |
| 4717 |
Write_Name_With_Col_Check (Chars (Full_View (Typ))); |
| 4718 |
|
| 4719 |
-- For all other Itypes, print a triple ? (fill in later |
| 4720 |
-- if needed). |
| 4721 |
|
| 4722 |
when others => |
| 4723 |
Write_Header (True); |
| 4724 |
Write_Str ("???"); |
| 4725 |
end case; |
| 4726 |
end if; |
| 4727 |
|
| 4728 |
-- Add terminating bracket and restore output buffer |
| 4729 |
|
| 4730 |
Write_Char (']'); |
| 4731 |
Write_Eol; |
| 4732 |
Restore_Output_Buffer (S); |
| 4733 |
end; |
| 4734 |
|
| 4735 |
Set_Itype_Printed (Typ); |
| 4736 |
end if; |
| 4737 |
end Write_Itype; |
| 4738 |
|
| 4739 |
------------------------------- |
| 4740 |
-- Write_Name_With_Col_Check -- |
| 4741 |
------------------------------- |
| 4742 |
|
| 4743 |
procedure Write_Name_With_Col_Check (N : Name_Id) is |
| 4744 |
J : Natural; |
| 4745 |
K : Natural; |
| 4746 |
L : Natural; |
| 4747 |
|
| 4748 |
begin |
| 4749 |
-- Avoid crashing on invalid Name_Ids |
| 4750 |
|
| 4751 |
if not Is_Valid_Name (N) then |
| 4752 |
Write_Str ("<invalid name "); |
| 4753 |
Write_Int (Int (N)); |
| 4754 |
Write_Str (">"); |
| 4755 |
return; |
| 4756 |
end if; |
| 4757 |
|
| 4758 |
Get_Name_String (N); |
| 4759 |
|
| 4760 |
-- Deal with -gnatdI which replaces any sequence Cnnnb where C is an |
| 4761 |
-- upper case letter, nnn is one or more digits and b is a lower case |
| 4762 |
-- letter by C...b, so that listings do not depend on serial numbers. |
| 4763 |
|
| 4764 |
if Debug_Flag_II then |
| 4765 |
J := 1; |
| 4766 |
while J < Name_Len - 1 loop |
| 4767 |
if Name_Buffer (J) in 'A' .. 'Z' |
| 4768 |
and then Name_Buffer (J + 1) in '0' .. '9' |
| 4769 |
then |
| 4770 |
K := J + 1; |
| 4771 |
while K < Name_Len loop |
| 4772 |
exit when Name_Buffer (K) not in '0' .. '9'; |
| 4773 |
K := K + 1; |
| 4774 |
end loop; |
| 4775 |
|
| 4776 |
if Name_Buffer (K) in 'a' .. 'z' then |
| 4777 |
L := Name_Len - K + 1; |
| 4778 |
|
| 4779 |
Name_Buffer (J + 4 .. J + L + 3) := |
| 4780 |
Name_Buffer (K .. Name_Len); |
| 4781 |
Name_Buffer (J + 1 .. J + 3) := "..."; |
| 4782 |
Name_Len := J + L + 3; |
| 4783 |
J := J + 5; |
| 4784 |
|
| 4785 |
else |
| 4786 |
J := K; |
| 4787 |
end if; |
| 4788 |
|
| 4789 |
else |
| 4790 |
J := J + 1; |
| 4791 |
end if; |
| 4792 |
end loop; |
| 4793 |
end if; |
| 4794 |
|
| 4795 |
-- Fall through for normal case |
| 4796 |
|
| 4797 |
Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len)); |
| 4798 |
end Write_Name_With_Col_Check; |
| 4799 |
|
| 4800 |
------------------------------------ |
| 4801 |
-- Write_Name_With_Col_Check_Sloc -- |
| 4802 |
------------------------------------ |
| 4803 |
|
| 4804 |
procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is |
| 4805 |
begin |
| 4806 |
-- Avoid crashing on invalid Name_Ids |
| 4807 |
|
| 4808 |
if not Is_Valid_Name (N) then |
| 4809 |
Write_Str ("<invalid name "); |
| 4810 |
Write_Int (Int (N)); |
| 4811 |
Write_Str (">"); |
| 4812 |
return; |
| 4813 |
end if; |
| 4814 |
|
| 4815 |
Get_Name_String (N); |
| 4816 |
Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len)); |
| 4817 |
end Write_Name_With_Col_Check_Sloc; |
| 4818 |
|
| 4819 |
-------------------- |
| 4820 |
-- Write_Operator -- |
| 4821 |
-------------------- |
| 4822 |
|
| 4823 |
procedure Write_Operator (N : Node_Id; S : String) is |
| 4824 |
F : Natural := S'First; |
| 4825 |
T : Natural := S'Last; |
| 4826 |
|
| 4827 |
begin |
| 4828 |
-- If no overflow check, just write string out, and we are done |
| 4829 |
|
| 4830 |
if not Do_Overflow_Check (N) then |
| 4831 |
Write_Str_Sloc (S); |
| 4832 |
|
| 4833 |
-- If overflow check, we want to surround the operator with curly |
| 4834 |
-- brackets, but not include spaces within the brackets. |
| 4835 |
|
| 4836 |
else |
| 4837 |
if S (F) = ' ' then |
| 4838 |
Write_Char (' '); |
| 4839 |
F := F + 1; |
| 4840 |
end if; |
| 4841 |
|
| 4842 |
if S (T) = ' ' then |
| 4843 |
T := T - 1; |
| 4844 |
end if; |
| 4845 |
|
| 4846 |
Write_Char ('{'); |
| 4847 |
Write_Str_Sloc (S (F .. T)); |
| 4848 |
Write_Char ('}'); |
| 4849 |
|
| 4850 |
if S (S'Last) = ' ' then |
| 4851 |
Write_Char (' '); |
| 4852 |
end if; |
| 4853 |
end if; |
| 4854 |
end Write_Operator; |
| 4855 |
|
| 4856 |
----------------------- |
| 4857 |
-- Write_Param_Specs -- |
| 4858 |
----------------------- |
| 4859 |
|
| 4860 |
procedure Write_Param_Specs (N : Node_Id) is |
| 4861 |
Specs : constant List_Id := Parameter_Specifications (N); |
| 4862 |
Specs_Present : constant Boolean := Is_Non_Empty_List (Specs); |
| 4863 |
|
| 4864 |
Ent : Entity_Id; |
| 4865 |
Extras : Node_Id; |
| 4866 |
Spec : Node_Id; |
| 4867 |
Formal : Node_Id; |
| 4868 |
|
| 4869 |
Output : Boolean := False; |
| 4870 |
-- Set true if we output at least one parameter |
| 4871 |
|
| 4872 |
begin |
| 4873 |
-- Write out explicit specs from Parameter_Specifications list |
| 4874 |
|
| 4875 |
if Specs_Present then |
| 4876 |
Write_Str_With_Col_Check (" ("); |
| 4877 |
Output := True; |
| 4878 |
|
| 4879 |
Spec := First (Specs); |
| 4880 |
loop |
| 4881 |
Sprint_Node (Spec); |
| 4882 |
Formal := Defining_Identifier (Spec); |
| 4883 |
Next (Spec); |
| 4884 |
exit when Spec = Empty; |
| 4885 |
|
| 4886 |
-- Add semicolon, unless we are printing original tree and the |
| 4887 |
-- next specification is part of a list (but not the first element |
| 4888 |
-- of that list). |
| 4889 |
|
| 4890 |
if not Dump_Original_Only or else not Prev_Ids (Spec) then |
| 4891 |
Write_Str ("; "); |
| 4892 |
end if; |
| 4893 |
end loop; |
| 4894 |
end if; |
| 4895 |
|
| 4896 |
-- See if we have extra formals |
| 4897 |
|
| 4898 |
if Nkind (N) in N_Function_Specification | N_Procedure_Specification then |
| 4899 |
Ent := Defining_Entity (N); |
| 4900 |
|
| 4901 |
-- Loop to write extra formals (if any) |
| 4902 |
|
| 4903 |
if Present (Ent) and then Is_Subprogram (Ent) then |
| 4904 |
Extras := Extra_Formals (Ent); |
| 4905 |
|
| 4906 |
if Present (Extras) then |
| 4907 |
if not Specs_Present then |
| 4908 |
Write_Str_With_Col_Check (" ("); |
| 4909 |
Output := True; |
| 4910 |
end if; |
| 4911 |
|
| 4912 |
Formal := Extras; |
| 4913 |
while Present (Formal) loop |
| 4914 |
if Specs_Present or else Formal /= Extras then |
| 4915 |
Write_Str ("; "); |
| 4916 |
end if; |
| 4917 |
|
| 4918 |
Write_Name_With_Col_Check (Chars (Formal)); |
| 4919 |
Write_Str (" : "); |
| 4920 |
Write_Name_With_Col_Check (Chars (Etype (Formal))); |
| 4921 |
Formal := Extra_Formal (Formal); |
| 4922 |
end loop; |
| 4923 |
end if; |
| 4924 |
end if; |
| 4925 |
end if; |
| 4926 |
|
| 4927 |
if Output then |
| 4928 |
Write_Char (')'); |
| 4929 |
end if; |
| 4930 |
end Write_Param_Specs; |
| 4931 |
|
| 4932 |
----------------------- |
| 4933 |
-- Write_Rewrite_Str -- |
| 4934 |
----------------------- |
| 4935 |
|
| 4936 |
procedure Write_Rewrite_Str (S : String) is |
| 4937 |
begin |
| 4938 |
if not Dump_Generated_Only then |
| 4939 |
if S'Length = 3 and then S = ">>>" then |
| 4940 |
Write_Str (">>>"); |
| 4941 |
else |
| 4942 |
Write_Str_With_Col_Check (S); |
| 4943 |
end if; |
| 4944 |
end if; |
| 4945 |
end Write_Rewrite_Str; |
| 4946 |
|
| 4947 |
----------------------- |
| 4948 |
-- Write_Source_Line -- |
| 4949 |
----------------------- |
| 4950 |
|
| 4951 |
procedure Write_Source_Line (L : Physical_Line_Number) is |
| 4952 |
Loc : Source_Ptr; |
| 4953 |
Src : Source_Buffer_Ptr; |
| 4954 |
Scn : Source_Ptr; |
| 4955 |
|
| 4956 |
begin |
| 4957 |
if Dump_Source_Text then |
| 4958 |
Src := Source_Text (Current_Source_File); |
| 4959 |
Loc := Line_Start (L, Current_Source_File); |
| 4960 |
Write_Eol; |
| 4961 |
|
| 4962 |
-- See if line is a comment line, if not, and if not line one, |
| 4963 |
-- precede with blank line. |
| 4964 |
|
| 4965 |
Scn := Loc; |
| 4966 |
while Src (Scn) = ' ' or else Src (Scn) = ASCII.HT loop |
| 4967 |
Scn := Scn + 1; |
| 4968 |
end loop; |
| 4969 |
|
| 4970 |
if (Src (Scn) in Line_Terminator |
| 4971 |
or else Src (Scn .. Scn + 1) /= "--") |
| 4972 |
and then L /= 1 |
| 4973 |
then |
| 4974 |
Write_Eol; |
| 4975 |
end if; |
| 4976 |
|
| 4977 |
-- Now write the source text of the line |
| 4978 |
|
| 4979 |
Write_Str ("-- "); |
| 4980 |
Write_Int (Int (L)); |
| 4981 |
Write_Str (": "); |
| 4982 |
|
| 4983 |
-- We need to check for EOF here, in case the last line of the source |
| 4984 |
-- file does not have a Line_Terminator. |
| 4985 |
|
| 4986 |
while Src (Loc) not in Line_Terminator | EOF loop |
| 4987 |
Write_Char (Src (Loc)); |
| 4988 |
Loc := Loc + 1; |
| 4989 |
end loop; |
| 4990 |
end if; |
| 4991 |
end Write_Source_Line; |
| 4992 |
|
| 4993 |
------------------------ |
| 4994 |
-- Write_Source_Lines -- |
| 4995 |
------------------------ |
| 4996 |
|
| 4997 |
procedure Write_Source_Lines (L : Physical_Line_Number) is |
| 4998 |
begin |
| 4999 |
while Last_Line_Printed < L loop |
| 5000 |
Last_Line_Printed := Last_Line_Printed + 1; |
| 5001 |
Write_Source_Line (Last_Line_Printed); |
| 5002 |
end loop; |
| 5003 |
end Write_Source_Lines; |
| 5004 |
|
| 5005 |
-------------------- |
| 5006 |
-- Write_Str_Sloc -- |
| 5007 |
-------------------- |
| 5008 |
|
| 5009 |
procedure Write_Str_Sloc (S : String) is |
| 5010 |
begin |
| 5011 |
for J in S'Range loop |
| 5012 |
Write_Char_Sloc (S (J)); |
| 5013 |
end loop; |
| 5014 |
end Write_Str_Sloc; |
| 5015 |
|
| 5016 |
------------------------------ |
| 5017 |
-- Write_Str_With_Col_Check -- |
| 5018 |
------------------------------ |
| 5019 |
|
| 5020 |
procedure Write_Str_With_Col_Check (S : String) is |
| 5021 |
begin |
| 5022 |
if Int (S'Last) + Column > Sprint_Line_Limit then |
| 5023 |
Write_Indent_Str (" "); |
| 5024 |
|
| 5025 |
if S (S'First) = ' ' then |
| 5026 |
Write_Str (S (S'First + 1 .. S'Last)); |
| 5027 |
else |
| 5028 |
Write_Str (S); |
| 5029 |
end if; |
| 5030 |
|
| 5031 |
else |
| 5032 |
Write_Str (S); |
| 5033 |
end if; |
| 5034 |
end Write_Str_With_Col_Check; |
| 5035 |
|
| 5036 |
----------------------------------- |
| 5037 |
-- Write_Str_With_Col_Check_Sloc -- |
| 5038 |
----------------------------------- |
| 5039 |
|
| 5040 |
procedure Write_Str_With_Col_Check_Sloc (S : String) is |
| 5041 |
begin |
| 5042 |
if Int (S'Last) + Column > Sprint_Line_Limit then |
| 5043 |
Write_Indent_Str (" "); |
| 5044 |
|
| 5045 |
if S (S'First) = ' ' then |
| 5046 |
Write_Str_Sloc (S (S'First + 1 .. S'Last)); |
| 5047 |
else |
| 5048 |
Write_Str_Sloc (S); |
| 5049 |
end if; |
| 5050 |
|
| 5051 |
else |
| 5052 |
Write_Str_Sloc (S); |
| 5053 |
end if; |
| 5054 |
end Write_Str_With_Col_Check_Sloc; |
| 5055 |
|
| 5056 |
--------------------------- |
| 5057 |
-- Write_Subprogram_Name -- |
| 5058 |
--------------------------- |
| 5059 |
|
| 5060 |
procedure Write_Subprogram_Name (N : Node_Id) is |
| 5061 |
begin |
| 5062 |
if not Comes_From_Source (N) |
| 5063 |
and then Is_Entity_Name (N) |
| 5064 |
then |
| 5065 |
declare |
| 5066 |
Ent : constant Entity_Id := Entity (N); |
| 5067 |
begin |
| 5068 |
if not In_Extended_Main_Source_Unit (Ent) |
| 5069 |
and then In_Predefined_Unit (Ent) |
| 5070 |
then |
| 5071 |
-- Run-time routine name, output name with a preceding dollar |
| 5072 |
-- making sure that we do not get a line split between them. |
| 5073 |
|
| 5074 |
Col_Check (Length_Of_Name (Chars (Ent)) + 1); |
| 5075 |
Write_Char ('$'); |
| 5076 |
Write_Name (Chars (Ent)); |
| 5077 |
return; |
| 5078 |
end if; |
| 5079 |
end; |
| 5080 |
end if; |
| 5081 |
|
| 5082 |
-- Normal case, not a run-time routine name |
| 5083 |
|
| 5084 |
Sprint_Node (N); |
| 5085 |
end Write_Subprogram_Name; |
| 5086 |
|
| 5087 |
------------------------------- |
| 5088 |
-- Write_Uint_With_Col_Check -- |
| 5089 |
------------------------------- |
| 5090 |
|
| 5091 |
procedure Write_Uint_With_Col_Check (U : Uint; Format : UI_Format) is |
| 5092 |
begin |
| 5093 |
Col_Check (UI_Decimal_Digits_Hi (U)); |
| 5094 |
UI_Write (U, Format); |
| 5095 |
end Write_Uint_With_Col_Check; |
| 5096 |
|
| 5097 |
------------------------------------ |
| 5098 |
-- Write_Uint_With_Col_Check_Sloc -- |
| 5099 |
------------------------------------ |
| 5100 |
|
| 5101 |
procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is |
| 5102 |
begin |
| 5103 |
Col_Check (UI_Decimal_Digits_Hi (U)); |
| 5104 |
Set_Debug_Sloc; |
| 5105 |
UI_Write (U, Format); |
| 5106 |
end Write_Uint_With_Col_Check_Sloc; |
| 5107 |
|
| 5108 |
------------------------------------- |
| 5109 |
-- Write_Ureal_With_Col_Check_Sloc -- |
| 5110 |
------------------------------------- |
| 5111 |
|
| 5112 |
procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is |
| 5113 |
D : constant Uint := Denominator (U); |
| 5114 |
N : constant Uint := Numerator (U); |
| 5115 |
begin |
| 5116 |
Col_Check (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4); |
| 5117 |
Set_Debug_Sloc; |
| 5118 |
UR_Write (U, Brackets => True); |
| 5119 |
end Write_Ureal_With_Col_Check_Sloc; |
| 5120 |
|
| 5121 |
end Sprint; |