From bfcb9c86b58daf2a17f31ea950f7a40a516dac8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 11 Jul 2021 20:53:43 +0200 Subject: [PATCH] :art: few stuff [prepare jit] --- include/env/type.h | 1 + src/import/import_type.c | 2 ++ src/lib/array.c | 4 ++-- src/lib/engine.c | 3 +++ src/lib/prim.c | 6 ++++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/env/type.h b/include/env/type.h index e1ded1a2..7806a0ae 100644 --- a/include/env/type.h +++ b/include/env/type.h @@ -36,6 +36,7 @@ enum tflag { tflag_distinct = 1 << 17, tflag_noret = 1 << 18, tflag_contract = 1 << 19, + tflag_float = 1 << 20, } __attribute__((packed)); struct Type_ { diff --git a/src/import/import_type.c b/src/import/import_type.c index 34fe9b8a..ed6fa92b 100644 --- a/src/import/import_type.c +++ b/src/import/import_type.c @@ -42,6 +42,8 @@ Type gwi_mk_type(const Gwi gwi, const m_str name, const m_uint size, const Type parent = get_parent(gwi, parent_name); const Type t = new_type(gwi->gwion->mp, name, parent); t->size = size; + if(safe_tflag(parent, tflag_float)) + set_tflag(t, tflag_float); return t; } diff --git a/src/lib/array.c b/src/lib/array.c index d01765f7..701505a3 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -921,7 +921,7 @@ ANN static M_Object do_alloc_array_loop(const VM_Shred shred, ArrayInfo *info, ANN static M_Object do_alloc_array(const VM_Shred shred, ArrayInfo *info) { const m_int cap = *(m_int *)REG(info->depth * SZ_INT); if (cap < 0) { - gw_err("[gwion](VM): NegativeArraySize: while allocating arrays...\n"); + gw_err("{-}[{0}{+}Gwion{0}{-}](VM):{0} NegativeArraySize: while allocating arrays...\n"); return NULL; } const M_Object base = do_alloc_array_object(shred->info->mp, info, cap); @@ -949,7 +949,7 @@ INSTR(ArrayAlloc) { if (info->is_obj) aai.data = init_array(shred, info, &num_obj); const M_Object ref = do_alloc_array(shred, &aai); if (!ref) { - gw_err("[Gwion](VM): (note: in shred[id=%" UINT_F ":%s])\n", + gw_err("{-}[{0}{+}Gwion{0}{-}](VM):{0} (note: in shred[id=%" UINT_F ":%s])\n", shred->tick->xid, shred->code->name); vm_shred_exit(shred); if (info->is_obj) free(aai.data); diff --git a/src/lib/engine.c b/src/lib/engine.c index 300ffe76..a984cf3a 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -112,16 +112,19 @@ ANN static m_bool import_core_libs(const Gwi gwi) { const Type t_float = gwi_mk_type(gwi, "float", SZ_FLOAT, NULL); GWI_BB(gwi_gack(gwi, t_float, gack_float)) GWI_BB(gwi_set_global_type(gwi, t_float, et_float)) + set_tflag(t_float, tflag_float); gwidoc(gwi, "represent duration."); const Type t_dur = gwi_mk_type(gwi, "dur", SZ_FLOAT, NULL); GWI_BB(gwi_gack(gwi, t_dur, gack_float)) GWI_BB(gwi_add_type(gwi, t_dur)) + set_tflag(t_dur, tflag_float); gwidoc(gwi, "represent time."); const Type t_time = gwi_mk_type(gwi, "time", SZ_FLOAT, NULL); GWI_BB(gwi_gack(gwi, t_time, gack_float)) GWI_BB(gwi_add_type(gwi, t_time)) + set_tflag(t_time, tflag_float); gwidoc(gwi, "internal time for `{/}now{0}{-}`."); const Type t_now = gwi_mk_type(gwi, "@now", SZ_FLOAT, "time"); diff --git a/src/lib/prim.c b/src/lib/prim.c index 60bbdc19..eff1c19e 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -437,7 +437,9 @@ static GWION_IMPORT(dur) { CHECK_FF("*=>", rassign, r_mul) CHECK_FF("/=>", rassign, r_div) - GWI_BB(gwi_oper_ini(gwi, "dur", "dur", "int")) + GWI_BB(gwi_oper_ini(gwi, "dur", "dur", "bool")) + GWI_BB(gwi_oper_end(gwi, "==", float_eq)) + GWI_BB(gwi_oper_end(gwi, "!=", float_neq)) GWI_BB(gwi_oper_end(gwi, ">", float_gt)) GWI_BB(gwi_oper_end(gwi, ">=", float_ge)) GWI_BB(gwi_oper_end(gwi, "<", float_lt)) @@ -476,7 +478,7 @@ static GWION_IMPORT(time) { GWI_BB(gwi_oper_end(gwi, "+", float_add)) GWI_BB(gwi_oper_ini(gwi, "dur", "@now", "time")) _CHECK_OP("=>", now, Time_Advance) - GWI_BB(gwi_oper_ini(gwi, "time", "time", "int")) + GWI_BB(gwi_oper_ini(gwi, "time", "time", "bool")) GWI_BB(gwi_oper_end(gwi, ">", float_gt)) GWI_BB(gwi_oper_end(gwi, ">=", float_ge)) GWI_BB(gwi_oper_end(gwi, "<", float_lt)) -- 2.43.0