From: Jérémie Astor Date: Tue, 5 May 2020 12:54:24 +0000 (+0200) Subject: :bug: Fix for builtin structs X-Git-Tag: nightly~1677 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=2e7b402586f88d57544dd900e192dfa0197da388;p=gwion.git :bug: Fix for builtin structs --- diff --git a/src/emit/emit.c b/src/emit/emit.c index 93b27452..ba7c7739 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -485,7 +485,7 @@ ANN static m_bool emit_prim_str(const Emitter emit, const m_str *str) { #define emit_prim_nil (void*)dummy_func ANN static inline void struct_interp(const Emitter emit, const Exp e) { - if(GET_FLAG(e->info->type, struct)) { + if(GET_FLAG(e->info->type, struct) && !GET_FLAG(e->info->type, builtin)) { exp_setvar(e, 1); regpush(emit, e->info->type->size - SZ_INT); } @@ -757,7 +757,8 @@ ANN static m_bool emit_exp_call(const Emitter emit, const Exp_Call* exp_call) { const Instr instr = emit_add_instr(emit, Reg2RegAddr); instr->m_val = -SZ_INT; instr->m_val2 = -SZ_INT; - } + } else if(!exp_call->m_func && GET_FLAG(e->info->type, struct)) + regpop(emit, SZ_INT); return GW_OK; } diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 90ab1d1e..be5cd561 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -139,7 +139,7 @@ ANN static Type scan_class(const Env env, const Type t, const Type_Decl* td); OP_CHECK(opck_object_scan) { struct TemplateScan *ts = (struct TemplateScan*)data; - if(ts->td->types) + if(ts->td->types && GET_FLAG(ts->t, template) && ts->t->e->def) return scan_class(env, ts->t, ts->td); if(!GET_FLAG(ts->t, template) || GET_FLAG(ts->t, unary)) return ts->t;