]> Nishi Git Mirror - gwion.git/commitdiff
:art: Improve Union
authorfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 20 Sep 2019 14:47:28 +0000 (16:47 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 20 Sep 2019 14:47:28 +0000 (16:47 +0200)
ast
examples/union.gw
src/lib/ptr.c
src/parse/check.c
tests/error/union_array_empty.gw
tests/error/union_invalid.gw [deleted file]
tests/error/union_object_ref.gw [deleted file]
tests/match/tuple.gw [moved from tests/match/tuple.c with 100% similarity]

diff --git a/ast b/ast
index 1bab5b098155c763f48164a1aae5e450797f36b7..59f147324289f644940968e3125cef2bde3a3f94 160000 (submodule)
--- a/ast
+++ b/ast
@@ -1 +1 @@
-Subproject commit 1bab5b098155c763f48164a1aae5e450797f36b7
+Subproject commit 59f147324289f644940968e3125cef2bde3a3f94
index a20847217c949f035e1e5de3192b53275a58632e..b20c5517ac8ed202e6bf8d49102fa4ee1a90dde3 100644 (file)
@@ -1,7 +1,6 @@
 union
 {
        int i;
-       Object @ o;
-
+       Object o;
 };
 <<< i, " ", o >>>;
index 80d571d2ed77c9e661d08aa06d67f0cfa3757786..183a867fa40c1ea7a0073b7d709311f26a4f21bf 100644 (file)
@@ -34,7 +34,9 @@ static INSTR(instr_ptr_assign) {
 }
 
 static OP_EMIT(opem_ptr_assign) {
-  emit_add_instr(emit, GWOP_EXCEPT);
+  const Exp_Binary* bin = (Exp_Binary*)data;
+  if(!GET_FLAG(bin->rhs->type, nonnull))
+    emit_add_instr(emit, GWOP_EXCEPT);
   return emit_add_instr(emit, instr_ptr_assign);
 }
 
index f6fbbb71f312961d2849cf182d16f5513b3ea6be..a9851dc74ea4a2c122b0d133b7be8a5173d77daa 100644 (file)
@@ -1129,9 +1129,6 @@ ANN m_bool check_union_def(const Env env, const Union_Def udef) {
   do {
     CHECK_OB(check_exp(env, l->self))
     if(isa(l->self->type, t_object) > 0) {
-        if(!GET_FLAG(l->self->d.exp_decl.td, ref) && !GET_FLAG(udef->type, template))
-      ERR_B(l->self->pos, _("In union, Objects must be declared as reference (use '@')"))
-//      SET_FLAG(l->self->d.exp_decl.td, ref);
       Var_Decl_List list = l->self->d.exp_decl.list;
       do SET_FLAG(list->self->value, pure);
       while((list = list->next));
index cfc880ea942f90aa62c19e63acee2e5b4b59addc..d62b538d09b99ebefdf6cf84f3f8c7671def51df 100644 (file)
@@ -1,5 +1,5 @@
 #! [contains] must be defined with empty
 union {
   int i;
-  int @array[4];
+  int array[4];
 };
diff --git a/tests/error/union_invalid.gw b/tests/error/union_invalid.gw
deleted file mode 100644 (file)
index b170fa0..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#! [contains] Unions should only contain declarations
- union
-{
-  one; two;
-};
diff --git a/tests/error/union_object_ref.gw b/tests/error/union_object_ref.gw
deleted file mode 100644 (file)
index e006098..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#! [contains] In union, Objects must be declared as reference (use '@')
-union
-{
-       int i;
-       Object o;
-
-};
-<<< i, " ", o >>>;
similarity index 100%
rename from tests/match/tuple.c
rename to tests/match/tuple.gw