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