Fix builtin methods.

This commit is contained in:
Bill Currie 2011-02-04 19:50:24 +09:00
parent d0ecbb38b8
commit d9446c5eb0
3 changed files with 21 additions and 6 deletions

View file

@ -76,7 +76,8 @@ method_t *new_method (struct type_s *ret_type, param_t *selector,
const char *method_name (method_t *method);
method_t *copy_method (method_t *method);
void add_method (methodlist_t *methodlist, method_t *method);
struct def_s *method_def (struct class_type_s *class_type, method_t *method);
struct symbol_s *method_symbol (struct class_type_s *class_type,
method_t *method);
void method_set_param_names (method_t *dst, method_t *src);
methodlist_t *new_methodlist (void);

View file

@ -97,10 +97,12 @@ new_method (type_t *ret_type, param_t *selector, param_t *opt_params)
self->next = cmd;
meth->next = 0;
meth->func = 0;
meth->instance = 0;
meth->selector = selector;
meth->params = self;
meth->type = parse_params (ret_type, meth->params);
meth->type = find_type (meth->type);
selector_name (name, (keywordarg_t *)selector);
method_types (types, meth);
@ -153,11 +155,11 @@ add_method (methodlist_t *methodlist, method_t *method)
methodlist->tail = &method->next;
}
def_t *
method_def (class_type_t *class_type, method_t *method)
symbol_t *
method_symbol (class_type_t *class_type, method_t *method)
{
dstring_t *str = dstring_newstr ();
def_t *def;
symbol_t *sym;
char *s;
const char *class_name;
@ -172,9 +174,10 @@ method_def (class_type_t *class_type, method_t *method)
*s = '_';
//printf ("%s %s %s %ld\n", method->name, method->types, str->str,
// str->size);
def = make_symbol (str->str, method->type, pr.far_data, st_static)->s.def;
sym = new_symbol_type (str->str, method->type);
sym = function_symbol (sym, 0, 1);//FIXME put in far data and make static
dstring_delete (str);
return def;
return sym;
}
void
@ -468,6 +471,7 @@ emit_methods (methodlist_t *methods, const char *name, int instance)
if (!count)
return 0;
methods->count = count;
methods->instance = instance;
methods_struct[2].type = array_type (&type_integer, count);
return emit_structure (va ("_OBJ_%s_METHODS_%s", type, name), 's',

View file

@ -1409,6 +1409,16 @@ ivars
methoddef
: ci methoddecl optional_state_expr compound_statement {}
| ci methoddecl '=' '#' const ';' {}
{
symbol_t *sym;
method_t *method = $2;
method->instance = $1;
method = class_find_method (current_class, method);
sym = method_symbol (current_class, method);
build_builtin_function (sym, $5);
method->def = sym->s.func->def;
}
;
ci