From e2fcf0f0c1464e70b711cb6311c71e546ee354ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 3 Aug 2021 22:31:44 +0200 Subject: [PATCH] :bug: fix enum (and add @hidden_enum) --- include/import/edef.h | 3 ++- src/emit/emit.c | 2 +- src/import/import_enum.c | 6 ++++-- src/lib/engine.c | 3 +++ src/lib/prim.c | 4 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/import/edef.h b/include/import/edef.h index 48c13ff7..b458033b 100644 --- a/include/import/edef.h +++ b/include/import/edef.h @@ -1,7 +1,8 @@ #ifndef __IMPORT_ENUM #define __IMPORT_ENUM -ANN2(1) m_int gwi_enum_ini(const Gwi gwi, const m_str type); +__attribute__ ((visibility ("default"))) +ANN m_int gwi_enum_ini(const Gwi gwi, const m_str type); ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint value); ANN Type gwi_enum_end(const Gwi gwi); ANN void ck_clean_edef(MemPool, ImportCK *); diff --git a/src/emit/emit.c b/src/emit/emit.c index 3644477d..bfd6fb87 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -2210,7 +2210,7 @@ ANN static m_bool emit_type_def(const Emitter emit, const Type_Def tdef) { : GW_OK; } -ANN static m_bool emit_enum_def(const Emitter emit, const Enum_Def edef) { +ANN static m_bool emit_enum_def(const Emitter emit NUSED, const Enum_Def edef) { LOOP_OPTIM for (m_uint i = 0; i < vector_size(&edef->values); ++i) { const Value v = (Value)vector_at(&edef->values, i); diff --git a/src/import/import_enum.c b/src/import/import_enum.c index 02f8f79b..c47ca50a 100644 --- a/src/import/import_enum.c +++ b/src/import/import_enum.c @@ -18,9 +18,11 @@ //! \arg the importer //! \arg string defining a primitive type //! why is return type m_int ? -ANN2(1) m_int gwi_enum_ini(const Gwi gwi, const m_str type) { + +__attribute__ ((visibility ("default"))) +ANN m_int gwi_enum_ini(const Gwi gwi, const m_str type) { CHECK_BB(ck_ini(gwi, ck_edef)); - if (type) CHECK_OB((gwi->ck->xid = gwi_str2sym(gwi, type))); + CHECK_OB((gwi->ck->xid = gwi_str2sym(gwi, type))); vector_init(&gwi->ck->v); return GW_OK; } diff --git a/src/lib/engine.c b/src/lib/engine.c index 3f6d8c2a..9acbaba6 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -224,6 +224,9 @@ ANN static m_bool import_core_libs(const Gwi gwi) { GWI_BB(gwi_oper_add(gwi, opck_class_call)) GWI_BB(gwi_oper_end(gwi, "=>", NULL)) +gwi_enum_ini(gwi, "@hidden_enum"); +gwi_enum_add(gwi, "@hidden_enum", 0); +gwi_enum_end(gwi); return GW_OK; } diff --git a/src/lib/prim.c b/src/lib/prim.c index 7edefbb0..23ff6459 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -255,9 +255,9 @@ static GWION_IMPORT(int_values) { GWI_BB(gwi_set_global_type(gwi, t_bool, et_bool)) GWI_BB(gwi_gack(gwi, t_bool, gack_bool)) gwi_item_ini(gwi, "bool", "true"); - gwi_item_end(gwi, ae_flag_const, num, 0); - gwi_item_ini(gwi, "bool", "false"); gwi_item_end(gwi, ae_flag_const, num, 1); + gwi_item_ini(gwi, "bool", "false"); + gwi_item_end(gwi, ae_flag_const, num, 0); GWI_BB(gwi_oper_ini(gwi, NULL, "int", "bool")) GWI_BB(gwi_oper_add(gwi, opck_unary_meta)) GWI_BB(gwi_oper_add(gwi, opck_int_not)) -- 2.43.0