mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
"qfcc *.qc" can now get through the prozac source withtout crashing (oodles
of compile errors, though:)
This commit is contained in:
parent
8415db2d84
commit
1a0b69e1d9
3 changed files with 48 additions and 19 deletions
|
@ -405,7 +405,7 @@ new_label_name (void)
|
|||
}
|
||||
|
||||
expr_t *
|
||||
new_error_expr ()
|
||||
new_error_expr (void)
|
||||
{
|
||||
expr_t *e = new_expr ();
|
||||
e->type = ex_error;
|
||||
|
@ -441,6 +441,11 @@ new_binary_expr (int op, expr_t *e1, expr_t *e2)
|
|||
{
|
||||
expr_t *e = new_expr ();
|
||||
|
||||
if (e1->type == ex_error)
|
||||
return e1;
|
||||
if (e2 && e2->type == ex_error)
|
||||
return e2;
|
||||
|
||||
inc_users (e1);
|
||||
inc_users (e2);
|
||||
|
||||
|
@ -456,6 +461,9 @@ new_unary_expr (int op, expr_t *e1)
|
|||
{
|
||||
expr_t *e = new_expr ();
|
||||
|
||||
if (e1 && e1->type == ex_error)
|
||||
return e1;
|
||||
|
||||
inc_users (e1);
|
||||
|
||||
e->type = ex_uexpr;
|
||||
|
@ -534,7 +542,7 @@ append_expr (expr_t *block, expr_t *e)
|
|||
if (block->type != ex_block)
|
||||
abort ();
|
||||
|
||||
if (!e)
|
||||
if (!e || e->type == ex_error)
|
||||
return block;
|
||||
|
||||
if (e->next) {
|
||||
|
@ -1027,6 +1035,8 @@ field_expr (expr_t *e1, expr_t *e2)
|
|||
struct_field_t *field;
|
||||
class_t *class;
|
||||
|
||||
if (e1->type == ex_error)
|
||||
return e1;
|
||||
t1 = get_type (e1);
|
||||
switch (t1->type) {
|
||||
case ev_struct:
|
||||
|
@ -1090,6 +1100,8 @@ field_expr (expr_t *e1, expr_t *e2)
|
|||
break;
|
||||
case ev_entity:
|
||||
t2 = get_type (e2);
|
||||
if (e2->type == ex_error)
|
||||
return e2;
|
||||
if (t2->type == ev_field) {
|
||||
e = new_binary_expr ('.', e1, e2);
|
||||
e->e.expr.type = t2->aux_type;
|
||||
|
@ -1116,7 +1128,10 @@ test_expr (expr_t *e, int test)
|
|||
if (!test)
|
||||
return unary_expr ('!', e);
|
||||
|
||||
switch (type = extract_type (e)) {
|
||||
type = extract_type (e);
|
||||
if (e->type == ex_error)
|
||||
return e;
|
||||
switch (type) {
|
||||
case ev_type_count:
|
||||
error (e, "internal error");
|
||||
abort ();
|
||||
|
@ -1223,6 +1238,10 @@ binary_expr (int op, expr_t *e1, expr_t *e2)
|
|||
e2 = test_expr (e2, true);
|
||||
}
|
||||
|
||||
if (e1->type == ex_error)
|
||||
return e1;
|
||||
if (e2->type == ex_error)
|
||||
return e2;
|
||||
t1 = get_type (e1);
|
||||
t2 = get_type (e2);
|
||||
if (!t1 || !t2) {
|
||||
|
@ -1342,10 +1361,10 @@ asx_expr (int op, expr_t *e1, expr_t *e2)
|
|||
expr_t *
|
||||
unary_expr (int op, expr_t *e)
|
||||
{
|
||||
if (e->type == ex_error)
|
||||
return e;
|
||||
convert_name (e);
|
||||
check_initialized (e);
|
||||
if (e->type == ex_error)
|
||||
return e;
|
||||
switch (op) {
|
||||
case '-':
|
||||
switch (e->type) {
|
||||
|
|
|
@ -86,9 +86,11 @@ allocate_stuff (void)
|
|||
}
|
||||
for (func = pr.func_head; func; func = func->next) {
|
||||
num_relocs += count_relocs (func->refs);
|
||||
num_defs += func->scope->num_defs;
|
||||
for (def = func->scope->head; def; def = def->def_next) {
|
||||
num_relocs += count_relocs (def->refs);
|
||||
if (func->scope) {
|
||||
num_defs += func->scope->num_defs;
|
||||
for (def = func->scope->head; def; def = def->def_next) {
|
||||
num_relocs += count_relocs (def->refs);
|
||||
}
|
||||
}
|
||||
}
|
||||
defs = calloc (num_defs, sizeof (qfo_def_t));
|
||||
|
@ -177,17 +179,20 @@ setup_data (void)
|
|||
func->def = LittleLong (def - defs);
|
||||
write_def (f->def, def++, &reloc);
|
||||
}
|
||||
func->locals_size = LittleLong (f->scope->space->size);
|
||||
func->local_defs = LittleLong (def - defs);
|
||||
func->num_local_defs = LittleLong (f->scope->num_defs);
|
||||
if (f->scope) {
|
||||
func->locals_size = LittleLong (f->scope->space->size);
|
||||
func->local_defs = LittleLong (def - defs);
|
||||
func->num_local_defs = LittleLong (f->scope->num_defs);
|
||||
}
|
||||
if (f->aux)
|
||||
func->line_info = LittleLong (f->aux->line_info);
|
||||
func->num_parms = LittleLong (function_parms (f, func->parm_size));
|
||||
func->relocs = LittleLong (reloc - relocs);
|
||||
write_relocs (f->refs, &reloc);
|
||||
|
||||
for (d = f->scope->head; d; d = d->def_next)
|
||||
write_def (d, def++, &reloc);
|
||||
if (f->scope)
|
||||
for (d = f->scope->head; d; d = d->def_next)
|
||||
write_def (d, def++, &reloc);
|
||||
}
|
||||
for (st = pr.statements; st - pr.statements < pr.num_statements; st++) {
|
||||
st->op = LittleLong (st->op);
|
||||
|
@ -217,7 +222,7 @@ write_obj_file (const char *filename)
|
|||
allocate_stuff ();
|
||||
setup_data ();
|
||||
|
||||
file = Qopen (filename, "wbz9");
|
||||
file = Qopen (filename, "wb");
|
||||
|
||||
pr.strofs = (pr.strofs + 3) & ~3;
|
||||
|
||||
|
|
|
@ -134,7 +134,11 @@ InitData (void)
|
|||
pr_source_line = 1;
|
||||
pr_error_count = 0;
|
||||
pr.num_statements = 1;
|
||||
pr.strofs = 1;
|
||||
pr.statements_size = 16384;
|
||||
pr.statements = calloc (pr.statements_size, sizeof (dstatement_t));
|
||||
pr.statement_linenums = calloc (pr.statements_size, sizeof (int));
|
||||
pr.strofs = 0;
|
||||
CopyString ("");
|
||||
pr.num_functions = 1;
|
||||
|
||||
pr.near_data = new_defspace ();
|
||||
|
@ -461,7 +465,6 @@ compile_to_obj (const char *file, const char *obj)
|
|||
|
||||
InitData ();
|
||||
begin_compilation ();
|
||||
s_file = ReuseString (strip_path (file));
|
||||
clear_frame_macros ();
|
||||
clear_classes ();
|
||||
clear_defs ();
|
||||
|
@ -470,6 +473,7 @@ compile_to_obj (const char *file, const char *obj)
|
|||
clear_structs ();
|
||||
clear_enums ();
|
||||
clear_typedefs ();
|
||||
s_file = ReuseString (strip_path (file));
|
||||
err = yyparse () || pr_error_count;
|
||||
fclose (yyin);
|
||||
if (cpp_name && (!options.save_temps)) {
|
||||
|
@ -490,6 +494,7 @@ separate_compile (void)
|
|||
dstring_t *output_file = dstring_newstr ();
|
||||
dstring_t *extension = dstring_newstr ();
|
||||
char *f;
|
||||
int err = 0;
|
||||
|
||||
if (options.compile && options.output_file && source_files[1]) {
|
||||
fprintf (stderr, "%s: cannot use -c and -o together with multiple "
|
||||
|
@ -515,7 +520,7 @@ separate_compile (void)
|
|||
&& (!strcmp (extension->str, ".r")
|
||||
|| !strcmp (extension->str, ".qc"))) {
|
||||
printf ("%s %s\n", *file, output_file->str);
|
||||
compile_to_obj (*file, output_file->str);
|
||||
err = compile_to_obj (*file, output_file->str) || err;
|
||||
|
||||
free ((char *)*file);
|
||||
*file = strdup (output_file->str);
|
||||
|
@ -525,11 +530,11 @@ separate_compile (void)
|
|||
"not done\n", this_program, *file);
|
||||
}
|
||||
}
|
||||
if (!options.compile) {
|
||||
if (!err && !options.compile) {
|
||||
for (file = source_files; *file; file++) {
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Reference in a new issue