diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-10-01 01:04:30 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-10-05 00:38:49 +0200 |
| commit | 2b0d4ead061a39da9dbd705c18c9955549c4d405 (patch) | |
| tree | 1412ac39adce3428b96caf67b1e7543f6c1246a5 /src/prc1/warn.c | |
| parent | 9140988be4e5bb028b7140aca1a67af1370c72a7 (diff) | |
| download | prc-sym.tar.gz | |
WIP symsym
Diffstat (limited to 'src/prc1/warn.c')
| -rw-r--r-- | src/prc1/warn.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/prc1/warn.c b/src/prc1/warn.c index 93635db..9fb535e 100644 --- a/src/prc1/warn.c +++ b/src/prc1/warn.c @@ -1,6 +1,7 @@ #include "warn.h" #include "cgen.h" #include "dbg.h" +#include "fn.h" #include "parse.h" #include "prv.h" #include "stmt.h" @@ -9,6 +10,8 @@ #include <stdlib.h> #include <string.h> +#if 0 + static int finalize(const struct lex *l, const struct prv *p, const struct print *pr) { @@ -30,7 +33,7 @@ static int finalize(const struct lex *l, const struct prv *p, .u.warn.p = *pr }; - dbg("\t\tadding warn statement with %zu entries%s\n", pr->nentries, + dbg("\t\tadd warn statement with %zu entries%s\n", pr->nentries, pr->println ? "" : ", no lf"); return 0; } @@ -135,13 +138,27 @@ int warn_cgen(const struct warn *w, struct cgen *c) return 0; } +#endif -void warn_free(struct warn *w) +int warn_cgen(const struct print *pr, struct cgen *c) { - print_free(&w->p); + return print_cgen(pr, c, "stderr"); } int warn(const struct lex *l, struct prv *p) { - return print(l, p, finalize); + struct fn *fn = fn_cur(p); + size_t n = fn->nstmts + 1; + struct stmt *stmts = realloc(fn->stmts, n * sizeof *stmts); + + if (!stmts) + { + perror("realloc(3)"); + return -1; + } + + dbg("\t\tadd warn statement\n"); + stmts[fn->nstmts++] = (struct stmt){.type = WARN, .u.print = {0}}; + fn->stmts = stmts; + return print(l, p); } |
