aboutsummaryrefslogtreecommitdiff
path: root/src/prc1/type.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2026-11-03 10:11:40 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2026-11-03 10:11:40 +0100
commit766006c5e8e6a4a51f2cc7c173a2054bc219b9f4 (patch)
tree35c3991ca37ef3eed6666c63c2683ac5507b2a07 /src/prc1/type.c
parent3ee275dbb8bcf5df7f54e7659b4a9a8f4f49911d (diff)
downloadprc-766006c5e8e6a4a51f2cc7c173a2054bc219b9f4.tar.gz
Fully support opaque types and forward declsHEADmaster
Diffstat (limited to 'src/prc1/type.c')
-rw-r--r--src/prc1/type.c35
1 files changed, 28 insertions, 7 deletions
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)