#include "traverse.h"
#include "template.h"
#include "parse.h"
+#include "partial.h"
static OP_CHECK(opck_func_call) {
Exp_Binary *bin = (Exp_Binary *)data;
return emit_exp_spork(emit, unary);
}
+static OP_CHECK(opck_func_partial) {
+ Exp_Call *call = (Exp_Call*)data;
+ return partial_type(env, call);
+}
+
+static OP_CHECK(opck_class_partial) {
+ Exp_Call *call = (Exp_Call*)data;
+ struct Op_Import opi = {.op = insert_symbol("@partial"),
+ .lhs = actual_type(env->gwion, call->func->type),
+ .pos = call->func->pos,
+ .data = (uintptr_t)data};
+ return op_check(env, &opi);
+}
+
static FREEARG(freearg_xork) { vmcode_remref((VM_Code)instr->m_val, gwion); }
static FREEARG(freearg_dottmpl) {
GWI_BB(gwi_oper_ini(gwi, "@function", "@function", NULL))
GWI_BB(gwi_oper_add(gwi, opck_auto_fptr))
GWI_BB(gwi_oper_end(gwi, "@=>", int_r_assign))
+ GWI_BB(gwi_oper_ini(gwi, "@function", NULL, NULL))
+ GWI_BB(gwi_oper_add(gwi, opck_func_partial))
+ GWI_BB(gwi_oper_end(gwi, "@partial", NULL))
+ GWI_BB(gwi_oper_ini(gwi, "Class", NULL, NULL))
+ GWI_BB(gwi_oper_add(gwi, opck_class_partial))
+ GWI_BB(gwi_oper_end(gwi, "@partial", NULL))
gwi_register_freearg(gwi, SporkIni, freearg_xork);
gwi_register_freearg(gwi, DotTmpl, freearg_dottmpl);
return GW_OK;
ANN static Type check_exp_call(const Env env, Exp_Call *exp) {
if (is_partial(env, exp->args)) {
CHECK_OO(check_exp(env, exp->func));
- return partial_type(env, exp);
+ struct Op_Import opi = {.op = insert_symbol("@partial"),
+ .lhs = exp->func->type,
+ .pos = exp->func->pos,
+ .data = (uintptr_t)exp};
+ return op_check(env, &opi);
}
if (exp->tmpl) {
DECL_BO(const m_bool, ret, = func_check(env, exp));
for(uint32_t i = 0; i < tl->len; i++) {
Type_Decl *tmp = *mp_vector_at(tl, Type_Decl*, i);
DECL_OO(const Type, t, = known_type(env, tmp));
- Specialized *spec = mp_vector_at(sl, Specialized, i);
- if(spec->traits) {
- Symbol missing = miss_traits(t, spec);
- if (missing) {
- ERR_O(td->pos, "does not implement requested trait '{/}%s{0}'",
- s_name(missing));
- }
+ if(!sl) continue;
+ Specialized *spec = mp_vector_at(sl, Specialized, i);
+ if(spec->traits) {
+ Symbol missing = miss_traits(t, spec);
+ if (missing) {
+ ERR_O(td->pos, "does not implement requested trait '{/}%s{0}'",
+ s_name(missing));
}
+ }
}
struct Op_Import opi = {.op = insert_symbol("@scan"),
.lhs = t,