From 5a79f27b837a7bbac19ee29f4c1f59e57da3f238 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Fri, 3 Jun 2022 13:07:49 +0900 Subject: [PATCH] Fix incorrect OP_CLOSURE instruction size returned by dis.examine --- src/debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/debug.c b/src/debug.c index a3f2b96..adb79c9 100644 --- a/src/debug.c +++ b/src/debug.c @@ -633,13 +633,15 @@ KRK_FUNC(build,{ size = 3; break; } #define CLOSURE_MORE \ KrkCodeObject * function = AS_codeobject(chunk->constants.values[constant]); \ + size_t baseOffset = offset; \ for (size_t j = 0; j < function->upvalueCount; ++j) { \ - int isLocal = chunk->code[offset++ + size]; \ - offset++; \ + int isLocal = chunk->code[baseOffset++ + size]; \ + baseOffset++; \ if (isLocal & 2) { \ - offset += 2; \ + baseOffset += 2; \ } \ - } + } \ + size += baseOffset - offset; #define EXPAND_ARGS_MORE #define LOCAL_MORE local = operand; static KrkValue _examineInternal(KrkCodeObject* func) {