ANN m_bool emit_array_extend(const Emitter emit, const Type t, const Exp e) {
CHECK_OB(emit_array_extend_inner(emit, t, e))
emit_add_instr(emit, PopArrayClass);
+ emit_add_instr(emit, RegAddRef);
return GW_OK;
}
assert(stmt->data.v.ptr);
const m_uint size = vector_size(&stmt->data.v);
if(!size)
+//return GW_OK;
ERR_B(stmt_self(stmt)->pos, _("label '%s' defined but not used."), s_name(stmt->name))
LOOP_OPTIM
for(m_uint i = size + 1; --i;) {
const Func func = f->base->func;
const Func_Def fdef = func->def;
const Func former = emit->env->func;
- if(tmpl_base(fdef->base->tmpl))
+ if(func->code || tmpl_base(fdef->base->tmpl))
return GW_OK;
if(SAFE_FLAG(emit->env->class_def, builtin) && GET_FLAG(emit->env->class_def, template))
return GW_OK;
if(scanx_body(emit->env, cdef, (_exp_func)emit_section, emit) > 0)
emit_class_finish(emit, t->nspc);
else {
+ free_code(emit->gwion->mp, emit->code);
emit_pop_code(emit);
return GW_ERROR;
}
static DTOR(array_dtor) {
const Type t = !GET_FLAG(o->type_ref, nonnull) ?
o->type_ref : o->type_ref->e->parent;
+ if(*(void**)(o->data + SZ_INT))
+ xfree(*(void**)(o->data + SZ_INT));
struct M_Vector_* a = ARRAY(o);
if(!a)
return;
gwi_class_xtor(gwi, NULL, array_dtor);
GWI_BB(gwi_item_ini(gwi, "@internal", "@array"))
GWI_BB(gwi_item_end(gwi, 0, NULL))
+ GWI_BB(gwi_item_ini(gwi, "@internal", "@ctor_data"))
+ GWI_BB(gwi_item_end(gwi, 0, NULL))
GWI_BB(gwi_func_ini(gwi, "int", "size"))
GWI_BB(gwi_func_end(gwi, vm_vector_size, ae_flag_none))
INSTR(ArrayPost) {
xfree(*(m_uint**)REG(0));
+ const M_Object o = *(M_Object*)(REG(-SZ_INT));
+ *(m_uint*)(o->data + SZ_INT) = 0;
}
INSTR(ArrayInit) {// for litteral array
vm_shred_exit(shred);
return; // TODO make exception vararg
}
+ *(void**)(ref->data + SZ_INT) = aai.data;
+ vector_add(&shred->gc, ref);
if(!is_obj) {
POP_REG(shred, SZ_INT * (info->depth - 1));
*(M_Object*)REG(-SZ_INT) = ref;
" This is not allowed in auto loop"), stmt->exp->info->type->name)
if(stmt->is_ptr) {
struct Type_List_ tl = {};
- struct Array_Sub_ array = {};
Type_Decl *td0 = type2td(env, ptr, stmt->exp->pos),
td = { .xid=insert_symbol("Ptr"), .types=&tl, .pos=stmt->exp->pos };
tl.td = td0;
- if(depth) {
- array.depth = depth;
- td0->array = &array;
- }
ptr = known_type(env, &td);
+ if(depth)
+ ptr = array_type(env, ptr, depth);
td0->array = NULL;
free_type_decl(env->gwion->mp, td0);
const Type base = get_type(ptr);