Set the type of the super structure to the correct type.

This commit is contained in:
Bill Currie 2011-02-11 11:29:25 +09:00
parent 7d2a95ee40
commit c185fbb782
3 changed files with 13 additions and 12 deletions

View File

@ -73,10 +73,11 @@ static hashtab_t *protocol_hash;
type_t type_SEL = { ev_pointer, "SEL" }; type_t type_SEL = { ev_pointer, "SEL" };
type_t type_IMP = { ev_func, "IMP", ty_none, type_t type_IMP = { ev_func, "IMP", ty_none,
{{&type_id, -3, {&type_id, &type_SEL}}}}; {{&type_id, -3, {&type_id, &type_SEL}}}};
type_t type_supermsg = { ev_func, ".supermsg", ty_none,
{{&type_id, -3, {0, &type_SEL}}}};
type_t type_Method = { ev_invalid, "Method" };
type_t type_Super = { ev_invalid, "Super" }; type_t type_Super = { ev_invalid, "Super" };
type_t type_SuperPtr = { ev_pointer, 0, ty_none, {{&type_Super}}};
type_t type_supermsg = { ev_func, ".supermsg", ty_none,
{{&type_id, -3, {&type_SuperPtr, &type_SEL}}}};
type_t type_Method = { ev_invalid, "Method" };
type_t type_method_description = { ev_invalid, "obj_method_description", type_t type_method_description = { ev_invalid, "obj_method_description",
ty_struct }; ty_struct };
type_t type_category = { ev_invalid, "category", ty_struct}; type_t type_category = { ev_invalid, "category", ty_struct};
@ -230,11 +231,11 @@ init_objective_structs (void)
make_structure (0, 's', super_struct, &type_Super); make_structure (0, 's', super_struct, &type_Super);
chain_type (&type_Super); chain_type (&type_Super);
chain_type (&type_SuperPtr);
chain_type (&type_supermsg);
make_structure ("obj_module_s", 's', module_struct, &type_module); make_structure ("obj_module_s", 's', module_struct, &type_module);
type_supermsg.t.func.param_types[0] = pointer_type (&type_Super);
chain_type (&type_supermsg);
} }
static void static void

View File

@ -207,8 +207,8 @@ param_mismatch (expr_t *e, int param, const char *fn, type_t *t1, type_t *t2)
print_type_str (s1, t1); print_type_str (s1, t1);
print_type_str (s2, t2); print_type_str (s2, t2);
e = error (e, "type mismatch for parameter %d of %s: %s %s", param, fn, e = error (e, "type mismatch for parameter %d of %s: expected %s, got %s",
s1->str, s2->str); param, fn, s1->str, s2->str);
dstring_delete (s1); dstring_delete (s1);
dstring_delete (s2); dstring_delete (s2);
return e; return e;
@ -2536,7 +2536,7 @@ super_expr (class_type_t *class_type)
binary_expr ('.', e, new_name_expr ("super_class"))); binary_expr ('.', e, new_name_expr ("super_class")));
append_expr (super_block, e); append_expr (super_block, e);
e = address_expr (super, 0, &type_void); e = address_expr (super, 0, 0);
super_block->e.block.result = e; super_block->e.block.result = e;
return super_block; return super_block;
} }
@ -2553,6 +2553,7 @@ message_expr (expr_t *receiver, keywordarg_t *message)
type_t *return_type; type_t *return_type;
class_t *class; class_t *class;
method_t *method; method_t *method;
expr_t *send_msg;
if (receiver->type == ex_symbol if (receiver->type == ex_symbol
&& strcmp (receiver->e.symbol->name, "super") == 0) { && strcmp (receiver->e.symbol->name, "super") == 0) {
@ -2604,14 +2605,13 @@ message_expr (expr_t *receiver, keywordarg_t *message)
a = &(*a)->next; a = &(*a)->next;
*a = receiver; *a = receiver;
send_msg = send_message (super);
if (method) { if (method) {
expr_t *err; expr_t *err;
if ((err = method_check_params (method, args))) if ((err = method_check_params (method, args)))
return err; return err;
call = build_function_call (send_message (super), method->type, args);
} else {
call = build_function_call (send_message (super), &type_IMP, args);
} }
call = build_function_call (send_msg, get_type (send_msg), args);
if (call->type == ex_error) if (call->type == ex_error)
return receiver; return receiver;

View File

@ -259,7 +259,7 @@ send_message (int super)
if (super) { if (super) {
sm_name = "obj_msgSend_super"; sm_name = "obj_msgSend_super";
sm_type = &type_IMP; sm_type = &type_supermsg;
} }
sym = symtab_lookup (pr.symtab, sm_name); sym = symtab_lookup (pr.symtab, sm_name);
if (!sym) { if (!sym) {