]> Nishi Git Mirror - gwion.git/commitdiff
:art: Update
authorfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 4 Nov 2019 14:50:14 +0000 (15:50 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 4 Nov 2019 14:50:14 +0000 (15:50 +0100)
src/import/udef.c
tests/import/checker.c
tests/import/func_fail2.c
tests/import/func_fail3.c
tests/import/union_tmpl_fail3.c [new file with mode: 0644]

index 24412fb1f7a5707904da46f4594ab2c66effd39e..81ee88277bf3853778f0b54098bf858498e86aba 100644 (file)
@@ -32,8 +32,7 @@ ANN Exp make_exp(const Gwi gwi, const m_str type, const m_str name) {
 ANN2(1) m_int gwi_union_ini(const Gwi gwi, const m_str type, const m_str name) {
   CHECK_BB(ck_ini(gwi, ck_udef))
   if(name)
-    CHECK_OB((gwi->ck->sym = str2sym(gwi, name)))
-//  gwi->ck->name = name;
+    CHECK_OB((gwi->ck->xid = str2sym(gwi, name)))
   gwi->ck->name = type;
   if(type)
     CHECK_BB(check_typename_def(gwi, gwi->ck))
@@ -74,7 +73,12 @@ ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) {
   udef->flag = flag;
   udef->xid = gwi->ck->xid;
   udef->type_xid = gwi->ck->sym;
+//  udef->xid = gwi->ck->sym;
+//  udef->type_xid = gwi->ck->xid;
+printf("%p\n", gwi->ck->xid);
   if(gwi->ck->tmpl) {
+if(udef->xid)
+printf("xid %s\n", s_name(udef->xid));
     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);
@@ -92,4 +96,5 @@ ANN void ck_clean_udef(MemPool mp, ImportCK* ck) {
     free_decl_list(mp, ck->list);
   if(ck->tmpl)
     free_id_list(mp, ck->tmpl);
+// do we miss ck->td ?
 }
index 33d19b2d0a8252a3d2bb67a8bae0f6cdba4a513e..72756d9287d23176ace2679795a04c2cbe015280 100644 (file)
@@ -13,6 +13,6 @@
 #include "gwi.h"
 
 GWION_IMPORT(checker) {
-  CHECK_BB(tmpl_valid(gwi, "<l"))
+  CHECK_OB(tmpl_valid(gwi, "<l"))
   return GW_OK;
 }
index ffaa5daa2214b260e3beef4d2ba5793bc9737995..ce023ed021c5d0b06c598d66aa2ddf1aafa98bd7 100644 (file)
@@ -13,7 +13,7 @@
 #include "instr.h"
 
 GWION_IMPORT(too_many_args) {
-  GWI_BB(gwi_func_ini(gwi, "int", "test"))
+  GWI_BB(gwi_func_ini(gwi, "Ptr<~int~>", "test"))
   GWI_BB(gwi_func_arg(gwi, "int", "i[][]"))
   GWI_BB(gwi_func_arg(gwi, "int", "me"))
   GWI_BB(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
index ed79d1bcb73b5b1e3199f0b0cad5f6921bf16908..56ff79a65099324f2af5256dbf52958b4671712c 100644 (file)
@@ -13,7 +13,7 @@
 #include "instr.h"
 
 GWION_IMPORT(too_many_args) {
-  GWI_BB(gwi_func_ini(gwi, "int", "test"))
+  GWI_BB(gwi_func_ini(gwi, "Ptr<~int~>", "test<~A~>"))
   GWI_BB(gwi_func_ini(gwi, "int", "test"))
   GWI_BB(gwi_func_arg(gwi, "int", "i[][]"))
   GWI_BB(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
diff --git a/tests/import/union_tmpl_fail3.c b/tests/import/union_tmpl_fail3.c
new file mode 100644 (file)
index 0000000..12d2530
--- /dev/null
@@ -0,0 +1,21 @@
+#include "gwion_util.h"
+#include "gwion_ast.h"
+#include "oo.h"
+#include "vm.h"
+#include "env.h"
+#include "type.h"
+#include "object.h"
+#include "instr.h"
+#include "gwion.h"
+#include "value.h"
+#include "operator.h"
+#include "import.h"
+
+GWION_IMPORT(union_test) {
+  GWI_BB(gwi_union_ini(gwi, "U<~A~>", "Test"))
+  GWI_BB(gwi_union_add(gwi,"float", "f"))
+  GWI_BB(gwi_union_add(gwi,"int", "i"))
+  GWI_BB(gwi_union_add(gwi,"A", "a"))
+  GWI_OB(gwi_union_end(gwi, 0))
+  return GW_OK;
+}