rename self to receiver

just because it is a keyword and can’t be used
This commit is contained in:
Torsten Ruger 2018-03-14 20:26:13 +05:30
parent 2533842204
commit 03a4e04f7e
10 changed files with 20 additions and 14 deletions

View File

@ -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
#

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 )

View File

@ -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]