Make new_function take a def rather than a name.

Moves into new_function some code that should have been there in the first
place.
This commit is contained in:
Bill Currie 2010-12-31 17:28:46 +09:00
parent 4c69a97ac7
commit a1f36a9944
4 changed files with 8 additions and 10 deletions

View file

@ -84,7 +84,7 @@ struct def_s *get_function_def (const char *name, struct type_s *type,
int overload, int create);
struct expr_s *find_function (struct expr_s *fexpr, struct expr_s *params);
void build_scope (function_t *f, struct def_s *func, param_t *params);
function_t *new_function (const char *name);
function_t *new_function (struct def_s *func);
void add_function (function_t *f);
function_t *build_code_function (function_t *f, struct expr_s *state_expr,
struct expr_s *statements);

View file

@ -825,9 +825,8 @@ class_finish_module (void)
pr.scope, st_extern);
init_def = get_def (&type_function, ".ctor", pr.scope, st_static);
current_func = init_func = new_function (".ctor");
current_func = init_func = new_function (init_def);
add_function (init_func);
init_func->def = init_def;
reloc_def_func (init_func, init_def->ofs);
init_func->code = pr.code->size;
build_scope (init_func, init_def, 0);

View file

@ -420,13 +420,14 @@ build_scope (function_t *f, def_t *func, param_t *params)
}
function_t *
new_function (const char *name)
new_function (def_t *func)
{
function_t *f;
ALLOC (1024, function_t, functions, f);
f->s_name = ReuseString (name);
f->s_name = ReuseString (func->name);
f->s_file = pr.source_file;
f->def = func;
return f;
}
@ -473,12 +474,11 @@ build_builtin_function (def_t *def, expr_t *bi_val)
return 0;
}
f = new_function (def->name);
f = new_function (def);
add_function (f);
f->builtin = bi_val->type == ex_integer ? bi_val->e.integer_val
: (int)bi_val->e.float_val;
f->def = def;
reloc_def_func (f, def->ofs);
build_function (f);
finish_function (f);

View file

@ -727,8 +727,7 @@ begin_function
{
if ($<def>0->constant)
error (0, "%s redefined", $<def>0->name);
$$ = current_func = new_function ($<def>0->name);
$$->def = $<def>0;
$$ = current_func = new_function ($<def>0);
if (!$$->def->external) {
add_function ($$);
reloc_def_func ($$, $$->def->ofs);
@ -743,7 +742,7 @@ begin_function
lineno->fa.func = $$->aux - pr.auxfunctions;
}
build_scope ($$, $<def>0, current_params);
build_scope ($$, $$->def, current_params);
current_scope = $$->scope;
current_storage = st_local;
}