From 959cb628fa602bbdf9ae88bf29f3754399732695 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 24 Jul 2015 15:48:12 +0300 Subject: [PATCH] implements fetching of next instruction --- lib/interpreter.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/interpreter.rb b/lib/interpreter.rb index 9b375c2..e544a57 100644 --- a/lib/interpreter.rb +++ b/lib/interpreter.rb @@ -50,9 +50,17 @@ class Interpreter name = @instruction.class.name.split("::").last fetch = send "execute_#{name}" return unless fetch - get_next_intruction + fetch_next_intruction end + def fetch_next_intruction + if(@instruction != @block.codes.last) + set_instruction @block.codes[ @block.codes.index(@instruction) + 1] + else + next_b = @block.method.source.blocks.index(@block) + 1 + set_block @block.method.source.blocks[next_b] + end + end def execute_Branch target = @instruction.block set_block target