if(gwi->gwion->env->class_def && !GET_FLAG(udef, static))
gwi->gwion->env->class_def->nspc->info->offset =
udef->o + udef->s;
- return udef->xid ? udef->value->type :
- udef->type_xid ? udef->type : udef->value->type;
+ if(udef->xid || !udef->type_xid) {
+ SET_FLAG(udef->value, builtin);
+ const M_Object o = new_object(gwi->gwion->mp, NULL, udef->value->type);
+ udef->value->d.ptr = (m_uint*)o;
+ return udef->value->type;
+ }
+ return udef->type;
}
ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) {
GWI_BB(gwi_item_ini(gwi, "int", "@val"))
GWI_BB(gwi_item_end(gwi, 0, NULL))
GWI_BB(gwi_class_end(gwi))
- t_ptr->nspc->info->offset = SZ_INT;
+ t_ptr->nspc->info->offset = SZ_INT; // TODO: should be an assert
GWI_BB(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "Ptr", NULL))
GWI_BB(gwi_oper_add(gwi, opck_ptr_assign))
GWI_BB(gwi_oper_emi(gwi, opem_ptr_assign))
--- /dev/null
+#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, NULL, "my_union"))
+ GWI_BB(gwi_union_add(gwi,"float", "f"))
+ GWI_BB(gwi_union_add(gwi,"int", "i"))
+ GWI_OB(gwi_union_end(gwi, 0))
+ return GW_OK;
+}
--- /dev/null
+<<< my_union >>>;
+<<<my_union.i>>>;
#!/bin/bash
-# [test] #61
+# [test] #62
n=0
[ "$1" ] && n="$1"