summaryrefslogtreecommitdiff
path: root/c/libdietc.l
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2023-07-31 13:53:16 -0700
committerMatthew Sotoudeh <matthew@masot.net>2023-07-31 13:53:16 -0700
commit86f852cd76cf92a4b08b59b127cc954420f95744 (patch)
tree459eb4b2d7e587a036dd10f1c4c9bc757346e0bd /c/libdietc.l
parent135b17bada960c4585d5a124fedb7e4e9d849078 (diff)
share more code between the C examplesHEADmaster
Diffstat (limited to 'c/libdietc.l')
-rw-r--r--c/libdietc.l20
1 files changed, 20 insertions, 0 deletions
diff --git a/c/libdietc.l b/c/libdietc.l
index 51c8e91..abdb914 100644
--- a/c/libdietc.l
+++ b/c/libdietc.l
@@ -280,3 +280,23 @@ struct type *libdietc_lhs_type(struct program program, struct instruction *instr
name = libdietc_tokdup(libdietc_nth_token(instruction->line, 0));
return libdietc_object_type(program, name);
}
+
+struct instruction *libdietc_insert_before(struct instruction *i, char *line) {
+ struct instruction *new = calloc(1, sizeof(*new));
+ *(i->pprev) = new;
+ new->pprev = i->pprev;
+ new->line = line;
+ new->next = i;
+ i->pprev = &(new->next);
+ return new;
+}
+
+struct instruction *libdietc_insert_after(struct instruction *i, char *line) {
+ struct instruction *new = calloc(1, sizeof(*new));
+ new->line = line;
+ new->next = i->next;
+ i->next->pprev = &(new->next);
+ new->pprev = &(i->next);
+ i->next = new;
+ return new;
+}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback