mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-27 06:34:11 +00:00
remove all arbitrary limits except for globals. they'll need a little more
work. Once they're done, it should take quite a big mod to crash qfcc due to too many strings/statements/etc :)
This commit is contained in:
parent
0552d31b0b
commit
e17604f9c2
16 changed files with 161 additions and 164 deletions
|
@ -58,7 +58,7 @@ typedef enum {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct statref_s *refs;
|
struct statref_s *refs;
|
||||||
dstatement_t *statement;
|
int ofs;
|
||||||
const char *name;
|
const char *name;
|
||||||
} ex_label_t;
|
} ex_label_t;
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ typedef struct function_s {
|
||||||
int parm_ofs[MAX_PARMS]; // allways contiguous, right?
|
int parm_ofs[MAX_PARMS]; // allways contiguous, right?
|
||||||
} function_t;
|
} function_t;
|
||||||
|
|
||||||
extern function_t *pr_functions;
|
|
||||||
extern function_t *current_func;
|
extern function_t *current_func;
|
||||||
|
|
||||||
typedef struct param_s {
|
typedef struct param_s {
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
typedef struct statref_s {
|
typedef struct statref_s {
|
||||||
struct statref_s *next;
|
struct statref_s *next;
|
||||||
dstatement_t *statement;
|
int ofs;
|
||||||
int field; // a, b, c (0, 1, 2)
|
int field; // a, b, c (0, 1, 2)
|
||||||
} statref_t;
|
} statref_t;
|
||||||
|
|
||||||
|
@ -53,10 +53,8 @@ extern opcode_t *op_goto;
|
||||||
extern opcode_t *op_jump;
|
extern opcode_t *op_jump;
|
||||||
extern opcode_t *op_jumpb;
|
extern opcode_t *op_jumpb;
|
||||||
|
|
||||||
statref_t *PR_NewStatref (dstatement_t *st, int field);
|
statref_t *PR_NewStatref (int ofs, int field);
|
||||||
void PR_AddStatementRef (struct def_s *def, 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,
|
opcode_t *PR_Opcode_Find (const char *name, struct def_s *var_a,
|
||||||
struct def_s *var_b, struct def_s *var_c);
|
struct def_s *var_b, struct def_s *var_c);
|
||||||
void PR_Opcode_Init_Tables (void);
|
void PR_Opcode_Init_Tables (void);
|
||||||
|
|
|
@ -49,6 +49,23 @@ typedef struct {
|
||||||
struct def_s *def_head; // unused head of linked list
|
struct def_s *def_head; // unused head of linked list
|
||||||
struct def_s **def_tail; // add new defs after this and move it
|
struct def_s **def_tail; // add new defs after this and move it
|
||||||
|
|
||||||
|
char *strings;
|
||||||
|
int strofs;
|
||||||
|
int strings_size;
|
||||||
|
|
||||||
|
dstatement_t *statements;
|
||||||
|
int *statement_linenums;
|
||||||
|
int num_statements;
|
||||||
|
int statements_size;
|
||||||
|
|
||||||
|
struct function_s *function_list;
|
||||||
|
dfunction_t *functions;
|
||||||
|
int num_functions;
|
||||||
|
|
||||||
|
float *globals;
|
||||||
|
int num_globals;
|
||||||
|
int globals_size;
|
||||||
|
|
||||||
int size_fields;
|
int size_fields;
|
||||||
} pr_info_t;
|
} pr_info_t;
|
||||||
|
|
||||||
|
@ -62,36 +79,15 @@ extern int pr_source_line;
|
||||||
extern struct def_s *pr_scope;
|
extern struct def_s *pr_scope;
|
||||||
extern int pr_error_count;
|
extern int pr_error_count;
|
||||||
|
|
||||||
#define G_FLOAT(o) (pr_globals[o])
|
#define G_FLOAT(o) (pr.globals[o])
|
||||||
#define G_INT(o) (*(int *)&pr_globals[o])
|
#define G_INT(o) (*(int *)&pr.globals[o])
|
||||||
#define G_VECTOR(o) (&pr_globals[o])
|
#define G_VECTOR(o) (&pr.globals[o])
|
||||||
#define G_STRING(o) (strings + *(string_t *)&pr_globals[o])
|
#define G_STRING(o) (pr.strings + *(string_t *)&pr.globals[o])
|
||||||
#define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
|
#define G_FUNCTION(o) (*(func_t *)&pr.globals[o])
|
||||||
#define G_STRUCT(t,o) (*(t *)&pr_globals[o])
|
#define G_STRUCT(t,o) (*(t *)&pr.globals[o])
|
||||||
|
|
||||||
extern string_t s_file; // filename for function definition
|
extern string_t s_file; // filename for function definition
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#define MAX_STRINGS 500000
|
|
||||||
#define MAX_GLOBALS 65536
|
|
||||||
#define MAX_FIELDS 1024
|
|
||||||
#define MAX_STATEMENTS 131072
|
|
||||||
#define MAX_FUNCTIONS 8192
|
|
||||||
|
|
||||||
extern char strings[MAX_STRINGS];
|
|
||||||
extern int strofs;
|
|
||||||
|
|
||||||
extern dstatement_t statements[MAX_STATEMENTS];
|
|
||||||
extern int numstatements;
|
|
||||||
extern int statement_linenums[MAX_STATEMENTS];
|
|
||||||
|
|
||||||
extern dfunction_t functions[MAX_FUNCTIONS];
|
|
||||||
extern int numfunctions;
|
|
||||||
|
|
||||||
extern float pr_globals[MAX_REGS];
|
|
||||||
extern int numpr_globals;
|
|
||||||
|
|
||||||
const char *strip_path (const char *filename);
|
const char *strip_path (const char *filename);
|
||||||
|
|
||||||
#endif//__qfcc_h
|
#endif//__qfcc_h
|
||||||
|
|
|
@ -159,7 +159,7 @@ class_begin (class_t *class)
|
||||||
va ("_OBJ_CATEGORY_%s_%s",
|
va ("_OBJ_CATEGORY_%s_%s",
|
||||||
class->class_name,
|
class->class_name,
|
||||||
class->category_name),
|
class->category_name),
|
||||||
0, &numpr_globals);
|
0, &pr.num_globals);
|
||||||
class->def->initialized = class->def->constant = 1;
|
class->def->initialized = class->def->constant = 1;
|
||||||
category = &G_STRUCT (pr_category_t, class->def->ofs);
|
category = &G_STRUCT (pr_category_t, class->def->ofs);
|
||||||
category->category_name = ReuseString (class->category_name);
|
category->category_name = ReuseString (class->category_name);
|
||||||
|
@ -175,7 +175,7 @@ class_begin (class_t *class)
|
||||||
|
|
||||||
meta_def = PR_GetDef (type_Class.aux_type,
|
meta_def = PR_GetDef (type_Class.aux_type,
|
||||||
va ("_OBJ_METACLASS_%s", class->class_name),
|
va ("_OBJ_METACLASS_%s", class->class_name),
|
||||||
0, &numpr_globals);
|
0, &pr.num_globals);
|
||||||
meta_def->initialized = meta_def->constant = 1;
|
meta_def->initialized = meta_def->constant = 1;
|
||||||
meta = &G_STRUCT (pr_class_t, meta_def->ofs);
|
meta = &G_STRUCT (pr_class_t, meta_def->ofs);
|
||||||
meta->class_pointer = ReuseString (class->class_name);
|
meta->class_pointer = ReuseString (class->class_name);
|
||||||
|
@ -190,7 +190,7 @@ class_begin (class_t *class)
|
||||||
|
|
||||||
class->def = PR_GetDef (type_Class.aux_type,
|
class->def = PR_GetDef (type_Class.aux_type,
|
||||||
va ("_OBJ_CLASS_%s", class->class_name),
|
va ("_OBJ_CLASS_%s", class->class_name),
|
||||||
0, &numpr_globals);
|
0, &pr.num_globals);
|
||||||
class->def->initialized = class->def->constant = 1;
|
class->def->initialized = class->def->constant = 1;
|
||||||
cls = &G_STRUCT (pr_class_t, class->def->ofs);
|
cls = &G_STRUCT (pr_class_t, class->def->ofs);
|
||||||
cls->class_pointer = meta_def->ofs;
|
cls->class_pointer = meta_def->ofs;
|
||||||
|
@ -321,7 +321,7 @@ class_message_response (class_t *class, expr_t *sel)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
selector = &G_STRUCT (pr_sel_t, sel->e.pointer.val);
|
selector = &G_STRUCT (pr_sel_t, sel->e.pointer.val);
|
||||||
sel_name = strings + selector->sel_id;
|
sel_name = pr.strings + selector->sel_id;
|
||||||
while (c) {
|
while (c) {
|
||||||
if (c->methods) {
|
if (c->methods) {
|
||||||
for (m = c->methods->head; m; m = m->next) {
|
for (m = c->methods->head; m; m = m->next) {
|
||||||
|
@ -398,7 +398,7 @@ class_def (class_t *class)
|
||||||
|
|
||||||
def = PR_GetDef (class->type,
|
def = PR_GetDef (class->type,
|
||||||
va ("_OBJ_CLASS_POINTER_%s", class->class_name),
|
va ("_OBJ_CLASS_POINTER_%s", class->class_name),
|
||||||
0, &numpr_globals);
|
0, &pr.num_globals);
|
||||||
if (def->initialized)
|
if (def->initialized)
|
||||||
return def;
|
return def;
|
||||||
if (class->def) { //FIXME need externals?
|
if (class->def) { //FIXME need externals?
|
||||||
|
@ -451,7 +451,7 @@ class_finish_module (void)
|
||||||
new_struct_field (symtab_type, &type_integer, "cat_def_cnt", vis_public);
|
new_struct_field (symtab_type, &type_integer, "cat_def_cnt", vis_public);
|
||||||
for (i = 0; i < num_classes + num_categories; i++)
|
for (i = 0; i < num_classes + num_categories; i++)
|
||||||
new_struct_field (symtab_type, &type_pointer, 0, vis_public);
|
new_struct_field (symtab_type, &type_pointer, 0, vis_public);
|
||||||
symtab_def = PR_GetDef (symtab_type, "_OBJ_SYMTAB", 0, &numpr_globals);
|
symtab_def = PR_GetDef (symtab_type, "_OBJ_SYMTAB", 0, &pr.num_globals);
|
||||||
symtab_def->initialized = symtab_def->constant = 1;
|
symtab_def->initialized = symtab_def->constant = 1;
|
||||||
symtab = &G_STRUCT (pr_symtab_t, symtab_def->ofs);
|
symtab = &G_STRUCT (pr_symtab_t, symtab_def->ofs);
|
||||||
symtab->cls_def_cnt = num_classes;
|
symtab->cls_def_cnt = num_classes;
|
||||||
|
@ -464,7 +464,7 @@ class_finish_module (void)
|
||||||
if ((*t)->def)
|
if ((*t)->def)
|
||||||
*def_ptr++ = (*t)->def->ofs;
|
*def_ptr++ = (*t)->def->ofs;
|
||||||
|
|
||||||
module_def = PR_GetDef (type_module, "_OBJ_MODULE", 0, &numpr_globals);
|
module_def = PR_GetDef (type_module, "_OBJ_MODULE", 0, &pr.num_globals);
|
||||||
module_def->initialized = module_def->constant = 1;
|
module_def->initialized = module_def->constant = 1;
|
||||||
module = &G_STRUCT (pr_module_t, module_def->ofs);
|
module = &G_STRUCT (pr_module_t, module_def->ofs);
|
||||||
module->size = type_size (type_module);
|
module->size = type_size (type_module);
|
||||||
|
@ -472,17 +472,17 @@ class_finish_module (void)
|
||||||
module->symtab = symtab_def->ofs;
|
module->symtab = symtab_def->ofs;
|
||||||
|
|
||||||
exec_class_def = PR_GetDef (&type_obj_exec_class, "__obj_exec_class",
|
exec_class_def = PR_GetDef (&type_obj_exec_class, "__obj_exec_class",
|
||||||
0, &numpr_globals);
|
0, &pr.num_globals);
|
||||||
exec_class_func = new_function ();
|
exec_class_func = new_function ();
|
||||||
exec_class_func->builtin = 0;
|
exec_class_func->builtin = 0;
|
||||||
exec_class_func->def = exec_class_def;
|
exec_class_func->def = exec_class_def;
|
||||||
build_function (exec_class_func);
|
build_function (exec_class_func);
|
||||||
finish_function (exec_class_func);
|
finish_function (exec_class_func);
|
||||||
|
|
||||||
init_def = PR_GetDef (&type_function, ".ctor", 0, &numpr_globals);
|
init_def = PR_GetDef (&type_function, ".ctor", 0, &pr.num_globals);
|
||||||
init_func = new_function ();
|
init_func = new_function ();
|
||||||
init_func->def = init_def;
|
init_func->def = init_def;
|
||||||
init_func->code = numstatements;
|
init_func->code = pr.num_statements;
|
||||||
build_function (init_func);
|
build_function (init_func);
|
||||||
init_expr = new_block_expr ();
|
init_expr = new_block_expr ();
|
||||||
append_expr (init_expr,
|
append_expr (init_expr,
|
||||||
|
@ -543,7 +543,7 @@ protocol_add_protocol_methods (protocol_t *protocol, expr_t *protocols)
|
||||||
def_t *
|
def_t *
|
||||||
protocol_def (protocol_t *protocol)
|
protocol_def (protocol_t *protocol)
|
||||||
{
|
{
|
||||||
return PR_GetDef (&type_Protocol, protocol->name, 0, &numpr_globals);
|
return PR_GetDef (&type_Protocol, protocol->name, 0, &pr.num_globals);
|
||||||
}
|
}
|
||||||
|
|
||||||
protocollist_t *
|
protocollist_t *
|
||||||
|
@ -573,7 +573,7 @@ emit_protocol (protocol_t *protocol)
|
||||||
|
|
||||||
proto_def = PR_GetDef (type_Protocol.aux_type,
|
proto_def = PR_GetDef (type_Protocol.aux_type,
|
||||||
va ("_OBJ_PROTOCOL_%s", protocol->name),
|
va ("_OBJ_PROTOCOL_%s", protocol->name),
|
||||||
0, &numpr_globals);
|
0, &pr.num_globals);
|
||||||
proto_def->initialized = proto_def->constant = 1;
|
proto_def->initialized = proto_def->constant = 1;
|
||||||
proto = &G_STRUCT (pr_protocol_t, proto_def->ofs);
|
proto = &G_STRUCT (pr_protocol_t, proto_def->ofs);
|
||||||
proto->class_pointer = 0;
|
proto->class_pointer = 0;
|
||||||
|
@ -604,7 +604,7 @@ emit_protocol_list (protocollist_t *protocols, const char *name)
|
||||||
new_struct_field (protocol_list, &type_pointer, 0, vis_public);
|
new_struct_field (protocol_list, &type_pointer, 0, vis_public);
|
||||||
proto_list_def = PR_GetDef (type_Protocol.aux_type,
|
proto_list_def = PR_GetDef (type_Protocol.aux_type,
|
||||||
va ("_OBJ_PROTOCOLS_%s", name),
|
va ("_OBJ_PROTOCOLS_%s", name),
|
||||||
0, &numpr_globals);
|
0, &pr.num_globals);
|
||||||
proto_list_def->initialized = proto_list_def->constant = 1;
|
proto_list_def->initialized = proto_list_def->constant = 1;
|
||||||
proto_list = &G_STRUCT (pr_protocol_list_t, proto_list_def->ofs);
|
proto_list = &G_STRUCT (pr_protocol_list_t, proto_list_def->ofs);
|
||||||
proto_list->next = 0;
|
proto_list->next = 0;
|
||||||
|
|
|
@ -78,12 +78,19 @@ emit_statement (int sline, opcode_t *op, def_t *var_a, def_t *var_b,
|
||||||
pr_lineno_t *lineno = new_lineno ();
|
pr_lineno_t *lineno = new_lineno ();
|
||||||
|
|
||||||
lineno->line = line;
|
lineno->line = line;
|
||||||
lineno->fa.addr = numstatements;
|
lineno->fa.addr = pr.num_statements;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
statement = &statements[numstatements];
|
if (pr.num_statements >= pr.statements_size) {
|
||||||
numstatements++;
|
pr.statements_size += 16384;
|
||||||
statement_linenums[statement - statements] = pr_source_line;
|
pr.statements = realloc (pr.statements,
|
||||||
|
pr.statements_size * sizeof (dstatement_t));
|
||||||
|
pr.statement_linenums = realloc (pr.statement_linenums,
|
||||||
|
pr.statements_size * sizeof (int));
|
||||||
|
}
|
||||||
|
statement = &pr.statements[pr.num_statements];
|
||||||
|
pr.num_statements++;
|
||||||
|
pr.statement_linenums[statement - pr.statements] = pr_source_line;
|
||||||
statement->op = op->opcode;
|
statement->op = op->opcode;
|
||||||
statement->a = var_a ? var_a->ofs : 0;
|
statement->a = var_a ? var_a->ofs : 0;
|
||||||
statement->b = var_b ? var_b->ofs : 0;
|
statement->b = var_b ? var_b->ofs : 0;
|
||||||
|
@ -126,18 +133,19 @@ emit_branch (int line, opcode_t *op, expr_t *e, expr_t *l)
|
||||||
dstatement_t *st;
|
dstatement_t *st;
|
||||||
statref_t *ref;
|
statref_t *ref;
|
||||||
def_t *def = 0;
|
def_t *def = 0;
|
||||||
|
int ofs;
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
def = emit_sub_expr (e, 0);
|
def = emit_sub_expr (e, 0);
|
||||||
st = &statements[numstatements];
|
st = &pr.statements[ofs = pr.num_statements];
|
||||||
emit_statement (line, op, def, 0, 0);
|
emit_statement (line, op, def, 0, 0);
|
||||||
if (l->e.label.statement) {
|
if (l->e.label.ofs) {
|
||||||
if (op == op_goto)
|
if (op == op_goto)
|
||||||
st->a = l->e.label.statement - st;
|
st->a = l->e.label.ofs - ofs;
|
||||||
else
|
else
|
||||||
st->b = l->e.label.statement - st;
|
st->b = l->e.label.ofs - ofs;
|
||||||
} else {
|
} else {
|
||||||
ref = PR_NewStatref (st, op != op_goto);
|
ref = PR_NewStatref (ofs, op != op_goto);
|
||||||
ref->next = l->e.label.refs;
|
ref->next = l->e.label.refs;
|
||||||
l->e.label.refs = ref;
|
l->e.label.refs = ref;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +208,7 @@ emit_assign_expr (int oper, expr_t *e)
|
||||||
int size = pr_type_size[def_a->type->type];
|
int size = pr_type_size[def_a->type->type];
|
||||||
int ofs = PR_NewLocation (def_a->type);
|
int ofs = PR_NewLocation (def_a->type);
|
||||||
|
|
||||||
memcpy (pr_globals + ofs, pr_globals + def_a->ofs, size);
|
memcpy (pr.globals + ofs, pr.globals + def_a->ofs, size);
|
||||||
def_a->ofs = ofs;
|
def_a->ofs = ofs;
|
||||||
def_a->constant = 0;
|
def_a->constant = 0;
|
||||||
if (options.warnings.cow)
|
if (options.warnings.cow)
|
||||||
|
@ -450,20 +458,20 @@ emit_expr (expr_t *e)
|
||||||
break;
|
break;
|
||||||
case ex_label:
|
case ex_label:
|
||||||
label = &e->e.label;
|
label = &e->e.label;
|
||||||
label->statement = &statements[numstatements];
|
label->ofs = pr.num_statements;
|
||||||
for (ref = label->refs; ref; ref = ref->next) {
|
for (ref = label->refs; ref; ref = ref->next) {
|
||||||
switch (ref->field) {
|
switch (ref->field) {
|
||||||
case 0:
|
case 0:
|
||||||
ref->statement->a = label->statement - ref->statement;
|
pr.statements[ref->ofs].a = label->ofs - ref->ofs;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ref->statement->b = label->statement - ref->statement;
|
pr.statements[ref->ofs].b = label->ofs - ref->ofs;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ref->statement->c = label->statement - ref->statement;
|
pr.statements[ref->ofs].c = label->ofs - ref->ofs;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
*(int *) ref->statement = label->statement - statements;
|
G_INT (ref->ofs) = label->ofs;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
|
|
|
@ -230,7 +230,7 @@ error (expr_t *e, const char *fmt, ...)
|
||||||
file = e->file;
|
file = e->file;
|
||||||
line = e->line;
|
line = e->line;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "%s:%d: ", strings + file, line);
|
fprintf (stderr, "%s:%d: ", pr.strings + file, line);
|
||||||
vfprintf (stderr, fmt, args);
|
vfprintf (stderr, fmt, args);
|
||||||
fputs ("\n", stderr);
|
fputs ("\n", stderr);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
@ -260,7 +260,7 @@ warning (expr_t *e, const char *fmt, ...)
|
||||||
file = e->file;
|
file = e->file;
|
||||||
line = e->line;
|
line = e->line;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "%s:%d: warning: ", strings + file, line);
|
fprintf (stderr, "%s:%d: warning: ", pr.strings + file, line);
|
||||||
vfprintf (stderr, fmt, args);
|
vfprintf (stderr, fmt, args);
|
||||||
fputs ("\n", stderr);
|
fputs ("\n", stderr);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
@ -472,7 +472,7 @@ new_def_expr (def_t *def)
|
||||||
expr_t *
|
expr_t *
|
||||||
new_self_expr (void)
|
new_self_expr (void)
|
||||||
{
|
{
|
||||||
def_t *def = PR_GetDef (&type_entity, ".self", 0, &numpr_globals);
|
def_t *def = PR_GetDef (&type_entity, ".self", 0, &pr.num_globals);
|
||||||
|
|
||||||
PR_DefInitialized (def);
|
PR_DefInitialized (def);
|
||||||
return new_def_expr (def);
|
return new_def_expr (def);
|
||||||
|
@ -482,7 +482,7 @@ expr_t *
|
||||||
new_this_expr (void)
|
new_this_expr (void)
|
||||||
{
|
{
|
||||||
type_t *type = field_type (&type_id);
|
type_t *type = field_type (&type_id);
|
||||||
def_t *def = PR_GetDef (type, ".this", 0, &numpr_globals);
|
def_t *def = PR_GetDef (type, ".this", 0, &pr.num_globals);
|
||||||
|
|
||||||
PR_DefInitialized (def);
|
PR_DefInitialized (def);
|
||||||
return new_def_expr (def);
|
return new_def_expr (def);
|
||||||
|
|
|
@ -168,8 +168,8 @@ new_function (void)
|
||||||
function_t *f;
|
function_t *f;
|
||||||
|
|
||||||
f = calloc (1, sizeof (function_t));
|
f = calloc (1, sizeof (function_t));
|
||||||
f->next = pr_functions;
|
f->next = pr.function_list;
|
||||||
pr_functions = f;
|
pr.function_list = f;
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ build_function (function_t *f)
|
||||||
{
|
{
|
||||||
f->def->constant = 1;
|
f->def->constant = 1;
|
||||||
f->def->initialized = 1;
|
f->def->initialized = 1;
|
||||||
G_FUNCTION (f->def->ofs) = numfunctions;
|
G_FUNCTION (f->def->ofs) = pr.num_functions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -212,9 +212,8 @@ finish_function (function_t *f)
|
||||||
dfunction_t *df;
|
dfunction_t *df;
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
// fill in the dfunction
|
df = calloc (1, sizeof (dfunction_t));
|
||||||
df = &functions[numfunctions];
|
pr.num_functions++;
|
||||||
numfunctions++;
|
|
||||||
f->dfunc = df;
|
f->dfunc = df;
|
||||||
|
|
||||||
if (f->builtin)
|
if (f->builtin)
|
||||||
|
@ -234,7 +233,7 @@ finish_function (function_t *f)
|
||||||
|
|
||||||
if (f->aux) {
|
if (f->aux) {
|
||||||
def_t *def;
|
def_t *def;
|
||||||
f->aux->function = df - functions;
|
f->aux->function = df - pr.functions;
|
||||||
for (def = f->def->scope_next; def; def = def->scope_next) {
|
for (def = f->def->scope_next; def; def = def->scope_next) {
|
||||||
if (def->name) {
|
if (def->name) {
|
||||||
ddef_t *d = new_local ();
|
ddef_t *d = new_local ();
|
||||||
|
|
|
@ -106,20 +106,25 @@ int_imm_get_key (void *_def, void *_str)
|
||||||
static const char *
|
static const char *
|
||||||
strings_get_key (void *_str, void *unsued)
|
strings_get_key (void *_str, void *unsued)
|
||||||
{
|
{
|
||||||
return strings + (int) _str;
|
return pr.strings + (int) _str;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CopyString (const char *str)
|
CopyString (const char *str)
|
||||||
{
|
{
|
||||||
int old;
|
int old;
|
||||||
|
int len = strlen (str) + 1;
|
||||||
|
|
||||||
if (!strings_tab) {
|
if (!strings_tab) {
|
||||||
strings_tab = Hash_NewTable (16381, strings_get_key, 0, 0);
|
strings_tab = Hash_NewTable (16381, strings_get_key, 0, 0);
|
||||||
}
|
}
|
||||||
old = strofs;
|
if (pr.strofs + len >= pr.strings_size) {
|
||||||
strcpy (strings + strofs, str);
|
pr.strings_size += (len + 16383) & ~16383;
|
||||||
strofs += strlen (str) + 1;
|
pr.strings = realloc (pr.strings, pr.strings_size);
|
||||||
|
}
|
||||||
|
old = pr.strofs;
|
||||||
|
strcpy (pr.strings + pr.strofs, str);
|
||||||
|
pr.strofs += len;
|
||||||
Hash_Add (strings_tab, (void *)old);
|
Hash_Add (strings_tab, (void *)old);
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +284,7 @@ ReuseConstant (expr_t *expr, def_t *def)
|
||||||
if (e.type == ex_string)
|
if (e.type == ex_string)
|
||||||
e.e.integer_val = ReuseString (rep->str);
|
e.e.integer_val = ReuseString (rep->str);
|
||||||
|
|
||||||
memcpy (pr_globals + cn->ofs, &e.e, 4 * pr_type_size[type->type]);
|
memcpy (pr.globals + cn->ofs, &e.e, 4 * pr_type_size[type->type]);
|
||||||
|
|
||||||
Hash_Add (tab, cn);
|
Hash_Add (tab, cn);
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ method_def (class_t *class, method_t *method)
|
||||||
*s = '_';
|
*s = '_';
|
||||||
//printf ("%s %s %s %ld\n", method->name, method->types, str->str, str->size);
|
//printf ("%s %s %s %ld\n", method->name, method->types, str->str, str->size);
|
||||||
// FIXME need a file scope
|
// FIXME need a file scope
|
||||||
def = PR_GetDef (method->type, str->str, 0, &numpr_globals);
|
def = PR_GetDef (method->type, str->str, 0, &pr.num_globals);
|
||||||
dstring_delete (str);
|
dstring_delete (str);
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ new_keywordarg (const char *selector, struct expr_s *expr)
|
||||||
static void
|
static void
|
||||||
make_message_def (const char *name, def_t **def, function_t **func)
|
make_message_def (const char *name, def_t **def, function_t **func)
|
||||||
{
|
{
|
||||||
*def = PR_GetDef (&type_IMP, name, 0, &numpr_globals);
|
*def = PR_GetDef (&type_IMP, name, 0, &pr.num_globals);
|
||||||
*func = new_function ();
|
*func = new_function ();
|
||||||
(*func)->builtin = 0;
|
(*func)->builtin = 0;
|
||||||
(*func)->def = *def;
|
(*func)->def = *def;
|
||||||
|
@ -229,8 +229,8 @@ sel_def_get_hash (void *_sel_def, void *unused)
|
||||||
sel_def_t *sel_def = (sel_def_t*)_sel_def;
|
sel_def_t *sel_def = (sel_def_t*)_sel_def;
|
||||||
unsigned long hash;
|
unsigned long hash;
|
||||||
|
|
||||||
hash = Hash_String (strings + sel_def->sel_id)
|
hash = Hash_String (pr.strings + sel_def->sel_id)
|
||||||
^ Hash_String (strings + sel_def->sel_types);
|
^ Hash_String (pr.strings + sel_def->sel_types);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,10 +241,10 @@ sel_def_compare (void *_sd1, void *_sd2, void *unused)
|
||||||
sel_def_t *sd2 = (sel_def_t*)_sd2;
|
sel_def_t *sd2 = (sel_def_t*)_sd2;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
cmp = strcmp (strings + sd1->sel_id, strings + sd2->sel_id) == 0;
|
cmp = strcmp (pr.strings + sd1->sel_id, pr.strings + sd2->sel_id) == 0;
|
||||||
if (cmp)
|
if (cmp)
|
||||||
cmp = strcmp (strings + sd1->sel_types,
|
cmp = strcmp (pr.strings + sd1->sel_types,
|
||||||
strings + sd2->sel_types) == 0;
|
pr.strings + sd2->sel_types) == 0;
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ emit_methods (methodlist_t *_methods, const char *name, int instance)
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
new_struct_field (method_list, type_Method.aux_type, 0, vis_public);
|
new_struct_field (method_list, type_Method.aux_type, 0, vis_public);
|
||||||
methods_def = PR_GetDef (method_list, va ("_OBJ_%s_METHODS_%s", type, name),
|
methods_def = PR_GetDef (method_list, va ("_OBJ_%s_METHODS_%s", type, name),
|
||||||
0, &numpr_globals);
|
0, &pr.num_globals);
|
||||||
methods_def->initialized = methods_def->constant = 1;
|
methods_def->initialized = methods_def->constant = 1;
|
||||||
methods = &G_STRUCT (pr_method_list_t, methods_def->ofs);
|
methods = &G_STRUCT (pr_method_list_t, methods_def->ofs);
|
||||||
methods->method_next = 0;
|
methods->method_next = 0;
|
||||||
|
|
|
@ -55,11 +55,11 @@ opcode_t *op_jump;
|
||||||
opcode_t *op_jumpb;
|
opcode_t *op_jumpb;
|
||||||
|
|
||||||
statref_t *
|
statref_t *
|
||||||
PR_NewStatref (dstatement_t *st, int field)
|
PR_NewStatref (int ofs, int field)
|
||||||
{
|
{
|
||||||
statref_t *ref = calloc (1, sizeof (statref_t));
|
statref_t *ref = calloc (1, sizeof (statref_t));
|
||||||
|
|
||||||
ref->statement = st;
|
ref->ofs = ofs;
|
||||||
ref->field = field;
|
ref->field = field;
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ void
|
||||||
PR_AddStatementRef (def_t *def, dstatement_t *st, int field)
|
PR_AddStatementRef (def_t *def, dstatement_t *st, int field)
|
||||||
{
|
{
|
||||||
if (def) {
|
if (def) {
|
||||||
statref_t *ref = PR_NewStatref (st, field);
|
statref_t *ref = PR_NewStatref (st - pr.statements, field);
|
||||||
|
|
||||||
ref->next = def->refs;
|
ref->next = def->refs;
|
||||||
def->refs = ref;
|
def->refs = ref;
|
||||||
|
|
|
@ -153,7 +153,7 @@ PR_GetDef (type_t *type, const char *name, def_t *scope, int *allocate)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type->type == ev_field) {
|
if (type->type == ev_field) {
|
||||||
*(int *) &pr_globals[def->ofs] = pr.size_fields;
|
*(int *) &pr.globals[def->ofs] = pr.size_fields;
|
||||||
|
|
||||||
if (type->aux_type->type == ev_vector) {
|
if (type->aux_type->type == ev_vector) {
|
||||||
def_t *d;
|
def_t *d;
|
||||||
|
@ -251,8 +251,8 @@ PR_NewLocation (type_t *type)
|
||||||
|
|
||||||
return loc->ofs;
|
return loc->ofs;
|
||||||
}
|
}
|
||||||
numpr_globals += size;
|
pr.num_globals += size;
|
||||||
return numpr_globals - size;
|
return pr.num_globals - size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -310,7 +310,7 @@ PR_FreeTempDefs (void)
|
||||||
*def = d->next;
|
*def = d->next;
|
||||||
|
|
||||||
if (d->users < 0)
|
if (d->users < 0)
|
||||||
printf ("%s:%d: warning: %s %3d %3d %d\n", strings + d->file,
|
printf ("%s:%d: warning: %s %3d %3d %d\n", pr.strings + d->file,
|
||||||
d->line, pr_type_name[d->type->type], d->ofs, d->users,
|
d->line, pr_type_name[d->type->type], d->ofs, d->users,
|
||||||
d->managed);
|
d->managed);
|
||||||
size = pr_type_size[d->type->type];
|
size = pr_type_size[d->type->type];
|
||||||
|
@ -339,7 +339,7 @@ PR_ResetTempDefs (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (d = temp_scope.next; d; d = d->next)
|
for (d = temp_scope.next; d; d = d->next)
|
||||||
printf ("%s:%d: warning: %s %3d %3d %d\n", strings + d->file, d->line,
|
printf ("%s:%d: warning: %s %3d %3d %d\n", pr.strings + d->file, d->line,
|
||||||
pr_type_name[d->type->type], d->ofs, d->users, d->managed);
|
pr_type_name[d->type->type], d->ofs, d->users, d->managed);
|
||||||
temp_scope.next = 0;
|
temp_scope.next = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,7 +348,7 @@ def_item
|
||||||
def_name
|
def_name
|
||||||
: NAME
|
: NAME
|
||||||
{
|
{
|
||||||
int *alloc = &numpr_globals;
|
int *alloc = &pr.num_globals;
|
||||||
|
|
||||||
if (pr_scope) {
|
if (pr_scope) {
|
||||||
alloc = pr_scope->alloc;
|
alloc = pr_scope->alloc;
|
||||||
|
@ -477,7 +477,7 @@ begin_function
|
||||||
{
|
{
|
||||||
$$ = current_func = new_function ();
|
$$ = current_func = new_function ();
|
||||||
$$->def = current_def;
|
$$->def = current_def;
|
||||||
$$->code = numstatements;
|
$$->code = pr.num_statements;
|
||||||
if (options.code.debug) {
|
if (options.code.debug) {
|
||||||
pr_lineno_t *lineno = new_lineno ();
|
pr_lineno_t *lineno = new_lineno ();
|
||||||
$$->aux = new_auxfunction ();
|
$$->aux = new_auxfunction ();
|
||||||
|
|
|
@ -88,26 +88,13 @@ pr_info_t pr;
|
||||||
int pr_source_line;
|
int pr_source_line;
|
||||||
int pr_error_count;
|
int pr_error_count;
|
||||||
|
|
||||||
float pr_globals[MAX_REGS];
|
ddef_t *globals;
|
||||||
int numpr_globals;
|
|
||||||
|
|
||||||
char strings[MAX_STRINGS];
|
|
||||||
int strofs;
|
|
||||||
|
|
||||||
dstatement_t statements[MAX_STATEMENTS];
|
|
||||||
int numstatements;
|
|
||||||
int statement_linenums[MAX_STATEMENTS];
|
|
||||||
|
|
||||||
function_t *pr_functions;
|
|
||||||
dfunction_t functions[MAX_FUNCTIONS];
|
|
||||||
int numfunctions;
|
|
||||||
|
|
||||||
ddef_t globals[MAX_GLOBALS];
|
|
||||||
int numglobaldefs;
|
int numglobaldefs;
|
||||||
|
|
||||||
int num_localdefs;
|
int num_localdefs;
|
||||||
const char *big_function = 0;
|
const char *big_function = 0;
|
||||||
|
|
||||||
ddef_t fields[MAX_FIELDS];
|
ddef_t *fields;
|
||||||
int numfielddefs;
|
int numfielddefs;
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,9 +103,13 @@ InitData (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
numstatements = 1;
|
pr.num_statements = 1;
|
||||||
strofs = 1;
|
pr.strofs = 1;
|
||||||
numfunctions = 1;
|
pr.num_functions = 1;
|
||||||
|
|
||||||
|
pr.globals = calloc (65536, 4); //FIXME
|
||||||
|
pr.globals_size = 65536;
|
||||||
|
|
||||||
numglobaldefs = 1;
|
numglobaldefs = 1;
|
||||||
numfielddefs = 1;
|
numfielddefs = 1;
|
||||||
|
|
||||||
|
@ -138,6 +129,9 @@ WriteData (int crc)
|
||||||
FILE *h;
|
FILE *h;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
globals = calloc (pr.num_globals, sizeof (ddef_t)); //FIXME
|
||||||
|
fields = calloc (pr.num_globals, sizeof (ddef_t)); //FIXME
|
||||||
|
|
||||||
for (def = pr.def_head; def; def = def->def_next) {
|
for (def = pr.def_head; def; def = def->def_next) {
|
||||||
if (def->scope)
|
if (def->scope)
|
||||||
continue;
|
continue;
|
||||||
|
@ -162,16 +156,16 @@ WriteData (int crc)
|
||||||
dd->ofs = def->ofs;
|
dd->ofs = def->ofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
strofs = (strofs + 3) & ~3;
|
pr.strofs = (pr.strofs + 3) & ~3;
|
||||||
|
|
||||||
if (options.verbosity >= 0) {
|
if (options.verbosity >= 0) {
|
||||||
printf ("%6i strofs\n", strofs);
|
printf ("%6i strofs\n", pr.strofs);
|
||||||
printf ("%6i statements\n", numstatements);
|
printf ("%6i statements\n", pr.num_statements);
|
||||||
printf ("%6i functions\n", numfunctions);
|
printf ("%6i functions\n", pr.num_functions);
|
||||||
printf ("%6i global defs\n", numglobaldefs);
|
printf ("%6i global defs\n", numglobaldefs);
|
||||||
printf ("%6i locals size (%s)\n", num_localdefs, big_function);
|
printf ("%6i locals size (%s)\n", num_localdefs, big_function);
|
||||||
printf ("%6i fielddefs\n", numfielddefs);
|
printf ("%6i fielddefs\n", numfielddefs);
|
||||||
printf ("%6i pr_globals\n", numpr_globals);
|
printf ("%6i globals\n", pr.num_globals);
|
||||||
printf ("%6i entity fields\n", pr.size_fields);
|
printf ("%6i entity fields\n", pr.size_fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,31 +173,36 @@ WriteData (int crc)
|
||||||
SafeWrite (h, &progs, sizeof (progs));
|
SafeWrite (h, &progs, sizeof (progs));
|
||||||
|
|
||||||
progs.ofs_strings = ftell (h);
|
progs.ofs_strings = ftell (h);
|
||||||
progs.numstrings = strofs;
|
progs.numstrings = pr.strofs;
|
||||||
SafeWrite (h, strings, strofs);
|
SafeWrite (h, pr.strings, pr.strofs);
|
||||||
|
|
||||||
progs.ofs_statements = ftell (h);
|
progs.ofs_statements = ftell (h);
|
||||||
progs.numstatements = numstatements;
|
progs.numstatements = pr.num_statements;
|
||||||
for (i = 0; i < numstatements; i++) {
|
for (i = 0; i < pr.num_statements; i++) {
|
||||||
statements[i].op = LittleShort (statements[i].op);
|
pr.statements[i].op = LittleShort (pr.statements[i].op);
|
||||||
statements[i].a = LittleShort (statements[i].a);
|
pr.statements[i].a = LittleShort (pr.statements[i].a);
|
||||||
statements[i].b = LittleShort (statements[i].b);
|
pr.statements[i].b = LittleShort (pr.statements[i].b);
|
||||||
statements[i].c = LittleShort (statements[i].c);
|
pr.statements[i].c = LittleShort (pr.statements[i].c);
|
||||||
}
|
}
|
||||||
SafeWrite (h, statements, numstatements * sizeof (dstatement_t));
|
SafeWrite (h, pr.statements, pr.num_statements * sizeof (dstatement_t));
|
||||||
|
|
||||||
|
{
|
||||||
|
function_t *f;
|
||||||
|
|
||||||
progs.ofs_functions = ftell (h);
|
progs.ofs_functions = ftell (h);
|
||||||
progs.numfunctions = numfunctions;
|
progs.numfunctions = pr.num_functions;
|
||||||
for (i = 0; i < numfunctions; i++) {
|
pr.functions = malloc (pr.num_functions * sizeof (dfunction_t));
|
||||||
functions[i].first_statement =
|
for (i = 0, f = pr.function_list; f; i++, f = f->next) {
|
||||||
LittleLong (functions[i].first_statement);
|
pr.functions[i].first_statement =
|
||||||
functions[i].parm_start = LittleLong (functions[i].parm_start);
|
LittleLong (f->dfunc->first_statement);
|
||||||
functions[i].s_name = LittleLong (functions[i].s_name);
|
pr.functions[i].parm_start = LittleLong (f->dfunc->parm_start);
|
||||||
functions[i].s_file = LittleLong (functions[i].s_file);
|
pr.functions[i].s_name = LittleLong (f->dfunc->s_name);
|
||||||
functions[i].numparms = LittleLong (functions[i].numparms);
|
pr.functions[i].s_file = LittleLong (f->dfunc->s_file);
|
||||||
functions[i].locals = LittleLong (functions[i].locals);
|
pr.functions[i].numparms = LittleLong (f->dfunc->numparms);
|
||||||
|
pr.functions[i].locals = LittleLong (f->dfunc->locals);
|
||||||
|
}
|
||||||
|
SafeWrite (h, pr.functions, pr.num_functions * sizeof (dfunction_t));
|
||||||
}
|
}
|
||||||
SafeWrite (h, functions, numfunctions * sizeof (dfunction_t));
|
|
||||||
|
|
||||||
progs.ofs_globaldefs = ftell (h);
|
progs.ofs_globaldefs = ftell (h);
|
||||||
progs.numglobaldefs = numglobaldefs;
|
progs.numglobaldefs = numglobaldefs;
|
||||||
|
@ -224,10 +223,10 @@ WriteData (int crc)
|
||||||
SafeWrite (h, fields, numfielddefs * sizeof (ddef_t));
|
SafeWrite (h, fields, numfielddefs * sizeof (ddef_t));
|
||||||
|
|
||||||
progs.ofs_globals = ftell (h);
|
progs.ofs_globals = ftell (h);
|
||||||
progs.numglobals = numpr_globals;
|
progs.numglobals = pr.num_globals;
|
||||||
for (i = 0; i < numpr_globals; i++)
|
for (i = 0; i < pr.num_globals; i++)
|
||||||
((int *) pr_globals)[i] = LittleLong (((int *) pr_globals)[i]);
|
((int *) pr.globals)[i] = LittleLong (((int *) pr.globals)[i]);
|
||||||
SafeWrite (h, pr_globals, numpr_globals * 4);
|
SafeWrite (h, pr.globals, pr.num_globals * 4);
|
||||||
|
|
||||||
if (options.verbosity >= -1)
|
if (options.verbosity >= -1)
|
||||||
printf ("%6i TOTAL SIZE\n", (int) ftell (h));
|
printf ("%6i TOTAL SIZE\n", (int) ftell (h));
|
||||||
|
@ -304,7 +303,7 @@ WriteData (int crc)
|
||||||
void
|
void
|
||||||
PR_BeginCompilation (void)
|
PR_BeginCompilation (void)
|
||||||
{
|
{
|
||||||
numpr_globals = RESERVED_OFS;
|
pr.num_globals = RESERVED_OFS;
|
||||||
pr.def_tail = &pr.def_head;
|
pr.def_tail = &pr.def_head;
|
||||||
|
|
||||||
pr_error_count = 0;
|
pr_error_count = 0;
|
||||||
|
@ -314,22 +313,17 @@ void
|
||||||
PR_RelocateRefs (def_t *def)
|
PR_RelocateRefs (def_t *def)
|
||||||
{
|
{
|
||||||
statref_t *ref;
|
statref_t *ref;
|
||||||
int *d;
|
|
||||||
|
|
||||||
for (ref = def->refs; ref; ref = ref->next) {
|
for (ref = def->refs; ref; ref = ref->next) {
|
||||||
switch (ref->field) {
|
switch (ref->field) {
|
||||||
case 0:
|
case 0:
|
||||||
ref->statement->a = def->ofs;
|
pr.statements[ref->ofs].a = def->ofs;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ref->statement->b = def->ofs;
|
pr.statements[ref->ofs].b = def->ofs;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ref->statement->c = def->ofs;
|
pr.statements[ref->ofs].c = def->ofs;
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
d = (int*)ref->statement;
|
|
||||||
*d += def->ofs;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
|
@ -372,7 +366,7 @@ qboolean PR_FinishCompilation (void)
|
||||||
e.type = ex_string;
|
e.type = ex_string;
|
||||||
e.e.string_val = debugfile;
|
e.e.string_val = debugfile;
|
||||||
ReuseConstant (&e, PR_GetDef (&type_string, ".debug_file", 0,
|
ReuseConstant (&e, PR_GetDef (&type_string, ".debug_file", 0,
|
||||||
&numpr_globals));
|
&pr.num_globals));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (def = pr.def_head; def; def = def->def_next) {
|
for (def = pr.def_head; def; def = def->def_next) {
|
||||||
|
@ -381,22 +375,22 @@ qboolean PR_FinishCompilation (void)
|
||||||
PR_RelocateRefs (def);
|
PR_RelocateRefs (def);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (f = pr_functions; f; f = f->next) {
|
for (f = pr.function_list; f; f = f->next) {
|
||||||
if (f->builtin)
|
if (f->builtin)
|
||||||
continue;
|
continue;
|
||||||
if (f->def->locals > num_localdefs) {
|
if (f->def->locals > num_localdefs) {
|
||||||
num_localdefs = f->def->locals;
|
num_localdefs = f->def->locals;
|
||||||
big_function = f->def->name;
|
big_function = f->def->name;
|
||||||
}
|
}
|
||||||
f->dfunc->parm_start = numpr_globals;
|
f->dfunc->parm_start = pr.num_globals;
|
||||||
for (def = f->def->scope_next; def; def = def->scope_next) {
|
for (def = f->def->scope_next; def; def = def->scope_next) {
|
||||||
if (def->absolute)
|
if (def->absolute)
|
||||||
continue;
|
continue;
|
||||||
def->ofs += numpr_globals;
|
def->ofs += pr.num_globals;
|
||||||
PR_RelocateRefs (def);
|
PR_RelocateRefs (def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
numpr_globals += num_localdefs;
|
pr.num_globals += num_localdefs;
|
||||||
|
|
||||||
return !errors;
|
return !errors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ emit_struct(type_t *strct, const char *name)
|
||||||
ivars_def = PR_GetDef (ivar_list, ivars_name->str, 0, 0);
|
ivars_def = PR_GetDef (ivar_list, ivars_name->str, 0, 0);
|
||||||
if (ivars_def)
|
if (ivars_def)
|
||||||
goto done;
|
goto done;
|
||||||
ivars_def = PR_GetDef (ivar_list, ivars_name->str, 0, &numpr_globals);
|
ivars_def = PR_GetDef (ivar_list, ivars_name->str, 0, &pr.num_globals);
|
||||||
ivars_def->initialized = ivars_def->constant = 1;
|
ivars_def->initialized = ivars_def->constant = 1;
|
||||||
ivars = &G_STRUCT (pr_ivar_list_t, ivars_def->ofs);
|
ivars = &G_STRUCT (pr_ivar_list_t, ivars_def->ofs);
|
||||||
ivars->ivar_count = count;
|
ivars->ivar_count = count;
|
||||||
|
|
|
@ -297,7 +297,7 @@ build_switch (expr_t *sw, case_node_t *tree, int op, expr_t *sw_val,
|
||||||
range->type = ex_uinteger;
|
range->type = ex_uinteger;
|
||||||
|
|
||||||
def = PR_GetArray (&type_uinteger, name, high - low + 1, 0,
|
def = PR_GetArray (&type_uinteger, name, high - low + 1, 0,
|
||||||
&numpr_globals);
|
&pr.num_globals);
|
||||||
table->type = ex_def;
|
table->type = ex_def;
|
||||||
table->e.def = def;
|
table->e.def = def;
|
||||||
|
|
||||||
|
@ -320,11 +320,9 @@ build_switch (expr_t *sw, case_node_t *tree, int op, expr_t *sw_val,
|
||||||
build_switch (sw, tree->right, op, sw_val, temp, default_label);
|
build_switch (sw, tree->right, op, sw_val, temp, default_label);
|
||||||
}
|
}
|
||||||
for (i = 0; i <= high - low; i++) {
|
for (i = 0; i <= high - low; i++) {
|
||||||
dstatement_t *st;
|
|
||||||
statref_t *ref;
|
statref_t *ref;
|
||||||
|
|
||||||
st = (dstatement_t *) (G_INT (def->ofs) + i);
|
ref = PR_NewStatref (G_INT (def->ofs) + i, 3);
|
||||||
ref = PR_NewStatref (st, 3);
|
|
||||||
ref->next = tree->labels[i]->e.label.refs;
|
ref->next = tree->labels[i]->e.label.refs;
|
||||||
tree->labels[i]->e.label.refs = ref;
|
tree->labels[i]->e.label.refs = ref;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue