aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-08-12 18:55:46 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-08-12 19:06:03 +0300
commit2157fdbaca0b80e488c4f77ad5c0d04b051175cf (patch)
tree6a6ba7be30b2eb32219cd9aa2eb30c3bddacd5b4 /src/ast.c
parentce6ba9e8d260e43d11518688363229755a212472 (diff)
downloadek-2157fdbaca0b80e488c4f77ad5c0d04b051175cf.tar.gz
ek-2157fdbaca0b80e488c4f77ad5c0d04b051175cf.zip
make defer work better with generic code
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c27
1 files changed, 27 insertions, 0 deletions
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;
+}
+