Skip to content

Commit

Permalink
Fix empty bytecode with blank tape in MindFreak optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
Maumagnaguagno committed Jan 7, 2024
1 parent 7169b42 commit 265e10a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion MindFreak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 265e10a

Please sign in to comment.