From: fennecdjay Date: Fri, 19 Jul 2019 12:47:27 +0000 (+0200) Subject: :art: Allow cast to self type X-Git-Tag: nightly~2322 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=ccbaf6ac20241382822b04571b585ab5ca47a11e;p=gwion.git :art: Allow cast to self type --- diff --git a/src/lib/object.c b/src/lib/object.c index 8df093bb..d9b3175c 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -214,6 +214,9 @@ GWION_IMPORT(object) { GWI_BB(gwi_oper_add(gwi, at_object)) GWI_BB(gwi_oper_emi(gwi, opem_at_object)) GWI_BB(gwi_oper_end(gwi, "@=>", ObjectAssign)) + GWI_BB(gwi_oper_ini(gwi, OP_ANY_TYPE, OP_ANY_TYPE, NULL)) + GWI_BB(gwi_oper_add(gwi, opck_basic_cast)) + GWI_BB(gwi_oper_end(gwi, "$", NULL)) GWI_BB(gwi_oper_ini(gwi, "Object", "Object", "int")) GWI_BB(gwi_oper_end(gwi, "==", EqObject)) GWI_BB(gwi_oper_end(gwi, "!=", NeqObject)) diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index 3f2f7522..ace7ddef 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -19,7 +19,8 @@ static inline m_str access(ae_Exp_Meta meta) { OP_CHECK(opck_basic_cast) { const Exp_Cast* cast = (Exp_Cast*)data; - return exp_self(cast)->type; + return isa(cast->exp->type, exp_self(cast)->type) > 0 ? + exp_self(cast)->type : t_null; } OP_EMIT(opem_basic_cast) {