| 1 |
/**************************************************************************** |
| 2 |
* * |
| 3 |
* GNAT COMPILER COMPONENTS * |
| 4 |
* * |
| 5 |
* S T R I N G T * |
| 6 |
* * |
| 7 |
* C Header File * |
| 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 |
/* This is the C header that corresponds to the Ada package specification for |
| 27 |
Stringt. It also contains the implementations of inlined functions from the |
| 28 |
package body for Stringt. It was created manually from stringt.ads and |
| 29 |
stringt.adb and must be kept synchronized with changes in these files. |
| 30 |
|
| 31 |
Note: only the access functions are provided, since the tree transformer |
| 32 |
is not allowed to modify the tree or its auxiliary structures. |
| 33 |
|
| 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. |
| 38 |
|
| 39 |
A string constant in this table consists of a series of Char_Code values, |
| 40 |
so that 16-bit character codes can be properly handled if this feature is |
| 41 |
implemented in the scanner. |
| 42 |
|
| 43 |
There is no guarantee that hashing is used in the implementation. This |
| 44 |
means that the caller cannot count on having the same Id value for two |
| 45 |
identical strings stored separately. |
| 46 |
|
| 47 |
The String_Id values reference entries in the Strings table, which |
| 48 |
contains String_Entry records that record the length of each stored string |
| 49 |
and its starting location in the String_Chars table. */ |
| 50 |
|
| 51 |
struct String_Entry |
| 52 |
{ |
| 53 |
Int String_Index; |
| 54 |
Int Length; |
| 55 |
}; |
| 56 |
|
| 57 |
/* Pointer to string entry vector. This pointer is passed to the tree |
| 58 |
transformer and stored in a global location. */ |
| 59 |
extern struct String_Entry *Strings_Ptr; |
| 60 |
|
| 61 |
/* Pointer to name characters table. This pointer is passed to the tree |
| 62 |
transformer and stored in a global location for access from here. The |
| 63 |
String_Index values are subscripts into this array. */ |
| 64 |
extern Char_Code *String_Chars_Ptr; |
| 65 |
|
| 66 |
|
| 67 |
/* String_Length returns the length of the specified string. */ |
| 68 |
INLINE Int String_Length (String_Id); |
| 69 |
|
| 70 |
INLINE Int |
| 71 |
String_Length (String_Id Id) |
| 72 |
{ |
| 73 |
return Strings_Ptr[Id - First_String_Id].Length; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
/* Get_String_Char obtains the specified character from a stored string. The |
| 78 |
lower bound of stored strings is always 1, so the range of values is 1 to |
| 79 |
String_Length (Id). */ |
| 80 |
INLINE Char_Code Get_String_Char (String_Id, Int); |
| 81 |
|
| 82 |
INLINE Char_Code |
| 83 |
Get_String_Char (String_Id Id, Int Index) |
| 84 |
{ |
| 85 |
return |
| 86 |
String_Chars_Ptr |
| 87 |
[Strings_Ptr[Id - First_String_Id].String_Index + Index - 1]; |
| 88 |
} |