]> Nishi Git Mirror - gwion.git/commitdiff
:art: imporovments
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 3 Nov 2019 22:53:27 +0000 (23:53 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 3 Nov 2019 22:53:27 +0000 (23:53 +0100)
14 files changed:
include/import.h
include/import/cdef.h [moved from include/import/class.h with 100% similarity]
include/import/edef.h [moved from include/import/enum.h with 100% similarity]
include/import/fdef.h [moved from include/import/func.h with 100% similarity]
include/import/internals.h
include/import/tdef.h [moved from include/import/typedef.h with 100% similarity]
include/import/type.h [new file with mode: 0644]
include/import/udef.h [new file with mode: 0644]
src/import/cdef.c [moved from src/import/class.c with 100% similarity]
src/import/fdef.c [moved from src/import/func.c with 100% similarity]
src/import/internals.c
src/import/tdef.c [moved from src/import/typedef.c with 100% similarity]
src/import/udef.c [moved from src/import/union.c with 98% similarity]
tests/tree/force_type.gw [new file with mode: 0644]

index 8a6ecd9239540102246eaa5211881d87ffcc8f24..d11c2e9dff2f4d589a4c20a85d3ad3edf42b0b89 100644 (file)
@@ -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);
similarity index 100%
rename from include/import/class.h
rename to include/import/cdef.h
similarity index 100%
rename from include/import/enum.h
rename to include/import/edef.h
similarity index 100%
rename from include/import/func.h
rename to include/import/fdef.h
index 4ec5795487b664f707707dd02b63327314a633b0..09aa34fb636f8251c3a1682fca9648088c6f6128 100644 (file)
@@ -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/type.h b/include/import/type.h
new file mode 100644 (file)
index 0000000..a3b04ad
--- /dev/null
@@ -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 (file)
index 0000000..d74200e
--- /dev/null
@@ -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
similarity index 100%
rename from src/import/class.c
rename to src/import/cdef.c
similarity index 100%
rename from src/import/func.c
rename to src/import/fdef.c
index 72b1d2409f44eb344f2592b946b08a16aa1a4cae..ea13b36875bde5278ebdf65741dbc63f4768c084 100644 (file)
@@ -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);
 }
similarity index 100%
rename from src/import/typedef.c
rename to src/import/tdef.c
similarity index 98%
rename from src/import/union.c
rename to src/import/udef.c
index bf5242c55ac19e291be0f64d918bcc32e9dc8909..e30c9c6bb945eeeee245297a64ef6a7014a53fcc 100644 (file)
@@ -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 (file)
index 0000000..776b493
--- /dev/null
@@ -0,0 +1,6 @@
+class C {
+  int i;
+}
+
+C c;
+c $ C;