From: fennecdjay Date: Sun, 6 Oct 2019 13:40:07 +0000 (+0200) Subject: :art: Few improvments X-Git-Tag: nightly~2198^2~132 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0d88191d4c59e8558979d6cae80398bd57fb3b46;p=gwion.git :art: Few improvments --- diff --git a/src/lib/vararg.c b/src/lib/vararg.c index db9efb4b..40d4a388 100644 --- a/src/lib/vararg.c +++ b/src/lib/vararg.c @@ -15,6 +15,9 @@ #include "import.h" #include "gwi.h" #include "specialid.h" +#include "traverse.h" +#include "parse.h" +#include "func.h" void free_vararg(MemPool p, struct Vararg_* arg) { xfree(arg->d); @@ -85,6 +88,12 @@ static FREEARG(freearg_vararg) { free_vector(((Gwion)gwion)->mp, (Vector)instr->m_val2); } +static ID_CHECK(idck_vararg) { + if(SAFE_FLAG(env->func, variadic)) + return env->gwion->type[et_vararg]; + ERR_O(exp_self(prim)->pos, _("'vararg' must be used inside variadic function")) +} + GWION_IMPORT(vararg) { const Type t_vararg = gwi_mk_type(gwi, "@Vararg", SZ_INT, "Object"); const Type t_varobj = gwi_mk_type(gwi, "VarObject", SZ_INT, "Object"); @@ -115,7 +124,7 @@ GWION_IMPORT(vararg) { GWI_BB(gwi_oper_add(gwi, at_varobj)) GWI_BB(gwi_oper_end(gwi, "@=>", VarargAssign)) register_freearg(gwi, VarargIni, freearg_vararg); - struct SpecialId_ spid = { .type=t_vararg, .exec=RegPushImm, .is_const=1 }; + struct SpecialId_ spid = { .type=t_vararg, .exec=RegPushImm, .is_const=1, .ck=idck_vararg}; gwi_specialid(gwi, "vararg", &spid); return GW_OK; } diff --git a/src/parse/check.c b/src/parse/check.c index bc39a88e..b75ec6af 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -435,6 +435,8 @@ ANN static Type_List mk_type_list(const Env env, const Type type) { Nspc nspc = type->e->owner; while(nspc && nspc != env->curr && nspc != env->global_nspc) { const Type t = nspc_lookup_type0(nspc->parent, insert_symbol(nspc->name)); + if(!t) + break; vector_add(&v, (vtype)insert_symbol(t->name)); nspc = nspc->parent; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 6f729a53..3604b47e 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -357,7 +357,7 @@ ANN2(1, 2) static m_bool scan2_fdef_tmpl(const Env env, const Func_Def f, const Nspc nspc = env->curr; uint i = 0; do { - const Value v = nspc_lookup_value1(nspc, f->base->xid); + const Value v = nspc_lookup_value0(nspc, f->base->xid); if(v) { Func ff = v->d.func_ref; if(!ff)continue;