From 48fdd0cb26181483339f22f6788a38e8eebb9f1d Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 9 Apr 2007 06:16:34 +0000 Subject: [PATCH] record the params for builtins, too. --- tools/qfcc/source/disassemble.c | 2 +- tools/qfcc/source/qc-parse.y | 39 ++++++++++++++++++++++++++------- tools/qfcc/source/qfprogs.c | 2 +- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/tools/qfcc/source/disassemble.c b/tools/qfcc/source/disassemble.c index 6a9fcf44d..f9f6be3b4 100644 --- a/tools/qfcc/source/disassemble.c +++ b/tools/qfcc/source/disassemble.c @@ -82,6 +82,6 @@ disassemble_progs (progs_t *pr) Sys_Printf ("%s:\n", PR_GetString (pr, desc->s_name)); pr->pr_xfunction = &func; } - PR_PrintStatement (pr, &pr->pr_statements[i], 0); + PR_PrintStatement (pr, &pr->pr_statements[i], 2); } } diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index a628b8330..0bf9dfcd9 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -167,7 +167,7 @@ expr_t *argv_expr (void); %type statement statements statement_block %type label break_label continue_label enum_list enum %type unary_expr primary cast_expr opt_arg_list arg_list -%type begin_function +%type begin_function builtin_function %type save_inits %type switch_block %type identifier @@ -262,9 +262,13 @@ cfunction : cfunction_def ';' { } - | cfunction_def '=' '#' fexpr ';' + | cfunction_def '=' '#' fexpr + { $$ = $1; } + { $$ = constant_expr ($4); } + builtin_function ';' { - build_builtin_function ($1, $4); + (void) ($5); + (void) ($6); } | cfunction_def opt_state_expr { $$ = current_storage; } @@ -506,11 +510,23 @@ func_init | code_func ; +builtin_function + : /* emtpy */ + { + $$ = build_builtin_function ($-1, $0); + build_scope ($$, $$->def, current_params); + flush_scope ($$->scope, 1); + } + ; + non_code_func : '=' '#' fexpr + { $$ = $0; } + { $$ = constant_expr ($3); } + builtin_function { - $3 = constant_expr ($3); - build_builtin_function ($0, $3); + (void) ($4); + (void) ($5); } | /* emtpy */ { @@ -1428,13 +1444,20 @@ methoddef (void) ($6); (void) ($9); } - | ci methoddecl '=' '#' const ';' + | ci methoddecl { $2->instance = $1; $2 = class_find_method (current_class, $2); - $2->def = method_def (current_class, $2); + } + '=' '#' const + { $$ = $2->def = method_def (current_class, $2); } + { $$ = $6; } + builtin_function ';' + { + $2->func = $9; - $2->func = build_builtin_function ($2->def, $5); + (void) ($7); + (void) ($8); } ; diff --git a/tools/qfcc/source/qfprogs.c b/tools/qfcc/source/qfprogs.c index f57e2b9d8..d0daaaa1d 100644 --- a/tools/qfcc/source/qfprogs.c +++ b/tools/qfcc/source/qfprogs.c @@ -459,7 +459,7 @@ load_progs (const char *name) return 0; PR_LoadStrings (&pr); - + PR_ResolveGlobals (&pr); PR_LoadDebug (&pr); } for (i = 0; i < pr.progs->numfunctions; i++) {