~sircmpwn/hare-dev

harec: gen: support tuples in gen_expr_const_at v2 APPLIED

Alexey Yerin: 1
 gen: support tuples in gen_expr_const_at

 1 files changed, 23 insertions(+), 0 deletions(-)
#843786 alpine.yml success
#843787 freebsd.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/hare-dev/patches/35273/mbox | git am -3
Learn more about email & git

[PATCH harec v2] gen: support tuples in gen_expr_const_at Export this patch

Fixes harec abort when using a def array of tuples.

Signed-off-by: Alexey Yerin <yyp@disroot.org>
---
v1 -> v2: rebase

 src/gen.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/gen.c b/src/gen.c
index 9fe70eb..c23a442 100644
--- a/src/gen.c
+++ b/src/gen.c
@@ -1883,6 +1883,26 @@ gen_const_tagged_at(struct gen_context *ctx,
	gen_expr_at(ctx, expr->constant.tagged.value, storage);
}

static void
gen_const_tuple_at(struct gen_context *ctx,
	const struct expression *expr, struct gen_value out)
{
	// TODO: Merge me into constant expressions
	struct qbe_value base = mkqval(ctx, &out);

	struct gen_value ftemp = mkgtemp(ctx, &builtin_type_void, "field.%d");
	for (const struct tuple_constant *field = expr->constant.tuple; field;
			field = field->next) {
		assert(field->value);

		struct qbe_value offs = constl(field->field->offset);
		ftemp.type = field->value->result;
		struct qbe_value ptr = mklval(ctx, &ftemp);
		pushi(ctx->current, &ptr, Q_ADD, &base, &offs, NULL);
		gen_expr_at(ctx, field->value, ftemp);
	}
}

static void
gen_expr_const_at(struct gen_context *ctx,
	const struct expression *expr, struct gen_value out)
@@ -1905,6 +1925,9 @@ gen_expr_const_at(struct gen_context *ctx,
	case STORAGE_TAGGED:
		gen_const_tagged_at(ctx, expr, out);
		break;
	case STORAGE_TUPLE:
		gen_const_tuple_at(ctx, expr, out);
		break;
	default:
		abort(); // Invariant
	}
-- 
2.37.3
harec/patches: SUCCESS in 53s

[gen: support tuples in gen_expr_const_at][0] v2 from [Alexey Yerin][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/35273
[1]: mailto:yyp@disroot.org

✓ #843787 SUCCESS harec/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/843787
✓ #843786 SUCCESS harec/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/843786
Could have used a test, but I'll take it. Thanks!

To git@git.sr.ht:~sircmpwn/harec
   825000c..dac4cd7  master -> master