diff --git a/lib/risc/interpreter.rb b/lib/risc/interpreter.rb index 696c104c..c6a62e4b 100644 --- a/lib/risc/interpreter.rb +++ b/lib/risc/interpreter.rb @@ -141,6 +141,7 @@ module Risc else value = object.get_internal_word( index ) end + log.debug "#{@instruction} == #{object}(#{object.class}) (#{value}|#{index})" set_register( @instruction.register , value ) true end @@ -153,7 +154,6 @@ module Risc else index = get_register(@instruction.index) end - puts "INDEX #{index} #{value}" object.set_internal_word( index , value ) trigger(:object_changed, @instruction.array , index) true diff --git a/lib/vool/statements/send_statement.rb b/lib/vool/statements/send_statement.rb index 16d5dffe..69899d77 100644 --- a/lib/vool/statements/send_statement.rb +++ b/lib/vool/statements/send_statement.rb @@ -80,8 +80,8 @@ module Vool mom_receive = @receiver.slot_definition(in_method) arg_target = [:message , :next_message , :arguments] args = [] - @arguments.each_with_index do |arg , index| # +1 because of type, + 1 beacuse 1-indexed - args << Mom::SlotLoad.new( arg_target + [index+1+1] , arg.slot_definition(in_method)) + @arguments.each_with_index do |arg , index| # +1 because of type + args << Mom::SlotLoad.new( arg_target + [index + 1] , arg.slot_definition(in_method)) end setup << Mom::ArgumentTransfer.new( mom_receive , args ) end diff --git a/test/mom/send/test_send_simple_args.rb b/test/mom/send/test_send_simple_args.rb index dfae89b0..63a3d548 100644 --- a/test/mom/send/test_send_simple_args.rb +++ b/test/mom/send/test_send_simple_args.rb @@ -50,7 +50,7 @@ module Risc assert_equal RegToSlot , produced.next(base+3).class assert_equal :r1 , produced.next(base+3).register.symbol assert_equal :r3 , produced.next(base+3).array.symbol - assert_equal 2 , produced.next(base+3).index , "first arg must have index 1" + assert_equal 1 , produced.next(base+3).index , "first arg must have index 1" end def test_load_label produced = produce_body diff --git a/test/parfait/test_word.rb b/test/parfait/test_word.rb index dc8d085d..9f6531bc 100644 --- a/test/parfait/test_word.rb +++ b/test/parfait/test_word.rb @@ -110,5 +110,19 @@ module Parfait two = Parfait.new_word("one") assert one.compare(two) end + def test_first_char + one = Parfait.new_word("one") + one.set_char(0 , "T".ord) + assert_equal "Tne" , one.to_string + end + def test_sec_char + one = Parfait.new_word("one") + one.set_char(1 , "m".ord) + assert_equal "ome" , one.to_string + end + def test_more_char + one = Parfait.new_word("one") + assert_raises {one.set_char(3 , "s".ord)} + end end end diff --git a/test/risc/interpreter/calling/test_get_byte.rb b/test/risc/interpreter/calling/test_get_byte.rb index c79df22d..af7e4707 100644 --- a/test/risc/interpreter/calling/test_get_byte.rb +++ b/test/risc/interpreter/calling/test_get_byte.rb @@ -5,7 +5,7 @@ module Risc include Ticker def setup - @string_input = as_main("return 'Hello'.get_internal_byte(1)") + @string_input = as_main("return 'Hello'.get_internal_byte(0)") super end def test_chain diff --git a/test/risc/interpreter/calling/test_set_byte.rb b/test/risc/interpreter/calling/test_set_byte.rb index cabe1e0f..78f20e80 100644 --- a/test/risc/interpreter/calling/test_set_byte.rb +++ b/test/risc/interpreter/calling/test_set_byte.rb @@ -5,7 +5,7 @@ module Risc include Ticker def setup - @string_input = as_main("return 'Hello'.set_internal_byte(1,75)") + @string_input = as_main("return 'Hello'.set_internal_byte(0,75)") super end