push->m_val = -(missing_depth) * SZ_INT;
}
assign->m_val = emit_var;
-// (void)emit_addref(emit, emit_var);
+ (void)emit_addref(emit, emit_var);
} else if(struct_ctor(v))
emit_struct_decl_finish(emit, v->type, emit_addr);
return GW_OK;
return op_emit_bool(emit, &opi);
}
-ANN static inline void emit_func_def_global(const Emitter emit, const Value value) {
+ANN static inline void emit_func_def_fglobal(const Emitter emit, const Value value) {
const Instr set_mem = emit_add_instr(emit, MemSetImm);
set_mem->m_val = value->from->offset;
set_mem->m_val2 = (m_uint)value->d.func_ref->code;
const Func func = fdef->base->func;
func->code = emit_func_def_code(emit, func);
if(fdef_is_file_global(emit, fdef))
- emit_func_def_global(emit, func->value_ref);
+ emit_func_def_fglobal(emit, func->value_ref);
if(emit->info->memoize && fflag(func, fflag_pure))
func->code->memoize = memoize_ini(emit, func);
}
return GW_OK;
if(fdef_is_file_global(emit, fdef))
func->value_ref->from->offset = emit_local(emit, emit->gwion->type[et_int]);
+ const uint global = GET_FLAG(f->base, global);
+ const m_uint scope = !global ? emit->env->scope->depth : env_push_global(emit->env);
emit_func_def_init(emit, func);
if(vflag(func->value_ref, vflag_member))
stack_alloc(emit);
emit_fdef_finish(emit, fdef);
else
emit_pop_code(emit);
+ if(global)
+ env_pop(emit->env, scope);
return ret;
}
exp_setvar(e, 1);
return check_lambda(env, t, &e->d.exp_lambda);
}
- if(implicit)
- return check_implicit(env, e, t);
+ if(implicit) {
+ const m_bool ret = check_implicit(env, e, t);
+ if(ret == GW_OK)
+ return ret;
+ }
}
return match ? 1 : -1;
}
nspc_pop_type(env->gwion->mp, env->curr);
CHECK_OO(e1->type)
}
- if(func_match_inner(env, e, e1->type, implicit, specific) < 0)
+ if(!func->def->base->tmpl && func->next)
+ env->context->error = 1;
+ const m_bool ret = func_match_inner(env, e, e1->type, implicit, specific);
+ if(func->next)
+ env->context->error = ret < 0;
+ if(ret < 0)
break;
e = e->next;
e1 = e1->next;
}
ANN m_bool scan1_func_def(const Env env, const Func_Def fdef) {
+ const uint global = GET_FLAG(fdef->base, global);
+ const m_uint scope = !global ? env->scope->depth : env_push_global(env);
if(fdef->base->td)
CHECK_BB(env_storage(env, fdef->base->flag, td_pos(fdef->base->td)))
CHECK_BB(scan1_fdef_defined(env, fdef))
const m_bool ret = scanx_fdef(env, env, fdef, (_exp_func)scan1_fdef);
--env->scope->depth;
env->func = former;
+ if(global)
+ env_pop(env, scope);
return ret;
}
ANN static m_bool scan2_args(const Func_Def f) {
Arg_List list = f->base->args;
+ const uint global = GET_FLAG(f->base, global);
do {
const Value v = list->var_decl->value;
v->from->offset = f->stack_depth;
f->stack_depth += v->type->size;
+ if(global)
+ SET_FLAG(v, global);
} while((list = list->next));
return GW_OK;
}
valuefrom(env, v->from);
SET_FLAG(v, const);
set_vflag(v, vflag_func);
- if(!env->class_def)
- set_vflag(v, vflag_fglobal);
- else {
+ if(!env->class_def) {
+ if(!GET_FLAG(d->base, global))
+ set_vflag(v, vflag_fglobal);
+ } else {
if(GET_FLAG(d->base, static))
SET_FLAG(v, static);
else