From 9404a1edfe3ae759aae6dc932751bb6fb2f6ac7d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Thu, 25 Feb 2021 23:50:41 +0100 Subject: [PATCH] :art: Add @class_check --- src/parse/check.c | 3 +++ src/parse/operator.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/parse/check.c b/src/parse/check.c index 6bd33170..2c8b1f20 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1296,6 +1296,9 @@ ANN m_bool check_class_def(const Env env, const Class_Def cdef) { if(tmpl_base(cdef->base.tmpl)) return GW_OK; const Type t = cdef->base.type; + struct Op_Import opi = { .op=insert_symbol("@class_check"), .lhs=t, + .data=(uintptr_t)cdef, .pos=cdef->pos }; + CHECK_OB(op_check(env, &opi)) if(t->info->owner_class) CHECK_BB(ensure_check(env, t->info->owner_class)) if(tflag(t, tflag_check)) diff --git a/src/parse/operator.c b/src/parse/operator.c index e394882f..3bf27e7d 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -175,10 +175,13 @@ for(int i = 0; i < 2; ++i) { } while(l && (l = op_parent(env, l))); } while((nspc = nspc->parent)); } + // this should be an any case if(opi->op == insert_symbol(env->gwion->st, "$") && opi->rhs == opi->lhs) return opi->rhs; if(opi->op == insert_symbol(env->gwion->st, "@func_check")) return NULL; + if(opi->op == insert_symbol(env->gwion->st, "@class_check")) + return env->gwion->type[et_error]; if(opi->op != insert_symbol(env->gwion->st, "@implicit")) env_err(env, opi->pos, _("%s %s %s: no match found for operator"), type_name(opi->lhs), s_name(opi->op), type_name(opi->rhs)); -- 2.43.0