From: fennecdjay Date: Sun, 3 Nov 2019 22:53:27 +0000 (+0100) Subject: :art: imporovments X-Git-Tag: nightly~2116^2~11 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=98bfeceefb8052e2e2b4d5d6a221000479c064e7;p=gwion.git :art: imporovments --- diff --git a/include/import.h b/include/import.h index 8a6ecd92..d11c2e9d 100644 --- a/include/import.h +++ b/include/import.h @@ -1,8 +1,6 @@ #ifndef __IMPORT #define __IMPORT -#define DLARG_MAX 6 - typedef void (*f_xtor)(const M_Object, const m_bit*, const VM_Shred); typedef void (*f_mfun)(const M_Object, const m_bit*, const VM_Shred); typedef void (*f_sfun)(const m_bit*, const m_bit*, const VM_Shred); @@ -30,31 +28,18 @@ typedef struct Gwi_* Gwi; #define _CHECK_OP(op, check, func)\ GWI_BB(gwi_oper_add(gwi, opck_##check))\ GWI_BB(gwi_oper_end(gwi, op, func)) -#define GWI_LOC new_loc(gwi->gwion->mp, __LINE__) - - -ANN VM* gwi_vm(const Gwi); -ANN2(1,2) ANEW Type gwi_mk_type(const Gwi, const m_str, const m_uint, const m_str); -ANN m_int gwi_add_type(const Gwi gwi, Type type); -ANN m_int gwi_set_global_type(const Gwi gwi, const Type type, const type_enum te); -ANN m_bool gwi_gack(const Gwi gwi, const Type type, const f_gack d); #include "import/checker.h" - -#include "import/class.h" +#include "import/type.h" +#include "import/cdef.h" #include "import/item.h" - -#include "import/typedef.h" - -ANN2(1) m_int gwi_union_ini(const Gwi gwi, const m_str type, const m_str name); -ANN m_int gwi_union_add(const Gwi gwi, const __restrict__ m_str type, const __restrict__ m_str name); -ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag); -ANN void ck_clean_udef(MemPool, ImportCK*); -#include "import/enum.h" -#include "import/func.h" - +#include "import/tdef.h" +#include "import/udef.h" +#include "import/edef.h" +#include "import/fdef.h" #include "import/oper.h" #include "import/special.h" +#include "import/internals.h" OP_CHECK(opck_const_rhs); OP_CHECK(opck_unary_meta); diff --git a/include/import/class.h b/include/import/cdef.h similarity index 100% rename from include/import/class.h rename to include/import/cdef.h diff --git a/include/import/enum.h b/include/import/edef.h similarity index 100% rename from include/import/enum.h rename to include/import/edef.h diff --git a/include/import/func.h b/include/import/fdef.h similarity index 100% rename from include/import/func.h rename to include/import/fdef.h diff --git a/include/import/internals.h b/include/import/internals.h index 4ec57954..09aa34fb 100644 --- a/include/import/internals.h +++ b/include/import/internals.h @@ -11,4 +11,6 @@ ANN void gwi_body(const Gwi, const Class_Body); ANN Exp make_exp(const Gwi gwi, const m_str type, const m_str name); ANN void gwi_reset(const Gwi gwi); +ANN VM* gwi_vm(const Gwi); +ANN m_bool gwi_gack(const Gwi gwi, const Type type, const f_gack d); #endif diff --git a/include/import/typedef.h b/include/import/tdef.h similarity index 100% rename from include/import/typedef.h rename to include/import/tdef.h diff --git a/include/import/type.h b/include/import/type.h new file mode 100644 index 00000000..a3b04adf --- /dev/null +++ b/include/import/type.h @@ -0,0 +1,8 @@ +#ifndef __IMPORT_TYPE +#define __IMPORT_TYPE + +ANN2(1,2) ANEW Type gwi_mk_type(const Gwi, const m_str, const m_uint, const m_str); +ANN m_int gwi_add_type(const Gwi gwi, Type type); +ANN m_int gwi_set_global_type(const Gwi gwi, const Type type, const type_enum te); + +#endif diff --git a/include/import/udef.h b/include/import/udef.h new file mode 100644 index 00000000..d74200eb --- /dev/null +++ b/include/import/udef.h @@ -0,0 +1,9 @@ +#ifndef __IMPORT_UNION +#define __IMPORT_UNION + +ANN2(1) m_int gwi_union_ini(const Gwi gwi, const m_str type, const m_str name); +ANN m_int gwi_union_add(const Gwi gwi, const __restrict__ m_str type, const __restrict__ m_str name); +ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag); +ANN void ck_clean_udef(MemPool, ImportCK*); + +#endif diff --git a/src/import/class.c b/src/import/cdef.c similarity index 100% rename from src/import/class.c rename to src/import/cdef.c diff --git a/src/import/func.c b/src/import/fdef.c similarity index 100% rename from src/import/func.c rename to src/import/fdef.c diff --git a/src/import/internals.c b/src/import/internals.c index 72b1d240..ea13b368 100644 --- a/src/import/internals.c +++ b/src/import/internals.c @@ -23,9 +23,10 @@ void gwi_body(const Gwi gwi, const Class_Body body) { } ANN void gwi_reset(const Gwi gwi) { - if(gwi->ck) + if(gwi->ck) { ck_clean(gwi); - mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck); - gwi->ck = NULL; + mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck); + gwi->ck = NULL; + } env_reset(gwi->gwion->env); } diff --git a/src/import/typedef.c b/src/import/tdef.c similarity index 100% rename from src/import/typedef.c rename to src/import/tdef.c diff --git a/src/import/union.c b/src/import/udef.c similarity index 98% rename from src/import/union.c rename to src/import/udef.c index bf5242c5..e30c9c6b 100644 --- a/src/import/union.c +++ b/src/import/udef.c @@ -70,6 +70,7 @@ ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) { if(!gwi->ck->list) GWI_ERR_O(_("union is empty")); const Union_Def udef = new_union_def(gwi->gwion->mp, gwi->ck->list, loc(gwi)); + gwi->ck->list = NULL; udef->flag = flag; udef->xid = gwi->ck->xid; udef->type_xid = gwi->ck->sym; @@ -77,6 +78,7 @@ ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) { if(udef->xid) GWI_ERR_O(_("Template union type can't declare instance at declaration")); udef->tmpl = new_tmpl(gwi->gwion->mp, gwi->ck->tmpl, -1); + gwi->ck->tmpl = NULL; } const Type t = union_type(gwi, udef); if(!SAFE_FLAG(t, template)) diff --git a/tests/tree/force_type.gw b/tests/tree/force_type.gw new file mode 100644 index 00000000..776b493d --- /dev/null +++ b/tests/tree/force_type.gw @@ -0,0 +1,6 @@ +class C { + int i; +} + +C c; +c $ C;