From 655fe17e182d494c6072d8e9850b8b4055506a27 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 18 Mar 2002 07:30:21 +0000 Subject: [PATCH] fix handling of pointers in function params and local vars for qc functions --- cs-code/Makefile.am | 2 +- cs-code/inputline_util.qc | 5 ++--- cs-code/menu.qc | 1 + cs-code/string_def.qc | 2 -- tools/qfcc/source/pr_def.c | 39 +++++++++++++++++++++----------------- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/cs-code/Makefile.am b/cs-code/Makefile.am index 97e77f5b8..0bc460c6c 100644 --- a/cs-code/Makefile.am +++ b/cs-code/Makefile.am @@ -11,7 +11,7 @@ QCPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include pkgdata_DATA= menu.dat -menu_src= menu.qc servlist.qc options.qc cbuf_def.qc cvar_def.qc draw_def.qc file_def.qc game_def.qc inputline_def.qc key_defs.qc menu_def.qc options_util.qc string_def.qc controls_o.qc stringh_def.qc +menu_src= menu.qc servlist.qc options.qc cbuf_def.qc cvar_def.qc draw_def.qc file_def.qc game_def.qc inputline_def.qc inputline_util.qc key_defs.qc menu_def.qc options_util.qc string_def.qc controls_o.qc stringh_def.qc menu.dat: menu.src $(menu_src) $(QFCC) $(QCFLAGS) $(QCPPFLAGS) -P $< diff --git a/cs-code/inputline_util.qc b/cs-code/inputline_util.qc index a49d41ad3..cc0aad713 100644 --- a/cs-code/inputline_util.qc +++ b/cs-code/inputline_util.qc @@ -31,15 +31,14 @@ Inserts characters of a string into a inputline. */ -#ifdef BUG_ELMEX + void (inputline_t il, string str) InputLine_SetText = { local integer i, charint; charint = String_GetChar(str,0); - for(i = 0; charint != 0; i++) { + for(i = 0; charint != 0; i++) { InputLine_Process(il, String_GetChar(str,i)); charint = String_GetChar(str,i); } }; -#endif diff --git a/cs-code/menu.qc b/cs-code/menu.qc index 4172c1e7e..96122d9fe 100644 --- a/cs-code/menu.qc +++ b/cs-code/menu.qc @@ -1,5 +1,6 @@ float () random = #0; float () traceon = #0; +float () traceoff = #0; string () gametype = #0; string (...) sprintf = #0; diff --git a/cs-code/string_def.qc b/cs-code/string_def.qc index f8df3e118..1e4f2bec5 100644 --- a/cs-code/string_def.qc +++ b/cs-code/string_def.qc @@ -1,6 +1,4 @@ string (integer old, integer new, string str) String_ReplaceChar = #0; string (integer pos, integer len, string str) String_Cut = #0; integer (string str) String_Len = #0; -#ifdef BUG_ELMEX integer (string str, integer pos) String_GetChar = #0; -#endif diff --git a/tools/qfcc/source/pr_def.c b/tools/qfcc/source/pr_def.c index 70753e8e9..95dec688a 100644 --- a/tools/qfcc/source/pr_def.c +++ b/tools/qfcc/source/pr_def.c @@ -26,8 +26,11 @@ static const char rcsid[] = #include #include "qfcc.h" +#include "expr.h" #include "struct.h" +extern expr_t *local_expr; // FIXME just where should this go? + typedef struct locref_s { struct locref_s *next; int ofs; @@ -192,27 +195,29 @@ PR_GetDef (type_t *type, const char *name, def_t *scope, int *allocate) size = PR_GetTypeSize (type->aux_type); pr.size_fields += size; } - } else if (type->type == ev_pointer) { - dstatement_t *st; - statref_t *ref; - int ofs; - - if (pr_scope) { - st = (dstatement_t *) &G_INT (def->ofs); - ref = PR_NewStatref (st, 4); - ref->next = def->refs; - def->refs = ref; - ofs = 1; - } else { - ofs = *allocate; - } + } else if (type->type == ev_pointer && type->num_parms) { + int ofs = *allocate; size = PR_GetTypeSize (type->aux_type); - if (type->num_parms) { - *allocate += type->num_parms * size; - def->initialized = def->constant = 1; + *allocate += type->num_parms * size; + + if (pr_scope) { + expr_t *e1 = new_expr (); + expr_t *e2 = new_expr (); + + e1->type = ex_def; + e1->e.def = def; + + e2->type = ex_def; + e2->e.def = PR_NewDef (type->aux_type, 0, pr_scope); + e2->e.def->ofs = ofs; + + append_expr (local_expr, new_binary_expr ('=', e1, address_expr (e2, 0, 0))); + } else { G_INT (def->ofs) = ofs; + def->constant = 1; } + def->initialized = 1; } return def;