diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-10-11 01:26:41 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-10-29 00:15:10 +0100 |
| commit | 49d1b87b246f50e5eca25419656188befb4cb85e (patch) | |
| tree | a7d78c859cc1072ad42175eb11a2944e4fdb51f5 /src/prc1/call.c | |
| parent | 4ce39e4fc1de9536de7dedfe91b6dee38dec76ae (diff) | |
| download | prc-49d1b87b246f50e5eca25419656188befb4cb85e.tar.gz | |
WIP triplet
Diffstat (limited to 'src/prc1/call.c')
| -rw-r--r-- | src/prc1/call.c | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/src/prc1/call.c b/src/prc1/call.c index f06f25b..176e1f3 100644 --- a/src/prc1/call.c +++ b/src/prc1/call.c @@ -3,9 +3,7 @@ #include "errloc.h" #include "fn.h" #include "lex.h" -#include "lit.h" #include "parse.h" -#include "pr.h" #include "prv.h" #include "stmt.h" #include "sym.h" @@ -16,21 +14,12 @@ #include <string.h> static int using(const struct lex *, struct prv *); -static int s_returning(const struct lex *, struct prv *); - -static const struct seq returning = - {(struct step[]){{ID, "returning"}, {0}}, .fn = s_returning}; +static int returning(const struct lex *, struct prv *); static const struct seq seqs[] = { {(struct step[]){{ID, "using"}, {0}}, .fn = using}, - returning, - {0} -}; - -static const struct seq useqs[] = -{ - returning, + {(struct step[]){{ID, "returning"}, {0}}, .fn = returning}, {0} }; @@ -54,12 +43,6 @@ static int param(const struct lex *l, struct prv *p, const struct sym *s) static int using(const struct lex *l, struct prv *p) { - struct pos init = - { - .name = __func__, - .seq = useqs - }; - struct stmt *stmt = stmt_cur(p); struct call *c = &stmt->u.call; const struct tk *tk = c->pr->tk, *u = c->using; @@ -72,9 +55,8 @@ static int using(const struct lex *l, struct prv *p) loc->line, loc->col); return -1; } - else if (push(&init, p)) - return -1; + reset(p); c->using = p->stk; return sym(p, param); } @@ -85,17 +67,11 @@ static int setret(const struct lex *l, struct prv *p, const struct sym *s) struct call *c = &stmt->u.call; c->ret = s; - return pop(l, p); + return 0; } -static int s_returning(const struct lex *l, struct prv *p) +static int returning(const struct lex *l, struct prv *p) { - struct pos init = - { - .name = __func__, - .seq = useqs - }; - struct stmt *stmt = stmt_cur(p); struct call *c = &stmt->u.call; const struct tk *tk = c->pr->tk, *r = c->returning; @@ -109,9 +85,7 @@ static int s_returning(const struct lex *l, struct prv *p) return -1; } - if (push(&init, p)) - return -1; - + reset(p); c->returning = p->stk; return sym(p, setret); } @@ -162,8 +136,9 @@ static int endcall(const struct lex *l, struct prv *p) return -1; } - fprintf(stderr, "%s: TODO\n", __func__); - return -1; + dbg("\t\tadd call statement to %s using %zu parameters " + "and %s return value\n", tk->s, pr->nparams, pr->ret ? "" : "no"); + return 0; } void call_free(struct call *c) |
