LOOP_OPTIM
for (m_uint i = 0; i < vector_size(&edef->values); ++i) {
const Value v = (Value)vector_at(&edef->values, i);
- if (!emit->env->class_def) {
+ if(edef->is_scoped || emit->env->class_def)
+ *(m_uint *)(v->from->owner->info->class_data + v->from->offset) = i;
+ else {
v->from->offset = emit_local(emit, emit->gwion->type[et_int]);
v->d.num = i;
- } else
- *(m_uint *)(emit->env->class_def->nspc->info->class_data +
- v->from->offset) = i;
+ }
}
set_tflag(edef->t, tflag_emit);
return GW_OK;
}
ANN m_bool check_enum_def(const Env env, const Enum_Def edef) {
- if (env->class_def) {
+ const bool is_scoped = edef->is_scoped;
+ const m_uint scope = is_scoped ?
+ env_push_type(env, edef->t) : 0;
+ if (is_scoped || env->class_def) {
ID_List list = edef->list;
do decl_static(env, nspc_lookup_value0(env->curr, list->xid));
while ((list = list->next));
}
+ if (is_scoped) {
+ env_pop(env, scope);
+ nspc_allocdata(env->gwion->mp, edef->t->nspc);
+ }
return GW_OK;
}
}
ANN m_bool scan1_enum_def(const Env env, const Enum_Def edef) {
+ const m_bool is_scoped = edef->is_scoped;
+ if(is_scoped)
+ edef->t->nspc = new_nspc(env->gwion->mp, edef->t->name);
+ const Nspc nspc = is_scoped ?
+ edef->t->nspc : edef->t->info->value->from->owner;
+ const m_uint scope = is_scoped ?
+ env_push_type(env, edef->t) : 0;
ID_List list = edef->list;
do {
- CHECK_BB(already_defined(env, list->xid, edef->pos));
- if (nspc_lookup_value1(edef->t->info->value->from->owner, list->xid))
- ERR_B(edef->pos, "'%s' already defined", s_name(list->xid));
+ if(!is_scoped) {
+ CHECK_BB(already_defined(env, list->xid, edef->pos));
+ if (nspc_lookup_value1(nspc, list->xid))
+ ERR_B(edef->pos, "'%s' already defined", s_name(list->xid));
+ }
const Value v = new_value(env->gwion->mp, edef->t, s_name(list->xid));
valuefrom(env, v->from, edef->pos);
if (env->class_def) {
set_vflag(v, vflag_builtin);
SET_FLAG(v, const);
set_vflag(v, vflag_valid);
- nspc_add_value(edef->t->info->value->from->owner, list->xid, v);
+ nspc_add_value(nspc, list->xid, v);
vector_add(&edef->values, (vtype)v);
} while ((list = list->next));
+ if(is_scoped)
+ env_pop(env, scope);
return GW_OK;
}