OSDN Git Service

New Language: Ada
[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  *                            $Revision: 1.1 $
10  *                                                                          *
11  *          Copyright (C) 1992-2001 Free Software Foundation, Inc.          *
12  *                                                                          *
13  * GNAT is free software;  you can  redistribute it  and/or modify it under *
14  * terms of the  GNU General Public License as published  by the Free Soft- *
15  * ware  Foundation;  either version 2,  or (at your option) any later ver- *
16  * sion.  GNAT is distributed in the hope that it will be useful, but WITH- *
17  * OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY *
18  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License *
19  * for  more details.  You should have  received  a copy of the GNU General *
20  * Public License  distributed with GNAT;  see file COPYING.  If not, write *
21  * to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, *
22  * MA 02111-1307, USA.                                                      *
23  *                                                                          *
24  * GNAT was originally developed  by the GNAT team at  New York University. *
25  * It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). *
26  *                                                                          *
27  ****************************************************************************/
28
29 /* This file is the C file that corresponds to the Ada package spec
30    Stringt. It was created manually from stringt.ads and stringt.adb
31                                                                             
32    Note: only the access functions are provided, since the tree transformer
33    is not allowed to modify the tree or its auxiliary structures.
34                                                                             
35    This package contains routines for handling the strings table which is
36    used to store string constants encountered in the source, and also those
37    additional string constants generated by compile time concatenation and
38    other similar processing.
39                                                                             
40    A string constant in this table consists of a series of Char_Code values,
41    so that 16-bit character codes can be properly handled if this feature is
42    implemented in the scanner.
43                                                                             
44    There is no guarantee that hashing is used in the implementation. This
45    means that the caller cannot count on having the same Id value for two
46    identical strings stored separately.
47                                                                             
48    The String_Id values reference entries in the Strings table, which
49    contains String_Entry records that record the length of each stored string
50    and its starting location in the String_Chars table.  */
51
52 struct String_Entry
53 {
54   Int String_Index;
55   Int Length;
56 };
57
58 /* Pointer to string entry vector. This pointer is passed to the tree
59    transformer and stored in a global location for access from here after
60    subtracting String_First_Entry, so that String_Id values can be used as
61    subscripts into the vector. */
62 extern struct String_Entry *Strings_Ptr;
63
64 /* Pointer to name characters table. This pointer is passed to the tree
65    transformer and stored in a global location for access from here. The
66    String_Index values are subscripts into this array.  */
67 extern Char_Code *String_Chars_Ptr;
68
69
70 /* String_Length returns the length of the specified string.  */
71 INLINE Int String_Length PARAMS ((String_Id));
72
73 INLINE Int
74 String_Length (Id)
75      String_Id Id;
76 {
77   return Strings_Ptr [Id].Length;
78 }
79
80
81 /* Get_String_Char obtains the specified character from a stored string.  The
82    lower bound of stored strings is always 1, so the range of values is 1 to
83    String_Length (Id).  */
84 INLINE Char_Code Get_String_Char PARAMS ((String_Id, Int));
85
86 INLINE Char_Code
87 Get_String_Char (Id, Index)
88      String_Id Id;
89      Int Index;
90 {
91   return String_Chars_Ptr [Strings_Ptr [Id].String_Index + Index - 1];
92 }