Rename the storage_class_t enum values.

With the intoduction of the statement type enum came a prefix clash. As
"st" makes sense for "statement type", I decided that "storage class"
should be "sc". Although there haven't been any problems as of yet, I
decided it would be a good idea to clean up the clash now. It also helps
avoid confusion (I was a bit surprised after working with st_assign etc to
be reminded of st_extern etc).
This commit is contained in:
Bill Currie 2012-12-02 10:11:30 +09:00
parent 4c65d9f2a4
commit 5725c5124c
17 changed files with 77 additions and 77 deletions

View file

@ -66,12 +66,12 @@ typedef struct def_s {
} def_t;
typedef enum storage_class_e {
st_global,
st_system,
st_extern,
st_static,
st_param,
st_local
sc_global,
sc_system,
sc_extern,
sc_static,
sc_param,
sc_local
} storage_class_t;
extern storage_class_t current_storage;

View file

@ -228,7 +228,7 @@ class_symbol (class_type_t *class_type, int external)
return 0; // probably in error recovery
}
sym = make_symbol (name, type, pr.far_data,
external ? st_extern : st_global);
external ? sc_extern : sc_global);
if (!sym->table)
symtab_addsymbol (pr.symtab, sym);
return sym;
@ -432,7 +432,7 @@ emit_ivars (symtab_t *ivars, const char *name)
ivar_list_struct[1].type = array_type (&type_obj_ivar, ivar_data.count);
def = emit_structure (va ("_OBJ_INSTANCE_VARIABLES_%s", name), 's',
ivar_list_struct, 0, &ivar_data, st_static);
ivar_list_struct, 0, &ivar_data, sc_static);
dstring_delete (ivar_data.encoding);
return def;
@ -449,7 +449,7 @@ begin_class (class_t *class)
defspace_t *space;
sym = make_symbol (va ("_OBJ_METACLASS_%s", class->name),
&type_obj_class, pr.far_data, st_static);
&type_obj_class, pr.far_data, sc_static);
meta_def = sym->s.def;
meta_def->initialized = meta_def->constant = meta_def->nosave = 1;
space = meta_def->space;
@ -511,7 +511,7 @@ emit_class_ref (const char *class_name)
def_t *name_def;
ref_sym = make_symbol (va (".obj_class_ref_%s", class_name), &type_pointer,
pr.far_data, st_static);
pr.far_data, sc_static);
if (!ref_sym->table)
symtab_addsymbol (pr.symtab, ref_sym);
ref_def = ref_sym->s.def;
@ -519,7 +519,7 @@ emit_class_ref (const char *class_name)
return;
ref_def->initialized = ref_def->constant = ref_def->nosave = 1;
name_sym = make_symbol (va (".obj_class_name_%s", class_name),
&type_pointer, pr.far_data, st_extern);
&type_pointer, pr.far_data, sc_extern);
if (!name_sym->table)
symtab_addsymbol (pr.symtab, name_sym);
name_def = name_sym->s.def;
@ -535,7 +535,7 @@ emit_class_name (const char *class_name)
def_t *name_def;
name_sym = make_symbol (va (".obj_class_name_%s", class_name),
&type_pointer, pr.far_data, st_global);
&type_pointer, pr.far_data, sc_global);
if (!name_sym->table)
symtab_addsymbol (pr.symtab, name_sym);
name_def = name_sym->s.def;
@ -556,7 +556,7 @@ emit_category_ref (const char *class_name, const char *category_name)
ref_sym = make_symbol (va (".obj_category_ref_%s_%s",
class_name, category_name),
&type_pointer, pr.far_data, st_static);
&type_pointer, pr.far_data, sc_static);
if (!ref_sym->table)
symtab_addsymbol (pr.symtab, ref_sym);
ref_def = ref_sym->s.def;
@ -566,7 +566,7 @@ emit_category_ref (const char *class_name, const char *category_name)
ref_def->nosave = 1;
name_sym = make_symbol (va (".obj_category_name_%s_%s",
class_name, category_name),
&type_pointer, pr.far_data, st_extern);
&type_pointer, pr.far_data, sc_extern);
if (!name_sym->table)
symtab_addsymbol (pr.symtab, name_sym);
name_def = name_sym->s.def;
@ -583,7 +583,7 @@ emit_category_name (const char *class_name, const char *category_name)
name_sym = make_symbol (va (".obj_category_name_%s_%s",
class_name, category_name),
&type_pointer, pr.far_data, st_global);
&type_pointer, pr.far_data, sc_global);
if (!name_sym->table)
symtab_addsymbol (pr.symtab, name_sym);
name_def = name_sym->s.def;
@ -959,7 +959,7 @@ class_pointer_symbol (class_t *class)
sym = make_symbol (va ("_OBJ_CLASS_POINTER_%s", class->name),
&type_Class,
pr.near_data, st_static);
pr.near_data, sc_static);
if (!sym->table)
symtab_addsymbol (pr.symtab, sym);
def = sym->s.def;
@ -1100,12 +1100,12 @@ class_finish_module (void)
symtab_struct[4].type = array_type (&type_pointer,
data.cls_def_cnt + data.cat_def_cnt);
symtab_def = emit_structure ("_OBJ_SYMTAB", 's', symtab_struct, 0, &data,
st_static);
sc_static);
free (data.classes);
free (data.categories);
module_sym = make_symbol ("_OBJ_MODULE", &type_obj_module, pr.far_data,
st_static);
sc_static);
symtab_addsymbol (current_symtab, module_sym);
module = &D_STRUCT (pr_module_t, module_sym->s.def);
module->size = type_size (&type_obj_module);
@ -1119,7 +1119,7 @@ class_finish_module (void)
&type_obj_exec_class);
exec_class_sym = function_symbol (exec_class_sym, 0, 1);
make_function (exec_class_sym, 0, exec_class_sym->table->space,
st_extern);
sc_extern);
}
init_sym = new_symbol_type (".ctor", &type_function);
@ -1133,7 +1133,7 @@ class_finish_module (void)
0, 0)));
save_storage = current_storage;
current_storage = st_static;
current_storage = sc_static;
current_func = begin_function (init_sym, 0, current_symtab, 1);
build_code_function (init_sym, 0, init_expr);;
current_func = 0;
@ -1184,7 +1184,7 @@ def_t *
protocol_def (protocol_t *protocol)
{
return make_symbol (protocol->name, &type_obj_protocol,
pr.far_data, st_static)->s.def;
pr.far_data, sc_static)->s.def;
}
protocollist_t *
@ -1221,7 +1221,7 @@ emit_protocol (protocol_t *protocol)
defspace_t *space;
proto_def = make_symbol (va ("_OBJ_PROTOCOL_%s", protocol->name),
&type_obj_protocol, pr.far_data, st_static)->s.def;
&type_obj_protocol, pr.far_data, sc_static)->s.def;
if (proto_def->initialized)
return proto_def;
proto_def->initialized = proto_def->constant = 1;
@ -1263,7 +1263,7 @@ emit_protocol_list (protocollist_t *protocols, const char *name)
proto_list_type = make_structure (0, 's', proto_list_struct, 0)->type;
proto_list_def = make_symbol (va ("_OBJ_PROTOCOLS_%s", name),
proto_list_type,
pr.far_data, st_static)->s.def;
pr.far_data, sc_static)->s.def;
proto_list_def->initialized = proto_list_def->constant = 1;
proto_list_def->nosave = 1;
space = proto_list_def->space;

