From 2157fdbaca0b80e488c4f77ad5c0d04b051175cf Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 12 Aug 2024 18:55:46 +0300 Subject: make defer work better with generic code --- src/ast.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/ast.c') diff --git a/src/ast.c b/src/ast.c index 890196b..c36d7a7 100644 --- a/src/ast.c +++ b/src/ast.c @@ -753,3 +753,30 @@ size_t type_offsetof(struct type *t, char *m) return offset; } + +struct ast *reverse_ast_list(struct ast *root) +{ + struct ast *new_root = NULL; + while (root) { + struct ast *next = root->n; + root->n = new_root; + new_root = root; + root = next; + } + + return new_root; +} + +struct type *reverse_type_list(struct type *root) +{ + struct type *new_root = NULL; + while (root) { + struct type *next = root->n; + root->n = new_root; + new_root = root; + root = next; + } + + return new_root; +} + -- cgit v1.3