From 30701980bcdb857cd26e5491310f3ef844b0ce59 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 25 Jan 2011 09:36:00 +0900 Subject: [PATCH] Get QC cfunctions and defs working. --- tools/qfcc/source/defspace.c | 1 + tools/qfcc/source/qc-parse.y | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/source/defspace.c b/tools/qfcc/source/defspace.c index 78dd2c871..eff5ac8a3 100644 --- a/tools/qfcc/source/defspace.c +++ b/tools/qfcc/source/defspace.c @@ -78,6 +78,7 @@ new_defspace (void) defspace_t *space; ALLOC (1024, defspace_t, spaces, space); + space->def_tail = &space->defs; space->grow = grow_space; return space; } diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index f1bd4d032..286b5d1c1 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -284,15 +284,36 @@ simple_def cfunction : cfunction_def ';' | cfunction_def '=' '#' fexpr ';' - | cfunction_def opt_state_expr statement_block + { + build_builtin_function ($1, $4); + } + | cfunction_def + { + $$ = current_symtab; + current_func = begin_function ($1, 0, current_symtab); + current_symtab = current_func->symtab; + } + opt_state_expr statement_block + { + build_code_function ($1, $3, $4); + current_symtab = $2; + } ; cfunction_def : OVERLOAD non_func_type identifier function_decl { + $$ = $3; + $$->params = current_params = $4; + $$->type = parse_params ($2, $4); + $$ = function_symbol ($$, 1, 1); } | non_func_type identifier function_decl { + $$ = $2; + $$->params = current_params = $3; + $$->type = parse_params ($1, $3); + $$ = function_symbol ($$, 0, 1); } ; @@ -487,6 +508,10 @@ def_list def_item : def_name opt_initializer { + $1 = check_redefined ($1); + $1->type = $0; + $1->visibility = current_visibility; + symtab_addsymbol (current_symtab, $1); } ;