mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
C style functions can now (optionally) be used (void foo ();)
This commit is contained in:
parent
e2602bc9d5
commit
1fc517f7db
3 changed files with 54 additions and 20 deletions
|
@ -69,6 +69,8 @@ param_t *copy_params (param_t *params);
|
|||
struct type_s *parse_params (struct type_s *type, param_t *params);
|
||||
void build_scope (function_t *f, struct def_s *func, param_t *params);
|
||||
function_t *new_function (const char *name);
|
||||
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);
|
||||
void build_function (function_t *f);
|
||||
void finish_function (function_t *f);
|
||||
|
|
|
@ -196,6 +196,20 @@ new_function (const char *name)
|
|||
return f;
|
||||
}
|
||||
|
||||
function_t *
|
||||
build_code_function (function_t *f, expr_t *state_expr, expr_t *statements)
|
||||
{
|
||||
build_function (f);
|
||||
if (state_expr) {
|
||||
state_expr->next = statements;
|
||||
emit_function (f, state_expr);
|
||||
} else {
|
||||
emit_function (f, statements);
|
||||
}
|
||||
finish_function (f);
|
||||
return f;
|
||||
}
|
||||
|
||||
function_t *
|
||||
build_builtin_function (def_t *def, expr_t *bi_val)
|
||||
{
|
||||
|
|
|
@ -246,6 +246,42 @@ simple_defs
|
|||
simple_def
|
||||
: non_func_type def_list ';' { }
|
||||
| func_type func_defs { }
|
||||
| cfunction { }
|
||||
;
|
||||
|
||||
cfunction
|
||||
: non_func_type NAME function_decl ';'
|
||||
{
|
||||
type_t *type;
|
||||
def_t *def;
|
||||
|
||||
type = parse_params ($1, $3);
|
||||
def = get_def (type, $2, current_scope, current_storage);
|
||||
}
|
||||
| non_func_type NAME function_decl '=' '#' fexpr ';'
|
||||
{
|
||||
type_t *type;
|
||||
def_t *def;
|
||||
|
||||
type = parse_params ($1, $3);
|
||||
def = get_def (type, $2, current_scope, current_storage);
|
||||
$6 = constant_expr ($6);
|
||||
build_builtin_function (def, $6);
|
||||
}
|
||||
| non_func_type NAME function_decl
|
||||
opt_state_expr
|
||||
{ $<op>$ = current_storage; }
|
||||
{
|
||||
type_t *type;
|
||||
|
||||
current_params = $3;
|
||||
type = parse_params ($1, $3);
|
||||
$<def>$ = get_def (type, $2, current_scope, current_storage);
|
||||
}
|
||||
begin_function statement_block { $<op>$ = $<op>5; } end_function
|
||||
{
|
||||
build_code_function ($7, $4, $8);
|
||||
}
|
||||
;
|
||||
|
||||
storage_class
|
||||
|
@ -446,9 +482,6 @@ non_code_func
|
|||
}
|
||||
| /* emtpy */
|
||||
{
|
||||
if ($<def>0 && !$<def>0->local
|
||||
&& $<def>0->type->type != ev_func)
|
||||
def_initialized ($<def>0);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -458,14 +491,7 @@ code_func
|
|||
{ $<def>$ = $<def>0; }
|
||||
begin_function statement_block { $<op>$ = $<op>3; } end_function
|
||||
{
|
||||
build_function ($5);
|
||||
if ($2) {
|
||||
$2->next = $6;
|
||||
emit_function ($5, $2);
|
||||
} else {
|
||||
emit_function ($5, $6);
|
||||
}
|
||||
finish_function ($5);
|
||||
build_code_function ($5, $2, $6);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -1287,15 +1313,7 @@ methoddef
|
|||
}
|
||||
begin_function statement_block { $<op>$ = $<op>5; } end_function
|
||||
{
|
||||
$2->func = $7;
|
||||
build_function ($7);
|
||||
if ($4) {
|
||||
$4->next = $8;
|
||||
emit_function ($7, $4);
|
||||
} else {
|
||||
emit_function ($7, $8);
|
||||
}
|
||||
finish_function ($7);
|
||||
$2->func = build_code_function ($7, $4, $8);
|
||||
}
|
||||
| ci methoddecl '=' '#' const ';'
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue