* cplus-dem.c: Sync with gcc.
From-SVN: r19077
This commit is contained in:
parent
963686319f
commit
9ee02b5c40
2 changed files with 162 additions and 21 deletions
|
@ -1,3 +1,7 @@
|
|||
Fri Apr 10 01:45:09 1998 Jeffrey A Law (law@cygnus.com)
|
||||
|
||||
* cplus-dem.c: Sync with gcc.
|
||||
|
||||
Thu Apr 2 13:53:54 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
|
||||
|
||||
* choose-temp.c: Include system.h when IN_GCC.
|
||||
|
|
|
@ -29,9 +29,14 @@ Boston, MA 02111-1307, USA. */
|
|||
try not to break either. */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <demangle.h>
|
||||
#undef CURRENT_DEMANGLING_STYLE
|
||||
#define CURRENT_DEMANGLING_STYLE work->options
|
||||
|
@ -223,6 +228,10 @@ static int
|
|||
demangle_method_args PARAMS ((struct work_stuff *work, const char **, string *));
|
||||
#endif
|
||||
|
||||
static int
|
||||
demangle_template_template_parm PARAMS ((struct work_stuff *work,
|
||||
const char **, string *));
|
||||
|
||||
static int
|
||||
demangle_template PARAMS ((struct work_stuff *work, const char **, string *,
|
||||
string *, int));
|
||||
|
@ -257,7 +266,7 @@ static int
|
|||
gnu_special PARAMS ((struct work_stuff *, const char **, string *));
|
||||
|
||||
static int
|
||||
arm_special PARAMS ((struct work_stuff *, const char **, string *));
|
||||
arm_special PARAMS ((const char **, string *));
|
||||
|
||||
static void
|
||||
string_need PARAMS ((string *, int));
|
||||
|
@ -347,7 +356,7 @@ consume_count (type)
|
|||
}
|
||||
|
||||
|
||||
/* Like consume_count, but for counts that are preceeded and followed
|
||||
/* Like consume_count, but for counts that are preceded and followed
|
||||
by '_' if they are greater than 10. Also, -1 is returned for
|
||||
failure, since 0 can be a valid value. */
|
||||
|
||||
|
@ -843,7 +852,7 @@ demangle_signature (work, mangled, declp)
|
|||
}
|
||||
else
|
||||
/* fall through */
|
||||
;
|
||||
{;}
|
||||
|
||||
default:
|
||||
if (AUTO_DEMANGLING || GNU_DEMANGLING)
|
||||
|
@ -927,6 +936,70 @@ demangle_method_args (work, mangled, declp)
|
|||
|
||||
#endif
|
||||
|
||||
static int
|
||||
demangle_template_template_parm (work, mangled, tname)
|
||||
struct work_stuff *work;
|
||||
const char **mangled;
|
||||
string *tname;
|
||||
{
|
||||
int i;
|
||||
int r;
|
||||
int need_comma = 0;
|
||||
int success = 1;
|
||||
string temp;
|
||||
|
||||
string_append (tname, "template <");
|
||||
/* get size of template parameter list */
|
||||
if (get_count (mangled, &r))
|
||||
{
|
||||
for (i = 0; i < r; i++)
|
||||
{
|
||||
if (need_comma)
|
||||
{
|
||||
string_append (tname, ", ");
|
||||
}
|
||||
|
||||
/* Z for type parameters */
|
||||
if (**mangled == 'Z')
|
||||
{
|
||||
(*mangled)++;
|
||||
string_append (tname, "class");
|
||||
}
|
||||
/* z for template parameters */
|
||||
else if (**mangled == 'z')
|
||||
{
|
||||
(*mangled)++;
|
||||
success =
|
||||
demangle_template_template_parm (work, mangled, tname);
|
||||
if (!success)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* temp is initialized in do_type */
|
||||
success = do_type (work, mangled, &temp);
|
||||
if (success)
|
||||
{
|
||||
string_appends (tname, &temp);
|
||||
}
|
||||
string_delete(&temp);
|
||||
if (!success)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
need_comma = 1;
|
||||
}
|
||||
|
||||
}
|
||||
if (tname->p[-1] == '>')
|
||||
string_append (tname, " ");
|
||||
string_append (tname, "> class");
|
||||
return (success);
|
||||
}
|
||||
|
||||
static int
|
||||
demangle_integral_value (work, mangled, s)
|
||||
struct work_stuff *work;
|
||||
|
@ -1212,19 +1285,50 @@ demangle_template (work, mangled, tname, trawname, is_type)
|
|||
{
|
||||
start = *mangled;
|
||||
/* get template name */
|
||||
if ((r = consume_count (mangled)) == 0 || strlen (*mangled) < r)
|
||||
if (**mangled == 'z')
|
||||
{
|
||||
return (0);
|
||||
int idx;
|
||||
(*mangled)++;
|
||||
(*mangled)++;
|
||||
|
||||
idx = consume_count_with_underscores (mangled);
|
||||
if (idx == -1
|
||||
|| (work->tmpl_argvec && idx >= work->ntmpl_args)
|
||||
|| consume_count_with_underscores (mangled) == -1)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
if (work->tmpl_argvec)
|
||||
{
|
||||
string_append (tname, work->tmpl_argvec[idx]);
|
||||
if (trawname)
|
||||
string_append (trawname, work->tmpl_argvec[idx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[10];
|
||||
sprintf(buf, "T%d", idx);
|
||||
string_append (tname, buf);
|
||||
if (trawname)
|
||||
string_append (trawname, work->tmpl_argvec[idx]);
|
||||
}
|
||||
}
|
||||
if (trawname)
|
||||
string_appendn (trawname, *mangled, r);
|
||||
is_java_array = (work -> options & DMGL_JAVA)
|
||||
&& strncmp (*mangled, "JArray1Z", 8) == 0;
|
||||
if (! is_java_array)
|
||||
else
|
||||
{
|
||||
string_appendn (tname, *mangled, r);
|
||||
if ((r = consume_count (mangled)) == 0 || strlen (*mangled) < r)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
if (trawname)
|
||||
string_appendn (trawname, *mangled, r);
|
||||
is_java_array = (work -> options & DMGL_JAVA)
|
||||
&& strncmp (*mangled, "JArray1Z", 8) == 0;
|
||||
if (! is_java_array)
|
||||
{
|
||||
string_appendn (tname, *mangled, r);
|
||||
}
|
||||
*mangled += r;
|
||||
}
|
||||
*mangled += r;
|
||||
}
|
||||
if (!is_java_array)
|
||||
string_append (tname, "<");
|
||||
|
@ -1272,6 +1376,33 @@ demangle_template (work, mangled, tname, trawname, is_type)
|
|||
break;
|
||||
}
|
||||
}
|
||||
/* z for template parameters */
|
||||
else if (**mangled == 'z')
|
||||
{
|
||||
int r2;
|
||||
(*mangled)++;
|
||||
success = demangle_template_template_parm (work, mangled, tname);
|
||||
|
||||
if (success
|
||||
&& (r2 = consume_count (mangled)) > 0 && strlen (*mangled) >= r2)
|
||||
{
|
||||
string_append (tname, " ");
|
||||
string_appendn (tname, *mangled, r2);
|
||||
if (!is_type)
|
||||
{
|
||||
/* Save the template argument. */
|
||||
int len = r2;
|
||||
work->tmpl_argvec[i] = xmalloc (len + 1);
|
||||
memcpy (work->tmpl_argvec[i], *mangled, len);
|
||||
work->tmpl_argvec[i][len] = '\0';
|
||||
}
|
||||
*mangled += r2;
|
||||
}
|
||||
if (!success)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string param;
|
||||
|
@ -1644,7 +1775,7 @@ demangle_prefix (work, mangled, declp)
|
|||
then find the next "__" that separates the prefix from the signature.
|
||||
*/
|
||||
if (!(ARM_DEMANGLING || LUCID_DEMANGLING)
|
||||
|| (arm_special (work, mangled, declp) == 0))
|
||||
|| (arm_special (mangled, declp) == 0))
|
||||
{
|
||||
while (*scan == '_')
|
||||
{
|
||||
|
@ -1897,8 +2028,8 @@ LOCAL FUNCTION
|
|||
SYNOPSIS
|
||||
|
||||
static int
|
||||
arm_special (struct work_stuff *work, const char **mangled,
|
||||
string *declp);
|
||||
arm_special (const char **mangled,
|
||||
string *declp);
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
|
@ -1912,8 +2043,7 @@ DESCRIPTION
|
|||
*/
|
||||
|
||||
static int
|
||||
arm_special (work, mangled, declp)
|
||||
struct work_stuff *work;
|
||||
arm_special (mangled, declp)
|
||||
const char **mangled;
|
||||
string *declp;
|
||||
{
|
||||
|
@ -2409,7 +2539,6 @@ do_type (work, mangled, result)
|
|||
/* A template parm. We substitute the corresponding argument. */
|
||||
{
|
||||
int idx;
|
||||
int lvl;
|
||||
|
||||
(*mangled)++;
|
||||
idx = consume_count_with_underscores (mangled);
|
||||
|
@ -2865,8 +2994,7 @@ demangle_function_name (work, mangled, declp, scan)
|
|||
string *declp;
|
||||
const char *scan;
|
||||
{
|
||||
int i;
|
||||
int len;
|
||||
size_t i;
|
||||
string type;
|
||||
const char *tem;
|
||||
|
||||
|
@ -2913,7 +3041,7 @@ demangle_function_name (work, mangled, declp, scan)
|
|||
{
|
||||
for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
|
||||
{
|
||||
len = declp->p - declp->b - 10;
|
||||
int len = declp->p - declp->b - 10;
|
||||
if (strlen (optable[i].in) == len
|
||||
&& memcmp (optable[i].in, declp->b + 10, len) == 0)
|
||||
{
|
||||
|
@ -3223,6 +3351,15 @@ static struct option long_options[] = {
|
|||
{0, no_argument, 0, 0}
|
||||
};
|
||||
|
||||
/* More 'friendly' abort that prints the line and file.
|
||||
config.h can #define abort fancy_abort if you like that sort of thing. */
|
||||
|
||||
void
|
||||
fancy_abort ()
|
||||
{
|
||||
fatal ("Internal gcc abort.");
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
|
|
Loading…
Add table
Reference in a new issue