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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [include/] [demangle.h] - Blame information for rev 308

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

Line No. Rev Author Line
1 205 julius
/* 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
enum gnu_v3_ctor_kinds {
164
  gnu_v3_complete_object_ctor = 1,
165
  gnu_v3_base_object_ctor,
166
  gnu_v3_complete_object_allocating_ctor
167
};
168
 
169
/* Return non-zero iff NAME is the mangled form of a constructor name
170
   in the G++ V3 ABI demangling style.  Specifically, return an `enum
171
   gnu_v3_ctor_kinds' value indicating what kind of constructor
172
   it is.  */
173
extern enum gnu_v3_ctor_kinds
174
        is_gnu_v3_mangled_ctor (const char *name);
175
 
176
 
177
enum gnu_v3_dtor_kinds {
178
  gnu_v3_deleting_dtor = 1,
179
  gnu_v3_complete_object_dtor,
180
  gnu_v3_base_object_dtor
181
};
182
 
183
/* Return non-zero iff NAME is the mangled form of a destructor name
184
   in the G++ V3 ABI demangling style.  Specifically, return an `enum
185
   gnu_v3_dtor_kinds' value, indicating what kind of destructor
186
   it is.  */
187
extern enum gnu_v3_dtor_kinds
188
        is_gnu_v3_mangled_dtor (const char *name);
189
 
190
/* The V3 demangler works in two passes.  The first pass builds a tree
191
   representation of the mangled name, and the second pass turns the
192
   tree representation into a demangled string.  Here we define an
193
   interface to permit a caller to build their own tree
194
   representation, which they can pass to the demangler to get a
195
   demangled string.  This can be used to canonicalize user input into
196
   something which the demangler might output.  It could also be used
197
   by other demanglers in the future.  */
198
 
199
/* These are the component types which may be found in the tree.  Many
200
   component types have one or two subtrees, referred to as left and
201
   right (a component type with only one subtree puts it in the left
202
   subtree).  */
203
 
