PR rtl-optimization/79386
[official-gcc.git] / gcc / ada / stringt.h
blob66ca4fb0fda06f6fffb57ac3d107e0cf79df2d88
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-2007, 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 /* This file is the C file that corresponds to the Ada package spec
27 Stringt. It was created manually from stringt.ads and stringt.adb
29 Note: only the access functions are provided, since the tree transformer
30 is not allowed to modify the tree or its auxiliary structures.
32 This package contains routines for handling the strings table which is
33 used to store string constants encountered in the source, and also those
34 additional string constants generated by compile time concatenation and
35 other similar processing.
37 A string constant in this table consists of a series of Char_Code values,
38 so that 16-bit character codes can be properly handled if this feature is
39 implemented in the scanner.
41 There is no guarantee that hashing is used in the implementation. This
42 means that the caller cannot count on having the same Id value for two
43 identical strings stored separately.
45 The String_Id values reference entries in the Strings table, which
46 contains String_Entry records that record the length of each stored string
47 and its starting location in the String_Chars table. */
49 struct String_Entry
51 Int String_Index;
52 Int Length;
55 /* Pointer to string entry vector. This pointer is passed to the tree
56 transformer and stored in a global location. */
57 extern struct String_Entry *Strings_Ptr;
59 /* Pointer to name characters table. This pointer is passed to the tree
60 transformer and stored in a global location for access from here. The
61 String_Index values are subscripts into this array. */
62 extern Char_Code *String_Chars_Ptr;
65 /* String_Length returns the length of the specified string. */
66 INLINE Int String_Length (String_Id);
68 INLINE Int
69 String_Length (String_Id Id)
71 return Strings_Ptr[Id - First_String_Id].Length;
75 /* Get_String_Char obtains the specified character from a stored string. The
76 lower bound of stored strings is always 1, so the range of values is 1 to
77 String_Length (Id). */
78 INLINE Char_Code Get_String_Char (String_Id, Int);
80 INLINE Char_Code
81 Get_String_Char (String_Id Id, Int Index)
83 return
84 String_Chars_Ptr
85 [Strings_Ptr[Id - First_String_Id].String_Index + Index - 1];