Commit f921acee by Jason Merrill Committed by Jason Merrill

method.c (old_backref_index): Split out...

	* method.c (old_backref_index): Split out...
	(flush_repeats): From here.  Rename back from try_old_backref.
	(build_mangled_name): Put back some old-style repeat handling.

From-SVN: r25809
parent 8fe57f78
1999-03-16 Jason Merrill <jason@yorick.cygnus.com>
* method.c (old_backref_index): Split out...
(flush_repeats): From here. Rename back from try_old_backref.
(build_mangled_name): Put back some old-style repeat handling.
Mon Mar 15 21:57:16 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> Mon Mar 15 21:57:16 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* lex.c: Don't include setjmp.h. * lex.c: Don't include setjmp.h.
......
...@@ -57,7 +57,8 @@ static char *scratch_firstobj; ...@@ -57,7 +57,8 @@ static char *scratch_firstobj;
static void icat PROTO((HOST_WIDE_INT)); static void icat PROTO((HOST_WIDE_INT));
static void dicat PROTO((HOST_WIDE_INT, HOST_WIDE_INT)); static void dicat PROTO((HOST_WIDE_INT, HOST_WIDE_INT));
static int try_old_backref PROTO((tree)); static int old_backref_index PROTO((tree));
static int flush_repeats PROTO((int, tree));
static void build_overload_identifier PROTO((tree)); static void build_overload_identifier PROTO((tree));
static void build_overload_nested_name PROTO((tree)); static void build_overload_nested_name PROTO((tree));
static void build_overload_int PROTO((tree, int)); static void build_overload_int PROTO((tree, int));
...@@ -299,17 +300,16 @@ dicat (lo, hi) ...@@ -299,17 +300,16 @@ dicat (lo, hi)
OB_PUTC ('0' + ulo); OB_PUTC ('0' + ulo);
} }
/* Old mangling style: If TYPE has already been used in the parameter list, /* Returns the index of TYPE in the typevec, or -1 if it's not there. */
emit a backward reference and return non-zero; otherwise, return 0. */
static __inline int static __inline int
try_old_backref (type) old_backref_index (type)
tree type; tree type;
{ {
int tindex = 0; int tindex = 0;
if (! is_back_referenceable_type (type)) if (! is_back_referenceable_type (type))
return 0; return -1;
/* The entry for this parm is at maxtype-1, so don't look there for /* The entry for this parm is at maxtype-1, so don't look there for
something to repeat. */ something to repeat. */
...@@ -318,9 +318,40 @@ try_old_backref (type) ...@@ -318,9 +318,40 @@ try_old_backref (type)
break; break;
if (tindex == maxtype - 1) if (tindex == maxtype - 1)
return 0; return -1;
return tindex;
}
/* Old mangling style: If TYPE has already been used in the parameter list,
emit a backward reference and return non-zero; otherwise, return 0.
NREPEATS is the number of repeats we've recorded of this type, or 0 if
this is the first time we've seen it and we're just looking to see if
it had been used before. */
static __inline int
flush_repeats (nrepeats, type)
int nrepeats;
tree type;
{
int tindex = old_backref_index (type);
if (tindex == -1)
{
my_friendly_assert (nrepeats == 0, 990316);
return 0;
}
OB_PUTC ('T'); if (nrepeats > 1)
{
OB_PUTC ('N');
icat (nrepeats);
if (nrepeats > 9)
OB_PUTC ('_');
}
else
OB_PUTC ('T');
icat (tindex); icat (tindex);
if (tindex > 9) if (tindex > 9)
OB_PUTC ('_'); OB_PUTC ('_');
...@@ -1129,17 +1160,16 @@ build_mangled_name (parmtypes, begin, end) ...@@ -1129,17 +1160,16 @@ build_mangled_name (parmtypes, begin, end)
if (old_style_repeats) if (old_style_repeats)
{ {
/* Note that for bug-compatibility with 2.7.2, we can't build
up repeats. So we call try_old_backref (formerly
flush_repeats) every round, and only emit Tn codes. */
/* Every argument gets counted. */ /* Every argument gets counted. */
my_friendly_assert (maxtype < typevec_size, 387); my_friendly_assert (maxtype < typevec_size, 387);
typevec[maxtype++] = parmtype; typevec[maxtype++] = parmtype;
} }
else if (flag_do_squangling)
if (last_type && same_type_p (parmtype, last_type))
{ {
if (last_type && same_type_p (parmtype, last_type)) if (flag_do_squangling
|| (old_style_repeats
&& is_back_referenceable_type (parmtype)))
{ {
/* The next type is the same as this one. Keep /* The next type is the same as this one. Keep
track of the repetition, and output the repeat track of the repetition, and output the repeat
...@@ -1147,18 +1177,24 @@ build_mangled_name (parmtypes, begin, end) ...@@ -1147,18 +1177,24 @@ build_mangled_name (parmtypes, begin, end)
nrepeats++; nrepeats++;
continue; continue;
} }
else if (nrepeats != 0) }
{ else if (nrepeats != 0)
/* Indicate how many times the previous parameter was {
repeated. */ /* Indicate how many times the previous parameter was
issue_nrepeats (nrepeats, last_type); repeated. */
nrepeats = 0; if (old_style_repeats)
} flush_repeats (nrepeats, last_type);
else
issue_nrepeats (nrepeats, last_type);
nrepeats = 0;
} }
last_type = parmtype; last_type = parmtype;
if (old_style_repeats && try_old_backref (parmtype)) /* Note that for bug-compatibility with 2.7.2, we can't build up
repeats of types other than the most recent one. So we call
flush_repeats every round, if we get this far. */
if (old_style_repeats && flush_repeats (0, parmtype))
continue; continue;
/* Output the PARMTYPE. */ /* Output the PARMTYPE. */
...@@ -1169,7 +1205,10 @@ build_mangled_name (parmtypes, begin, end) ...@@ -1169,7 +1205,10 @@ build_mangled_name (parmtypes, begin, end)
necessary. */ necessary. */
if (nrepeats != 0) if (nrepeats != 0)
{ {
issue_nrepeats (nrepeats, last_type); if (old_style_repeats)
flush_repeats (nrepeats, last_type);
else
issue_nrepeats (nrepeats, last_type);
nrepeats = 0; nrepeats = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment