mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
qfcc.h:
rearrange def_t a little and add def_next (leaving next free for other uses) pr_def.c: use def_next instead of next to link /all/ of the named defs qfcc.c: ditto
This commit is contained in:
parent
327e95a3c8
commit
56aafce20c
3 changed files with 19 additions and 20 deletions
|
@ -281,17 +281,18 @@ typedef struct statref_s {
|
|||
int field; // a, b, c (0, 1, 2)
|
||||
} statref_t;
|
||||
|
||||
typedef struct def_s
|
||||
{
|
||||
type_t *type;
|
||||
typedef struct def_s {
|
||||
type_t *type;
|
||||
const char *name;
|
||||
struct def_s *next;
|
||||
int num_locals;
|
||||
struct def_s *scope_next; // to facilitate hash table removal
|
||||
gofs_t ofs;
|
||||
struct def_s *scope; // function the var was defined in, or NULL
|
||||
int initialized; // 1 when a declaration included "= immediate"
|
||||
gofs_t ofs;
|
||||
int initialized;// 1 when a declaration included "= immediate"
|
||||
statref_t *refs; // for relocations
|
||||
|
||||
struct def_s *def_next; // for writing out the global defs list
|
||||
struct def_s *next; // general purpose linking
|
||||
struct def_s *scope_next; // to facilitate hash table removal
|
||||
struct def_s *scope; // function the var was defined in, or NULL
|
||||
} def_t;
|
||||
|
||||
//============================================================================
|
||||
|
|
|
@ -134,12 +134,10 @@ PR_NewDef (type_t *type, const char *name, def_t *scope)
|
|||
|
||||
def = calloc (1, sizeof (def_t));
|
||||
|
||||
#if 1
|
||||
if (name) {
|
||||
pr.def_tail->next = def;
|
||||
pr.def_tail->def_next = def;
|
||||
pr.def_tail = def;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (scope) {
|
||||
def->scope_next = scope->scope_next;
|
||||
|
|
|
@ -235,7 +235,7 @@ WriteData (int crc)
|
|||
FILE *h;
|
||||
int i;
|
||||
|
||||
for (def = pr.def_head.next; def; def = def->next) {
|
||||
for (def = pr.def_head.def_next; def; def = def->def_next) {
|
||||
if (def->scope)
|
||||
continue;
|
||||
if (def->type->type == ev_func) {
|
||||
|
@ -397,7 +397,7 @@ PR_DefForFieldOfs (gofs_t ofs)
|
|||
{
|
||||
def_t *d;
|
||||
|
||||
for (d = pr.def_head.next; d; d = d->next) {
|
||||
for (d = pr.def_head.def_next; d; d = d->def_next) {
|
||||
if (d->type->type != ev_field)
|
||||
continue;
|
||||
if (*((int *) &pr_globals[d->ofs]) == ofs)
|
||||
|
@ -575,7 +575,7 @@ PR_PrintDefs (void)
|
|||
{
|
||||
def_t *d;
|
||||
|
||||
for (d = pr.def_head.next; d; d = d->next)
|
||||
for (d = pr.def_head.def_next; d; d = d->def_next)
|
||||
PR_PrintOfs (d->ofs);
|
||||
}
|
||||
|
||||
|
@ -641,7 +641,7 @@ PR_FinishCompilation (void)
|
|||
def_t *def;
|
||||
|
||||
// check to make sure all functions prototyped have code
|
||||
for (d = pr.def_head.next; d; d = d->next) {
|
||||
for (d = pr.def_head.def_next; d; d = d->def_next) {
|
||||
if (d->type->type == ev_func && !d->scope) { // function args ok
|
||||
// f = G_FUNCTION(d->ofs);
|
||||
// if (!f || (!f->code && !f->builtin))
|
||||
|
@ -655,7 +655,7 @@ PR_FinishCompilation (void)
|
|||
if (errors)
|
||||
return !errors;
|
||||
|
||||
for (def = pr.def_head.next; def; def = def->next) {
|
||||
for (def = pr.def_head.def_next; def; def = def->def_next) {
|
||||
if (def->scope)
|
||||
continue;
|
||||
PR_RelocateRefs (def);
|
||||
|
@ -700,7 +700,7 @@ PR_WriteProgdefs (char *filename)
|
|||
// print global vars until the first field is defined
|
||||
fprintf (f, "\n/* file generated by qcc, do not modify */\n\ntypedef struct\n{\tint\tpad[%i];\n", RESERVED_OFS);
|
||||
|
||||
for (d = pr.def_head.next; d; d = d->next) {
|
||||
for (d = pr.def_head.def_next; d; d = d->def_next) {
|
||||
if (!strcmp (d->name, "end_sys_globals"))
|
||||
break;
|
||||
|
||||
|
@ -710,7 +710,7 @@ PR_WriteProgdefs (char *filename)
|
|||
break;
|
||||
case ev_vector:
|
||||
fprintf (f, "\tvec3_t\t%s;\n", d->name);
|
||||
d = d->next->next->next; // skip the elements
|
||||
d = d->def_next->def_next->def_next; // skip the elements
|
||||
break;
|
||||
case ev_string:
|
||||
fprintf (f, "\tstring_t\t%s;\n", d->name);
|
||||
|
@ -730,7 +730,7 @@ PR_WriteProgdefs (char *filename)
|
|||
|
||||
// print all fields
|
||||
fprintf (f, "typedef struct\n{\n");
|
||||
for (d = pr.def_head.next; d; d = d->next) {
|
||||
for (d = pr.def_head.def_next; d; d = d->def_next) {
|
||||
if (!strcmp (d->name, "end_sys_fields"))
|
||||
break;
|
||||
|
||||
|
@ -743,7 +743,7 @@ PR_WriteProgdefs (char *filename)
|
|||
break;
|
||||
case ev_vector:
|
||||
fprintf (f, "\tvec3_t\t%s;\n", d->name);
|
||||
d = d->next->next->next; // skip the elements
|
||||
d = d->def_next->def_next->def_next; // skip the elements
|
||||
break;
|
||||
case ev_string:
|
||||
fprintf (f, "\tstring_t\t%s;\n", d->name);
|
||||
|
|
Loading…
Reference in a new issue