diff options
author | Matthew Sotoudeh <matthew@masot.net> | 2023-07-31 13:53:16 -0700 |
---|---|---|
committer | Matthew Sotoudeh <matthew@masot.net> | 2023-07-31 13:53:16 -0700 |
commit | 86f852cd76cf92a4b08b59b127cc954420f95744 (patch) | |
tree | 459eb4b2d7e587a036dd10f1c4c9bc757346e0bd /c/libdietc.l | |
parent | 135b17bada960c4585d5a124fedb7e4e9d849078 (diff) |
Diffstat (limited to 'c/libdietc.l')
-rw-r--r-- | c/libdietc.l | 20 |
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; +} |