OSDN Git Service

Nathanael Nerode <neroden@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / ada / stringt.h
1 /****************************************************************************
2  *                                                                          *
3  *                         GNAT COMPILER COMPONENTS                         *
4  *                                                                          *
5  *                              S T R I N G T                               *
6  *                                                                          *
7  *                              C Header File                               *
8  *                                                                          *
9  *                                                                          *
10  *          Copyright (C) 1992-2001 Free Software Foundation, Inc.          *
11  *                                                                          *
12  * GNAT is free software;  you can  redistribute it  and/or modify it under *
13  * terms of the  GNU General Public License as published  by the Free Soft- *
14  * ware  Foundation;  either version 2,  or (at your option) any later ver- *
15  * sion.  GNAT is distributed in the hope that it will be useful, but WITH- *
16  * OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY *
17  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License *
18  * for  more details.  You should have  received  a copy of the GNU General *
19  * Public License  distributed with GNAT;  see file COPYING.  If not, write *
20  * to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, *
21  * MA 02111-1307, USA.                                                      *
22  *                                                                          *
23  * GNAT was originally developed  by the GNAT team at  New York University. *
24  * Extensive contributions were provided by Ada Core Technologies Inc.      *
25  *                                                                          *
26  ****************************************************************************/
27
28 /* This file is the C file that corresponds to the Ada package spec
29    Stringt. It was created manually from stringt.ads and stringt.adb
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 PARAMS ((String_Id));
69
70 INLINE Int
71 String_Length (Id)
72      String_Id Id;
73 {
74   return Strings_Ptr[Id - First_String_Id].Length;
75 }
76
77
78 /* Get_String_Char obtains the specified character from a stored string.  The
79    lower bound of stored strings is always 1, so the range of values is 1 to
80    String_Length (Id).  */
81 INLINE Char_Code Get_String_Char PARAMS ((String_Id, Int));
82
83 INLINE Char_Code
84 Get_String_Char (Id, Index)
85      String_Id Id;
86      Int Index;
87 {
88   return
89     String_Chars_Ptr
90       [Strings_Ptr[Id - First_String_Id].String_Index + Index - 1];
91 }