const Var_Decl_List var_decl_list = new_var_decl_list(emit->gwion->mp, var_decl, NULL);
const Exp exp = new_exp_decl(emit->gwion->mp, type_decl, var_decl_list);
exp->d.exp_decl.type = udef->value->type;
+ SET_FLAG(udef->value->type, emit);
var_decl->value = udef->value;
const m_bool ret = emit_exp_decl(emit, &exp->d.exp_decl);
free_exp(emit->gwion->mp, exp);
scope = emit_push_type(emit, udef->value->type);
} else if(udef->type_xid) {
union_allocdata(emit->gwion->mp, udef);
+ SET_FLAG(udef->type, emit);
scope = emit_push_type(emit, udef->type);
- } else if(emit->env->class_def) {
+ } else if(emit->env->class_def) {// miss flag ?
if(!GET_FLAG(l->self->d.exp_decl.list->self->value, member))
udef->o = emit_local(emit, udef->s, 0);
- } else if(global) {
+ } else if(global) {// miss flag?
void* ptr = (void*)xcalloc(1, udef->s);
l = udef->l;
do {
emit_union_offset(udef->l, udef->o);
if(udef->xid || udef->type_xid || global)
emit_pop(emit, scope);
- SET_FLAG(udef->xid ? udef->value->type : udef->type, emit);
+puts(emit->env->name);
+// SET_FLAG(udef->xid ? udef->value->type : udef->type, emit);
return GW_OK;
}
if(f) {
if(!f->code)
break;
- *(VM_Code*)shred->reg = f->code;
- shred->reg += SZ_INT;
+ if(GET_FLAG(f, member))
+ shred->reg += SZ_INT;
+ *(VM_Code*)(shred->reg-SZ_INT) = f->code;
return;
} else {
const Func_Def def = traverse_tmpl(emit, dt, t->nspc);
if(!def)
continue;
- *(VM_Code*)shred->reg = def->base->func->code;
- shred->reg += SZ_INT;
+ const Func f = def->base->func;
+ if(GET_FLAG(f, member))
+ shred->reg += SZ_INT;
+ *(VM_Code*)(shred->reg-SZ_INT) = f->code;
return;
}
} while((t = t->e->parent));
const m_bool ret = traverse_ast(env, ast);
if(ret > 0) //{
nspc_commit(env->curr);
- if(ret || env->context->global)
+ if(ret > 0 || env->context->global)
vector_add(&env->scope->known_ctx, (vtype)ctx);
else //nspc_rollback(env->global_nspc);
REM_REF(ctx, env->gwion);
#include "tuple.h"
ANN static void free_type(Type a, Gwion gwion) {
- if(GET_FLAG(a, template)) {
+ if(GET_FLAG(a, template) || GET_FLAG(a, global)) {
if(GET_FLAG(a, union)) {
if(a->e->def->union_def) {
if(!GET_FLAG(a, pure)) { // <=> decl_list
}
static Func ensure_tmpl(const Env env, const Func_Def fdef, const Exp_Call *exp) {
- const m_bool ret = traverse_func_def(env, fdef);
- if(ret > 0) {
+ const m_bool ret = GET_FLAG(fdef, checked) || traverse_func_def(env, fdef) > 0;
+ if(ret) {
const Func f = fdef->base->func;
const Func next = f->next;
f->next = NULL;
nspc_pop_value(env->gwion->mp, env->curr);
--env->scope->depth;
env->func = former;
+ SET_FLAG(fdef, checked);
if(GET_FLAG(fdef, global))
env_pop(env,scope);
return ret;
ANN static m_bool scan0_class_def_pre(const Env env, const Class_Def cdef) {
CHECK_BB(env_storage(env, cdef->flag, cdef->pos))
- if(GET_FLAG(cdef, global)) {
- vector_add(&env->scope->nspc_stack, (vtype)env->curr);
- env->curr = env->global_nspc;
- env->context->global = 1;
- }
- CHECK_BB(scan0_defined(env, cdef->base.xid, cdef->pos))
CHECK_BB(isres(env, cdef->base.xid, cdef->pos))
return GW_OK;
}
ANN static Type scan0_class_def_init(const Env env, const Class_Def cdef) {
+ CHECK_BO(scan0_defined(env, cdef->base.xid, cdef->pos))
const Type t = scan0_type(env, ++env->scope->type_xid, s_name(cdef->base.xid), env->gwion->type[et_object]);
t->e->owner = env->curr;
t->nspc = new_nspc(env->gwion->mp, t->name);
// t->nspc->parent = GET_FLAG(cdef, global) ? env_nspc(env) : env->curr;
- t->nspc->parent = GET_FLAG(cdef, global) ? env->global_nspc : env->curr;
+ t->nspc->parent = env->curr;
t->e->def = cdef;
t->flag = cdef->flag;
if(!strstr(t->name, "<"))
}
ANN m_bool scan0_class_def(const Env env, const Class_Def cdef) {
- CHECK_BB(scan0_class_def_pre(env, cdef))
- const m_bool ret = scan0_class_def_inner(env, cdef);
+ if(GET_FLAG(cdef, global)) {
+ vector_add(&env->scope->nspc_stack, (vtype)env->curr);
+ env->curr = env->global_nspc;
+ env->context->global = 1;
+ }
+ const m_bool ret = scan0_class_def_pre(env, cdef) > 0 ?
+ scan0_class_def_inner(env, cdef) : GW_ERROR;
if(GET_FLAG(cdef, global))
env->curr = (Nspc)vector_pop(&env->scope->nspc_stack);
return ret;
CHECK_OO(scan2_func_assign(env, f->def, f, v))
if(!overload) {
ADD_REF(v);
- nspc_add_value(env->curr, f->def->base->xid, v);
+ nspc_add_value_front(env->curr, f->def->base->xid, v);
} else if(overload->d.func_ref) {
f->next = overload->d.func_ref->next;
overload->d.func_ref->next = f;