From 2143d558c6da82d36f19ad491e56a26ac87407ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 8 Jan 2021 11:23:33 +0100 Subject: [PATCH] :art: Clear Value flags --- include/env/value.h | 15 ++++++--------- src/emit/emit.c | 2 +- src/env/nspc.c | 6 +++--- src/lib/object.c | 15 ++------------- src/parse/scan1.c | 4 ++-- 5 files changed, 14 insertions(+), 28 deletions(-) diff --git a/include/env/value.h b/include/env/value.h index db136b84..6d845011 100644 --- a/include/env/value.h +++ b/include/env/value.h @@ -10,15 +10,12 @@ struct ValueFrom_ { enum vflag { vflag_none = 1 << 0, vflag_func = 1 << 1, - vflag_union = 1 << 2, - vflag_enum = 1 << 3, - vflag_freeme = 1 << 4, - vflag_fglobal = 1 << 5, - vflag_valid = 1 << 6, - vflag_direct = 1 << 7, - vflag_builtin = 1 << 8, - vflag_member = 1 << 9, - vflag_closed = 1 << 10 + vflag_fglobal = 1 << 2, + vflag_valid = 1 << 3, + vflag_direct = 1 << 4, + vflag_builtin = 1 << 5, + vflag_member = 1 << 6, + vflag_closed = 1 << 7 // vflag_used = 1 << 3 } __attribute__((packed)); diff --git a/src/emit/emit.c b/src/emit/emit.c index 8b54391b..310655c1 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -410,7 +410,7 @@ ANN static m_bool _emit_symbol(const Emitter emit, const Symbol *data) { regpushi(emit, (m_uint)actual_type(emit->gwion, v->type)); return GW_OK; } - if(vflag(v, vflag_builtin) || vflag(v, vflag_direct) || vflag(v, vflag_enum)) + if(vflag(v, vflag_builtin) || vflag(v, vflag_direct)) return emit_symbol_builtin(emit, data); if(!strncmp(v->type->name, "@Foreach:[", 10)) { if(exp_getvar(exp_self(prim_self(data)))) { diff --git a/src/env/nspc.c b/src/env/nspc.c index a528cf64..247cc17f 100644 --- a/src/env/nspc.c +++ b/src/env/nspc.c @@ -13,8 +13,8 @@ ANN void nspc_commit(const Nspc nspc) { } ANN static inline void nspc_release_object(const Nspc a, Value value, Gwion gwion) { - if(!vflag(value, vflag_union) && ((GET_FLAG(value, static) && a->info->class_data) || - (value->d.ptr && vflag(value, vflag_builtin)))) { + if((GET_FLAG(value, static) && a->info->class_data) || + (value->d.ptr && vflag(value, vflag_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); @@ -22,7 +22,7 @@ ANN static inline void nspc_release_object(const Nspc a, Value value, Gwion gwio } ANN2(1,3) static inline void nspc_release_struct(const Nspc a, Value value, Gwion gwion) { - if(value && !vflag(value, vflag_union) && ((GET_FLAG(value, static) && a->info->class_data) || + if(value && ((GET_FLAG(value, static) && a->info->class_data) || (vflag(value, vflag_builtin) && value->d.ptr))) { const m_bit *ptr = (value && value->d.ptr) ? (m_bit*)value->d.ptr: (m_bit*)(a->info->class_data + value->from->offset); diff --git a/src/lib/object.c b/src/lib/object.c index 1459b04d..f7ab81ac 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -72,19 +72,8 @@ ANN void __release(const M_Object o, const VM_Shred shred) { struct scope_iter iter = { t->nspc->info->value, 0, 0 };\ Value v; while(scope_iter(&iter, &v) > 0) { - if(!GET_FLAG(v, static) && !vflag(v, vflag_union) && - isa(v->type, shred->info->vm->gwion->type[et_object]) > 0) - release(*(M_Object*)(o->data + v->from->offset), shred); - else if(tflag(v->type, tflag_struct) && - !GET_FLAG(v, static) && !vflag(v, vflag_union) && v->type->info->tuple) { - const TupleForm tf = v->type->info->tuple; - for(m_uint i = 0; i < vector_size(&tf->types); ++i) { - const m_bit *data = o->data + v->from->offset; - const Type t = (Type)vector_at(&tf->types, i); - if(isa(t, shred->info->vm->gwion->type[et_object]) > 0) - release(*(M_Object*)(data + vector_at(&tf->offset, i)), shred); - } - } + if(!GET_FLAG(v, static) && isa(v->type, shred->info->vm->gwion->type[et_compound]) > 0) + compound_release(shred, v->type, o->data + v->from->offset); } } if(tflag(t, tflag_dtor) && t->nspc->dtor) { diff --git a/src/parse/scan1.c b/src/parse/scan1.c index a5766604..5625bef6 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -324,10 +324,10 @@ ANN m_bool scan1_enum_def(const Env env, const Enum_Def edef) { SET_FLAG(v, static); SET_ACCESS(edef, v) SET_ACCESS(edef, edef->t) - } + } else + set_vflag(v, vflag_builtin); SET_FLAG(v, const); set_vflag(v, vflag_valid); - set_vflag(v, vflag_enum); nspc_add_value(edef->t->info->owner, list->xid, v); vector_add(&edef->values, (vtype)v); } while((list = list->next)); -- 2.43.0