eObjectAssign,
eAssign,
eObjectRelease,
+ eObjectRelease2,
eGWOP_EXCEPT,
eAllocMember4,
eDotMember,
#define ObjectAssign (f_instr)eObjectAssign
#define Assign (f_instr)eAssign
#define ObjectRelease (f_instr)eObjectRelease
+#define ObjectRelease2 (f_instr)eObjectRelease2
#define GWOP_EXCEPT (f_instr)eGWOP_EXCEPT
#define AllocMember4 (f_instr)eAllocMember4
#define DotMember (f_instr)eDotMember
gw_out(" {-R}%-14"UINT_F"{0}", instr->m_val);
gw_out("\n");
break;
+ case eObjectRelease2:
+ gw_out("{Y}┃{0}{-}% 4lu{0}: ObjectRelease2", j);
+ gw_out(" {-R}%-14p{0}", instr->m_val);
+ gw_out("\n");
+ break;
case eGWOP_EXCEPT:
gw_out("{Y}┃{0}{-}% 4lu{0}: GWOP_EXCEPT ", j);
gw_out(" {-R}%-14"UINT_F"{0}", instr->m_val);
ObjectAssign
Assign
ObjectRelease~u
+ObjectRelease2~p
GWOP_EXCEPT~u
AllocMember4~u
DotMember~u
ANN static void emit_pop_scope(const Emitter emit) {
m_int offset;
- while ((offset = frame_pop(emit)) > -1) {
+ struct Vector_ v;
+ vector_init(&v);
+ while ((offset = frame_pop(emit)) > -1)
+ vector_add(&v, offset);
+ if(!vector_size(&v))
+ vector_release(&v);
+ else if(vector_size(&v) == 1) {
Instr instr = emit_add_instr(emit, ObjectRelease);
- instr->m_val = (m_uint)offset;
+ instr->m_val = vector_front(&v);
+ vector_release(&v);
+ } else {
+ Instr instr = emit_add_instr(emit, ObjectRelease2);
+ instr->m_val = (m_uint)v.ptr;
}
vector_pop(&emit->info->pure);
if (emit->info->debug) emit_add_instr(emit, DebugPop);
if (!*(m_uint *)REG(-SZ_INT)) handle(shred, "PredicateFail");
}
+static FREEARG(freearg_release) {
+ struct Vector_ v = { .ptr = instr->m_val };
+ vector_release(&v);
+}
+
ANN static m_bool import_core_libs(const Gwi gwi) {
gwidoc(gwi, "one type to rule them all.");
const Type t_class = gwi_mk_type(gwi, "Class", SZ_INT, NULL);
gwi_enum_ini(gwi, "@hidden_enum");
gwi_enum_add(gwi, "@hidden_enum", 0);
gwi_enum_end(gwi);
+
+gwi_register_freearg(gwi, ObjectRelease2, freearg_release);
+
return GW_OK;
}
&&branchnefloat, &&unroll, &&arrayappend, &&autounrollinit, &&autoloop,
&&arraytop, &&arrayaccess, &&arrayget, &&arrayaddr, &&newobj, &&addref,
&&addrefaddr, &&structaddref, &&structaddrefaddr, &&objassign, &&assign,
- &&remref, &&except, &&allocmemberaddr, &&dotmember, &&dotfloat,
+ &&remref, &&remref2, &&except, &&allocmemberaddr, &&dotmember, &&dotfloat,
&&dotother, &&dotaddr, &&unioncheck, &&unionint, &&unionfloat,
&&unionother, &&unionaddr, &&staticint, &&staticfloat, &&staticother,
&&upvalueint, &&upvaluefloat, &&upvalueother, &&upvalueaddr, &&dotfunc,
remref:
release(*(M_Object *)(mem + VAL), shred);
DISPATCH()
+ remref2:
+ struct Vector_ v = { .ptr = (m_uint*)VAL };
+ for(m_uint i = 0; i < vector_size(&v); i++)
+ release(*(M_Object *)(mem + vector_at(&v, i)), shred);
+ DISPATCH()
except:
/* TODO: Refactor except instruction *
* so that *