diff --git a/lib/mom/instruction/slot_load.rb b/lib/mom/instruction/slot_load.rb index 987d458c..b50453b2 100644 --- a/lib/mom/instruction/slot_load.rb +++ b/lib/mom/instruction/slot_load.rb @@ -21,7 +21,7 @@ module Mom # The first element is either a known type name (Capitalized symbol of the class name) , # or the symbol :message # And subsequent symbols must be instance variables on the previous type. - # Examples: [:message , :self] or [:Space : :next_message] + # Examples: [:message , :receiver] or [:Space : :next_message] # # @right: depends on the derived Class # diff --git a/lib/mom/instruction/slot_move.rb b/lib/mom/instruction/slot_move.rb index 141d1410..b85fd1b6 100644 --- a/lib/mom/instruction/slot_move.rb +++ b/lib/mom/instruction/slot_move.rb @@ -2,8 +2,14 @@ module Mom #SlotMove is a SlotLoad where the right side is a slot, just like the left. class SlotMove < SlotLoad - def to_risc(compiler) + def initialize(left , right) + right = SlotDefinition.new(right.shift , right) if right.is_a? Array + super(left , right) + end + + def to_risc(context) + Risc::Label.new(self,"SlotMove") end end end diff --git a/lib/risc/builtin/compile_helper.rb b/lib/risc/builtin/compile_helper.rb index b001ab3a..35252c1d 100644 --- a/lib/risc/builtin/compile_helper.rb +++ b/lib/risc/builtin/compile_helper.rb @@ -4,7 +4,7 @@ module Risc module CompileHelper def self_and_int_arg(compiler , source) - me = compiler.add_known( :self ) + me = compiler.add_known( :receiver ) int_arg = load_int_arg_at(compiler , source , 1 ) return me , int_arg end diff --git a/lib/risc/builtin/integer.rb b/lib/risc/builtin/integer.rb index 4578a5fd..2e019356 100644 --- a/lib/risc/builtin/integer.rb +++ b/lib/risc/builtin/integer.rb @@ -18,9 +18,9 @@ module Risc def div10 context s = "div_10" compiler = Risc::MethodCompiler.create_method(:Integer,:div10 ).init_method - me = compiler.add_known( :self ) - tmp = compiler.add_known( :self ) - q = compiler.add_known( :self ) + me = compiler.add_known( :receiver ) + tmp = compiler.add_known( :receiver ) + q = compiler.add_known( :receiver ) const = compiler.use_reg :Integer , 1 compiler.add_load_constant( s, 1 , const ) # int tmp = self >> 1 diff --git a/lib/risc/method_compiler.rb b/lib/risc/method_compiler.rb index ca4e9f4a..d61c562c 100644 --- a/lib/risc/method_compiler.rb +++ b/lib/risc/method_compiler.rb @@ -66,7 +66,7 @@ module Risc def add_known(name) case name - when :self + when :receiver ret = use_reg @type add_slot_to_reg(" load self" , :message , :receiver , ret ) return ret diff --git a/lib/vool/statements/assign_statement.rb b/lib/vool/statements/assign_statement.rb index fc5bd80b..2d77a7fa 100644 --- a/lib/vool/statements/assign_statement.rb +++ b/lib/vool/statements/assign_statement.rb @@ -18,7 +18,7 @@ module Vool end def to_mom( method ) - @value.slot_class.new([:message , :self , @name] , @value.to_mom(method)) + @value.slot_class.new([:message , :receiver , @name] , @value.to_mom(method)) end end diff --git a/lib/vool/statements/basic_values.rb b/lib/vool/statements/basic_values.rb index 8535cd90..fab8cfd8 100644 --- a/lib/vool/statements/basic_values.rb +++ b/lib/vool/statements/basic_values.rb @@ -52,7 +52,7 @@ module Vool @clazz = clazz end def to_mom(in_method) - Mom::SlotDefinition.new(:message , [:self]) + Mom::SlotDefinition.new(:message , [:receiver]) end def ct_type @clazz.instance_type diff --git a/lib/vool/statements/send_statement.rb b/lib/vool/statements/send_statement.rb index 2ac2195f..7731bce0 100644 --- a/lib/vool/statements/send_statement.rb +++ b/lib/vool/statements/send_statement.rb @@ -93,16 +93,16 @@ module Vool private def build_condition cached_type = Mom::SlotDefinition.new(@dynamic , [:cached_type]) - current_type = Mom::SlotDefinition.new(:message , [:self , :type]) + current_type = Mom::SlotDefinition.new(:message , [:receiver , :type]) Mom::NotSameCheck.new(cached_type , current_type) end def build_type_cache_update - [Mom::SlotMove.new([@dynamic, :cached_type] , [:self , :type])] + [Mom::SlotMove.new([@dynamic, :cached_type] , [:receiver , :type])] end def build_method_cache_update(in_method) receiver = StringStatement.new(@name) resolve = SendStatement.new(:resolve_method , receiver , [SelfStatement.new]) - move_method = Mom::SlotMove.new([@dynamic, :cached_method] , [:self , :return]) + move_method = Mom::SlotMove.new([@dynamic, :cached_method] , [:receiver , :return]) resolve.to_mom(in_method) << move_method end end diff --git a/lib/vool/statements/variables.rb b/lib/vool/statements/variables.rb index 5281cfad..c06c8dcc 100644 --- a/lib/vool/statements/variables.rb +++ b/lib/vool/statements/variables.rb @@ -21,7 +21,7 @@ module Vool class InstanceVariable < Statement include Named def to_mom(method) - Mom::SlotDefinition.new(:message , [ :self , @name] ) + Mom::SlotDefinition.new(:message , [ :receiver , @name] ) end # used to collect type information def add_ivar( array ) diff --git a/test/vool/to_mom/test_ivar.rb b/test/vool/to_mom/test_ivar.rb index ef817b45..e7fad65a 100644 --- a/test/vool/to_mom/test_ivar.rb +++ b/test/vool/to_mom/test_ivar.rb @@ -22,7 +22,7 @@ module Vool assert_equal :message , @method.first.left.known_object end def test_slot_gets_self - assert_equal :self , @method.first.left.slots[0] + assert_equal :receiver , @method.first.left.slots[0] end def test_slot_assigns_to_local assert_equal :a , @method.first.left.slots[-1]