ANN static m_bool check_stmt_list(const Env env, Stmt_List list);
ANN m_bool check_class_def(const Env env, const Class_Def class_def);
-ANN static m_bool check_implicit(const Env env, const m_str str,
+ANN static m_bool check_implicit(const Env env, const Symbol sym,
const Exp e, const Type t) {
struct Implicit imp = { .e=e, .t=t, .pos=e->pos };
- struct Op_Import opi = { .op=insert_symbol(str), .lhs=e->type,
+ struct Op_Import opi = { .op=sym, .lhs=e->type,
.rhs=t, .data=(uintptr_t)&imp, .pos=e->pos };
CHECK_OB(op_check(env, &opi))
e->nspc = env->curr;
}
ANN m_bool check_exp_array_subscripts(Env env, Exp exp) {
+// TODO: use "@access" check_implicit
CHECK_OB(check_exp(env, exp))
do if(isa(exp->type, env->gwion->type[et_int]) < 0)
ERR_B(exp->pos, _("incompatible array subscript type '%s' ..."), exp->type->name)
const Type common = find_common_anc(e->type, type);
if(common)
return GW_OK;
- if(check_implicit(env, "@implicit", e, type) < 0)
+ if(check_implicit(env, insert_symbol("@implicit"), e, type) < 0)
ERR_B(e->pos, _("array init [...] contains incompatible types ..."))
set_cast(env, type, e); // ???
return GW_OK;
ANN static m_bool vec_value(const Env env, Exp e) {
int count = 1;
CHECK_OB(check_exp(env, e))
+ const Symbol sym = insert_symbol("@implicit");
do {
- if(check_implicit(env, "@implicit", e, env->gwion->type[et_float]) < 0)
+ if(check_implicit(env, sym, e, env->gwion->type[et_float]) < 0)
ERR_B(e->pos, _("invalid type '%s' in value #%d...\n"), e->type->name, count)
++count;
} while((e = e->next));
return check_lambda(env, owner, &e->d.exp_lambda, t->e->d.func->def);
}
if(implicit)
- return check_implicit(env, "@implicit", e, t);
+ return check_implicit(env, insert_symbol("@implicit"), e, t);
}
return match ? 1 : -1;
}
}
ANN static inline m_bool cond_type(const Env env, const Exp e) {
- return check_implicit(env, "@repeat", e, env->gwion->type[et_int]);
+ const Symbol sym = insert_symbol("@repeat");
+ return check_implicit(env, sym, e, env->gwion->type[et_int]);
}
#define stmt_func_xxx(name, type, prolog, exp) describe_stmt_func(check, name, type, prolog, exp)
}
if(isa(ret_type, env->func->def->base->ret_type) > 0)
return GW_OK;
- return check_implicit(env, "@implicit", stmt->val, env->func->def->base->ret_type);
+ const Symbol sym = insert_symbol("@implicit");
+ return check_implicit(env, sym, stmt->val, env->func->def->base->ret_type);
}
#define describe_check_stmt_stack(stack, name) \