CHECK_BB(pass[1](gwion->env, &ret))
CHECK_BB(ret)
}
- ast_cleaner(gwion, c->ast);
+ if(!arg.global)
+ ast_cleaner(gwion, c->ast);
return GW_OK;
}
#include "traverse.h"
#include "vm.h"
#include "parse.h"
+#include "clean.h"
ANN static struct Env_Scope_ *new_envscope(MemPool p) {
struct Env_Scope_ *a = mp_calloc(p, Env_Scope);
ANN void release_ctx(struct Env_Scope_ *a, struct Gwion_ *gwion) {
const m_uint size = vector_size(&a->known_ctx);
- for(m_uint i = size + 1; --i;)
- context_remref((Context)vector_at(&a->known_ctx, i - 1), gwion);
+ for(m_uint i = size + 1; --i;) {
+ const Context ctx = (Context)vector_at(&a->known_ctx, i - 1);
+ if(!ctx->error && ctx->global)
+ ast_cleaner(gwion, ctx->tree);
+ context_remref(ctx, gwion);
+ }
}
ANN static void free_env_scope(struct Env_Scope_ *a, Gwion gwion) {
return GW_OK;
}
-ANN m_bool scan2_fdef(const Env env, const Func_Def f) {
- const Value overload = nspc_lookup_value2(env->curr, f->base->xid); // try0
+//! use function from parent class as next.
+ANN static void upfunction(const Env env, const Func_Base *fb) {
+ const Value v = find_value(env->class_def->info->parent, fb->xid);
+ if(!v)
+ return;
+ Func func = fb->func;
+ while(func->next && func->next->value_ref->from->owner == env->curr)
+ func = func->next;
+ func->next = v->d.func_ref;
+}
+
+ANN m_bool scan2_fdef(const Env env, const Func_Def fdef) {
+ const Value overload = nspc_lookup_value2(env->curr, fdef->base->xid);
if(overload)
- CHECK_BB(scan2_func_def_overload(env, f, overload))
- return (!tmpl_base(f->base->tmpl) ? scan2_fdef_std : scan2_fdef_tmpl)(env, f, overload);
+ CHECK_BB(scan2_func_def_overload(env, fdef, overload))
+ CHECK_BB((!tmpl_base(fdef->base->tmpl) ? scan2_fdef_std : scan2_fdef_tmpl)(env, fdef, overload))
+ if(env->class_def)
+ upfunction(env, fdef->base);
+ return GW_OK;
}
__attribute__((returns_nonnull))