harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3db5d7265cfacbd57248655205996619dd1b79b6
parent 6f6bc722102a63f2e45e8ec4d36a061637083f92
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 11 Jan 2021 10:34:54 -0500

Initial type riggings for slices

Diffstat:
Msrc/qtype.c | 5++++-
Msrc/type_store.c | 23+++++++++++++++++------
2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/qtype.c b/src/qtype.c @@ -144,8 +144,11 @@ lookup_aggregate(struct gen_context *ctx, const struct type *type) } } break; - case TYPE_STORAGE_ENUM: case TYPE_STORAGE_SLICE: + field->type = &qbe_long; // XXX: ARCH + field->count = 3; + break; + case TYPE_STORAGE_ENUM: case TYPE_STORAGE_TAGGED_UNION: assert(0); // TODO case TYPE_STORAGE_ARRAY: diff --git a/src/type_store.c b/src/type_store.c @@ -309,10 +309,11 @@ type_hash(struct type_store *store, const struct type *type) assert(0); // TODO case TYPE_STORAGE_POINTER: hash = djb2(hash, type->pointer.flags); - hash = type_hash(store, type->pointer.referent); + hash = djb2(hash, type_hash(store, type->pointer.referent)); break; case TYPE_STORAGE_SLICE: - assert(0); // TODO + hash = djb2(hash, type_hash(store, type->array.members)); + break; case TYPE_STORAGE_STRUCT: case TYPE_STORAGE_UNION: for (const struct struct_field *field = type->struct_union.fields; @@ -408,7 +409,7 @@ type_eq_type(struct type_store *store, return a->pointer.flags == b->pointer.flags && type_eq_type(store, a->pointer.referent, b->pointer.referent); case TYPE_STORAGE_SLICE: - assert(0); // TODO + return type_eq_type(store, a->array.members, b->array.members); case TYPE_STORAGE_STRUCT: case TYPE_STORAGE_UNION: for (const struct struct_field *afield = a->struct_union.fields, @@ -578,7 +579,12 @@ type_init_from_atype(struct type_store *store, store, atype->pointer.referent); break; case TYPE_STORAGE_SLICE: - assert(0); // TODO + type->size = 24; // XXX: ARCH + type->align = 8; + type->array.members = type_store_lookup_atype( + store, atype->array.members); + type->array.length = SIZE_UNDEFINED; + break; case TYPE_STORAGE_STRUCT: type->struct_union.c_compat = true; // Fallthrough @@ -622,6 +628,7 @@ type_init_from_type(struct type_store *store, case TYPE_STORAGE_UINT: case TYPE_STORAGE_UINTPTR: case TYPE_STORAGE_VOID: + case TYPE_STORAGE_STRING: assert(0); // Invariant case TYPE_STORAGE_ALIAS: new->size = old->size; @@ -669,8 +676,12 @@ type_init_from_type(struct type_store *store, store, old->pointer.referent); break; case TYPE_STORAGE_SLICE: - case TYPE_STORAGE_STRING: - assert(0); // TODO + new->size = 24; // XXX: ARCH + new->align = 8; + new->array.members = type_store_lookup_type( + store, old->array.members); + new->array.length = SIZE_UNDEFINED; + break; case TYPE_STORAGE_STRUCT: case TYPE_STORAGE_UNION:; struct struct_field **next = &new->struct_union.fields;