From 24670e368db82a45eb11f4d4a383d40deca24182 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sun, 11 Dec 2022 14:40:25 +0100 Subject: [PATCH] :bug: prepare SetCtor in VM --- src/lib/instr.c | 19 +++++++------------ src/vm/vm.c | 4 +++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/lib/instr.c b/src/lib/instr.c index 2d8411e8..2cea5b4b 100644 --- a/src/lib/instr.c +++ b/src/lib/instr.c @@ -122,14 +122,13 @@ INSTR(DotTmpl) { #define VAL (*(m_uint *)(byte + SZ_INT)) #define FVAL (*(m_float *)(byte + SZ_INT)) #define VAL2 (*(m_uint *)(byte + SZ_INT * 2)) -#define BYTE(a) \ - m_bit *byte = shred->code->bytecode + (shred->pc - 1) * BYTECODE_SZ; \ - *(m_uint *)byte = a; +#define BYTE(a) \ + m_bit *byte = shred->code->bytecode + (shred->pc - 1) * BYTECODE_SZ; \ + *(m_uint *)byte = instr->opcode; \ + instr->opcode = a; INSTR(SetFunc) { - m_bit *byte = shred->code->bytecode + (shred->pc - 1) * BYTECODE_SZ; - *(m_uint *)byte = instr->opcode; - instr->opcode = eRegPushImm; + BYTE(eRegPushImm); const Func f = (Func)instr->m_val; VAL = *(m_uint *)(shred->reg) = (m_uint)f->code; shred->reg += SZ_INT; @@ -139,16 +138,14 @@ INSTR(SetCtor) { BYTE(eRegSetImm) const Type t = (Type)instr->m_val; VAL = *(m_uint *)(shred->reg + SZ_INT) = (m_uint)t->nspc->pre_ctor; - VAL2 = SZ_INT; + VAL2 = SZ_INT; } INSTR(fast_except) { struct FastExceptInfo *info = (struct FastExceptInfo *)instr->m_val2; if(*(m_uint*)REG(-SZ_INT)) { - m_bit *byte = shred->code->bytecode + (shred->pc - 1) * BYTECODE_SZ; \ - *(m_uint *)byte = instr->opcode; + BYTE(eNoOp); VAL = -SZ_INT; - instr->opcode = eNoOp; if(info) mp_free2(shred->info->mp, sizeof(struct FastExceptInfo), info); instr->m_val2 = 0; return; @@ -157,8 +154,6 @@ INSTR(fast_except) { gwerr_basic("Object not instantiated", NULL, NULL, info->file, info->loc, 0); if(info->file2) gwerr_warn("declared here", NULL, NULL, info->file2, info->loc2); -// mp_free2(shred->info->mp, sizeof(struct FastExceptInfo), info); -// instr->m_val2 = 0; } handle(shred, "NullPtrException"); } diff --git a/src/vm/vm.c b/src/vm/vm.c index 773c852e..e3c5c3e3 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -1569,7 +1569,9 @@ _other: instr->opcode = (m_uint)&&noop; else if(exec == SetFunc) instr->opcode = (m_uint)&®pushimm; - prepare_code += BYTECODE_SZ;\ + else if(exec == SetCtor) + instr->opcode = (m_uint)&®setimm; + prepare_code += BYTECODE_SZ; goto *_dispatch[*(m_bit*)prepare_code]; } PREPARE(vmin); -- 2.43.0