From: Jérémie Astor Date: Sun, 5 Sep 2021 21:21:45 +0000 (+0200) Subject: :art: Add Object conditionnal X-Git-Tag: nightly~470^2~9 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=b2da01498e1f38423d47a6c7daf47dde43abbd31;p=gwion.git :art: Add Object conditionnal --- diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 04f92bde..d06c65e6 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -348,9 +348,6 @@ static OP_EMIT(opem_not_object) { const Instr back = (Instr)vector_back(v); if (back->opcode == eGWOP_EXCEPT) { back->opcode = eIntNot; -// vector_pop(v); -// mp_free(emit->gwion->mp, Instr, back); -// emit_add_instr(emit, IntNot); return GW_OK; } const Instr instr = emit_add_instr(emit, RegSetImm); @@ -358,6 +355,28 @@ static OP_EMIT(opem_not_object) { return GW_OK; } +static OP_EMIT(opem_uncond_object) { + const Vector v = &emit->code->instr; + const Instr back = (Instr)vector_at(v, vector_size(v) -2); + if (back->opcode == eGWOP_EXCEPT) { + free_instr(emit->gwion, back); + vector_rem(v, vector_size(v) - 2); + } + emit_add_instr(emit, BranchNeqInt); + return GW_OK; +} + +static OP_EMIT(opem_cond_object) { + const Vector v = &emit->code->instr; + const Instr back = (Instr)vector_at(v, vector_size(v) -2); + if (back->opcode == eGWOP_EXCEPT) { + free_instr(emit->gwion, back); + vector_rem(v, vector_size(v) - 2); + } + emit_add_instr(emit, BranchEqInt); + return GW_OK; +} + GWION_IMPORT(object_op) { const Type t_error = gwi_mk_type(gwi, "@error", 0, NULL); gwi->gwion->type[et_error] = t_error; @@ -371,12 +390,13 @@ GWION_IMPORT(object_op) { GWI_BB(gwi_oper_end(gwi, "!=", NeqObject)) GWI_BB(gwi_oper_add(gwi, opck_object_cast)) GWI_BB(gwi_oper_end(gwi, "$", NULL)) - //. GWI_BB(gwi_oper_add(gwi, opck_implicit_null2obj)) - // GWI_BB(gwi_oper_emi(gwi, opem_implicit_null2obj)) - // GWI_BB(gwi_oper_end(gwi, "@implicit", NULL)) GWI_BB(gwi_oper_ini(gwi, NULL, "Object", "bool")) + GWI_BB(gwi_oper_emi(gwi, opem_uncond_object)) + GWI_BB(gwi_oper_end(gwi, "@unconditionnal", NULL)) + GWI_BB(gwi_oper_emi(gwi, opem_cond_object)) + GWI_BB(gwi_oper_end(gwi, "@conditional", NULL)) GWI_BB(gwi_oper_emi(gwi, opem_not_object)) - GWI_BB(gwi_oper_end(gwi, "!", IntNot)) + GWI_BB(gwi_oper_end(gwi, "!", NULL)) GWI_BB(gwi_oper_ini(gwi, "@Compound", NULL, NULL)) GWI_BB(gwi_oper_add(gwi, opck_struct_scan)) GWI_BB(gwi_oper_end(gwi, "@scan", NULL))