From c50420f549634fdcfcb6b6a5110db1d617cbc7d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 1 Mar 2021 20:28:42 +0100 Subject: [PATCH] :art: Fix late --- src/emit/emit.c | 11 +++++++++++ src/parse/check.c | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 178d1963..07689b4e 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -846,6 +846,16 @@ ANN static inline m_bool ensure_emit(const Emitter emit, const Type t) { return envset_run(&es, t); } +ANN static void set_late(const Gwion gwion, const Exp_Decl *decl, const Var_Decl var) { + const Value v = var->value; + const uint array_ref = (decl->td->array && !decl->td->array->exp) || (var->array && !var->array->exp); + if(!exp_getvar(exp_self(decl)) && (GET_FLAG(array_base(v->type), abstract) || + GET_FLAG(decl->td, late) || is_fptr(gwion, v->type) || array_ref)) { + SET_FLAG(v, late); + } else + UNSET_FLAG(v, late); +} + ANN static m_bool emit_decl(const Emitter emit, const Exp_Decl* decl) { const m_bool global = GET_FLAG(decl->td, global); const uint var = exp_getvar(exp_self(decl)); @@ -860,6 +870,7 @@ ANN static m_bool emit_decl(const Emitter emit, const Exp_Decl* decl) { CHECK_BB(emit_exp_decl_non_static(emit, decl, list->self, r, var)) else CHECK_BB(emit_exp_decl_global(emit, decl, list->self, r, var)) + set_late(emit->gwion, decl, list->self); if(GET_FLAG(array_base(v->type), abstract) && !GET_FLAG(decl->td, late) && GET_FLAG(v, late)) { env_warn(emit->env, decl->td->pos, _("Type '%s' is abstract, use late"), v->type->name); } diff --git a/src/parse/check.c b/src/parse/check.c index f652149b..24d145d7 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -103,16 +103,6 @@ ANN static m_bool check_var_td(const Env env, const Var_Decl var, Type_Decl *con return GW_OK; } -ANN static void set_late(const Gwion gwion, const Exp_Decl *decl, const Var_Decl var) { - const Value v = var->value; - const uint array_ref = (decl->td->array && !decl->td->array->exp) || (var->array && !var->array->exp); - if(!exp_getvar(exp_self(decl)) && (GET_FLAG(array_base(v->type), abstract) || - GET_FLAG(decl->td, late) || is_fptr(gwion, v->type) || array_ref)) { - SET_FLAG(v, late); - } else - UNSET_FLAG(v, late); -} - ANN static m_bool check_decl(const Env env, const Exp_Decl *decl) { Var_Decl_List list = decl->list; do { @@ -121,7 +111,6 @@ ANN static m_bool check_decl(const Env env, const Exp_Decl *decl) { CHECK_BB(check_var_td(env, var, decl->td)) if(is_fptr(env->gwion, decl->type)) CHECK_BB(check_fptr_decl(env, var)) - set_late(env->gwion, decl, list->self); set_vflag(var->value, vflag_valid); //set_vflag(var->value, vflag_used)); nspc_add_value(env->curr, var->xid, var->value); -- 2.43.0