diff --git a/lib/mom/slot_load.rb b/lib/mom/slot_load.rb index c834d20d..089d66fe 100644 --- a/lib/mom/slot_load.rb +++ b/lib/mom/slot_load.rb @@ -28,15 +28,17 @@ module Mom class SlotLoad < Instruction attr_reader :left , :right def initialize(left , right) + left = SlotDefinition.new(left.shift , left) if left.is_a? Array @left , @right = left , right + raise "right not SlotDefinition, #{left}" unless left.is_a? SlotDefinition end end - # A SlotConstant moves a constant into a know Slot. + # A SlotConstant moves a constant into a known Slot. # Eg when you write a = 5 , the 5 becomes a constant, and so the right side # the a is an instance variable on the current frame, and the frame is an instance # of the current message, so the effect is something like message.frame.a = 5 - # @left: See SlotLoad, and array of symbols + # @left: See SlotLoad, an array of symbols # @right: A Constant from parse, ie an instance of classes in basc_value, like TrueStatement class SlotConstant < SlotLoad @@ -47,6 +49,7 @@ module Mom end + #SlotMove is a SlotLoad where the right side is a slot, just like the left. class SlotMove < SlotLoad end diff --git a/test/vool/to_mom/send/simple_send_harness.rb b/test/vool/to_mom/send/simple_send_harness.rb index a00a7d0d..a258a8e3 100644 --- a/test/vool/to_mom/send/simple_send_harness.rb +++ b/test/vool/to_mom/send/simple_send_harness.rb @@ -14,7 +14,7 @@ module Vool assert_equal Mom::ArgumentTransfer, @stats[1].class end def test_receiver_move - assert_equal :receiver, @stats[1].receiver.left[2] + assert_equal :receiver, @stats[1].receiver.left.slots[1] end def test_receiver type , value = receiver diff --git a/test/vool/to_mom/send/test_send_cached_simple.rb b/test/vool/to_mom/send/test_send_cached_simple.rb index 1641930a..199a0f36 100644 --- a/test/vool/to_mom/send/test_send_cached_simple.rb +++ b/test/vool/to_mom/send/test_send_cached_simple.rb @@ -44,7 +44,8 @@ module Vool end def test_call_third - assert @fourth.method_var_name.start_with?("cached_") , @fourth.to_rxf + assert @fourth.cached_method.start_with?("cached_") , @fourth.to_rxf + assert @fourth.cached_type.start_with?("cached_") , @fourth.to_rxf end def est_receiver_move_class diff --git a/test/vool/to_mom/send/test_send_simple_args.rb b/test/vool/to_mom/send/test_send_simple_args.rb index 59b82cd7..8eb6e629 100644 --- a/test/vool/to_mom/send/test_send_simple_args.rb +++ b/test/vool/to_mom/send/test_send_simple_args.rb @@ -15,8 +15,8 @@ module Vool [IntegerStatement , 5] end def test_args_two_move - assert_equal :next_message, @stats[1].arguments[1].left[1] - assert_equal :arguments, @stats[1].arguments[1].left[2] + assert_equal :next_message, @stats[1].arguments[1].left.slots[0] + assert_equal :arguments, @stats[1].arguments[1].left.slots[1] end def test_args_two_str assert_equal IntegerStatement, @stats[1].arguments[1].right.class diff --git a/test/vool/to_mom/send/test_send_simple_string.rb b/test/vool/to_mom/send/test_send_simple_string.rb index d252e88c..a08c977f 100644 --- a/test/vool/to_mom/send/test_send_simple_string.rb +++ b/test/vool/to_mom/send/test_send_simple_string.rb @@ -16,8 +16,8 @@ module Vool end def test_args_one_move - assert_equal :next_message, @stats[1].arguments[0].left[1] - assert_equal :arguments, @stats[1].arguments[0].left[2] + assert_equal :next_message, @stats[1].arguments[0].left.slots[0] + assert_equal :arguments, @stats[1].arguments[0].left.slots[1] end def test_args_one_str assert_equal IntegerStatement, @stats[1].arguments[0].right.class diff --git a/test/vool/to_mom/test_ivar.rb b/test/vool/to_mom/test_ivar.rb index ae099b2a..61bd285e 100644 --- a/test/vool/to_mom/test_ivar.rb +++ b/test/vool/to_mom/test_ivar.rb @@ -19,13 +19,13 @@ module Vool assert @method.first.left end def test_slot_starts_at_message - assert_equal :message , @method.first.left[0] + assert_equal :message , @method.first.left.known_object end def test_slot_gets_self - assert_equal :self , @method.first.left[1] + assert_equal :self , @method.first.left.slots[0] end def test_slot_assigns_to_local - assert_equal :a , @method.first.left[-1] + assert_equal :a , @method.first.left.slots[-1] end def test_slot_assigns_something assert @method.first.right diff --git a/test/vool/to_mom/test_return.rb b/test/vool/to_mom/test_return.rb index 998b4f23..4f0883a9 100644 --- a/test/vool/to_mom/test_return.rb +++ b/test/vool/to_mom/test_return.rb @@ -25,10 +25,10 @@ module Vool assert_equal Mom::ReturnSequence, @stats.last.class end def test_slot_starts_at_message - assert_equal :message , @stats.first.left[0] + assert_equal :message , @stats.first.left.known_object end def test_slot_gets_return - assert_equal :return_value , @stats.first.left[1] + assert_equal :return_value , @stats.first.left.slots[0] end def test_slot_assigns_something assert @stats.first.right