mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 08:27:39 +00:00
Break out the begin_function code into its own function.
This commit is contained in:
parent
c5d0acf0fa
commit
7971b0868e
3 changed files with 35 additions and 23 deletions
|
@ -90,6 +90,8 @@ 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 (struct def_s *func, const char *nice_name);
|
||||
void add_function (function_t *f);
|
||||
function_t *begin_function (struct def_s *def, const char *nicename,
|
||||
param_t *params);
|
||||
function_t *build_code_function (function_t *f, struct expr_s *state_expr,
|
||||
struct expr_s *statements);
|
||||
function_t *build_builtin_function (struct def_s *def, struct expr_s *bi_val);
|
||||
|
|
|
@ -443,6 +443,32 @@ add_function (function_t *f)
|
|||
f->aux = new_auxfunction ();
|
||||
}
|
||||
|
||||
function_t *
|
||||
begin_function (def_t *def, const char *nicename, param_t *params)
|
||||
{
|
||||
function_t *func;
|
||||
|
||||
if (def->constant)
|
||||
error (0, "%s redefined", def->name);
|
||||
func = new_function (def, nicename);
|
||||
if (!def->external) {
|
||||
add_function (func);
|
||||
reloc_def_func (func, def->ofs);
|
||||
}
|
||||
func->code = pr.code->size;
|
||||
if (options.code.debug && func->aux) {
|
||||
pr_lineno_t *lineno = new_lineno ();
|
||||
func->aux->source_line = def->line;
|
||||
func->aux->line_info = lineno - pr.linenos;
|
||||
func->aux->local_defs = pr.num_locals;
|
||||
func->aux->return_type = def->type->aux_type->type;
|
||||
|
||||
lineno->fa.func = func->aux - pr.auxfunctions;
|
||||
}
|
||||
build_scope (func, def, params);
|
||||
return func;
|
||||
}
|
||||
|
||||
function_t *
|
||||
build_code_function (function_t *f, expr_t *state_expr, expr_t *statements)
|
||||
{
|
||||
|
|
|
@ -726,24 +726,8 @@ opt_comma
|
|||
begin_function
|
||||
: /*empty*/
|
||||
{
|
||||
if ($<def>0->constant)
|
||||
error (0, "%s redefined", $<def>0->name);
|
||||
$$ = current_func = new_function ($<def>0, $<string_val>-1);
|
||||
if (!$$->def->external) {
|
||||
add_function ($$);
|
||||
reloc_def_func ($$, $$->def->ofs);
|
||||
}
|
||||
$$->code = pr.code->size;
|
||||
if (options.code.debug && current_func->aux) {
|
||||
pr_lineno_t *lineno = new_lineno ();
|
||||
$$->aux->source_line = $$->def->line;
|
||||
$$->aux->line_info = lineno - pr.linenos;
|
||||
$$->aux->local_defs = pr.num_locals;
|
||||
$$->aux->return_type = $$->def->type->aux_type->type;
|
||||
|
||||
lineno->fa.func = $$->aux - pr.auxfunctions;
|
||||
}
|
||||
build_scope ($$, $$->def, current_params);
|
||||
$$ = begin_function ($<def>0, $<string_val>-1, current_params);
|
||||
current_func = $$;
|
||||
current_scope = $$->scope;
|
||||
current_storage = st_local;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue