mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +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)
|
int field; // a, b, c (0, 1, 2)
|
||||||
} statref_t;
|
} statref_t;
|
||||||
|
|
||||||
typedef struct def_s
|
typedef struct def_s {
|
||||||
{
|
type_t *type;
|
||||||
type_t *type;
|
|
||||||
const char *name;
|
const char *name;
|
||||||
struct def_s *next;
|
|
||||||
int num_locals;
|
int num_locals;
|
||||||
struct def_s *scope_next; // to facilitate hash table removal
|
gofs_t ofs;
|
||||||
gofs_t ofs;
|
int initialized;// 1 when a declaration included "= immediate"
|
||||||
struct def_s *scope; // function the var was defined in, or NULL
|
|
||||||
int initialized; // 1 when a declaration included "= immediate"
|
|
||||||
statref_t *refs; // for relocations
|
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;
|
} def_t;
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
|
@ -134,12 +134,10 @@ PR_NewDef (type_t *type, const char *name, def_t *scope)
|
||||||
|
|
||||||
def = calloc (1, sizeof (def_t));
|
def = calloc (1, sizeof (def_t));
|
||||||
|
|
||||||
#if 1
|
|
||||||
if (name) {
|
if (name) {
|
||||||
pr.def_tail->next = def;
|
pr.def_tail->def_next = def;
|
||||||
pr.def_tail = def;
|
pr.def_tail = def;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (scope) {
|
if (scope) {
|
||||||
def->scope_next = scope->scope_next;
|
def->scope_next = scope->scope_next;
|
||||||
|
|
|
@ -235,7 +235,7 @@ WriteData (int crc)
|
||||||
FILE *h;
|
FILE *h;
|
||||||
int i;
|
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)
|
if (def->scope)
|
||||||
continue;
|
continue;
|
||||||
if (def->type->type == ev_func) {
|
if (def->type->type == ev_func) {
|
||||||
|
@ -397,7 +397,7 @@ PR_DefForFieldOfs (gofs_t ofs)
|
||||||
{
|
{
|
||||||
def_t *d;
|
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)
|
if (d->type->type != ev_field)
|
||||||
continue;
|
continue;
|
||||||
if (*((int *) &pr_globals[d->ofs]) == ofs)
|
if (*((int *) &pr_globals[d->ofs]) == ofs)
|
||||||
|
@ -575,7 +575,7 @@ PR_PrintDefs (void)
|
||||||
{
|
{
|
||||||
def_t *d;
|
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);
|
PR_PrintOfs (d->ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,7 +641,7 @@ PR_FinishCompilation (void)
|
||||||
def_t *def;
|
def_t *def;
|
||||||
|
|
||||||
// check to make sure all functions prototyped have code
|
// 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
|
if (d->type->type == ev_func && !d->scope) { // function args ok
|
||||||
// f = G_FUNCTION(d->ofs);
|
// f = G_FUNCTION(d->ofs);
|
||||||
// if (!f || (!f->code && !f->builtin))
|
// if (!f || (!f->code && !f->builtin))
|
||||||
|
@ -655,7 +655,7 @@ PR_FinishCompilation (void)
|
||||||
if (errors)
|
if (errors)
|
||||||
return !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)
|
if (def->scope)
|
||||||
continue;
|
continue;
|
||||||
PR_RelocateRefs (def);
|
PR_RelocateRefs (def);
|
||||||
|
@ -700,7 +700,7 @@ PR_WriteProgdefs (char *filename)
|
||||||
// print global vars until the first field is defined
|
// 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);
|
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"))
|
if (!strcmp (d->name, "end_sys_globals"))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ PR_WriteProgdefs (char *filename)
|
||||||
break;
|
break;
|
||||||
case ev_vector:
|
case ev_vector:
|
||||||
fprintf (f, "\tvec3_t\t%s;\n", d->name);
|
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;
|
break;
|
||||||
case ev_string:
|
case ev_string:
|
||||||
fprintf (f, "\tstring_t\t%s;\n", d->name);
|
fprintf (f, "\tstring_t\t%s;\n", d->name);
|
||||||
|
@ -730,7 +730,7 @@ PR_WriteProgdefs (char *filename)
|
||||||
|
|
||||||
// print all fields
|
// print all fields
|
||||||
fprintf (f, "typedef struct\n{\n");
|
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"))
|
if (!strcmp (d->name, "end_sys_fields"))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -743,7 +743,7 @@ PR_WriteProgdefs (char *filename)
|
||||||
break;
|
break;
|
||||||
case ev_vector:
|
case ev_vector:
|
||||||
fprintf (f, "\tvec3_t\t%s;\n", d->name);
|
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;
|
break;
|
||||||
case ev_string:
|
case ev_string:
|
||||||
fprintf (f, "\tstring_t\t%s;\n", d->name);
|
fprintf (f, "\tstring_t\t%s;\n", d->name);
|
||||||
|
|
Loading…
Reference in a new issue