Line 1... |
Line 1... |
/* Demangler for g++ V3 ABI.
|
/* Demangler for g++ V3 ABI.
|
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
Written by Ian Lance Taylor <ian@wasabisystems.com>.
|
Written by Ian Lance Taylor <ian@wasabisystems.com>.
|
|
|
This file is part of the libiberty library, which is part of GCC.
|
This file is part of the libiberty library, which is part of GCC.
|
|
|
Line 276... |
Line 276... |
};
|
};
|
|
|
enum { D_PRINT_BUFFER_LENGTH = 256 };
|
enum { D_PRINT_BUFFER_LENGTH = 256 };
|
struct d_print_info
|
struct d_print_info
|
{
|
{
|
/* The options passed to the demangler. */
|
|
int options;
|
|
/* Fixed-length allocated buffer for demangled data, flushed to the
|
/* Fixed-length allocated buffer for demangled data, flushed to the
|
callback with a NUL termination once full. */
|
callback with a NUL termination once full. */
|
char buf[D_PRINT_BUFFER_LENGTH];
|
char buf[D_PRINT_BUFFER_LENGTH];
|
/* Current length of data in buffer. */
|
/* Current length of data in buffer. */
|
size_t len;
|
size_t len;
|
Line 434... |
Line 432... |
const char *, size_t);
|
const char *, size_t);
|
static void
|
static void
|
d_growable_string_callback_adapter (const char *, size_t, void *);
|
d_growable_string_callback_adapter (const char *, size_t, void *);
|
|
|
static void
|
static void
|
d_print_init (struct d_print_info *, int, demangle_callbackref, void *);
|
d_print_init (struct d_print_info *, demangle_callbackref, void *);
|
|
|
static inline void d_print_error (struct d_print_info *);
|
static inline void d_print_error (struct d_print_info *);
|
|
|
static inline int d_print_saw_error (struct d_print_info *);
|
static inline int d_print_saw_error (struct d_print_info *);
|
|
|
Line 452... |
Line 450... |
static inline void d_append_string (struct d_print_info *, const char *);
|
static inline void d_append_string (struct d_print_info *, const char *);
|
|
|
static inline char d_last_char (struct d_print_info *);
|
static inline char d_last_char (struct d_print_info *);
|
|
|
static void
|
static void
|
d_print_comp (struct d_print_info *, const struct demangle_component *);
|
d_print_comp (struct d_print_info *, int, const struct demangle_component *);
|
|
|
static void
|
static void
|
d_print_java_identifier (struct d_print_info *, const char *, int);
|
d_print_java_identifier (struct d_print_info *, const char *, int);
|
|
|
static void
|
static void
|
d_print_mod_list (struct d_print_info *, struct d_print_mod *, int);
|
d_print_mod_list (struct d_print_info *, int, struct d_print_mod *, int);
|
|
|
static void
|
static void
|
d_print_mod (struct d_print_info *, const struct demangle_component *);
|
d_print_mod (struct d_print_info *, int, const struct demangle_component *);
|
|
|
static void
|
static void
|
d_print_function_type (struct d_print_info *,
|
d_print_function_type (struct d_print_info *, int,
|
const struct demangle_component *,
|
const struct demangle_component *,
|
struct d_print_mod *);
|
struct d_print_mod *);
|
|
|
static void
|
static void
|
d_print_array_type (struct d_print_info *,
|
d_print_array_type (struct d_print_info *, int,
|
const struct demangle_component *,
|
const struct demangle_component *,
|
struct d_print_mod *);
|
struct d_print_mod *);
|
|
|
static void
|
static void
|
d_print_expr_op (struct d_print_info *, const struct demangle_component *);
|
d_print_expr_op (struct d_print_info *, int, const struct demangle_component *);
|
|
|
static void
|
static void
|
d_print_cast (struct d_print_info *, const struct demangle_component *);
|
d_print_cast (struct d_print_info *, int, const struct demangle_component *);
|
|
|
static int d_demangle_callback (const char *, int,
|
static int d_demangle_callback (const char *, int,
|
demangle_callbackref, void *);
|
demangle_callbackref, void *);
|
static char *d_demangle (const char *, int, size_t *);
|
static char *d_demangle (const char *, int, size_t *);
|
|
|
Line 1280... |
Line 1278... |
}
|
}
|
|
|
/* <prefix> ::= <prefix> <unqualified-name>
|
/* <prefix> ::= <prefix> <unqualified-name>
|
::= <template-prefix> <template-args>
|
::= <template-prefix> <template-args>
|
::= <template-param>
|
::= <template-param>
|
|
::= <decltype>
|
::=
|
::=
|
::= <substitution>
|
::= <substitution>
|
|
|
<template-prefix> ::= <prefix> <(template) unqualified-name>
|
<template-prefix> ::= <prefix> <(template) unqualified-name>
|
::= <template-param>
|
::= <template-param>
|
Line 1308... |
Line 1307... |
/* The older code accepts a <local-name> here, but I don't see
|
/* The older code accepts a <local-name> here, but I don't see
|
that in the grammar. The older code does not accept a
|
that in the grammar. The older code does not accept a
|
<template-param> here. */
|
<template-param> here. */
|
|
|
comb_type = DEMANGLE_COMPONENT_QUAL_NAME;
|
comb_type = DEMANGLE_COMPONENT_QUAL_NAME;
|
if (IS_DIGIT (peek)
|
if (peek == 'D')
|
|
{
|
|
char peek2 = d_peek_next_char (di);
|
|
if (peek2 == 'T' || peek2 == 't')
|
|
/* Decltype. */
|
|
dc = cplus_demangle_type (di);
|
|
else
|
|
/* Destructor name. */
|
|
dc = d_unqualified_name (di);
|
|
}
|
|
else if (IS_DIGIT (peek)
|
|| IS_LOWER (peek)
|
|| IS_LOWER (peek)
|
|| peek == 'C'
|
|| peek == 'C'
|
|| peek == 'D'
|
|
|| peek == 'U'
|
|| peek == 'U'
|
|| peek == 'L')
|
|| peek == 'L')
|
dc = d_unqualified_name (di);
|
dc = d_unqualified_name (di);
|
else if (peek == 'S')
|
else if (peek == 'S')
|
dc = d_substitution (di, 1);
|
dc = d_substitution (di, 1);
|
Line 2738... |
Line 2746... |
else if (peek == 'f' && d_peek_next_char (di) == 'p')
|
else if (peek == 'f' && d_peek_next_char (di) == 'p')
|
{
|
{
|
/* Function parameter used in a late-specified return type. */
|
/* Function parameter used in a late-specified return type. */
|
int index;
|
int index;
|
d_advance (di, 2);
|
d_advance (di, 2);
|
index = d_compact_number (di);
|
if (d_peek_char (di) == 'T')
|
if (index < 0)
|
{
|
|
/* 'this' parameter. */
|
|
d_advance (di, 1);
|
|
index = 0;
|
|
}
|
|
else
|
|
{
|
|
index = d_compact_number (di) + 1;
|
|
if (index == 0)
|
return NULL;
|
return NULL;
|
|
}
|
return d_make_function_param (di, index);
|
return d_make_function_param (di, index);
|
}
|
}
|
else if (IS_DIGIT (peek)
|
else if (IS_DIGIT (peek)
|
|| (peek == 'o' && d_peek_next_char (di) == 'n'))
|
|| (peek == 'o' && d_peek_next_char (di) == 'n'))
|
{
|
{
|
Line 3291... |
Line 3307... |
}
|
}
|
|
|
/* Initialize a print information structure. */
|
/* Initialize a print information structure. */
|
|
|
static void
|
static void
|
d_print_init (struct d_print_info *dpi, int options,
|
d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
|
demangle_callbackref callback, void *opaque)
|
void *opaque)
|
{
|
{
|
dpi->options = options;
|
|
dpi->len = 0;
|
dpi->len = 0;
|
dpi->last_char = '\0';
|
dpi->last_char = '\0';
|
dpi->templates = NULL;
|
dpi->templates = NULL;
|
dpi->modifiers = NULL;
|
dpi->modifiers = NULL;
|
|
dpi->pack_index = 0;
|
dpi->flush_count = 0;
|
dpi->flush_count = 0;
|
|
|
dpi->callback = callback;
|
dpi->callback = callback;
|
dpi->opaque = opaque;
|
dpi->opaque = opaque;
|
|
|
Line 3390... |
Line 3406... |
const struct demangle_component *dc,
|
const struct demangle_component *dc,
|
demangle_callbackref callback, void *opaque)
|
demangle_callbackref callback, void *opaque)
|
{
|
{
|
struct d_print_info dpi;
|
struct d_print_info dpi;
|
|
|
d_print_init (&dpi, options, callback, opaque);
|
d_print_init (&dpi, callback, opaque);
|
|
|
d_print_comp (&dpi, dc);
|
d_print_comp (&dpi, options, dc);
|
|
|
d_print_flush (&dpi);
|
d_print_flush (&dpi);
|
|
|
return ! d_print_saw_error (&dpi);
|
return ! d_print_saw_error (&dpi);
|
}
|
}
|
Line 3535... |
Line 3551... |
|
|
/* DC is a component of a mangled expression. Print it, wrapped in parens
|
/* DC is a component of a mangled expression. Print it, wrapped in parens
|
if needed. */
|
if needed. */
|
|
|
static void
|
static void
|
d_print_subexpr (struct d_print_info *dpi,
|
d_print_subexpr (struct d_print_info *dpi, int options,
|
const struct demangle_component *dc)
|
const struct demangle_component *dc)
|
{
|
{
|
int simple = 0;
|
int simple = 0;
|
if (dc->type == DEMANGLE_COMPONENT_NAME
|
if (dc->type == DEMANGLE_COMPONENT_NAME
|
|| dc->type == DEMANGLE_COMPONENT_FUNCTION_PARAM)
|
|| dc->type == DEMANGLE_COMPONENT_FUNCTION_PARAM)
|
simple = 1;
|
simple = 1;
|
if (!simple)
|
if (!simple)
|
d_append_char (dpi, '(');
|
d_append_char (dpi, '(');
|
d_print_comp (dpi, dc);
|
d_print_comp (dpi, options, dc);
|
if (!simple)
|
if (!simple)
|
d_append_char (dpi, ')');
|
d_append_char (dpi, ')');
|
}
|
}
|
|
|
/* Subroutine to handle components. */
|
/* Subroutine to handle components. */
|
|
|
static void
|
static void
|
d_print_comp (struct d_print_info *dpi,
|
d_print_comp (struct d_print_info *dpi, int options,
|
const struct demangle_component *dc)
|
const struct demangle_component *dc)
|
{
|
{
|
|
/* Magic variable to let reference smashing skip over the next modifier
|
|
without needing to modify *dc. */
|
|
const struct demangle_component *mod_inner = NULL;
|
|
|
if (dc == NULL)
|
if (dc == NULL)
|
{
|
{
|
d_print_error (dpi);
|
d_print_error (dpi);
|
return;
|
return;
|
}
|
}
|
Line 3566... |
Line 3586... |
return;
|
return;
|
|
|
switch (dc->type)
|
switch (dc->type)
|
{
|
{
|
case DEMANGLE_COMPONENT_NAME:
|
case DEMANGLE_COMPONENT_NAME:
|
if ((dpi->options & DMGL_JAVA) == 0)
|
if ((options & DMGL_JAVA) == 0)
|
d_append_buffer (dpi, dc->u.s_name.s, dc->u.s_name.len);
|
d_append_buffer (dpi, dc->u.s_name.s, dc->u.s_name.len);
|
else
|
else
|
d_print_java_identifier (dpi, dc->u.s_name.s, dc->u.s_name.len);
|
d_print_java_identifier (dpi, dc->u.s_name.s, dc->u.s_name.len);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_QUAL_NAME:
|
case DEMANGLE_COMPONENT_QUAL_NAME:
|
case DEMANGLE_COMPONENT_LOCAL_NAME:
|
case DEMANGLE_COMPONENT_LOCAL_NAME:
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
if ((dpi->options & DMGL_JAVA) == 0)
|
if ((options & DMGL_JAVA) == 0)
|
d_append_string (dpi, "::");
|
d_append_string (dpi, "::");
|
else
|
else
|
d_append_char (dpi, '.');
|
d_append_char (dpi, '.');
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_TYPED_NAME:
|
case DEMANGLE_COMPONENT_TYPED_NAME:
|
{
|
{
|
struct d_print_mod *hold_modifiers;
|
struct d_print_mod *hold_modifiers;
|
Line 3669... |
Line 3689... |
|
|
local_name = d_left (local_name);
|
local_name = d_left (local_name);
|
}
|
}
|
}
|
}
|
|
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
|
|
if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE)
|
if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE)
|
dpi->templates = dpt.next;
|
dpi->templates = dpt.next;
|
|
|
/* If the modifiers didn't get printed by the type, print them
|
/* If the modifiers didn't get printed by the type, print them
|
Line 3682... |
Line 3702... |
{
|
{
|
--i;
|
--i;
|
if (! adpm[i].printed)
|
if (! adpm[i].printed)
|
{
|
{
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
d_print_mod (dpi, adpm[i].mod);
|
d_print_mod (dpi, options, adpm[i].mod);
|
}
|
}
|
}
|
}
|
|
|
dpi->modifiers = hold_modifiers;
|
dpi->modifiers = hold_modifiers;
|
|
|
Line 3705... |
Line 3725... |
hold_dpm = dpi->modifiers;
|
hold_dpm = dpi->modifiers;
|
dpi->modifiers = NULL;
|
dpi->modifiers = NULL;
|
|
|
dcl = d_left (dc);
|
dcl = d_left (dc);
|
|
|
if ((dpi->options & DMGL_JAVA) != 0
|
if ((options & DMGL_JAVA) != 0
|
&& dcl->type == DEMANGLE_COMPONENT_NAME
|
&& dcl->type == DEMANGLE_COMPONENT_NAME
|
&& dcl->u.s_name.len == 6
|
&& dcl->u.s_name.len == 6
|
&& strncmp (dcl->u.s_name.s, "JArray", 6) == 0)
|
&& strncmp (dcl->u.s_name.s, "JArray", 6) == 0)
|
{
|
{
|
/* Special-case Java arrays, so that JArray<TYPE> appears
|
/* Special-case Java arrays, so that JArray<TYPE> appears
|
instead as TYPE[]. */
|
instead as TYPE[]. */
|
|
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
d_append_string (dpi, "[]");
|
d_append_string (dpi, "[]");
|
}
|
}
|
else
|
else
|
{
|
{
|
d_print_comp (dpi, dcl);
|
d_print_comp (dpi, options, dcl);
|
if (d_last_char (dpi) == '<')
|
if (d_last_char (dpi) == '<')
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, '<');
|
d_append_char (dpi, '<');
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
/* Avoid generating two consecutive '>' characters, to avoid
|
/* Avoid generating two consecutive '>' characters, to avoid
|
the C++ syntactic ambiguity. */
|
the C++ syntactic ambiguity. */
|
if (d_last_char (dpi) == '>')
|
if (d_last_char (dpi) == '>')
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, '>');
|
d_append_char (dpi, '>');
|
Line 3757... |
Line 3777... |
template. */
|
template. */
|
|
|
hold_dpt = dpi->templates;
|
hold_dpt = dpi->templates;
|
dpi->templates = hold_dpt->next;
|
dpi->templates = hold_dpt->next;
|
|
|
d_print_comp (dpi, a);
|
d_print_comp (dpi, options, a);
|
|
|
dpi->templates = hold_dpt;
|
dpi->templates = hold_dpt;
|
|
|
return;
|
return;
|
}
|
}
|
|
|
case DEMANGLE_COMPONENT_CTOR:
|
case DEMANGLE_COMPONENT_CTOR:
|
d_print_comp (dpi, dc->u.s_ctor.name);
|
d_print_comp (dpi, options, dc->u.s_ctor.name);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_DTOR:
|
case DEMANGLE_COMPONENT_DTOR:
|
d_append_char (dpi, '~');
|
d_append_char (dpi, '~');
|
d_print_comp (dpi, dc->u.s_dtor.name);
|
d_print_comp (dpi, options, dc->u.s_dtor.name);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_VTABLE:
|
case DEMANGLE_COMPONENT_VTABLE:
|
d_append_string (dpi, "vtable for ");
|
d_append_string (dpi, "vtable for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_VTT:
|
case DEMANGLE_COMPONENT_VTT:
|
d_append_string (dpi, "VTT for ");
|
d_append_string (dpi, "VTT for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE:
|
case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE:
|
d_append_string (dpi, "construction vtable for ");
|
d_append_string (dpi, "construction vtable for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
d_append_string (dpi, "-in-");
|
d_append_string (dpi, "-in-");
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_TYPEINFO:
|
case DEMANGLE_COMPONENT_TYPEINFO:
|
d_append_string (dpi, "typeinfo for ");
|
d_append_string (dpi, "typeinfo for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_TYPEINFO_NAME:
|
case DEMANGLE_COMPONENT_TYPEINFO_NAME:
|
d_append_string (dpi, "typeinfo name for ");
|
d_append_string (dpi, "typeinfo name for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_TYPEINFO_FN:
|
case DEMANGLE_COMPONENT_TYPEINFO_FN:
|
d_append_string (dpi, "typeinfo fn for ");
|
d_append_string (dpi, "typeinfo fn for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_THUNK:
|
case DEMANGLE_COMPONENT_THUNK:
|
d_append_string (dpi, "non-virtual thunk to ");
|
d_append_string (dpi, "non-virtual thunk to ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_VIRTUAL_THUNK:
|
case DEMANGLE_COMPONENT_VIRTUAL_THUNK:
|
d_append_string (dpi, "virtual thunk to ");
|
d_append_string (dpi, "virtual thunk to ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_COVARIANT_THUNK:
|
case DEMANGLE_COMPONENT_COVARIANT_THUNK:
|
d_append_string (dpi, "covariant return thunk to ");
|
d_append_string (dpi, "covariant return thunk to ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_JAVA_CLASS:
|
case DEMANGLE_COMPONENT_JAVA_CLASS:
|
d_append_string (dpi, "java Class for ");
|
d_append_string (dpi, "java Class for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_GUARD:
|
case DEMANGLE_COMPONENT_GUARD:
|
d_append_string (dpi, "guard variable for ");
|
d_append_string (dpi, "guard variable for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_REFTEMP:
|
case DEMANGLE_COMPONENT_REFTEMP:
|
d_append_string (dpi, "reference temporary for ");
|
d_append_string (dpi, "reference temporary for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_HIDDEN_ALIAS:
|
case DEMANGLE_COMPONENT_HIDDEN_ALIAS:
|
d_append_string (dpi, "hidden alias for ");
|
d_append_string (dpi, "hidden alias for ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_SUB_STD:
|
case DEMANGLE_COMPONENT_SUB_STD:
|
d_append_buffer (dpi, dc->u.s_string.string, dc->u.s_string.len);
|
d_append_buffer (dpi, dc->u.s_string.string, dc->u.s_string.len);
|
return;
|
return;
|
Line 3864... |
Line 3884... |
&& pdpm->mod->type != DEMANGLE_COMPONENT_VOLATILE
|
&& pdpm->mod->type != DEMANGLE_COMPONENT_VOLATILE
|
&& pdpm->mod->type != DEMANGLE_COMPONENT_CONST)
|
&& pdpm->mod->type != DEMANGLE_COMPONENT_CONST)
|
break;
|
break;
|
if (pdpm->mod->type == dc->type)
|
if (pdpm->mod->type == dc->type)
|
{
|
{
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
goto modifier;
|
|
|
|
case DEMANGLE_COMPONENT_REFERENCE:
|
|
case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
|
|
{
|
|
/* Handle reference smashing: & + && = &. */
|
|
const struct demangle_component *sub = d_left (dc);
|
|
if (sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM)
|
|
{
|
|
struct demangle_component *a = d_lookup_template_argument (dpi, sub);
|
|
if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
|
|
a = d_index_template_argument (a, dpi->pack_index);
|
|
|
|
if (a == NULL)
|
|
{
|
|
d_print_error (dpi);
|
|
return;
|
|
}
|
|
|
|
sub = a;
|
|
}
|
|
|
|
if (sub->type == DEMANGLE_COMPONENT_REFERENCE
|
|
|| sub->type == dc->type)
|
|
dc = sub;
|
|
else if (sub->type == DEMANGLE_COMPONENT_RVALUE_REFERENCE)
|
|
mod_inner = d_left (sub);
|
|
}
|
/* Fall through. */
|
/* Fall through. */
|
|
|
case DEMANGLE_COMPONENT_RESTRICT_THIS:
|
case DEMANGLE_COMPONENT_RESTRICT_THIS:
|
case DEMANGLE_COMPONENT_VOLATILE_THIS:
|
case DEMANGLE_COMPONENT_VOLATILE_THIS:
|
case DEMANGLE_COMPONENT_CONST_THIS:
|
case DEMANGLE_COMPONENT_CONST_THIS:
|
case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
|
case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
|
case DEMANGLE_COMPONENT_POINTER:
|
case DEMANGLE_COMPONENT_POINTER:
|
case DEMANGLE_COMPONENT_REFERENCE:
|
|
case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
|
|
case DEMANGLE_COMPONENT_COMPLEX:
|
case DEMANGLE_COMPONENT_COMPLEX:
|
case DEMANGLE_COMPONENT_IMAGINARY:
|
case DEMANGLE_COMPONENT_IMAGINARY:
|
|
modifier:
|
{
|
{
|
/* We keep a list of modifiers on the stack. */
|
/* We keep a list of modifiers on the stack. */
|
struct d_print_mod dpm;
|
struct d_print_mod dpm;
|
|
|
dpm.next = dpi->modifiers;
|
dpm.next = dpi->modifiers;
|
dpi->modifiers = &dpm;
|
dpi->modifiers = &dpm;
|
dpm.mod = dc;
|
dpm.mod = dc;
|
dpm.printed = 0;
|
dpm.printed = 0;
|
dpm.templates = dpi->templates;
|
dpm.templates = dpi->templates;
|
|
|
d_print_comp (dpi, d_left (dc));
|
if (!mod_inner)
|
|
mod_inner = d_left (dc);
|
|
|
|
d_print_comp (dpi, options, mod_inner);
|
|
|
/* If the modifier didn't get printed by the type, print it
|
/* If the modifier didn't get printed by the type, print it
|
now. */
|
now. */
|
if (! dpm.printed)
|
if (! dpm.printed)
|
d_print_mod (dpi, dc);
|
d_print_mod (dpi, options, dc);
|
|
|
dpi->modifiers = dpm.next;
|
dpi->modifiers = dpm.next;
|
|
|
return;
|
return;
|
}
|
}
|
|
|
case DEMANGLE_COMPONENT_BUILTIN_TYPE:
|
case DEMANGLE_COMPONENT_BUILTIN_TYPE:
|
if ((dpi->options & DMGL_JAVA) == 0)
|
if ((options & DMGL_JAVA) == 0)
|
d_append_buffer (dpi, dc->u.s_builtin.type->name,
|
d_append_buffer (dpi, dc->u.s_builtin.type->name,
|
dc->u.s_builtin.type->len);
|
dc->u.s_builtin.type->len);
|
else
|
else
|
d_append_buffer (dpi, dc->u.s_builtin.type->java_name,
|
d_append_buffer (dpi, dc->u.s_builtin.type->java_name,
|
dc->u.s_builtin.type->java_len);
|
dc->u.s_builtin.type->java_len);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_VENDOR_TYPE:
|
case DEMANGLE_COMPONENT_VENDOR_TYPE:
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_FUNCTION_TYPE:
|
case DEMANGLE_COMPONENT_FUNCTION_TYPE:
|
{
|
{
|
if ((dpi->options & DMGL_RET_POSTFIX) != 0)
|
if ((options & DMGL_RET_POSTFIX) != 0)
|
d_print_function_type (dpi, dc, dpi->modifiers);
|
d_print_function_type (dpi,
|
|
options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP),
|
|
dc, dpi->modifiers);
|
|
|
/* Print return type if present */
|
/* Print return type if present */
|
if (d_left (dc) != NULL)
|
if (d_left (dc) != NULL && (options & DMGL_RET_POSTFIX) != 0)
|
|
d_print_comp (dpi, options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP),
|
|
d_left (dc));
|
|
else if (d_left (dc) != NULL && (options & DMGL_RET_DROP) == 0)
|
{
|
{
|
struct d_print_mod dpm;
|
struct d_print_mod dpm;
|
|
|
/* We must pass this type down as a modifier in order to
|
/* We must pass this type down as a modifier in order to
|
print it in the right location. */
|
print it in the right location. */
|
Line 3933... |
Line 3989... |
dpi->modifiers = &dpm;
|
dpi->modifiers = &dpm;
|
dpm.mod = dc;
|
dpm.mod = dc;
|
dpm.printed = 0;
|
dpm.printed = 0;
|
dpm.templates = dpi->templates;
|
dpm.templates = dpi->templates;
|
|
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP),
|
|
d_left (dc));
|
|
|
dpi->modifiers = dpm.next;
|
dpi->modifiers = dpm.next;
|
|
|
if (dpm.printed)
|
if (dpm.printed)
|
return;
|
return;
|
|
|
/* In standard prefix notation, there is a space between the
|
/* In standard prefix notation, there is a space between the
|
return type and the function signature. */
|
return type and the function signature. */
|
if ((dpi->options & DMGL_RET_POSTFIX) == 0)
|
if ((options & DMGL_RET_POSTFIX) == 0)
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
}
|
}
|
|
|
if ((dpi->options & DMGL_RET_POSTFIX) == 0)
|
if ((options & DMGL_RET_POSTFIX) == 0)
|
d_print_function_type (dpi, dc, dpi->modifiers);
|
d_print_function_type (dpi,
|
|
options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP),
|
|
dc, dpi->modifiers);
|
|
|
return;
|
return;
|
}
|
}
|
|
|
case DEMANGLE_COMPONENT_ARRAY_TYPE:
|
case DEMANGLE_COMPONENT_ARRAY_TYPE:
|
Line 4000... |
Line 4059... |
}
|
}
|
|
|
pdpm = pdpm->next;
|
pdpm = pdpm->next;
|
}
|
}
|
|
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
|
|
dpi->modifiers = hold_modifiers;
|
dpi->modifiers = hold_modifiers;
|
|
|
if (adpm[0].printed)
|
if (adpm[0].printed)
|
return;
|
return;
|
|
|
while (i > 1)
|
while (i > 1)
|
{
|
{
|
--i;
|
--i;
|
d_print_mod (dpi, adpm[i].mod);
|
d_print_mod (dpi, options, adpm[i].mod);
|
}
|
}
|
|
|
d_print_array_type (dpi, dc, dpi->modifiers);
|
d_print_array_type (dpi, options, dc, dpi->modifiers);
|
|
|
return;
|
return;
|
}
|
}
|
|
|
case DEMANGLE_COMPONENT_PTRMEM_TYPE:
|
case DEMANGLE_COMPONENT_PTRMEM_TYPE:
|
Line 4029... |
Line 4088... |
dpi->modifiers = &dpm;
|
dpi->modifiers = &dpm;
|
dpm.mod = dc;
|
dpm.mod = dc;
|
dpm.printed = 0;
|
dpm.printed = 0;
|
dpm.templates = dpi->templates;
|
dpm.templates = dpi->templates;
|
|
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
|
|
/* If the modifier didn't get printed by the type, print it
|
/* If the modifier didn't get printed by the type, print it
|
now. */
|
now. */
|
if (! dpm.printed)
|
if (! dpm.printed)
|
d_print_mod (dpi, dc);
|
d_print_mod (dpi, options, dc);
|
|
|
dpi->modifiers = dpm.next;
|
dpi->modifiers = dpm.next;
|
|
|
return;
|
return;
|
}
|
}
|
Line 4048... |
Line 4107... |
d_append_string (dpi, "_Sat ");
|
d_append_string (dpi, "_Sat ");
|
/* Don't print "int _Accum". */
|
/* Don't print "int _Accum". */
|
if (dc->u.s_fixed.length->u.s_builtin.type
|
if (dc->u.s_fixed.length->u.s_builtin.type
|
!= &cplus_demangle_builtin_types['i'-'a'])
|
!= &cplus_demangle_builtin_types['i'-'a'])
|
{
|
{
|
d_print_comp (dpi, dc->u.s_fixed.length);
|
d_print_comp (dpi, options, dc->u.s_fixed.length);
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
}
|
}
|
if (dc->u.s_fixed.accum)
|
if (dc->u.s_fixed.accum)
|
d_append_string (dpi, "_Accum");
|
d_append_string (dpi, "_Accum");
|
else
|
else
|
Line 4060... |
Line 4119... |
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_ARGLIST:
|
case DEMANGLE_COMPONENT_ARGLIST:
|
case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST:
|
case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST:
|
if (d_left (dc) != NULL)
|
if (d_left (dc) != NULL)
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
if (d_right (dc) != NULL)
|
if (d_right (dc) != NULL)
|
{
|
{
|
size_t len;
|
size_t len;
|
unsigned long int flush_count;
|
unsigned long int flush_count;
|
/* Make sure ", " isn't flushed by d_append_string, otherwise
|
/* Make sure ", " isn't flushed by d_append_string, otherwise
|
Line 4072... |
Line 4131... |
if (dpi->len >= sizeof (dpi->buf) - 2)
|
if (dpi->len >= sizeof (dpi->buf) - 2)
|
d_print_flush (dpi);
|
d_print_flush (dpi);
|
d_append_string (dpi, ", ");
|
d_append_string (dpi, ", ");
|
len = dpi->len;
|
len = dpi->len;
|
flush_count = dpi->flush_count;
|
flush_count = dpi->flush_count;
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
/* If that didn't print anything (which can happen with empty
|
/* If that didn't print anything (which can happen with empty
|
template argument packs), remove the comma and space. */
|
template argument packs), remove the comma and space. */
|
if (dpi->flush_count == flush_count && dpi->len == len)
|
if (dpi->flush_count == flush_count && dpi->len == len)
|
dpi->len -= 2;
|
dpi->len -= 2;
|
}
|
}
|
Line 4095... |
Line 4154... |
return;
|
return;
|
}
|
}
|
|
|
case DEMANGLE_COMPONENT_EXTENDED_OPERATOR:
|
case DEMANGLE_COMPONENT_EXTENDED_OPERATOR:
|
d_append_string (dpi, "operator ");
|
d_append_string (dpi, "operator ");
|
d_print_comp (dpi, dc->u.s_extended_operator.name);
|
d_print_comp (dpi, options, dc->u.s_extended_operator.name);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_CAST:
|
case DEMANGLE_COMPONENT_CAST:
|
d_append_string (dpi, "operator ");
|
d_append_string (dpi, "operator ");
|
d_print_cast (dpi, dc);
|
d_print_cast (dpi, options, dc);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_UNARY:
|
case DEMANGLE_COMPONENT_UNARY:
|
if (d_left (dc)->type != DEMANGLE_COMPONENT_CAST)
|
if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
|
d_print_expr_op (dpi, d_left (dc));
|
&& d_left (dc)->u.s_operator.op->len == 1
|
|
&& d_left (dc)->u.s_operator.op->name[0] == '&'
|
|
&& d_right (dc)->type == DEMANGLE_COMPONENT_TYPED_NAME
|
|
&& d_left (d_right (dc))->type == DEMANGLE_COMPONENT_QUAL_NAME
|
|
&& d_right (d_right (dc))->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
|
|
{
|
|
/* Address of a function (therefore in an expression context) must
|
|
have its argument list suppressed.
|
|
|
|
unary operator ... dc
|
|
operator & ... d_left (dc)
|
|
typed name ... d_right (dc)
|
|
qualified name ... d_left (d_right (dc))
|
|
<names>
|
|
function type ... d_right (d_right (dc))
|
|
argument list
|
|
<arguments> */
|
|
|
|
d_print_expr_op (dpi, options, d_left (dc));
|
|
d_print_comp (dpi, options, d_left (d_right (dc)));
|
|
return;
|
|
}
|
|
else if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
|
|
&& d_left (dc)->u.s_operator.op->len == 1
|
|
&& d_left (dc)->u.s_operator.op->name[0] == '&'
|
|
&& d_right (dc)->type == DEMANGLE_COMPONENT_QUAL_NAME)
|
|
{
|
|
/* Keep also already processed variant without the argument list.
|
|
|
|
unary operator ... dc
|
|
operator & ... d_left (dc)
|
|
qualified name ... d_right (dc)
|
|
<names> */
|
|
|
|
d_print_expr_op (dpi, options, d_left (dc));
|
|
d_print_comp (dpi, options, d_right (dc));
|
|
return;
|
|
}
|
|
else if (d_left (dc)->type != DEMANGLE_COMPONENT_CAST)
|
|
d_print_expr_op (dpi, options, d_left (dc));
|
else
|
else
|
{
|
{
|
d_append_char (dpi, '(');
|
d_append_char (dpi, '(');
|
d_print_cast (dpi, d_left (dc));
|
d_print_cast (dpi, options, d_left (dc));
|
d_append_char (dpi, ')');
|
d_append_char (dpi, ')');
|
}
|
}
|
d_print_subexpr (dpi, d_right (dc));
|
d_print_subexpr (dpi, options, d_right (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_BINARY:
|
case DEMANGLE_COMPONENT_BINARY:
|
if (d_right (dc)->type != DEMANGLE_COMPONENT_BINARY_ARGS)
|
if (d_right (dc)->type != DEMANGLE_COMPONENT_BINARY_ARGS)
|
{
|
{
|
Line 4130... |
Line 4228... |
if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
|
if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
|
&& d_left (dc)->u.s_operator.op->len == 1
|
&& d_left (dc)->u.s_operator.op->len == 1
|
&& d_left (dc)->u.s_operator.op->name[0] == '>')
|
&& d_left (dc)->u.s_operator.op->name[0] == '>')
|
d_append_char (dpi, '(');
|
d_append_char (dpi, '(');
|
|
|
d_print_subexpr (dpi, d_left (d_right (dc)));
|
if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") == 0
|
|
&& d_left (d_right (dc))->type == DEMANGLE_COMPONENT_TYPED_NAME)
|
|
{
|
|
/* Function call used in an expression should not have printed types
|
|
of the function arguments. Values of the function arguments still
|
|
get printed below. */
|
|
|
|
const struct demangle_component *func = d_left (d_right (dc));
|
|
|
|
if (d_right (func)->type != DEMANGLE_COMPONENT_FUNCTION_TYPE)
|
|
d_print_error (dpi);
|
|
d_print_subexpr (dpi, options, d_left (func));
|
|
}
|
|
else
|
|
d_print_subexpr (dpi, options, d_left (d_right (dc)));
|
if (strcmp (d_left (dc)->u.s_operator.op->code, "ix") == 0)
|
if (strcmp (d_left (dc)->u.s_operator.op->code, "ix") == 0)
|
{
|
{
|
d_append_char (dpi, '[');
|
d_append_char (dpi, '[');
|
d_print_comp (dpi, d_right (d_right (dc)));
|
d_print_comp (dpi, options, d_right (d_right (dc)));
|
d_append_char (dpi, ']');
|
d_append_char (dpi, ']');
|
}
|
}
|
else
|
else
|
{
|
{
|
if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") != 0)
|
if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") != 0)
|
d_print_expr_op (dpi, d_left (dc));
|
d_print_expr_op (dpi, options, d_left (dc));
|
d_print_subexpr (dpi, d_right (d_right (dc)));
|
d_print_subexpr (dpi, options, d_right (d_right (dc)));
|
}
|
}
|
|
|
if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
|
if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
|
&& d_left (dc)->u.s_operator.op->len == 1
|
&& d_left (dc)->u.s_operator.op->len == 1
|
&& d_left (dc)->u.s_operator.op->name[0] == '>')
|
&& d_left (dc)->u.s_operator.op->name[0] == '>')
|
Line 4163... |
Line 4275... |
|| d_right (d_right (dc))->type != DEMANGLE_COMPONENT_TRINARY_ARG2)
|
|| d_right (d_right (dc))->type != DEMANGLE_COMPONENT_TRINARY_ARG2)
|
{
|
{
|
d_print_error (dpi);
|
d_print_error (dpi);
|
return;
|
return;
|
}
|
}
|
d_print_subexpr (dpi, d_left (d_right (dc)));
|
d_print_subexpr (dpi, options, d_left (d_right (dc)));
|
d_print_expr_op (dpi, d_left (dc));
|
d_print_expr_op (dpi, options, d_left (dc));
|
d_print_subexpr (dpi, d_left (d_right (d_right (dc))));
|
d_print_subexpr (dpi, options, d_left (d_right (d_right (dc))));
|
d_append_string (dpi, " : ");
|
d_append_string (dpi, " : ");
|
d_print_subexpr (dpi, d_right (d_right (d_right (dc))));
|
d_print_subexpr (dpi, options, d_right (d_right (d_right (dc))));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_TRINARY_ARG1:
|
case DEMANGLE_COMPONENT_TRINARY_ARG1:
|
case DEMANGLE_COMPONENT_TRINARY_ARG2:
|
case DEMANGLE_COMPONENT_TRINARY_ARG2:
|
/* We should only see these are part of DEMANGLE_COMPONENT_TRINARY. */
|
/* We should only see these are part of DEMANGLE_COMPONENT_TRINARY. */
|
Line 4198... |
Line 4310... |
case D_PRINT_UNSIGNED_LONG_LONG:
|
case D_PRINT_UNSIGNED_LONG_LONG:
|
if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME)
|
if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME)
|
{
|
{
|
if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
|
if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
|
d_append_char (dpi, '-');
|
d_append_char (dpi, '-');
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
switch (tp)
|
switch (tp)
|
{
|
{
|
default:
|
default:
|
break;
|
break;
|
case D_PRINT_UNSIGNED:
|
case D_PRINT_UNSIGNED:
|
Line 4248... |
Line 4360... |
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
d_append_char (dpi, '(');
|
d_append_char (dpi, '(');
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
d_append_char (dpi, ')');
|
d_append_char (dpi, ')');
|
if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
|
if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
|
d_append_char (dpi, '-');
|
d_append_char (dpi, '-');
|
if (tp == D_PRINT_FLOAT)
|
if (tp == D_PRINT_FLOAT)
|
d_append_char (dpi, '[');
|
d_append_char (dpi, '[');
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
if (tp == D_PRINT_FLOAT)
|
if (tp == D_PRINT_FLOAT)
|
d_append_char (dpi, ']');
|
d_append_char (dpi, ']');
|
}
|
}
|
return;
|
return;
|
|
|
Line 4266... |
Line 4378... |
d_append_num (dpi, dc->u.s_number.number);
|
d_append_num (dpi, dc->u.s_number.number);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_JAVA_RESOURCE:
|
case DEMANGLE_COMPONENT_JAVA_RESOURCE:
|
d_append_string (dpi, "java resource ");
|
d_append_string (dpi, "java resource ");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_COMPOUND_NAME:
|
case DEMANGLE_COMPONENT_COMPOUND_NAME:
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_CHARACTER:
|
case DEMANGLE_COMPONENT_CHARACTER:
|
d_append_char (dpi, dc->u.s_character.character);
|
d_append_char (dpi, dc->u.s_character.character);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_DECLTYPE:
|
case DEMANGLE_COMPONENT_DECLTYPE:
|
d_append_string (dpi, "decltype (");
|
d_append_string (dpi, "decltype (");
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
d_append_char (dpi, ')');
|
d_append_char (dpi, ')');
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_PACK_EXPANSION:
|
case DEMANGLE_COMPONENT_PACK_EXPANSION:
|
{
|
{
|
Line 4294... |
Line 4406... |
if (a == NULL)
|
if (a == NULL)
|
{
|
{
|
/* d_find_pack won't find anything if the only packs involved
|
/* d_find_pack won't find anything if the only packs involved
|
in this expansion are function parameter packs; in that
|
in this expansion are function parameter packs; in that
|
case, just print the pattern and "...". */
|
case, just print the pattern and "...". */
|
d_print_subexpr (dpi, d_left (dc));
|
d_print_subexpr (dpi, options, d_left (dc));
|
d_append_string (dpi, "...");
|
d_append_string (dpi, "...");
|
return;
|
return;
|
}
|
}
|
|
|
len = d_pack_length (a);
|
len = d_pack_length (a);
|
dc = d_left (dc);
|
dc = d_left (dc);
|
for (i = 0; i < len; ++i)
|
for (i = 0; i < len; ++i)
|
{
|
{
|
dpi->pack_index = i;
|
dpi->pack_index = i;
|
d_print_comp (dpi, dc);
|
d_print_comp (dpi, options, dc);
|
if (i < len-1)
|
if (i < len-1)
|
d_append_string (dpi, ", ");
|
d_append_string (dpi, ", ");
|
}
|
}
|
}
|
}
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_FUNCTION_PARAM:
|
case DEMANGLE_COMPONENT_FUNCTION_PARAM:
|
|
{
|
|
long num = dc->u.s_number.number;
|
|
if (num == 0)
|
|
d_append_string (dpi, "this");
|
|
else
|
|
{
|
d_append_string (dpi, "{parm#");
|
d_append_string (dpi, "{parm#");
|
d_append_num (dpi, dc->u.s_number.number + 1);
|
d_append_num (dpi, num);
|
d_append_char (dpi, '}');
|
d_append_char (dpi, '}');
|
|
}
|
|
}
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS:
|
case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS:
|
d_append_string (dpi, "global constructors keyed to ");
|
d_append_string (dpi, "global constructors keyed to ");
|
d_print_comp (dpi, dc->u.s_binary.left);
|
d_print_comp (dpi, options, dc->u.s_binary.left);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS:
|
case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS:
|
d_append_string (dpi, "global destructors keyed to ");
|
d_append_string (dpi, "global destructors keyed to ");
|
d_print_comp (dpi, dc->u.s_binary.left);
|
d_print_comp (dpi, options, dc->u.s_binary.left);
|
return;
|
return;
|
|
|
case DEMANGLE_COMPONENT_LAMBDA:
|
case DEMANGLE_COMPONENT_LAMBDA:
|
d_append_string (dpi, "{lambda(");
|
d_append_string (dpi, "{lambda(");
|
d_print_comp (dpi, dc->u.s_unary_num.sub);
|
d_print_comp (dpi, options, dc->u.s_unary_num.sub);
|
d_append_string (dpi, ")#");
|
d_append_string (dpi, ")#");
|
d_append_num (dpi, dc->u.s_unary_num.num + 1);
|
d_append_num (dpi, dc->u.s_unary_num.num + 1);
|
d_append_char (dpi, '}');
|
d_append_char (dpi, '}');
|
return;
|
return;
|
|
|
Line 4403... |
Line 4523... |
|
|
/* Print a list of modifiers. SUFFIX is 1 if we are printing
|
/* Print a list of modifiers. SUFFIX is 1 if we are printing
|
qualifiers on this after printing a function. */
|
qualifiers on this after printing a function. */
|
|
|
static void
|
static void
|
d_print_mod_list (struct d_print_info *dpi,
|
d_print_mod_list (struct d_print_info *dpi, int options,
|
struct d_print_mod *mods, int suffix)
|
struct d_print_mod *mods, int suffix)
|
{
|
{
|
struct d_print_template *hold_dpt;
|
struct d_print_template *hold_dpt;
|
|
|
if (mods == NULL || d_print_saw_error (dpi))
|
if (mods == NULL || d_print_saw_error (dpi))
|
Line 4417... |
Line 4537... |
|| (! suffix
|
|| (! suffix
|
&& (mods->mod->type == DEMANGLE_COMPONENT_RESTRICT_THIS
|
&& (mods->mod->type == DEMANGLE_COMPONENT_RESTRICT_THIS
|
|| mods->mod->type == DEMANGLE_COMPONENT_VOLATILE_THIS
|
|| mods->mod->type == DEMANGLE_COMPONENT_VOLATILE_THIS
|
|| mods->mod->type == DEMANGLE_COMPONENT_CONST_THIS)))
|
|| mods->mod->type == DEMANGLE_COMPONENT_CONST_THIS)))
|
{
|
{
|
d_print_mod_list (dpi, mods->next, suffix);
|
d_print_mod_list (dpi, options, mods->next, suffix);
|
return;
|
return;
|
}
|
}
|
|
|
mods->printed = 1;
|
mods->printed = 1;
|
|
|
hold_dpt = dpi->templates;
|
hold_dpt = dpi->templates;
|
dpi->templates = mods->templates;
|
dpi->templates = mods->templates;
|
|
|
if (mods->mod->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
|
if (mods->mod->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
|
{
|
{
|
d_print_function_type (dpi, mods->mod, mods->next);
|
d_print_function_type (dpi, options, mods->mod, mods->next);
|
dpi->templates = hold_dpt;
|
dpi->templates = hold_dpt;
|
return;
|
return;
|
}
|
}
|
else if (mods->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE)
|
else if (mods->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE)
|
{
|
{
|
d_print_array_type (dpi, mods->mod, mods->next);
|
d_print_array_type (dpi, options, mods->mod, mods->next);
|
dpi->templates = hold_dpt;
|
dpi->templates = hold_dpt;
|
return;
|
return;
|
}
|
}
|
else if (mods->mod->type == DEMANGLE_COMPONENT_LOCAL_NAME)
|
else if (mods->mod->type == DEMANGLE_COMPONENT_LOCAL_NAME)
|
{
|
{
|
Line 4450... |
Line 4570... |
print it as usual, but don't let the left argument see any
|
print it as usual, but don't let the left argument see any
|
modifiers. */
|
modifiers. */
|
|
|
hold_modifiers = dpi->modifiers;
|
hold_modifiers = dpi->modifiers;
|
dpi->modifiers = NULL;
|
dpi->modifiers = NULL;
|
d_print_comp (dpi, d_left (mods->mod));
|
d_print_comp (dpi, options, d_left (mods->mod));
|
dpi->modifiers = hold_modifiers;
|
dpi->modifiers = hold_modifiers;
|
|
|
if ((dpi->options & DMGL_JAVA) == 0)
|
if ((options & DMGL_JAVA) == 0)
|
d_append_string (dpi, "::");
|
d_append_string (dpi, "::");
|
else
|
else
|
d_append_char (dpi, '.');
|
d_append_char (dpi, '.');
|
|
|
dc = d_right (mods->mod);
|
dc = d_right (mods->mod);
|
Line 4473... |
Line 4593... |
while (dc->type == DEMANGLE_COMPONENT_RESTRICT_THIS
|
while (dc->type == DEMANGLE_COMPONENT_RESTRICT_THIS
|
|| dc->type == DEMANGLE_COMPONENT_VOLATILE_THIS
|
|| dc->type == DEMANGLE_COMPONENT_VOLATILE_THIS
|
|| dc->type == DEMANGLE_COMPONENT_CONST_THIS)
|
|| dc->type == DEMANGLE_COMPONENT_CONST_THIS)
|
dc = d_left (dc);
|
dc = d_left (dc);
|
|
|
d_print_comp (dpi, dc);
|
d_print_comp (dpi, options, dc);
|
|
|
dpi->templates = hold_dpt;
|
dpi->templates = hold_dpt;
|
return;
|
return;
|
}
|
}
|
|
|
d_print_mod (dpi, mods->mod);
|
d_print_mod (dpi, options, mods->mod);
|
|
|
dpi->templates = hold_dpt;
|
dpi->templates = hold_dpt;
|
|
|
d_print_mod_list (dpi, mods->next, suffix);
|
d_print_mod_list (dpi, options, mods->next, suffix);
|
}
|
}
|
|
|
/* Print a modifier. */
|
/* Print a modifier. */
|
|
|
static void
|
static void
|
d_print_mod (struct d_print_info *dpi,
|
d_print_mod (struct d_print_info *dpi, int options,
|
const struct demangle_component *mod)
|
const struct demangle_component *mod)
|
{
|
{
|
switch (mod->type)
|
switch (mod->type)
|
{
|
{
|
case DEMANGLE_COMPONENT_RESTRICT:
|
case DEMANGLE_COMPONENT_RESTRICT:
|
Line 4508... |
Line 4628... |
case DEMANGLE_COMPONENT_CONST_THIS:
|
case DEMANGLE_COMPONENT_CONST_THIS:
|
d_append_string (dpi, " const");
|
d_append_string (dpi, " const");
|
return;
|
return;
|
case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
|
case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
d_print_comp (dpi, d_right (mod));
|
d_print_comp (dpi, options, d_right (mod));
|
return;
|
return;
|
case DEMANGLE_COMPONENT_POINTER:
|
case DEMANGLE_COMPONENT_POINTER:
|
/* There is no pointer symbol in Java. */
|
/* There is no pointer symbol in Java. */
|
if ((dpi->options & DMGL_JAVA) == 0)
|
if ((options & DMGL_JAVA) == 0)
|
d_append_char (dpi, '*');
|
d_append_char (dpi, '*');
|
return;
|
return;
|
case DEMANGLE_COMPONENT_REFERENCE:
|
case DEMANGLE_COMPONENT_REFERENCE:
|
d_append_char (dpi, '&');
|
d_append_char (dpi, '&');
|
return;
|
return;
|
Line 4530... |
Line 4650... |
d_append_string (dpi, "imaginary ");
|
d_append_string (dpi, "imaginary ");
|
return;
|
return;
|
case DEMANGLE_COMPONENT_PTRMEM_TYPE:
|
case DEMANGLE_COMPONENT_PTRMEM_TYPE:
|
if (d_last_char (dpi) != '(')
|
if (d_last_char (dpi) != '(')
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
d_print_comp (dpi, d_left (mod));
|
d_print_comp (dpi, options, d_left (mod));
|
d_append_string (dpi, "::*");
|
d_append_string (dpi, "::*");
|
return;
|
return;
|
case DEMANGLE_COMPONENT_TYPED_NAME:
|
case DEMANGLE_COMPONENT_TYPED_NAME:
|
d_print_comp (dpi, d_left (mod));
|
d_print_comp (dpi, options, d_left (mod));
|
return;
|
return;
|
case DEMANGLE_COMPONENT_VECTOR_TYPE:
|
case DEMANGLE_COMPONENT_VECTOR_TYPE:
|
d_append_string (dpi, " __vector(");
|
d_append_string (dpi, " __vector(");
|
d_print_comp (dpi, d_left (mod));
|
d_print_comp (dpi, options, d_left (mod));
|
d_append_char (dpi, ')');
|
d_append_char (dpi, ')');
|
return;
|
return;
|
|
|
default:
|
default:
|
/* Otherwise, we have something that won't go back on the
|
/* Otherwise, we have something that won't go back on the
|
modifier stack, so we can just print it. */
|
modifier stack, so we can just print it. */
|
d_print_comp (dpi, mod);
|
d_print_comp (dpi, options, mod);
|
return;
|
return;
|
}
|
}
|
}
|
}
|
|
|
/* Print a function type, except for the return type. */
|
/* Print a function type, except for the return type. */
|
|
|
static void
|
static void
|
d_print_function_type (struct d_print_info *dpi,
|
d_print_function_type (struct d_print_info *dpi, int options,
|
const struct demangle_component *dc,
|
const struct demangle_component *dc,
|
struct d_print_mod *mods)
|
struct d_print_mod *mods)
|
{
|
{
|
int need_paren;
|
int need_paren;
|
int need_space;
|
int need_space;
|
Line 4613... |
Line 4733... |
}
|
}
|
|
|
hold_modifiers = dpi->modifiers;
|
hold_modifiers = dpi->modifiers;
|
dpi->modifiers = NULL;
|
dpi->modifiers = NULL;
|
|
|
d_print_mod_list (dpi, mods, 0);
|
d_print_mod_list (dpi, options, mods, 0);
|
|
|
if (need_paren)
|
if (need_paren)
|
d_append_char (dpi, ')');
|
d_append_char (dpi, ')');
|
|
|
d_append_char (dpi, '(');
|
d_append_char (dpi, '(');
|
|
|
if (d_right (dc) != NULL)
|
if (d_right (dc) != NULL)
|
d_print_comp (dpi, d_right (dc));
|
d_print_comp (dpi, options, d_right (dc));
|
|
|
d_append_char (dpi, ')');
|
d_append_char (dpi, ')');
|
|
|
d_print_mod_list (dpi, mods, 1);
|
d_print_mod_list (dpi, options, mods, 1);
|
|
|
dpi->modifiers = hold_modifiers;
|
dpi->modifiers = hold_modifiers;
|
}
|
}
|
|
|
/* Print an array type, except for the element type. */
|
/* Print an array type, except for the element type. */
|
|
|
static void
|
static void
|
d_print_array_type (struct d_print_info *dpi,
|
d_print_array_type (struct d_print_info *dpi, int options,
|
const struct demangle_component *dc,
|
const struct demangle_component *dc,
|
struct d_print_mod *mods)
|
struct d_print_mod *mods)
|
{
|
{
|
int need_space;
|
int need_space;
|
|
|
Line 4667... |
Line 4787... |
}
|
}
|
|
|
if (need_paren)
|
if (need_paren)
|
d_append_string (dpi, " (");
|
d_append_string (dpi, " (");
|
|
|
d_print_mod_list (dpi, mods, 0);
|
d_print_mod_list (dpi, options, mods, 0);
|
|
|
if (need_paren)
|
if (need_paren)
|
d_append_char (dpi, ')');
|
d_append_char (dpi, ')');
|
}
|
}
|
|
|
Line 4679... |
Line 4799... |
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
|
|
d_append_char (dpi, '[');
|
d_append_char (dpi, '[');
|
|
|
if (d_left (dc) != NULL)
|
if (d_left (dc) != NULL)
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
|
|
d_append_char (dpi, ']');
|
d_append_char (dpi, ']');
|
}
|
}
|
|
|
/* Print an operator in an expression. */
|
/* Print an operator in an expression. */
|
|
|
static void
|
static void
|
d_print_expr_op (struct d_print_info *dpi,
|
d_print_expr_op (struct d_print_info *dpi, int options,
|
const struct demangle_component *dc)
|
const struct demangle_component *dc)
|
{
|
{
|
if (dc->type == DEMANGLE_COMPONENT_OPERATOR)
|
if (dc->type == DEMANGLE_COMPONENT_OPERATOR)
|
d_append_buffer (dpi, dc->u.s_operator.op->name,
|
d_append_buffer (dpi, dc->u.s_operator.op->name,
|
dc->u.s_operator.op->len);
|
dc->u.s_operator.op->len);
|
else
|
else
|
d_print_comp (dpi, dc);
|
d_print_comp (dpi, options, dc);
|
}
|
}
|
|
|
/* Print a cast. */
|
/* Print a cast. */
|
|
|
static void
|
static void
|
d_print_cast (struct d_print_info *dpi,
|
d_print_cast (struct d_print_info *dpi, int options,
|
const struct demangle_component *dc)
|
const struct demangle_component *dc)
|
{
|
{
|
if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE)
|
if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE)
|
d_print_comp (dpi, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
else
|
else
|
{
|
{
|
struct d_print_mod *hold_dpm;
|
struct d_print_mod *hold_dpm;
|
struct d_print_template dpt;
|
struct d_print_template dpt;
|
|
|
Line 4722... |
Line 4842... |
|
|
dpt.next = dpi->templates;
|
dpt.next = dpi->templates;
|
dpi->templates = &dpt;
|
dpi->templates = &dpt;
|
dpt.template_decl = d_left (dc);
|
dpt.template_decl = d_left (dc);
|
|
|
d_print_comp (dpi, d_left (d_left (dc)));
|
d_print_comp (dpi, options, d_left (d_left (dc)));
|
|
|
dpi->templates = dpt.next;
|
dpi->templates = dpt.next;
|
|
|
if (d_last_char (dpi) == '<')
|
if (d_last_char (dpi) == '<')
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, '<');
|
d_append_char (dpi, '<');
|
d_print_comp (dpi, d_right (d_left (dc)));
|
d_print_comp (dpi, options, d_right (d_left (dc)));
|
/* Avoid generating two consecutive '>' characters, to avoid
|
/* Avoid generating two consecutive '>' characters, to avoid
|
the C++ syntactic ambiguity. */
|
the C++ syntactic ambiguity. */
|
if (d_last_char (dpi) == '>')
|
if (d_last_char (dpi) == '>')
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, ' ');
|
d_append_char (dpi, '>');
|
d_append_char (dpi, '>');
|