const Type type = nspc_lookup_type1(src->info->owner, sym);
if(type)
return type;
- const Type t = new_type(env->gwion->mp, env->gwion->type[et_array]->xid,
+ const Type t = new_type(env->gwion->mp, ++env->scope->type_xid,
s_name(sym), env->gwion->type[et_array]);
t->array_depth = depth + src->array_depth;
t->info->base_type = array_base(src) ?: src;
mp_free(((Gwion)gwion)->mp, ArrayInfo, info);
}
-static OP_CHECK(opck_not_array) {
- const Array_Sub array = (Array_Sub)data;
- if(get_depth(array->type)) {
- struct Array_Sub_ next = { array->exp, array->type->info->parent, array->depth };
- return check_array_access(env, &next);
- }
- ERR_O(array->exp->pos, _("array subscripts (%"UINT_F") exceeds defined dimension (%"UINT_F")"),
- array->depth, get_depth(array->type))
-}
-
ANN Type check_array_access(const Env env, const Array_Sub array);
static OP_CHECK(opck_array) {
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, "int", (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))
}
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 };