OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [include/] [demangle.h] - Blame information for rev 853

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.