Commit a8f18c40 by Nicola Pero Committed by Nicola Pero

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
parent 18970372
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.
......
......@@ -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) \
......
......@@ -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);
......
......@@ -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:
......
......@@ -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).
......
......@@ -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);
......
......@@ -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));
......
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.
......
......@@ -92,7 +92,6 @@ objcp/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 \
......@@ -104,7 +103,6 @@ objcp/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 \
......@@ -117,7 +115,6 @@ objcp/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 \
......@@ -131,7 +128,6 @@ objcp/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 \
......@@ -148,7 +144,6 @@ objcp/objcp-act.o : objc/objc-act.c \
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) \
......
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