diff --git a/tools/qfcc/include/expr.h b/tools/qfcc/include/expr.h index 908eb557a..d1458b8a1 100644 --- a/tools/qfcc/include/expr.h +++ b/tools/qfcc/include/expr.h @@ -81,6 +81,7 @@ typedef struct { int val; struct type_s *type; int abs; + struct def_s *def; } ex_pointer_t; typedef struct expr_s { diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index 4e29ca58e..8a8a9e616 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -206,8 +206,9 @@ class_begin (class_t *class) class->def->initialized = class->def->constant = 1; cls = &G_STRUCT (pr_class_t, class->def->ofs); EMIT_DEF (cls->class_pointer, meta_def); - cls->super_class = meta->super_class; - cls->name = meta->name; + if (class->super_class) + EMIT_STRING (cls->super_class, class->super_class->class_name); + EMIT_STRING (cls->name, class->class_name); meta->info = _PR_CLS_CLASS; cls->protocols = meta->protocols; } diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 94cc622a9..29d4bfe7c 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -1856,30 +1856,34 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t) switch (e1->type) { case ex_def: - type = e1->e.def->type; - if (type->type == ev_struct) { - int abs = e1->e.def->global; + { def_t *def = e1->e.def; + type = def->type; + if (type->type == ev_struct) { + int abs = e1->e.def->global; + def_t *def = e1->e.def; - e = e1; - e->type = ex_pointer; - e->e.pointer.val = def->ofs; - e->e.pointer.type = t; - e->e.pointer.abs = abs; - } else if (type->type == ev_array) { - int abs = e1->e.def->global; - def_t *def = e1->e.def; + e = e1; + e->type = ex_pointer; + e->e.pointer.val = def->ofs; + e->e.pointer.type = t; + e->e.pointer.abs = abs; + } else if (type->type == ev_array) { + int abs = e1->e.def->global; + def_t *def = e1->e.def; - e = e1; - e->type = ex_pointer; - e->e.pointer.val = def->ofs; - e->e.pointer.type = t; - e->e.pointer.abs = abs; - } else { - e = new_unary_expr ('&', e1); - e->e.expr.type = pointer_type (type); + e = e1; + e->type = ex_pointer; + e->e.pointer.val = def->ofs; + e->e.pointer.type = t; + e->e.pointer.abs = abs; + } else { + e = new_unary_expr ('&', e1); + e->e.expr.type = pointer_type (type); + } + e->e.pointer.def = def; + break; } - break; case ex_expr: if (e1->e.expr.op == '.') { e = e1; diff --git a/tools/qfcc/source/immediate.c b/tools/qfcc/source/immediate.c index 0942a4f7c..86199819a 100644 --- a/tools/qfcc/source/immediate.c +++ b/tools/qfcc/source/immediate.c @@ -36,6 +36,7 @@ static const char rcsid[] = #include "qfcc.h" #include "def.h" +#include "emit.h" #include "expr.h" #include "immediate.h" #include "reloc.h" @@ -228,6 +229,10 @@ ReuseConstant (expr_t *expr, def_t *def) case ex_func: reloc = new_reloc (cn->ofs, rel_def_func); break; + case ex_pointer: + if (e.e.pointer.def) + EMIT_DEF (G_INT (cn->ofs), e.e.pointer.def); + break; default: break; } diff --git a/tools/qfcc/source/qfodump.c b/tools/qfcc/source/qfodump.c index c86135061..b36a9b1eb 100644 --- a/tools/qfcc/source/qfodump.c +++ b/tools/qfcc/source/qfodump.c @@ -94,7 +94,7 @@ dump_defs (qfo_t *qfo) // qfo->strings + qfo->data[def->ofs].string_var); } else if (def->basic_type == ev_func) { printf (" %4d %s\n", qfo->data[def->ofs].func_var, - qfo->strings + qfo->functions[qfo->data[def->ofs].func_var].name); + qfo->strings + qfo->functions[qfo->data[def->ofs].func_var - 1].name); } else { // printf (" %4d\n", qfo->data[def->ofs].integer_var); }