-Subproject commit 5c6ff39a52550be2956e927091e58470d3cc6dc6
+Subproject commit 40397642ad13c18fc0edc65791b475e29d832d8a
const void *data;
const m_int scope;
const enum tflag flag;
+ Context _ctx;
+ m_str _filename;
bool run;
};
ANN m_bool envset_run(struct EnvSet*, const Type);
ANN2(1,3) m_bool envset_push(struct EnvSet*, const Type, const Nspc);
+ANN static inline m_bool envset_pushv(struct EnvSet *es, const Value v) {
+ return envset_push(es, v->from->owner_class, v->from->owner);
+}
ANN2(1) void envset_pop(struct EnvSet*, const Type);
ANN static inline m_bool extend_push(const Env env, const Type t) {
const size_t scope = emit->env->scope->depth;
struct EnvSet es = { .env=emit->env, .data=emit, .func=(_exp_func)emit_cdef,
.scope=scope, .flag=tflag_emit };
- CHECK_BB(envset_push(&es, v->from->owner_class, v->from->owner));
+ CHECK_BB(envset_pushv(&es, v));
(void)emit_push(emit, v->from->owner_class, v->from->owner);
const m_bool ret = emit_func_def(emit, f->def);
if(es.run)
}
struct EnvSet es = { .env=emit->env, .data=emit, .func=(_exp_func)emit_cdef,
.scope=emit->env->scope->depth, .flag=tflag_emit };
- CHECK_BB(envset_push(&es, lambda->owner, lambda->def->base->func->value_ref->from->owner));
+ CHECK_BB(envset_pushv(&es, lambda->def->base->func->value_ref));
const m_bool ret = emit_lambda(emit, lambda);
if(es.run)
envset_pop(&es, lambda->owner);
return ret;
}
-ANN static m_bool optimize_taill_call(const Emitter emit, const Exp_Call* e) {
+ANN static m_bool optimize_tail_call(const Emitter emit, const Exp_Call* e) {
if(e->args) {
emit_func_args(emit, e);
const Func f = e->func->type->info->func;
if(stmt->val->exp_type == ae_exp_call) {
const Func f = stmt->val->d.exp_call.func->type->info->func;
if(stmt->val->exp_type == ae_exp_call && emit->env->func == f)
- return optimize_taill_call(emit, &stmt->val->d.exp_call);
+ return optimize_tail_call(emit, &stmt->val->d.exp_call);
}
CHECK_BB(emit_exp_pop_next(emit, stmt->val));
}
env_push_type((void*)es->env, t);
if(tflag(t, tflag_tmpl))
CHECK_BB(template_push_types(es->env, t->info->cdef->base.tmpl)); // incorrect templates?
+ es->_ctx = es->env->context;
+ es->_filename = es->env->name;
+ es->env->context = t->info->value->from->ctx;
+ es->env->name = t->info->value->from->filename;
return GW_OK;
}
return GW_OK;
}
-ANN2(1) void envset_pop(struct EnvSet *es, const Type t) {
+ANN2(1) static void _envset_pop(struct EnvSet *es, const Type t) {
if(safe_tflag(t, tflag_tmpl)) // might not be useful
nspc_pop_type(es->env->gwion->mp, es->env->curr);
env_pop(es->env, es->scope);
env_pop(es->env, es->scope);
}
+ANN2(1) void envset_pop(struct EnvSet *es, const Type t) {
+ _envset_pop(es, t);
+ if(es->_ctx)
+ es->env->context = es->_ctx;
+ if(es->_filename)
+ es->env->name = es->_filename;
+}
+
ANN m_bool envset_run(struct EnvSet *es, const Type t) {
check(es, t);
const Type owner_class = t->info->value->from->owner_class;
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)scan0_cdef,
.scope=env->scope->depth, .flag=tflag_scan0 };
const Type owner = t->info->value->from->owner_class;
- CHECK_BO(envset_push(&es, owner, t->info->value->from->owner));
+ CHECK_BO(envset_pushv(&es, t->info->value));
const Type ret = _scan_class(env, &info);
if(es.run)
envset_pop(&es, owner);
if(!fdef->base->ret_type) { // template fptr
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef,
.scope=env->scope->depth, .flag=tflag_check };
- CHECK_BO(envset_push(&es, v->from->owner_class, v->from->owner));
+ CHECK_BO(envset_pushv(&es, v));
func->def->base->fbflag |= fbflag_internal;
const m_bool ret = check_traverse_fdef(env, func->def);
if(es.run)
// if(!fflag(func, fflag_valid)) {
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef,
.scope=env->scope->depth, .flag=tflag_check };
- CHECK_BO(envset_push(&es, func->value_ref->from->owner_class, func->value_ref->from->owner));
+ CHECK_BO(envset_pushv(&es, func->value_ref));
CHECK_BO(check_func_def(env, func->def));
if(es.run)
envset_pop(&es, func->value_ref->from->owner_class);
struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)check_cdef,
.scope=scope, .flag=tflag_check };
struct ResolverArgs ra = {.v = v, .e = exp, .tmpl_name = tmpl_name, .types = types};
- CHECK_BO(envset_push(&es, v->from->owner_class, v->from->owner));
+ CHECK_BO(envset_pushv(&es, v));
(void)env_push(env, v->from->owner_class, v->from->owner);
if(v->from->owner_class && v->from->owner_class->info->cdef->base.tmpl)
(void)template_push_types(env, v->from->owner_class->info->cdef->base.tmpl);