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/fn.c | |
| parent | 9140988be4e5bb028b7140aca1a67af1370c72a7 (diff) | |
| download | prc-2b0d4ead061a39da9dbd705c18c9955549c4d405.tar.gz | |
WIP symsym
Diffstat (limited to 'src/prc1/fn.c')
| -rw-r--r-- | src/prc1/fn.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/prc1/fn.c b/src/prc1/fn.c index 03aa11e..84f6c4b 100644 --- a/src/prc1/fn.c +++ b/src/prc1/fn.c @@ -9,6 +9,7 @@ #include "pr.h" #include "stmt.h" #include "storage.h" +#include "sym.h" #include "td.h" #include "ws.h" #include <stdlib.h> @@ -20,11 +21,8 @@ static int prvfn(const struct lex *l, struct prv *p); static const struct seq fnseq[] = { - {(struct step[]) - {{ID, "public"}, {ID, "function"}, {ID}, {0}}, .fn = pubfn, - .end = fn_end}, - {(struct step[]) - {{ID, "function"}, {ID}, {0}}, .fn = prvfn, .end = fn_end}, + {(struct step[]){{ID, "public"}, {ID, "function"}, {ID}, {0}}, .fn = pubfn}, + {(struct step[]){{ID, "function"}, {ID}, {0}}, .fn = prvfn}, {0} }; @@ -92,8 +90,8 @@ static int pushfn(const struct tk *tk, const struct lex *lex, struct prv *p, if (div_fn(lex, p)) return -1; - dbg("adding %s function %s\n", l == STATIC ? "private" : "public", tk->s); - return 1; + dbg("add %s function %s\n", l == STATIC ? "private" : "public", tk->s); + return 0; } static int pubfn(const struct lex *l, struct prv *p) @@ -229,6 +227,14 @@ void fn_free(struct fn *fn) t = next; } + for (struct sym *s = fn->syms; s;) + { + struct sym *next = s->next; + + sym_free(s); + s = next; + } + storage_free(fn->lk); storage_free(fn->ws); storage_free(fn->gl); @@ -253,14 +259,11 @@ int fn(const struct lex *l, struct prv *p) { struct pos init = { - .seq = fnseq, - .stseq = fnseq, - .step = fnseq->steps + .name = __func__, + .seq = fnseq }; - if (lex_eof(l, p->stk)) - return 0; - else if (lex_eof(l, p->stk + 1)) + if (lex_eof(l, p->stk + 1)) { errloc(p->stk, "incomplete function statement"); return -1; @@ -269,5 +272,5 @@ int fn(const struct lex *l, struct prv *p) return -1; p->stk = p->tk; - return 1; + return 0; } |
