-Subproject commit 13713de48c46bbbeb8d6b69518a959f6d378c00d
+Subproject commit c245f1f3c808ded546f81360f21b82648f2d1720
tflag_tmpl = 1 << 15,
tflag_typedef = 1 << 16,
tflag_distinct = 1 << 17,
- tflag_noret = 1 << 17,
+ tflag_noret = 1 << 18,
} __attribute__((packed));
struct Type_ {
f->code = finalyze(emit, FuncReturn);
return emit->env->class_def->info->gack = f->code;
}
- const VM_Code code = finalyze(emit, FuncReturn);
- if(emit->info->memoize && fflag(emit->env->func, fflag_pure))
- code->is_memoize = true;
- return code;
+ return finalyze(emit, FuncReturn);
+}
+
+ANN static inline VM_Code _emit_func_def_code(const Emitter emit, const Func func) {
+ return !fbflag(func->def->base, fbflag_internal) ?
+ finalyze(emit, FuncReturn) : emit_internal(emit, func);
}
ANN static VM_Code emit_func_def_code(const Emitter emit, const Func func) {
- if(fbflag(func->def->base, fbflag_internal))
- return emit_internal(emit, func);
- else
- return finalyze(emit, FuncReturn);
+ const VM_Code code = _emit_func_def_code(emit, func);
+ if(emit->info->memoize && fflag(func, fflag_pure))
+ code->is_memoize = true;
+ return code;
}
ANN static m_bool emit_func_def_body(const Emitter emit, const Func_Def fdef) {
return ret;
}
-ANN static bool class_def_has_body(Ast ast) {
+ANN static bool class_def_has_body(const Env env, Ast ast) {
do {
const Section *section = ast->section;
if(section->section_type == ae_section_stmt) {
do {
if(GET_FLAG(dlist->self->value, late))
continue;
- if(tflag(dlist->self->value->type, tflag_ctor) ||
- dlist->self->value->type->array_depth)
+if(isa(dlist->self->value->type, env->gwion->type[et_compound]) > 0)
+// if(tflag(dlist->self->value->type, tflag_ctor) ||
+// dlist->self->value->type->array_depth)
return true;
} while((dlist = dlist->next));
} else
inherit(t);
if(cdef->body) {
CHECK_BB(env_body(env, cdef, check_body));
- if(class_def_has_body(cdef->body))
+ if(class_def_has_body(env, cdef->body))
set_tflag(t, tflag_ctor);
}
if(!GET_FLAG(cdef, abstract))
CHECK_BB(check_abstract(env, cdef));
+ Value value;
+ struct scope_iter iter = { t->nspc->info->value, 0, 0 };
+ while(scope_iter(&iter, &value) > 0) {
+ if(isa(value->type, env->gwion->type[et_compound]) < 0)
+ continue;
+ if(value->type->nspc && !GET_FLAG(value, late)) {
+ Value v;
+ struct scope_iter inner = { value->type->nspc->info->value, 0, 0 };
+ while(scope_iter(&inner, &v) > 0) {
+ if(isa(v->type, t) > 0 || isa(t, v->type) > 0) {
+//exit(3);
+ env_err(env, v->from->loc, _("recursive type"));
+env->context->error = false;
+ env_err(env, value->from->loc, _("recursive type"));
+env->context->error = true;
+return GW_ERROR;
+}
+}
+}
+ }
return GW_OK;
}
return t;
}
+ANN static inline Type find(const Env env, Type_Decl* td) {
+ if(!td->fptr)
+ return find_type(env, td);
+ if(!td->fptr->type)
+ CHECK_BO(traverse_fptr_def(env, td->fptr));
+ return td->fptr->type;
+}
+
+ANN static inline Type find1(const Env env, const Type base, Type_Decl* td) {
+ if(!td->fptr)
+ return scan_type(env, base, td);
+ if(!td->fptr->type) {
+ CHECK_BO(scan0_fptr_def(env, td->fptr));
+ CHECK_BO(traverse_fptr_def(env, td->fptr));
+ }
+ return td->fptr->type;
+}
+
ANN static Type resolve(const Env env, Type_Decl* td) {
Type_Decl *last = td;
while(last->next)
last = last->next;
- DECL_OO(const Type, base, = find_type(env, td));
+ DECL_OO(const Type, base, = find(env, td));
const Context ctx = base->info->value->from->ctx;
if(ctx && ctx->error)
ERR_O(td->pos, _("type '%s' is invalid"), base->name)
- DECL_OO(const Type, type, = scan_type(env, base, td));
+ DECL_OO(const Type, type, = find1(env, base, td));
const Type t = !td->ref ? type : ref(env, td);
const Type ret = !td->option ? t : option(env, td);
const Array_Sub array = last->array;