aboutsummaryrefslogtreecommitdiff
path: root/gcc/objc/objc-encoding.c
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2011-07-11 09:42:23 +0000
committerNicola Pero <nicola@gcc.gnu.org>2011-07-11 09:42:23 +0000
commita8f18c40371add2ef647d14127cf91b046570bec (patch)
tree024ae2d04e639fefc111192785d29753f43e2712 /gcc/objc/objc-encoding.c
parent18970372c2159a1ad63e58f1683a01d2bcf3a86f (diff)
downloadgcc-a8f18c40371add2ef647d14127cf91b046570bec.zip
gcc-a8f18c40371add2ef647d14127cf91b046570bec.tar.gz
gcc-a8f18c40371add2ef647d14127cf91b046570bec.tar.bz2
In gcc/objc/: 2011-07-11 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/objc/: 2011-07-11 Nicola Pero <nicola.pero@meta-innovation.com> * objc-encoding.h (obstack.h): Do not include. (util_obstack, util_firstobj): Do not declare. (encode_field_decl): Updated prototype to return a tree and take a single tree argument. Updated comments. * objc-encoding.c (util_obstack, util_firstobj): Made static. (objc_encoding_init): New. (encode_field_decl): Existing function renamed to encode_field and made static. New encode_field_decl wrapper function added. (encode_aggregate_fields): Update call to encode_field_decl to call encode_field. * objc-next-runtime-abi-02.c (obstack.h): Do not include. (util_obstack, util_firstobj): Do not declare. (build_v2_ivar_list_initializer): Updated call to encode_field_decl. * objc-runtime-shared-support.c (obstack.h): Do not include. (util_obstack, util_firstobj): Do not declare. (build_ivar_list_initializer): Updated call to encode_field_decl. * objc-act.c (objc_init): Use objc_encoding_init. * Make-lang.in (objc/objc-runtime-shared-support.o): Do not depend on OBSTACK_H. (objc/objc-gnu-runtime-abi-01.o): Likewise. (objc/objc-next-runtime-abi-01.o): Likewise. (objc/objc-next-runtime-abi-02.o): Likewise. (objc/objc-act.o): Likewise. In gcc/objcp/: 2011-07-11 Nicola Pero <nicola.pero@meta-innovation.com> * Make-lang.in (objcp/objc-runtime-shared-support.o): Do not depend on OBSTACK_H. (objcp/objc-gnu-runtime-abi-01.o): Likewise. (objcp/objc-next-runtime-abi-01.o): Likewise. (objcp/objc-next-runtime-abi-02.o): Likewise. (objcp/objcp-act.o): Likewise. From-SVN: r176139
Diffstat (limited to 'gcc/objc/objc-encoding.c')
-rw-r--r--gcc/objc/objc-encoding.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/gcc/objc/objc-encoding.c b/gcc/objc/objc-encoding.c
index cb1d0c4..10171fd 100644
--- a/gcc/objc/objc-encoding.c
+++ b/gcc/objc/objc-encoding.c
@@ -53,18 +53,24 @@ along with GCC; see the file COPYING3. If not see
/* Set up for use of obstacks. */
#include "obstack.h"
-/* This obstack is used to accumulate the encoding of a data type.
- TODO: Make this static. */
-struct obstack util_obstack;
+/* This obstack is used to accumulate the encoding of a data type. */
+static struct obstack util_obstack;
/* This points to the beginning of obstack contents, so we can free
- the whole contents. TODO: Make this static. */
-char *util_firstobj;
+ the whole contents. */
+static char *util_firstobj;
+
+void objc_encoding_init (void)
+{
+ gcc_obstack_init (&util_obstack);
+ util_firstobj = (char *) obstack_finish (&util_obstack);
+}
int generating_instance_variables = 0;
static void encode_type_qualifiers (tree);
static void encode_type (tree, int, int);
+static void encode_field (tree field_decl, int curtype, int format);
static tree
objc_method_parm_type (tree type)
@@ -470,7 +476,7 @@ encode_aggregate_fields (tree type, bool pointed_to, int curtype, int format)
obstack_1grow (&util_obstack, '"');
}
- encode_field_decl (field, curtype, format);
+ encode_field (field, curtype, format);
}
}
@@ -802,8 +808,8 @@ encode_gnu_bitfield (int position, tree type, int size)
obstack_grow (&util_obstack, buffer, strlen (buffer));
}
-void
-encode_field_decl (tree field_decl, int curtype, int format)
+static void
+encode_field (tree field_decl, int curtype, int format)
{
#ifdef OBJCPLUS
/* C++ static members, and things that are not fields at all,
@@ -828,6 +834,25 @@ encode_field_decl (tree field_decl, int curtype, int format)
encode_type (TREE_TYPE (field_decl), curtype, format);
}
+tree
+encode_field_decl (tree field_decl)
+{
+ tree result;
+
+ encode_field (field_decl,
+ obstack_object_size (&util_obstack),
+ OBJC_ENCODE_DONT_INLINE_DEFS);
+
+ /* Null terminate string. */
+ obstack_1grow (&util_obstack, 0);
+
+ /* Get identifier for the string. */
+ result = get_identifier (XOBFINISH (&util_obstack, char *));
+ obstack_free (&util_obstack, util_firstobj);
+
+ return result;
+}
+
/* This routine encodes the attribute of the input PROPERTY according
to following formula: