From a1fe5efd271e8f0fd173308a925c0f33d30576c9 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 22 May 2002 01:39:07 +0000 Subject: [PATCH] initialize class_Class.super_class iff @keywords are seen (ie, compiling obj code). --- tools/qfcc/include/class.h | 1 + tools/qfcc/source/class.c | 6 ++++++ tools/qfcc/source/qc-lex.l | 3 +++ tools/qfcc/source/type.c | 1 - 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/include/class.h b/tools/qfcc/include/class.h index 2134fd62f..d04e1fd4e 100644 --- a/tools/qfcc/include/class.h +++ b/tools/qfcc/include/class.h @@ -55,6 +55,7 @@ struct method_s; struct protocol_s; struct type_s; +void class_init (void); class_t *get_class (const char *name, int create); void class_add_methods (class_t *class, struct methodlist_s *methods); void class_add_protocol_methods (class_t *class, expr_t *protocols); diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index e15b648e7..31ef7386b 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -63,6 +63,12 @@ protocol_get_key (void *protocol, void *unused) return ((protocol_t *) protocol)->name; } +void +class_init (void) +{ + class_Class.super_class = get_class ("Object", 1); +} + class_t * get_class (const char *name, int create) { diff --git a/tools/qfcc/source/qc-lex.l b/tools/qfcc/source/qc-lex.l index 83a6001df..0a7528067 100644 --- a/tools/qfcc/source/qc-lex.l +++ b/tools/qfcc/source/qc-lex.l @@ -34,6 +34,7 @@ static const char rcsid[] = #include #include #include "qfcc.h" +#include "class.h" #include "struct.h" #include "type.h" #include "qc-parse.h" @@ -302,6 +303,8 @@ type_or_name (char *token) } keyword = Hash_Find (keyword_tab, token); if (keyword) { + if (token[0] == '@' && !class_Class.super_class) + class_init (); yylval.type = keyword->type; return keyword->value; } diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index b25381214..f0683b942 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -433,7 +433,6 @@ init_types (void) type = type_Class.aux_type = new_struct (0); type->type = ev_class; type->class = &class_Class; - class_Class.super_class = get_class ("Object", 1); //FIXME evil hack class_Class.ivars = type_Class.aux_type; new_struct_field (type, &type_Class, "class_pointer", vis_public); new_struct_field (type, &type_Class, "super_class", vis_public);