From: Jérémie Astor Date: Tue, 15 Dec 2020 02:58:10 +0000 (+0100) Subject: :art: Improve op_emit api X-Git-Tag: nightly~1105^2~9 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=93dc7ae883bca251e60becaf666330dd07f886c4;p=gwion.git :art: Improve op_emit api --- diff --git a/include/emit.h b/include/emit.h index 272ac97e..1bd8373f 100644 --- a/include/emit.h +++ b/include/emit.h @@ -42,11 +42,10 @@ ANN void emit_class_finish(const Emitter, const Nspc); ANN2(1,2) m_bool emit_instantiate_object(const Emitter, const Type, const Array_Sub, const m_bool); ANN m_uint emit_code_offset(const Emitter emit); ANN m_uint emit_local(const Emitter emit, const Type t); -ANN Instr emit_exp_spork(const Emitter, const Exp_Unary*); +ANN m_bool emit_exp_spork(const Emitter, const Exp_Unary*); ANN m_bool emit_exp(const Emitter, const Exp); -ANN static inline Instr emit_gc(const Emitter emit, const m_int offset) { +ANN static inline void emit_gc(const Emitter emit, const m_int offset) { const Instr gc = emit_add_instr(emit, GcAdd); gc->m_val = offset; - return gc; } #endif diff --git a/include/import/checker.h b/include/import/checker.h index 210fc79a..38564c09 100644 --- a/include/import/checker.h +++ b/include/import/checker.h @@ -39,7 +39,7 @@ typedef struct OperCK { // name_checker ? m_str ret; Symbol sym; Type (*ck)(Env, void*, m_bool*); // oper - Instr (*em)(Emitter, void*); // oper + m_bool (*em)(Emitter, void*); // oper m_str lhs;// oper m_str rhs;// oper } OperCK; diff --git a/src/emit/emit.c b/src/emit/emit.c index 193f71dc..577fef59 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1312,21 +1312,20 @@ ANN void spork_func(const Emitter emit, const struct Sporker *sp) { (void)emit_add_instr(emit, SporkEnd); } -ANN static Instr spork_ini(const Emitter emit, const struct Sporker *sp) { +ANN static void spork_ini(const Emitter emit, const struct Sporker *sp) { if(sp->is_spork) { const Instr instr = emit_add_instr(emit, SporkIni); instr->m_val = (m_uint)sp->vm_code; instr->m_val2 = sp->is_spork; - return instr; + return; } regpushi(emit, (m_uint)sp->type); const Instr instr = emit_add_instr(emit, ForkIni); instr->m_val = (m_uint)sp->vm_code; instr->m_val2 = sp->type->size; - return instr; } -ANN Instr emit_exp_spork(const Emitter emit, const Exp_Unary* unary) { +ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary* unary) { struct Sporker sporker = { .exp=unary->exp, .code=unary->code, @@ -1334,10 +1333,10 @@ ANN Instr emit_exp_spork(const Emitter emit, const Exp_Unary* unary) { .is_spork=(unary->op == insert_symbol("spork")), .emit_var=exp_getvar(exp_self(unary)) }; - CHECK_OO((sporker.vm_code = spork_prepare(emit, &sporker))) - const Instr ini = spork_ini(emit, &sporker); + CHECK_OB((sporker.vm_code = spork_prepare(emit, &sporker))) + spork_ini(emit, &sporker); (unary->code ? spork_code : spork_func)(emit, &sporker); - return ini; + return GW_OK; } ANN static m_bool emit_exp_unary(const Emitter emit, const Exp_Unary* unary) { diff --git a/src/lib/lib_func.c b/src/lib/lib_func.c index 7d8da5ad..0185f6d6 100644 --- a/src/lib/lib_func.c +++ b/src/lib/lib_func.c @@ -33,7 +33,7 @@ static OP_EMIT(opem_func_assign) { Exp_Binary* bin = (Exp_Binary*)data; if(bin->rhs->info->type->info->func->def->base->tmpl) fptr_instr(emit, bin->lhs->info->type->info->func, 2); - const Instr instr = emit_add_instr(emit, int_r_assign); + (void)emit_add_instr(emit, int_r_assign); if(!is_fptr(emit->gwion, bin->lhs->info->type) && vflag(bin->rhs->info->type->info->func->value_ref, vflag_member)) { const Instr pop = emit_add_instr(emit, RegPop); pop->m_val = SZ_INT; diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index 51ce17a4..dfe55a37 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -97,7 +97,7 @@ OP_CHECK(opck_new) { OP_EMIT(opem_new) { const Exp_Unary* unary = (Exp_Unary*)data; - CHECK_BO(emit_instantiate_object(emit, exp_self(unary)->info->type, + CHECK_BB(emit_instantiate_object(emit, exp_self(unary)->info->type, unary->td->array, 0)) emit_gc(emit, -SZ_INT); return GW_OK;