m_str name;
struct ValueFrom_ *from;
union value_data{
+ m_uint num;
+ m_float fnum;
m_uint* ptr;
Func func_ref;
} d;
} else {
const m_uint size = v->type->size;
const Instr instr = emit_kind(emit, size, exp_getvar(prim_exp(data)), regpushimm);
- if(!exp_getvar(prim_exp(data)) && size == SZ_INT) {
- if(isa(v->type, emit->gwion->type[et_object]) > 0)
+ if((!exp_getvar(prim_exp(data)) && size == SZ_INT)) {
+ if(isa(v->type, emit->gwion->type[et_object]) > 0 || vflag(v, vflag_enum))
instr->m_val = (m_uint)v->d.ptr;
else if(v->d.ptr)
instr->m_val = *(m_uint*)v->d.ptr;
for(m_uint i = 0; i < vector_size(&edef->values); ++i) {
const Value v = (Value)vector_at(&edef->values, i);
if(!emit->env->class_def) {
- ALLOC_PTR(emit->gwion->mp, addr, m_uint, i);
v->from->offset = emit_local(emit, emit->gwion->type[et_int]);
- v->d.ptr = addr;
+ v->d.num = i;
} else
*(m_bit*)(emit->env->class_def->nspc->info->class_data + v->from->offset) = i;
}
ANN void free_value(Value a, Gwion gwion) {
const Type t = a->type;
+if(!vflag(a, vflag_enum)) {
if(!vflag(a, vflag_func) && a->d.ptr && !vflag(a, vflag_direct) &&
- !(vflag(a, vflag_enum) && vflag(a, vflag_builtin) && a->from->owner_class)
+ !(vflag(a, vflag_builtin) && a->from->owner_class)
&& isa(t, gwion->type[et_object]) < 0)
_mp_free(gwion->mp, t->size, a->d.ptr);
else if(vflag(a, vflag_freeme))
xfree(a->d.ptr);
+}
if(is_class(gwion, t))
type_remref(t, gwion);
mp_free(gwion->mp, ValueFrom, a->from);
CHECK_BB(ck_ok(gwi, ck_edef))
DECL_OB(const ID_List, list, = gwi_str2symlist(gwi, name))
add2list(gwi->ck, list);
- ALLOC_PTR(gwi->gwion->mp, addr, m_int, i);
- vector_add(&gwi->ck->v, (vtype)addr);
+ vector_add(&gwi->ck->v, (vtype)i);
return GW_OK;
}
const Value value = (Value)vector_at(v, i);
const m_uint addr = vector_at(&ck->v, i);
set_vflag(value, vflag_builtin);
-// ADD_REF(value->type); // what ?
- if(!gwi->gwion->env->class_def)
- value->d.ptr = (m_uint*)(addr ? addr : i);
- else
- value->d.ptr = (m_uint*)(addr ? *(m_uint*)addr : i);
+ value->d.num = addr ?: i;
}
// better clean ?
}