home *** CD-ROM | disk | FTP | other *** search
- *** 1.7 1992/03/18 03:41:26
- --- Changelog 1992/04/19 16:55:39
- ***************
- *** 51,53 ****
- --- 51,58 ----
- various fixes from the net. gprof -s should work better now.
-
- ------------------------------- Patchlevel 6 ---------------------------
- +
- + cplusdem.c:: ++jrb
- + fix up demangler as per util diffs
- +
- + ------------------------------- Patchlevel 7 ---------------------------
- *** 1.8 1992/03/18 03:41:26
- --- PatchLev.h 1992/04/19 16:55:40
- ***************
- *** 1,4 ****
- ! #define PatchLevel "06"
-
- /*
- * the Patch Level above is to identify the version
- --- 1,4 ----
- ! #define PatchLevel "07"
-
- /*
- * the Patch Level above is to identify the version
- *** 1.1 1992/03/08 17:48:29
- --- cplusdem.c 1992/04/19 16:55:40
- ***************
- *** 166,171 ****
- --- 166,177 ----
- "cm", ",", /* ansi */
- "nop", "", /* old (for operator=) */
- "as", "=", /* ansi */
- + "cond", "?:", /* old */
- + "cn", "?:", /* psuedo-ansi */
- + "max", ">?", /* old */
- + "mx", ">?", /* psuedo-ansi */
- + "min", "<?", /* old */
- + "mn", "<?", /* psuedo-ansi */
- };
-
- /* Beware: these aren't '\0' terminated. */
- ***************
- *** 186,194 ****
- static void string_appends (string *p, string *s);
- static void string_appendn (string *p, const char *s, int n);
- static void string_prepend (string *p, const char *s);
- - #if 0
- static void string_prepends (string *p, string *s);
- - #endif
- static void string_prependn (string *p, const char *s, int n);
- static int get_count (const char **type, int *count);
- static int do_args (const char **type, string *decl);
- --- 192,198 ----
- ***************
- *** 195,200 ****
- --- 199,207 ----
- static int do_type (const char **type, string *result);
- static int do_arg (const char **type, string *result);
- static int do_args (const char **type, string *decl);
- + static int do_cuv_prefix (const char **type, string *result, int *non_empty);
- + static int do_builtin_type (const char **type, string *result, int *non_empty);
- + static int do_template_args (const char **type, string *result);
- static void munge_function_name (string *name);
- static void remember_type (const char *type, int len);
- #else
- ***************
- *** 214,219 ****
- --- 221,229 ----
- static int do_type ();
- static int do_arg ();
- static int do_args ();
- + static int do_cuv_prefix ();
- + static int do_builtin_type ();
- + static int do_template_args ();
- static void munge_function_name ();
- static void remember_type ();
- #endif
- ***************
- *** 275,286 ****
- destructor = 1;
- p = type;
- }
- - /* static data member */
- - else if (*type != '_' && (strchr (type, CPLUS_MARKER) != NULL))
- - {
- - static_type = 1;
- - p = type;
- - }
- /* virtual table "_vt$" */
- else if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == CPLUS_MARKER)
- {
- --- 285,290 ----
- ***************
- *** 290,295 ****
- --- 294,305 ----
- strcat (tem, " virtual table");
- return tem;
- }
- + /* static data member */
- + else if (type[0] == '_' && type[1] != '_' && (strchr (type, CPLUS_MARKER) != NULL))
- + {
- + static_type = 1;
- + p = type + 1;
- + }
- else return NULL;
- }
-
- ***************
- *** 323,334 ****
- string_appendn (&decl, "", 1);
- munge_function_name (&decl);
- if (decl.b[0] == '_')
- ! {
- ! string_delete (&decl);
- ! return NULL;
- ! }
- ! else
- ! p += 2;
- }
- else
- {
- --- 333,340 ----
- string_appendn (&decl, "", 1);
- munge_function_name (&decl);
- if (decl.b[0] == '_')
- ! decl.p--;
- ! p += 2;
- }
- else
- {
- ***************
- *** 351,363 ****
- {
- case 'C':
- /* a const member function */
- ! if (!isdigit (p[1]))
- {
- string_delete (&decl);
- return NULL;
- }
- - p += 1;
- - const_flag = 1;
- /* fall through */
- case '0':
- case '1':
- --- 357,371 ----
- {
- case 'C':
- /* a const member function */
- ! p += 1;
- ! const_flag = 1;
- ! if (*p == 't')
- ! goto template;
- ! if (!isdigit (*p))
- {
- string_delete (&decl);
- return NULL;
- }
- /* fall through */
- case '0':
- case '1':
- ***************
- *** 416,597 ****
- break;
- /* template additions */
- case 't':
- p += 1;
- {
- ! int r, i;
- ! int non_empty = 0;
- string tname;
- string trawname;
-
- - string temp;
- - int need_comma = 0;
- -
- string_init(&tname);
- string_init(&trawname);
- !
- /* get template name */
- if (!get_simple_count (&p, &r))
- {
- ! string_delete (&decl);
- ! return 0;
- }
- string_appendn (&tname, p, r);
- string_appendn (&trawname, p, r);
- - string_appendn (&trawname, "", 1);
- p += r;
- string_append (&tname, "<");
- ! /* get size of template parameter list */
- ! if (!get_count (&p, &r))
- ! return 0;
- ! for (i = 0; i < r; i++)
- {
- ! if (need_comma)
- ! string_append (&tname, ", ");
- ! /* Z for type parameters */
- ! if (*p == 'Z')
- ! {
- ! p += 1;
- !
- ! success = do_type (&p, &temp);
- ! string_appendn (&temp, "", 1);
- ! if (success)
- ! string_append (&tname, temp.b);
- ! string_delete(&temp);
- ! if (!success)
- ! break;
- ! }
- ! /* otherwise, value parameter */
- ! else
- ! {
- ! const char *old_p = p;
- ! int is_pointer = 0;
- ! int is_real = 0;
- ! int is_integral = 0;
- ! int done = 0;
- !
- ! success = do_type (&p, &temp);
- ! string_appendn (&temp, "", 1);
- ! if (success)
- ! string_append (&tname, temp.b);
- ! string_delete(&temp);
- ! if (!success)
- ! break;
- ! string_append (&tname, "=");
- ! while (*old_p && !done)
- ! {
- ! switch (*old_p)
- ! {
- ! case 'P':
- ! case 'R':
- ! done = is_pointer = 1;
- ! break;
- ! case 'C': /* const */
- ! case 'U': /* unsigned */
- ! case 'V': /* volatile */
- ! case 'F': /* function */
- ! case 'M': /* member function */
- ! case 'O': /* ??? */
- ! old_p++;
- ! continue;
- ! case 'Q': /* repetition of following */
- ! case 'T': /* remembered type */
- ! abort();
- ! break;
- ! case 'v': /* void */
- ! abort();
- ! break;
- ! case 'x': /* long long */
- ! case 'l': /* long */
- ! case 'i': /* int */
- ! case 's': /* short */
- ! case 'c': /* char */
- ! done = is_integral = 1;
- ! break;
- ! case 'r': /* long double */
- ! case 'd': /* double */
- ! case 'f': /* float */
- ! done = is_real = 1;
- ! break;
- ! default:
- ! abort();
- ! }
- ! }
- ! if (is_integral)
- ! {
- ! if (*p == 'm')
- ! {
- ! string_appendn (&tname, "-", 1);
- ! p++;
- ! }
- ! while (isdigit (*p))
- ! {
- ! string_appendn (&tname, p, 1);
- ! p++;
- ! }
- ! }
- ! else if (is_real)
- ! {
- ! if (*p == 'm')
- ! {
- ! string_appendn (&tname, "-", 1);
- ! p++;
- ! }
- ! while (isdigit (*p))
- ! {
- ! string_appendn (&tname, p, 1);
- ! p++;
- ! }
- ! if (*p == '.') /* fraction */
- ! {
- ! string_appendn (&tname, ".", 1);
- ! p++;
- ! while (isdigit (*p))
- ! {
- ! string_appendn (&tname, p, 1);
- ! p++;
- ! }
- ! }
- ! if (*p == 'e') /* exponent */
- ! {
- ! string_appendn (&tname, "e", 1);
- ! p++;
- ! while (isdigit (*p))
- ! {
- ! string_appendn (&tname, p, 1);
- ! p++;
- ! }
- ! }
- ! }
- ! else if (is_pointer)
- ! {
- ! int symbol_len;
- !
- ! if (!get_count (&p, &symbol_len))
- ! {
- ! success = 0;
- ! break;
- ! }
- ! string_appendn (&tname, p, symbol_len);
- ! p += symbol_len;
- ! }
- ! }
- ! need_comma = 1;
- }
- string_append (&tname, ">::");
- if (destructor)
- string_append(&tname, "~");
- ! if (constructor || destructor) {
- ! string_appendn (&trawname, "", 1);
- ! string_append (&tname, trawname.b);
- ! }
- string_delete(&trawname);
- !
- if (!success) {
- string_delete(&tname);
- return 0;
- }
- ! string_appendn (&tname, "", 1);
- ! string_prepend (&decl, tname.b);
- string_delete (&tname);
-
- if (static_type)
- --- 424,468 ----
- break;
- /* template additions */
- case 't':
- + template:
- p += 1;
- {
- ! int r;
- string tname;
- string trawname;
-
- string_init(&tname);
- string_init(&trawname);
- !
- /* get template name */
- if (!get_simple_count (&p, &r))
- {
- ! success = 0;
- ! break;
- }
- string_appendn (&tname, p, r);
- string_appendn (&trawname, p, r);
- p += r;
- string_append (&tname, "<");
- ! success = do_template_args (&p, &tname);
- ! if (!success)
- {
- ! string_delete (&tname);
- ! string_delete (&trawname);
- ! break;
- }
- string_append (&tname, ">::");
- if (destructor)
- string_append(&tname, "~");
- ! if (constructor || destructor)
- ! string_appends (&tname, &trawname);
- string_delete(&trawname);
- !
- if (!success) {
- string_delete(&tname);
- return 0;
- }
- ! string_prepends (&decl, &tname);
- string_delete (&tname);
-
- if (static_type)
- ***************
- *** 602,609 ****
- }
- else
- success = do_args (&p, &decl);
- ! break;
- }
- }
-
- for (i = 0; i < ntypes; i++)
- --- 473,482 ----
- }
- else
- success = do_args (&p, &decl);
- ! if (const_flag)
- ! string_append (&decl, " const");
- }
- + break;
- }
-
- for (i = 0; i < ntypes; i++)
- ***************
- *** 686,692 ****
- case 'Q':
- n = (*type)[1] - '0';
- if (n < 0 || n > 9)
- ! success = 0;
- *type += 2;
- while (n-- > 0)
- do_type (type, result);
- --- 559,568 ----
- case 'Q':
- n = (*type)[1] - '0';
- if (n < 0 || n > 9)
- ! {
- ! success = 0;
- ! break;
- ! }
- *type += 2;
- while (n-- > 0)
- do_type (type, result);
- ***************
- *** 842,850 ****
- }
- }
-
- ! int
- do_cuv_prefix (type, result, non_empty)
- ! char **type;
- string* result;
- int* non_empty;
- {
- --- 718,726 ----
- }
- }
-
- ! static int
- do_cuv_prefix (type, result, non_empty)
- ! const char **type;
- string* result;
- int* non_empty;
- {
- ***************
- *** 887,895 ****
- return success;
- }
-
- ! int
- do_builtin_type (type, result, non_empty)
- ! char **type;
- string* result;
- int *non_empty;
- {
- --- 763,771 ----
- return success;
- }
-
- ! static int
- do_builtin_type (type, result, non_empty)
- ! const char **type;
- string* result;
- int *non_empty;
- {
- ***************
- *** 991,996 ****
- --- 867,890 ----
- string_appendn (result, *type, n);
- *type += n;
- break;
- + case 't':
- + *type += 1;
- + /* get template name */
- + if (!get_simple_count (type, &n))
- + {
- + success = 0;
- + break;
- + }
- + if (*non_empty)
- + string_append (result, " ");
- + string_appendn (result, *type, n);
- + *type += n;
- + string_append (result, "<");
- + if (!do_template_args (type, result))
- + success = 0;
- + else
- + string_append (result, ">");
- + break;
- default:
- success = 0;
- break;
- ***************
- *** 998,1003 ****
- --- 892,1045 ----
- return success;
- }
-
- + static int
- + do_template_args (type, result)
- + const char **type;
- + string *result;
- + {
- + int r, i;
- +
- + string temp;
- + int need_comma = 0;
- + int success;
- +
- + /* get size of template parameter list */
- + if (!get_count (type, &r))
- + return 0;
- + for (i = 0; i < r; i++)
- + {
- + if (need_comma)
- + string_append (result, ", ");
- + /* Z for type parameters */
- + if (**type == 'Z')
- + {
- + *type += 1;
- +
- + success = do_type (type, &temp);
- + if (success)
- + string_appends (result, &temp);
- + string_delete(&temp);
- + if (!success)
- + break;
- + }
- + /* otherwise, value parameter */
- + else
- + {
- + const char *old_p = *type;
- + int is_pointer = 0;
- + int is_real = 0;
- + int is_integral = 0;
- + int done = 0;
- +
- + success = do_type (type, &temp);
- + if (success)
- + string_appends (result, &temp);
- + string_delete(&temp);
- + if (!success)
- + break;
- + string_append (result, "=");
- + while (*old_p && !done)
- + {
- + switch (*old_p)
- + {
- + case 'P':
- + case 'R':
- + done = is_pointer = 1;
- + break;
- + case 'C': /* const */
- + case 'U': /* unsigned */
- + case 'V': /* volatile */
- + case 'F': /* function */
- + case 'M': /* member function */
- + case 'O': /* ??? */
- + old_p++;
- + continue;
- + case 'Q': /* repetition of following */
- + case 'T': /* remembered type */
- + abort();
- + break;
- + case 'v': /* void */
- + abort();
- + break;
- + case 'x': /* long long */
- + case 'l': /* long */
- + case 'i': /* int */
- + case 's': /* short */
- + case 'c': /* char */
- + done = is_integral = 1;
- + break;
- + case 'r': /* long double */
- + case 'd': /* double */
- + case 'f': /* float */
- + done = is_real = 1;
- + break;
- + default:
- + abort();
- + }
- + }
- + if (is_integral)
- + {
- + if (**type == 'm')
- + {
- + string_appendn (result, "-", 1);
- + *type++;
- + }
- + while (isdigit (**type))
- + {
- + string_appendn (result, *type, 1);
- + *type++;
- + }
- + }
- + else if (is_real)
- + {
- + if (**type == 'm')
- + {
- + string_appendn (result, "-", 1);
- + *type++;
- + }
- + while (isdigit (**type))
- + {
- + string_appendn (result, *type, 1);
- + *type++;
- + }
- + if (**type == '.') /* fraction */
- + {
- + string_appendn (result, ".", 1);
- + *type++;
- + while (isdigit (**type))
- + {
- + string_appendn (result, *type, 1);
- + *type++;
- + }
- + }
- + if (**type == 'e') /* exponent */
- + {
- + string_appendn (result, "e", 1);
- + *type++;
- + while (isdigit (**type))
- + {
- + string_appendn (result, *type, 1);
- + *type++;
- + }
- + }
- + }
- + else if (is_pointer)
- + {
- + int symbol_len;
- +
- + if (!get_count (type, &symbol_len))
- + {
- + success = 0;
- + break;
- + }
- + string_appendn (result, *type, symbol_len);
- + *type += symbol_len;
- + }
- + }
- + need_comma = 1;
- + }
- + }
- +
- /* `result' will be initialised in do_type; it will be freed on failure */
-
- static int
- ***************
- *** 1321,1327 ****
- string_prependn (p, s, strlen (s));
- }
-
- - #if 0
- static void
- string_prepends (p, s)
- string *p, *s;
- --- 1363,1368 ----
- ***************
- *** 1330,1336 ****
- return;
- string_prependn (p, s->b, s->p - s->b);
- }
- - #endif
-
- static void
- string_prependn (p, s, n)
- --- 1371,1376 ----
-