-Subproject commit d1d23609b24dc2f754c2808bd23f13100edcc001
+Subproject commit a4e4f7f5955fff6ebb05e90949a54c556dee964e
two,
three
}
- <<< zero, " ", one, " ", two, " ", three >>>;
+ <<< E.zero, " ", E.one, " ", E.two, " ", E.three >>>;
}
var C c;
<<< c >>>;
LOOP_OPTIM
for (m_uint i = 0; i < vector_size(&edef->values); ++i) {
const Value v = (Value)vector_at(&edef->values, i);
- 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;
- }
+ *(m_uint *)(v->from->owner->info->class_data + v->from->offset) = i;
}
set_tflag(edef->t, tflag_emit);
return GW_OK;
}
static GWION_IMPORT(int_values) {
- GWI_BB(gwi_enum_ini(gwi, "bool"))
- GWI_BB(gwi_enum_add(gwi, "false", 0))
- GWI_BB(gwi_enum_add(gwi, "true", 1))
- const Type t_bool = gwi_enum_end(gwi);
+ DECL_OB(const Type, t_bool, = gwi_mk_type(gwi, "bool", SZ_INT, "int"));
+ GWI_BB(gwi_set_global_type(gwi, t_bool, et_bool))
GWI_BB(gwi_gack(gwi, t_bool, gack_bool))
- gwi->gwion->type[et_bool] = t_bool;
+ gwi_item_ini(gwi, "bool", "true");
+ gwi_item_end(gwi, ae_flag_const, num, 0);
+ gwi_item_ini(gwi, "bool", "false");
+ gwi_item_end(gwi, ae_flag_const, num, 1);
GWI_BB(gwi_oper_ini(gwi, NULL, "int", "bool"))
GWI_BB(gwi_oper_add(gwi, opck_unary_meta))
GWI_BB(gwi_oper_add(gwi, opck_int_not))
}
ANN m_bool check_enum_def(const Env env, const Enum_Def edef) {
- 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);
- }
+ const m_uint scope = env_push_type(env, edef->t);
+ ID_List list = edef->list;
+ do decl_static(env, nspc_lookup_value0(env->curr, list->xid));
+ while ((list = list->next));
+ 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;
+ edef->t->nspc = new_nspc(env->gwion->mp, edef->t->name);
+ const Nspc nspc = edef->t->nspc;
+ const m_uint scope = env_push_type(env, edef->t);
ID_List list = edef->list;
do {
- 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) {
nspc_add_value(nspc, list->xid, v);
vector_add(&edef->values, (vtype)v);
} while ((list = list->next));
- if(is_scoped)
- env_pop(env, scope);
+ env_pop(env, scope);
return GW_OK;
}
class C {
- enum MyEnum@ {
+ enum MyEnum {
zero, one
}
}
#! [contains] 1
-enum MyEnum@ {
+enum MyEnum {
zero, one
}
enum E { a, b };
}
-C.a;
-<<< C.a >>>;
-<<< --C.a >>>;
+C.E.a;
+<<< C.E.a >>>;
+<<< --C.E.a >>>;
enum E {
zero, one, two, three
};
-<<< zero, " ", one, " ", two, " ", three >>>;
+<<< E.zero, " ", E.one, " ", E.two, " ", E.three >>>;