diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2011-07-11 09:42:23 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2011-07-11 09:42:23 +0000 |
commit | a8f18c40371add2ef647d14127cf91b046570bec (patch) | |
tree | 024ae2d04e639fefc111192785d29753f43e2712 /gcc/objc | |
parent | 18970372c2159a1ad63e58f1683a01d2bcf3a86f (diff) | |
download | gcc-a8f18c40371add2ef647d14127cf91b046570bec.tar.gz |
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')
-rw-r--r-- | gcc/objc/ChangeLog | 27 | ||||
-rw-r--r-- | gcc/objc/Make-lang.in | 5 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 4 | ||||
-rw-r--r-- | gcc/objc/objc-encoding.c | 41 | ||||
-rw-r--r-- | gcc/objc/objc-encoding.h | 25 | ||||
-rw-r--r-- | gcc/objc/objc-next-runtime-abi-02.c | 13 | ||||
-rw-r--r-- | gcc/objc/objc-runtime-shared-support.c | 15 |
7 files changed, 69 insertions, 61 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index e2741977546..b5cae8e0de5 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,30 @@ +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. + 2011-07-04 Nicola Pero <nicola.pero@meta-innovation.com> Refactored encoding code into objc-encoding.h and objc-encoding.c. diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in index 1ac74ba4549..f9b3907fe1c 100644 --- a/gcc/objc/Make-lang.in +++ b/gcc/objc/Make-lang.in @@ -88,7 +88,6 @@ objc/objc-runtime-shared-support.o : objc/objc-runtime-shared-support.c \ gt-objc-objc-runtime-shared-support.h \ $(START_HDRS) \ $(GGC_H) $(DIAGNOSTIC_CORE_H) $(FLAGS_H) input.h \ - $(OBSTACK_H) \ objc/objc-encoding.h \ objc/objc-next-metadata-tags.h \ objc/objc-runtime-shared-support.h @@ -97,7 +96,6 @@ objc/objc-gnu-runtime-abi-01.o: objc/objc-gnu-runtime-abi-01.c \ gt-objc-objc-gnu-runtime-abi-01.h \ $(START_HDRS) \ $(GGC_H) $(DIAGNOSTIC_CORE_H) $(FLAGS_H) input.h \ - $(OBSTACK_H) \ toplev.h \ objc/objc-encoding.h \ objc/objc-runtime-hooks.h \ @@ -107,7 +105,6 @@ objc/objc-next-runtime-abi-01.o: objc/objc-next-runtime-abi-01.c \ gt-objc-objc-next-runtime-abi-01.h \ $(START_HDRS) \ $(GGC_H) $(DIAGNOSTIC_CORE_H) $(FLAGS_H) input.h \ - $(OBSTACK_H) \ $(TARGET_H) output.h \ objc/objc-encoding.h \ objc/objc-next-metadata-tags.h \ @@ -118,7 +115,6 @@ objc/objc-next-runtime-abi-02.o: objc/objc-next-runtime-abi-02.c \ gt-objc-objc-next-runtime-abi-02.h \ $(START_HDRS) \ $(GGC_H) $(DIAGNOSTIC_CORE_H) $(FLAGS_H) input.h \ - $(OBSTACK_H) \ $(TARGET_H) \ objc/objc-encoding.h \ objc/objc-next-metadata-tags.h \ @@ -129,7 +125,6 @@ objc/objc-act.o : objc/objc-act.c \ gt-objc-objc-act.h \ $(START_HDRS) \ $(GGC_H) $(DIAGNOSTIC_CORE_H) $(FLAGS_H) input.h \ - $(OBSTACK_H) \ toplev.h $(FUNCTION_H) output.h debug.h $(LANGHOOKS_DEF_H) \ $(HASHTAB_H) $(GIMPLE_H) \ $(C_PRAGMA_H) $(C_TARGET_H) \ diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 14db224df75..72a486d9c83 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -381,9 +381,7 @@ objc_init (void) /* Set up stuff used by FE parser and all runtimes. */ errbuf = XNEWVEC (char, 1024 * 10); hash_init (); - /* TODO: Use objc_encoding_init(). */ - gcc_obstack_init (&util_obstack); - util_firstobj = (char *) obstack_finish (&util_obstack); + objc_encoding_init (); /* ... and then check flags and set-up for the selected runtime ... */ if (flag_next_runtime && flag_objc_abi >= 2) ok = objc_next_runtime_abi_02_init (&runtime); diff --git a/gcc/objc/objc-encoding.c b/gcc/objc/objc-encoding.c index cb1d0c4e992..10171fdd2c5 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: diff --git a/gcc/objc/objc-encoding.h b/gcc/objc/objc-encoding.h index 2fad5937bc9..18ea4d2e5ff 100644 --- a/gcc/objc/objc-encoding.h +++ b/gcc/objc/objc-encoding.h @@ -22,25 +22,10 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_OBJC_ENCODING_H #define GCC_OBJC_ENCODING_H -/* TODO: Hide the following obstack code in objc-encoding.c, and have - a objc_encoding_init() that is called by objc_init() to set them - up. */ - -/* Set up for use of obstacks. */ -#include "obstack.h" - -/* This obstack is used to accumulate the encoding of a data type. */ -extern struct obstack util_obstack; - -/* This points to the beginning of obstack contents, so we can free - the whole contents. */ -extern char *util_firstobj; - -/* This will be used to initialize the obstacks used by encoding. It +/* This is used to initialize the obstacks used by encoding. It should be called before any encoding function is used. It is usually done in objc_init(). */ -/* extern void objc_encoding_init (void); */ - +extern void objc_encoding_init (void); /* Encode a method prototype. The format is described in gcc/doc/objc.texi, section 'Method signatures'. */ @@ -57,8 +42,10 @@ extern tree objc_build_encode_expr (tree type); /* Encode the attributes of a property. */ extern tree objc_v2_encode_prop_attr (tree property); -/* Encode the type of a field. */ -extern void encode_field_decl (tree field_decl, int curtype, int format); +/* Encode the type of a field. Return an identifier with the type + encoding for the field. The type encoding is a null-terminated + string. */ +extern tree encode_field_decl (tree field_decl); /* Tells "encode_pointer/encode_aggregate" whether we are generating type descriptors for instance variables (as opposed to methods). diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index e7570c7e4b2..8bdd7f1c190 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -50,13 +50,8 @@ along with GCC; see the file COPYING3. If not see #include "ggc.h" #include "target.h" -#include "obstack.h" #include "tree-iterator.h" -/* These are only used for encoding ivars. */ -extern struct obstack util_obstack; -extern char *util_firstobj; - #include "objc-runtime-hooks.h" #include "objc-runtime-shared-support.h" #include "objc-encoding.h" @@ -2852,15 +2847,9 @@ build_v2_ivar_list_initializer (tree class_name, tree type, tree field_decl) meth_var_names)); /* Set type. */ - encode_field_decl (field_decl, - obstack_object_size (&util_obstack), - OBJC_ENCODE_DONT_INLINE_DEFS); - /* Null terminate string. */ - obstack_1grow (&util_obstack, 0); - id = add_objc_string (get_identifier (XOBFINISH (&util_obstack, char *)), + id = add_objc_string (encode_field_decl (field_decl), meth_var_types); CONSTRUCTOR_APPEND_ELT (ivar, NULL_TREE, id); - obstack_free (&util_obstack, util_firstobj); /* Set alignment. */ val = DECL_ALIGN_UNIT (field_decl); diff --git a/gcc/objc/objc-runtime-shared-support.c b/gcc/objc/objc-runtime-shared-support.c index 913b0fd7e2b..7d478d97bea 100644 --- a/gcc/objc/objc-runtime-shared-support.c +++ b/gcc/objc/objc-runtime-shared-support.c @@ -41,12 +41,6 @@ along with GCC; see the file COPYING3. If not see #include "objcp-decl.h" #endif /* OBJCPLUS */ -#include "obstack.h" - -/* These are only used for encoding ivars. */ -extern struct obstack util_obstack; -extern char *util_firstobj; - /* Hooks for string decls etc. */ #include "objc-runtime-hooks.h" @@ -551,16 +545,9 @@ build_ivar_list_initializer (tree type, tree field_decl) CONSTRUCTOR_APPEND_ELT (ivar, NULL_TREE, build_int_cst (NULL_TREE, 0)); /* Set type. */ - encode_field_decl (field_decl, - obstack_object_size (&util_obstack), - OBJC_ENCODE_DONT_INLINE_DEFS); - - /* Null terminate string. */ - obstack_1grow (&util_obstack, 0); - id = add_objc_string (get_identifier (XOBFINISH (&util_obstack, char *)), + id = add_objc_string (encode_field_decl (field_decl), meth_var_types); CONSTRUCTOR_APPEND_ELT (ivar, NULL_TREE, id); - obstack_free (&util_obstack, util_firstobj); /* Set offset. */ CONSTRUCTOR_APPEND_ELT (ivar, NULL_TREE, byte_position (field_decl)); |