204
enum demangle_component_type
205
{
206
  /* A name, with a length and a pointer to a string.  */
207
  DEMANGLE_COMPONENT_NAME,
208
  /* A qualified name.  The left subtree is a class or namespace or
209
     some such thing, and the right subtree is a name qualified by
210
     that class.  */
211
  DEMANGLE_COMPONENT_QUAL_NAME,
212
  /* A local name.  The left subtree describes a function, and the
213
     right subtree is a name which is local to that function.  */
214
  DEMANGLE_COMPONENT_LOCAL_NAME,
215
  /* A typed name.  The left subtree is a name, and the right subtree
216
     describes that name as a function.  */
217
  DEMANGLE_COMPONENT_TYPED_NAME,
218
  /* A template.  The left subtree is a template name, and the right
219
     subtree is a template argument list.  */
220
  DEMANGLE_COMPONENT_TEMPLATE,
221
  /* A template parameter.  This holds a number, which is the template
222
     parameter index.  */
223
  DEMANGLE_COMPONENT_TEMPLATE_PARAM,
224
  /* A function parameter.  This holds a number, which is the index.  */
225
  DEMANGLE_COMPONENT_FUNCTION_PARAM,
226
  /* A constructor.  This holds a name and the kind of
227
     constructor.  */
228
  DEMANGLE_COMPONENT_CTOR,
229
  /* A destructor.  This holds a name and the kind of destructor.  */
230
  DEMANGLE_COMPONENT_DTOR,
231
  /* A vtable.  This has one subtree, the type for which this is a
232
     vtable.  */
233
  DEMANGLE_COMPONENT_VTABLE,
234
  /* A VTT structure.  This has one subtree, the type for which this
235
     is a VTT.  */
236
  DEMANGLE_COMPONENT_VTT,
237
  /* A construction vtable.  The left subtree is the type for which
238
     this is a vtable, and the right subtree is the derived type for
239
     which this vtable is built.  */
240
  DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE,
241
  /* A typeinfo structure.  This has one subtree, the type for which
242
     this is the tpeinfo structure.  */
243
  DEMANGLE_COMPONENT_TYPEINFO,
244
  /* A typeinfo name.  This has one subtree, the type for which this
245
     is the typeinfo name.  */
246
  DEMANGLE_COMPONENT_TYPEINFO_NAME,
247
  /* A typeinfo function.  This has one subtree, the type for which
248
     this is the tpyeinfo function.  */
249
  DEMANGLE_COMPONENT_TYPEINFO_FN,
250
  /* A thunk.  This has one subtree, the name for which this is a
251
     thunk.  */
252
  DEMANGLE_COMPONENT_THUNK,
253
  /* A virtual thunk.  This has one subtree, the name for which this
254
     is a virtual thunk.  */
255
  DEMANGLE_COMPONENT_VIRTUAL_THUNK,
256
  /* A covariant thunk.  This has one subtree, the name for which this
257
     is a covariant thunk.  */
258
  DEMANGLE_COMPONENT_COVARIANT_THUNK,
259
  /* A Java class.  This has one subtree, the type.  */
260
  DEMANGLE_COMPONENT_JAVA_CLASS,
261
  /* A guard variable.  This has one subtree, the name for which this
262
     is a guard variable.  */
263
  DEMANGLE_COMPONENT_GUARD,
264
  /* A reference temporary.  This has one subtree, the name for which
265
     this is a temporary.  */
266
  DEMANGLE_COMPONENT_REFTEMP,
267
  /* A hidden alias.  This has one subtree, the encoding for which it
268
     is providing alternative linkage.  */
269
  DEMANGLE_COMPONENT_HIDDEN_ALIAS,
270
  /* A standard substitution.  This holds the name of the
271
     substitution.  */
272
  DEMANGLE_COMPONENT_SUB_STD,
273
  /* The restrict qualifier.  The one subtree is the type which is
274
     being qualified.  */
275
  DEMANGLE_COMPONENT_RESTRICT,
276
  /* The volatile qualifier.  The one subtree is the type which is
277
     being qualified.  */
278
  DEMANGLE_COMPONENT_VOLATILE,
279
  /* The const qualifier.  The one subtree is the type which is being
280
     qualified.  */
281
  DEMANGLE_COMPONENT_CONST,
282
  /* The restrict qualifier modifying a member function.  The one
283
     subtree is the type which is being qualified.  */
284
  DEMANGLE_COMPONENT_RESTRICT_THIS,
285
  /* The volatile qualifier modifying a member function.  The one
286
     subtree is the type which is being qualified.  */
287
  DEMANGLE_COMPONENT_VOLATILE_THIS,
288
  /* The const qualifier modifying a member function.  The one subtree
289
     is the type which is being qualified.  */
290
  DEMANGLE_COMPONENT_CONST_THIS,
291
  /* A vendor qualifier.  The left subtree is the type which is being
292
     qualified, and the right subtree is the name of the
293
     qualifier.  */
294
  DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
295
  /* A pointer.  The one subtree is the type which is being pointed
296
     to.  */
297
  DEMANGLE_COMPONENT_POINTER,
298
  /* A reference.  The one subtree is the type which is being
299
     referenced.  */
300
  DEMANGLE_COMPONENT_REFERENCE,
301
  /* C++0x: An rvalue reference.  The one subtree is the type which is
302
     being referenced.  */
303
  DEMANGLE_COMPONENT_RVALUE_REFERENCE,
304
  /* A complex type.  The one subtree is the base type.  */
305
  DEMANGLE_COMPONENT_COMPLEX,
306
  /* An imaginary type.  The one subtree is the base type.  */
307
  DEMANGLE_COMPONENT_IMAGINARY,
308
  /* A builtin type.  This holds the builtin type information.  */
309
  DEMANGLE_COMPONENT_BUILTIN_TYPE,
310
  /* A vendor's builtin type.  This holds the name of the type.  */
311
  DEMANGLE_COMPONENT_VENDOR_TYPE,
312
  /* A function type.  The left subtree is the return type.  The right
313
     subtree is a list of ARGLIST nodes.  Either or both may be
314
     NULL.  */
315
  DEMANGLE_COMPONENT_FUNCTION_TYPE,
316
  /* An array type.  The left subtree is the dimension, which may be
317
     NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an
318
     expression.  The right subtree is the element type.  */
319
  DEMANGLE_COMPONENT_ARRAY_TYPE,
320
  /* A pointer to member type.  The left subtree is the class type,
321
     and the right subtree is the member type.  CV-qualifiers appear
322
     on the latter.  */
323
  DEMANGLE_COMPONENT_PTRMEM_TYPE,
324
  /* A fixed-point type.  */
325
  DEMANGLE_COMPONENT_FIXED_TYPE,
326
  /* An argument list.  The left subtree is the current argument, and
327
     the right subtree is either NULL or another ARGLIST node.  */
328
  DEMANGLE_COMPONENT_ARGLIST,
329
  /* A template argument list.  The left subtree is the current
330
     template argument, and the right subtree is either NULL or
331
     another TEMPLATE_ARGLIST node.  */
332
  DEMANGLE_COMPONENT_TEMPLATE_ARGLIST,
333
  /* An operator.  This holds information about a standard
334
     operator.  */
335
  DEMANGLE_COMPONENT_OPERATOR,
336
  /* An extended operator.  This holds the number of arguments, and
337
     the name of the extended operator.  */
338
  DEMANGLE_COMPONENT_EXTENDED_OPERATOR,
339
  /* A typecast, represented as a unary operator.  The one subtree is
340
     the type to which the argument should be cast.  */
341
  DEMANGLE_COMPONENT_CAST,
342
  /* A unary expression.  The left subtree is the operator, and the
343
     right subtree is the single argument.  */
344
  DEMANGLE_COMPONENT_UNARY,
345
  /* A binary expression.  The left subtree is the operator, and the
346
     right subtree is a BINARY_ARGS.  */
347
  DEMANGLE_COMPONENT_BINARY,
348
  /* Arguments to a binary expression.  The left subtree is the first
349
     argument, and the right subtree is the second argument.  */
350
  DEMANGLE_COMPONENT_BINARY_ARGS,
351
  /* A trinary expression.  The left subtree is the operator, and the
352
     right subtree is a TRINARY_ARG1.  */
353
  DEMANGLE_COMPONENT_TRINARY,
354
  /* Arguments to a trinary expression.  The left subtree is the first
355
     argument, and the right subtree is a TRINARY_ARG2.  */
356
  DEMANGLE_COMPONENT_TRINARY_ARG1,
357
  /* More arguments to a trinary expression.  The left subtree is the
358
     second argument, and the right subtree is the third argument.  */
359
  DEMANGLE_COMPONENT_TRINARY_ARG2,
360
  /* A literal.  The left subtree is the type, and the right subtree
361
     is the value, represented as a DEMANGLE_COMPONENT_NAME.  */
362
  DEMANGLE_COMPONENT_LITERAL,
363
  /* A negative literal.  Like LITERAL, but the value is negated.
364
     This is a minor hack: the NAME used for LITERAL points directly
365
     to the mangled string, but since negative numbers are mangled
366
     using 'n' instead of '-', we want a way to indicate a negative
367
     number which involves neither modifying the mangled string nor
368
     allocating a new copy of the literal in memory.  */
369
  DEMANGLE_COMPONENT_LITERAL_NEG,
370
  /* A libgcj compiled resource.  The left subtree is the name of the
371
     resource.  */
372
  DEMANGLE_COMPONENT_JAVA_RESOURCE,
373
  /* A name formed by the concatenation of two parts.  The left
374
     subtree is the first part and the right subtree the second.  */
375
  DEMANGLE_COMPONENT_COMPOUND_NAME,
376
  /* A name formed by a single character.  */
377
  DEMANGLE_COMPONENT_CHARACTER,
378
  /* A decltype type.  */
379
  DEMANGLE_COMPONENT_DECLTYPE,
380
  /* Global constructors keyed to name.  */
381
  DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS,
382
  /* Global destructors keyed to name.  */
383
  DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS,
384
  /* A pack expansion.  */
385
  DEMANGLE_COMPONENT_PACK_EXPANSION
386
};
387
 
388
/* Types which are only used internally.  */
389
 
390
struct demangle_operator_info;
391
struct demangle_builtin_type_info;
392
 
393
/* A node in the tree representation is an instance of a struct
394
   demangle_component.  Note that the field names of the struct are
395
   not well protected against macros defined by the file including
396
   this one.  We can fix this if it ever becomes a problem.  */
397
 
398
struct demangle_component
399
{
400
  /* The type of this component.  */
401
  enum demangle_component_type type;
402
 
403
  union
404
  {
405
    /* For DEMANGLE_COMPONENT_NAME.  */
406
    struct
407
    {
408
      /* A pointer to the name (which need not NULL terminated) and
409
         its length.  */
410
      const char *s;
411
      int len;
412
    } s_name;
413
 
414
    /* For DEMANGLE_COMPONENT_OPERATOR.  */
415
    struct
416
    {
417
      /* Operator.  */
418
      const struct demangle_operator_info *op;
419
    } s_operator;
420
 
421
    /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR.  */
422
    struct
423
    {
424
      /* Number of arguments.  */
425
      int args;
426
      /* Name.  */
427
      struct demangle_component *name;
428
    } s_extended_operator;
429
 
430
    /* For DEMANGLE_COMPONENT_FIXED_TYPE.  */
431
    struct
432
    {
433
      /* The length, indicated by a C integer type name.  */
434
      struct demangle_component *length;
435
      /* _Accum or _Fract?  */
436
      short accum;
437
      /* Saturating or not?  */
438
      short sat;
439
    } s_fixed;
440
 
441
    /* For DEMANGLE_COMPONENT_CTOR.  */
442
    struct
443
    {
444
      /* Kind of constructor.  */
445
      enum gnu_v3_ctor_kinds kind;
446
      /* Name.  */
447
      struct demangle_component *name;
448
    } s_ctor;
449
 
450
    /* For DEMANGLE_COMPONENT_DTOR.  */
451
    struct
452
    {
453
      /* Kind of destructor.  */
454
      enum gnu_v3_dtor_kinds kind;
455
      /* Name.  */
456
      struct demangle_component *name;
457
    } s_dtor;
458
 
459
    /* For DEMANGLE_COMPONENT_BUILTIN_TYPE.  */
460
    struct
461
    {
462
      /* Builtin type.  */
463
      const struct demangle_builtin_type_info *type;
464
    } s_builtin;
465
 
466
    /* For DEMANGLE_COMPONENT_SUB_STD.  */
467
    struct
468
    {
469
      /* Standard substitution string.  */
470
      const char* string;
471
      /* Length of string.  */
472
      int len;
473
    } s_string;
474
 
475
    /* For DEMANGLE_COMPONENT_*_PARAM.  */
476
    struct
477
    {
478
      /* Parameter index.  */
479
      long number;
480
    } s_number;
481
 
482
    /* For DEMANGLE_COMPONENT_CHARACTER.  */
483
    struct
484
    {
485
      int character;
486
    } s_character;
487
 
488
    /* For other types.  */
489
    struct
490
    {
491
      /* Left (or only) subtree.  */
492
      struct demangle_component *left;
493
      /* Right subtree.  */
494
      struct demangle_component *right;
495
    } s_binary;
496
 
497
  } u;
498
};
499
 
