From: Jérémie Astor Date: Thu, 16 Dec 2021 14:26:08 +0000 (+0100) Subject: :bug: Improve constructors X-Git-Tag: nightly~391 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=5b1e289b9e14b772ea42fae16939139452a1c1a3;p=gwion.git :bug: Improve constructors --- diff --git a/src/emit/emit.c b/src/emit/emit.c index c9f1451b..ea2ea831 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1341,15 +1341,12 @@ ANN static m_bool emit_exp_call(const Emitter emit, const Exp_Call *exp_call) { const Instr instr = emit_add_instr(emit, Reg2RegAddr); instr->m_val = -SZ_INT; } else { - if(isa(t, emit->gwion->type[et_object]) > 0) { -//emit_object_addref(emit, -SZ_INT, 0); - emit_local_exp(emit, e); -// emit_localx(emit, t); - } if (!is_func(emit->gwion, exp_call->func->type) && tflag(e->type, tflag_struct)) regpop(emit, SZ_INT); } + if(isa(e->type, emit->gwion->type[et_object]) > 0) + emit_local_exp(emit, e); return GW_OK; } @@ -2096,10 +2093,6 @@ ANN static m_bool emit_stmt_return(const Emitter emit, const Stmt_Exp stmt) { return optimize_tail_call(emit, &stmt->val->d.exp_call); } CHECK_BB(emit_exp_pop_next(emit, stmt->val)); - - if(isa(stmt->val->type, emit->gwion->type[et_object]) > 0 && - (!stmt->val->data && stmt->val->acquire)) - emit_object_addref(emit, -SZ_INT, exp_getvar(stmt->val)); } vector_add(&emit->code->stack_return, (vtype)emit_add_instr(emit, Goto)); return GW_OK; diff --git a/src/parse/scan0.c b/src/parse/scan0.c index b1bb1e1d..06e7aa2d 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -516,10 +516,12 @@ ANN m_bool scan0_class_def(const Env env, const Class_Def c) { if (GET_FLAG(cdef, global)) env->curr = (Nspc)vector_pop(&env->scope->nspc_stack); if (cpy && cdef->base.type) { - c->base.type = cdef->base.type; + c->base.type = cdef->base.type; c->base.type->info->cdef = cdef; set_tflag(c->base.type, tflag_cdef); } +// if (GET_FLAG(cdef, global)) +// type_addref(c->base.type); return ret; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 357e4168..a8390b00 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -551,7 +551,8 @@ ANN m_bool _scan2_func_def(const Env env, const Func_Def fdef) { if(!env->class_def) ERR_B(fdef->base->pos, _("{G+}new{0} operator must be set inside {C+}class{0}")); if(!fdef->base->ret_type) - fdef->base->ret_type = env->class_def; +// fdef->base->ret_type = env->class_def; + fdef->base->ret_type = env->gwion->type[et_auto]; } if (GET_FLAG(fdef->base, global) && !env->class_def) env->context->global = 1; const Func_Def f = !is_cpy(fdef) ? fdef : scan2_cpy_fdef(env, fdef);