From 766006c5e8e6a4a51f2cc7c173a2054bc219b9f4 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Tue, 3 Nov 2026 10:11:40 +0100 Subject: Fully support opaque types and forward decls --- src/prc1/type.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'src/prc1/type.c') diff --git a/src/prc1/type.c b/src/prc1/type.c index 72940c8..36e222e 100644 --- a/src/prc1/type.c +++ b/src/prc1/type.c @@ -166,22 +166,43 @@ const struct type *type_ufind(const struct fn *fn, const char *tr, const char *s) { const struct td *td = fn->td; - const struct type *t; + const struct type *t, *op = NULL; if (fn->parent && (t = type_find(fn->parent, tr, s))) - return t; - else if ((t = triplet_type(tr, s))) - return t; + { + if (t->type == OP) + op = t; + else + return t; + } + + if ((t = triplet_type(tr, s))) + { + if (t->type == OP) + op = t; + else + return t; + } else if (td) for (const struct type *t = td->types; t; t = t->next) if (!strcmp(t->tk->s, s)) - return t; + { + if (t->type == OP) + op = t; + else + return t; + } for (size_t i = 0; i < fn->nimps; i++) if ((t = type_ufind(fn->imps[i].ast.fns, tr, s))) - return t; + { + if (t->type == OP) + op = t; + else + return t; + } - return NULL; + return op; } const struct type *type_find(const struct fn *fn, const char *tr, const char *s) -- cgit v1.2.3