From 220747ee19587f72b3e88ef4b3149ca197f818f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 13 May 2022 15:56:43 +0200 Subject: [PATCH] :art: improve enum gack --- src/parse/scan0.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 518ebbd6..c237c607 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -221,6 +221,12 @@ ANN m_bool scan0_type_def(const Env env, const Type_Def tdef) { #define scan0_nspc(env, a) \ GET_FLAG(a, global) ? !env->class_def ? env->global_nspc : NULL : env->curr +#include "gack.h" +static GACK(gack_enum) { + const Value v = (Value)map_at(&t->nspc->info->value->map, *(m_uint*)VALUE); + INTERP_PRINTF("%s", v->name); +} + ANN static Type enum_type(const Env env, const Enum_Def edef) { const Type t = type_copy(env->gwion->mp, env->gwion->type[et_int]); t->name = s_name(edef->xid); @@ -233,6 +239,7 @@ ANN static Type enum_type(const Env env, const Enum_Def edef) { add_type(env, env->curr, t); mk_class(env, t, edef->pos); set_tflag(t, tflag_enum); + CHECK_BO(mk_gack(env->gwion->mp, t, gack_enum)); if (global) env_pop(env, 0); // scan0_implicit_similar(env, t, env->gwion->type[et_int]); // scan0_implicit_similar(env, env->gwion->type[et_int], t); -- 2.43.0