500
/* People building mangled trees are expected to allocate instances of
501
   struct demangle_component themselves.  They can then call one of
502
   the following functions to fill them in.  */
503
 
504
/* Fill in most component types with a left subtree and a right
505
   subtree.  Returns non-zero on success, zero on failure, such as an
506
   unrecognized or inappropriate component type.  */
507
 
508
extern int
509
cplus_demangle_fill_component (struct demangle_component *fill,
510
                               enum demangle_component_type,
511
                               struct demangle_component *left,
512
                               struct demangle_component *right);
513
 
514
/* Fill in a DEMANGLE_COMPONENT_NAME.  Returns non-zero on success,
515
   zero for bad arguments.  */
516
 
517
extern int
518
cplus_demangle_fill_name (struct demangle_component *fill,
519
                          const char *, int);
520
 
521
/* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the
522
   builtin type (e.g., "int", etc.).  Returns non-zero on success,
523
   zero if the type is not recognized.  */
524
 
525
extern int
526
cplus_demangle_fill_builtin_type (struct demangle_component *fill,
527
                                  const char *type_name);
528
 
529
/* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the
530
   operator and the number of arguments which it takes (the latter is
531
   used to disambiguate operators which can be both binary and unary,
532
   such as '-').  Returns non-zero on success, zero if the operator is
533
   not recognized.  */
