m_bool run;
};
-ANN m_bool envset_run(struct EnvSet *es, const Type t);
-ANN m_bool envset_push(struct EnvSet *es, const Type t);
-ANN void envset_pop(struct EnvSet *es, const Type t);
+ANN m_bool envset_run(struct EnvSet*, const Type);
+ANN2(1,3) m_bool envset_push(struct EnvSet*, const Type, const Nspc);
+ANN2(1) void envset_pop(struct EnvSet*, const Type);
#endif
const m_uint scope = emit->env->scope->depth;
struct EnvSet es = { .env=emit->env, .data=emit, .func=(_exp_func)emit_cdef,
.scope=scope, .flag=ae_flag_emit };
- if(dt->owner_class)
- envset_push(&es, dt->owner_class);
+ CHECK_BB(envset_push(&es, dt->owner_class, dt->owner))
(void)emit_push(emit, dt->owner_class, dt->owner);
const m_bool ret = traverse_emit_func_def(emit, dt->def);
if(es.run)
- envset_pop(&es, dt->owner_class->e->owner_class);
+ envset_pop(&es, dt->owner_class);
emit_pop(emit, scope);
return ret;
}
const size_t scope = emit->env->scope->depth;
struct EnvSet es = { .env=emit->env, .data=emit, .func=(_exp_func)emit_cdef,
.scope=scope, .flag=ae_flag_emit };
- if(v->from->owner_class)
- envset_push(&es, v->from->owner_class);
+ CHECK_BB(envset_push(&es, v->from->owner_class, v->from->owner))
(void)emit_push(emit, v->from->owner_class, v->from->owner);
const m_bool ret = emit_func_def(emit, f->def);
if(es.run)
- envset_pop(&es, v->from->owner_class->e->owner_class);
+ envset_pop(&es, v->from->owner_class);
emit_pop(emit, scope);
return ret > 0 ? push_func_code(emit, f) : GW_ERROR;
}
}
struct EnvSet es = { .env=emit->env, .data=emit, .func=(_exp_func)emit_cdef,
.scope=emit->env->scope->depth, .flag=ae_flag_emit };
- if(lambda->owner)
- envset_push(&es, lambda->owner);
+ CHECK_BB(envset_push(&es, lambda->owner, lambda->def->base->func->value_ref->from->owner))
const m_bool ret = emit_lambda(emit, lambda);
if(es.run)
envset_pop(&es, lambda->owner);
return GW_OK;
}
-ANN m_bool envset_push(struct EnvSet *es, const Type t) {
- check(es, t);
- if(es->run)
- CHECK_BB(envset_push(es, t->e->owner_class))
+ANN2(1,3) m_bool envset_push(struct EnvSet *es, const Type t, const Nspc nspc) {
+ if(t) {
+ check(es, t);
+ return es->run ? push(es, t) : GW_OK;
+ }
+ if(nspc != es->env->curr) {
+ env_push(es->env, NULL, nspc);
+ es->run = 1;
+ }
return GW_OK;
}
-ANN void envset_pop(struct EnvSet *es, const Type t) {
+ANN2(1) void envset_pop(struct EnvSet *es, const Type t) {
env_pop(es->env, es->scope);
+ if(!t)
+ return;
if(GET_FLAG(t, template))
nspc_pop_type(es->env->gwion->mp, es->env->curr);
if(t->e->owner_class)
- envset_pop(es, t->e->owner_class);
+ envset_pop(es, t);
}
ANN m_bool envset_run(struct EnvSet *es, const Type t) {
const Func_Def fdef = t->e->d.func->def;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef,
.scope=env->scope->depth, .flag=ae_flag_check };
- if((l->owner = t->e->owner_class))
- envset_push(&es, l->owner);
+ l->owner = t->e->owner_class;
+ CHECK_BB(envset_push(&es, l->owner, t->e->owner))
const m_bool ret = _check_lambda(env, l, fdef);
if(es.run)
envset_pop(&es, l->owner);
return a->base.type;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)scan0_cdef,
.scope=env->scope->depth, .flag=ae_flag_scan0 };
- if(t->e->owner_class)
- CHECK_BO(envset_push(&es, t->e->owner_class))
+ CHECK_BO(envset_push(&es, t->e->owner_class, t->e->owner))
a->base.tmpl = mk_tmpl(env, t->e->def->base.tmpl, td->types);
const m_bool ret = _scan_class(env, t, a);
if(es.run)
const m_uint scope = env->scope->depth;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef,
.scope=scope, .flag=ae_flag_check };
- if(v->from->owner_class)
- envset_push(&es, v->from->owner_class);
+ CHECK_BO(envset_push(&es, v->from->owner_class, v->from->owner))
(void)env_push(env, v->from->owner_class, v->from->owner);
if(is_fptr(env->gwion, v->type)) {
const Symbol sym = func_symbol(env, v->from->owner->name, v->name, tmpl_name, 0);
const m_uint scope = env->scope->depth;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef,
.scope=scope, .flag=ae_flag_check };
- if(v->from->owner_class)
- envset_push(&es, v->from->owner_class);
+ CHECK_BO(envset_push(&es, v->from->owner_class, v->from->owner))
(void)env_push(env, v->from->owner_class, v->from->owner);
const m_bool ret = traverse_func_def(env, func->def);
if(es.run)