This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Cleanups in objc-act.c
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: Cleanups in objc-act.c
- From: Stan Shebs <shebs at apple dot com>
- Date: Thu, 08 Mar 2001 19:32:48 -0800
As a warmup for integrating Apple's additions to Objective-C, I've
committed a set of obvious improvements that were already in Apple's
version of objc-act.c, mainly additional comments.
Stan
2001-03-08 Stan Shebs <shebs@apple.com>
* objc/objc-act.c: Fix old typos in comments, add comments for
various functions.
(hash_init): Fix file name in error message.
(hash_enter): Ditto.
(hash_add_attr): Ditto.
(continue_class): Ditto.
Index: objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.70
diff -p -r1.70 objc-act.c
*** objc-act.c 2001/03/07 00:29:25 1.70
--- objc-act.c 2001/03/09 03:25:38
*************** lookup_protocol_in_reflist (rproto_list,
*** 901,907 ****
{
tree rproto, p;
! /* Make sure the protocol is support by the object on the rhs. */
if (TREE_CODE (lproto) == PROTOCOL_INTERFACE_TYPE)
{
tree fnd = 0;
--- 901,907 ----
{
tree rproto, p;
! /* Make sure the protocol is supported by the object on the rhs. */
if (TREE_CODE (lproto) == PROTOCOL_INTERFACE_TYPE)
{
tree fnd = 0;
*************** objc_comptypes (lhs, rhs, reflexive)
*** 1021,1027 ****
return (TYPED_OBJECT (TREE_TYPE (lhs)) != 0);
else
! /* Defer to comptypes .*/
return -1;
}
--- 1021,1027 ----
return (TYPED_OBJECT (TREE_TYPE (lhs)) != 0);
else
! /* Defer to comptypes. */
return -1;
}
*************** get_static_reference (interface, protoco
*** 1118,1124 ****
TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
TYPE_NEXT_VARIANT (m) = t;
! /* Look up protocols and install in lang specific list. */
TYPE_PROTOCOL_LIST (t) = lookup_and_install_protocols (protocols);
/* This forces a new pointer type to be created later
--- 1118,1125 ----
TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
TYPE_NEXT_VARIANT (m) = t;
! /* Look up protocols and install in lang specific list. Note
! that the protocol list can have a different lifetime than T! */
TYPE_PROTOCOL_LIST (t) = lookup_and_install_protocols (protocols);
/* This forces a new pointer type to be created later
*************** my_build_string (len, str)
*** 1404,1414 ****
}
/* Given a chain of STRING_CST's, build a static instance of
! NXConstanString which points at the concatenation of those strings.
We place the string object in the __string_objects section of the
__OBJC segment. The Objective-C runtime will initialize the isa
! pointers of the string objects to point at the NXConstandString class
! object. */
tree
build_objc_string_object (strings)
--- 1405,1415 ----
}
/* Given a chain of STRING_CST's, build a static instance of
! NXConstantString which points at the concatenation of those strings.
We place the string object in the __string_objects section of the
__OBJC segment. The Objective-C runtime will initialize the isa
! pointers of the string objects to point at the NXConstantString
! class object. */
tree
build_objc_string_object (strings)
*************** generate_method_descriptors (protocol) /
*** 3038,3043 ****
--- 3039,3047 ----
UOBJC_INSTANCE_METHODS_decl = 0;
}
+ /* Generate a temporary FUNCTION_DECL node to be used in
+ hack_method_prototype below. */
+
static tree
build_tmp_function_decl ()
{
*************** build_tmp_function_decl ()
*** 3071,3076 ****
--- 3075,3087 ----
return define_decl (expr_decl, decl_specs);
}
+ /* Generate the prototypes for protocol methods. This is used to
+ generate method encodings for these.
+
+ NST_METHODS is the method to generate a _DECL node for TMP_DECL is
+ a decl node to be used. This is also where the return value is
+ given. */
+
static void
hack_method_prototype (nst_methods, tmp_decl)
tree nst_methods;
*************** hash_init ()
*** 5439,5445 ****
cls_method_hash_list = (hash *)xmalloc (SIZEHASHTABLE * sizeof (hash));
if (!nst_method_hash_list || !cls_method_hash_list)
! perror ("unable to allocate space in objc-tree.c");
else
{
int i;
--- 5450,5456 ----
cls_method_hash_list = (hash *)xmalloc (SIZEHASHTABLE * sizeof (hash));
if (!nst_method_hash_list || !cls_method_hash_list)
! perror ("unable to allocate space in objc-act.c");
else
{
int i;
*************** hash_init ()
*** 5452,5457 ****
--- 5463,5473 ----
}
}
+ /* WARNING!!!! hash_enter is called with a method, and will peek
+ inside to find its selector! But hash_lookup is given a selector
+ directly, and looks for the selector that's inside the found
+ entry's key (method) for comparison. */
+
static void
hash_enter (hashlist, method)
hash *hashlist;
*************** hash_enter (hashlist, method)
*** 5468,5474 ****
hash_alloc_list = (hash) xmalloc (sizeof (struct hashed_entry)
* HASH_ALLOC_LIST_SIZE);
if (! hash_alloc_list)
! perror ("unable to allocate in objc-tree.c");
}
obj = &hash_alloc_list[hash_alloc_index++];
obj->list = 0;
--- 5484,5490 ----
hash_alloc_list = (hash) xmalloc (sizeof (struct hashed_entry)
* HASH_ALLOC_LIST_SIZE);
if (! hash_alloc_list)
! perror ("unable to allocate in objc-act.c");
}
obj = &hash_alloc_list[hash_alloc_index++];
obj->list = 0;
*************** hash_add_attr (entry, value)
*** 5512,5518 ****
attr_alloc_list = (attr) xmalloc (sizeof (struct hashed_attribute)
* ATTR_ALLOC_LIST_SIZE);
if (! attr_alloc_list)
! perror ("unable to allocate in objc-tree.c");
}
obj = &attr_alloc_list[attr_alloc_index++];
obj->next = entry->list;
--- 5528,5534 ----
attr_alloc_list = (attr) xmalloc (sizeof (struct hashed_attribute)
* ATTR_ALLOC_LIST_SIZE);
if (! attr_alloc_list)
! perror ("unable to allocate in objc-act.c");
}
obj = &attr_alloc_list[attr_alloc_index++];
obj->next = entry->list;
*************** tree
*** 5913,5918 ****
--- 5929,5937 ----
get_class_ivars (interface)
tree interface;
{
+ /* Make sure we copy the leaf ivars in case @defs is used in a local
+ context. Otherwise finish_struct will overwrite the layout info
+ using temporary storage. */
return build_ivar_chain (interface, 1);
}
*************** continue_class (class)
*** 6283,6289 ****
if (!(imp_entry
= (struct imp_entry *) xmalloc (sizeof (struct imp_entry))))
! perror ("unable to allocate in objc-tree.c");
imp_entry->next = imp_list;
imp_entry->imp_context = class;
--- 6302,6308 ----
if (!(imp_entry
= (struct imp_entry *) xmalloc (sizeof (struct imp_entry))))
! perror ("unable to allocate in objc-act.c");
imp_entry->next = imp_list;
imp_entry->imp_context = class;
*************** really_start_method (method, parmlist)
*** 7164,7169 ****
--- 7183,7190 ----
METHOD_DEFINITION (method) = current_function_decl;
+ /* Check consistency...start_function, pushdecl, duplicate_decls. */
+
if (implementation_template != implementation_context)
{
tree proto;
*************** get_super_receiver ()
*** 7270,7275 ****
--- 7291,7297 ----
tree super_name = CLASS_SUPER_NAME (implementation_template);
tree super_class;
+ /* Barf if super used in a category of Object. */
if (!super_name)
{
error ("no super class declared in interface for `%s'",
*************** encode_method_def (func_decl)
*** 7368,7373 ****
--- 7390,7396 ----
obstack_grow (&util_obstack, buffer, strlen (buffer));
}
+ /* Null terminate string. */
obstack_1grow (&util_obstack, 0);
result = get_identifier (obstack_finish (&util_obstack));
obstack_free (&util_obstack, util_firstobj);
*************** gen_declspecs (declspecs, buf, raw)
*** 7774,7780 ****
strcat (buf, "long double ");
break;
! case RECORD_TYPE:
if (TYPE_NAME (declspecs)
&& TREE_CODE (TYPE_NAME (declspecs)) == IDENTIFIER_NODE)
{
--- 7797,7803 ----
strcat (buf, "long double ");
break;
! case RECORD_TYPE:
if (TYPE_NAME (declspecs)
&& TREE_CODE (TYPE_NAME (declspecs)) == IDENTIFIER_NODE)
{