Rev 5191 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5191 | Rev 6324 | ||
---|---|---|---|
1 | /* Defs for interface to demanglers. |
1 | /* Defs for interface to demanglers. |
2 | Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, |
- | |
3 | 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
2 | Copyright (C) 1992-2015 Free Software Foundation, Inc. |
4 | 3 | ||
5 | This program is free software; you can redistribute it and/or |
4 | This program is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public License |
5 | modify it under the terms of the GNU Library General Public License |
7 | as published by the Free Software Foundation; either version 2, or |
6 | as published by the Free Software Foundation; either version 2, or |
8 | (at your option) any later version. |
7 | (at your option) any later version. |
9 | 8 | ||
10 | In addition to the permissions in the GNU Library General Public |
9 | In addition to the permissions in the GNU Library General Public |
11 | License, the Free Software Foundation gives you unlimited |
10 | License, the Free Software Foundation gives you unlimited |
12 | permission to link the compiled version of this file into |
11 | permission to link the compiled version of this file into |
13 | combinations with other programs, and to distribute those |
12 | combinations with other programs, and to distribute those |
14 | combinations without any restriction coming from the use of this |
13 | combinations without any restriction coming from the use of this |
15 | file. (The Library Public License restrictions do apply in other |
14 | file. (The Library Public License restrictions do apply in other |
16 | respects; for example, they cover modification of the file, and |
15 | respects; for example, they cover modification of the file, and |
17 | distribution when not linked into a combined executable.) |
16 | distribution when not linked into a combined executable.) |
18 | 17 | ||
19 | This program is distributed in the hope that it will be useful, but |
18 | This program is distributed in the hope that it will be useful, but |
20 | WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22 | Library General Public License for more details. |
21 | Library General Public License for more details. |
23 | 22 | ||
24 | You should have received a copy of the GNU Library General Public |
23 | You should have received a copy of the GNU Library General Public |
25 | License along with this program; if not, write to the Free Software |
24 | License along with this program; if not, write to the Free Software |
26 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
25 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
27 | 02110-1301, USA. */ |
26 | 02110-1301, USA. */ |
28 | 27 | ||
29 | 28 | ||
30 | #if !defined (DEMANGLE_H) |
29 | #if !defined (DEMANGLE_H) |
31 | #define DEMANGLE_H |
30 | #define DEMANGLE_H |
32 | 31 | ||
33 | #include "libiberty.h" |
32 | #include "libiberty.h" |
34 | 33 | ||
35 | #ifdef __cplusplus |
34 | #ifdef __cplusplus |
36 | extern "C" { |
35 | extern "C" { |
37 | #endif /* __cplusplus */ |
36 | #endif /* __cplusplus */ |
38 | 37 | ||
39 | /* Options passed to cplus_demangle (in 2nd parameter). */ |
38 | /* Options passed to cplus_demangle (in 2nd parameter). */ |
40 | 39 | ||
41 | #define DMGL_NO_OPTS 0 /* For readability... */ |
40 | #define DMGL_NO_OPTS 0 /* For readability... */ |
42 | #define DMGL_PARAMS (1 << 0) /* Include function args */ |
41 | #define DMGL_PARAMS (1 << 0) /* Include function args */ |
43 | #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ |
42 | #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ |
44 | #define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */ |
43 | #define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */ |
45 | #define DMGL_VERBOSE (1 << 3) /* Include implementation details. */ |
44 | #define DMGL_VERBOSE (1 << 3) /* Include implementation details. */ |
46 | #define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */ |
45 | #define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */ |
47 | #define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when |
46 | #define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when |
48 | present) after function signature. |
47 | present) after function signature. |
49 | It applies only to the toplevel |
48 | It applies only to the toplevel |
50 | function type. */ |
49 | function type. */ |
51 | #define DMGL_RET_DROP (1 << 6) /* Suppress printing function return |
50 | #define DMGL_RET_DROP (1 << 6) /* Suppress printing function return |
52 | types, even if present. It applies |
51 | types, even if present. It applies |
53 | only to the toplevel function type. |
52 | only to the toplevel function type. |
54 | */ |
53 | */ |
55 | 54 | ||
56 | #define DMGL_AUTO (1 << 8) |
55 | #define DMGL_AUTO (1 << 8) |
57 | #define DMGL_GNU (1 << 9) |
56 | #define DMGL_GNU (1 << 9) |
58 | #define DMGL_LUCID (1 << 10) |
57 | #define DMGL_LUCID (1 << 10) |
59 | #define DMGL_ARM (1 << 11) |
58 | #define DMGL_ARM (1 << 11) |
60 | #define DMGL_HP (1 << 12) /* For the HP aCC compiler; |
59 | #define DMGL_HP (1 << 12) /* For the HP aCC compiler; |
61 | same as ARM except for |
60 | same as ARM except for |
62 | template arguments, etc. */ |
61 | template arguments, etc. */ |
63 | #define DMGL_EDG (1 << 13) |
62 | #define DMGL_EDG (1 << 13) |
64 | #define DMGL_GNU_V3 (1 << 14) |
63 | #define DMGL_GNU_V3 (1 << 14) |
65 | #define DMGL_GNAT (1 << 15) |
64 | #define DMGL_GNAT (1 << 15) |
- | 65 | #define DMGL_DLANG (1 << 16) |
|
66 | 66 | ||
67 | /* If none of these are set, use 'current_demangling_style' as the default. */ |
67 | /* If none of these are set, use 'current_demangling_style' as the default. */ |
68 | #define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT) |
68 | #define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT|DMGL_DLANG) |
69 | 69 | ||
70 | /* Enumeration of possible demangling styles. |
70 | /* Enumeration of possible demangling styles. |
71 | 71 | ||
72 | Lucid and ARM styles are still kept logically distinct, even though |
72 | Lucid and ARM styles are still kept logically distinct, even though |
73 | they now both behave identically. The resulting style is actual the |
73 | they now both behave identically. The resulting style is actual the |
74 | union of both. I.E. either style recognizes both "__pt__" and "__rf__" |
74 | union of both. I.E. either style recognizes both "__pt__" and "__rf__" |
75 | for operator "->", even though the first is lucid style and the second |
75 | for operator "->", even though the first is lucid style and the second |
76 | is ARM style. (FIXME?) */ |
76 | is ARM style. (FIXME?) */ |
77 | 77 | ||
78 | extern enum demangling_styles |
78 | extern enum demangling_styles |
79 | { |
79 | { |
80 | no_demangling = -1, |
80 | no_demangling = -1, |
81 | unknown_demangling = 0, |
81 | unknown_demangling = 0, |
82 | auto_demangling = DMGL_AUTO, |
82 | auto_demangling = DMGL_AUTO, |
83 | gnu_demangling = DMGL_GNU, |
83 | gnu_demangling = DMGL_GNU, |
84 | lucid_demangling = DMGL_LUCID, |
84 | lucid_demangling = DMGL_LUCID, |
85 | arm_demangling = DMGL_ARM, |
85 | arm_demangling = DMGL_ARM, |
86 | hp_demangling = DMGL_HP, |
86 | hp_demangling = DMGL_HP, |
87 | edg_demangling = DMGL_EDG, |
87 | edg_demangling = DMGL_EDG, |
88 | gnu_v3_demangling = DMGL_GNU_V3, |
88 | gnu_v3_demangling = DMGL_GNU_V3, |
89 | java_demangling = DMGL_JAVA, |
89 | java_demangling = DMGL_JAVA, |
90 | gnat_demangling = DMGL_GNAT |
90 | gnat_demangling = DMGL_GNAT, |
- | 91 | dlang_demangling = DMGL_DLANG |
|
91 | } current_demangling_style; |
92 | } current_demangling_style; |
92 | 93 | ||
93 | /* Define string names for the various demangling styles. */ |
94 | /* Define string names for the various demangling styles. */ |
94 | 95 | ||
95 | #define NO_DEMANGLING_STYLE_STRING "none" |
96 | #define NO_DEMANGLING_STYLE_STRING "none" |
96 | #define AUTO_DEMANGLING_STYLE_STRING "auto" |
97 | #define AUTO_DEMANGLING_STYLE_STRING "auto" |
97 | #define GNU_DEMANGLING_STYLE_STRING "gnu" |
98 | #define GNU_DEMANGLING_STYLE_STRING "gnu" |
98 | #define LUCID_DEMANGLING_STYLE_STRING "lucid" |
99 | #define LUCID_DEMANGLING_STYLE_STRING "lucid" |
99 | #define ARM_DEMANGLING_STYLE_STRING "arm" |
100 | #define ARM_DEMANGLING_STYLE_STRING "arm" |
100 | #define HP_DEMANGLING_STYLE_STRING "hp" |
101 | #define HP_DEMANGLING_STYLE_STRING "hp" |
101 | #define EDG_DEMANGLING_STYLE_STRING "edg" |
102 | #define EDG_DEMANGLING_STYLE_STRING "edg" |
102 | #define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3" |
103 | #define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3" |
103 | #define JAVA_DEMANGLING_STYLE_STRING "java" |
104 | #define JAVA_DEMANGLING_STYLE_STRING "java" |
104 | #define GNAT_DEMANGLING_STYLE_STRING "gnat" |
105 | #define GNAT_DEMANGLING_STYLE_STRING "gnat" |
- | 106 | #define DLANG_DEMANGLING_STYLE_STRING "dlang" |
|
105 | 107 | ||
106 | /* Some macros to test what demangling style is active. */ |
108 | /* Some macros to test what demangling style is active. */ |
107 | 109 | ||
108 | #define CURRENT_DEMANGLING_STYLE current_demangling_style |
110 | #define CURRENT_DEMANGLING_STYLE current_demangling_style |
109 | #define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO) |
111 | #define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO) |
110 | #define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU) |
112 | #define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU) |
111 | #define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID) |
113 | #define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID) |
112 | #define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM) |
114 | #define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM) |
113 | #define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP) |
115 | #define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP) |
114 | #define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG) |
116 | #define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG) |
115 | #define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3) |
117 | #define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3) |
116 | #define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA) |
118 | #define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA) |
117 | #define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT) |
119 | #define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT) |
- | 120 | #define DLANG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_DLANG) |
|
118 | 121 | ||
119 | /* Provide information about the available demangle styles. This code is |
122 | /* Provide information about the available demangle styles. This code is |
120 | pulled from gdb into libiberty because it is useful to binutils also. */ |
123 | pulled from gdb into libiberty because it is useful to binutils also. */ |
121 | 124 | ||
122 | extern const struct demangler_engine |
125 | extern const struct demangler_engine |
123 | { |
126 | { |
124 | const char *const demangling_style_name; |
127 | const char *const demangling_style_name; |
125 | const enum demangling_styles demangling_style; |
128 | const enum demangling_styles demangling_style; |
126 | const char *const demangling_style_doc; |
129 | const char *const demangling_style_doc; |
127 | } libiberty_demanglers[]; |
130 | } libiberty_demanglers[]; |
128 | 131 | ||
129 | extern char * |
132 | extern char * |
130 | cplus_demangle (const char *mangled, int options); |
133 | cplus_demangle (const char *mangled, int options); |
131 | 134 | ||
132 | extern int |
135 | extern int |
133 | cplus_demangle_opname (const char *opname, char *result, int options); |
136 | cplus_demangle_opname (const char *opname, char *result, int options); |
134 | 137 | ||
135 | extern const char * |
138 | extern const char * |
136 | cplus_mangle_opname (const char *opname, int options); |
139 | cplus_mangle_opname (const char *opname, int options); |
137 | 140 | ||
138 | /* Note: This sets global state. FIXME if you care about multi-threading. */ |
141 | /* Note: This sets global state. FIXME if you care about multi-threading. */ |
139 | 142 | ||
140 | extern void |
143 | extern void |
141 | set_cplus_marker_for_demangling (int ch); |
144 | set_cplus_marker_for_demangling (int ch); |
142 | 145 | ||
143 | extern enum demangling_styles |
146 | extern enum demangling_styles |
144 | cplus_demangle_set_style (enum demangling_styles style); |
147 | cplus_demangle_set_style (enum demangling_styles style); |
145 | 148 | ||
146 | extern enum demangling_styles |
149 | extern enum demangling_styles |
147 | cplus_demangle_name_to_style (const char *name); |
150 | cplus_demangle_name_to_style (const char *name); |
148 | 151 | ||
149 | /* Callback typedef for allocation-less demangler interfaces. */ |
152 | /* Callback typedef for allocation-less demangler interfaces. */ |
150 | typedef void (*demangle_callbackref) (const char *, size_t, void *); |
153 | typedef void (*demangle_callbackref) (const char *, size_t, void *); |
151 | 154 | ||
152 | /* V3 ABI demangling entry points, defined in cp-demangle.c. Callback |
155 | /* V3 ABI demangling entry points, defined in cp-demangle.c. Callback |
153 | variants return non-zero on success, zero on error. char* variants |
156 | variants return non-zero on success, zero on error. char* variants |
154 | return a string allocated by malloc on success, NULL on error. */ |
157 | return a string allocated by malloc on success, NULL on error. */ |
155 | extern int |
158 | extern int |
156 | cplus_demangle_v3_callback (const char *mangled, int options, |
159 | cplus_demangle_v3_callback (const char *mangled, int options, |
157 | demangle_callbackref callback, void *opaque); |
160 | demangle_callbackref callback, void *opaque); |
158 | 161 | ||
159 | extern char* |
162 | extern char* |
160 | cplus_demangle_v3 (const char *mangled, int options); |
163 | cplus_demangle_v3 (const char *mangled, int options); |
161 | 164 | ||
162 | extern int |
165 | extern int |
163 | java_demangle_v3_callback (const char *mangled, |
166 | java_demangle_v3_callback (const char *mangled, |
164 | demangle_callbackref callback, void *opaque); |
167 | demangle_callbackref callback, void *opaque); |
165 | 168 | ||
166 | extern char* |
169 | extern char* |
167 | java_demangle_v3 (const char *mangled); |
170 | java_demangle_v3 (const char *mangled); |
168 | 171 | ||
169 | char * |
172 | char * |
170 | ada_demangle (const char *mangled, int options); |
173 | ada_demangle (const char *mangled, int options); |
- | 174 | ||
- | 175 | extern char * |
|
- | 176 | dlang_demangle (const char *mangled, int options); |
|
171 | 177 | ||
172 | enum gnu_v3_ctor_kinds { |
178 | enum gnu_v3_ctor_kinds { |
173 | gnu_v3_complete_object_ctor = 1, |
179 | gnu_v3_complete_object_ctor = 1, |
174 | gnu_v3_base_object_ctor, |
180 | gnu_v3_base_object_ctor, |
175 | gnu_v3_complete_object_allocating_ctor, |
181 | gnu_v3_complete_object_allocating_ctor, |
- | 182 | /* These are not part of the V3 ABI. Unified constructors are generated |
|
- | 183 | as a speed-for-space optimization when the -fdeclone-ctor-dtor option |
|
- | 184 | is used, and are always internal symbols. */ |
|
- | 185 | gnu_v3_unified_ctor, |
|
176 | gnu_v3_object_ctor_group |
186 | gnu_v3_object_ctor_group |
177 | }; |
187 | }; |
178 | 188 | ||
179 | /* Return non-zero iff NAME is the mangled form of a constructor name |
189 | /* Return non-zero iff NAME is the mangled form of a constructor name |
180 | in the G++ V3 ABI demangling style. Specifically, return an `enum |
190 | in the G++ V3 ABI demangling style. Specifically, return an `enum |
181 | gnu_v3_ctor_kinds' value indicating what kind of constructor |
191 | gnu_v3_ctor_kinds' value indicating what kind of constructor |
182 | it is. */ |
192 | it is. */ |
183 | extern enum gnu_v3_ctor_kinds |
193 | extern enum gnu_v3_ctor_kinds |
184 | is_gnu_v3_mangled_ctor (const char *name); |
194 | is_gnu_v3_mangled_ctor (const char *name); |
185 | 195 | ||
186 | 196 | ||
187 | enum gnu_v3_dtor_kinds { |
197 | enum gnu_v3_dtor_kinds { |
188 | gnu_v3_deleting_dtor = 1, |
198 | gnu_v3_deleting_dtor = 1, |
189 | gnu_v3_complete_object_dtor, |
199 | gnu_v3_complete_object_dtor, |
190 | gnu_v3_base_object_dtor, |
200 | gnu_v3_base_object_dtor, |
- | 201 | /* These are not part of the V3 ABI. Unified destructors are generated |
|
- | 202 | as a speed-for-space optimization when the -fdeclone-ctor-dtor option |
|
- | 203 | is used, and are always internal symbols. */ |
|
- | 204 | gnu_v3_unified_dtor, |
|
191 | gnu_v3_object_dtor_group |
205 | gnu_v3_object_dtor_group |
192 | }; |
206 | }; |
193 | 207 | ||
194 | /* Return non-zero iff NAME is the mangled form of a destructor name |
208 | /* Return non-zero iff NAME is the mangled form of a destructor name |
195 | in the G++ V3 ABI demangling style. Specifically, return an `enum |
209 | in the G++ V3 ABI demangling style. Specifically, return an `enum |
196 | gnu_v3_dtor_kinds' value, indicating what kind of destructor |
210 | gnu_v3_dtor_kinds' value, indicating what kind of destructor |
197 | it is. */ |
211 | it is. */ |
198 | extern enum gnu_v3_dtor_kinds |
212 | extern enum gnu_v3_dtor_kinds |
199 | is_gnu_v3_mangled_dtor (const char *name); |
213 | is_gnu_v3_mangled_dtor (const char *name); |
200 | 214 | ||
201 | /* The V3 demangler works in two passes. The first pass builds a tree |
215 | /* The V3 demangler works in two passes. The first pass builds a tree |
202 | representation of the mangled name, and the second pass turns the |
216 | representation of the mangled name, and the second pass turns the |
203 | tree representation into a demangled string. Here we define an |
217 | tree representation into a demangled string. Here we define an |
204 | interface to permit a caller to build their own tree |
218 | interface to permit a caller to build their own tree |
205 | representation, which they can pass to the demangler to get a |
219 | representation, which they can pass to the demangler to get a |
206 | demangled string. This can be used to canonicalize user input into |
220 | demangled string. This can be used to canonicalize user input into |
207 | something which the demangler might output. It could also be used |
221 | something which the demangler might output. It could also be used |
208 | by other demanglers in the future. */ |
222 | by other demanglers in the future. */ |
209 | 223 | ||
210 | /* These are the component types which may be found in the tree. Many |
224 | /* These are the component types which may be found in the tree. Many |
211 | component types have one or two subtrees, referred to as left and |
225 | component types have one or two subtrees, referred to as left and |
212 | right (a component type with only one subtree puts it in the left |
226 | right (a component type with only one subtree puts it in the left |
213 | subtree). */ |
227 | subtree). */ |
214 | 228 | ||
215 | enum demangle_component_type |
229 | enum demangle_component_type |
216 | { |
230 | { |
217 | /* A name, with a length and a pointer to a string. */ |
231 | /* A name, with a length and a pointer to a string. */ |
218 | DEMANGLE_COMPONENT_NAME, |
232 | DEMANGLE_COMPONENT_NAME, |
219 | /* A qualified name. The left subtree is a class or namespace or |
233 | /* A qualified name. The left subtree is a class or namespace or |
220 | some such thing, and the right subtree is a name qualified by |
234 | some such thing, and the right subtree is a name qualified by |
221 | that class. */ |
235 | that class. */ |
222 | DEMANGLE_COMPONENT_QUAL_NAME, |
236 | DEMANGLE_COMPONENT_QUAL_NAME, |
223 | /* A local name. The left subtree describes a function, and the |
237 | /* A local name. The left subtree describes a function, and the |
224 | right subtree is a name which is local to that function. */ |
238 | right subtree is a name which is local to that function. */ |
225 | DEMANGLE_COMPONENT_LOCAL_NAME, |
239 | DEMANGLE_COMPONENT_LOCAL_NAME, |
226 | /* A typed name. The left subtree is a name, and the right subtree |
240 | /* A typed name. The left subtree is a name, and the right subtree |
227 | describes that name as a function. */ |
241 | describes that name as a function. */ |
228 | DEMANGLE_COMPONENT_TYPED_NAME, |
242 | DEMANGLE_COMPONENT_TYPED_NAME, |
229 | /* A template. The left subtree is a template name, and the right |
243 | /* A template. The left subtree is a template name, and the right |
230 | subtree is a template argument list. */ |
244 | subtree is a template argument list. */ |
231 | DEMANGLE_COMPONENT_TEMPLATE, |
245 | DEMANGLE_COMPONENT_TEMPLATE, |
232 | /* A template parameter. This holds a number, which is the template |
246 | /* A template parameter. This holds a number, which is the template |
233 | parameter index. */ |
247 | parameter index. */ |
234 | DEMANGLE_COMPONENT_TEMPLATE_PARAM, |
248 | DEMANGLE_COMPONENT_TEMPLATE_PARAM, |
235 | /* A function parameter. This holds a number, which is the index. */ |
249 | /* A function parameter. This holds a number, which is the index. */ |
236 | DEMANGLE_COMPONENT_FUNCTION_PARAM, |
250 | DEMANGLE_COMPONENT_FUNCTION_PARAM, |
237 | /* A constructor. This holds a name and the kind of |
251 | /* A constructor. This holds a name and the kind of |
238 | constructor. */ |
252 | constructor. */ |
239 | DEMANGLE_COMPONENT_CTOR, |
253 | DEMANGLE_COMPONENT_CTOR, |
240 | /* A destructor. This holds a name and the kind of destructor. */ |
254 | /* A destructor. This holds a name and the kind of destructor. */ |
241 | DEMANGLE_COMPONENT_DTOR, |
255 | DEMANGLE_COMPONENT_DTOR, |
242 | /* A vtable. This has one subtree, the type for which this is a |
256 | /* A vtable. This has one subtree, the type for which this is a |
243 | vtable. */ |
257 | vtable. */ |
244 | DEMANGLE_COMPONENT_VTABLE, |
258 | DEMANGLE_COMPONENT_VTABLE, |
245 | /* A VTT structure. This has one subtree, the type for which this |
259 | /* A VTT structure. This has one subtree, the type for which this |
246 | is a VTT. */ |
260 | is a VTT. */ |
247 | DEMANGLE_COMPONENT_VTT, |
261 | DEMANGLE_COMPONENT_VTT, |
248 | /* A construction vtable. The left subtree is the type for which |
262 | /* A construction vtable. The left subtree is the type for which |
249 | this is a vtable, and the right subtree is the derived type for |
263 | this is a vtable, and the right subtree is the derived type for |
250 | which this vtable is built. */ |
264 | which this vtable is built. */ |
251 | DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, |
265 | DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, |
252 | /* A typeinfo structure. This has one subtree, the type for which |
266 | /* A typeinfo structure. This has one subtree, the type for which |
253 | this is the tpeinfo structure. */ |
267 | this is the tpeinfo structure. */ |
254 | DEMANGLE_COMPONENT_TYPEINFO, |
268 | DEMANGLE_COMPONENT_TYPEINFO, |
255 | /* A typeinfo name. This has one subtree, the type for which this |
269 | /* A typeinfo name. This has one subtree, the type for which this |
256 | is the typeinfo name. */ |
270 | is the typeinfo name. */ |
257 | DEMANGLE_COMPONENT_TYPEINFO_NAME, |
271 | DEMANGLE_COMPONENT_TYPEINFO_NAME, |
258 | /* A typeinfo function. This has one subtree, the type for which |
272 | /* A typeinfo function. This has one subtree, the type for which |
259 | this is the tpyeinfo function. */ |
273 | this is the tpyeinfo function. */ |
260 | DEMANGLE_COMPONENT_TYPEINFO_FN, |
274 | DEMANGLE_COMPONENT_TYPEINFO_FN, |
261 | /* A thunk. This has one subtree, the name for which this is a |
275 | /* A thunk. This has one subtree, the name for which this is a |
262 | thunk. */ |
276 | thunk. */ |
263 | DEMANGLE_COMPONENT_THUNK, |
277 | DEMANGLE_COMPONENT_THUNK, |
264 | /* A virtual thunk. This has one subtree, the name for which this |
278 | /* A virtual thunk. This has one subtree, the name for which this |
265 | is a virtual thunk. */ |
279 | is a virtual thunk. */ |
266 | DEMANGLE_COMPONENT_VIRTUAL_THUNK, |
280 | DEMANGLE_COMPONENT_VIRTUAL_THUNK, |
267 | /* A covariant thunk. This has one subtree, the name for which this |
281 | /* A covariant thunk. This has one subtree, the name for which this |
268 | is a covariant thunk. */ |
282 | is a covariant thunk. */ |
269 | DEMANGLE_COMPONENT_COVARIANT_THUNK, |
283 | DEMANGLE_COMPONENT_COVARIANT_THUNK, |
270 | /* A Java class. This has one subtree, the type. */ |
284 | /* A Java class. This has one subtree, the type. */ |
271 | DEMANGLE_COMPONENT_JAVA_CLASS, |
285 | DEMANGLE_COMPONENT_JAVA_CLASS, |
272 | /* A guard variable. This has one subtree, the name for which this |
286 | /* A guard variable. This has one subtree, the name for which this |
273 | is a guard variable. */ |
287 | is a guard variable. */ |
274 | DEMANGLE_COMPONENT_GUARD, |
288 | DEMANGLE_COMPONENT_GUARD, |
275 | /* The init and wrapper functions for C++11 thread_local variables. */ |
289 | /* The init and wrapper functions for C++11 thread_local variables. */ |
276 | DEMANGLE_COMPONENT_TLS_INIT, |
290 | DEMANGLE_COMPONENT_TLS_INIT, |
277 | DEMANGLE_COMPONENT_TLS_WRAPPER, |
291 | DEMANGLE_COMPONENT_TLS_WRAPPER, |
278 | /* A reference temporary. This has one subtree, the name for which |
292 | /* A reference temporary. This has one subtree, the name for which |
279 | this is a temporary. */ |
293 | this is a temporary. */ |
280 | DEMANGLE_COMPONENT_REFTEMP, |
294 | DEMANGLE_COMPONENT_REFTEMP, |
281 | /* A hidden alias. This has one subtree, the encoding for which it |
295 | /* A hidden alias. This has one subtree, the encoding for which it |
282 | is providing alternative linkage. */ |
296 | is providing alternative linkage. */ |
283 | DEMANGLE_COMPONENT_HIDDEN_ALIAS, |
297 | DEMANGLE_COMPONENT_HIDDEN_ALIAS, |
284 | /* A standard substitution. This holds the name of the |
298 | /* A standard substitution. This holds the name of the |
285 | substitution. */ |
299 | substitution. */ |
286 | DEMANGLE_COMPONENT_SUB_STD, |
300 | DEMANGLE_COMPONENT_SUB_STD, |
287 | /* The restrict qualifier. The one subtree is the type which is |
301 | /* The restrict qualifier. The one subtree is the type which is |
288 | being qualified. */ |
302 | being qualified. */ |
289 | DEMANGLE_COMPONENT_RESTRICT, |
303 | DEMANGLE_COMPONENT_RESTRICT, |
290 | /* The volatile qualifier. The one subtree is the type which is |
304 | /* The volatile qualifier. The one subtree is the type which is |
291 | being qualified. */ |
305 | being qualified. */ |
292 | DEMANGLE_COMPONENT_VOLATILE, |
306 | DEMANGLE_COMPONENT_VOLATILE, |
293 | /* The const qualifier. The one subtree is the type which is being |
307 | /* The const qualifier. The one subtree is the type which is being |
294 | qualified. */ |
308 | qualified. */ |
295 | DEMANGLE_COMPONENT_CONST, |
309 | DEMANGLE_COMPONENT_CONST, |
296 | /* The restrict qualifier modifying a member function. The one |
310 | /* The restrict qualifier modifying a member function. The one |
297 | subtree is the type which is being qualified. */ |
311 | subtree is the type which is being qualified. */ |
298 | DEMANGLE_COMPONENT_RESTRICT_THIS, |
312 | DEMANGLE_COMPONENT_RESTRICT_THIS, |
299 | /* The volatile qualifier modifying a member function. The one |
313 | /* The volatile qualifier modifying a member function. The one |
300 | subtree is the type which is being qualified. */ |
314 | subtree is the type which is being qualified. */ |
301 | DEMANGLE_COMPONENT_VOLATILE_THIS, |
315 | DEMANGLE_COMPONENT_VOLATILE_THIS, |
302 | /* The const qualifier modifying a member function. The one subtree |
316 | /* The const qualifier modifying a member function. The one subtree |
303 | is the type which is being qualified. */ |
317 | is the type which is being qualified. */ |
304 | DEMANGLE_COMPONENT_CONST_THIS, |
318 | DEMANGLE_COMPONENT_CONST_THIS, |
305 | /* C++11 A reference modifying a member function. The one subtree is the |
319 | /* C++11 A reference modifying a member function. The one subtree is the |
306 | type which is being referenced. */ |
320 | type which is being referenced. */ |
307 | DEMANGLE_COMPONENT_REFERENCE_THIS, |
321 | DEMANGLE_COMPONENT_REFERENCE_THIS, |
308 | /* C++11: An rvalue reference modifying a member function. The one |
322 | /* C++11: An rvalue reference modifying a member function. The one |
309 | subtree is the type which is being referenced. */ |
323 | subtree is the type which is being referenced. */ |
310 | DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS, |
324 | DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS, |
311 | /* A vendor qualifier. The left subtree is the type which is being |
325 | /* A vendor qualifier. The left subtree is the type which is being |
312 | qualified, and the right subtree is the name of the |
326 | qualified, and the right subtree is the name of the |
313 | qualifier. */ |
327 | qualifier. */ |
314 | DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, |
328 | DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, |
315 | /* A pointer. The one subtree is the type which is being pointed |
329 | /* A pointer. The one subtree is the type which is being pointed |
316 | to. */ |
330 | to. */ |
317 | DEMANGLE_COMPONENT_POINTER, |
331 | DEMANGLE_COMPONENT_POINTER, |
318 | /* A reference. The one subtree is the type which is being |
332 | /* A reference. The one subtree is the type which is being |
319 | referenced. */ |
333 | referenced. */ |
320 | DEMANGLE_COMPONENT_REFERENCE, |
334 | DEMANGLE_COMPONENT_REFERENCE, |
321 | /* C++0x: An rvalue reference. The one subtree is the type which is |
335 | /* C++0x: An rvalue reference. The one subtree is the type which is |
322 | being referenced. */ |
336 | being referenced. */ |
323 | DEMANGLE_COMPONENT_RVALUE_REFERENCE, |
337 | DEMANGLE_COMPONENT_RVALUE_REFERENCE, |
324 | /* A complex type. The one subtree is the base type. */ |
338 | /* A complex type. The one subtree is the base type. */ |
325 | DEMANGLE_COMPONENT_COMPLEX, |
339 | DEMANGLE_COMPONENT_COMPLEX, |
326 | /* An imaginary type. The one subtree is the base type. */ |
340 | /* An imaginary type. The one subtree is the base type. */ |
327 | DEMANGLE_COMPONENT_IMAGINARY, |
341 | DEMANGLE_COMPONENT_IMAGINARY, |
328 | /* A builtin type. This holds the builtin type information. */ |
342 | /* A builtin type. This holds the builtin type information. */ |
329 | DEMANGLE_COMPONENT_BUILTIN_TYPE, |
343 | DEMANGLE_COMPONENT_BUILTIN_TYPE, |
330 | /* A vendor's builtin type. This holds the name of the type. */ |
344 | /* A vendor's builtin type. This holds the name of the type. */ |
331 | DEMANGLE_COMPONENT_VENDOR_TYPE, |
345 | DEMANGLE_COMPONENT_VENDOR_TYPE, |
332 | /* A function type. The left subtree is the return type. The right |
346 | /* A function type. The left subtree is the return type. The right |
333 | subtree is a list of ARGLIST nodes. Either or both may be |
347 | subtree is a list of ARGLIST nodes. Either or both may be |
334 | NULL. */ |
348 | NULL. */ |
335 | DEMANGLE_COMPONENT_FUNCTION_TYPE, |
349 | DEMANGLE_COMPONENT_FUNCTION_TYPE, |
336 | /* An array type. The left subtree is the dimension, which may be |
350 | /* An array type. The left subtree is the dimension, which may be |
337 | NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an |
351 | NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an |
338 | expression. The right subtree is the element type. */ |
352 | expression. The right subtree is the element type. */ |
339 | DEMANGLE_COMPONENT_ARRAY_TYPE, |
353 | DEMANGLE_COMPONENT_ARRAY_TYPE, |
340 | /* A pointer to member type. The left subtree is the class type, |
354 | /* A pointer to member type. The left subtree is the class type, |
341 | and the right subtree is the member type. CV-qualifiers appear |
355 | and the right subtree is the member type. CV-qualifiers appear |
342 | on the latter. */ |
356 | on the latter. */ |
343 | DEMANGLE_COMPONENT_PTRMEM_TYPE, |
357 | DEMANGLE_COMPONENT_PTRMEM_TYPE, |
344 | /* A fixed-point type. */ |
358 | /* A fixed-point type. */ |
345 | DEMANGLE_COMPONENT_FIXED_TYPE, |
359 | DEMANGLE_COMPONENT_FIXED_TYPE, |
346 | /* A vector type. The left subtree is the number of elements, |
360 | /* A vector type. The left subtree is the number of elements, |
347 | the right subtree is the element type. */ |
361 | the right subtree is the element type. */ |
348 | DEMANGLE_COMPONENT_VECTOR_TYPE, |
362 | DEMANGLE_COMPONENT_VECTOR_TYPE, |
349 | /* An argument list. The left subtree is the current argument, and |
363 | /* An argument list. The left subtree is the current argument, and |
350 | the right subtree is either NULL or another ARGLIST node. */ |
364 | the right subtree is either NULL or another ARGLIST node. */ |
351 | DEMANGLE_COMPONENT_ARGLIST, |
365 | DEMANGLE_COMPONENT_ARGLIST, |
352 | /* A template argument list. The left subtree is the current |
366 | /* A template argument list. The left subtree is the current |
353 | template argument, and the right subtree is either NULL or |
367 | template argument, and the right subtree is either NULL or |
354 | another TEMPLATE_ARGLIST node. */ |
368 | another TEMPLATE_ARGLIST node. */ |
355 | DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, |
369 | DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, |
356 | /* An initializer list. The left subtree is either an explicit type or |
370 | /* An initializer list. The left subtree is either an explicit type or |
357 | NULL, and the right subtree is a DEMANGLE_COMPONENT_ARGLIST. */ |
371 | NULL, and the right subtree is a DEMANGLE_COMPONENT_ARGLIST. */ |
358 | DEMANGLE_COMPONENT_INITIALIZER_LIST, |
372 | DEMANGLE_COMPONENT_INITIALIZER_LIST, |
359 | /* An operator. This holds information about a standard |
373 | /* An operator. This holds information about a standard |
360 | operator. */ |
374 | operator. */ |
361 | DEMANGLE_COMPONENT_OPERATOR, |
375 | DEMANGLE_COMPONENT_OPERATOR, |
362 | /* An extended operator. This holds the number of arguments, and |
376 | /* An extended operator. This holds the number of arguments, and |
363 | the name of the extended operator. */ |
377 | the name of the extended operator. */ |
364 | DEMANGLE_COMPONENT_EXTENDED_OPERATOR, |
378 | DEMANGLE_COMPONENT_EXTENDED_OPERATOR, |
365 | /* A typecast, represented as a unary operator. The one subtree is |
379 | /* A typecast, represented as a unary operator. The one subtree is |
366 | the type to which the argument should be cast. */ |
380 | the type to which the argument should be cast. */ |
367 | DEMANGLE_COMPONENT_CAST, |
381 | DEMANGLE_COMPONENT_CAST, |
368 | /* A nullary expression. The left subtree is the operator. */ |
382 | /* A nullary expression. The left subtree is the operator. */ |
369 | DEMANGLE_COMPONENT_NULLARY, |
383 | DEMANGLE_COMPONENT_NULLARY, |
370 | /* A unary expression. The left subtree is the operator, and the |
384 | /* A unary expression. The left subtree is the operator, and the |
371 | right subtree is the single argument. */ |
385 | right subtree is the single argument. */ |
372 | DEMANGLE_COMPONENT_UNARY, |
386 | DEMANGLE_COMPONENT_UNARY, |
373 | /* A binary expression. The left subtree is the operator, and the |
387 | /* A binary expression. The left subtree is the operator, and the |
374 | right subtree is a BINARY_ARGS. */ |
388 | right subtree is a BINARY_ARGS. */ |
375 | DEMANGLE_COMPONENT_BINARY, |
389 | DEMANGLE_COMPONENT_BINARY, |
376 | /* Arguments to a binary expression. The left subtree is the first |
390 | /* Arguments to a binary expression. The left subtree is the first |
377 | argument, and the right subtree is the second argument. */ |
391 | argument, and the right subtree is the second argument. */ |
378 | DEMANGLE_COMPONENT_BINARY_ARGS, |
392 | DEMANGLE_COMPONENT_BINARY_ARGS, |
379 | /* A trinary expression. The left subtree is the operator, and the |
393 | /* A trinary expression. The left subtree is the operator, and the |
380 | right subtree is a TRINARY_ARG1. */ |
394 | right subtree is a TRINARY_ARG1. */ |
381 | DEMANGLE_COMPONENT_TRINARY, |
395 | DEMANGLE_COMPONENT_TRINARY, |
382 | /* Arguments to a trinary expression. The left subtree is the first |
396 | /* Arguments to a trinary expression. The left subtree is the first |
383 | argument, and the right subtree is a TRINARY_ARG2. */ |
397 | argument, and the right subtree is a TRINARY_ARG2. */ |
384 | DEMANGLE_COMPONENT_TRINARY_ARG1, |
398 | DEMANGLE_COMPONENT_TRINARY_ARG1, |
385 | /* More arguments to a trinary expression. The left subtree is the |
399 | /* More arguments to a trinary expression. The left subtree is the |
386 | second argument, and the right subtree is the third argument. */ |
400 | second argument, and the right subtree is the third argument. */ |
387 | DEMANGLE_COMPONENT_TRINARY_ARG2, |
401 | DEMANGLE_COMPONENT_TRINARY_ARG2, |
388 | /* A literal. The left subtree is the type, and the right subtree |
402 | /* A literal. The left subtree is the type, and the right subtree |
389 | is the value, represented as a DEMANGLE_COMPONENT_NAME. */ |
403 | is the value, represented as a DEMANGLE_COMPONENT_NAME. */ |
390 | DEMANGLE_COMPONENT_LITERAL, |
404 | DEMANGLE_COMPONENT_LITERAL, |
391 | /* A negative literal. Like LITERAL, but the value is negated. |
405 | /* A negative literal. Like LITERAL, but the value is negated. |
392 | This is a minor hack: the NAME used for LITERAL points directly |
406 | This is a minor hack: the NAME used for LITERAL points directly |
393 | to the mangled string, but since negative numbers are mangled |
407 | to the mangled string, but since negative numbers are mangled |
394 | using 'n' instead of '-', we want a way to indicate a negative |
408 | using 'n' instead of '-', we want a way to indicate a negative |
395 | number which involves neither modifying the mangled string nor |
409 | number which involves neither modifying the mangled string nor |
396 | allocating a new copy of the literal in memory. */ |
410 | allocating a new copy of the literal in memory. */ |
397 | DEMANGLE_COMPONENT_LITERAL_NEG, |
411 | DEMANGLE_COMPONENT_LITERAL_NEG, |
398 | /* A libgcj compiled resource. The left subtree is the name of the |
412 | /* A libgcj compiled resource. The left subtree is the name of the |
399 | resource. */ |
413 | resource. */ |
400 | DEMANGLE_COMPONENT_JAVA_RESOURCE, |
414 | DEMANGLE_COMPONENT_JAVA_RESOURCE, |
401 | /* A name formed by the concatenation of two parts. The left |
415 | /* A name formed by the concatenation of two parts. The left |
402 | subtree is the first part and the right subtree the second. */ |
416 | subtree is the first part and the right subtree the second. */ |
403 | DEMANGLE_COMPONENT_COMPOUND_NAME, |
417 | DEMANGLE_COMPONENT_COMPOUND_NAME, |
404 | /* A name formed by a single character. */ |
418 | /* A name formed by a single character. */ |
405 | DEMANGLE_COMPONENT_CHARACTER, |
419 | DEMANGLE_COMPONENT_CHARACTER, |
406 | /* A number. */ |
420 | /* A number. */ |
407 | DEMANGLE_COMPONENT_NUMBER, |
421 | DEMANGLE_COMPONENT_NUMBER, |
408 | /* A decltype type. */ |
422 | /* A decltype type. */ |
409 | DEMANGLE_COMPONENT_DECLTYPE, |
423 | DEMANGLE_COMPONENT_DECLTYPE, |
410 | /* Global constructors keyed to name. */ |
424 | /* Global constructors keyed to name. */ |
411 | DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, |
425 | DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, |
412 | /* Global destructors keyed to name. */ |
426 | /* Global destructors keyed to name. */ |
413 | DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, |
427 | DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, |
414 | /* A lambda closure type. */ |
428 | /* A lambda closure type. */ |
415 | DEMANGLE_COMPONENT_LAMBDA, |
429 | DEMANGLE_COMPONENT_LAMBDA, |
416 | /* A default argument scope. */ |
430 | /* A default argument scope. */ |
417 | DEMANGLE_COMPONENT_DEFAULT_ARG, |
431 | DEMANGLE_COMPONENT_DEFAULT_ARG, |
418 | /* An unnamed type. */ |
432 | /* An unnamed type. */ |
419 | DEMANGLE_COMPONENT_UNNAMED_TYPE, |
433 | DEMANGLE_COMPONENT_UNNAMED_TYPE, |
420 | /* A transactional clone. This has one subtree, the encoding for |
434 | /* A transactional clone. This has one subtree, the encoding for |
421 | which it is providing alternative linkage. */ |
435 | which it is providing alternative linkage. */ |
422 | DEMANGLE_COMPONENT_TRANSACTION_CLONE, |
436 | DEMANGLE_COMPONENT_TRANSACTION_CLONE, |
423 | /* A non-transactional clone entry point. In the i386/x86_64 abi, |
437 | /* A non-transactional clone entry point. In the i386/x86_64 abi, |
424 | the unmangled symbol of a tm_callable becomes a thunk and the |
438 | the unmangled symbol of a tm_callable becomes a thunk and the |
425 | non-transactional function version is mangled thus. */ |
439 | non-transactional function version is mangled thus. */ |
426 | DEMANGLE_COMPONENT_NONTRANSACTION_CLONE, |
440 | DEMANGLE_COMPONENT_NONTRANSACTION_CLONE, |
427 | /* A pack expansion. */ |
441 | /* A pack expansion. */ |
428 | DEMANGLE_COMPONENT_PACK_EXPANSION, |
442 | DEMANGLE_COMPONENT_PACK_EXPANSION, |
429 | /* A name with an ABI tag. */ |
443 | /* A name with an ABI tag. */ |
430 | DEMANGLE_COMPONENT_TAGGED_NAME, |
444 | DEMANGLE_COMPONENT_TAGGED_NAME, |
431 | /* A cloned function. */ |
445 | /* A cloned function. */ |
432 | DEMANGLE_COMPONENT_CLONE |
446 | DEMANGLE_COMPONENT_CLONE |
433 | }; |
447 | }; |
434 | 448 | ||
435 | /* Types which are only used internally. */ |
449 | /* Types which are only used internally. */ |
436 | 450 | ||
437 | struct demangle_operator_info; |
451 | struct demangle_operator_info; |
438 | struct demangle_builtin_type_info; |
452 | struct demangle_builtin_type_info; |
439 | 453 | ||
440 | /* A node in the tree representation is an instance of a struct |
454 | /* A node in the tree representation is an instance of a struct |
441 | demangle_component. Note that the field names of the struct are |
455 | demangle_component. Note that the field names of the struct are |
442 | not well protected against macros defined by the file including |
456 | not well protected against macros defined by the file including |
443 | this one. We can fix this if it ever becomes a problem. */ |
457 | this one. We can fix this if it ever becomes a problem. */ |
444 | 458 | ||
445 | struct demangle_component |
459 | struct demangle_component |
446 | { |
460 | { |
447 | /* The type of this component. */ |
461 | /* The type of this component. */ |
448 | enum demangle_component_type type; |
462 | enum demangle_component_type type; |
449 | 463 | ||
450 | union |
464 | union |
451 | { |
465 | { |
452 | /* For DEMANGLE_COMPONENT_NAME. */ |
466 | /* For DEMANGLE_COMPONENT_NAME. */ |
453 | struct |
467 | struct |
454 | { |
468 | { |
455 | /* A pointer to the name (which need not NULL terminated) and |
469 | /* A pointer to the name (which need not NULL terminated) and |
456 | its length. */ |
470 | its length. */ |
457 | const char *s; |
471 | const char *s; |
458 | int len; |
472 | int len; |
459 | } s_name; |
473 | } s_name; |
460 | 474 | ||
461 | /* For DEMANGLE_COMPONENT_OPERATOR. */ |
475 | /* For DEMANGLE_COMPONENT_OPERATOR. */ |
462 | struct |
476 | struct |
463 | { |
477 | { |
464 | /* Operator. */ |
478 | /* Operator. */ |
465 | const struct demangle_operator_info *op; |
479 | const struct demangle_operator_info *op; |
466 | } s_operator; |
480 | } s_operator; |
467 | 481 | ||
468 | /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */ |
482 | /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */ |
469 | struct |
483 | struct |
470 | { |
484 | { |
471 | /* Number of arguments. */ |
485 | /* Number of arguments. */ |
472 | int args; |
486 | int args; |
473 | /* Name. */ |
487 | /* Name. */ |
474 | struct demangle_component *name; |
488 | struct demangle_component *name; |
475 | } s_extended_operator; |
489 | } s_extended_operator; |
476 | 490 | ||
477 | /* For DEMANGLE_COMPONENT_FIXED_TYPE. */ |
491 | /* For DEMANGLE_COMPONENT_FIXED_TYPE. */ |
478 | struct |
492 | struct |
479 | { |
493 | { |
480 | /* The length, indicated by a C integer type name. */ |
494 | /* The length, indicated by a C integer type name. */ |
481 | struct demangle_component *length; |
495 | struct demangle_component *length; |
482 | /* _Accum or _Fract? */ |
496 | /* _Accum or _Fract? */ |
483 | short accum; |
497 | short accum; |
484 | /* Saturating or not? */ |
498 | /* Saturating or not? */ |
485 | short sat; |
499 | short sat; |
486 | } s_fixed; |
500 | } s_fixed; |
487 | 501 | ||
488 | /* For DEMANGLE_COMPONENT_CTOR. */ |
502 | /* For DEMANGLE_COMPONENT_CTOR. */ |
489 | struct |
503 | struct |
490 | { |
504 | { |
491 | /* Kind of constructor. */ |
505 | /* Kind of constructor. */ |
492 | enum gnu_v3_ctor_kinds kind; |
506 | enum gnu_v3_ctor_kinds kind; |
493 | /* Name. */ |
507 | /* Name. */ |
494 | struct demangle_component *name; |
508 | struct demangle_component *name; |
495 | } s_ctor; |
509 | } s_ctor; |
496 | 510 | ||
497 | /* For DEMANGLE_COMPONENT_DTOR. */ |
511 | /* For DEMANGLE_COMPONENT_DTOR. */ |
498 | struct |
512 | struct |
499 | { |
513 | { |
500 | /* Kind of destructor. */ |
514 | /* Kind of destructor. */ |
501 | enum gnu_v3_dtor_kinds kind; |
515 | enum gnu_v3_dtor_kinds kind; |
502 | /* Name. */ |
516 | /* Name. */ |
503 | struct demangle_component *name; |
517 | struct demangle_component *name; |
504 | } s_dtor; |
518 | } s_dtor; |
505 | 519 | ||
506 | /* For DEMANGLE_COMPONENT_BUILTIN_TYPE. */ |
520 | /* For DEMANGLE_COMPONENT_BUILTIN_TYPE. */ |
507 | struct |
521 | struct |
508 | { |
522 | { |
509 | /* Builtin type. */ |
523 | /* Builtin type. */ |
510 | const struct demangle_builtin_type_info *type; |
524 | const struct demangle_builtin_type_info *type; |
511 | } s_builtin; |
525 | } s_builtin; |
512 | 526 | ||
513 | /* For DEMANGLE_COMPONENT_SUB_STD. */ |
527 | /* For DEMANGLE_COMPONENT_SUB_STD. */ |
514 | struct |
528 | struct |
515 | { |
529 | { |
516 | /* Standard substitution string. */ |
530 | /* Standard substitution string. */ |
517 | const char* string; |
531 | const char* string; |
518 | /* Length of string. */ |
532 | /* Length of string. */ |
519 | int len; |
533 | int len; |
520 | } s_string; |
534 | } s_string; |
521 | 535 | ||
522 | /* For DEMANGLE_COMPONENT_*_PARAM. */ |
536 | /* For DEMANGLE_COMPONENT_*_PARAM. */ |
523 | struct |
537 | struct |
524 | { |
538 | { |
525 | /* Parameter index. */ |
539 | /* Parameter index. */ |
526 | long number; |
540 | long number; |
527 | } s_number; |
541 | } s_number; |
528 | 542 | ||
529 | /* For DEMANGLE_COMPONENT_CHARACTER. */ |
543 | /* For DEMANGLE_COMPONENT_CHARACTER. */ |
530 | struct |
544 | struct |
531 | { |
545 | { |
532 | int character; |
546 | int character; |
533 | } s_character; |
547 | } s_character; |
534 | 548 | ||
535 | /* For other types. */ |
549 | /* For other types. */ |
536 | struct |
550 | struct |
537 | { |
551 | { |
538 | /* Left (or only) subtree. */ |
552 | /* Left (or only) subtree. */ |
539 | struct demangle_component *left; |
553 | struct demangle_component *left; |
540 | /* Right subtree. */ |
554 | /* Right subtree. */ |
541 | struct demangle_component *right; |
555 | struct demangle_component *right; |
542 | } s_binary; |
556 | } s_binary; |
543 | 557 | ||
544 | struct |
558 | struct |
545 | { |
559 | { |
546 | /* subtree, same place as d_left. */ |
560 | /* subtree, same place as d_left. */ |
547 | struct demangle_component *sub; |
561 | struct demangle_component *sub; |
548 | /* integer. */ |
562 | /* integer. */ |
549 | int num; |
563 | int num; |
550 | } s_unary_num; |
564 | } s_unary_num; |
551 | 565 | ||
552 | } u; |
566 | } u; |
553 | }; |
567 | }; |
554 | 568 | ||
555 | /* People building mangled trees are expected to allocate instances of |
569 | /* People building mangled trees are expected to allocate instances of |
556 | struct demangle_component themselves. They can then call one of |
570 | struct demangle_component themselves. They can then call one of |
557 | the following functions to fill them in. */ |
571 | the following functions to fill them in. */ |
558 | 572 | ||
559 | /* Fill in most component types with a left subtree and a right |
573 | /* Fill in most component types with a left subtree and a right |
560 | subtree. Returns non-zero on success, zero on failure, such as an |
574 | subtree. Returns non-zero on success, zero on failure, such as an |
561 | unrecognized or inappropriate component type. */ |
575 | unrecognized or inappropriate component type. */ |
562 | 576 | ||
563 | extern int |
577 | extern int |
564 | cplus_demangle_fill_component (struct demangle_component *fill, |
578 | cplus_demangle_fill_component (struct demangle_component *fill, |
565 | enum demangle_component_type, |
579 | enum demangle_component_type, |
566 | struct demangle_component *left, |
580 | struct demangle_component *left, |
567 | struct demangle_component *right); |
581 | struct demangle_component *right); |
568 | 582 | ||
569 | /* Fill in a DEMANGLE_COMPONENT_NAME. Returns non-zero on success, |
583 | /* Fill in a DEMANGLE_COMPONENT_NAME. Returns non-zero on success, |
570 | zero for bad arguments. */ |
584 | zero for bad arguments. */ |
571 | 585 | ||
572 | extern int |
586 | extern int |
573 | cplus_demangle_fill_name (struct demangle_component *fill, |
587 | cplus_demangle_fill_name (struct demangle_component *fill, |
574 | const char *, int); |
588 | const char *, int); |
575 | 589 | ||
576 | /* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the |
590 | /* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the |
577 | builtin type (e.g., "int", etc.). Returns non-zero on success, |
591 | builtin type (e.g., "int", etc.). Returns non-zero on success, |
578 | zero if the type is not recognized. */ |
592 | zero if the type is not recognized. */ |
579 | 593 | ||
580 | extern int |
594 | extern int |
581 | cplus_demangle_fill_builtin_type (struct demangle_component *fill, |
595 | cplus_demangle_fill_builtin_type (struct demangle_component *fill, |
582 | const char *type_name); |
596 | const char *type_name); |
583 | 597 | ||
584 | /* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the |
598 | /* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the |
585 | operator and the number of arguments which it takes (the latter is |
599 | operator and the number of arguments which it takes (the latter is |
586 | used to disambiguate operators which can be both binary and unary, |
600 | used to disambiguate operators which can be both binary and unary, |
587 | such as '-'). Returns non-zero on success, zero if the operator is |
601 | such as '-'). Returns non-zero on success, zero if the operator is |
588 | not recognized. */ |
602 | not recognized. */ |
589 | 603 | ||
590 | extern int |
604 | extern int |
591 | cplus_demangle_fill_operator (struct demangle_component *fill, |
605 | cplus_demangle_fill_operator (struct demangle_component *fill, |
592 | const char *opname, int args); |
606 | const char *opname, int args); |
593 | 607 | ||
594 | /* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the |
608 | /* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the |
595 | number of arguments and the name. Returns non-zero on success, |
609 | number of arguments and the name. Returns non-zero on success, |
596 | zero for bad arguments. */ |
610 | zero for bad arguments. */ |
597 | 611 | ||
598 | extern int |
612 | extern int |
599 | cplus_demangle_fill_extended_operator (struct demangle_component *fill, |
613 | cplus_demangle_fill_extended_operator (struct demangle_component *fill, |
600 | int numargs, |
614 | int numargs, |
601 | struct demangle_component *nm); |
615 | struct demangle_component *nm); |
602 | 616 | ||
603 | /* Fill in a DEMANGLE_COMPONENT_CTOR. Returns non-zero on success, |
617 | /* Fill in a DEMANGLE_COMPONENT_CTOR. Returns non-zero on success, |
604 | zero for bad arguments. */ |
618 | zero for bad arguments. */ |
605 | 619 | ||
606 | extern int |
620 | extern int |
607 | cplus_demangle_fill_ctor (struct demangle_component *fill, |
621 | cplus_demangle_fill_ctor (struct demangle_component *fill, |
608 | enum gnu_v3_ctor_kinds kind, |
622 | enum gnu_v3_ctor_kinds kind, |
609 | struct demangle_component *name); |
623 | struct demangle_component *name); |
610 | 624 | ||
611 | /* Fill in a DEMANGLE_COMPONENT_DTOR. Returns non-zero on success, |
625 | /* Fill in a DEMANGLE_COMPONENT_DTOR. Returns non-zero on success, |
612 | zero for bad arguments. */ |
626 | zero for bad arguments. */ |
613 | 627 | ||
614 | extern int |
628 | extern int |
615 | cplus_demangle_fill_dtor (struct demangle_component *fill, |
629 | cplus_demangle_fill_dtor (struct demangle_component *fill, |
616 | enum gnu_v3_dtor_kinds kind, |
630 | enum gnu_v3_dtor_kinds kind, |
617 | struct demangle_component *name); |
631 | struct demangle_component *name); |
618 | 632 | ||
619 | /* This function translates a mangled name into a struct |
633 | /* This function translates a mangled name into a struct |
620 | demangle_component tree. The first argument is the mangled name. |
634 | demangle_component tree. The first argument is the mangled name. |
621 | The second argument is DMGL_* options. This returns a pointer to a |
635 | The second argument is DMGL_* options. This returns a pointer to a |
622 | tree on success, or NULL on failure. On success, the third |
636 | tree on success, or NULL on failure. On success, the third |
623 | argument is set to a block of memory allocated by malloc. This |
637 | argument is set to a block of memory allocated by malloc. This |
624 | block should be passed to free when the tree is no longer |
638 | block should be passed to free when the tree is no longer |
625 | needed. */ |
639 | needed. */ |
626 | 640 | ||
627 | extern struct demangle_component * |
641 | extern struct demangle_component * |
628 | cplus_demangle_v3_components (const char *mangled, int options, void **mem); |
642 | cplus_demangle_v3_components (const char *mangled, int options, void **mem); |
629 | 643 | ||
630 | /* This function takes a struct demangle_component tree and returns |
644 | /* This function takes a struct demangle_component tree and returns |
631 | the corresponding demangled string. The first argument is DMGL_* |
645 | the corresponding demangled string. The first argument is DMGL_* |
632 | options. The second is the tree to demangle. The third is a guess |
646 | options. The second is the tree to demangle. The third is a guess |
633 | at the length of the demangled string, used to initially allocate |
647 | at the length of the demangled string, used to initially allocate |
634 | the return buffer. The fourth is a pointer to a size_t. On |
648 | the return buffer. The fourth is a pointer to a size_t. On |
635 | success, this function returns a buffer allocated by malloc(), and |
649 | success, this function returns a buffer allocated by malloc(), and |
636 | sets the size_t pointed to by the fourth argument to the size of |
650 | sets the size_t pointed to by the fourth argument to the size of |
637 | the allocated buffer (not the length of the returned string). On |
651 | the allocated buffer (not the length of the returned string). On |
638 | failure, this function returns NULL, and sets the size_t pointed to |
652 | failure, this function returns NULL, and sets the size_t pointed to |
639 | by the fourth argument to 0 for an invalid tree, or to 1 for a |
653 | by the fourth argument to 0 for an invalid tree, or to 1 for a |
640 | memory allocation error. */ |
654 | memory allocation error. */ |
641 | 655 | ||
642 | extern char * |
656 | extern char * |
643 | cplus_demangle_print (int options, |
657 | cplus_demangle_print (int options, |
644 | const struct demangle_component *tree, |
658 | const struct demangle_component *tree, |
645 | int estimated_length, |
659 | int estimated_length, |
646 | size_t *p_allocated_size); |
660 | size_t *p_allocated_size); |
647 | 661 | ||
648 | /* This function takes a struct demangle_component tree and passes back |
662 | /* This function takes a struct demangle_component tree and passes back |
649 | a demangled string in one or more calls to a callback function. |
663 | a demangled string in one or more calls to a callback function. |
650 | The first argument is DMGL_* options. The second is the tree to |
664 | The first argument is DMGL_* options. The second is the tree to |
651 | demangle. The third is a pointer to a callback function; on each call |
665 | demangle. The third is a pointer to a callback function; on each call |
652 | this receives an element of the demangled string, its length, and an |
666 | this receives an element of the demangled string, its length, and an |
653 | opaque value. The fourth is the opaque value passed to the callback. |
667 | opaque value. The fourth is the opaque value passed to the callback. |
654 | The callback is called once or more to return the full demangled |
668 | The callback is called once or more to return the full demangled |
655 | string. The demangled element string is always nul-terminated, though |
669 | string. The demangled element string is always nul-terminated, though |
656 | its length is also provided for convenience. In contrast to |
670 | its length is also provided for convenience. In contrast to |
657 | cplus_demangle_print(), this function does not allocate heap memory |
671 | cplus_demangle_print(), this function does not allocate heap memory |
658 | to grow output strings (except perhaps where alloca() is implemented |
672 | to grow output strings (except perhaps where alloca() is implemented |
659 | by malloc()), and so is normally safe for use where the heap has been |
673 | by malloc()), and so is normally safe for use where the heap has been |
660 | corrupted. On success, this function returns 1; on failure, 0. */ |
674 | corrupted. On success, this function returns 1; on failure, 0. */ |
661 | 675 | ||
662 | extern int |
676 | extern int |
663 | cplus_demangle_print_callback (int options, |
677 | cplus_demangle_print_callback (int options, |
664 | const struct demangle_component *tree, |
678 | const struct demangle_component *tree, |
665 | demangle_callbackref callback, void *opaque); |
679 | demangle_callbackref callback, void *opaque); |
666 | 680 | ||
667 | #ifdef __cplusplus |
681 | #ifdef __cplusplus |
668 | } |
682 | } |
669 | #endif /* __cplusplus */ |
683 | #endif /* __cplusplus */ |
670 | 684 | ||
671 | #endif /* DEMANGLE_H */><>><>><>><>><>><>><>><>><>><>><>><>><>><>><> |
685 | #endif /* DEMANGLE_H */><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><> |