// look mum no pos
struct Op_Import opi = { .op=insert_symbol("@array"), .lhs=info->array.exp->info->type, .rhs=info->array.type,
.data=(uintptr_t)info, .op_type=op_array };
+ if(type_ref(info->array.type)) {
+ const Instr instr = emit_add_instr(emit, GWOP_EXCEPT);
+ instr->m_val = -SZ_INT;
+ }
return op_emit(emit, &opi);
}
return array_type(env, array_base(t), t->array_depth - array->depth);
const Exp curr = take_exp(array->exp, t->array_depth);
struct Array_Sub_ next = { curr->next, array_base(t), array->depth - t->array_depth };
- return check_array_access(env, &next);
-}
-
-static OP_CHECK(opck_not_array) {
- const Array_Sub array = (Array_Sub)data;
- if(array->depth <= get_depth(array->type))
- return array->type;
- ERR_N(array->exp->pos, _("array subscripts (%"UINT_F") exceeds defined dimension (%"UINT_F")"),
- array->depth, get_depth(array->type))
+ return check_array_access(env, &next) ?: env->gwion->type[et_error];
}
ANN static void array_loop(const Emitter emit, const m_uint depth) {
GWI_BB(gwi_oper_add(gwi, opck_array_slice))
GWI_BB(gwi_oper_emi(gwi, opem_array_slice))
GWI_BB(gwi_oper_end(gwi, "@slice", NULL))
- GWI_BB(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, (m_str)OP_ANY_TYPE, NULL))
- GWI_BB(gwi_oper_add(gwi, opck_not_array))
- GWI_BB(gwi_oper_end(gwi, "@array", NULL))
GWI_BB(gwi_oper_ini(gwi, "int", "@Array", NULL))
GWI_BB(gwi_oper_add(gwi, opck_array))
GWI_BB(gwi_oper_emi(gwi, opem_array_access))
}
if(GET_FLAG(value, late) && !exp_getvar(exp_self(member))) {
const Instr instr = emit_add_instr(emit, GWOP_EXCEPT);
- if(!is_fptr(emit->gwion, value->type))
- instr->m_val = -SZ_INT;
+ instr->m_val = -SZ_INT;
}
return GW_OK;
}
}
ANN Type check_array_access(const Env env, const Array_Sub array) {
-// if(!get_depth(array->type))
-// ERR_O(array->exp->pos, _("array subscripts (%"UINT_F") exceeds defined dimension (%"UINT_F")"),
-// array->depth, get_depth(array->type))
const Symbol sym = insert_symbol("@array");
struct Op_Import opi = { .op=sym, .lhs=array->exp->info->type, .rhs=array->type,
.pos=array->exp->pos, .data=(uintptr_t)array, .op_type=op_array };
if(var->array->exp)
CHECK_BB(scan1_exp(env, var->array->exp))
t = array_type(env, decl->type, var->array->depth);
- } else if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, late)) {
- if(!(t == env->class_def && env->scope->depth)) {
-// if(decl->td->xid == insert_symbol("auto"))
- SET_FLAG(decl->td, late);
-// else
-// ERR_B(exp_self(decl)->pos, _("Type '%s' is abstract, declare as ref. (use @)"), t->name)
- }
- }
+ } else if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, late))
+ SET_FLAG(decl->td, late);
const Value v = var->value = var->value ?: new_value(env->gwion->mp, t, s_name(var->xid));
// rewrite logic
if(!env->scope->depth && env->class_def && !GET_FLAG(decl->td, static))
* VAL = offset (no default SZ_INT) *
* VAL2 = error message *
* grep for GWOP_EXCEPT and Except, exception... */
- if(!*(void**)(reg-(m_int)VAL)) {
+ if(!*(m_bit**)(reg+(m_int)(VAL))) {
shred->pc = PC;
exception(shred, "NullPtrException");
continue;
+++ /dev/null
-#! [contains] exceeds defined dimension
-var int i[2];
-i[0][0];