annotate gcc/ada/stringt.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S T R I N G T --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 with Namet; use Namet;
kono
parents:
diff changeset
33 with System; use System;
kono
parents:
diff changeset
34 with Types; use Types;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 package Stringt is
kono
parents:
diff changeset
37 pragma Elaborate_Body;
kono
parents:
diff changeset
38 -- This is to make sure Null_String_Id is properly initialized
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 -- This package contains routines for handling the strings table which is
kono
parents:
diff changeset
41 -- used to store string constants encountered in the source, and also those
kono
parents:
diff changeset
42 -- additional string constants generated by compile time concatenation and
kono
parents:
diff changeset
43 -- other similar processing.
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 -- A string constant in this table consists of a series of Char_Code values,
kono
parents:
diff changeset
46 -- so that 16-bit character codes can be properly handled if this feature
kono
parents:
diff changeset
47 -- is implemented in the scanner.
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 -- There is no guarantee that hashing is used in the implementation, although
kono
parents:
diff changeset
50 -- it may be. This means that the caller cannot count on having the same Id
kono
parents:
diff changeset
51 -- value for two identical strings stored separately and also cannot count on
kono
parents:
diff changeset
52 -- the two such Id values being different.
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 Null_String_Id : String_Id;
kono
parents:
diff changeset
55 -- Gets set to a null string with length zero
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 --------------------------------------
kono
parents:
diff changeset
58 -- String Table Access Subprograms --
kono
parents:
diff changeset
59 --------------------------------------
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 procedure Initialize;
kono
parents:
diff changeset
62 -- Initializes the strings table for a new compilation. Note that
kono
parents:
diff changeset
63 -- Initialize must not be called if Tree_Read is used.
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 procedure Lock;
kono
parents:
diff changeset
66 -- Lock internal tables before calling back end
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 procedure Unlock;
kono
parents:
diff changeset
69 -- Unlock internal tables, in case back end needs to modify them
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 procedure Mark;
kono
parents:
diff changeset
72 -- Take a snapshot of the internal tables. Used in conjunction with Release
kono
parents:
diff changeset
73 -- when computing temporary string values that need not be preserved.
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 procedure Release;
kono
parents:
diff changeset
76 -- Restore the internal tables to the situation when Mark was last called.
kono
parents:
diff changeset
77 -- If Release is called with no prior call to Mark, the entire string table
kono
parents:
diff changeset
78 -- is cleared to its initial (empty) setting.
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure Start_String;
kono
parents:
diff changeset
81 -- Sets up for storing a new string in the table. To store a string, a
kono
parents:
diff changeset
82 -- call is first made to Start_String, then successive calls are
kono
parents:
diff changeset
83 -- made to Store_String_Character to store the characters of the string.
kono
parents:
diff changeset
84 -- Finally, a call to End_String terminates the entry and returns it Id.
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 procedure Start_String (S : String_Id);
kono
parents:
diff changeset
87 -- Like Start_String with no parameter, except that the contents of the
kono
parents:
diff changeset
88 -- new string is initialized to be a copy of the given string. A test is
kono
parents:
diff changeset
89 -- made to see if S is the last created string, and if so it is shared,
kono
parents:
diff changeset
90 -- rather than copied, this can be particularly helpful for the case of
kono
parents:
diff changeset
91 -- a continued concatenation of string constants.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 procedure Store_String_Char (C : Char_Code);
kono
parents:
diff changeset
94 procedure Store_String_Char (C : Character);
kono
parents:
diff changeset
95 -- Store next character of string, see description above for Start_String
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 procedure Store_String_Chars (S : String);
kono
parents:
diff changeset
98 procedure Store_String_Chars (S : String_Id);
kono
parents:
diff changeset
99 -- Store character codes of given string in sequence
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 procedure Store_String_Int (N : Int);
kono
parents:
diff changeset
102 -- Stored decimal representation of integer with possible leading minus
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 procedure Unstore_String_Char;
kono
parents:
diff changeset
105 -- Undoes effect of previous Store_String_Char call, used in some error
kono
parents:
diff changeset
106 -- situations of unterminated string constants.
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 function End_String return String_Id;
kono
parents:
diff changeset
109 -- Terminates current string and returns its Id
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 function String_Length (Id : String_Id) return Nat;
kono
parents:
diff changeset
112 -- Returns length of previously stored string
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 function Get_String_Char (Id : String_Id; Index : Int) return Char_Code;
kono
parents:
diff changeset
115 pragma Inline (Get_String_Char);
kono
parents:
diff changeset
116 -- Obtains the specified character from a stored string. The lower bound
kono
parents:
diff changeset
117 -- of stored strings is always 1, so the range is 1 .. String_Length (Id).
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 function String_Equal (L, R : String_Id) return Boolean;
kono
parents:
diff changeset
120 -- Determines if two string literals represent the same string
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 function String_To_Name (S : String_Id) return Name_Id;
kono
parents:
diff changeset
123 -- Convert String_Id to Name_Id
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 procedure Append (Buf : in out Bounded_String; S : String_Id);
kono
parents:
diff changeset
126 -- Append characters of given string to Buf. Error if any characters are
kono
parents:
diff changeset
127 -- out of Character range. Does not attempt to do any encoding of
kono
parents:
diff changeset
128 -- characters.
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 procedure String_To_Name_Buffer (S : String_Id);
kono
parents:
diff changeset
131 -- Place characters of given string in Name_Buffer, setting Name_Len.
kono
parents:
diff changeset
132 -- Error if any characters are out of Character range. Does not attempt
kono
parents:
diff changeset
133 -- to do any encoding of any characters.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 function String_Chars_Address return System.Address;
kono
parents:
diff changeset
136 -- Return address of String_Chars table (used by Back_End call to Gigi)
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 function String_From_Name_Buffer
kono
parents:
diff changeset
139 (Buf : Bounded_String := Global_Name_Buffer) return String_Id;
kono
parents:
diff changeset
140 -- Given a name stored in Buf, returns a string of the corresponding value.
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 function Strings_Address return System.Address;
kono
parents:
diff changeset
143 -- Return address of Strings table (used by Back_End call to Gigi)
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 procedure Tree_Read;
kono
parents:
diff changeset
146 -- Initializes internal tables from current tree file using the relevant
kono
parents:
diff changeset
147 -- Table.Tree_Read routines. Note that Initialize should not be called if
kono
parents:
diff changeset
148 -- Tree_Read is used. Tree_Read includes all necessary initialization.
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 procedure Tree_Write;
kono
parents:
diff changeset
151 -- Writes out internal tables to current tree file using the relevant
kono
parents:
diff changeset
152 -- Table.Tree_Write routines.
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 procedure Write_Char_Code (Code : Char_Code);
kono
parents:
diff changeset
155 -- Procedure to write a character code value, used for debugging purposes
kono
parents:
diff changeset
156 -- for writing character codes. If the character code is in the range
kono
parents:
diff changeset
157 -- 16#20# .. 16#7E#, then the single graphic character corresponding to
kono
parents:
diff changeset
158 -- the code is output. For any other codes in the range 16#00# .. 16#FF#,
kono
parents:
diff changeset
159 -- the code is output as ["hh"] where hh is the two digit hex value for
kono
parents:
diff changeset
160 -- the code. Codes greater than 16#FF# are output as ["hhhh"] where hhhh
kono
parents:
diff changeset
161 -- is the four digit hex representation of the code value (high order
kono
parents:
diff changeset
162 -- byte first). Hex letters are always in lower case.
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 procedure Write_String_Table_Entry (Id : String_Id);
kono
parents:
diff changeset
165 -- Writes a string value with enclosing quotes to the current file using
kono
parents:
diff changeset
166 -- routines in package Output. Does not write an end of line character.
kono
parents:
diff changeset
167 -- This procedure is used for debug output purposes, and also for output
kono
parents:
diff changeset
168 -- of strings specified by pragma Linker Option to the ali file. 7-bit
kono
parents:
diff changeset
169 -- ASCII graphics (except for double quote) are output literally.
kono
parents:
diff changeset
170 -- The double quote appears as two successive double quotes.
kono
parents:
diff changeset
171 -- All other codes, are output as described for Write_Char_Code. For
kono
parents:
diff changeset
172 -- example, the string created by folding "A" & ASCII.HT & "Hello" will
kono
parents:
diff changeset
173 -- print as "A["09"]Hello". A No_String value prints simply as "no string"
kono
parents:
diff changeset
174 -- without surrounding quote marks.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 private
kono
parents:
diff changeset
177 pragma Inline (End_String);
kono
parents:
diff changeset
178 pragma Inline (String_Length);
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 end Stringt;