~sircmpwn/hare-dev

harec: gen: don't reinvent mkgtemp v1 APPLIED

Bor Grošelj Simić: 1
 gen: don't reinvent mkgtemp

 1 files changed, 5 insertions(+), 24 deletions(-)
#1061644 alpine.yml success
#1061645 freebsd.yml success
#1061646 netbsd.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/44958/mbox | git am -3
Learn more about email & git

[PATCH harec] gen: don't reinvent mkgtemp Export this patch

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
---
 src/gen.c | 29 +++++------------------------
 1 file changed, 5 insertions(+), 24 deletions(-)

diff --git a/src/gen.c b/src/gen.c
index 03ea6f7..daca666 100644
--- a/src/gen.c
+++ b/src/gen.c
@@ -162,11 +162,7 @@ gen_load(struct gen_context *ctx, struct gen_value object)
		break; // no-op
	}

	struct gen_value value = {
		.kind = GV_TEMP,
		.type = object.type,
		.name = gen_name(&ctx->id, "load.%d"),
	};
	struct gen_value value = mkgtemp(ctx, object.type, "load.%d");
	struct qbe_value qobj = mkqval(ctx, &object),
		qval = mkqval(ctx, &value);
	enum qbe_instr qi = load_for_type(ctx, object.type);
@@ -997,12 +993,7 @@ gen_expr_binding_unpack(struct gen_context *ctx,
	assert(binding->object == NULL);

	const struct type *type = binding->initializer->result;
	char *tuple_name = gen_name(&ctx->id, "tupleunpack.%d");
	struct gen_value tuple_gv = {
		.kind = GV_TEMP,
		.type = type,
		.name = tuple_name,
	};
	struct gen_value tuple_gv = mkgtemp(ctx, type, "tupleunpack.%d");
	struct qbe_value tuple_qv = mklval(ctx, &tuple_gv);
	struct qbe_value sz = constl(type->size);
	enum qbe_instr alloc = alloc_for_align(type->align);
@@ -1017,14 +1008,8 @@ gen_expr_binding_unpack(struct gen_context *ctx,
		}
		assert(unpack->object->otype != O_DECL);

		const struct type *type = unpack->object->type;
		struct gen_value item_gv = {
			.kind = GV_TEMP,
			.type = type,
			.name = gen_name(&ctx->id, "binding.%d"),
		};
		struct gen_binding *gb = xcalloc(1, sizeof(struct gen_binding));
		gb->value = item_gv;
		gb->value = mkgtemp(ctx, unpack->object->type, "binding.%d");
		gb->object = unpack->object;
		gb->next = ctx->bindings;
		ctx->bindings = gb;
@@ -1064,9 +1049,7 @@ gen_expr_binding(struct gen_context *ctx, const struct expression *expr)

		const struct type *type = binding->object->type;
		struct gen_binding *gb = xcalloc(1, sizeof(struct gen_binding));
		gb->value.kind = GV_TEMP;
		gb->value.type = type;
		gb->value.name = gen_name(&ctx->id, "binding.%d");
		gb->value = mkgtemp(ctx, type, "binding.%d");
		gb->object = binding->object;
		gb->next = ctx->bindings;
		ctx->bindings = gb;
@@ -2519,9 +2502,7 @@ gen_match_with_tagged(struct gen_context *ctx,
		}

		struct gen_binding *gb = xcalloc(1, sizeof(struct gen_binding));
		gb->value.kind = GV_TEMP;
		gb->value.type = _case->type;
		gb->value.name = gen_name(&ctx->id, "binding.%d");
		gb->value = mkgtemp(ctx, _case->type, "binding.%d");
		gb->object = _case->object;
		gb->next = ctx->bindings;
		ctx->bindings = gb;
-- 
2.38.4
harec/patches: SUCCESS in 58s

[gen: don't reinvent mkgtemp][0] from [Bor Grošelj Simić][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/44958
[1]: mailto:bgs@turminal.net

✓ #1061644 SUCCESS harec/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/1061644
✓ #1061646 SUCCESS harec/patches/netbsd.yml  https://builds.sr.ht/~sircmpwn/job/1061646
✓ #1061645 SUCCESS harec/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/1061645
thanks!

to git@git.sr.ht:~sircmpwn/harec
  6151bd6..a3687cb  master -> master