Fix passing messages to classes.

Rename class_pointer_def() to class_pointer_symbol() and use it when a
class name is used as the receiver of a message.
This commit is contained in:
Bill Currie 2011-02-06 14:33:52 +09:00
parent 67957a14df
commit 2f7b892452
4 changed files with 14 additions and 8 deletions

View file

@ -128,7 +128,7 @@ struct method_s *class_find_method (class_type_t *class_type,
struct method_s *method);
struct method_s *class_message_response (class_t *class, int class_msg,
struct expr_s *sel);
struct def_s *class_pointer_def (class_t *class_type);
struct symbol_s *class_pointer_symbol (class_t *class_type);
category_t *get_category (struct symbol_s *class_name,
const char *category_name, int create);
void category_add_methods (category_t *category, struct methodlist_s *methods);

View file

@ -973,19 +973,21 @@ category_add_protocols (category_t *category, protocollist_t *protocols)
category->protocols = protocols;
}
def_t *
class_pointer_def (class_t *class)
symbol_t *
class_pointer_symbol (class_t *class)
{
def_t *def;
symbol_t *sym;
class_type_t class_type = {ct_class, {0}};
class_type.c.class = class;
def = make_symbol (va ("_OBJ_CLASS_POINTER_%s", class->name),
sym = make_symbol (va ("_OBJ_CLASS_POINTER_%s", class->name),
pointer_type (class->type),
pr.far_data, st_static)->s.def;
pr.far_data, st_static);
def = sym->s.def;
if (def->initialized)
return def;
return sym;
def->initialized = def->constant = 1;
def->nosave = 1;
if (!class->def)
@ -993,7 +995,7 @@ class_pointer_def (class_t *class)
if (!class->def->external)
D_INT (def) = class->def->offset;
reloc_def_def (class->def, def->offset);
return def;
return sym;
}

View file

@ -1571,7 +1571,10 @@ obj_messageexpr
receiver
: fexpr
| CLASS_NAME { $$ = new_symbol_expr ($1); }
| CLASS_NAME
{
$$ = new_symbol_expr (class_pointer_symbol ($1->type->t.class));
}
;
messageargs

View file

@ -193,6 +193,7 @@ make_symbol (const char *name, type_t *type, defspace_t *space,
sym = symtab_lookup (pr.symtab, name);
if (!sym) {
sym = new_symbol_type (name, type);
symtab_addsymbol (pr.symtab, sym);
}
if (sym->type != type) {
error (0, "%s redefined", name);