harec

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

commit b6a0bfc8edb169b9cadd4f705768ca7c2d7080af
parent a73da60c8112a5aea0931288b611bf7e76a6f917
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 14 Mar 2021 10:48:41 -0400

gen: run defers in reverse order

Diffstat:
Minclude/gen.h | 2+-
Msrc/gen.c | 5++---
2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/gen.h b/include/gen.h @@ -39,7 +39,7 @@ struct gen_scope_context { enum scope_class class; struct qbe_value *after; struct qbe_value *end; - struct gen_deferred *defers, **next_defer; + struct gen_deferred *defers; struct gen_scope_context *parent; }; diff --git a/src/gen.c b/src/gen.c @@ -28,7 +28,6 @@ push_scope(struct gen_context *ctx, scope->class = class; scope->end = end; scope->parent = ctx->scope; - scope->next_defer = &scope->defers; ctx->scope = scope; return scope; } @@ -1630,8 +1629,8 @@ gen_expr_defer(struct gen_context *ctx, { struct gen_deferred *d = xcalloc(1, sizeof(struct gen_deferred)); d->expr = expr->defer.deferred; - *ctx->scope->next_defer = d; - ctx->scope->next_defer = &d->next; + d->next = ctx->scope->defers; + ctx->scope->defers = d; } static void