+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.
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
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 \
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 \
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 \
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) \
/* 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);
/* 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)
obstack_1grow (&util_obstack, '"');
}
- encode_field_decl (field, curtype, format);
+ encode_field (field, curtype, format);
}
}
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,
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:
#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'. */
/* 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).
#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"
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);
#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"
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));
+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.
+
2011-07-04 Nicola Pero <nicola.pero@meta-innovation.com>
* Make-lang.in (OBJCXX_OBJS): Added objc-encoding.o.
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 \
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 \
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 \
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 \
gt-objc-objc-act.h \
$(START_HDRS) \
$(GGC_H) $(DIAGNOSTIC_H) $(FLAGS_H) input.h \
- $(OBSTACK_H) \
toplev.h $(FUNCTION_H) output.h debug.h $(LANGHOOKS_DEF_H) \
$(HASHTAB_H) $(GIMPLE_H) \
$(RTL_H) $(EXPR_H) $(TARGET_H) \