fix slot_moves for sending, receiver and args

This commit is contained in:
Torsten Ruger 2017-09-10 13:14:51 +03:00
parent 43d660d2d2
commit c245acbdd3
5 changed files with 16 additions and 14 deletions

View File

@ -38,10 +38,10 @@ module Vool
end end
def message_setup def message_setup
pops = [Mom::SlotConstant.new([:message , :next_message , :receiver] , @receiver) ] pops = [@receiver.slot_class.new([:message , :next_message , :receiver] , @receiver) ]
@arguments.each_with_index do |arg , index| @arguments.each_with_index do |arg , index|
arg_target = [:message , :next_message , :arguments] arg_target = [:message , :next_message , :arguments]
pops << Mom::SlotConstant.new( arg_target + [index] , arg) pops << arg.slot_class.new( arg_target + [index] , arg)
end end
pops pops
end end
@ -63,7 +63,7 @@ module Vool
def cached_call def cached_call
raise "Not implemented" raise "Not implemented"
[Mom::SlotConstant.new([:message , :next_message , :receiver] , @receiver) ] [@receiver.slot_class.new([:message , :next_message , :receiver] , @receiver) ]
end end
end end

View File

@ -24,7 +24,7 @@ module Mom
assert_equal 9 , @stats.length assert_equal 9 , @stats.length
end end
def test_array def test_array
check_array [SlotMove,TruthCheck,Label,SimpleCall,SlotMove,Label,SimpleCall,SlotMove,Label] , @stats check_array [SlotMove,TruthCheck,Label,SimpleCall,SlotConstant,Label,SimpleCall,SlotConstant,Label] , @stats
end end
end end
end end

View File

@ -7,13 +7,14 @@ module Vool
def setup def setup
Risc.machine.boot Risc.machine.boot
@stats = compile_first_method( "5.mod4").first @stats = compile_first_method( "5.mod4").first
@first = @stats.first
end end
def test_compiles_not_array def test_compiles_not_array
assert Array != @stats.class , @stats assert Array != @stats.class , @stats
end end
def test_class_compiles def test_class_compiles
assert_equal Mom::SlotMove , @stats.first.class , @stats assert_equal Mom::SlotConstant , @first.class , @stats
end end
def test_slot_is_set def test_slot_is_set
assert @stats.first.left assert @stats.first.left
@ -22,13 +23,13 @@ module Vool
assert_equal 2 , @stats.length assert_equal 2 , @stats.length
end end
def test_receiver_move_class def test_receiver_move_class
assert_equal Mom::SlotMove, @stats.first.class assert_equal Mom::SlotConstant, @first.class
end end
def test_receiver_move def test_receiver_move
assert_equal :receiver, @stats.first.left[2] assert_equal :receiver, @first.left[2]
end end
def test_receiver def test_receiver
assert_equal IntegerStatement, @stats.first.right.class assert_equal IntegerStatement, @first.right.class
assert_equal 5, @stats.first.right.value assert_equal 5, @stats.first.right.value
end end
def test_call_is def test_call_is

View File

@ -13,13 +13,13 @@ module Vool
assert_equal Mom::Statements , @stats.class assert_equal Mom::Statements , @stats.class
end end
def test_class_compiles def test_class_compiles
assert_equal Mom::SlotMove , @stats.first.class , @stats assert_equal Mom::SlotConstant , @stats.first.class , @stats
end end
def test_four_instructions_are_returned def test_four_instructions_are_returned
assert_equal 4 , @stats.length assert_equal 4 , @stats.length
end end
def test_receiver_move def test_receiver_move
assert_equal Mom::SlotMove, @stats[0].class assert_equal Mom::SlotConstant, @stats[0].class
assert_equal :receiver, @stats[0].left[2] assert_equal :receiver, @stats[0].left[2]
end end
def test_receiver def test_receiver

View File

@ -7,24 +7,25 @@ module Vool
def setup def setup
Risc.machine.boot Risc.machine.boot
@stats = compile_first_method( "'5'.get_internal_byte(1)").first @stats = compile_first_method( "'5'.get_internal_byte(1)").first
@first = @stats.first
end end
def test_compiles_not_array def test_compiles_not_array
assert Array != @stats.class , @stats assert Array != @stats.class , @stats
end end
def test_class_compiles def test_class_compiles
assert_equal Mom::SlotMove , @stats.first.class , @stats assert_equal Mom::SlotConstant , @first.class , @stats
end end
def test_four_instructions_are_returned def test_four_instructions_are_returned
assert_equal 3 , @stats.length assert_equal 3 , @stats.length
end end
def test_receiver_move def test_receiver_move
assert_equal Mom::SlotMove, @stats.first.class assert_equal Mom::SlotConstant, @stats.first.class
assert_equal :receiver, @stats[0].left[2] assert_equal :receiver, @first.left[2]
end end
def test_receiver def test_receiver
assert_equal StringStatement, @stats[0].right.class assert_equal StringStatement, @stats[0].right.class
assert_equal "5", @stats[0].right.value assert_equal "5", @first.right.value
end end
def test_args_one_move def test_args_one_move
assert_equal :next_message, @stats[1].left[1] assert_equal :next_message, @stats[1].left[1]