mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
clear out the hash tables for compiling multiple object files
This commit is contained in:
parent
a6d999dfa4
commit
8415db2d84
14 changed files with 148 additions and 35 deletions
|
@ -96,4 +96,6 @@ void add_protocol (protocollist_t *protocollist, protocol_t *protocol);
|
|||
int emit_protocol (protocol_t *protocol);
|
||||
int emit_protocol_list (protocollist_t *protocols, const char *name);
|
||||
|
||||
void clear_classes (void);
|
||||
|
||||
#endif//__class_h
|
||||
|
|
|
@ -111,5 +111,6 @@ void reset_tempdefs ();
|
|||
void flush_scope (scope_t *scope, int force_used);
|
||||
void def_initialized (def_t *d);
|
||||
|
||||
void clear_defs (void);
|
||||
|
||||
#endif//__def_h
|
||||
|
|
|
@ -38,4 +38,6 @@ struct def_s *ReuseConstant (struct expr_s *expr, struct def_s *def);
|
|||
int CopyString (const char *str);
|
||||
int ReuseString (const char *str);
|
||||
|
||||
void clear_immediates (void);
|
||||
|
||||
#endif//__immediate_h
|
||||
|
|
|
@ -82,4 +82,6 @@ struct def_s *selector_def (const char *sel_id, const char *sel_types);
|
|||
|
||||
int emit_methods (methodlist_t *methods, const char *name, int instance);
|
||||
|
||||
void clear_selectors (void);
|
||||
|
||||
#endif//__method_h
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#ifndef __qfcc_h
|
||||
#define __qfcc_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include "QF/pr_comp.h"
|
||||
|
||||
//============================================================================
|
||||
|
@ -93,6 +94,9 @@ extern string_t s_file; // filename for function definition
|
|||
const char *strip_path (const char *filename);
|
||||
|
||||
const char *save_string (const char *str);
|
||||
void clear_frame_macros (void);
|
||||
extern FILE *yyin;
|
||||
int yyparse (void);
|
||||
|
||||
#define ALLOC(s, t, n, v) \
|
||||
do { \
|
||||
|
|
|
@ -60,4 +60,7 @@ int emit_struct (struct type_s *strct, const char *name);
|
|||
void process_enum (struct expr_s *enm);
|
||||
expr_t *get_enum (const char *name);
|
||||
|
||||
void clear_structs (void);
|
||||
void clear_enums (void);
|
||||
|
||||
#endif//__struct_h
|
||||
|
|
|
@ -89,4 +89,6 @@ int type_size (type_t *type);
|
|||
|
||||
void init_types (void);
|
||||
|
||||
void clear_typedefs (void);
|
||||
|
||||
#endif//__type_h
|
||||
|
|
|
@ -618,3 +618,14 @@ emit_protocol_list (protocollist_t *protocols, const char *name)
|
|||
proto_list->list[i] = emit_protocol (protocols->list[i]);
|
||||
return proto_list_def->ofs;
|
||||
}
|
||||
|
||||
void
|
||||
clear_classes (void)
|
||||
{
|
||||
if (class_hash)
|
||||
Hash_FlushTable (class_hash);
|
||||
if (protocol_hash)
|
||||
Hash_FlushTable (protocol_hash);
|
||||
if (category_hash)
|
||||
Hash_FlushTable (category_hash);
|
||||
}
|
||||
|
|
|
@ -397,3 +397,10 @@ def_initialized (def_t *d)
|
|||
d->initialized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
clear_defs (void)
|
||||
{
|
||||
if (defs_by_name)
|
||||
Hash_FlushTable (defs_by_name);
|
||||
}
|
||||
|
|
|
@ -156,32 +156,7 @@ ReuseConstant (expr_t *expr, def_t *def)
|
|||
if (!rep)
|
||||
rep = dstring_newstr ();
|
||||
if (!string_imm_defs) {
|
||||
string_imm_defs = Hash_NewTable (16381, string_imm_get_key, 0, 0);
|
||||
float_imm_defs = Hash_NewTable (16381, float_imm_get_key, 0, 0);
|
||||
vector_imm_defs = Hash_NewTable (16381, vector_imm_get_key, 0, 0);
|
||||
entity_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "entity");
|
||||
field_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "field");
|
||||
func_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "func");
|
||||
pointer_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "pointer");
|
||||
quaternion_imm_defs =
|
||||
Hash_NewTable (16381, quaternion_imm_get_key, 0, 0);
|
||||
integer_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "integer");
|
||||
|
||||
Hash_Add (string_imm_defs, cn = new_def (&type_string, ".imm",
|
||||
pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
Hash_Add (float_imm_defs, cn = new_def (&type_float, ".imm",
|
||||
pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
Hash_Add (entity_imm_defs, cn = new_def (&type_entity, ".imm",
|
||||
pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
Hash_Add (pointer_imm_defs, cn = new_def (&type_pointer, ".imm",
|
||||
pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
Hash_Add (integer_imm_defs, cn = new_def (&type_integer, ".imm",
|
||||
pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
clear_immediates ();
|
||||
}
|
||||
cn = 0;
|
||||
switch (e.type) {
|
||||
|
@ -295,3 +270,41 @@ ReuseConstant (expr_t *expr, def_t *def)
|
|||
|
||||
return cn;
|
||||
}
|
||||
|
||||
void
|
||||
clear_immediates (void)
|
||||
{
|
||||
def_t *cn;
|
||||
if (string_imm_defs) {
|
||||
Hash_FlushTable (string_imm_defs);
|
||||
Hash_FlushTable (float_imm_defs);
|
||||
Hash_FlushTable (vector_imm_defs);
|
||||
Hash_FlushTable (entity_imm_defs);
|
||||
Hash_FlushTable (field_imm_defs);
|
||||
Hash_FlushTable (func_imm_defs);
|
||||
Hash_FlushTable (pointer_imm_defs);
|
||||
Hash_FlushTable (quaternion_imm_defs);
|
||||
} else {
|
||||
string_imm_defs = Hash_NewTable (16381, string_imm_get_key, 0, 0);
|
||||
float_imm_defs = Hash_NewTable (16381, float_imm_get_key, 0, 0);
|
||||
vector_imm_defs = Hash_NewTable (16381, vector_imm_get_key, 0, 0);
|
||||
entity_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "entity");
|
||||
field_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "field");
|
||||
func_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "func");
|
||||
pointer_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "pointer");
|
||||
quaternion_imm_defs =
|
||||
Hash_NewTable (16381, quaternion_imm_get_key, 0, 0);
|
||||
}
|
||||
integer_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "integer");
|
||||
|
||||
Hash_Add (string_imm_defs, cn = new_def (&type_string, ".imm", pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
Hash_Add (float_imm_defs, cn = new_def (&type_float, ".imm", pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
Hash_Add (entity_imm_defs, cn = new_def (&type_entity, ".imm", pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
Hash_Add (pointer_imm_defs, cn = new_def (&type_pointer, ".imm", pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
Hash_Add (integer_imm_defs, cn = new_def (&type_integer, ".imm", pr.scope));
|
||||
cn->initialized = cn->constant = 1;
|
||||
}
|
||||
|
|
|
@ -323,3 +323,10 @@ emit_methods (methodlist_t *_methods, const char *name, int instance)
|
|||
}
|
||||
return methods_def->ofs;
|
||||
}
|
||||
|
||||
void
|
||||
clear_selectors (void)
|
||||
{
|
||||
if (sel_def_hash)
|
||||
Hash_FlushTable (sel_def_hash);
|
||||
}
|
||||
|
|
|
@ -71,10 +71,12 @@ static const char rcsid[] =
|
|||
#include "function.h"
|
||||
#include "idstuff.h"
|
||||
#include "immediate.h"
|
||||
#include "method.h"
|
||||
#include "obj_file.h"
|
||||
#include "opcodes.h"
|
||||
#include "options.h"
|
||||
#include "reloc.h"
|
||||
#include "struct.h"
|
||||
#include "type.h"
|
||||
|
||||
options_t options;
|
||||
|
@ -125,6 +127,12 @@ InitData (void)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (pr.statements) {
|
||||
free (pr.statements);
|
||||
memset (&pr, 0, sizeof (pr));
|
||||
}
|
||||
pr_source_line = 1;
|
||||
pr_error_count = 0;
|
||||
pr.num_statements = 1;
|
||||
pr.strofs = 1;
|
||||
pr.num_functions = 1;
|
||||
|
@ -444,6 +452,37 @@ setup_sym_file (const char *output_file)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
compile_to_obj (const char *file, const char *obj)
|
||||
{
|
||||
int err;
|
||||
|
||||
yyin = preprocess_file (file);
|
||||
|
||||
InitData ();
|
||||
begin_compilation ();
|
||||
s_file = ReuseString (strip_path (file));
|
||||
clear_frame_macros ();
|
||||
clear_classes ();
|
||||
clear_defs ();
|
||||
clear_immediates ();
|
||||
clear_selectors ();
|
||||
clear_structs ();
|
||||
clear_enums ();
|
||||
clear_typedefs ();
|
||||
err = yyparse () || pr_error_count;
|
||||
fclose (yyin);
|
||||
if (cpp_name && (!options.save_temps)) {
|
||||
if (unlink (tempname->str)) {
|
||||
perror ("unlink");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
if (!err)
|
||||
write_obj_file (obj);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
separate_compile (void)
|
||||
{
|
||||
|
@ -475,6 +514,9 @@ separate_compile (void)
|
|||
if (strncmp (*file, "-l", 2)
|
||||
&& (!strcmp (extension->str, ".r")
|
||||
|| !strcmp (extension->str, ".qc"))) {
|
||||
printf ("%s %s\n", *file, output_file->str);
|
||||
compile_to_obj (*file, output_file->str);
|
||||
|
||||
free ((char *)*file);
|
||||
*file = strdup (output_file->str);
|
||||
} else {
|
||||
|
@ -522,15 +564,13 @@ progs_src_compile (void)
|
|||
}
|
||||
setup_sym_file (options.output_file);
|
||||
|
||||
InitData ();
|
||||
|
||||
begin_compilation ();
|
||||
|
||||
// compile all the files
|
||||
while ((src = Parse (src))) {
|
||||
int error;
|
||||
|
||||
extern FILE *yyin;
|
||||
int yyparse (void);
|
||||
extern void clear_frame_macros (void);
|
||||
int err;
|
||||
|
||||
//extern int yydebug;
|
||||
//yydebug = 1;
|
||||
|
@ -548,7 +588,7 @@ progs_src_compile (void)
|
|||
s_file = ReuseString (strip_path (filename->str));
|
||||
pr_source_line = 1;
|
||||
clear_frame_macros ();
|
||||
error = yyparse () || pr_error_count;
|
||||
err = yyparse () || pr_error_count;
|
||||
fclose (yyin);
|
||||
if (cpp_name && (!options.save_temps)) {
|
||||
if (unlink (tempname->str)) {
|
||||
|
@ -556,7 +596,7 @@ progs_src_compile (void)
|
|||
exit (1);
|
||||
}
|
||||
}
|
||||
if (error)
|
||||
if (err)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -608,8 +648,6 @@ main (int argc, char **argv)
|
|||
opcode_init ();
|
||||
init_types ();
|
||||
|
||||
InitData ();
|
||||
|
||||
if (source_files) {
|
||||
res = separate_compile ();
|
||||
} else {
|
||||
|
|
|
@ -246,6 +246,13 @@ emit_struct(type_t *strct, const char *name)
|
|||
return ivars_def->ofs;
|
||||
}
|
||||
|
||||
void
|
||||
clear_structs (void)
|
||||
{
|
||||
if (structs)
|
||||
Hash_FlushTable (structs);
|
||||
}
|
||||
|
||||
void
|
||||
process_enum (expr_t *enm)
|
||||
{
|
||||
|
@ -302,3 +309,10 @@ get_enum (const char *name)
|
|||
return 0;
|
||||
return &e->value;
|
||||
}
|
||||
|
||||
void
|
||||
clear_enums (void)
|
||||
{
|
||||
if (enums)
|
||||
Hash_FlushTable (enums);
|
||||
}
|
||||
|
|
|
@ -529,3 +529,10 @@ init_types (void)
|
|||
type_obj_exec_class.parm_types[0] = pointer_type (type_module);
|
||||
chain_type (&type_obj_exec_class);
|
||||
}
|
||||
|
||||
void
|
||||
clear_typedefs (void)
|
||||
{
|
||||
if (typedef_hash)
|
||||
Hash_FlushTable (typedef_hash);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue