mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
misc def improvments
This commit is contained in:
parent
9474765e75
commit
cb395c5469
6 changed files with 22 additions and 13 deletions
|
@ -205,7 +205,7 @@ emit_assign_expr (int oper, expr_t *e)
|
|||
def_a = emit_sub_expr (e1, 0);
|
||||
if (def_a->constant) {
|
||||
if (options.code.cow) {
|
||||
int size = pr_type_size[def_a->type->type];
|
||||
int size = type_size (def_a->type->type);
|
||||
int ofs = PR_NewLocation (def_a->type);
|
||||
|
||||
memcpy (pr.globals + ofs, pr.globals + def_a->ofs, size);
|
||||
|
|
|
@ -1990,14 +1990,14 @@ init_elements (def_t *def, expr_t *eles)
|
|||
} else if (e->type >= ex_string) {
|
||||
if (get_type (e) != def->type->aux_type) {
|
||||
error (e, "type mismatch in initializer");
|
||||
g += pr_type_size[def->type->aux_type->type];
|
||||
g += type_size (def->type->aux_type->type);
|
||||
} else {
|
||||
if (e->type == ex_string) {
|
||||
*(int*)g = ReuseString (e->e.string_val);
|
||||
} else {
|
||||
memcpy (g, &e->e, pr_type_size[extract_type (e)] * 4);
|
||||
memcpy (g, &e->e, type_size (extract_type (e)) * 4);
|
||||
}
|
||||
g += pr_type_size[extract_type (e)];
|
||||
g += type_size (extract_type (e));
|
||||
}
|
||||
} else {
|
||||
error (e, "non-constant initializer");
|
||||
|
|
|
@ -229,7 +229,7 @@ finish_function (function_t *f)
|
|||
if ((count = df->numparms) < 0)
|
||||
count = -count - 1;
|
||||
for (i = 0; i < count; i++)
|
||||
df->parm_size[i] = pr_type_size[f->def->type->parm_types[i]->type];
|
||||
df->parm_size[i] = type_size (f->def->type->parm_types[i]->type);
|
||||
|
||||
if (f->aux) {
|
||||
def_t *def;
|
||||
|
|
|
@ -284,7 +284,7 @@ ReuseConstant (expr_t *expr, def_t *def)
|
|||
if (e.type == ex_string)
|
||||
e.e.integer_val = ReuseString (rep->str);
|
||||
|
||||
memcpy (pr.globals + cn->ofs, &e.e, 4 * pr_type_size[type->type]);
|
||||
memcpy (pr.globals + cn->ofs, &e.e, 4 * type_size (type->type));
|
||||
|
||||
Hash_Add (tab, cn);
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ typedef struct locref_s {
|
|||
|
||||
static def_t *free_temps[4]; // indexted by type size
|
||||
static def_t temp_scope;
|
||||
static def_t *free_defs;
|
||||
static locref_t *free_locs[4]; // indexted by type size
|
||||
static locref_t *free_free_locs;
|
||||
|
||||
|
@ -213,7 +214,15 @@ PR_NewDef (type_t *type, const char *name, def_t *scope)
|
|||
{
|
||||
def_t *def;
|
||||
|
||||
def = calloc (1, sizeof (def_t));
|
||||
if (!free_defs) {
|
||||
int i;
|
||||
free_defs = malloc (16384 * sizeof (def_t));
|
||||
for (i = 0; i < 16383; i++)
|
||||
free_defs[i].next = &free_defs[i + 1];
|
||||
}
|
||||
def = free_defs;
|
||||
free_defs = free_defs->next;
|
||||
memset (def, 0, sizeof (*def));
|
||||
|
||||
if (name) {
|
||||
*pr.def_tail = def;
|
||||
|
@ -258,7 +267,7 @@ PR_NewLocation (type_t *type)
|
|||
void
|
||||
PR_FreeLocation (def_t *def)
|
||||
{
|
||||
int size = pr_type_size[def->type->type];
|
||||
int size = type_size (def->type->type);
|
||||
locref_t *loc;
|
||||
|
||||
if (!free_free_locs) {
|
||||
|
@ -279,7 +288,7 @@ PR_FreeLocation (def_t *def)
|
|||
def_t *
|
||||
PR_GetTempDef (type_t *type, def_t *scope)
|
||||
{
|
||||
int size = pr_type_size[type->type];
|
||||
int size = type_size (type->type);
|
||||
def_t *def;
|
||||
|
||||
if (free_temps[size]) {
|
||||
|
@ -289,7 +298,7 @@ PR_GetTempDef (type_t *type, def_t *scope)
|
|||
} else {
|
||||
def = PR_NewDef (type, 0, scope);
|
||||
def->ofs = *scope->alloc;
|
||||
*scope->alloc += pr_type_size[size];
|
||||
*scope->alloc += type_size (size);
|
||||
}
|
||||
def->freed = def->removed = def->users = 0;
|
||||
def->next = temp_scope.next;
|
||||
|
@ -313,7 +322,7 @@ PR_FreeTempDefs (void)
|
|||
printf ("%s:%d: warning: %s %3d %3d %d\n", pr.strings + d->file,
|
||||
d->line, pr_type_name[d->type->type], d->ofs, d->users,
|
||||
d->managed);
|
||||
size = pr_type_size[d->type->type];
|
||||
size = type_size (d->type->type);
|
||||
if (d->expr)
|
||||
d->expr->e.temp.def = 0;
|
||||
|
||||
|
|
|
@ -129,8 +129,8 @@ WriteData (int crc)
|
|||
FILE *h;
|
||||
int i;
|
||||
|
||||
globals = calloc (pr.num_globals, sizeof (ddef_t)); //FIXME
|
||||
fields = calloc (pr.num_globals, sizeof (ddef_t)); //FIXME
|
||||
globals = calloc (pr.num_globals, sizeof (ddef_t));
|
||||
fields = calloc (pr.num_globals, sizeof (ddef_t));
|
||||
|
||||
for (def = pr.def_head; def; def = def->def_next) {
|
||||
if (def->scope)
|
||||
|
|
Loading…
Reference in a new issue