fix handling of pointers in function params and local vars for qc functions

This commit is contained in:
Bill Currie 2002-03-18 07:30:21 +00:00
parent 46cc4ac9dd
commit 655fe17e18
5 changed files with 26 additions and 23 deletions

View file

@ -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 $<

View file

@ -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

View file

@ -1,5 +1,6 @@
float () random = #0;
float () traceon = #0;
float () traceoff = #0;
string () gametype = #0;
string (...) sprintf = #0;

View file

@ -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

View file

@ -26,8 +26,11 @@ static const char rcsid[] =
#include <QF/sys.h>
#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;