regseti(emit, count);
const Instr instr = emit_add_instr(emit, ArrayInit);
instr->m_val = (m_uint)type;
- instr->m_val2 = array_base(type)->size;
+ instr->m_val2 = array_base_simple(type)->size;
emit_gc(emit, -SZ_INT);
emit_notpure(emit);
return GW_OK;
do
if (prim_array_inner(env, type, e, loc) < 0) err = true;
while ((e = e->next));
- if (!err) return array_type(env, array_base(type), type->array_depth + 1);
+ if (!err) return array_type(env, array_base_simple(type), type->array_depth + 1);
env_set_error(env);
return NULL;
}
" This is not allowed in foreach loop"),
et->name)
DECL_OO(Type, base, = typedef_base(et));
- DECL_OO(const Type, t, = array_base(base));
+ DECL_OO(const Type, t, = array_base_simple(base));
const m_uint depth = base->array_depth - 1;
return depth ? array_type(env, t, depth) : t;
}
ANN static inline Type op_parent(const Env env, const Type t) {
const size_t depth = t->array_depth;
- return !depth || !array_base(t)->info->parent
- ? t->info->parent
- : array_type(env, array_base(t)->info->parent, depth);
+ if (!depth)
+ return t->info->parent;
+ const Type base = array_base_simple(t);
+ return !base->info->parent
+ ? t->info->parent
+ : array_type(env, base->info->parent, depth);
}
ANN static Type op_check_inner(const Env env, struct OpChecker *ock,
if (var->array->exp) CHECK_BB(scan1_exp(env, var->array->exp));
CHECK_OB((t = array_type(env, decl->type, var->array->depth)));
}
- if (GET_FLAG(array_base(t), abstract) &&
+ const Type base = array_base_simple(t);
+ if (GET_FLAG(base, abstract) &&
((var->array && var->array->exp) ||
(decl->td->array && decl->td->array->exp)))
ERR_B(var->pos, _("arrays of abstract type '%s' must be declared empty"),
- array_base(t)->name);
+ base->name);
const Value v = var->value =
var->value ?: new_value(env->gwion->mp, t, s_name(var->xid));
nspc_add_value(env->curr, var->xid, v);