From 67c06b207b4c9d4275816af885bcc72c3c9c81f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 9 Dec 2020 02:50:20 +0100 Subject: [PATCH] :art: Improve IntRange --- src/lib/prim.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/prim.c b/src/lib/prim.c index 87c738fd..e021a104 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -59,16 +59,15 @@ static GWION_IMPORT(int_r) { } static INSTR(IntRange) { - shred->reg -= SZ_INT *2; - const m_int start = *(m_int*)REG(0); - const m_int end = *(m_int*)REG(SZ_INT); + shred->reg -= SZ_INT; + const m_int start = *(m_int*)REG(-SZ_INT); + const m_int end = *(m_int*)REG(0); const m_int op = start < end ? 1 : -1; const m_uint sz = op > 0 ? end - start : start - end; const M_Object array = new_array(shred->info->vm->gwion->mp, (Type)instr->m_val, sz); for(m_int i = start, j = 0; i != end; i += op, ++j) m_vector_set(ARRAY(array), j, &i); - *(M_Object*)REG(0) = array; - PUSH_REG(shred, SZ_INT); + *(M_Object*)REG(-SZ_INT) = array; } static OP_CHECK(opck_int_range) { -- 2.43.0