harec

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

commit 87c475437271928914088800ee7f1af7804fc966
parent f74e171d7d9b9d40e53d996b0bf4388bdb6a3f5f
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 24 Feb 2021 15:30:17 -0500

gen: generate enum data items

Diffstat:
Msrc/gen.c | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/gen.c b/src/gen.c @@ -2744,6 +2744,36 @@ gen_data_item(struct gen_context *ctx, struct expression *expr, } break; case STORAGE_ENUM: + switch (type->_enum.storage) { + case STORAGE_I8: + case STORAGE_U8: + item->type = QD_VALUE; + constw(&item->value, (uint8_t)constant->uval); + item->value.type = &qbe_byte; + break; + case STORAGE_I16: + case STORAGE_U16: + item->type = QD_VALUE; + constw(&item->value, (uint16_t)constant->uval); + item->value.type = &qbe_half; + break; + case STORAGE_I32: + case STORAGE_U32: + case STORAGE_INT: + case STORAGE_UINT: + item->type = QD_VALUE; + constw(&item->value, (uint32_t)constant->uval); + break; + case STORAGE_U64: + case STORAGE_I64: + case STORAGE_SIZE: + item->type = QD_VALUE; + constl(&item->value, (uint32_t)constant->uval); + break; + default: + assert(0); + } + break; case STORAGE_TAGGED: case STORAGE_TUPLE: case STORAGE_UNION: