mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
Clean out ex_def as ex_symbol replaces it.
This commit is contained in:
parent
b5424bca7d
commit
5deda9c9b9
15 changed files with 86 additions and 244 deletions
|
@ -49,7 +49,6 @@ typedef enum {
|
|||
ex_block, ///< statement block expression (::ex_block_t)
|
||||
ex_expr, ///< binary expression (::ex_expr_t)
|
||||
ex_uexpr, ///< unary expression (::ex_expr_t)
|
||||
ex_def, ///< non-temporary variable (::def_t)
|
||||
ex_symbol, ///< non-temporary variable (::symbol_t)
|
||||
ex_temp, ///< temporary variable (::ex_temp_t)
|
||||
|
||||
|
@ -184,7 +183,6 @@ typedef struct expr_s {
|
|||
ex_bool_t bool; ///< boolean logic expression
|
||||
ex_block_t block; ///< statement block expression
|
||||
ex_expr_t expr; ///< binary or unary expression
|
||||
struct def_s *def; ///< def reference expression
|
||||
struct symbol_s *symbol; ///< symbol reference expression
|
||||
ex_temp_t temp; ///< temporary variable expression
|
||||
ex_value_t value; ///< constant value
|
||||
|
@ -318,12 +316,6 @@ expr_t *new_binary_expr (int op, expr_t *e1, expr_t *e2);
|
|||
*/
|
||||
expr_t *new_unary_expr (int op, expr_t *e1);
|
||||
|
||||
/** Create a new def reference (non-temporary variable) expression node.
|
||||
|
||||
\return The new def reference expression node (::def_t).
|
||||
*/
|
||||
expr_t *new_def_expr (struct def_s *def);
|
||||
|
||||
/** Create a new symbol reference (non-temporary variable) expression node.
|
||||
|
||||
\return The new symbol reference expression node (::symbol_t).
|
||||
|
@ -480,15 +472,6 @@ int is_quaternion_val (expr_t *e);
|
|||
int is_integer_val (expr_t *e);
|
||||
int is_short_val (expr_t *e);
|
||||
|
||||
/** Convert a constant def to a constant expression.
|
||||
|
||||
\param var The def to convert.
|
||||
\return A new constant expression of the appropriate type with
|
||||
the value of the constant def, or \a var if neither a def
|
||||
nor a constant def.
|
||||
*/
|
||||
expr_t *constant_expr (expr_t *var);
|
||||
|
||||
/** Bind the result of an expression to a temporary variable.
|
||||
|
||||
If a temporary variable is not needed when emitting code, none will
|
||||
|
|
|
@ -32,12 +32,10 @@
|
|||
#ifndef __idstuff_h
|
||||
#define __idstuff_h
|
||||
|
||||
struct def_s;
|
||||
|
||||
//XXX eww :/
|
||||
void PrecacheSound (struct def_s *e, int ch);
|
||||
void PrecacheModel (struct def_s *e, int ch);
|
||||
void PrecacheFile (struct def_s *e, int ch);
|
||||
void PrecacheSound (const char *, int ch);
|
||||
void PrecacheModel (const char *, int ch);
|
||||
void PrecacheFile (const char *, int ch);
|
||||
int WriteFiles (const char *sourcedir);
|
||||
int WriteProgdefs (const char *filename);
|
||||
|
||||
|
|
|
@ -69,6 +69,8 @@ typedef struct pr_info_s {
|
|||
struct defspace_s *entity_data;
|
||||
struct scope_s *scope;
|
||||
|
||||
struct symtab_s *symtab;
|
||||
|
||||
srcline_t *srcline_stack;
|
||||
string_t source_file;
|
||||
int source_line;
|
||||
|
|
|
@ -754,10 +754,10 @@ class_finish_module (void)
|
|||
def_t *symtab_def;
|
||||
pr_symtab_t *symtab;
|
||||
pointer_t *def_ptr;
|
||||
def_t *module_def;
|
||||
pr_module_t *module;
|
||||
def_t *exec_class_def;
|
||||
def_t *init_def;
|
||||
symbol_t *module_sym;
|
||||
//FIXME pr_module_t *module;
|
||||
symbol_t *exec_class_sym;
|
||||
symbol_t *init_sym;
|
||||
function_t *init_func;
|
||||
expr_t *init_expr;
|
||||
|
||||
|
@ -807,32 +807,26 @@ class_finish_module (void)
|
|||
}
|
||||
}
|
||||
|
||||
module_def = get_def (&type_module, "_OBJ_MODULE", pr.scope, st_static);
|
||||
module_def->initialized = module_def->constant = 1;
|
||||
module_def->nosave = 1;
|
||||
module = &G_STRUCT (pr_module_t, module_def->ofs);
|
||||
module->size = type_size (&type_module);
|
||||
EMIT_STRING (module->name, G_GETSTR (pr.source_file));
|
||||
EMIT_DEF (module->symtab, symtab_def);
|
||||
module_sym = new_symbol_type ("_OBJ_MODULE", &type_module);
|
||||
//FIXME module = &G_STRUCT (pr_module_t, module_def->ofs);
|
||||
//FIXME module->size = type_size (&type_module);
|
||||
//FIXME EMIT_STRING (module->name, G_GETSTR (pr.source_file));
|
||||
//FIXME EMIT_DEF (module->symtab, symtab_def);
|
||||
|
||||
exec_class_def = get_def (&type_obj_exec_class, "__obj_exec_class",
|
||||
pr.scope, st_extern);
|
||||
exec_class_sym = new_symbol_type ("__obj_exec_class",
|
||||
&type_obj_exec_class);
|
||||
symtab_addsymbol (current_symtab, exec_class_sym);
|
||||
|
||||
init_def = get_def (&type_function, ".ctor", pr.scope, st_static);
|
||||
current_func = init_func = new_function (init_def->name, 0);
|
||||
add_function (init_func);
|
||||
reloc_def_func (init_func, init_def->ofs);
|
||||
init_func->code = pr.code->size;
|
||||
//FIXME build_scope (init_func, init_def, 0);
|
||||
build_function (init_func);
|
||||
init_sym = new_symbol_type (".ctor", &type_function);
|
||||
symtab_addsymbol (current_symtab, init_sym);
|
||||
init_expr = new_block_expr ();
|
||||
append_expr (init_expr,
|
||||
build_function_call (new_def_expr (exec_class_def),
|
||||
exec_class_def->type,
|
||||
address_expr (new_def_expr (module_def),
|
||||
build_function_call (new_symbol_expr (exec_class_sym),
|
||||
exec_class_sym->type,
|
||||
address_expr (new_symbol_expr (module_sym),
|
||||
0, 0)));
|
||||
emit_function (init_func, init_expr);
|
||||
finish_function (init_func);
|
||||
current_func = init_func = begin_function (init_sym, 0, current_symtab);
|
||||
build_code_function (init_sym, 0, init_expr);;
|
||||
current_func = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ convert_to_float (expr_t *e)
|
|||
internal_error (e, 0);
|
||||
}
|
||||
break;
|
||||
case ex_def:
|
||||
case ex_symbol:
|
||||
case ex_expr:
|
||||
case ex_uexpr:
|
||||
case ex_temp:
|
||||
|
|
|
@ -104,8 +104,6 @@ get_type (expr_t *e)
|
|||
case ex_expr:
|
||||
case ex_uexpr:
|
||||
return e->e.expr.type;
|
||||
case ex_def:
|
||||
return e->e.def->type;
|
||||
case ex_symbol:
|
||||
return e->e.symbol->type;
|
||||
case ex_temp:
|
||||
|
@ -237,39 +235,6 @@ test_error (expr_t *e, type_t *t)
|
|||
return e;
|
||||
}
|
||||
|
||||
static void
|
||||
check_initialized (expr_t *e)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
if (e->type == ex_def
|
||||
&& !(e->e.def->type->type == ev_func
|
||||
&& !e->e.def->local)
|
||||
&& !is_struct (e->e.def->type)
|
||||
&& !e->e.def->external
|
||||
&& !e->e.def->initialized) {
|
||||
name = e->e.def->name;
|
||||
if (options.warnings.uninited_variable && !e->e.def->suppress) {
|
||||
if (options.code.local_merging)
|
||||
warning (e, "%s may be used uninitialized", name);
|
||||
else
|
||||
notice (e, "%s may be used uninitialized", name);
|
||||
}
|
||||
e->e.def->suppress = 1; // warn only once
|
||||
if (options.traditional && options.code.local_merging
|
||||
&& !e->e.def->set) {
|
||||
def_t *def = e->e.def;
|
||||
e->e.def->set = 1; // auto-init only once
|
||||
e = assign_expr (e, new_nil_expr ());
|
||||
e->file = def->file;
|
||||
e->line = def->line;
|
||||
e->next = current_func->var_init;
|
||||
current_func->var_init = e;
|
||||
notice (e, "auto-initializing %s", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expr_t *
|
||||
inc_users (expr_t *e)
|
||||
{
|
||||
|
@ -312,7 +277,6 @@ copy_expr (expr_t *e)
|
|||
return 0;
|
||||
switch (e->type) {
|
||||
case ex_error:
|
||||
case ex_def:
|
||||
case ex_symbol:
|
||||
case ex_nil:
|
||||
case ex_value:
|
||||
|
@ -494,15 +458,6 @@ new_unary_expr (int op, expr_t *e1)
|
|||
return e;
|
||||
}
|
||||
|
||||
expr_t *
|
||||
new_def_expr (def_t *def)
|
||||
{
|
||||
expr_t *e = new_expr ();
|
||||
e->type = ex_def;
|
||||
e->e.def = def;
|
||||
return e;
|
||||
}
|
||||
|
||||
expr_t *
|
||||
new_symbol_expr (symbol_t *symbol)
|
||||
{
|
||||
|
@ -813,34 +768,6 @@ expr_short (expr_t *e)
|
|||
internal_error (e, "not a short constant");
|
||||
}
|
||||
|
||||
expr_t *
|
||||
constant_expr (expr_t *var)
|
||||
{
|
||||
def_t *def;
|
||||
|
||||
if (var->type != ex_def || !var->e.def->constant)
|
||||
return var;
|
||||
|
||||
def = var->e.def;
|
||||
def->used = 1;
|
||||
switch (def->type->type) {
|
||||
case ev_string:
|
||||
return new_string_expr (G_GETSTR (def->ofs));
|
||||
case ev_float:
|
||||
return new_float_expr (G_FLOAT (def->ofs));
|
||||
case ev_vector:
|
||||
return new_vector_expr (G_VECTOR (def->ofs));
|
||||
case ev_field:
|
||||
return new_field_expr (G_INT (def->ofs), def->type, def);
|
||||
case ev_integer:
|
||||
return new_integer_expr (G_INT (def->ofs));
|
||||
// case ev_uinteger:
|
||||
// return new_uinteger_expr (G_INT (def->ofs));
|
||||
default:
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
expr_t *
|
||||
new_bind_expr (expr_t *e1, expr_t *e2)
|
||||
{
|
||||
|
@ -861,33 +788,35 @@ new_bind_expr (expr_t *e1, expr_t *e2)
|
|||
expr_t *
|
||||
new_self_expr (void)
|
||||
{
|
||||
def_t *def = get_def (&type_entity, ".self", pr.scope, st_extern);
|
||||
|
||||
def_initialized (def);
|
||||
return new_def_expr (def);
|
||||
symbol_t *sym = symtab_lookup (pr.symtab, ".self");
|
||||
|
||||
if (!sym) {
|
||||
sym = new_symbol_type (".self", &type_entity);
|
||||
symtab_addsymbol (pr.symtab, sym);
|
||||
}
|
||||
return new_symbol_expr (sym);
|
||||
}
|
||||
|
||||
expr_t *
|
||||
new_this_expr (void)
|
||||
{
|
||||
type_t *type = field_type (&type_id);
|
||||
def_t *def = get_def (type, ".this", pr.scope, st_extern);
|
||||
|
||||
def_initialized (def);
|
||||
def->nosave = 1;
|
||||
return new_def_expr (def);
|
||||
symbol_t *sym = symtab_lookup (pr.symtab, ".this");
|
||||
|
||||
if (!sym) {
|
||||
sym = new_symbol_type (".this", field_type (&type_id));
|
||||
symtab_addsymbol (pr.symtab, sym);
|
||||
}
|
||||
return new_symbol_expr (sym);
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
param_expr (const char *name, type_t *type)
|
||||
{
|
||||
def_t *def = get_def (&type_param, name, pr.scope, st_extern);
|
||||
expr_t *def_expr;
|
||||
symbol_t *sym = symtab_lookup (pr.symtab, name);
|
||||
expr_t *sym_expr;
|
||||
|
||||
def_initialized (def);
|
||||
def->nosave = 1;
|
||||
def_expr = new_def_expr (def);
|
||||
return unary_expr ('.', address_expr (def_expr, 0, type));
|
||||
sym_expr = new_symbol_expr (sym);
|
||||
return unary_expr ('.', address_expr (sym_expr, 0, type));
|
||||
}
|
||||
|
||||
expr_t *
|
||||
|
@ -994,15 +923,6 @@ print_expr (expr_t *e)
|
|||
print_expr (e->e.expr.e1);
|
||||
printf (" u%s", get_op_string (e->e.expr.op));
|
||||
break;
|
||||
case ex_def:
|
||||
if (e->e.def->name)
|
||||
printf ("%s", e->e.def->name);
|
||||
if (!e->e.def->global) {
|
||||
printf ("<%d>", e->e.def->ofs);
|
||||
} else {
|
||||
printf ("[%d]", e->e.def->ofs);
|
||||
}
|
||||
break;
|
||||
case ex_symbol:
|
||||
printf ("%s", e->e.symbol->name);
|
||||
break;
|
||||
|
@ -1088,7 +1008,6 @@ test_expr (expr_t *e, int test)
|
|||
return unary_expr ('!', e);
|
||||
|
||||
type = extract_type (e);
|
||||
check_initialized (e);
|
||||
if (e->type == ex_error)
|
||||
return e;
|
||||
switch (type) {
|
||||
|
@ -1492,9 +1411,6 @@ binary_expr (int op, expr_t *e1, expr_t *e2)
|
|||
|
||||
if (op == '.')
|
||||
return field_expr (e1, e2);
|
||||
check_initialized (e1);
|
||||
|
||||
check_initialized (e2);
|
||||
|
||||
if (op == OR || op == AND) {
|
||||
e1 = test_expr (e1, true);
|
||||
|
@ -1505,8 +1421,6 @@ binary_expr (int op, expr_t *e1, expr_t *e2)
|
|||
return e1;
|
||||
if (e2->type == ex_error)
|
||||
return e2;
|
||||
e1 = constant_expr (e1);
|
||||
e2 = constant_expr (e2);
|
||||
t1 = get_type (e1);
|
||||
t2 = get_type (e2);
|
||||
if (!t1 || !t2) {
|
||||
|
@ -1606,7 +1520,6 @@ unary_expr (int op, expr_t *e)
|
|||
quat_t q;
|
||||
const char *s;
|
||||
|
||||
check_initialized (e);
|
||||
if (e->type == ex_error)
|
||||
return e;
|
||||
switch (op) {
|
||||
|
@ -1652,13 +1565,11 @@ unary_expr (int op, expr_t *e)
|
|||
return error (e, "invalid type for unary -");
|
||||
case ex_expr:
|
||||
case ex_bool:
|
||||
case ex_def:
|
||||
case ex_temp:
|
||||
{
|
||||
expr_t *n = new_unary_expr (op, e);
|
||||
|
||||
n->e.expr.type = (e->type == ex_def)
|
||||
? e->e.def->type : e->e.expr.type;
|
||||
n->e.expr.type = e->e.expr.type;
|
||||
return n;
|
||||
}
|
||||
case ex_symbol:
|
||||
|
@ -1714,7 +1625,6 @@ unary_expr (int op, expr_t *e)
|
|||
return error (e, "invalid type for unary !");
|
||||
case ex_uexpr:
|
||||
case ex_expr:
|
||||
case ex_def:
|
||||
case ex_symbol:
|
||||
case ex_temp:
|
||||
{
|
||||
|
@ -1772,7 +1682,6 @@ unary_expr (int op, expr_t *e)
|
|||
goto bitnot_expr;
|
||||
case ex_expr:
|
||||
case ex_bool:
|
||||
case ex_def:
|
||||
case ex_symbol:
|
||||
case ex_temp:
|
||||
bitnot_expr:
|
||||
|
@ -1855,7 +1764,6 @@ build_function_call (expr_t *fexpr, type_t *ftype, expr_t *params)
|
|||
if (type_size (t) > type_size (&type_param))
|
||||
err = error (e, "formal parameter %d is too large to be passed by"
|
||||
" value", i + 1);
|
||||
check_initialized (e);
|
||||
if (ftype->t.func.param_types[i] == &type_float
|
||||
&& is_integer_val (e)) {
|
||||
convert_int (e);
|
||||
|
@ -1869,7 +1777,7 @@ build_function_call (expr_t *fexpr, type_t *ftype, expr_t *params)
|
|||
if (e->type == ex_error)
|
||||
return e;
|
||||
if (!type_assignable (ftype->t.func.param_types[i], t)) {
|
||||
err = param_mismatch (e, i + 1, fexpr->e.def->name,
|
||||
err = param_mismatch (e, i + 1, fexpr->e.symbol->name,
|
||||
ftype->t.func.param_types[i], t);
|
||||
}
|
||||
t = ftype->t.func.param_types[i];
|
||||
|
@ -1940,25 +1848,22 @@ function_expr (expr_t *fexpr, expr_t *params)
|
|||
if (fexpr->type == ex_error)
|
||||
return fexpr;
|
||||
if (ftype->type != ev_func) {
|
||||
if (fexpr->type == ex_def)
|
||||
if (fexpr->type == ex_symbol)
|
||||
return error (fexpr, "Called object \"%s\" is not a function",
|
||||
fexpr->e.def->name);
|
||||
fexpr->e.symbol->name);
|
||||
else
|
||||
return error (fexpr, "Called object is not a function");
|
||||
}
|
||||
|
||||
if (fexpr->type == ex_def && params && is_string_val (params)) {
|
||||
if (fexpr->type == ex_symbol && params && is_string_val (params)) {
|
||||
// FIXME eww, I hate this, but it's needed :(
|
||||
// FIXME make a qc hook? :)
|
||||
def_t *func = fexpr->e.def;
|
||||
def_t *e = ReuseConstant (params, 0);
|
||||
|
||||
if (strncmp (func->name, "precache_sound", 14) == 0)
|
||||
PrecacheSound (e, func->name[14]);
|
||||
else if (strncmp (func->name, "precache_model", 14) == 0)
|
||||
PrecacheModel (e, func->name[14]);
|
||||
else if (strncmp (func->name, "precache_file", 13) == 0)
|
||||
PrecacheFile (e, func->name[13]);
|
||||
if (strncmp (fexpr->e.symbol->name, "precache_sound", 14) == 0)
|
||||
PrecacheSound (expr_string (params), fexpr->e.symbol->name[14]);
|
||||
else if (strncmp (fexpr->e.symbol->name, "precache_model", 14) == 0)
|
||||
PrecacheModel (expr_string (params), fexpr->e.symbol->name[14]);
|
||||
else if (strncmp (fexpr->e.symbol->name, "precache_file", 13) == 0)
|
||||
PrecacheFile (expr_string (params), fexpr->e.symbol->name[13]);
|
||||
}
|
||||
|
||||
return build_function_call (fexpr, ftype, params);
|
||||
|
@ -2000,7 +1905,6 @@ return_expr (function_t *f, expr_t *e)
|
|||
convert_int (e);
|
||||
t = &type_float;
|
||||
}
|
||||
check_initialized (e);
|
||||
if (t == &type_void) {
|
||||
if (e->type == ex_nil) {
|
||||
t = f->sym->type->t.func.type;
|
||||
|
@ -2171,7 +2075,6 @@ expr_t *
|
|||
address_expr (expr_t *e1, expr_t *e2, type_t *t)
|
||||
{
|
||||
expr_t *e;
|
||||
type_t *type;
|
||||
|
||||
if (e1->type == ex_error)
|
||||
return e1;
|
||||
|
@ -2180,26 +2083,13 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t)
|
|||
t = get_type (e1);
|
||||
|
||||
switch (e1->type) {
|
||||
case ex_def:
|
||||
{
|
||||
def_t *def = e1->e.def;
|
||||
def->used = 1;
|
||||
type = def->type;
|
||||
if (is_struct (type) || is_class (type)) {
|
||||
e = new_pointer_expr (0, t, def);
|
||||
e->line = e1->line;
|
||||
e->file = e1->file;
|
||||
} else if (is_array (type)) {
|
||||
e = e1;
|
||||
e = new_pointer_expr (0, t, def);
|
||||
e->file = e1->file;
|
||||
e->line = e1->line;
|
||||
} else {
|
||||
e = new_unary_expr ('&', e1);
|
||||
e->e.expr.type = pointer_type (t);
|
||||
}
|
||||
case ex_symbol:
|
||||
if (e1->e.symbol->sy_type == sy_var) {
|
||||
e = new_unary_expr ('&', e1);
|
||||
e->e.expr.type = pointer_type (t);
|
||||
break;
|
||||
}
|
||||
return error (e1, "invalid type for unary &");
|
||||
case ex_expr:
|
||||
if (e1->e.expr.op == '.') {
|
||||
e = e1;
|
||||
|
@ -2460,7 +2350,7 @@ is_lvalue (expr_t *e)
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
if (e->type == ex_def || e->type == ex_temp)
|
||||
if (e->type == ex_temp)
|
||||
return 1;
|
||||
if (e->type == ex_expr && e->e.expr.op == '.')
|
||||
return 1;
|
||||
|
@ -2493,9 +2383,6 @@ assign_expr (expr_t *e1, expr_t *e2)
|
|||
}
|
||||
}
|
||||
|
||||
if (e1->type == ex_def)
|
||||
def_initialized (e1->e.def);
|
||||
|
||||
if (!is_lvalue (e1)) {
|
||||
if (options.traditional)
|
||||
warning (e1, "invalid lvalue in assignment");
|
||||
|
@ -2509,7 +2396,7 @@ assign_expr (expr_t *e1, expr_t *e2)
|
|||
}
|
||||
//XXX func = func ???
|
||||
if (t1->type != ev_pointer || !is_array (t2))
|
||||
check_initialized (e2);
|
||||
;//FIXME check_initialized (e2);
|
||||
else {
|
||||
e2 = address_expr (e2, 0, t2->t.fldptr.type); // FIXME
|
||||
t2 = get_type (e2);
|
||||
|
@ -2590,7 +2477,7 @@ assign_expr (expr_t *e1, expr_t *e2)
|
|||
&& POINTER_VAL (e->e.value.v.pointer) < 65536)) {
|
||||
if (e->type == ex_expr && e->e.expr.op == '&'
|
||||
&& e->e.expr.type->type == ev_pointer
|
||||
&& e->e.expr.e1->type < ex_nil) {
|
||||
&& !is_constant (e)) {
|
||||
e2 = e;
|
||||
e2->e.expr.op = '.';
|
||||
e2->e.expr.type = t2;
|
||||
|
@ -2619,8 +2506,6 @@ cast_expr (type_t *type, expr_t *e)
|
|||
if (e->type == ex_error)
|
||||
return e;
|
||||
|
||||
check_initialized (e);
|
||||
|
||||
e_type = get_type (e);
|
||||
|
||||
if (type == e_type)
|
||||
|
@ -2671,7 +2556,7 @@ selector_expr (keywordarg_t *selector)
|
|||
index *= type_size (type_SEL.t.fldptr.type);
|
||||
sel_def = get_def (type_SEL.t.fldptr.type, "_OBJ_SELECTOR_TABLE", pr.scope,
|
||||
st_extern);
|
||||
sel = new_def_expr (sel_def);
|
||||
sel = 0; //FIXME new_def_expr (sel_def);
|
||||
dstring_delete (sel_id);
|
||||
return address_expr (sel, new_short_expr (index), 0);
|
||||
}
|
||||
|
@ -2714,7 +2599,7 @@ super_expr (class_type_t *class_type)
|
|||
|
||||
super_d = 0;//FIXME get_def (&type_Super, ".super", current_func->scope, st_local);
|
||||
def_initialized (super_d);
|
||||
super = new_def_expr (super_d);
|
||||
super = 0; //FIXME new_def_expr (super_d);
|
||||
super_block = new_block_expr ();
|
||||
|
||||
e = assign_expr (binary_expr ('.', super, new_name_expr ("self")),
|
||||
|
@ -2723,7 +2608,7 @@ super_expr (class_type_t *class_type)
|
|||
|
||||
_class_type.type = ct_class;
|
||||
_class_type.c.class = class;
|
||||
e = new_def_expr (class_def (&_class_type, 1));
|
||||
e = 0; //FIXME new_def_expr (class_def (&_class_type, 1));
|
||||
e = assign_expr (binary_expr ('.', super, new_name_expr ("class")),
|
||||
binary_expr ('.', e, new_name_expr ("super_class")));
|
||||
append_expr (super_block, e);
|
||||
|
|
|
@ -72,16 +72,10 @@ static int precache_files_block[MAX_SOUNDS];
|
|||
static int numfiles;
|
||||
|
||||
void
|
||||
PrecacheSound (def_t *e, int ch)
|
||||
PrecacheSound (const char *n, int ch)
|
||||
{
|
||||
char *n;
|
||||
int i;
|
||||
|
||||
if (!e->ofs)
|
||||
return;
|
||||
|
||||
n = G_STRING (e->ofs);
|
||||
|
||||
for (i = 0; i < numsounds; i++) {
|
||||
if (!strcmp (n, precache_sounds[i])) {
|
||||
return;
|
||||
|
@ -103,16 +97,10 @@ PrecacheSound (def_t *e, int ch)
|
|||
}
|
||||
|
||||
void
|
||||
PrecacheModel (def_t *e, int ch)
|
||||
PrecacheModel (const char *n, int ch)
|
||||
{
|
||||
char *n;
|
||||
int i;
|
||||
|
||||
if (!e->ofs)
|
||||
return;
|
||||
|
||||
n = G_STRING (e->ofs);
|
||||
|
||||
for (i = 0; i < nummodels; i++) {
|
||||
if (!strcmp (n, precache_models[i])) {
|
||||
return;
|
||||
|
@ -134,16 +122,10 @@ PrecacheModel (def_t *e, int ch)
|
|||
}
|
||||
|
||||
void
|
||||
PrecacheFile (def_t *e, int ch)
|
||||
PrecacheFile (const char *n, int ch)
|
||||
{
|
||||
char *n;
|
||||
int i;
|
||||
|
||||
if (!e->ofs)
|
||||
return;
|
||||
|
||||
n = G_STRING (e->ofs);
|
||||
|
||||
for (i = 0; i < numfiles; i++) {
|
||||
if (!strcmp (n, precache_files[i])) {
|
||||
return;
|
||||
|
|
|
@ -224,7 +224,7 @@ ReuseConstant (expr_t *expr, def_t *def)
|
|||
if (def) {
|
||||
imm = 0; //FIXME do full def aliasing
|
||||
} else {
|
||||
expr_t *e = new_def_expr (imm->def);
|
||||
expr_t *e = 0;//FIXME new_def_expr (imm->def);
|
||||
e = address_expr (e, 0, type);
|
||||
e = unary_expr ('.', e);
|
||||
return emit_sub_expr (e, 0);
|
||||
|
|
|
@ -247,12 +247,15 @@ copy_keywordargs (const keywordarg_t *kwargs)
|
|||
expr_t *
|
||||
send_message (int super)
|
||||
{
|
||||
return 0;
|
||||
#if 0 //FIXME
|
||||
if (super)
|
||||
return new_def_expr (get_def (&type_supermsg, "obj_msgSend_super",
|
||||
pr.scope, st_extern));
|
||||
else
|
||||
return new_def_expr (get_def (&type_IMP, "obj_msgSend", pr.scope,
|
||||
st_extern));
|
||||
#endif
|
||||
}
|
||||
|
||||
method_t *
|
||||
|
|
|
@ -464,7 +464,7 @@ param
|
|||
array_decl
|
||||
: '[' fexpr ']'
|
||||
{
|
||||
$2 = constant_expr ($2);
|
||||
$2 = fold_constants ($2);
|
||||
if (($2->type != ex_value && $2->e.value.type != ev_integer)
|
||||
|| $2->e.value.v.integer_val < 1) {
|
||||
error (0, "invalid array size");
|
||||
|
|
|
@ -87,6 +87,7 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
|||
#include "reloc.h"
|
||||
#include "strpool.h"
|
||||
#include "struct.h"
|
||||
#include "symtab.h"
|
||||
#include "type.h"
|
||||
|
||||
options_t options;
|
||||
|
@ -544,12 +545,7 @@ begin_compilation (void)
|
|||
static void
|
||||
setup_param_block (void)
|
||||
{
|
||||
size_t i;
|
||||
def_t *def;
|
||||
static struct {
|
||||
const char *name;
|
||||
type_t *type;
|
||||
} defs[] = {
|
||||
static struct_def_t defs[] = {
|
||||
{".zero", &type_zero},
|
||||
{".return", &type_param},
|
||||
{".param_0", &type_param},
|
||||
|
@ -561,11 +557,13 @@ setup_param_block (void)
|
|||
{".param_6", &type_param},
|
||||
{".param_7", &type_param},
|
||||
};
|
||||
size_t i;
|
||||
symbol_t *sym;
|
||||
|
||||
pr.symtab = new_symtab (0, stab_global);
|
||||
for (i = 0; i < sizeof (defs) / sizeof (defs[0]); i++) {
|
||||
def = get_def (defs[i].type, defs[i].name, pr.scope, st_global);
|
||||
def->nosave = 1;
|
||||
def_initialized (def);
|
||||
sym = new_symbol_type (defs[i].name, defs[i].type);
|
||||
symtab_addsymbol (pr.symtab, sym);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ program
|
|||
subprogram_declarations
|
||||
compound_statement '.'
|
||||
{
|
||||
symtab_t *st = current_symtab;
|
||||
// move the symbol for the program name to the end of the list
|
||||
symtab_removesymbol (current_symtab, $1);
|
||||
symtab_addsymbol (current_symtab, $1);
|
||||
|
@ -157,6 +158,7 @@ program
|
|||
current_func = begin_function ($1, 0, current_symtab);
|
||||
current_symtab = current_func->symtab;
|
||||
build_code_function ($1, 0, $4);
|
||||
current_symtab = st;
|
||||
|
||||
$4 = function_expr (new_symbol_expr ($1), 0);
|
||||
$1 = new_symbol (".main");
|
||||
|
@ -166,6 +168,7 @@ program
|
|||
current_func = begin_function ($1, 0, current_symtab);
|
||||
current_symtab = current_func->symtab;
|
||||
build_code_function ($1, 0, $4);
|
||||
current_symtab = st;
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -173,7 +176,7 @@ program_head
|
|||
: PROGRAM ID '(' opt_identifier_list ')' ';'
|
||||
{
|
||||
$$ = $2;
|
||||
current_symtab = new_symtab (0, stab_global);
|
||||
current_symtab = pr.symtab;
|
||||
|
||||
$$->type = parse_params (&type_void, 0);
|
||||
$$ = function_symbol ($$, 0, 1);
|
||||
|
|
|
@ -210,7 +210,6 @@ statement_subexpr (sblock_t *sblock, expr_t *e, operand_t **op)
|
|||
break;
|
||||
case ex_uexpr:
|
||||
break;
|
||||
case ex_def:
|
||||
case ex_symbol:
|
||||
*op = new_operand (op_symbol);
|
||||
(*op)->o.symbol = e->e.symbol;
|
||||
|
@ -312,7 +311,6 @@ statement_expr (sblock_t *sblock, expr_t *e)
|
|||
goto non_executable;
|
||||
}
|
||||
break;
|
||||
case ex_def:
|
||||
case ex_symbol:
|
||||
case ex_temp:
|
||||
case ex_nil:
|
||||
|
|
|
@ -162,7 +162,6 @@ add_enum (symbol_t *enm, symbol_t *name, expr_t *val)
|
|||
if (*enum_tab->symtail)
|
||||
value = ((symbol_t *)(*enum_tab->symtail))->s.value.v.integer_val + 1;
|
||||
if (val) {
|
||||
val = constant_expr (val);
|
||||
if (!is_constant (val))
|
||||
error (val, "non-constant initializer");
|
||||
else if (!is_integer_val (val))
|
||||
|
|
|
@ -110,10 +110,7 @@ case_label_expr (switch_block_t *switch_block, expr_t *value)
|
|||
|
||||
SYS_CHECKMEM (cl);
|
||||
|
||||
if (value) {
|
||||
value = constant_expr (value);
|
||||
}
|
||||
if (value && value->type < ex_nil) {
|
||||
if (value && !is_constant (value)) {
|
||||
error (value, "non-constant case value");
|
||||
free (cl);
|
||||
return 0;
|
||||
|
@ -316,7 +313,7 @@ build_switch (expr_t *sw, case_node_t *tree, int op, expr_t *sw_val,
|
|||
//FIXME unsigned int better?
|
||||
def = get_def (array_type (&type_integer, high - low + 1), name,
|
||||
pr.scope, st_static);
|
||||
table = new_def_expr (def);
|
||||
table = 0;//FIXME new_def_expr (def);
|
||||
|
||||
if (tree->left) {
|
||||
branch = new_binary_expr (IFB, temp, low_label);
|
||||
|
|
Loading…
Reference in a new issue