diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-05-09 02:56:07 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-06-21 01:15:38 +0200 |
| commit | b25ff71bb198c227b3202ee32a8067cda413bc16 (patch) | |
| tree | 41d665a87d948c10b17a853220cbcdbaeebf3672 /stmt.c | |
| download | prc-b25ff71bb198c227b3202ee32a8067cda413bc16.tar.gz | |
Diffstat (limited to 'stmt.c')
| -rw-r--r-- | stmt.c | 69 |
1 files changed, 69 insertions, 0 deletions
@@ -0,0 +1,69 @@ +#include "stmt.h" +#include "call.h" +#include "fn.h" +#include "parse.h" +#include "prv.h" +#include "display.h" +#include "exit.h" +#include "set.h" +#include "warn.h" + +void stmt_free(struct stmt *s) +{ + switch (s->type) + { + case DISPLAY: + display_free(&s->u.display); + break; + case SET: + set_free(&s->u.set); + break; + case CALL: + call_free(&s->u.call); + break; + case WARN: + warn_free(&s->u.warn); + break; + } +} + +int stmt_cgen(const struct stmt *s, struct cgen *c) +{ + switch (s->type) + { + case DISPLAY: + return display_cgen(&s->u.display, c); + case SET: + return set_cgen(&s->u.set, c); + case CALL: + return call_cgen(&s->u.call, c); + case WARN: + return warn_cgen(&s->u.warn, c); + } + + fprintf(stderr, "%s: unreachable\n", __func__); + return -1; +} + +struct stmt *stmt_cur(const struct prv *p) +{ + const struct fn *fn = fn_cur(p); + + return &fn->stmts[fn->nstmts - 1]; +} + +const struct seq stmts[] = +{ + {(struct step[]){ + {ID, "display"}, {ANY, NULL, 1}, {ID, "etc"}, {0}}, .fn = display}, + {(struct step[]) + {{ID, "display"}, {ANY, NULL, 1}, {0}}, .fn = display}, + {(struct step[]){ + {ID, "warn"}, {ANY, NULL, 1}, {ID, "etc"}, {0}}, .fn = warn}, + {(struct step[]) + {{ID, "warn"}, {ANY, NULL, 1}, {0}}, .fn = warn}, + {(struct step[]){{ID, "exit"}, {0}}, .fn = s_exit}, + {(struct step[]){{ID, "set"}, {0}}, .fn = set}, + {(struct step[]){{ID, "call"}, {0}}, .fn = call}, + {0} +}; |
