rename self to receiver
just because it is a keyword and can’t be used
This commit is contained in:
parent
2533842204
commit
03a4e04f7e
@ -21,7 +21,7 @@ module Mom
|
|||||||
# The first element is either a known type name (Capitalized symbol of the class name) ,
|
# The first element is either a known type name (Capitalized symbol of the class name) ,
|
||||||
# or the symbol :message
|
# or the symbol :message
|
||||||
# And subsequent symbols must be instance variables on the previous type.
|
# 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
|
# @right: depends on the derived Class
|
||||||
#
|
#
|
||||||
|
@ -2,8 +2,14 @@ module Mom
|
|||||||
|
|
||||||
#SlotMove is a SlotLoad where the right side is a slot, just like the left.
|
#SlotMove is a SlotLoad where the right side is a slot, just like the left.
|
||||||
class SlotMove < SlotLoad
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ module Risc
|
|||||||
module CompileHelper
|
module CompileHelper
|
||||||
|
|
||||||
def self_and_int_arg(compiler , source)
|
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 )
|
int_arg = load_int_arg_at(compiler , source , 1 )
|
||||||
return me , int_arg
|
return me , int_arg
|
||||||
end
|
end
|
||||||
|
@ -18,9 +18,9 @@ module Risc
|
|||||||
def div10 context
|
def div10 context
|
||||||
s = "div_10"
|
s = "div_10"
|
||||||
compiler = Risc::MethodCompiler.create_method(:Integer,:div10 ).init_method
|
compiler = Risc::MethodCompiler.create_method(:Integer,:div10 ).init_method
|
||||||
me = compiler.add_known( :self )
|
me = compiler.add_known( :receiver )
|
||||||
tmp = compiler.add_known( :self )
|
tmp = compiler.add_known( :receiver )
|
||||||
q = compiler.add_known( :self )
|
q = compiler.add_known( :receiver )
|
||||||
const = compiler.use_reg :Integer , 1
|
const = compiler.use_reg :Integer , 1
|
||||||
compiler.add_load_constant( s, 1 , const )
|
compiler.add_load_constant( s, 1 , const )
|
||||||
# int tmp = self >> 1
|
# int tmp = self >> 1
|
||||||
|
@ -66,7 +66,7 @@ module Risc
|
|||||||
|
|
||||||
def add_known(name)
|
def add_known(name)
|
||||||
case name
|
case name
|
||||||
when :self
|
when :receiver
|
||||||
ret = use_reg @type
|
ret = use_reg @type
|
||||||
add_slot_to_reg(" load self" , :message , :receiver , ret )
|
add_slot_to_reg(" load self" , :message , :receiver , ret )
|
||||||
return ret
|
return ret
|
||||||
|
@ -18,7 +18,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_mom( method )
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -52,7 +52,7 @@ module Vool
|
|||||||
@clazz = clazz
|
@clazz = clazz
|
||||||
end
|
end
|
||||||
def to_mom(in_method)
|
def to_mom(in_method)
|
||||||
Mom::SlotDefinition.new(:message , [:self])
|
Mom::SlotDefinition.new(:message , [:receiver])
|
||||||
end
|
end
|
||||||
def ct_type
|
def ct_type
|
||||||
@clazz.instance_type
|
@clazz.instance_type
|
||||||
|
@ -93,16 +93,16 @@ module Vool
|
|||||||
private
|
private
|
||||||
def build_condition
|
def build_condition
|
||||||
cached_type = Mom::SlotDefinition.new(@dynamic , [:cached_type])
|
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)
|
Mom::NotSameCheck.new(cached_type , current_type)
|
||||||
end
|
end
|
||||||
def build_type_cache_update
|
def build_type_cache_update
|
||||||
[Mom::SlotMove.new([@dynamic, :cached_type] , [:self , :type])]
|
[Mom::SlotMove.new([@dynamic, :cached_type] , [:receiver , :type])]
|
||||||
end
|
end
|
||||||
def build_method_cache_update(in_method)
|
def build_method_cache_update(in_method)
|
||||||
receiver = StringStatement.new(@name)
|
receiver = StringStatement.new(@name)
|
||||||
resolve = SendStatement.new(:resolve_method , receiver , [SelfStatement.new])
|
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
|
resolve.to_mom(in_method) << move_method
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,7 @@ module Vool
|
|||||||
class InstanceVariable < Statement
|
class InstanceVariable < Statement
|
||||||
include Named
|
include Named
|
||||||
def to_mom(method)
|
def to_mom(method)
|
||||||
Mom::SlotDefinition.new(:message , [ :self , @name] )
|
Mom::SlotDefinition.new(:message , [ :receiver , @name] )
|
||||||
end
|
end
|
||||||
# used to collect type information
|
# used to collect type information
|
||||||
def add_ivar( array )
|
def add_ivar( array )
|
||||||
|
@ -22,7 +22,7 @@ module Vool
|
|||||||
assert_equal :message , @method.first.left.known_object
|
assert_equal :message , @method.first.left.known_object
|
||||||
end
|
end
|
||||||
def test_slot_gets_self
|
def test_slot_gets_self
|
||||||
assert_equal :self , @method.first.left.slots[0]
|
assert_equal :receiver , @method.first.left.slots[0]
|
||||||
end
|
end
|
||||||
def test_slot_assigns_to_local
|
def test_slot_assigns_to_local
|
||||||
assert_equal :a , @method.first.left.slots[-1]
|
assert_equal :a , @method.first.left.slots[-1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user