diff options
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; +} |