]> Nishi Git Mirror - gwion.git/commitdiff
:bug: Fix emit_call and union functions
authorfennecdjay <fennecdjay@gmail.com>
Wed, 29 Jun 2022 22:58:50 +0000 (00:58 +0200)
committerfennecdjay <fennecdjay@gmail.com>
Wed, 29 Jun 2022 22:58:50 +0000 (00:58 +0200)
src/emit/emit.c
src/lib/union.c

index abc2f703a718f5904f298ea9940c554aeeb28740..a322288ffa70dc504b6024defaa1cd1b504c5588 100644 (file)
@@ -1616,12 +1616,10 @@ ANN m_bool emit_exp_call1(const Emitter emit, const Func f,
   else if (unlikely(!f->code && emit->env->func != f)) {
     if (tmpl) CHECK_BB(emit_template_code(emit, f));
     else CHECK_BB(emit_ensure_func(emit, f));
-  } else {
-    if(!f->value_ref->from->owner_class ||
+  } else if(!f->value_ref->from->owner_class ||
        GET_FLAG(f->value_ref->from->owner_class, final) ||
-       GET_FLAG(f->value_ref->from->owner_class, static))
+       GET_FLAG(f, static) || tmpl)
     push_func_code(emit, f);
-  }
   call_finish(emit, f, is_static);
   emit->status = status;
   return GW_OK;
index 8bd38f19e96882a28c8d7639252313814ce4b60b..0f2b2ea8032e1b6b89848423214b4f9d915ff5e7 100644 (file)
@@ -34,9 +34,7 @@ static OP_EMIT(opem_union_dot) {
   CHECK_BB(emit_exp(emit, member->base));
   if (is_func(emit->gwion, exp_self(member)->type)) { // is_callable? can only be a func
     const Instr instr = emit_add_instr(emit, RegPushImm);
-    const Func  f =
-        (Func)vector_front(&member->base->type->info->parent->nspc->vtable);
-    instr->m_val = (m_uint)f->code;
+    instr->m_val = (m_uint)exp_self(member)->type->info->func->code;
     return GW_OK;
   }
   if (!strcmp(s_name(member->xid), "index")) {
@@ -190,7 +188,6 @@ ANN GWION_IMPORT(union) {
       .op   = insert_symbol(gwi->gwion->st, "@func_check")};
   CHECK_BB(add_op(gwi->gwion, &opi1));
 
-builtin_func(gwi->gwion->mp, f1, union_new);
   gwi->gwion->type[et_union] = t_union;
 
   GWI_BB(gwi_oper_ini(gwi, "union", (m_str)OP_ANY_TYPE, NULL))