From: Jérémie Astor Date: Thu, 25 Feb 2021 22:50:41 +0000 (+0100) Subject: :art: Add @class_check X-Git-Tag: nightly~921 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=9404a1edfe3ae759aae6dc932751bb6fb2f6ac7d;p=gwion.git :art: Add @class_check --- 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));