From 59577d3ca0184d05dc728e9c007843321b78ccf7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 26 Jun 2020 15:37:19 +0200 Subject: [PATCH] :bug: Fix builtin struct --- src/emit/emit.c | 5 +++-- src/import/cdef.c | 2 +- src/parse/check.c | 2 +- src/vm/vm.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 730c3224..8c2d3fd6 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -515,7 +515,8 @@ ANN static void interp_multi(const Emitter emit, const Exp e) { } ANN static void interp_size(const Emitter emit, const Type t) { - const m_uint sz = isa(t, emit->gwion->type[et_compound]) < 0 ? + const m_uint sz = (isa(t, emit->gwion->type[et_object]) < 0 || + (!GET_FLAG(t, builtin) && isa(t, emit->gwion->type[et_compound]) > 0))? t->size : SZ_INT; const Instr instr = regseti(emit, sz); instr->m_val2 = SZ_INT; @@ -593,7 +594,7 @@ ANN static m_bool decl_static(const Emitter emit, const Var_Decl var_decl, const } ANN static inline int struct_ctor(const Value v) { - return GET_FLAG(v->type, struct); + return GET_FLAG(v->type, struct) && !GET_FLAG(v->type, builtin); } ANN static void decl_expand(const Emitter emit, const Type t) { diff --git a/src/import/cdef.c b/src/import/cdef.c index 01927fee..6a96d2e9 100644 --- a/src/import/cdef.c +++ b/src/import/cdef.c @@ -106,7 +106,7 @@ ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent ANN Type gwi_struct_ini(const Gwi gwi, const m_str name) { CHECK_OO(str2sym(gwi, name)) - const Type t = new_type(gwi->gwion->mp, ++gwi->gwion->env->scope->type_xid, name, NULL); + const Type t = new_type(gwi->gwion->mp, ++gwi->gwion->env->scope->type_xid, name, gwi->gwion->type[et_compound]); t->e->tuple = new_tupleform(gwi->gwion->mp, NULL); gwi_type_flag(t); SET_FLAG(t, struct); diff --git a/src/parse/check.c b/src/parse/check.c index 7eb363c4..922813d5 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -353,7 +353,7 @@ ANN static Type check_prim_typeof(const Env env, const Exp *exp) { ANN static Type check_prim_interp(const Env env, const Exp* exp) { CHECK_OO(check_exp(env, *exp)) Exp e = *exp; - do if(GET_FLAG(e->info->type, struct)) + do if(GET_FLAG(e->info->type, struct) && !GET_FLAG(e->info->type, builtin)) exp_setvar(e, 1); while((e = e->next)); return env->gwion->type[et_string]; diff --git a/src/vm/vm.c b/src/vm/vm.c index 8ab29370..b4582fcf 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -467,7 +467,7 @@ allocfloat: DISPATCH() allocother: // LOOP_OPTIM - for(m_uint i = 0; i <= VAL; i += SZ_INT) + for(m_uint i = 0; i <= VAL2; i += SZ_INT) *(m_uint*)(reg+i) = (*(m_uint*)(mem+VAL+i) = 0); reg += VAL2; DISPATCH() -- 2.43.0