From: Jérémie Astor Date: Sat, 30 Apr 2022 18:28:20 +0000 (+0200) Subject: cleaning, global context scope X-Git-Tag: nightly~275^2~8 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=1ca1d4aa8bf31613254a36b5d11f2e3428a360d0;p=gwion.git cleaning, global context scope --- diff --git a/ast b/ast index c296c9b9..e09543b3 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit c296c9b96cd54440f1dbaf7073c92ed62f82f298 +Subproject commit e09543b39ec51dc344d74dd2c1adb415957c6b5a diff --git a/src/env/context.c b/src/env/context.c index 641633c7..b0c9c58d 100644 --- a/src/env/context.c +++ b/src/env/context.c @@ -22,14 +22,24 @@ ANN2(1,3) Context new_context(MemPool p, const Ast ast, const m_str str) { } ANN void load_context(const Context context, const Env env) { + const Nspc global = new_nspc(env->gwion->mp, context->name); + global->parent = env->global_nspc; + env->global_nspc = global; context_addref((env->context = context)); vector_add(&env->scope->nspc_stack, (vtype)env->curr); env->name = context->name; - context->nspc->parent = env->curr; - env->curr = context->nspc; + context->nspc->parent = global; + env->curr = context->nspc; } -ANN void unload_context(const Context context, const Env env) { - context_remref(context, env->gwion); +ANN void unload_context(const Context ctx, const Env env) { + const Nspc global = env->global_nspc; + context_remref(ctx, env->gwion); env->curr = (Nspc)vector_pop(&env->scope->nspc_stack); + if(ctx->error) { + nspc_remref(global, env->gwion); + env->global_nspc = global->parent; + } + else if(!ctx->global) + env->global_nspc = global->parent; } diff --git a/src/plug.c b/src/plug.c index caebf3f9..bff274b2 100644 --- a/src/plug.c +++ b/src/plug.c @@ -162,8 +162,8 @@ ANN static m_bool _plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc const size_t size = strlen(iname); char name[size + 1]; strcpy(name, iname); - for (size_t i = 0; i < size; i++) { - if (name[i] == ':' || name[i] == '[' || name[i] == ']') name[i] = '_'; + for (size_t j = 0; j < size; j++) { + if (name[j] == ':' || name[j] == '[' || name[j] == ']') name[j] = '_'; } if (!strcmp(name, base)) { if (plug->imp) return GW_OK;