}
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;
}
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;