harec

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

commit 96204ef2eddcc9a41abf46acc2b75351d0876ed5
parent 716dad41aebc0dc43aaead5e091a811c2b7081f0
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 25 Jul 2021 09:55:57 +0200

gen: classify functions as non-aggregate

Since they have a (special-cased) first-class status in qbe.

Diffstat:
Msrc/genutil.c | 12++----------
Msrc/qtype.c | 4+++-
2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/genutil.c b/src/genutil.c @@ -45,16 +45,8 @@ void gen_direct(struct gen_context *ctx, struct gen_temp *temp, const struct type *type, const char *fmt) { - // Functions are a special case: the Hare type system (correctly) states - // that they have an undefined size and storage, but we can assign them - // to qbe temporaries as pointers (=l), so they are suitable for use as - // direct objects. - if (type_dealias(type)->storage != STORAGE_FUNCTION) { - assert(type->size != 0 && type->size != SIZE_UNDEFINED); - const struct qbe_type *qtype = qtype_lookup(ctx, type, false); - assert(qtype->stype != Q__AGGREGATE && qtype->stype != Q__VOID); - } - + assert(!type_is_aggregate(type)); + assert(type_dealias(type)->storage != STORAGE_VOID); temp->type = type; temp->name = gen_name(ctx, fmt); temp->indirect = false; diff --git a/src/qtype.c b/src/qtype.c @@ -195,6 +195,9 @@ type_is_aggregate(const struct type *type) case STORAGE_UINTPTR: case STORAGE_VOID: return false; + case STORAGE_FUNCTION: + // Special case + return false; case STORAGE_ALIAS: return type_is_aggregate(type->alias.type); case STORAGE_ARRAY: @@ -204,7 +207,6 @@ type_is_aggregate(const struct type *type) case STORAGE_TAGGED: case STORAGE_TUPLE: case STORAGE_UNION: - case STORAGE_FUNCTION: return true; case STORAGE_FCONST: case STORAGE_ICONST: