-Subproject commit 3c3ef7e94a1d508e871d2b6041e0522b57b54039
+Subproject commit 1f6a5431625621eb2619fd63cd2061aee9ea0022
const m_uint size = v->type->size;
const Instr instr = emit_dotstatic(emit, size, exp_getvar(prim_exp(data)));
instr->m_val = (m_uint)&v->d.ptr;
+ // prevent invalid access to global variables
+ if(!exp_getvar(exp_self(prim_self(data))) &&
+ isa(v->type, emit->gwion->type[et_object]) > 0) {
+ const Instr instr = emit_add_instr(emit, GWOP_EXCEPT);
+ instr->m_val = -SZ_INT;
+ // use m_val2 to set some info?
+ }
} else {
const m_uint size = v->type->size;
const Instr instr = emit_regpushimm(emit, size, exp_getvar(prim_exp(data)));
const Instr get = emit_add_instr(emit, ArrayGet);
get->m_val = i * SZ_INT;
get->m_val2 = -SZ_INT;
+ const Instr ex = emit_add_instr(emit, GWOP_EXCEPT);
+ ex->m_val = -SZ_INT;
}
const Instr post_pop = emit_add_instr(emit, RegMove);
post_pop->m_val = -SZ_INT;
}
ANN static void array_finish(const Emitter emit, const m_uint depth,
- const m_uint size, const m_bool is_var) {
+ const Type t, const m_bool is_var) {
const Instr get = emit_add_instr(emit, is_var ? ArrayAddr : ArrayGet);
+ // determine if we have an object here
+ if(!is_var) {
+ const m_uint _depth = get_depth(t);
+ if(_depth < depth || isa(array_base(t), emit->gwion->type[et_object]) > 0)
+ emit_add_instr(emit, GWOP_EXCEPT);
+ }
get->m_val = depth * SZ_INT;
// emit_add_instr(emit, ArrayValid);
const Instr push = emit_add_instr(emit, RegMove);
- push->m_val = is_var ? SZ_INT : size;
+ push->m_val = is_var ? SZ_INT : t->size;
}
ANN static inline m_bool array_do(const Emitter emit, const Array_Sub array,
// emit_gc(emit, -SZ_INT);
CHECK_BB(emit_exp(emit, array->exp));
array_loop(emit, array->depth);
- array_finish(emit, array->depth, array->type->size, is_var);
+ array_finish(emit, array->depth, array->type, is_var);
return GW_OK;
}
const Instr instr = emit_add_instr(emit, RegPushImm);
instr->m_val = (m_uint)value->type;
}
- if (GET_FLAG(value, late) && !exp_getvar(exp_self(member))) {
+ if(isa(value->type, emit->gwion->type[et_object]) > 0 &&
+ !exp_getvar(exp_self(member)) &&
+ (GET_FLAG(value, static) || GET_FLAG(value, late))) {
const Instr instr = emit_add_instr(emit, GWOP_EXCEPT);
instr->m_val = -SZ_INT;
}
const Vector v = &emit->code->instr;
const Instr back = (Instr)vector_back(v);
if (back->opcode == eGWOP_EXCEPT) {
- vector_pop(v);
- mp_free(emit->gwion->mp, Instr, back);
- emit_add_instr(emit, IntNot);
+ back->opcode = eIntNot;
+// vector_pop(v);
+// mp_free(emit->gwion->mp, Instr, back);
+// emit_add_instr(emit, IntNot);
return GW_OK;
}
const Instr instr = emit_add_instr(emit, RegSetImm);