diff options
author | David Daney <ddaney@avtrex.com> | 2008-01-27 06:25:45 +0000 |
---|---|---|
committer | David Daney <ddaney@avtrex.com> | 2008-01-27 06:25:45 +0000 |
commit | 830ef6349cb14a656a04d20859b7a34433ab67b6 (patch) | |
tree | 9cba040d0b7071e2e5ed08b5b858df5ff6242e39 /libiberty/cp-demangle.c | |
parent | 3880c9e785cf1e555f0be6753c40a9625ab67f83 (diff) | |
download | gdb-830ef6349cb14a656a04d20859b7a34433ab67b6.zip gdb-830ef6349cb14a656a04d20859b7a34433ab67b6.tar.gz gdb-830ef6349cb14a656a04d20859b7a34433ab67b6.tar.bz2 |
include/
2008-01-26 David Daney <ddaney@avtrex.com>
* demangle.h (demangle_component_type): Add
DEMANGLE_COMPONENT_JAVA_RESOURCE,
DEMANGLE_COMPONENT_COMPOUND_NAME, and
DEMANGLE_COMPONENT_CHARACTER as new enum values.
(demangle_component): Add struct s_character to union u.
libiberty/
2008-01-26 David Daney <ddaney@avtrex.com>
* cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_JAVA_RESOURCE,
DEMANGLE_COMPONENT_COMPOUND_NAME, and
DEMANGLE_COMPONENT_CHARACTER cases.
(d_make_comp): Handle DEMANGLE_COMPONENT_COMPOUND_NAME and
DEMANGLE_COMPONENT_JAVA_RESOURCE cases.
(d_make_character): New function.
(d_java_resource): Same.
(d_special_name): Handle "Gr" case.
(d_print_comp): Handle DEMANGLE_COMPONENT_JAVA_RESOURCE,
DEMANGLE_COMPONENT_COMPOUND_NAME, and
DEMANGLE_COMPONENT_CHARACTER cases.
* testsuite/demangle-expected: Add test for java resource name
mangling.
Diffstat (limited to 'libiberty/cp-demangle.c')
-rw-r--r-- | libiberty/cp-demangle.c | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 3fc6a21..edcfedc 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -650,6 +650,15 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_LITERAL_NEG: printf ("negative literal\n"); break; + case DEMANGLE_COMPONENT_JAVA_RESOURCE: + printf ("java resource\n"); + break; + case DEMANGLE_COMPONENT_COMPOUND_NAME: + printf ("compound name\n"); + break; + case DEMANGLE_COMPONENT_CHARACTER: + printf ("character '%c'\n", dc->u.s_character.character); + return; } d_dump (d_left (dc), indent + 2); @@ -769,6 +778,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_TRINARY_ARG2: case DEMANGLE_COMPONENT_LITERAL: case DEMANGLE_COMPONENT_LITERAL_NEG: + case DEMANGLE_COMPONENT_COMPOUND_NAME: if (left == NULL || right == NULL) return NULL; break; @@ -795,6 +805,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_ARGLIST: case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: case DEMANGLE_COMPONENT_CAST: + case DEMANGLE_COMPONENT_JAVA_RESOURCE: if (left == NULL) return NULL; break; @@ -1501,6 +1512,102 @@ d_operator_name (struct d_info *di) } } +static struct demangle_component * +d_make_character (struct d_info *di, int c) +{ + struct demangle_component *p; + p = d_make_empty (di); + if (p != NULL) + { + p->type = DEMANGLE_COMPONENT_CHARACTER; + p->u.s_character.character = c; + } + return p; +} + +static struct demangle_component * +d_java_resource (struct d_info *di) +{ + struct demangle_component *p = NULL; + struct demangle_component *next = NULL; + long len, i; + char c; + const char *str; + + len = d_number (di); + if (len <= 1) + return NULL; + + /* Eat the leading '_'. */ + if (d_next_char (di) != '_') + return NULL; + len--; + + str = d_str (di); + i = 0; + + while (len > 0) + { + c = str[i]; + if (!c) + return NULL; + + /* Each chunk is either a '$' escape... */ + if (c == '$') + { + i++; + switch (str[i++]) + { + case 'S': + c = '/'; + break; + case '_': + c = '.'; + break; + case '$': + c = '$'; + break; + default: + return NULL; + } + next = d_make_character (di, c); + d_advance (di, i); + str = d_str (di); + len -= i; + i = 0; + if (next == NULL) + return NULL; + } + /* ... or a sequence of characters. */ + else + { + while (i < len && str[i] && str[i] != '$') + i++; + + next = d_make_name (di, str, i); + d_advance (di, i); + str = d_str (di); + len -= i; + i = 0; + if (next == NULL) + return NULL; + } + + if (p == NULL) + p = next; + else + { + p = d_make_comp (di, DEMANGLE_COMPONENT_COMPOUND_NAME, p, next); + if (p == NULL) + return NULL; + } + } + + p = d_make_comp (di, DEMANGLE_COMPONENT_JAVA_RESOURCE, p, NULL); + + return p; +} + /* <special-name> ::= TV <type> ::= TT <type> ::= TI <type> @@ -1514,6 +1621,7 @@ d_operator_name (struct d_info *di) ::= TJ <type> ::= GR <name> ::= GA <encoding> + ::= Gr <resource name> */ static struct demangle_component * @@ -1605,6 +1713,9 @@ d_special_name (struct d_info *di) return d_make_comp (di, DEMANGLE_COMPONENT_HIDDEN_ALIAS, d_encoding (di, 0), NULL); + case 'r': + return d_java_resource (di); + default: return NULL; } @@ -3552,6 +3663,20 @@ d_print_comp (struct d_print_info *dpi, } return; + case DEMANGLE_COMPONENT_JAVA_RESOURCE: + d_append_string (dpi, "java resource "); + d_print_comp (dpi, d_left (dc)); + return; + + case DEMANGLE_COMPONENT_COMPOUND_NAME: + d_print_comp (dpi, d_left (dc)); + d_print_comp (dpi, d_right (dc)); + return; + + case DEMANGLE_COMPONENT_CHARACTER: + d_append_char (dpi, dc->u.s_character.character); + return; + default: d_print_error (dpi); return; |