mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
Make adding a symbol to multiple tables an internal error.
This commit is contained in:
parent
d7cdf8077b
commit
f2c272f0b8
5 changed files with 16 additions and 4 deletions
|
@ -986,6 +986,8 @@ class_pointer_symbol (class_t *class)
|
|||
sym = make_symbol (va ("_OBJ_CLASS_POINTER_%s", class->name),
|
||||
pointer_type (class->type),
|
||||
pr.far_data, st_static);
|
||||
if (!sym->table)
|
||||
symtab_addsymbol (pr.symtab, sym);
|
||||
def = sym->s.def;
|
||||
if (def->initialized)
|
||||
return sym;
|
||||
|
|
|
@ -2404,6 +2404,8 @@ selector_expr (keywordarg_t *selector)
|
|||
index *= type_size (type_SEL.t.fldptr.type);
|
||||
sel_sym = make_symbol ("_OBJ_SELECTOR_TABLE", type_SEL.t.fldptr.type,
|
||||
0, st_extern);
|
||||
if (!sel_sym->table)
|
||||
symtab_addsymbol (pr.symtab, sel_sym);
|
||||
sel = new_symbol_expr (sel_sym);
|
||||
dstring_delete (sel_id);
|
||||
return address_expr (sel, new_short_expr (index), 0);
|
||||
|
|
|
@ -446,12 +446,14 @@ build_scope (symbol_t *fsym, symtab_t *parent)
|
|||
symbol_t *args = 0;
|
||||
symbol_t *param;
|
||||
symtab_t *symtab;
|
||||
symtab_t *cs = current_symtab;
|
||||
|
||||
check_function (fsym);
|
||||
|
||||
symtab = new_symtab (parent, stab_local);
|
||||
fsym->s.func->symtab = symtab;
|
||||
symtab->space = new_defspace ();
|
||||
current_symtab = symtab;
|
||||
|
||||
if (fsym->type->t.func.num_params < 0) {
|
||||
args = new_symbol_type (".args", &type_va_list);
|
||||
|
@ -466,7 +468,6 @@ build_scope (symbol_t *fsym, symtab_t *parent)
|
|||
continue; // non-param selector
|
||||
param = new_symbol_type (p->name, p->type);
|
||||
initialize_def (param, param->type, 0, symtab->space, st_local);
|
||||
symtab_addsymbol (symtab, param);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -477,6 +478,7 @@ build_scope (symbol_t *fsym, symtab_t *parent)
|
|||
i++;
|
||||
}
|
||||
}
|
||||
current_symtab = cs;
|
||||
}
|
||||
|
||||
function_t *
|
||||
|
|
|
@ -374,6 +374,7 @@ get_selector (expr_t *sel)
|
|||
def_t *
|
||||
emit_selectors (void)
|
||||
{
|
||||
symbol_t *sel_sym;
|
||||
def_t *sel_def;
|
||||
type_t *sel_type;
|
||||
pr_sel_t *sel;
|
||||
|
@ -383,8 +384,11 @@ emit_selectors (void)
|
|||
return 0;
|
||||
|
||||
sel_type = array_type (type_SEL.t.fldptr.type, sel_index);
|
||||
sel_def = make_symbol ("_OBJ_SELECTOR_TABLE", type_SEL.t.fldptr.type,
|
||||
pr.far_data, st_static)->s.def;
|
||||
sel_sym = make_symbol ("_OBJ_SELECTOR_TABLE", type_SEL.t.fldptr.type,
|
||||
pr.far_data, st_static);
|
||||
if (!sel_sym->table)
|
||||
symtab_addsymbol (pr.symtab, sel_sym);
|
||||
sel_def = sel_sym->s.def;
|
||||
sel_def->initialized = sel_def->constant = 1;
|
||||
sel_def->nosave = 1;
|
||||
|
||||
|
|
|
@ -108,6 +108,9 @@ symbol_t *
|
|||
symtab_addsymbol (symtab_t *symtab, symbol_t *symbol)
|
||||
{
|
||||
symbol_t *s;
|
||||
if (symbol->table)
|
||||
internal_error (0, "symbol '%s' is already in another symbol table",
|
||||
symbol->name);
|
||||
if ((s = Hash_Find (symtab->tab, symbol->name)))
|
||||
return s;
|
||||
Hash_Add (symtab->tab, symbol);
|
||||
|
@ -193,7 +196,6 @@ make_symbol (const char *name, type_t *type, defspace_t *space,
|
|||
sym = symtab_lookup (pr.symtab, name);
|
||||
if (!sym) {
|
||||
sym = new_symbol_type (name, type);
|
||||
symtab_addsymbol (pr.symtab, sym);
|
||||
}
|
||||
if (sym->type != type) {
|
||||
error (0, "%s redefined", name);
|
||||
|
|
Loading…
Reference in a new issue