From: Jérémie Astor Date: Tue, 17 Aug 2021 09:21:55 +0000 (+0200) Subject: :art: Few fixes X-Git-Tag: nightly~470^2~72 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=742c9b60a91d868f95ee8890ebfd88b13b19e297;p=gwion.git :art: Few fixes --- diff --git a/src/emit/emit.c b/src/emit/emit.c index 83685362..818df36e 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1026,7 +1026,7 @@ ANN static void emit_func_arg_vararg(const Emitter emit, ANN static m_bool emit_func_args(const Emitter emit, const Exp_Call *exp_call) { if (exp_call->args) { CHECK_BB(emit_exp(emit, exp_call->args)); - // emit_exp_addref(emit, exp_call->args, -exp_totalsize(exp_call->args)); +// emit_exp_addref_array(emit, exp_call->args, -exp_totalsize(exp_call->args)); } const Type t = actual_type(emit->gwion, exp_call->func->type); if (is_func(emit->gwion, t) && diff --git a/src/lib/array.c b/src/lib/array.c index 9675c969..270b18be 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -208,8 +208,8 @@ static OP_EMIT(opem_array_sr) { return emit_array_shift(emit, ArrayConcatRight); const Instr pop = emit_add_instr(emit, RegMove); pop->m_val = -SZ_INT; - if (isa(bin->rhs->type, emit->gwion->type[et_object]) > 0) - emit_add_instr(emit, RegAddRef); + if (isa(bin->lhs->type, emit->gwion->type[et_compound]) > 0) + emit_compound_addref(emit, bin->lhs->type, -SZ_INT, false); (void)emit_add_instr(emit, ArrayAppendFront); return GW_OK; } @@ -218,12 +218,10 @@ static OP_EMIT(opem_array_sl) { const Exp_Binary *bin = (Exp_Binary *)data; if (shift_match(bin->rhs->type, bin->lhs->type)) return emit_array_shift(emit, ArrayConcatLeft); + if (isa(bin->rhs->type, emit->gwion->type[et_compound]) > 0) + emit_compound_addref(emit, bin->rhs->type, -SZ_INT, false); const Instr pop = emit_add_instr(emit, RegMove); pop->m_val = -bin->rhs->type->size; - if (isa(bin->rhs->type, emit->gwion->type[et_object]) > 0) { - const Instr ref = emit_add_instr(emit, RegAddRef); - ref->m_val = -SZ_INT; - } emit_add_instr(emit, ArrayAppend); return GW_OK; } diff --git a/src/parse/check.c b/src/parse/check.c index 915fc604..557f8325 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -815,23 +815,26 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) { if (value->from->owner_class) CHECK_BO(ensure_traverse(env, value->from->owner_class)); } - if (exp->args) CHECK_OO(check_exp(env, exp->args)); + if (exp->args) { + CHECK_OO(check_exp(env, exp->args)); + Exp e = exp->args; + do exp_setuse(e, true); + while((e = e->next)); + } if (tflag(t, tflag_ftmpl)) return check_exp_call_template(env, (Exp_Call *)exp); // TODO: effects? const Func func = find_func_match(env, t->info->func, exp); if (func) { if (!is_fptr(env->gwion, func->value_ref->type)) // skip function pointers if (func != env->func && func->def && !fflag(func, fflag_valid)) { - struct EnvSet es = {.env = env, - .data = env, - .func = (_exp_func)check_cdef, - .scope = env->scope->depth, - .flag = tflag_check}; - CHECK_BO(envset_pushv(&es, func->value_ref)); - CHECK_BO(check_func_def(env, func->def)); - if (es.run) envset_pop(&es, func->value_ref->from->owner_class); + if(func->value_ref->from->owner_class) + CHECK_BO(ensure_check(env, func->value_ref->from->owner_class)); + else { + const m_uint scope = env_push(env, NULL, func->value_ref->from->owner); + CHECK_BO(check_func_def(env, func->def)); + env_pop(env, scope); + } } - exp->func->type = func->value_ref->type; call_add_effect(env, func, exp->func->pos); if (func == env->func) set_fflag(env->func, fflag_recurs); @@ -987,6 +990,9 @@ ANN static Type check_exp_if(const Env env, Exp_If *const exp_if) { if (isa(if_exp, else_exp) < 0) ERR_O(exp_self(exp_if)->pos, _("condition type '%s' does not match '%s'"), cond->name, ret->name) + exp_setuse(exp_if->cond, true); + exp_setuse(exp_if->if_exp, true); + exp_setuse(exp_if->else_exp, true); return ret; } @@ -1581,7 +1587,7 @@ ANN m_bool _check_func_def(const Env env, const Func_Def f) { const Func func = f->base->func; const Func_Def fdef = func->def; if(fflag(func, fflag_valid))return GW_OK; - set_fflag(fdef->base->func, fflag_valid); + set_fflag(func, fflag_valid); assert(func == fdef->base->func); if (env->class_def) // tmpl ? CHECK_BB(check_parent_match(env, fdef));