Mercurial > hg > CbC > CbC_gcc
comparison gcc/ada/namet.ads @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
4 -- -- | 4 -- -- |
5 -- N A M E T -- | 5 -- N A M E T -- |
6 -- -- | 6 -- -- |
7 -- S p e c -- | 7 -- S p e c -- |
8 -- -- | 8 -- -- |
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- | 9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. -- |
10 -- -- | 10 -- -- |
11 -- GNAT is free software; you can redistribute it and/or modify it under -- | 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- -- | 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- -- | 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- -- | 14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
191 | 191 |
192 No_Name : constant Name_Id := Names_Low_Bound; | 192 No_Name : constant Name_Id := Names_Low_Bound; |
193 -- The special Name_Id value No_Name is used in the parser to indicate | 193 -- The special Name_Id value No_Name is used in the parser to indicate |
194 -- a situation where no name is present (e.g. on a loop or block). | 194 -- a situation where no name is present (e.g. on a loop or block). |
195 | 195 |
196 Error_Name : constant Name_Id := Names_Low_Bound + 1; | 196 Error_Name : constant Name_Id := Names_Low_Bound + 1; |
197 -- The special Name_Id value Error_Name is used in the parser to | 197 -- The special Name_Id value Error_Name is used in the parser to |
198 -- indicate that some kind of error was encountered in scanning out | 198 -- indicate that some kind of error was encountered in scanning out |
199 -- the relevant name, so it does not have a representable label. | 199 -- the relevant name, so it does not have a representable label. |
200 | 200 |
201 subtype Error_Name_Or_No_Name is Name_Id range No_Name .. Error_Name; | |
202 -- Used to test for either error name or no name | |
203 | |
204 First_Name_Id : constant Name_Id := Names_Low_Bound + 2; | 201 First_Name_Id : constant Name_Id := Names_Low_Bound + 2; |
205 -- Subscript of first entry in names table | 202 -- Subscript of first entry in names table |
203 | |
204 subtype Valid_Name_Id is Name_Id range First_Name_Id .. Name_Id'Last; | |
205 -- All but No_Name and Error_Name | |
206 | 206 |
207 ------------------------------ | 207 ------------------------------ |
208 -- Name_Id Membership Tests -- | 208 -- Name_Id Membership Tests -- |
209 ------------------------------ | 209 ------------------------------ |
210 | 210 |
335 function To_String (Buf : Bounded_String) return String; | 335 function To_String (Buf : Bounded_String) return String; |
336 pragma Inline (To_String); | 336 pragma Inline (To_String); |
337 function "+" (Buf : Bounded_String) return String renames To_String; | 337 function "+" (Buf : Bounded_String) return String renames To_String; |
338 | 338 |
339 function Name_Find | 339 function Name_Find |
340 (Buf : Bounded_String := Global_Name_Buffer) return Name_Id; | 340 (Buf : Bounded_String := Global_Name_Buffer) return Valid_Name_Id; |
341 function Name_Find (S : String) return Name_Id; | 341 function Name_Find (S : String) return Valid_Name_Id; |
342 -- Name_Find searches the names table to see if the string has already been | 342 -- Name_Find searches the names table to see if the string has already been |
343 -- stored. If so, the Id of the existing entry is returned. Otherwise a new | 343 -- stored. If so, the Id of the existing entry is returned. Otherwise a new |
344 -- entry is created with its Name_Table_Int fields set to zero/false. Note | 344 -- entry is created with its Name_Table_Int fields set to zero/false. Note |
345 -- that it is permissible for Buf.Length to be zero to lookup the empty | 345 -- that it is permissible for Buf.Length to be zero to lookup the empty |
346 -- name string. | 346 -- name string. |
347 | 347 |
348 function Name_Enter | 348 function Name_Enter |
349 (Buf : Bounded_String := Global_Name_Buffer) return Name_Id; | 349 (Buf : Bounded_String := Global_Name_Buffer) return Valid_Name_Id; |
350 function Name_Enter (S : String) return Name_Id; | 350 function Name_Enter (S : String) return Valid_Name_Id; |
351 -- Name_Enter is similar to Name_Find. The difference is that it does not | 351 -- Name_Enter is similar to Name_Find. The difference is that it does not |
352 -- search the table for an existing match, and also subsequent Name_Find | 352 -- search the table for an existing match, and also subsequent Name_Find |
353 -- calls using the same name will not locate the entry created by this | 353 -- calls using the same name will not locate the entry created by this |
354 -- call. Thus multiple calls to Name_Enter with the same name will create | 354 -- call. Thus multiple calls to Name_Enter with the same name will create |
355 -- multiple entries in the name table with different Name_Id values. This | 355 -- multiple entries in the name table with different Name_Id values. This |
356 -- is useful in the case of created names, which are never expected to be | 356 -- is useful in the case of created names, which are never expected to be |
357 -- looked up. Note: Name_Enter should never be used for one character | 357 -- looked up. Note: Name_Enter should never be used for one character |
358 -- names, since these are efficiently located without hashing by Name_Find | 358 -- names, since these are efficiently located without hashing by Name_Find |
359 -- in any case. | 359 -- in any case. |
360 | 360 |
361 function Name_Equals (N1 : Name_Id; N2 : Name_Id) return Boolean; | 361 function Name_Equals |
362 (N1 : Valid_Name_Id; | |
363 N2 : Valid_Name_Id) return Boolean; | |
362 -- Return whether N1 and N2 denote the same character sequence | 364 -- Return whether N1 and N2 denote the same character sequence |
363 | 365 |
364 function Get_Name_String (Id : Name_Id) return String; | 366 function Get_Name_String (Id : Valid_Name_Id) return String; |
365 -- Returns the characters of Id as a String. The lower bound is 1. | 367 -- Returns the characters of Id as a String. The lower bound is 1. |
366 | 368 |
367 -- The following Append procedures ignore any characters that don't fit in | 369 -- The following Append procedures ignore any characters that don't fit in |
368 -- Buf. | 370 -- Buf. |
369 | 371 |
378 -- Append S onto Buf | 380 -- Append S onto Buf |
379 | 381 |
380 procedure Append (Buf : in out Bounded_String; Buf2 : Bounded_String); | 382 procedure Append (Buf : in out Bounded_String; Buf2 : Bounded_String); |
381 -- Append Buf2 onto Buf | 383 -- Append Buf2 onto Buf |
382 | 384 |
383 procedure Append (Buf : in out Bounded_String; Id : Name_Id); | 385 procedure Append (Buf : in out Bounded_String; Id : Valid_Name_Id); |
384 -- Append the characters of Id onto Buf. It is an error to call this with | 386 -- Append the characters of Id onto Buf. It is an error to call this with |
385 -- one of the special name Id values (No_Name or Error_Name). | 387 -- one of the special name Id values (No_Name or Error_Name). |
386 | 388 |
387 procedure Append_Decoded (Buf : in out Bounded_String; Id : Name_Id); | 389 procedure Append_Decoded (Buf : in out Bounded_String; Id : Valid_Name_Id); |
388 -- Same as Append, except that the result is decoded, so that upper half | 390 -- Same as Append, except that the result is decoded, so that upper half |
389 -- characters and wide characters appear as originally found in the source | 391 -- characters and wide characters appear as originally found in the source |
390 -- program text, operators have their source forms (special characters and | 392 -- program text, operators have their source forms (special characters and |
391 -- enclosed in quotes), and character literals appear surrounded by | 393 -- enclosed in quotes), and character literals appear surrounded by |
392 -- apostrophes. | 394 -- apostrophes. |
393 | 395 |
394 procedure Append_Decoded_With_Brackets | 396 procedure Append_Decoded_With_Brackets |
395 (Buf : in out Bounded_String; | 397 (Buf : in out Bounded_String; |
396 Id : Name_Id); | 398 Id : Valid_Name_Id); |
397 -- Same as Append_Decoded, except that the brackets notation (Uhh | 399 -- Same as Append_Decoded, except that the brackets notation (Uhh |
398 -- replaced by ["hh"], Whhhh replaced by ["hhhh"], WWhhhhhhhh replaced by | 400 -- replaced by ["hh"], Whhhh replaced by ["hhhh"], WWhhhhhhhh replaced by |
399 -- ["hhhhhhhh"]) is used for all non-lower half characters, regardless of | 401 -- ["hhhhhhhh"]) is used for all non-lower half characters, regardless of |
400 -- how Opt.Wide_Character_Encoding_Method is set, and also in that | 402 -- how Opt.Wide_Character_Encoding_Method is set, and also in that |
401 -- characters in the range 16#80# .. 16#FF# are converted to brackets | 403 -- characters in the range 16#80# .. 16#FF# are converted to brackets |
402 -- notation in all cases. This routine can be used when there is a | 404 -- notation in all cases. This routine can be used when there is a |
403 -- requirement for a canonical representation not affected by the | 405 -- requirement for a canonical representation not affected by the |
404 -- character set options (e.g. in the binder generation of symbols). | 406 -- character set options (e.g. in the binder generation of symbols). |
405 | 407 |
406 procedure Append_Unqualified (Buf : in out Bounded_String; Id : Name_Id); | 408 procedure Append_Unqualified |
409 (Buf : in out Bounded_String; Id : Valid_Name_Id); | |
407 -- Same as Append, except that qualification (as defined in unit | 410 -- Same as Append, except that qualification (as defined in unit |
408 -- Exp_Dbug) is removed (including both preceding __ delimited names, and | 411 -- Exp_Dbug) is removed (including both preceding __ delimited names, and |
409 -- also the suffixes used to indicate package body entities and to | 412 -- also the suffixes used to indicate package body entities and to |
410 -- distinguish between overloaded entities). Note that names are not | 413 -- distinguish between overloaded entities). Note that names are not |
411 -- qualified until just before the call to gigi, so this routine is only | 414 -- qualified until just before the call to gigi, so this routine is only |
413 -- includes all ASIS processing, since ASIS works on the tree written | 416 -- includes all ASIS processing, since ASIS works on the tree written |
414 -- after gigi has been called. | 417 -- after gigi has been called. |
415 | 418 |
416 procedure Append_Unqualified_Decoded | 419 procedure Append_Unqualified_Decoded |
417 (Buf : in out Bounded_String; | 420 (Buf : in out Bounded_String; |
418 Id : Name_Id); | 421 Id : Valid_Name_Id); |
419 -- Same as Append_Unqualified, but decoded as for Append_Decoded | 422 -- Same as Append_Unqualified, but decoded as for Append_Decoded |
420 | 423 |
421 procedure Append_Encoded (Buf : in out Bounded_String; C : Char_Code); | 424 procedure Append_Encoded (Buf : in out Bounded_String; C : Char_Code); |
422 -- Appends given character code at the end of Buf. Lower case letters and | 425 -- Appends given character code at the end of Buf. Lower case letters and |
423 -- digits are stored unchanged. Other 8-bit characters are stored using the | 426 -- digits are stored unchanged. Other 8-bit characters are stored using the |
441 -- this location get moved beyond the inserted string. | 444 -- this location get moved beyond the inserted string. |
442 | 445 |
443 function Is_Internal_Name (Buf : Bounded_String) return Boolean; | 446 function Is_Internal_Name (Buf : Bounded_String) return Boolean; |
444 | 447 |
445 procedure Get_Last_Two_Chars | 448 procedure Get_Last_Two_Chars |
446 (N : Name_Id; | 449 (N : Valid_Name_Id; |
447 C1 : out Character; | 450 C1 : out Character; |
448 C2 : out Character); | 451 C2 : out Character); |
449 -- Obtains last two characters of a name. C1 is last but one character and | 452 -- Obtains last two characters of a name. C1 is last but one character and |
450 -- C2 is last character. If name is less than two characters long then both | 453 -- C2 is last character. If name is less than two characters long then both |
451 -- C1 and C2 are set to ASCII.NUL on return. | 454 -- C1 and C2 are set to ASCII.NUL on return. |
452 | 455 |
453 function Get_Name_Table_Boolean1 (Id : Name_Id) return Boolean; | 456 function Get_Name_Table_Boolean1 (Id : Valid_Name_Id) return Boolean; |
454 function Get_Name_Table_Boolean2 (Id : Name_Id) return Boolean; | 457 function Get_Name_Table_Boolean2 (Id : Valid_Name_Id) return Boolean; |
455 function Get_Name_Table_Boolean3 (Id : Name_Id) return Boolean; | 458 function Get_Name_Table_Boolean3 (Id : Valid_Name_Id) return Boolean; |
456 -- Fetches the Boolean values associated with the given name | 459 -- Fetches the Boolean values associated with the given name |
457 | 460 |
458 function Get_Name_Table_Byte (Id : Name_Id) return Byte; | 461 function Get_Name_Table_Byte (Id : Valid_Name_Id) return Byte; |
459 pragma Inline (Get_Name_Table_Byte); | 462 pragma Inline (Get_Name_Table_Byte); |
460 -- Fetches the Byte value associated with the given name | 463 -- Fetches the Byte value associated with the given name |
461 | 464 |
462 function Get_Name_Table_Int (Id : Name_Id) return Int; | 465 function Get_Name_Table_Int (Id : Valid_Name_Id) return Int; |
463 pragma Inline (Get_Name_Table_Int); | 466 pragma Inline (Get_Name_Table_Int); |
464 -- Fetches the Int value associated with the given name | 467 -- Fetches the Int value associated with the given name |
465 | 468 |
466 procedure Set_Name_Table_Boolean1 (Id : Name_Id; Val : Boolean); | 469 procedure Set_Name_Table_Boolean1 (Id : Valid_Name_Id; Val : Boolean); |
467 procedure Set_Name_Table_Boolean2 (Id : Name_Id; Val : Boolean); | 470 procedure Set_Name_Table_Boolean2 (Id : Valid_Name_Id; Val : Boolean); |
468 procedure Set_Name_Table_Boolean3 (Id : Name_Id; Val : Boolean); | 471 procedure Set_Name_Table_Boolean3 (Id : Valid_Name_Id; Val : Boolean); |
469 -- Sets the Boolean value associated with the given name | 472 -- Sets the Boolean value associated with the given name |
470 | 473 |
471 procedure Set_Name_Table_Byte (Id : Name_Id; Val : Byte); | 474 procedure Set_Name_Table_Byte (Id : Valid_Name_Id; Val : Byte); |
472 pragma Inline (Set_Name_Table_Byte); | 475 pragma Inline (Set_Name_Table_Byte); |
473 -- Sets the Byte value associated with the given name | 476 -- Sets the Byte value associated with the given name |
474 | 477 |
475 procedure Set_Name_Table_Int (Id : Name_Id; Val : Int); | 478 procedure Set_Name_Table_Int (Id : Valid_Name_Id; Val : Int); |
476 pragma Inline (Set_Name_Table_Int); | 479 pragma Inline (Set_Name_Table_Int); |
477 -- Sets the Int value associated with the given name | 480 -- Sets the Int value associated with the given name |
478 | 481 |
479 function Is_Internal_Name (Id : Name_Id) return Boolean; | 482 function Is_Internal_Name (Id : Valid_Name_Id) return Boolean; |
480 -- Returns True if the name is an internal name, i.e. contains a character | 483 -- Returns True if the name is an internal name, i.e. contains a character |
481 -- for which Is_OK_Internal_Letter is true, or if the name starts or ends | 484 -- for which Is_OK_Internal_Letter is true, or if the name starts or ends |
482 -- with an underscore. | 485 -- with an underscore. |
483 -- | 486 -- |
484 -- Note: if the name is qualified (has a double underscore), then only the | 487 -- Note: if the name is qualified (has a double underscore), then only the |
498 -- suffix of an internally generated name, i.e. it is an upper case letter | 501 -- suffix of an internally generated name, i.e. it is an upper case letter |
499 -- other than one of the ones used for encoding source names (currently the | 502 -- other than one of the ones used for encoding source names (currently the |
500 -- set of reserved letters is O, Q, U, W) and also returns False for the | 503 -- set of reserved letters is O, Q, U, W) and also returns False for the |
501 -- letter X, which is reserved for debug output (see Exp_Dbug). | 504 -- letter X, which is reserved for debug output (see Exp_Dbug). |
502 | 505 |
503 function Is_Operator_Name (Id : Name_Id) return Boolean; | 506 function Is_Operator_Name (Id : Valid_Name_Id) return Boolean; |
504 -- Returns True if name given is of the form of an operator (that is, it | 507 -- Returns True if name given is of the form of an operator (that is, it |
505 -- starts with an upper case O). | 508 -- starts with an upper case O). |
506 | 509 |
507 function Is_Valid_Name (Id : Name_Id) return Boolean; | 510 function Is_Valid_Name (Id : Name_Id) return Boolean; |
508 -- True if Id is a valid name - points to a valid entry in the Name_Entries | 511 -- True if Id is a valid name - points to a valid entry in the Name_Entries |
509 -- table. | 512 -- table. |
510 | 513 |
511 function Length_Of_Name (Id : Name_Id) return Nat; | 514 function Length_Of_Name (Id : Valid_Name_Id) return Nat; |
512 pragma Inline (Length_Of_Name); | 515 pragma Inline (Length_Of_Name); |
513 -- Returns length of given name in characters. This is the length of the | 516 -- Returns length of given name in characters. This is the length of the |
514 -- encoded name, as stored in the names table. | 517 -- encoded name, as stored in the names table. |
515 | 518 |
516 procedure Initialize; | 519 procedure Initialize; |
551 | 554 |
552 procedure Tree_Write; | 555 procedure Tree_Write; |
553 -- Writes out internal tables to current tree file using the relevant | 556 -- Writes out internal tables to current tree file using the relevant |
554 -- Table.Tree_Write routines. | 557 -- Table.Tree_Write routines. |
555 | 558 |
556 procedure Write_Name (Id : Name_Id); | 559 procedure Write_Name (Id : Valid_Name_Id); |
557 -- Write_Name writes the characters of the specified name using the | 560 -- Write_Name writes the characters of the specified name using the |
558 -- standard output procedures in package Output. The name is written | 561 -- standard output procedures in package Output. The name is written |
559 -- in encoded form (i.e. including Uhh, Whhh, Qx, _op as they appear in | 562 -- in encoded form (i.e. including Uhh, Whhh, Qx, _op as they appear in |
560 -- the name table). If Id is Error_Name, or No_Name, no text is output. | 563 -- the name table). If Id is Error_Name, or No_Name, no text is output. |
561 | 564 |
562 procedure Write_Name_Decoded (Id : Name_Id); | 565 procedure Write_Name_Decoded (Id : Valid_Name_Id); |
563 -- Like Write_Name, except that the name written is the decoded name, as | 566 -- Like Write_Name, except that the name written is the decoded name, as |
564 -- described for Append_Decoded. | 567 -- described for Append_Decoded. |
565 | 568 |
566 function Name_Entries_Count return Nat; | 569 function Name_Entries_Count return Nat; |
567 -- Return current number of entries in the names table | 570 -- Return current number of entries in the names table |
584 | 587 |
585 procedure Add_Nat_To_Name_Buffer (V : Nat); | 588 procedure Add_Nat_To_Name_Buffer (V : Nat); |
586 | 589 |
587 procedure Add_Str_To_Name_Buffer (S : String); | 590 procedure Add_Str_To_Name_Buffer (S : String); |
588 | 591 |
589 procedure Get_Decoded_Name_String (Id : Name_Id); | 592 procedure Get_Decoded_Name_String (Id : Valid_Name_Id); |
590 | 593 |
591 procedure Get_Decoded_Name_String_With_Brackets (Id : Name_Id); | 594 procedure Get_Decoded_Name_String_With_Brackets (Id : Valid_Name_Id); |
592 | 595 |
593 procedure Get_Name_String (Id : Name_Id); | 596 procedure Get_Name_String (Id : Valid_Name_Id); |
594 | 597 |
595 procedure Get_Name_String_And_Append (Id : Name_Id); | 598 procedure Get_Name_String_And_Append (Id : Valid_Name_Id); |
596 | 599 |
597 procedure Get_Unqualified_Decoded_Name_String (Id : Name_Id); | 600 procedure Get_Unqualified_Decoded_Name_String (Id : Valid_Name_Id); |
598 | 601 |
599 procedure Get_Unqualified_Name_String (Id : Name_Id); | 602 procedure Get_Unqualified_Name_String (Id : Valid_Name_Id); |
600 | 603 |
601 procedure Insert_Str_In_Name_Buffer (S : String; Index : Positive); | 604 procedure Insert_Str_In_Name_Buffer (S : String; Index : Positive); |
602 | 605 |
603 function Is_Internal_Name return Boolean; | 606 function Is_Internal_Name return Boolean; |
604 | 607 |
737 end record; | 740 end record; |
738 | 741 |
739 for Name_Entry'Size use 16 * 8; | 742 for Name_Entry'Size use 16 * 8; |
740 -- This ensures that we did not leave out any fields | 743 -- This ensures that we did not leave out any fields |
741 | 744 |
742 -- This is the table that is referenced by Name_Id entries. | 745 -- This is the table that is referenced by Valid_Name_Id entries. |
743 -- It contains one entry for each unique name in the table. | 746 -- It contains one entry for each unique name in the table. |
744 | 747 |
745 package Name_Entries is new Table.Table ( | 748 package Name_Entries is new Table.Table ( |
746 Table_Component_Type => Name_Entry, | 749 Table_Component_Type => Name_Entry, |
747 Table_Index_Type => Name_Id'Base, | 750 Table_Index_Type => Valid_Name_Id'Base, |
748 Table_Low_Bound => First_Name_Id, | 751 Table_Low_Bound => First_Name_Id, |
749 Table_Initial => Alloc.Names_Initial, | 752 Table_Initial => Alloc.Names_Initial, |
750 Table_Increment => Alloc.Names_Increment, | 753 Table_Increment => Alloc.Names_Increment, |
751 Table_Name => "Name_Entries"); | 754 Table_Name => "Name_Entries"); |
752 | 755 |