]>
Commit | Line | Data |
---|---|---|
996ae0b0 RK |
1 | /**************************************************************************** |
2 | * * | |
3 | * GNAT COMPILER COMPONENTS * | |
4 | * * | |
5 | * S T R I N G T * | |
6 | * * | |
7 | * C Header File * | |
8 | * * | |
b5c84c3c | 9 | * Copyright (C) 1992-2007, Free Software Foundation, Inc. * |
996ae0b0 RK |
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- * | |
d70c0bd6 | 13 | * ware Foundation; either version 3, or (at your option) any later ver- * |
996ae0b0 RK |
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 * | |
b5c84c3c RD |
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. * | |
996ae0b0 RK |
20 | * * |
21 | * GNAT was originally developed by the GNAT team at New York University. * | |
71ff80dc | 22 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
996ae0b0 RK |
23 | * * |
24 | ****************************************************************************/ | |
25 | ||
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 | |
12e0c41c | 28 | |
996ae0b0 RK |
29 | Note: only the access functions are provided, since the tree transformer |
30 | is not allowed to modify the tree or its auxiliary structures. | |
12e0c41c | 31 | |
996ae0b0 RK |
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. | |
12e0c41c | 36 | |
996ae0b0 RK |
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. | |
12e0c41c | 40 | |
996ae0b0 RK |
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. | |
12e0c41c | 44 | |
996ae0b0 RK |
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. */ | |
48 | ||
49 | struct String_Entry | |
50 | { | |
51 | Int String_Index; | |
52 | Int Length; | |
53 | }; | |
54 | ||
55 | /* Pointer to string entry vector. This pointer is passed to the tree | |
07fc65c4 | 56 | transformer and stored in a global location. */ |
996ae0b0 RK |
57 | extern struct String_Entry *Strings_Ptr; |
58 | ||
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; | |
63 | ||
64 | ||
65 | /* String_Length returns the length of the specified string. */ | |
b4e2d709 | 66 | INLINE Int String_Length (String_Id); |
996ae0b0 RK |
67 | |
68 | INLINE Int | |
b4e2d709 | 69 | String_Length (String_Id Id) |
996ae0b0 | 70 | { |
07fc65c4 | 71 | return Strings_Ptr[Id - First_String_Id].Length; |
996ae0b0 RK |
72 | } |
73 | ||
74 | ||
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). */ | |
b4e2d709 | 78 | INLINE Char_Code Get_String_Char (String_Id, Int); |
996ae0b0 RK |
79 | |
80 | INLINE Char_Code | |
b4e2d709 | 81 | Get_String_Char (String_Id Id, Int Index) |
996ae0b0 | 82 | { |
07fc65c4 GB |
83 | return |
84 | String_Chars_Ptr | |
85 | [Strings_Ptr[Id - First_String_Id].String_Index + Index - 1]; | |
996ae0b0 | 86 | } |