diff --git a/lib/vool/local_assignment.rb b/lib/vool/local_assignment.rb index fcc93ee4..85019b0a 100644 --- a/lib/vool/local_assignment.rb +++ b/lib/vool/local_assignment.rb @@ -10,7 +10,9 @@ module Vool # Only snag is that we do not know this position, as only the compiler knows # if the variable name is a local or an arg. So we delegate to the compiler. def slot_position( compiler ) - compiler.slot_type_for(@name) + slot = compiler.slot_type_for(@name) + #puts "SLOT= #{slot}" + slot end end diff --git a/lib/vool/send_statement.rb b/lib/vool/send_statement.rb index 2a7ffff3..187c7a28 100644 --- a/lib/vool/send_statement.rb +++ b/lib/vool/send_statement.rb @@ -46,10 +46,10 @@ module Vool def message_setup(compiler,called_method) setup = Mom::MessageSetup.new( called_method ) mom_receive = @receiver.to_slot(compiler) - arg_target = [:message , :next_message , :arguments] + arg_target = [:message , :next_message ] args = [] @arguments.each_with_index do |arg , index| # +1 because of type - args << Mom::SlotLoad.new(self, arg_target + [index + 1] , arg.to_slot(compiler)) + args << Mom::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot(compiler)) end setup << Mom::ArgumentTransfer.new(self, mom_receive , args ) end diff --git a/lib/vool/yield_statement.rb b/lib/vool/yield_statement.rb index 13e1ac15..02de0092 100644 --- a/lib/vool/yield_statement.rb +++ b/lib/vool/yield_statement.rb @@ -50,10 +50,10 @@ module Vool arg_index = compiler.get_method.arguments_type.get_length - 1 setup = Mom::MessageSetup.new( arg_index ) mom_receive = @receiver.to_slot(compiler) - arg_target = [:message , :next_message , :arguments] + arg_target = [:message , :next_message ] args = [] @arguments.each_with_index do |arg , index| # +1 because of type - args << Mom::SlotLoad.new(self, arg_target + [index + 1] , arg.to_slot(compiler)) + args << Mom::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot(compiler)) end setup << Mom::ArgumentTransfer.new( self , mom_receive , args ) setup << Mom::BlockYield.new( self , arg_index ) diff --git a/test/vool/lambdas/test_assign.rb b/test/vool/lambdas/test_assign.rb index e7966b2b..92e64870 100644 --- a/test/vool/lambdas/test_assign.rb +++ b/test/vool/lambdas/test_assign.rb @@ -60,7 +60,7 @@ module VoolBlocks assert @ins.left end def test_slots_left - assert_equal [:caller,:caller, :arguments, :arg] , @ins.left.slots + assert_equal [:caller,:caller, :arg1] , @ins.left.slots end end diff --git a/test/vool/send/test_send_args_send.rb b/test/vool/send/test_send_args_send.rb index f3fb4fd5..713a9fe6 100644 --- a/test/vool/send/test_send_args_send.rb +++ b/test/vool/send/test_send_args_send.rb @@ -29,7 +29,7 @@ module Vool left = @ins.next(1).arguments[0].left assert_equal Symbol, left.known_object.class assert_equal :message, left.known_object - assert_equal [:next_message, :arguments, 1], left.slots + assert_equal [:next_message, :arg1], left.slots end end end diff --git a/test/vool/send/test_send_simple_args.rb b/test/vool/send/test_send_simple_args.rb index 734fd710..427b27b0 100644 --- a/test/vool/send/test_send_simple_args.rb +++ b/test/vool/send/test_send_simple_args.rb @@ -13,7 +13,7 @@ module Vool end def test_args_two_move assert_equal :next_message, @ins.next(1).arguments[1].left.slots[0] - assert_equal :arguments, @ins.next(1).arguments[1].left.slots[1] + assert_equal :arg2, @ins.next(1).arguments[1].left.slots[1] end def test_args_two_str assert_equal Mom::IntegerConstant, @ins.next(1).arguments[1].right.known_object.class diff --git a/test/vool/send/test_send_simple_string.rb b/test/vool/send/test_send_simple_string.rb index b6e3bd80..09edaabf 100644 --- a/test/vool/send/test_send_simple_string.rb +++ b/test/vool/send/test_send_simple_string.rb @@ -13,12 +13,12 @@ module Vool def test_args_one_move assert_equal :next_message, @ins.next.arguments[0].left.slots[0] - assert_equal :arguments, @ins.next.arguments[0].left.slots[1] + assert_equal :arg1, @ins.next.arguments[0].left.slots[1] end def test_args_one_str assert_equal Mom::IntegerConstant, @ins.next.arguments[0].right.known_object.class assert_equal 1, @ins.next.arguments[0].right.known_object.value - assert_equal [:next_message, :arguments, 1], @ins.next.arguments[0].left.slots + assert_equal [:next_message, :arg1], @ins.next.arguments[0].left.slots end end end diff --git a/test/vool/test_assignment.rb b/test/vool/test_assignment.rb index 9ddddc05..43e61704 100644 --- a/test/vool/test_assignment.rb +++ b/test/vool/test_assignment.rb @@ -65,11 +65,8 @@ module Vool def test_slot_starts_at_message assert_equal :message , @ins.left.known_object end - def test_slot_gets_self - assert_equal :arguments , @ins.left.slots[0] - end - def test_slot_assigns_to_local - assert_equal :arg , @ins.left.slots[-1] + def test_slot_gets_arg + assert_equal :arg1 , @ins.left.slots[0] end end diff --git a/test/vool/test_local_assignment.rb b/test/vool/test_local_assignment.rb index 4df953f9..45a68a64 100644 --- a/test/vool/test_local_assignment.rb +++ b/test/vool/test_local_assignment.rb @@ -35,4 +35,34 @@ module Vool assert_equal Mom::IntegerConstant , @ins.right.known_object.class end end + + class TestArgMom < MiniTest::Test + include VoolCompile + + def setup + Parfait.boot!(Parfait.default_test_options) + @compiler = compile_first_method( "arg = 5") + @ins = @compiler.mom_instructions.next + end + + def test_class_compiles + assert_equal Mom::SlotLoad , @ins.class , @ins + end + def test_slot_is_set + assert @ins.left + end + def test_slot_starts_at_message + assert_equal :message , @ins.left.known_object + end + def test_slot_gets_arg + assert_equal :arg1 , @ins.left.slots[0] + end + def test_slot_assigns_something + assert @ins.right + end + def test_slot_assigns_int + assert_equal Mom::IntegerConstant , @ins.right.known_object.class + end + end + end diff --git a/test/vool/test_yield_statement.rb b/test/vool/test_yield_statement.rb index 1dbd59ad..9304f26d 100644 --- a/test/vool/test_yield_statement.rb +++ b/test/vool/test_yield_statement.rb @@ -26,7 +26,7 @@ module Vool left = @ins.next(3).arguments[0].left assert_equal Symbol, left.known_object.class assert_equal :message, left.known_object - assert_equal [:next_message, :arguments, 1], left.slots + assert_equal [:next_message, :arg1], left.slots end def test_check_left assert_equal SlotDefinition, @ins.left.class