Commit 06e67e16 by Nicola Pero Committed by Nicola Pero

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
parent 06f1db4b
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> 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>
PR objc/45763 PR objc/45763
......
...@@ -8197,7 +8197,7 @@ encode_vector (tree type, int curtype, int format) ...@@ -8197,7 +8197,7 @@ encode_vector (tree type, int curtype, int format)
} }
static void 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); tree field = TYPE_FIELDS (type);
...@@ -8250,14 +8250,14 @@ encode_aggregate_within (tree type, int curtype, int format, int left, ...@@ -8250,14 +8250,14 @@ encode_aggregate_within (tree type, int curtype, int format, int left,
if (flag_next_runtime) if (flag_next_runtime)
{ {
pointed_to = (ob_size > 0 if (ob_size > 0 && *(obstack_next_free (&util_obstack) - 1) == '^')
? *(obstack_next_free (&util_obstack) - 1) == '^' pointed_to = true;
: 0);
inline_contents = ((format == OBJC_ENCODE_INLINE_DEFS || generating_instance_variables) if ((format == OBJC_ENCODE_INLINE_DEFS || generating_instance_variables)
&& (!pointed_to && (!pointed_to || ob_size - curtype == 1
|| ob_size - curtype == 1 || (ob_size - curtype == 2
|| (ob_size - curtype == 2 && *(obstack_next_free (&util_obstack) - 2) == 'r')))
&& *(obstack_next_free (&util_obstack) - 2) == 'r'))); inline_contents = true;
} }
else else
{ {
...@@ -8279,27 +8279,19 @@ encode_aggregate_within (tree type, int curtype, int format, int left, ...@@ -8279,27 +8279,19 @@ encode_aggregate_within (tree type, int curtype, int format, int left,
inline_contents = true; inline_contents = true;
else else
{ {
/* FIXME: It's hard to understand what the following /* Note that the check (ob_size - curtype < 2) prevents
code is meant to be doing. It seems that it will infinite recursion when encoding a structure which is
inline contents even if we are encoding a pointed a linked list (eg, struct node { struct node *next;
structure and the last characters were 'r^' or just }). 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
So it seems that in the end the only case where we break the loop.
don't inline contents is '^r', which is a pointer to
a 'const' structure! If that is the case, the whole The other case where we don't inline is "^r", which
blob of code could be rewritten in a simpler way. is a pointer to a constant struct.
*/ */
if (c1 == 'r') if ((ob_size - curtype <= 2) && !(c0 == 'r'))
{ inline_contents = true;
if (ob_size - curtype == 2)
inline_contents = true;
}
else
{
if (ob_size - curtype == 1)
inline_contents = true;
}
} }
} }
} }
...@@ -8372,8 +8364,11 @@ encode_type (tree type, int curtype, int format) ...@@ -8372,8 +8364,11 @@ encode_type (tree type, int curtype, int format)
if (type == error_mark_node) if (type == error_mark_node)
return; return;
if (TYPE_READONLY (type)) if (!flag_next_runtime)
obstack_1grow (&util_obstack, 'r'); {
if (TYPE_READONLY (type))
obstack_1grow (&util_obstack, 'r');
}
switch (code) switch (code)
{ {
......
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