diff --git a/ruamoko/game/World.r b/ruamoko/game/World.r index a0c2215d4..6d5bd0fc5 100644 --- a/ruamoko/game/World.r +++ b/ruamoko/game/World.r @@ -24,16 +24,16 @@ integer deathmatch; local integer i; self = [super init]; - self.head = NIL; + head = NIL; for (i = 0; i < MAX_BODIES; i++) { local GameEntity ent = NIL; ent = [[GameEntity alloc] init]; - self.bodies[i] = ent.ent; + bodies[i] = ent.ent; } #if 0 for (i = 0; i < MAX_BODIES; i++) { - self.bodies[i] = [[[GameEntity alloc] init] ent]; + bodies[i] = [[[GameEntity alloc] init] ent]; } #endif } diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index 938eca462..1fd71e377 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -137,17 +137,35 @@ get_class (const char *name, int create) return c; } +static void +set_self_type (class_t *class, method_t *method) +{ + if (method->instance) + method->params->type = class->type; + else + method->params->type = &type_Class; +} + +static void +methods_set_self_type (class_t *class, methodlist_t *methods) +{ + method_t *method; + + for (method = methods->head; method; method = method->next) + set_self_type (class, method); +} + void class_add_methods (class_t *class, methodlist_t *methods) { if (!methods) return; - if (!class->methods) - class->methods = new_methodlist (); *class->methods->tail = methods->head; class->methods->tail = methods->tail; free (methods); + + methods_set_self_type (class, class->methods); } void diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index c2a62bbaf..c4f9ebda4 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -284,6 +284,12 @@ type_mismatch (expr_t *e1, expr_t *e2, int op) t1 = extract_type (e1); t2 = extract_type (e2); + if (1) { + print_type (get_type (e1)); + print_type (get_type (e2)); + printf ("\n%p %p\n", get_type (e1), get_type (e2)); + } + return error (e1, "type mismatch: %s %s %s", pr_type_name[t1], get_op_string (op), pr_type_name[t2]); } diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index ad8fd3e00..b49c6e50b 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -1401,14 +1401,11 @@ methodproto : '+' methoddecl ';' { $2->instance = 0; - $2->params->type = &type_Class; $$ = $2; } | '-' methoddecl ';' { $2->instance = 1; - if ($-1) - $2->params->type = $-1->type; $$ = $2; } ; diff --git a/tools/qwaq/test.r b/tools/qwaq/test.r index 44b420ddd..5cab138f5 100644 --- a/tools/qwaq/test.r +++ b/tools/qwaq/test.r @@ -1,10 +1,25 @@ @interface Foo : Object +{ + integer x; +} -run; @end @implementation Foo ++alloc +{ + print ("+alloc\n"); + return class_create_instance (self); +} + +-init +{ + print ("-init\n"); + return [super init]; +} + + (void) initialize { print ("+initialize\n"); @@ -13,7 +28,7 @@ -run { print ("Hello world\n"); - printf ("%i\n", self); + printf ("%i %p\n", self, &self.x); } @end