ada: Simplify "not Present" with "No"
[official-gcc.git] / gcc / ada / stringt.ads
blobee34b0893d63dd3fd600bcf05605802757d30da4
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S T R I N G T --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2023, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 with Namet; use Namet;
27 with System;
28 with Types; use Types;
30 package Stringt is
31 pragma Elaborate_Body;
32 -- This is to make sure Null_String_Id is properly initialized
34 -- This package contains routines for handling the strings table which is
35 -- used to store string constants encountered in the source, and also those
36 -- additional string constants generated by compile time concatenation and
37 -- other similar processing.
39 -- WARNING: There is a C version of this package. Any changes to this
40 -- source file must be properly reflected in the C header file stringt.h
42 -- A string constant in this table consists of a series of Char_Code values,
43 -- so that 16-bit character codes can be properly handled if this feature
44 -- is implemented in the scanner.
46 -- There is no guarantee that hashing is used in the implementation, although
47 -- it may be. This means that the caller cannot count on having the same Id
48 -- value for two identical strings stored separately and also cannot count on
49 -- the two such Id values being different.
51 Null_String_Id : String_Id;
52 -- Gets set to a null string with length zero
54 --------------------------------------
55 -- String Table Access Subprograms --
56 --------------------------------------
58 procedure Initialize;
59 -- Initializes the strings table for a new compilation
61 procedure Lock;
62 -- Lock internal tables before calling back end
64 procedure Unlock;
65 -- Unlock internal tables, in case back end needs to modify them
67 procedure Mark;
68 -- Take a snapshot of the internal tables. Used in conjunction with Release
69 -- when computing temporary string values that need not be preserved.
71 procedure Release;
72 -- Restore the internal tables to the situation when Mark was last called.
73 -- If Release is called with no prior call to Mark, the entire string table
74 -- is cleared to its initial (empty) setting.
76 procedure Start_String;
77 -- Sets up for storing a new string in the table. To store a string, a
78 -- call is first made to Start_String, then successive calls are
79 -- made to Store_String_Character to store the characters of the string.
80 -- Finally, a call to End_String terminates the entry and returns it Id.
82 procedure Start_String (S : String_Id);
83 -- Like Start_String with no parameter, except that the contents of the
84 -- new string is initialized to be a copy of the given string. A test is
85 -- made to see if S is the last created string, and if so it is shared,
86 -- rather than copied, this can be particularly helpful for the case of
87 -- a continued concatenation of string constants.
89 procedure Store_String_Char (C : Char_Code);
90 procedure Store_String_Char (C : Character);
91 -- Store next character of string, see description above for Start_String
93 procedure Store_String_Chars (S : String);
94 procedure Store_String_Chars (S : String_Id);
95 -- Store character codes of given string in sequence
97 procedure Store_String_Int (N : Int);
98 -- Stored decimal representation of integer with possible leading minus
100 procedure Unstore_String_Char;
101 -- Undoes effect of previous Store_String_Char call, used in some error
102 -- situations of unterminated string constants.
104 function End_String return String_Id;
105 -- Terminates current string and returns its Id
107 function String_Length (Id : String_Id) return Nat;
108 -- Returns length of previously stored string
110 function Get_String_Char (Id : String_Id; Index : Int) return Char_Code;
111 pragma Inline (Get_String_Char);
112 -- Obtains the specified character from a stored string. The lower bound
113 -- of stored strings is always 1, so the range is 1 .. String_Length (Id).
115 function String_Equal (L, R : String_Id) return Boolean;
116 -- Determines if two string literals represent the same string
118 function String_To_Name (S : String_Id) return Name_Id;
119 -- Convert String_Id to Name_Id
121 procedure Append (Buf : in out Bounded_String; S : String_Id);
122 -- Append characters of given string to Buf. Error if any characters are
123 -- out of Character range. Does not attempt to do any encoding of
124 -- characters.
126 function To_String (S : String_Id) return String;
127 -- Return S as a String
129 procedure String_To_Name_Buffer (S : String_Id);
130 -- Place characters of given string in Name_Buffer, setting Name_Len.
131 -- Error if any characters are out of Character range. Does not attempt
132 -- to do any encoding of any characters.
134 function String_Chars_Address return System.Address;
135 -- Return address of String_Chars table (used by Back_End call to Gigi)
137 function String_From_Name_Buffer
138 (Buf : Bounded_String := Global_Name_Buffer) return String_Id;
139 -- Given a name stored in Buf, returns a string of the corresponding value.
141 function Strings_Address return System.Address;
142 -- Return address of Strings table (used by Back_End call to Gigi)
144 procedure Write_Char_Code (Code : Char_Code);
145 -- Procedure to write a character code value, used for debugging purposes
146 -- for writing character codes. If the character code is in the range
147 -- 16#20# .. 16#7E#, then the single graphic character corresponding to
148 -- the code is output. For any other codes in the range 16#00# .. 16#FF#,
149 -- the code is output as ["hh"] where hh is the two digit hex value for
150 -- the code. Codes greater than 16#FF# are output as ["hhhh"] where hhhh
151 -- is the four digit hex representation of the code value (high order
152 -- byte first). Hex letters are always in lower case.
154 procedure Write_String_Table_Entry (Id : String_Id);
155 -- Writes a string value with enclosing quotes to the current file using
156 -- routines in package Output. Does not write an end of line character.
157 -- This procedure is used for debug output purposes, and also for output
158 -- of strings specified by pragma Linker Option to the ali file. 7-bit
159 -- ASCII graphics (except for double quote) are output literally.
160 -- The double quote appears as two successive double quotes.
161 -- All other codes, are output as described for Write_Char_Code. For
162 -- example, the string created by folding "A" & ASCII.HT & "Hello" will
163 -- print as "A["09"]Hello". A No_String value prints simply as "no string"
164 -- without surrounding quote marks.
166 private
167 pragma Inline (End_String);
168 pragma Inline (String_Length);
170 end Stringt;