From f6f6771447182053db9c29a18685adb7b3b878a2 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 19 Jul 2019 15:04:37 +0200 Subject: [PATCH] :art: Use PushStaticCode for recursive templates --- src/emit/emit.c | 10 ++++++++-- src/parse/check.c | 2 +- src/parse/template.c | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index e50b6d13..3a0228fa 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -864,8 +864,14 @@ 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 && !is_fptr(f->value_ref->type)) - CHECK_BB(emit_template_code(emit, f)) + if(GET_FLAG(f, template) && !is_fptr(f->value_ref->type)) { + if(emit->env->func != f) + CHECK_BB(emit_template_code(emit, f)) + else { + const Instr back = (Instr)vector_back(&emit->code->instr); + back->opcode = ePushStaticCode; + } + } } else if((f->value_ref->owner_class && is_special(f->value_ref->owner_class) > 0) || !f->value_ref->owner_class || (GET_FLAG(f, template) && isa(f->value_ref->type, t_fptr) < 0)) diff --git a/src/parse/check.c b/src/parse/check.c index ee81952f..c141924c 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -482,7 +482,7 @@ ANN static Func _find_template_match(const Env env, const Value v, const Exp_Cal CHECK_BO(check_call(env, exp)) const Type_List types = exp->tmpl->call; Func m_func = NULL, former = env->func; - const m_str tmpl_name = tl2str(env, types); + DECL_OO(const m_str, tmpl_name, = tl2str(env, types)) const m_uint scope = env_push(env, v->owner_class, v->owner); if(is_fptr(v->type)) { const Symbol sym = func_symbol(env, v->owner->name, v->name, tmpl_name, 0); diff --git a/src/parse/template.c b/src/parse/template.c index f0a07c4e..5cfbeba0 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -190,7 +190,8 @@ ANN Type scan_type(const Env env, const Type t, const Type_Decl* type) { return a->base.type; } else if(type->types) { // TODO: clean me if(isa(t, t_function) > 0 && t->e->d.func->def->base->tmpl) { - const m_str tl_name = tl2str(env, type->types); + DECL_OO(const m_str, tl_name, = tl2str(env, type->types)) +// err_msg here ? const Symbol sym = func_symbol(env, t->e->owner->name, t->e->d.func->name, tl_name, 0); free_mstr(env->gwion->mp, tl_name); const Type base_type = nspc_lookup_type1(t->e->owner, sym); -- 2.43.0