Encode types to string and qfo representation on creation.

This commit is contained in:
Bill Currie 2011-02-22 13:36:16 +09:00
parent a07cd17f38
commit 64cf07351f
3 changed files with 23 additions and 0 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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 *