From 35afe88edea7c17db07d7b19c8c20b51809de6b8 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 7 Nov 2015 17:34:41 +0200 Subject: [PATCH] allow get_slot with two registers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit before was register and number, but for runtime that doesn’t work --- lib/interpreter/interpreter.rb | 9 +++++++-- lib/register/instructions/get_slot.rb | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/interpreter/interpreter.rb b/lib/interpreter/interpreter.rb index 711ff16c..660d1314 100644 --- a/lib/interpreter/interpreter.rb +++ b/lib/interpreter/interpreter.rb @@ -120,7 +120,12 @@ module Interpreter def execute_GetSlot object = object_for( @instruction.array ) - value = object.internal_object_get( @instruction.index ) + if( @instruction.index.is_a?(Numeric) ) + index = @instruction.index + else + index = get_register(@instruction.index) + end + value = object.internal_object_get( index ) #value = value.object_id unless value.is_a? Fixnum set_register( @instruction.register , value ) true @@ -192,7 +197,7 @@ module Interpreter else raise "unimplemented '#{@instruction.operator}' #{@instruction}" end - ## result not over 2**62 => overflow + ## result not over 2**62 => overflow log.debug "#{@instruction} == #{result} (#{left}|#{right})" right = set_register(@instruction.left , result) true diff --git a/lib/register/instructions/get_slot.rb b/lib/register/instructions/get_slot.rb index a921178b..0426b598 100644 --- a/lib/register/instructions/get_slot.rb +++ b/lib/register/instructions/get_slot.rb @@ -23,8 +23,8 @@ module Register @array = array @index = index @register = register - raise "index 0 " if index == 0 - raise "not integer #{index}" unless index.is_a? Numeric + raise "index 0 " if index == 0 + raise "Not integer or reg #{index}" unless index.is_a?(Numeric) or RegisterValue.look_like_reg(index) raise "Not register #{register}" unless RegisterValue.look_like_reg(register) raise "Not register #{array}" unless RegisterValue.look_like_reg(array) end