From 05b258c474ae233b0599fd0c2b743f0619b0ae12 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 27 Apr 2022 19:11:34 +0200 Subject: [PATCH] :art: fun $ funptr --- src/lib/lib_func.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/lib_func.c b/src/lib/lib_func.c index a9e6cb51..6550ea98 100644 --- a/src/lib/lib_func.c +++ b/src/lib/lib_func.c @@ -387,6 +387,7 @@ static OP_CHECK(opck_fptr_at) { exp_setvar(bin->rhs, 1); return bin->rhs->type; } + /* static OP_CHECK(opck_fptr_cast) { Exp_Cast * cast = (Exp_Cast *)data; @@ -424,6 +425,15 @@ static OP_CHECK(opck_fptr_impl) { return impl->t; } +static OP_CHECK(opck_fptr_cast) { + Exp_Cast *cast = (Exp_Cast *)data; + const Type t = known_type(env, cast->td); + struct FptrInfo info = {cast->exp->type->info->func, t->info->func, + cast->exp, cast->td->pos}; + CHECK_BN(fptr_do(env, &info)); + return t; +} + // smh the VM should be able to do that static INSTR(Func2Code) { *(VM_Code *)REG(-SZ_INT) = (*(Func *)REG(-SZ_INT))->code; @@ -724,6 +734,8 @@ GWION_IMPORT(func) { GWI_BB(gwi_oper_add(gwi, opck_fptr_impl)) GWI_BB(gwi_oper_emi(gwi, opem_fptr_impl)) GWI_BB(gwi_oper_end(gwi, "@implicit", NULL)) + GWI_BB(gwi_oper_add(gwi, opck_fptr_cast)) + GWI_BB(gwi_oper_end(gwi, "$", NULL)) GWI_BB(gwi_oper_ini(gwi, "@op", "@func_ptr", NULL)) GWI_BB(gwi_oper_add(gwi, opck_op_impl)) GWI_BB(gwi_oper_emi(gwi, opem_op_impl)) -- 2.43.0