]> Nishi Git Mirror - gwion.git/commitdiff
:art: Few improvments
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 6 Oct 2019 13:40:07 +0000 (15:40 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 6 Oct 2019 13:40:07 +0000 (15:40 +0200)
src/lib/vararg.c
src/parse/check.c
src/parse/scan2.c

index db9efb4bf08d23257ece27e485a0181e8614133a..40d4a388538c31c9819f71ef6f7da2d03bf3e2c8 100644 (file)
@@ -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;
 }
index bc39a88eb773c9efa20cdf31c931f2c01e84d776..b75ec6affea7494abc7c8a14536ebf4d5ae84c45 100644 (file)
@@ -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;
   }
index 6f729a5303d908df2320b355e237e6192554257a..3604b47ef6b0d67c17549d3a69200eb275ad3716 100644 (file)
@@ -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;