even more cleanup

This commit is contained in:
Bill Currie 2002-06-04 21:23:39 +00:00
parent 080a46469f
commit 69605d0b19
19 changed files with 164 additions and 70 deletions

View file

@ -1,4 +1,5 @@
AUTOMAKE_OPTIONS= foreign
EXTRA_DIST= class.h cmdlib.h cpp.h def.h expr.h function.h idstuff.h \
immediate.h method.h options.h qfcc.h struct.h switch.h type.h
EXTRA_DIST= class.h cmdlib.h cpp.h debug.h def.h expr.h function.h idstuff.h \
immediate.h method.h opcodes.h options.h qfcc.h struct.h switch.h \
type.h

View file

@ -0,0 +1,50 @@
/*
debug.h
#DESCRIPTION#
Copyright (C) 2001 #AUTHOR#
Author: #AUTHOR#
Date: #DATE#
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __debug_h
#define __debug_h
#include "QF/pr_debug.h"
extern int num_auxfunctions;
extern pr_auxfunction_t *auxfunctions;
extern int num_linenos;
extern pr_lineno_t *linenos;
extern int num_locals;
extern struct ddef_s *locals;
pr_auxfunction_t *new_auxfunction (void);
pr_lineno_t *new_lineno (void);
struct ddef_s *new_local (void);
#endif//__debug_h

View file

@ -57,7 +57,7 @@ typedef enum {
} expr_type;
typedef struct {
statref_t *refs;
struct statref_s *refs;
dstatement_t *statement;
const char *name;
} ex_label_t;

View file

@ -0,0 +1,64 @@
/*
opcodes.h
#DESCRIPTION#
Copyright (C) 2001 #AUTHOR#
Author: #AUTHOR#
Date: #DATE#
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __opcodes_h
#define __opcodes_h
#include "QF/pr_comp.h"
typedef struct statref_s {
struct statref_s *next;
dstatement_t *statement;
int field; // a, b, c (0, 1, 2)
} statref_t;
extern opcode_t *op_done;
extern opcode_t *op_return;
extern opcode_t *op_if;
extern opcode_t *op_ifnot;
extern opcode_t *op_ifbe;
extern opcode_t *op_ifb;
extern opcode_t *op_ifae;
extern opcode_t *op_ifa;
extern opcode_t *op_state;
extern opcode_t *op_goto;
extern opcode_t *op_jump;
extern opcode_t *op_jumpb;
statref_t *PR_NewStatref (dstatement_t *st, int field);
void PR_AddStatementRef (struct def_s *def, dstatement_t *st, int field);
struct def_s *PR_Statement (opcode_t *op, struct def_s *var_a,
struct def_s *var_b);
opcode_t *PR_Opcode_Find (const char *name, struct def_s *var_a,
struct def_s *var_b, struct def_s *var_c);
void PR_Opcode_Init_Tables (void);
#endif//__opcodes_h

View file

@ -33,15 +33,6 @@
#define __qfcc_h
#include "QF/pr_comp.h"
#include "QF/pr_debug.h"
#include "def.h"
typedef struct statref_s {
struct statref_s *next;
dstatement_t *statement;
int field; // a, b, c (0, 1, 2)
} statref_t;
//============================================================================
@ -53,59 +44,37 @@ typedef struct statref_s {
// output generated by prog parsing
//
typedef struct {
int current_memory;
struct type_s *types;
def_t def_head; // unused head of linked list
def_t *def_tail; // add new defs after this and move it
def_t *search; // search chain through defs
struct def_s *def_head; // unused head of linked list
struct def_s **def_tail; // add new defs after this and move it
int size_fields;
int size_fields;
} pr_info_t;
extern pr_info_t pr;
extern opcode_t *op_done;
extern opcode_t *op_return;
extern opcode_t *op_if;
extern opcode_t *op_ifnot;
extern opcode_t *op_ifbe;
extern opcode_t *op_ifb;
extern opcode_t *op_ifae;
extern opcode_t *op_ifa;
extern opcode_t *op_state;
extern opcode_t *op_goto;
extern opcode_t *op_jump;
extern opcode_t *op_jumpb;
statref_t *PR_NewStatref (dstatement_t *st, int field);
void PR_AddStatementRef (def_t *def, dstatement_t *st, int field);
def_t *PR_Statement (opcode_t *op, def_t *var_a, def_t *var_b);
opcode_t *PR_Opcode_Find (const char *name,
def_t *var_a, def_t *var_b, def_t *var_c);
void PR_Opcode_Init_Tables (void);
//============================================================================
extern char destfile[];
extern int pr_source_line;
extern def_t *pr_scope;
extern struct def_s *pr_scope;
extern int pr_error_count;
def_t *PR_GetArray (struct type_s *etype, const char *name, int size,
def_t *scope, int *allocate);
struct def_s *PR_GetArray (struct type_s *etype, const char *name, int size,
struct def_s *scope, int *allocate);
def_t *PR_GetDef (struct type_s *type, const char *name, def_t *scope,
struct def_s *PR_GetDef (struct type_s *type, const char *name, struct def_s *scope,
int *allocate);
def_t *PR_NewDef (struct type_s *type, const char *name, def_t *scope);
struct def_s *PR_NewDef (struct type_s *type, const char *name, struct def_s *scope);
int PR_NewLocation (struct type_s *type);
void PR_FreeLocation (def_t *def);
def_t *PR_GetTempDef (struct type_s *type, def_t *scope);
void PR_FreeLocation (struct def_s *def);
struct def_s *PR_GetTempDef (struct type_s *type, struct def_s *scope);
void PR_FreeTempDefs ();
void PR_ResetTempDefs ();
void PR_FlushScope (def_t *scope, int force_used);
void PR_DefInitialized (def_t *d);
void PR_FlushScope (struct def_s *scope, int force_used);
void PR_DefInitialized (struct def_s *d);
#define G_FLOAT(o) (pr_globals[o])
#define G_INT(o) (*(int *)&pr_globals[o])
@ -137,19 +106,6 @@ extern int numfunctions;
extern float pr_globals[MAX_REGS];
extern int numpr_globals;
extern int num_auxfunctions;
extern pr_auxfunction_t *auxfunctions;
extern int num_linenos;
extern pr_lineno_t *linenos;
extern int num_locals;
extern ddef_t *locals;
pr_auxfunction_t *new_auxfunction (void);
pr_lineno_t *new_lineno (void);
ddef_t *new_local (void);
const char *strip_path (const char *filename);
#endif//__qfcc_h

View file

@ -41,7 +41,9 @@ static const char rcsid[] =
#endif
#include <stdlib.h>
#include "qfcc.h"
#include "QF/pr_comp.h"
#include "debug.h"
static int auxfunctions_size;
int num_auxfunctions;

View file

@ -44,10 +44,13 @@ static const char rcsid[] =
#include <QF/mathlib.h>
#include <QF/va.h>
#include "qfcc.h"
#include "def.h"
#include "debug.h"
#include "expr.h"
#include "immediate.h"
#include "opcodes.h"
#include "options.h"
#include "qfcc.h"
#include "type.h"
#include "qc-parse.h"

View file

@ -47,8 +47,9 @@ static const char rcsid[] =
#include <QF/va.h>
#include "qfcc.h"
#include "expr.h"
#include "class.h"
#include "def.h"
#include "expr.h"
#include "function.h"
#include "idstuff.h"
#include "immediate.h"

View file

@ -45,9 +45,12 @@ static const char rcsid[] =
#include "qfcc.h"
#include "debug.h"
#include "def.h"
#include "expr.h"
#include "function.h"
#include "immediate.h"
#include "opcodes.h"
#include "type.h"
param_t *

View file

@ -33,6 +33,7 @@ static const char rcsid[] =
#include <QF/dstring.h>
#include "cmdlib.h"
#include "def.h"
#include "qfcc.h"
#include "expr.h"
#include "options.h"
@ -206,7 +207,7 @@ WriteProgdefs (char *filename)
"\n/* file generated by qcc, do not modify */\n\ntypedef struct\n{\tint\tpad[%i];\n",
RESERVED_OFS);
for (d = pr.def_head.def_next; d; d = d->def_next) {
for (d = pr.def_head; d; d = d->def_next) {
if (!strcmp (d->name, "end_sys_globals"))
break;
@ -236,7 +237,7 @@ WriteProgdefs (char *filename)
// print all fields
fprintf (f, "typedef struct\n{\n");
for (d = pr.def_head.def_next; d; d = d->def_next) {
for (d = pr.def_head; d; d = d->def_next) {
if (!strcmp (d->name, "end_sys_fields"))
break;

View file

@ -35,6 +35,7 @@ static const char rcsid[] =
#include "QF/va.h"
#include "qfcc.h"
#include "def.h"
#include "expr.h"
#include "immediate.h"
#include "type.h"

View file

@ -50,6 +50,7 @@ static const char rcsid[] =
#include "expr.h"
#include "class.h"
#include "def.h"
#include "immediate.h"
#include "method.h"
#include "struct.h"

View file

@ -33,6 +33,8 @@ static const char rcsid[] =
#include <QF/hash.h>
#include "qfcc.h"
#include "def.h"
#include "opcodes.h"
#include "options.h"
#include "type.h"

View file

@ -35,6 +35,7 @@ static const char rcsid[] =
#include <QF/va.h>
#include "qfcc.h"
#include "def.h"
#include "expr.h"
#include "struct.h"
#include "type.h"
@ -215,8 +216,8 @@ PR_NewDef (type_t *type, const char *name, def_t *scope)
def = calloc (1, sizeof (def_t));
if (name) {
pr.def_tail->def_next = def;
pr.def_tail = def;
*pr.def_tail = def;
pr.def_tail = &def->def_next;
}
if (scope) {

View file

@ -46,6 +46,8 @@ static const char rcsid[] =
#include <QF/sys.h>
#include "qfcc.h"
#include "debug.h"
#include "def.h"
#include "expr.h"
#include "function.h"
#include "immediate.h"
@ -87,7 +89,7 @@ void free_local_inits (hashtab_t *def_list);
%union {
int op;
def_t *def;
struct def_s *def;
struct hashtab_s *def_list;
type_t *type;
expr_t *expr;

View file

@ -65,11 +65,13 @@ static const char rcsid[] =
#include "class.h"
#include "cmdlib.h"
#include "cpp.h"
#include "debug.h"
#include "def.h"
#include "expr.h"
#include "function.h"
#include "idstuff.h"
#include "immediate.h"
#include "opcodes.h"
#include "options.h"
#include "type.h"
@ -136,7 +138,7 @@ WriteData (int crc)
FILE *h;
int i;
for (def = pr.def_head.def_next; def; def = def->def_next) {
for (def = pr.def_head; def; def = def->def_next) {
if (def->scope)
continue;
if (def->type->type == ev_func) {
@ -354,7 +356,7 @@ qboolean PR_FinishCompilation (void)
class_finish_module ();
// check to make sure all functions prototyped have code
if (options.warnings.undefined_function)
for (d = pr.def_head.def_next; d; d = d->def_next) {
for (d = pr.def_head; d; d = d->def_next) {
if (d->type->type == ev_func && !d->scope) { // function args ok
if (d->used) {
if (!d->initialized) {
@ -375,7 +377,7 @@ qboolean PR_FinishCompilation (void)
&numpr_globals));
}
for (def = pr.def_head.def_next; def; def = def->def_next) {
for (def = pr.def_head; def; def = def->def_next) {
if (def->scope || def->absolute)
continue;
PR_RelocateRefs (def);

View file

@ -48,6 +48,7 @@ static const char rcsid[] =
#include <QF/va.h>
#include "qfcc.h"
#include "def.h"
#include "expr.h"
#include "immediate.h"
#include "struct.h"

View file

@ -45,7 +45,9 @@ static const char rcsid[] =
#include <QF/sys.h>
#include "qfcc.h"
#include "def.h"
#include "expr.h"
#include "opcodes.h"
#include "options.h"
#include "type.h"
#include "switch.h"

View file

@ -47,6 +47,7 @@ static const char rcsid[] =
#include "QF/va.h"
#include "qfcc.h"
#include "def.h"
#include "expr.h"
#include "class.h"
#include "function.h"