534
 
535
extern int
536
cplus_demangle_fill_operator (struct demangle_component *fill,
537
                              const char *opname, int args);
538
 
539
/* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the
540
   number of arguments and the name.  Returns non-zero on success,
541
   zero for bad arguments.  */
542
 
543
extern int
544
cplus_demangle_fill_extended_operator (struct demangle_component *fill,
545
                                       int numargs,
546
                                       struct demangle_component *nm);
547
 
548
/* Fill in a DEMANGLE_COMPONENT_CTOR.  Returns non-zero on success,
549
   zero for bad arguments.  */
550
 
551
extern int
552
cplus_demangle_fill_ctor (struct demangle_component *fill,
553
                          enum gnu_v3_ctor_kinds kind,
554
                          struct demangle_component *name);
555
 
556
/* Fill in a DEMANGLE_COMPONENT_DTOR.  Returns non-zero on success,
557
   zero for bad arguments.  */
558
 
559
extern int
560
cplus_demangle_fill_dtor (struct demangle_component *fill,
561
                          enum gnu_v3_dtor_kinds kind,
562
                          struct demangle_component *name);
563
 
564
/* This function translates a mangled name into a struct
565
   demangle_component tree.  The first argument is the mangled name.
566
   The second argument is DMGL_* options.  This returns a pointer to a
567
   tree on success, or NULL on failure.  On success, the third
568
   argument is set to a block of memory allocated by malloc.  This
569
   block should be passed to free when the tree is no longer
570
   needed.  */
571
 
572
extern struct demangle_component *
573
cplus_demangle_v3_components (const char *mangled, int options, void **mem);
574
 
575
/* This function takes a struct demangle_component tree and returns
576
   the corresponding demangled string.  The first argument is DMGL_*
577
   options.  The second is the tree to demangle.  The third is a guess
578
   at the length of the demangled string, used to initially allocate
579
   the return buffer.  The fourth is a pointer to a size_t.  On
580
   success, this function returns a buffer allocated by malloc(), and
581
   sets the size_t pointed to by the fourth argument to the size of
582
   the allocated buffer (not the length of the returned string).  On
583
   failure, this function returns NULL, and sets the size_t pointed to
584
   by the fourth argument to 0 for an invalid tree, or to 1 for a
585
   memory allocation error.  */
586
 
587
extern char *
588
cplus_demangle_print (int options,
589
                      const struct demangle_component *tree,
590
                      int estimated_length,
591
                      size_t *p_allocated_size);
592
 
593
/* This function takes a struct demangle_component tree and passes back
594
   a demangled string in one or more calls to a callback function.
595
   The first argument is DMGL_* options.  The second is the tree to
596
   demangle.  The third is a pointer to a callback function; on each call
597
   this receives an element of the demangled string, its length, and an
598
   opaque value.  The fourth is the opaque value passed to the callback.
599
   The callback is called once or more to return the full demangled
600
   string.  The demangled element string is always nul-terminated, though
601
   its length is also provided for convenience.  In contrast to
602
   cplus_demangle_print(), this function does not allocate heap memory
603
   to grow output strings (except perhaps where alloca() is implemented
604
   by malloc()), and so is normally safe for use where the heap has been
605
   corrupted.  On success, this function returns 1; on failure, 0.  */
606
 
607
extern int
608
cplus_demangle_print_callback (int options,
609
                               const struct demangle_component *tree,
610
                               demangle_callbackref callback, void *opaque);
611
 
612
#ifdef __cplusplus
613
}
614
#endif /* __cplusplus */
615
 
616
#endif  /* DEMANGLE_H */

powered by: WebSVN 2.1.0

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