tflag_enum = 1 << 22,
tflag_ref = 1 << 23,
tflag_packed = 1 << 24,
+ tflag_compound = 1 << 25,
} __attribute__((packed));
struct Type_ {
}
ANN void emit_compound_release(const Emitter emit, const Type t, const m_uint offset) {
- if(isa(t, emit->gwion->type[et_compound]) > 0)
+ if(tflag(t, tflag_compound))
return emit_object_release(emit, offset);
emit_struct_release(emit, t, offset);
}
}
ANN m_uint emit_local(const Emitter emit, const Type t) {
- const bool is_compound = isa(t, emit->gwion->type[et_compound]) > 0;
+ const bool is_compound = tflag(t, tflag_compound);
Local *const l = add_local(emit, t, is_compound);
return l->offset;
}
ANN static inline m_bool arrayinfo_ctor(const Emitter emit, ArrayInfo *info) {
const Type base = info->base;
- if (isa(base, emit->gwion->type[et_compound]) > 0 &&
+ if (tflag(base, tflag_compound) &&
!GET_FLAG(base, abstract)) {
CHECK_BB(emit_pre_constructor_array(emit, base));
info->is_obj = 1;
ANN2(1)
static void emit_exp_addref1(const Emitter emit, const Exp exp, m_int size) {
const Type t = exp->cast_to ?: exp->type;
- if (isa(t, emit->gwion->type[et_compound]) > 0)
+ if (tflag(t, tflag_compound))
emit_compound_addref(emit, exp->type, size, exp_getvar(exp));
}
if (stmt->val->exp_type == ae_exp_call && emit->env->func == f)
return optimize_tail_call(emit, &stmt->val->d.exp_call);
}
-// if(!stmt->val->ref && isa(stmt->val->type, emit->gwion->type[et_compound]) > 0)
+// if(!stmt->val->ref && tflag(stmt->val->type, tflag_compound))
// emit_local(emit, stmt->val->type);
emit->status.in_return = true;
CHECK_BB(emit_exp(emit, stmt->val));
static inline void _free_nspc_value(const Nspc a, const Value v, Gwion gwion) {
if(v->from->ctx && v->from->ctx->error) return; // this is quite a hack
- if (isa(v->type, gwion->type[et_compound]) > 0 ) {
+ if (tflag(v->type, tflag_compound) ) {
if (!tflag(v->type, tflag_struct))
nspc_release_object(a, v, gwion);
else nspc_release_struct(a, v, gwion);
}
ANN static Type type_finish(const Gwi gwi, const Type t) {
+ tflag(t, tflag_compound);
gwi_add_type(gwi, t);
import_class_ini(gwi->gwion->env, t);
if (t->info->cdef && t->info->cdef->base.tmpl) {
if (shift_match(bin->lhs->type, bin->rhs->type))
return emit_array_shift(emit, ArrayConcatRight);
emit_regmove(emit, -SZ_INT);
- if (isa(bin->lhs->type, emit->gwion->type[et_compound]) > 0)
+ if (tflag(bin->lhs->type, tflag_compound))
emit_compound_addref(emit, bin->lhs->type, -SZ_INT*2, false);
(void)emit_add_instr(emit, ArrayAppendFront);
return GW_OK;
const Exp_Binary *bin = (Exp_Binary *)data;
if (shift_match(bin->rhs->type, bin->lhs->type))
return emit_array_shift(emit, ArrayConcatLeft);
- if (isa(bin->rhs->type, emit->gwion->type[et_compound]) > 0)
+ if (tflag(bin->rhs->type, tflag_compound))
emit_compound_addref(emit, bin->rhs->type, -SZ_INT, false);
emit_regmove(emit, -bin->rhs->type->size);
emit_add_instr(emit, ArrayAppend);
t->array_depth = base->array_depth + 1;
t->info->base_type = array_base(base);
set_tflag(t, tflag_cdef | tflag_tmpl);
- void *rem = isa(base, env->gwion->type[et_compound]) > 0
+ void *rem = tflag(base, tflag_compound)
? !tflag(base, tflag_struct) ? vm_vector_rem_obj
: vm_vector_rem_struct
: vm_vector_rem;
builtin_func(env->gwion, (Func)vector_at(&t->nspc->vtable, 0), rem);
- void *insert = isa(base, env->gwion->type[et_compound]) > 0
+ void *insert = tflag(base, tflag_compound)
? !tflag(base, tflag_struct) ? vm_vector_insert_obj
: vm_vector_insert_struct
: vm_vector_insert;
array_func(env, t, "foldr", vm_vector_foldr);
// array_func(env, t, "new", vm_vector_new);
- if (isa(base, env->gwion->type[et_compound]) > 0) {
+ if (tflag(base, tflag_compound)) {
t->nspc->dtor = new_vmcode(env->gwion->mp, NULL, NULL,
"array component dtor", SZ_INT, true, false);
set_tflag(t, tflag_dtor);
const Capture_List captures = (*(Func_Def*)caps)->captures;
for(m_uint i = 0; i < captures->len; i++) {
Capture *const cap = mp_vector_at(captures, Capture, i);
- if(isa(cap->temp->type, shred->info->vm->gwion->type[et_compound]) > 0)
+ if(tflag(cap->temp->type, tflag_compound))
compound_release(shred, cap->temp->type, caps + SZ_INT + sz);
sz += cap->temp->type->size;
}
e->type = cap->orig->type;
exp_setvar(e, cap->is_ref);
emit_exp(emit, e);
- if(!cap->is_ref && isa(cap->temp->type, emit->gwion->type[et_compound]) > 0)
+ if(!cap->is_ref && tflag(cap->temp->type, tflag_compound))
emit_compound_addref(emit, cap->temp->type, cap->temp->type->size, 0);
offset += cap->temp->type->size;
}
info->key = key;
info->val = val;
info->sz = key->size + val->size;
- info->keyk = isa(key, types[et_compound]) > 0 + tflag(key, tflag_struct);
- info->valk = isa(val, types[et_compound]) > 0 + tflag(val, tflag_struct);
+ info->keyk = tflag(key, tflag_compound) + tflag(key, tflag_struct);
+ info->valk = tflag(val, tflag_compound) + tflag(val, tflag_struct);
}
static DTOR(dict_clear_dtor) {
const Vector offsets = &base->info->tuple->offset;
for (m_uint i = 0; i < vector_size(types); ++i) {
const Type t = (Type)vector_at(types, i);
- if (isa(t, shred->info->vm->gwion->type[et_compound]) < 0) continue;
+ if (!tflag(t, tflag_compound)) continue;
const m_uint offset = vector_at(offsets, i);
compound_release(shred, t, ptr + offset);
}
if (idx) {
const Map map = &o->type_ref->nspc->info->value->map;
const Value v = (Value)map_at(map, idx - 1);
- if (isa(v->type, shred->info->vm->gwion->type[et_compound]) > 0)
+ if (tflag(v->type, tflag_compound))
compound_release(shred, v->type, (o->data + SZ_INT));
}
}
if (GET_FLAG(exp->d.exp_decl.td, late)) continue;
Var_Decl vd = exp->d.exp_decl.vd;
if (GET_FLAG(vd.value, late)) continue;
- if (isa(vd.value->type, env->gwion->type[et_compound]) > 0)
+ if (tflag(vd.value->type, tflag_compound))
return true;
} else return true;
}
}
if(t != tgt && v->type->nspc && (!GET_FLAG(v, late) || vflag(v, vflag_assigned)) && strncmp(tgt->name, "Option:[", 8) &&
- isa(tgt, env->gwion->type[et_compound]) > 0)
+ tflag(tgt, tflag_compound))
return recursive_type(env, t, tgt);
return false;
bool error = false;
struct scope_iter iter = {t->nspc->info->value, 0, 0};
while (scope_iter(&iter, &value) > 0) {
- if (isa(value->type, env->gwion->type[et_compound]) < 0) continue;
+ if (!tflag(value->type, tflag_compound)) continue;
if (value->type->nspc && (!GET_FLAG(value, late) || vflag(value, vflag_assigned))) {
if(value->type == t || recursive_type(env, t, value->type)) {
env_err(env, value->from->loc, _("recursive type"));
t->size = 0;
set_tflag(t, tflag_struct);
}
+ set_tflag(t, tflag_compound);
t->info->tuple = new_tupleform(env->gwion->mp, parent);
t->nspc = new_nspc(env->gwion->mp, t->name);
t->nspc->parent = env->curr;