}
static inline m_bool push_func_code(const Emitter emit, const Func f) {
+ const Instr instr = (Instr)vector_back(&emit->code->instr);
if(GET_FLAG(f, template) && f->value_ref->owner_class) {
- const Instr instr = (Instr)vector_back(&emit->code->instr);
- assert(instr->opcode == eDotTmplVal);
+// assert(instr->opcode == eDotTmplVal);
size_t len = strlen(f->name);
size_t sz = len - strlen(f->value_ref->owner_class->name);
char c[sz + 1];
func_i->m_val = (m_uint)(func->code ?: (VM_Code)func);
return GW_OK;
}
- if(func->def->base->tmpl)
+// if(func->def->base->tmpl)
+ if(GET_FLAG(func->def, template))
emit_add_instr(emit, DotTmplVal);
else {
const Instr instr = emit_add_instr(emit, GET_FLAG(func, member) ? DotFunc : DotStaticFunc);
const Type parent = cdef->base.type->e->parent;
const Type base = parent->e->d.base_type;
if(base && !GET_FLAG(base, emit))
+// if(parent && (!GET_FLAG(parent, emit) || GET_FLAG(parent, template)))
CHECK_BB(scanx_parent(base, emit_parent_inner, emit))
return !GET_FLAG(parent, emit) ? GW_OK : scanx_parent(parent, emit_parent_inner, emit);
}
const m_bool ret = traverse_func_def(env, fdef);
if(ret > 0) {
const Func f = fdef->base->func;
- if(check_call(env, exp) > 0) {
- const Func next = f->next;
- f->next = NULL;
- const Func func = find_func_match(env, f, exp->args);
- f->next = next;
- if(func) {
- SET_FLAG(func, checked | ae_flag_template);
- return func;
- }
+ const Func next = f->next;
+ f->next = NULL;
+ const Func func = find_func_match(env, f, exp->args);
+ f->next = next;
+ if(func) {
+ SET_FLAG(func, checked | ae_flag_template);
+ return func;
}
}
return NULL;
ERR_O(exp_self(exp)->pos, _("template call of non-template function."))
if(t->e->d.func->def->base->tmpl->call)
CHECK_BO(predefined_call(env, t, exp_self(exp)->pos))
+CHECK_BO(check_call(env, exp))
const Func ret = find_template_match(env, v, exp);
CHECK_OO((exp->m_func = ret))
return ret->def->base->ret_type;
const Type_Decl *td = cdef->base.ext;
if(td->array)
CHECK_BB(check_exp_array_subscripts(env, td->array->exp))
- if(parent->e->def)
+ if(parent->e->def && (!GET_FLAG(parent, check) || GET_FLAG(parent, template)))
CHECK_BB(scanx_parent(parent, traverse_class_def, env))
if(GET_FLAG(parent, typedef))
SET_FLAG(cdef->base.type, typedef);
} while((t = t->e->parent));
if(isa(parent, t_object) < 0)
ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name)
- if(parent->e->def)
+ if(parent->e->def && (!GET_FLAG(parent, scan1) || GET_FLAG(parent, template)))
CHECK_BB(scanx_parent(parent, scan1_class_def, env))
if(type_ref(parent))
ERR_B(pos, _("can't use ref type in class extend"))
ANN static m_bool scan2_class_parent(const Env env, const Class_Def cdef) {
const Type parent = cdef->base.type->e->parent;
- if(parent->e->def)
+ if(parent->e->def && (!GET_FLAG(parent, scan2) || GET_FLAG(parent, template)))
CHECK_BB(scanx_parent(parent, scan2_cdef, env))
if(cdef->base.ext->array)
CHECK_BB(scan2_exp(env, cdef->base.ext->array->exp))