eBranchNeqFloat,
eDecIntAddr,
eInitLoopCounter,
+ eArrayAppend,
eArrayTop,
eObjectInstantiate,
eRegAddRef,
#define BranchNeqFloat (f_instr)eBranchNeqFloat
#define DecIntAddr (f_instr)eDecIntAddr
#define InitLoopCounter (f_instr)eInitLoopCounter
+#define ArrayAppend (f_instr)eArrayAppend
#define ArrayTop (f_instr)eArrayTop
#define ObjectInstantiate (f_instr)eObjectInstantiate
#define RegAddRef (f_instr)eRegAddRef
*(m_uint*)RETURN = ARRAY_CAP(ARRAY(o));
}
-INSTR(ArrayAppend) { GWDEBUG_EXE
- POP_REG(shred, instr->m_val);
- const M_Object o = *(M_Object*)REG(-SZ_INT);
- if(!o)
- Except(shred, "NullPtrException");
- m_vector_add(ARRAY(o), REG(0));
- release(o, shred);
- *(M_Object*)REG(-SZ_INT) = o;
-}
-
ANN static Type get_array_type(Type t) {
while(t->d.base_type)
t = t->d.base_type;
static OP_EMIT(opem_array_shift) {
const Exp_Binary* bin = (Exp_Binary*)data;
const Type type = bin->rhs->type;
- Instr instr = emit_add_instr(emit, ArrayAppend);
- instr->m_val = type->size;
+ const Instr pop = emit_add_instr(emit, RegPop);
+ pop->m_val = type->size;
+ emit_add_instr(emit, GWOP_EXCEPT);
+ emit_add_instr(emit, ArrayAppend);
return GW_OK;
}
CHECK_BB(gwi_oper_end(gwi, op_ref, ObjectAssign))
CHECK_BB(gwi_oper_add(gwi, opck_array_shift))
CHECK_BB(gwi_oper_emi(gwi, opem_array_shift))
- CHECK_BB(gwi_oper_end(gwi, op_shl, ArrayAppend))
+ CHECK_BB(gwi_oper_end(gwi, op_shl, NULL))
CHECK_BB(gwi_oper_ini(gwi, "Array", "Array", NULL))
CHECK_BB(gwi_oper_add(gwi, opck_array_cast))
CHECK_BB(gwi_oper_emi(gwi, opem_basic_cast))
#include "value.h"
#include "gack.h"
+#include "array.h"
static inline uint64_t splitmix64_stateless(uint64_t index) {
&&sporkini, &&sporkini, &&sporkfunc, &&sporkthis, &&sporkexp, &&forkend, &&sporkend,
&&brancheqint, &&branchneint, &&brancheqfloat, &&branchnefloat,
&&decintaddr, &&initloop,
- &&arraytop, &&newobj,
+ &&arrayappend, &&arraytop, &&newobj,
&&addref, &&assign, &&remref,
&&except, &&allocmemberaddr, &&dotmember, &&dotfloat, &&dotother, &&dotaddr,
&&staticint, &&staticfloat, &&staticother,
reg -= SZ_INT;
(*(m_uint*)instr->m_val) = labs(*(m_int*)reg);
DISPATCH()
+arrayappend:
+ m_vector_add(ARRAY(a.obj), reg);
+ release(a.obj, shred);
+ DISPATCH()
arraytop:
if(*(m_uint*)(reg - SZ_INT * 2) < *(m_uint*)(reg-SZ_INT))
goto newobj;