View file

@ -65,34 +65,34 @@ static void
set_storage_bits (def_t *def, storage_class_t storage)
{
switch (storage) {
case st_system:
case sc_system:
def->system = 1;
// fall through
case st_global:
case sc_global:
def->global = 1;
def->external = 0;
def->local = 0;
def->param = 0;
break;
case st_extern:
case sc_extern:
def->global = 1;
def->external = 1;
def->local = 0;
def->param = 0;
break;
case st_static:
case sc_static:
def->external = 0;
def->global = 0;
def->local = 0;
def->param = 0;
break;
case st_local:
case sc_local:
def->external = 0;
def->global = 0;
def->local = 1;
def->param = 0;
break;
case st_param:
case sc_param:
def->external = 0;
def->global = 0;
def->local = 1;
@ -129,10 +129,10 @@ new_def (const char *name, type_t *type, defspace_t *space,
if (!type)
return def;
if (!space && storage != st_extern)
if (!space && storage != sc_extern)
internal_error (0, "non-external def with no storage space");
if (storage != st_extern) {
if (storage != sc_extern) {
int size = type_size (type);
if (!size) {
error (0, "%s has incomplete type", name);
@ -186,7 +186,7 @@ temp_def (etype_t type, int size)
temp->type = ev_types[type];
temp->file = pr.source_file;
temp->line = pr.source_line;
set_storage_bits (temp, st_local);
set_storage_bits (temp, sc_local);
temp->space = space;
return temp;
}
@ -420,7 +420,7 @@ init_field_def (def_t *def, expr_t *init, storage_class_t storage)
field_def = field_sym->s.def;
if (!field_sym->table)
symtab_addsymbol (pr.entity_fields, field_sym);
if (storage != st_extern) {
if (storage != sc_extern) {
D_INT (def) = field_def->offset;
reloc_def_field (field_def, def);
def->constant = 1;
@ -459,7 +459,7 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
// is var and same type
if (!check->s.def)
internal_error (0, "half defined var");
if (storage == st_extern) {
if (storage == sc_extern) {
if (init)
warning (0, "initializing external variable");
return;
@ -474,7 +474,7 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
sym->type = type;
if (!sym->table)
symtab_addsymbol (current_symtab, sym);
// if (storage == st_global && init && is_scalar (type)) {
// if (storage == sc_global && init && is_scalar (type)) {
// sym->sy_type = sy_const;
// memset (&sym->s.value, 0, sizeof (&sym->s.value));
// if (init->type != ex_value) { //FIXME arrays/structs
@ -497,9 +497,9 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
}
if (type == &type_vector && options.code.vector_components)
init_vector_components (sym, 0);
if (type->type == ev_field && storage != st_local && storage != st_param)
if (type->type == ev_field && storage != sc_local && storage != sc_param)
init_field_def (sym->s.def, init, storage);
if (storage == st_extern) {
if (storage == sc_extern) {
if (init)
warning (0, "initializing external variable");
return;

View file

@ -66,7 +66,7 @@ get_value_def (ex_value_t *value, etype_t type)
def_t *def;
if (type == ev_short) {
def = new_def (0, &type_short, 0, st_extern);
def = new_def (0, &type_short, 0, sc_extern);
def->offset = value->v.short_val;
return def;
}

View file

@ -844,7 +844,7 @@ new_self_expr (void)
{
symbol_t *sym;
sym = make_symbol (".self", &type_entity, pr.near_data, st_extern);
sym = make_symbol (".self", &type_entity, pr.near_data, sc_extern);
if (!sym->table)
symtab_addsymbol (pr.symtab, sym);
return new_symbol_expr (sym);
@ -855,7 +855,7 @@ new_this_expr (void)
{
symbol_t *sym;
sym = make_symbol (".this", field_type (&type_id), pr.near_data, st_extern);
sym = make_symbol (".this", field_type (&type_id), pr.near_data, sc_extern);
if (!sym->table)
symtab_addsymbol (pr.symtab, sym);
return new_symbol_expr (sym);
@ -881,7 +881,7 @@ param_expr (const char *name, type_t *type)
symbol_t *sym;
expr_t *sym_expr;
sym = make_symbol (name, &type_param, pr.symtab->space, st_extern);
sym = make_symbol (name, &type_param, pr.symtab->space, sc_extern);
if (!sym->table)
symtab_addsymbol (pr.symtab, sym);
sym_expr = new_symbol_expr (sym);
@ -2702,12 +2702,12 @@ selector_expr (keywordarg_t *selector)
index = selector_index (sel_id->str);
index *= type_size (type_SEL.t.fldptr.type);
sel_sym = make_symbol ("_OBJ_SELECTOR_TABLE_PTR", &type_SEL,
pr.near_data, st_static);
pr.near_data, sc_static);
if (!sel_sym->table) {
symtab_addsymbol (pr.symtab, sel_sym);
sel_table = make_symbol ("_OBJ_SELECTOR_TABLE",
array_type (type_SEL.t.fldptr.type, 0),
pr.far_data, st_extern);
pr.far_data, sc_extern);
if (!sel_table->table)
symtab_addsymbol (pr.symtab, sel_table);
reloc_def_def (sel_table->s.def, sel_sym->s.def);
@ -2758,7 +2758,7 @@ super_expr (class_type_t *class_type)
if (!sym || sym->table != current_symtab) {
sym = new_symbol (".super");
initialize_def (sym, &type_obj_super, 0, current_symtab->space,
st_local);
sc_local);
}
super = new_symbol_expr (sym);

View file

@ -305,7 +305,7 @@ static symbol_t *
param_symbol (const char *name)
{
symbol_t *sym;
sym = make_symbol (name, &type_param, pr.symtab->space, st_extern);
sym = make_symbol (name, &type_param, pr.symtab->space, sc_extern);
if (!sym->table)
symtab_addsymbol (pr.symtab, sym);
return sym;

View file

@ -456,7 +456,7 @@ build_scope (symbol_t *fsym, symtab_t *parent)
if (fsym->type->t.func.num_params < 0) {
args = new_symbol_type (".args", &type_va_list);
initialize_def (args, args->type, 0, symtab->space, st_param);
initialize_def (args, args->type, 0, symtab->space, sc_param);
}
for (p = fsym->params, i = 0; p; p = p->next) {
@ -465,14 +465,14 @@ build_scope (symbol_t *fsym, symtab_t *parent)
if (!p->type)
continue; // non-param selector
param = new_symbol_type (p->name, p->type);
initialize_def (param, param->type, 0, symtab->space, st_param);
initialize_def (param, param->type, 0, symtab->space, sc_param);
i++;
}
if (args) {
while (i < MAX_PARMS) {
param = new_symbol_type (va (".par%d", i), &type_param);
initialize_def (param, &type_param, 0, symtab->space, st_param);
initialize_def (param, &type_param, 0, symtab->space, sc_param);
i++;
}
}
@ -499,14 +499,14 @@ make_function (symbol_t *sym, const char *nice_name, defspace_t *space,
reloc_t *relocs = 0;
if (sym->sy_type != sy_func)
internal_error (0, "%s is not a function", sym->name);
if (storage == st_extern && sym->s.func)
if (storage == sc_extern && sym->s.func)
return;
if (!sym->s.func) {
sym->s.func = new_function (sym->name, nice_name);
sym->s.func->sym = sym;
}
if (sym->s.func->def && sym->s.func->def->external
&& storage != st_extern) {
&& storage != sc_extern) {
//FIXME this really is not the right way
relocs = sym->s.func->def->relocs;
free_def (sym->s.func->def);

View file

@ -260,7 +260,7 @@ send_message (int super)
current_symtab = pr.symtab;
sym = new_symbol_type (sm_name, sm_type);
sym = function_symbol (sym, 0, 1);
make_function (sym, 0, sym->table->space, st_extern);
make_function (sym, 0, sym->table->space, sc_extern);
current_symtab = save;
}
return new_symbol_expr (sym);
@ -387,7 +387,7 @@ emit_selectors (void)
sel_type = array_type (type_SEL.t.fldptr.type, sel_index);
sel_sym = make_symbol ("_OBJ_SELECTOR_TABLE", sel_type,
pr.far_data, st_static);
pr.far_data, sc_static);
if (!sel_sym->table)
symtab_addsymbol (pr.symtab, sel_sym);
sel_def = sel_sym->s.def;
@ -489,7 +489,7 @@ emit_methods (methodlist_t *methods, const char *name, int instance)
methods_struct[2].type = array_type (&type_obj_method, count);
return emit_structure (va ("_OBJ_%s_METHODS_%s", type, name), 's',
methods_struct, 0, methods, st_static);
methods_struct, 0, methods, sc_static);
}
static void
@ -556,7 +556,7 @@ emit_method_descriptions (methodlist_t *methods, const char *name,
method_list_struct[1].type = array_type (&type_obj_method_description,
count);
return emit_structure (va ("_OBJ_%s_METHODS_%s", type, name), 's',
method_list_struct, 0, methods, st_static);
method_list_struct, 0, methods, sc_static);
}
void

View file

@ -84,7 +84,7 @@ qfo_new_encoding (type_t *type, int size)
size += sizeof (qfot_type_t) - sizeof (enc->t);
size /= sizeof (pr_type_t);
def = new_def (type->encoding, 0, pr.type_data, st_static);
def = new_def (type->encoding, 0, pr.type_data, sc_static);
def->offset = defspace_alloc_loc (pr.type_data, size);
enc = D_POINTER (qfot_type_t, def);
@ -176,7 +176,7 @@ qfo_encode_struct (type_t *type)
if (type->meta == ty_enum)
sy = sy_const;
if (!type->t.symtab) {
def = new_def (type->encoding, 0, pr.type_data, st_extern);
def = new_def (type->encoding, 0, pr.type_data, sc_extern);
return def;
}
for (num_fields = 0, sym = type->t.symtab->symbols; sym; sym = sym->next) {

View file

@ -333,7 +333,7 @@ function_body
$<symtab>$ = current_symtab;
current_func = begin_function ($<symbol>2, 0, current_symtab, 0);
current_symtab = current_func->symtab;
current_storage = st_local;
current_storage = sc_local;
}
compound_statement
{
@ -413,10 +413,10 @@ external_decl
;
storage_class
: EXTERN { $$ = make_spec (0, st_extern, 0, 0); }
| STATIC { $$ = make_spec (0, st_static, 0, 0); }
| SYSTEM { $$ = make_spec (0, st_system, 0, 0); }
| TYPEDEF { $$ = make_spec (0, st_global, 1, 0); }
: EXTERN { $$ = make_spec (0, sc_extern, 0, 0); }
| STATIC { $$ = make_spec (0, sc_static, 0, 0); }
| SYSTEM { $$ = make_spec (0, sc_system, 0, 0); }
| TYPEDEF { $$ = make_spec (0, sc_global, 1, 0); }
| OVERLOAD { $$ = make_spec (0, current_storage, 0, 1); }
;
@ -939,7 +939,7 @@ code_func
$<symtab>$ = current_symtab;
current_func = begin_function ($<symbol>0, 0, current_symtab, 0);
current_symtab = current_func->symtab;
current_storage = st_local;
current_storage = sc_local;
}
compound_statement
{
@ -1034,7 +1034,7 @@ local_def
: local_specifiers
{
if (!$1.storage)
$1.storage = st_local;
$1.storage = sc_local;
$<spec>$ = $1;
local_expr = new_block_expr ();
}
@ -1614,7 +1614,7 @@ methoddef
method->func = sym->s.func;
method->def = sym->s.func->def;
current_symtab = current_func->symtab;
current_storage = st_local;
current_storage = sc_local;
}
compound_statement
{

View file

@ -239,7 +239,7 @@ subprogram_declaration
$<storage>$ = current_storage;
current_func = begin_function ($1, 0, current_symtab, 0);
current_symtab = current_func->symtab;
current_storage = st_local;
current_storage = sc_local;
}
declarations compound_statement ';'
{

View file

@ -44,7 +44,7 @@ function_t *current_func;
class_type_t *current_class;
expr_t *local_expr;
vis_t current_visibility;
storage_class_t current_storage = st_global;
storage_class_t current_storage = sc_global;
symtab_t *current_symtab;
/* When defining a new symbol, already existing symbols must be in a

View file

@ -1484,7 +1484,7 @@ check_final_block (sblock_t *sblock)
warning (0, "control reaches end of non-void function");
if (options.traditional || options.code.progsversion == PROG_ID_VERSION) {
return_symbol = make_symbol (".return", &type_param, pr.symtab->space,
st_extern);
sc_extern);
return_opcode = "<RETURN>";
}
if (return_symbol) {

View file

@ -281,7 +281,7 @@ emit_structure (const char *name, int su, struct_def_t *defs, type_t *type,
}
if (defs[i].name)
internal_error (0, "structure %s too many defs", name);
if (storage != st_global && storage != st_static)
if (storage != sc_global && storage != sc_static)
internal_error (0, "structure %s must be global or static", name);
struct_sym = make_symbol (name, type, pr.far_data, storage);

View file

@ -343,7 +343,7 @@ build_switch (expr_t *sw, case_node_t *tree, int op, expr_t *sw_val,
}
table_sym = new_symbol (table_name);
initialize_def (table_sym, array_type (&type_integer, high - low + 1),
table_init, pr.near_data, st_static);
table_init, pr.near_data, sc_static);
table_expr = new_symbol_expr (table_sym);
table_expr = new_alias_expr (&type_integer, table_expr);

View file

@ -189,9 +189,9 @@ make_symbol (const char *name, type_t *type, defspace_t *space,
symbol_t *sym;
struct reloc_s *relocs = 0;
if (storage != st_extern && storage != st_global && storage != st_static)
if (storage != sc_extern && storage != sc_global && storage != sc_static)
internal_error (0, "invalid storage class for %s", __FUNCTION__);
if (storage != st_extern && !space)
if (storage != sc_extern && !space)
internal_error (0, "null space for non-external storage");
sym = symtab_lookup (pr.symtab, name);
if (!sym) {
@ -206,7 +206,7 @@ make_symbol (const char *name, type_t *type, defspace_t *space,
sym = new_symbol_type (name, type);
}
}
if (sym->s.def && sym->s.def->external && storage != st_extern) {
if (sym->s.def && sym->s.def->external && storage != sc_extern) {
//FIXME this really is not the right way
relocs = sym->s.def->relocs;
free_def (sym->s.def);

View file

@ -481,7 +481,7 @@ emit_value (ex_value_t *value, def_t *def)
imm = 0; //FIXME do full def aliasing
} else {
symbol_t *sym;
sym = make_symbol (".zero", &type_zero, 0, st_extern);
sym = make_symbol (".zero", &type_zero, 0, sc_extern);
return sym->s.def;
}
}
@ -496,7 +496,7 @@ emit_value (ex_value_t *value, def_t *def)
cn = def;
} else {
if (cn->type != type) {
def = new_def (".imm", type, pr.near_data, st_static);
def = new_def (".imm", type, pr.near_data, sc_static);
def->offset = cn->offset;
cn = def;
}
@ -507,13 +507,13 @@ emit_value (ex_value_t *value, def_t *def)
// always share immediates
if (def) {
if (def->type != type) {
cn = new_def (".imm", type, pr.near_data, st_static);
cn = new_def (".imm", type, pr.near_data, sc_static);
cn->offset = def->offset;
} else {
cn = def;
}
} else {
cn = new_def (".imm", type, pr.near_data, st_static);
cn = new_def (".imm", type, pr.near_data, sc_static);
}
cn->initialized = cn->constant = 1;
cn->nosave = 1;
@ -603,7 +603,7 @@ clear_immediates (void)
Hash_SetHashCompare (integer_imm_defs, imm_get_hash, imm_compare);
}
def = make_symbol (".zero", &type_zero, 0, st_extern)->s.def;
def = make_symbol (".zero", &type_zero, 0, sc_extern)->s.def;
make_def_imm (def, string_imm_defs);
make_def_imm (def, float_imm_defs);