From: fennecdjay Date: Fri, 29 Mar 2024 12:42:19 +0000 (+0100) Subject: :art: improve tdpp X-Git-Tag: nightly~25 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=2480226c8bf86c223efcaaa41ba8ae9f3667ac62;p=gwion.git :art: improve tdpp --- diff --git a/include/env/env.h b/include/env/env.h index a9cfdb30..eebaf167 100644 --- a/include/env/env.h +++ b/include/env/env.h @@ -57,7 +57,7 @@ ANN Value mk_class(const Env env, const Type base, const loc_t); ANN bool compat_func(const __restrict__ Func_Def, const __restrict__ Func_Def); ANN Type known_type(const Env env, Type_Decl *); -ANN m_str tdpp(MemPool, SymTable*, const Type_Decl*, const bool no_color); +ANN m_str tdpp(MemPool, SymTable*, const Type_Decl*, const bool no_color, const bool minimize); ANN Type prim_ref(const Env env, const Type t, const Type_Decl *td); ANN bool env_access(const Env env, const ae_flag flag, const loc_t); ANN bool env_storage(const Env env, ae_flag flag, const loc_t); diff --git a/src/parse/type_decl.c b/src/parse/type_decl.c index e30896f9..6efaa75d 100644 --- a/src/parse/type_decl.c +++ b/src/parse/type_decl.c @@ -117,8 +117,9 @@ ANN static Type resolve(const Env env, Type_Decl *td) { return !array ? ret : array_type(env, ret, array->depth, td->tag.loc); } -ANN m_str tdpp(MemPool mp, SymTable *st, const Type_Decl *td, bool no_color) { - struct GwfmtState ls = {}; +ANN m_str tdpp(MemPool mp, SymTable *st, const Type_Decl *td, + const bool no_color, const bool minimize) { + struct GwfmtState ls = { .minimize = minimize,}; text_init(&ls.text, mp); Gwfmt gwfmter = {.mp = mp, .ls = &ls, .st = st }; bool has_color = tcol_has_color(); @@ -129,7 +130,7 @@ ANN m_str tdpp(MemPool mp, SymTable *st, const Type_Decl *td, bool no_color) { } ANN static inline void *type_unknown(const Env env, const Type_Decl *td) { - m_str str = tdpp(env->gwion->mp, env->gwion->st, td, false); + m_str str = tdpp(env->gwion->mp, env->gwion->st, td, false, tcol_has_color()); env_err(env, td->tag.loc, _("unknown type '%s'"), str); free_mstr(env->gwion->mp, str); return NULL; diff --git a/src/sema/sema.c b/src/sema/sema.c index e56faad1..614b9a86 100644 --- a/src/sema/sema.c +++ b/src/sema/sema.c @@ -219,6 +219,7 @@ ANN static bool sema_exp_call(Sema *a, Exp_Call *b) { ANN static bool sema_exp_array(Sema *a, Exp_Array *b) { const bool ok = sema_exp(a, b->base); + CHECK_B(array_not_empty(a, b->array, "in array expression", exp_self(b)->loc)); return sema_array_sub(a, b->array) && ok; } @@ -448,7 +449,7 @@ ANN2(1, 2) static bool sema_spread(Sema *a, const Spread_Def spread, MP_Vector * const Type_Decl *td = *mp_vector_at(a->tmpls, Type_Decl*, i); fseek(f, 0, SEEK_SET); - const m_str type = tdpp(a->mp, a->st, td, true); + const m_str type = tdpp(a->mp, a->st, td, true, true); sprintf(c, "%s=%s", s_name(spread->tag.sym), type); pparg_add(a->ppa, c); free_mstr(a->mp, type);