aboutsummaryrefslogtreecommitdiff
path: root/src/prc1/call.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2026-10-31 17:24:18 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2026-10-31 17:24:18 +0100
commit40cd81581d14260eb0d90bfe460ad0b2af38c9ca (patch)
treed115754363c40e9ff87b08c76c3f5f451630d30f /src/prc1/call.c
parentd4ded2a5054dcef06e76d62ae4affdf9bcd7234b (diff)
downloadprc-40cd81581d14260eb0d90bfe460ad0b2af38c9ca.tar.gz
call.c: Fix find prototype
Diffstat (limited to 'src/prc1/call.c')
-rw-r--r--src/prc1/call.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/prc1/call.c b/src/prc1/call.c
index 41dde47..e6db4ca 100644
--- a/src/prc1/call.c
+++ b/src/prc1/call.c
@@ -142,13 +142,28 @@ void call_free(struct call *c)
free(c->params);
}
-static const struct pr *find(const struct ast *ast, const char *s)
+static const struct pr *find_proto(const struct fn *fn, const char *tr,
+ const char *s)
+{
+ const struct type *t = type_find(fn, tr, s);
+
+ if (t && t->type == P)
+ return t->u.p.fn->pr;
+
+ return NULL;
+}
+
+static const struct pr *find(const struct ast *ast, const char *tr,
+ const char *s)
{
for (size_t i = 0; i < ast->nfns; i++)
{
const struct fn *fn = &ast->fns[i];
+ const struct pr *pr;
- if (!strcmp(fn->tk->s, s))
+ if ((pr = find_proto(fn, tr, s)))
+ return pr;
+ else if (!strcmp(fn->tk->s, s))
return fn->pr;
}
@@ -161,10 +176,16 @@ static int onsym(const struct lex *l, struct prv *p, const struct sym *s)
struct stmt *stmt = stmt_cur(p);
struct call *c = &stmt->u.call;
const struct tk *tk = s->tk;
- const struct pr *pr = find(p->ast, tk->s);
+ const char *tr = triplet(p);
+ const struct pr *pr;
const struct stentry *e;
- if (pr)
+ if (!tr)
+ {
+ fprintf(stderr, "%s: unreachable\n", __func__);
+ return -1;
+ }
+ else if ((pr = find(p->ast, tr, tk->s)))
c->pr = pr;
else if (!(e = fn_var(fn, tk)))
{