From 64cf07351f89722a1f11626909fb18f17a6ade6a Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 22 Feb 2011 13:36:16 +0900 Subject: [PATCH] Encode types to string and qfo representation on creation. --- tools/qfcc/source/obj_type.c | 8 ++++++++ tools/qfcc/source/qfcc.c | 2 ++ tools/qfcc/source/type.c | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/tools/qfcc/source/obj_type.c b/tools/qfcc/source/obj_type.c index b4bcc709b..0414c61bf 100644 --- a/tools/qfcc/source/obj_type.c +++ b/tools/qfcc/source/obj_type.c @@ -174,6 +174,10 @@ qfo_encode_struct (type_t *type) sy = sy_var; if (type->ty == ty_enum) sy = sy_const; + if (!type->t.symtab) { + def = new_def (type->encoding, 0, pr.type_data, st_extern); + return def; + } for (num_fields = 0, sym = type->t.symtab->symbols; sym; sym = sym->next) { if (sym->sy_type != sy) continue; @@ -253,6 +257,10 @@ qfo_encode_type (type_t *type) qfo_encode_class, // ty_class }; + if (type->type_def && type->type_def->external) { + free_def (type->type_def); + type->type_def = 0; + } if (type->type_def) return type->type_def; if (type->ty < 0 || type->ty > ty_class) diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index 0eb6ca065..a8d1c4f4c 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -145,6 +145,8 @@ InitData (void) pr.near_data->max_size = 65536; pr.near_data->grow = 0; + pr.type_data = new_defspace (); + pr.symtab = new_symtab (0, stab_global); pr.symtab->space = pr.near_data; diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index 8049c7493..54d2609f7 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -53,6 +53,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "diagnostic.h" #include "expr.h" #include "function.h" +#include "obj_type.h" #include "options.h" #include "qfcc.h" #include "strpool.h" @@ -116,6 +117,18 @@ chain_type (type_t *type) { type->next = pr.types; pr.types = type; + if (!type->encoding) { + static dstring_t *encoding; + + if (!encoding) + encoding = dstring_newstr(); + else + dstring_clearstr (encoding); + encode_type (encoding, type); + type->encoding = save_string (encoding->str); + } + if (!type->type_def) + type->type_def = qfo_encode_type (type); } type_t *