mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +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)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
|
@ -300,13 +300,13 @@ cfunction
|
|||
;
|
||||
|
||||
cfunction_def
|
||||
: OVERLOAD non_func_type identifier function_decl
|
||||
: OVERLOAD non_func_type identifier function_decl
|
||||
{
|
||||
type_t *type = parse_params ($2, current_params = $4);
|
||||
$$ = get_function_def ($3, type, current_scope,
|
||||
current_storage, 1, 1);
|
||||
}
|
||||
| non_func_type identifier function_decl
|
||||
| non_func_type identifier function_decl
|
||||
{
|
||||
type_t *type = parse_params ($1, current_params = $3);
|
||||
$$ = get_function_def ($2, type, current_scope,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -758,7 +742,7 @@ end_function
|
|||
;
|
||||
|
||||
statement_block
|
||||
: '{'
|
||||
: '{'
|
||||
{
|
||||
if (!options.traditional) {
|
||||
scope_t *scope = new_scope (sc_local, current_scope->space,
|
||||
|
@ -1428,7 +1412,7 @@ classdef
|
|||
;
|
||||
|
||||
protocoldef
|
||||
: PROTOCOL protocol_name
|
||||
: PROTOCOL protocol_name
|
||||
protocolrefs { protocol_add_protocols ($2, $3); $<class>$ = 0; }
|
||||
methodprotolist { protocol_add_methods ($2, $5); }
|
||||
END { current_class = 0; (void) ($<class>4); }
|
||||
|
|
Loading…
Reference in a new issue