ANN m_bool traverse_func_template(const Env, const Func_Def);
ANN2(1,3) void env_err(const Env, const loc_t pos, const m_str fmt, ...);
ANN Value global_string(const Env env, const m_str str);
+ANN void release_ctx(struct Env_Scope_ *a, struct Gwion_* gwion);
#endif
ANN void gwion_end(const Gwion gwion);
void free_code_instr(const Vector v, const Gwion gwion);
ANN void gwion_end_child(const VM_Shred shred, const Gwion gwion);
+ANN void push_global(const Gwion gwion, const m_str name);
+ANN Nspc pop_global(const Gwion gwion);
#endif
env->scope->depth = 0;
}
-ANN static void free_env_scope(struct Env_Scope_ *a, Gwion gwion) {
+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;)
REM_REF((Context)vector_at(&a->known_ctx, i - 1), gwion);
+}
+
+ANN static void free_env_scope(struct Env_Scope_ *a, Gwion gwion) {
+ release_ctx(a, gwion);
vector_release(&a->known_ctx);
vector_release(&a->nspc_stack);
vector_release(&a->class_stack);
ANN void free_env(const Env a) {
free_env_scope(a->scope, a->gwion);
- REM_REF(a->global_nspc, a->gwion);
- free(a);
+ while(pop_global(a->gwion));
+ xfree(a);
}
ANN2(1,3) m_uint env_push(const Env env, const Type type, const Nspc nspc) {
}
return NULL;
}
+
+ANN void push_global(struct Gwion_ *gwion, const m_str name) {
+ const Nspc nspc = new_nspc(gwion->mp, name);
+ nspc->parent = gwion->env->global_nspc;
+ gwion->env->global_nspc = nspc;
+}
+
+ANN Nspc pop_global(struct Gwion_ *gwion) {
+ const Nspc nspc = gwion->env->global_nspc->parent;
+ REM_REF(gwion->env->global_nspc, gwion)
+ return gwion->env->global_nspc = nspc;
+}
#include "specialid.h"
static GACK(gack_class) {
- gw_out("class(%s)", actual_type(shred->info->vm->gwion, t)->name);
+ const Type type = actual_type(shred->info->vm->gwion, t) ?: t;
+ gw_out("class(%s)", type->name);
}
static GACK(gack_function) {
OperCK oper = {};
struct Gwi_ gwi = { .gwion=vm->gwion, .loc=&loc, .oper=&oper };
CHECK_BB(import_core_libs(&gwi))
+ push_global(vm->gwion, "[plugins]");
vm->gwion->env->name = "[imported]";
for(m_uint i = 0; i < vector_size(plug_dirs); ++i) {
m_bool (*import)(Gwi) = (m_bool(*)(Gwi))vector_at(plug_dirs, i);
if(import && import(&gwi) < 0)
gwi_reset(&gwi);
}
+ push_global(vm->gwion, "[user]");
return GW_OK;
}