}
ANN Type check_td(const Env env, Type_Decl *td);
-ANN static inline Type check_new_td(const Env env, Type_Decl *td) {
- if(!td->exp)
- return known_type(env, td);
- DECL_OO(const Type, t, = check_exp(env, td->exp))
- return actual_type(env->gwion, t);
-}
OP_CHECK(opck_new) {
const Exp_Unary* unary = (Exp_Unary*)data;
- DECL_ON(const Type, t, = check_new_td(env, unary->td))
+ DECL_ON(const Type, t, = known_type(env, unary->td))
if(isa(t, env->gwion->type[et_object]) < 0)
ERR_N(exp_self(unary)->pos, _("can't use 'new' on non-object types...\n"))
if(type_ref(t))
return GW_OK;
}
-ANN static inline m_bool check_td_exp(const Env env, Type_Decl *td) {
- RET_NSPC(traverse_exp(env, td->exp))
-}
-
-ANN Type check_td(const Env env, Type_Decl *td) {
- CHECK_BO(check_td_exp(env, td))
- const Type t = actual_type(env->gwion, td->exp->type);
- td->xid = insert_symbol("auto");
- return t;
-}
-
-ANN static Type no_xid(const Env env, const Exp_Decl *decl) {
- CHECK_OO((((Exp_Decl*)decl)->type = check_td(env, decl->td)))
- CHECK_BO(traverse_exp(env, exp_self(decl)))
- return decl->type;
-}
-
ANN static m_bool check_var(const Env env, const Var_Decl var) {
if(env->class_def && !env->scope->depth && env->class_def->info->parent)
CHECK_BB(check_exp_decl_parent(env, var))
}
ANN Type check_exp_decl(const Env env, const Exp_Decl* decl) {
- if(!decl->td->xid)
- return no_xid(env, decl);
if(decl->td->array && decl->td->array->exp)
CHECK_OO(check_exp(env, decl->td->array->exp))
if(decl->td->xid == insert_symbol("auto")) { // should be better
do {
const Var_Decl decl = arg_list->var_decl;
const Value v = decl->value;
- if(arg_list->td && !arg_list->td->xid)
- CHECK_OB((arg_list->type = v->type = check_td(env, arg_list->td)))
// TODO: use coumpound instead of object?
if(isa(v->type, env->gwion->type[et_object]) > 0 || isa(v->type, env->gwion->type[et_function]) > 0)
unset_fflag(env->func, fflag_pure);
ANN static Type check_exp_cast(const Env env, const Exp_Cast* cast) {
DECL_OO(const Type, t, = check_exp(env, cast->exp))
- CHECK_OO((exp_self(cast)->type = cast->td->xid ? known_type(env, cast->td) : check_td(env, cast->td)))
+ CHECK_OO((exp_self(cast)->type = known_type(env, cast->td)))
struct Op_Import opi = { .op=insert_symbol("$"), .lhs=t, .rhs=exp_self(cast)->type,
.data=(uintptr_t)cast, .pos=exp_self(cast)->pos, .op_type=op_cast };
return op_check(env, &opi);
CHECK_BB(check_parent_match(env, fdef))
if(tmpl_base(fdef->base->tmpl))
return GW_OK;
- if(fdef->base->td && !fdef->base->td->xid) { // tmpl ?
- CHECK_OB((fdef->base->ret_type = check_td(env, fdef->base->td)))
- return check_traverse_fdef(env, fdef);
- }
CHECK_BB(check_func_def_override(env, fdef))
DECL_BB(const m_int, scope, = GET_FLAG(fdef->base, global) ? env_push_global(env) : env->scope->depth)
const Func former = env->func;