From: fennecdjay Date: Sun, 9 Jun 2019 19:34:16 +0000 (+0200) Subject: :art: Few fixes X-Git-Tag: nightly~2443^2~3 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=a3a96dc3f46eab4768921fe10ba4012bb268286d;p=gwion.git :art: Few fixes --- diff --git a/src/emit/emit.c b/src/emit/emit.c index 53d96f6f..259553c7 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -863,7 +863,7 @@ ANN static Instr emit_call(const Emitter emit, const Func f) { ANN m_bool emit_exp_call1(const Emitter emit, const Func f) { if(!f->code || (GET_FLAG(f, ref) && !GET_FLAG(f, builtin))) { - if(GET_FLAG(f, template) && emit->env->func != f) + if(GET_FLAG(f, template) && emit->env->func != f && isa(actual_type(f->value_ref->type), t_fptr) < 0) CHECK_BB(emit_template_code(emit, f)) } else if((f->value_ref->owner_class && is_special(f->value_ref->owner_class) > 0) || !f->value_ref->owner_class || (GET_FLAG(f, template) && diff --git a/src/lib/func.c b/src/lib/func.c index 70efd95e..85a103f7 100644 --- a/src/lib/func.c +++ b/src/lib/func.c @@ -140,8 +140,10 @@ ANN static Type fptr_type(const Env env, struct FptrInfo *info) { if(fptr_tmpl_push(env, info) > 0 && fptr_rettype(env, info) > 0 && fptr_arity(info) && fptr_args(env, base) > 0) type = info->lhs->value_ref->type; - if(info->rhs->def->base->tmpl) + if(info->rhs->def->base->tmpl) { nspc_pop_type(env->gwion->mp, env->curr); + nspc_pop_type(env->gwion->mp, env->curr); + } } return type; } diff --git a/src/lib/vararg.c b/src/lib/vararg.c index 47b5dda8..9620ed23 100644 --- a/src/lib/vararg.c +++ b/src/lib/vararg.c @@ -34,7 +34,7 @@ INSTR(VarargTop) { INSTR(VarargIni) { struct Vararg_* arg = mp_calloc(shred->info->mp, Vararg); POP_REG(shred, instr->m_val - SZ_INT) - arg->d = (m_bit*)xmalloc(instr->m_val); + arg->d = (m_bit*)xmalloc(round2szint(instr->m_val)); for(m_uint i = 0; i < instr->m_val; i += SZ_INT) *(m_uint*)(arg->d + i) = *(m_uint*)(shred->reg - SZ_INT + i); const Vector kinds = (Vector)instr->m_val2; diff --git a/src/parse/func.c b/src/parse/func.c index 26a50eab..13127df2 100644 --- a/src/parse/func.c +++ b/src/parse/func.c @@ -8,9 +8,10 @@ #include "type.h" #include "nspc.h" #include "func.h" +#include "value.h" ANN static void free_func(Func a, Gwion gwion) { - if(GET_FLAG(a, template)) { + if(GET_FLAG(a, template) && isa(actual_type(a->value_ref->type), t_fptr) < 0) { free_tmpl(gwion->mp, a->def->base->tmpl); free_func_base(gwion->mp, a->def->base); free_loc(gwion->mp, a->def->pos); diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 7fba103e..b9a4e5dc 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -109,6 +109,8 @@ ANN m_bool scan2_stmt_fptr(const Env env, const Stmt_Fptr ptr) { } ptr->value->owner_class = env->class_def; } + if(ptr->base->tmpl) + SET_FLAG(ptr->base->func, template); nspc_add_value(env->curr, ptr->base->xid, ptr->value); nspc_add_func(ptr->type->e->owner, ptr->base->xid, ptr->base->func); return GW_OK;