In gcc/objc/: 2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>

In gcc/objc/:
2010-09-28  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc-act.c (encode_type): Do not add 'r' with the next runtime.
        (encode_aggregate_within): Reorganized code to be more readable.
        (encode_aggregate_fields): Updated second argument to be 'bool'
        instead of 'int'.

From-SVN: r164680
This commit is contained in:
Nicola Pero 2010-09-28 09:54:51 +00:00 committed by Nicola Pero
parent 06f1db4b1c
commit 06e67e167d
2 changed files with 32 additions and 30 deletions

View File

@ -1,3 +1,10 @@
2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (encode_type): Do not add 'r' with the next runtime.
(encode_aggregate_within): Reorganized code to be more readable.
(encode_aggregate_fields): Updated second argument to be 'bool'
instead of 'int'.
2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>
PR objc/45763

View File

@ -8197,7 +8197,7 @@ encode_vector (tree type, int curtype, int format)
}
static void
encode_aggregate_fields (tree type, int pointed_to, int curtype, int format)
encode_aggregate_fields (tree type, bool pointed_to, int curtype, int format)
{
tree field = TYPE_FIELDS (type);
@ -8250,14 +8250,14 @@ encode_aggregate_within (tree type, int curtype, int format, int left,
if (flag_next_runtime)
{
pointed_to = (ob_size > 0
? *(obstack_next_free (&util_obstack) - 1) == '^'
: 0);
inline_contents = ((format == OBJC_ENCODE_INLINE_DEFS || generating_instance_variables)
&& (!pointed_to
|| ob_size - curtype == 1
|| (ob_size - curtype == 2
&& *(obstack_next_free (&util_obstack) - 2) == 'r')));
if (ob_size > 0 && *(obstack_next_free (&util_obstack) - 1) == '^')
pointed_to = true;
if ((format == OBJC_ENCODE_INLINE_DEFS || generating_instance_variables)
&& (!pointed_to || ob_size - curtype == 1
|| (ob_size - curtype == 2
&& *(obstack_next_free (&util_obstack) - 2) == 'r')))
inline_contents = true;
}
else
{
@ -8279,27 +8279,19 @@ encode_aggregate_within (tree type, int curtype, int format, int left,
inline_contents = true;
else
{
/* FIXME: It's hard to understand what the following
code is meant to be doing. It seems that it will
inline contents even if we are encoding a pointed
structure and the last characters were 'r^' or just
'^'.
/* Note that the check (ob_size - curtype < 2) prevents
infinite recursion when encoding a structure which is
a linked list (eg, struct node { struct node *next;
}). Each time we follow a pointer, we add one
character to ob_size, and curtype is fixed, so after
at most two pointers we stop inlining contents and
break the loop.
So it seems that in the end the only case where we
don't inline contents is '^r', which is a pointer to
a 'const' structure! If that is the case, the whole
blob of code could be rewritten in a simpler way.
The other case where we don't inline is "^r", which
is a pointer to a constant struct.
*/
if (c1 == 'r')
{
if (ob_size - curtype == 2)
inline_contents = true;
}
else
{
if (ob_size - curtype == 1)
inline_contents = true;
}
if ((ob_size - curtype <= 2) && !(c0 == 'r'))
inline_contents = true;
}
}
}
@ -8372,8 +8364,11 @@ encode_type (tree type, int curtype, int format)
if (type == error_mark_node)
return;
if (TYPE_READONLY (type))
obstack_1grow (&util_obstack, 'r');
if (!flag_next_runtime)
{
if (TYPE_READONLY (type))
obstack_1grow (&util_obstack, 'r');
}
switch (code)
{