From ccbaf6ac20241382822b04571b585ab5ca47a11e Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 19 Jul 2019 14:47:27 +0200 Subject: [PATCH] :art: Allow cast to self type --- src/lib/object.c | 3 +++ src/lib/opfunc.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) 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) { -- 2.43.0