From: fennecdjay Date: Tue, 12 Nov 2019 13:29:32 +0000 (+0100) Subject: :art: Simplify lambda X-Git-Tag: nightly~2106 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=c3efca1776529a0508b848296832ca9f7ebf581e;p=gwion.git :art: Simplify lambda --- diff --git a/ast b/ast index a95e4eac..a665041d 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit a95e4eac0089fcbb55cd477987f5dcd40116eb6f +Subproject commit a665041d509e08858bfe7932dd753fd99b0fa105 diff --git a/src/emit/emit.c b/src/emit/emit.c index a133530f..fb750137 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1141,7 +1141,7 @@ ANN static m_bool emit_lambda(const Emitter emit, const Exp_Lambda * lambda) { } ANN static m_bool emit_exp_lambda(const Emitter emit, const Exp_Lambda * lambda) { - if(!lambda->def) { + if(!lambda->def->base->func) { regpushi(emit, SZ_INT); return GW_OK; } diff --git a/src/lib/func.c b/src/lib/func.c index 4e104305..52a1debc 100644 --- a/src/lib/func.c +++ b/src/lib/func.c @@ -144,7 +144,7 @@ ANN static Type fptr_type(const Env env, struct FptrInfo *info) { } ANN static m_bool _check_lambda(const Env env, Exp_Lambda *l, const Func_Def def) { - Arg_List base = def->base->args, arg = l->args; + Arg_List base = def->base->args, arg = l->def->base->args; while(base && arg) { arg->td = base->td; base = base->next; @@ -152,11 +152,13 @@ ANN static m_bool _check_lambda(const Env env, Exp_Lambda *l, const Func_Def def } if(base || arg) ERR_B(exp_self(l)->pos, _("argument number does not match for lambda")) - l->def = new_func_def(env->gwion->mp, - new_func_base(env->gwion->mp, def->base->td, l->name, l->args), - l->code, def->flag, loc_cpy(env->gwion->mp, def->pos)); + l->def->flag = def->flag; + l->def->base->td = cpy_type_decl(env->gwion->mp, def->base->td); +// l->def = new_func_def(env->gwion->mp, +// new_func_base(env->gwion->mp, def->base->td, l->name, l->args), +// l->code, def->flag, loc_cpy(env->gwion->mp, def->pos)); CHECK_BB(traverse_func_def(env, l->def)) - arg = l->args; + arg = l->def->base->args; while(arg) { arg->td = NULL; arg = arg->next; diff --git a/src/parse/check.c b/src/parse/check.c index e87a95a0..d068faed 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -751,7 +751,7 @@ ANN static Type check_lambda_call(const Env env, const Exp_Call *exp) { if(exp->args) CHECK_OO(check_exp(env, exp->args)) Exp_Lambda *l = &exp->func->d.exp_lambda; - Arg_List arg = l->args; + Arg_List arg = l->def->base->args; Exp e = exp->args; while(arg && e) { arg->type = e->type; @@ -760,8 +760,6 @@ ANN static Type check_lambda_call(const Env env, const Exp_Call *exp) { } if(arg || e) ERR_O(exp_self(exp)->pos, _("argument number does not match for lambda")) - l->def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, NULL, l->name, l->args), - l->code, 0, loc_cpy(env->gwion->mp, exp_self(exp)->pos)); CHECK_BO(traverse_func_def(env, l->def)) if(env->class_def) SET_FLAG(l->def, member);