diff options
Diffstat (limited to 'src/prc1/call.c')
| -rw-r--r-- | src/prc1/call.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/prc1/call.c b/src/prc1/call.c index 21ef4de..ed64070 100644 --- a/src/prc1/call.c +++ b/src/prc1/call.c @@ -7,6 +7,7 @@ #include "parse.h" #include "prv.h" #include "stmt.h" +#include "sym.h" #include "type.h" #include <stddef.h> #include <stdio.h> @@ -149,12 +150,12 @@ static int callpr(const struct lex *l, struct prv *p) else if (pop(l, p)) return -1; - dbg("\t\tadding call to %s using %zu params and %s as return variable\n", + dbg("\t\tadd call to %s using %zu params and %s as return variable\n", c->tk->s, n, tk->s); c->ret = e; c->nparams = n; p->stk = ++tk; - return 1; + return 0; } static int callr(const struct lex *l, struct prv *p) @@ -185,10 +186,10 @@ static int callr(const struct lex *l, struct prv *p) else if (pop(l, p)) return -1; - dbg("\t\tadding call to %s with %s as return variable\n", c->tk->s, tk->s); + dbg("\t\tadd call to %s with %s as return variable\n", c->tk->s, tk->s); c->ret = e; p->stk = ++tk; - return 1; + return 0; } static int callp(const struct lex *l, struct prv *p) @@ -229,9 +230,9 @@ static int callp(const struct lex *l, struct prv *p) if (pop(l, p)) return -1; - dbg("\t\tadding call to %s with 1 param\n", c->tk->s); + dbg("\t\tadd call to %s with 1 param\n", c->tk->s); p->stk = tk; - return 1; + return 0; } static int callv(const struct lex *l, struct prv *p) @@ -249,9 +250,9 @@ static int callv(const struct lex *l, struct prv *p) else if (pop(l, p)) return -1; - dbg("\t\tadding call to %s with %s as return variable\n", c->tk->s, tk->s); + dbg("\t\tadd call to %s with %s as return variable\n", c->tk->s, tk->s); p->stk = ++tk; - return 1; + return 0; } static const struct pr *find_proto(const struct fn *fn, const char *s) @@ -436,6 +437,12 @@ void call_free(struct call *c) free(c->params); } +static int onsym(const struct lex *l, struct prv *p, const struct sym *s) +{ + fprintf(stderr, "%s: TODO\n", __func__); + return -1; +} + int call(const struct lex *l, struct prv *p) { const struct tk *tk = p->tk; @@ -443,23 +450,21 @@ int call(const struct lex *l, struct prv *p) struct fn *fn = fn_cur(p); size_t n = fn->nstmts +1; struct stmt *stmts; - struct pos init = - { - .seq = seqs, - .stseq = seqs, - .step = seqs->steps - }; /* TODO: function pointers */ - - if (lex_eof(l, tk)) + if (!(pr = find(p->ast, tk->s))) { - errloc(tk - 1, "incomplete call statement"); + errloc(tk, "undefined reference to function \"%s\"", tk->s); return -1; } - else if (!(pr = find(p->ast, tk->s))) + else if (!strcmp((++tk)->s, "using")) { - errloc(tk, "undefined reference to function \"%s\"", tk->s); + fprintf(stderr, "%s: TODO using rule\n", __func__); + return -1; + } + else if (!strcmp(tk->s, "returning")) + { + fprintf(stderr, "%s: TODO returning rule\n", __func__); return -1; } else if (!(stmts = realloc(fn->stmts, n * sizeof *stmts))) @@ -479,9 +484,6 @@ int call(const struct lex *l, struct prv *p) } }; - if (push(&init, p)) - return -1; - p->stk = p->tk; - return 1; + return sym(p, onsym); } |
