Delay initialization of obj_module_t as long as possible.

This keeps the type descriptor out of progs that never use any
Objective-QC features.
This commit is contained in:
Bill Currie 2011-03-04 08:25:50 +09:00
parent c99f3aba0e
commit 4192ef835c
4 changed files with 24 additions and 18 deletions

View file

@ -113,7 +113,6 @@ class_t *extract_class (class_type_t *class_type);
const char *get_class_name (class_type_t *class_type, int pretty);
struct symbol_s *class_symbol (class_type_t *class_type, int external);
void class_init (void);
void class_init_obj_module (void);
class_t *get_class (struct symbol_s *sym, int create);
void class_add_methods (class_t *class, struct methodlist_s *methods);
void class_add_protocols (class_t *class, protocollist_t *protocols);

View file

@ -267,16 +267,7 @@ init_classes (void)
chain_type (&type_id);
}
void
class_init (void)
{
if (!current_symtab)
current_symtab = pr.symtab;
init_classes ();
init_objective_structs ();
}
void
static void
class_init_obj_module (void)
{
symbol_t *sym;
@ -292,6 +283,16 @@ class_init_obj_module (void)
symtab_addsymbol (pr.symtab, sym);
}
void
class_init (void)
{
if (!current_symtab)
current_symtab = pr.symtab;
class_init_obj_module ();
init_classes ();
init_objective_structs ();
}
symbol_t *
class_symbol (class_type_t *class_type, int external)
{

View file

@ -299,6 +299,11 @@ static keyword_t keywords[] = {
{"enum", ENUM, 0, 0, PROG_ID_VERSION, 0},
{"typedef", TYPEDEF, 0, 0, PROG_ID_VERSION, 0},
// these two are a hack to trigger the initialization of the class
// sytem if they are seen before any other Objective-QC symbol
{"obj_module_s", 0, 0, 0, PROG_VERSION, 1},
{"obj_module_t", 0, 0, 0, PROG_VERSION, 1},
{"@class", CLASS, 0, 0, PROG_VERSION, 1},
{"@defs", DEFS, 0, 0, PROG_VERSION, 1},
{"@encode", ENCODE, 0, 0, PROG_VERSION, 1},
@ -348,13 +353,15 @@ keyword_or_id (char *token)
if (keyword) {
if (!options.traditional && keyword->objc && !class_Class.super_class)
class_init ();
if (keyword->value == STRUCT) {
yylval.op = token[0];
} else {
yylval.type = 0;
yylval.type = keyword->type;
if (keyword->value) {
if (keyword->value == STRUCT) {
yylval.op = token[0];
} else {
yylval.type = 0;
yylval.type = keyword->type;
}
return keyword->value;
}
return keyword->value;
}
if (token[0] == '@') {
return '@';

View file

@ -864,7 +864,6 @@ chain_initial_types (void)
chain_type (&type_quaternion);
chain_type (&type_integer);
chain_type (&type_short);
class_init_obj_module ();
}
chain_type (&type_param);