From b68396841bbab6bf00d8f7b43d6b69ca18bacb13 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 11 Oct 2019 00:09:01 +0200 Subject: [PATCH] :art: Fix member union --- src/emit/emit.c | 5 +---- src/oo/nspc.c | 4 ++-- src/parse/check.c | 2 ++ src/parse/scan0.c | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 5709a02c..1fbe3375 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1420,10 +1420,7 @@ ANN static m_bool emit_union_def(const Emitter emit, const Union_Def udef) { union_allocdata(emit->gwion->mp, udef); SET_FLAG(udef->type, emit); scope = emit_push_type(emit, udef->type); - } else if(emit->env->class_def) {// miss flag ? - if(!GET_FLAG(l->self->d.exp_decl.list->self->value, member)) - udef->o = emit_local(emit, udef->s, 0); - } else if(global) {// miss flag? + } else if(global) { void* ptr = (void*)xcalloc(1, udef->s); l = udef->l; do { diff --git a/src/oo/nspc.c b/src/oo/nspc.c index 5075deca..2dde7770 100644 --- a/src/oo/nspc.c +++ b/src/oo/nspc.c @@ -19,8 +19,8 @@ ANN void nspc_commit(const Nspc nspc) { } ANN static inline void nspc_release_object(const Nspc a, Value value, Gwion gwion) { - if((GET_FLAG(value, static) && a->info->class_data) || - (value->d.ptr && GET_FLAG(value, builtin))) { + if(!GET_FLAG(value, pure) && ((GET_FLAG(value, static) && a->info->class_data) || + (value->d.ptr && GET_FLAG(value, builtin)))) { const M_Object obj = value->d.ptr ? (M_Object)value->d.ptr : *(M_Object*)(a->info->class_data + value->from->offset); release(obj, gwion->vm->cleaner_shred); diff --git a/src/parse/check.c b/src/parse/check.c index ffc0065b..6ce23e61 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1145,6 +1145,8 @@ ANN m_bool check_union_def(const Env env, const Union_Def udef) { check_udef(env, udef); const m_uint scope = union_push(env, udef); const m_bool ret = check_union_decl(env, udef); + if(!udef->xid && !udef->type_xid && env->class_def && !GET_FLAG(udef, static)) + env->class_def->nspc->info->offset = udef->o + udef->s; union_pop(env, udef, scope); return ret; } diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 5a2468a8..85cdb991 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -276,7 +276,7 @@ ANN m_bool scan0_union_def(const Env env, const Union_Def udef) { valuefrom(env, udef->value->from); nspc_add_value(nspc, sym, udef->value); add_type(env, nspc, t); - SET_FLAG(udef->value, checked | udef->flag); + SET_FLAG(udef->value, checked | ae_flag_pure | udef->flag); SET_FLAG(t, scan1 | ae_flag_union); } if(udef->tmpl) { -- 2.43.0