Commit 7427ba36 by Iain Sandoe

vec-ify ObjC* build_objc_method_call()

gcc/objc:
	* objc-act.c (build_objc_method_call): Replace calls to 
	build_function_call () with the VEC equivalent.  Construct parameter
	lists as VECs.

From-SVN: r165112
parent fd651069
2010-10-07 Iain Sandoe <iains@gcc.gnu.org> 2010-10-07 Iain Sandoe <iains@gcc.gnu.org>
* objc-act.c (objc_build_message_expr): Call mark_exp_read () to signal that * objc-act.c (build_objc_method_call): Replace calls to
the receiver has been used. build_function_call () with the VEC equivalent. Construct parameter
lists as VECs.
2010-10-07 Iain Sandoe <iains@gcc.gnu.org>
* objc-act.c (objc_build_message_expr): Call mark_exp_read () to
signal that the receiver has been used.
2010-10-06 Nicola Pero <nicola.pero@meta-innovation.com> 2010-10-06 Nicola Pero <nicola.pero@meta-innovation.com>
......
...@@ -6689,6 +6689,8 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype, ...@@ -6689,6 +6689,8 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
: umsg_decl) : umsg_decl)
: umsg_nonnil_decl)); : umsg_nonnil_decl));
tree rcv_p = (super_flag ? objc_super_type : objc_object_type); tree rcv_p = (super_flag ? objc_super_type : objc_object_type);
VEC(tree, gc) *parms = NULL;
unsigned nparm = (method_params ? list_length (method_params) : 0);
/* If a prototype for the method to be called exists, then cast /* If a prototype for the method to be called exists, then cast
the sender's return type and arguments to match that of the method. the sender's return type and arguments to match that of the method.
...@@ -6710,6 +6712,9 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype, ...@@ -6710,6 +6712,9 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
/* Use SAVE_EXPR to avoid evaluating the receiver twice. */ /* Use SAVE_EXPR to avoid evaluating the receiver twice. */
lookup_object = save_expr (lookup_object); lookup_object = save_expr (lookup_object);
/* Param list + 2 slots for object and selector. */
parms = VEC_alloc (tree, gc, nparm + 2);
if (flag_next_runtime) if (flag_next_runtime)
{ {
/* If we are returning a struct in memory, and the address /* If we are returning a struct in memory, and the address
...@@ -6724,38 +6729,40 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype, ...@@ -6724,38 +6729,40 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
sender = (super_flag ? umsg_super_stret_decl : sender = (super_flag ? umsg_super_stret_decl :
flag_nil_receivers ? umsg_stret_decl : umsg_nonnil_stret_decl); flag_nil_receivers ? umsg_stret_decl : umsg_nonnil_stret_decl);
method_params = tree_cons (NULL_TREE, lookup_object,
tree_cons (NULL_TREE, selector,
method_params));
method = build_fold_addr_expr_loc (input_location, sender); method = build_fold_addr_expr_loc (input_location, sender);
/* Pass the object to the method. */
VEC_quick_push (tree, parms, lookup_object);
} }
else else
{ {
/* This is the portable (GNU) way. */ /* This is the portable (GNU) way. */
tree object;
/* First, call the lookup function to get a pointer to the method, /* First, call the lookup function to get a pointer to the method,
then cast the pointer, then call it with the method arguments. */ then cast the pointer, then call it with the method arguments. */
VEC(tree, gc) *tv = VEC_alloc (tree, gc, 2);
object = (super_flag ? self_decl : lookup_object); VEC_quick_push (tree, tv, lookup_object);
VEC_quick_push (tree, tv, selector);
t = tree_cons (NULL_TREE, selector, NULL_TREE); method = build_function_call_vec (loc, sender, tv, NULL);
t = tree_cons (NULL_TREE, lookup_object, t); VEC_free (tree, gc, tv);
method = build_function_call (loc, sender, t);
/* Pass the appropriate object to the method. */
/* Pass the object to the method. */ VEC_quick_push (tree, parms, (super_flag ? self_decl : lookup_object));
method_params = tree_cons (NULL_TREE, object, }
tree_cons (NULL_TREE, selector,
method_params)); /* Pass the selector to the method. */
} VEC_quick_push (tree, parms, selector);
/* Now append the remainder of the parms. */
/* ??? Selector is not at this point something we can use inside if (nparm)
the compiler itself. Set it to garbage for the nonce. */ for (; method_params; method_params = TREE_CHAIN (method_params))
t = build3 (OBJ_TYPE_REF, sender_cast, method, lookup_object, size_zero_node); VEC_quick_push (tree, parms, TREE_VALUE (method_params));
return build_function_call (loc,
t, method_params); /* Build an obj_type_ref, with the correct cast for the method call. */
t = build3 (OBJ_TYPE_REF, sender_cast, method,
lookup_object, size_zero_node);
t = build_function_call_vec (loc, t, parms, NULL);\
VEC_free (tree, gc, parms);
return t;
} }
static void static void
build_protocol_reference (tree p) build_protocol_reference (tree p)
{ {
......
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