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) &&
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;
}
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;
#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);
}
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;