From 265e10a8fbc2b69beff60c4101506c48aa7b6fbb Mon Sep 17 00:00:00 2001 From: Mau Magnaguagno Date: Sun, 7 Jan 2024 04:26:08 -0300 Subject: [PATCH] Fix empty bytecode with blank tape in MindFreak optimize --- MindFreak.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MindFreak.rb b/MindFreak.rb index cb9b4b9..da3bf72 100644 --- a/MindFreak.rb +++ b/MindFreak.rb @@ -313,7 +313,7 @@ def bytecode(program) def optimize(bytecode, blank_tape = false) # Dead code elimination - bytecode.shift(bytecode[0][1]+1) if blank_tape and bytecode[0][0] == JUMP and not bytecode[1][0] == INCREMENT && bytecode[2][0] == JUMPBACK + bytecode.shift(bytecode[0][1]+1) if blank_tape and bytecode[0] and bytecode[0][0] == JUMP and bytecode[1][0] != INCREMENT || bytecode[2][0] != JUMPBACK clear = [INCREMENT, 0, nil, true] memory = Hash.new(0) i = -1