From 35f4216dfd97f3693f438649c3803e624765b35f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 31 Mar 2020 01:46:42 +0200 Subject: [PATCH] :art: '$' operator fixes --- include/import.h | 2 +- src/lib/array.c | 2 -- src/lib/func.c | 1 - src/lib/opfunc.c | 9 +++++---- src/lib/prim.c | 4 ++-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/import.h b/include/import.h index d11c2e9d..a5502758 100644 --- a/include/import.h +++ b/include/import.h @@ -49,9 +49,9 @@ OP_CHECK(opck_post); OP_CHECK(opck_rassign); OP_CHECK(opck_rhs_emit_var); OP_CHECK(opck_basic_cast); +OP_CHECK(opck_simple_cast); OP_CHECK(opck_usr_implicit); OP_CHECK(opck_new); -OP_EMIT(opem_basic_cast); OP_EMIT(opem_new); #endif diff --git a/src/lib/array.c b/src/lib/array.c index 47383c79..93ca7368 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -332,10 +332,8 @@ GWION_IMPORT(array) { GWI_BB(gwi_oper_end(gwi, "<<", NULL)) GWI_BB(gwi_oper_ini(gwi, "@Array", "@Array", NULL)) GWI_BB(gwi_oper_add(gwi, opck_array_cast)) - GWI_BB(gwi_oper_emi(gwi, opem_basic_cast)) GWI_BB(gwi_oper_end(gwi, "$", NULL)) GWI_BB(gwi_oper_ini(gwi, "nonnull @Array", "int", "int")) -// GWI_BB(gwi_oper_ini(gwi, "@Array", "int", "int")) GWI_BB(gwi_oper_add(gwi, opck_array_slice)) GWI_BB(gwi_oper_emi(gwi, opem_array_slice)) GWI_BB(gwi_oper_end(gwi, "@slice", NULL)) diff --git a/src/lib/func.c b/src/lib/func.c index 09832140..1c3588eb 100644 --- a/src/lib/func.c +++ b/src/lib/func.c @@ -230,7 +230,6 @@ static void member_fptr(const Emitter emit) { } static OP_EMIT(opem_fptr_cast) { - CHECK_OO(opem_basic_cast(emit, data)) Exp_Cast* cast = (Exp_Cast*)data; if(exp_self(cast)->info->type->e->d.func->def->base->tmpl) fptr_instr(emit, cast->exp->info->type->e->d.func, 1); diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index 9d10e537..979afb03 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -16,16 +16,17 @@ OP_CHECK(opck_basic_cast) { exp_self(cast)->info->type : env->gwion->type[et_null]; } +OP_CHECK(opck_simple_cast) { + const Exp_Cast* cast = (Exp_Cast*)data; + return cast->exp->info->cast_to = exp_self(cast)->info->type; +} + OP_CHECK(opck_usr_implicit) { struct Implicit* imp = (struct Implicit*)data; imp->e->info->cast_to = imp->t; return imp->t; } -OP_EMIT(opem_basic_cast) { - return (Instr)GW_OK; -} - OP_CHECK(opck_const_rhs) { const Exp_Binary* bin = (Exp_Binary*)data; const m_str access = exp_access(bin->rhs); diff --git a/src/lib/prim.c b/src/lib/prim.c index e82f4669..b6081a86 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -166,7 +166,7 @@ static GWION_IMPORT(intfloat) { CHECK_IF("-=>", rassign, r_minus) CHECK_IF("*=>", rassign, r_mul) CHECK_IF("/=>", rassign, r_div) - _CHECK_OP("$", basic_cast, CastI2F) + _CHECK_OP("$", simple_cast, CastI2F) _CHECK_OP("@implicit", implicit_i2f, CastI2F) return GW_OK; } @@ -191,7 +191,7 @@ static GWION_IMPORT(floatint) { CHECK_FI("-=>", rassign, r_minus) CHECK_FI("*=>", rassign, r_mul) CHECK_FI("/=>", rassign, r_div) - _CHECK_OP("$", basic_cast, CastF2I) + _CHECK_OP("$", simple_cast, CastF2I) _CHECK_OP("@implicit", implicit_f2i, CastF2I) return GW_OK; } -- 2.43.0