add set_slot and save_return
as functions to generate instructions
This commit is contained in:
parent
a24e96efbc
commit
1e18db00c9
@ -24,6 +24,7 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.look_like_reg is_it
|
def self.look_like_reg is_it
|
||||||
|
return true if is_it.is_a? RegisterReference
|
||||||
return false unless is_it.is_a? Symbol
|
return false unless is_it.is_a? Symbol
|
||||||
if( [:lr , :pc].include? is_it )
|
if( [:lr , :pc].include? is_it )
|
||||||
return true
|
return true
|
||||||
@ -84,13 +85,26 @@ module Register
|
|||||||
GetSlot.new( from , index , to)
|
GetSlot.new( from , index , to)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.set_slot from , to , index
|
||||||
|
index = resolve_index( to , index)
|
||||||
|
from = resolve_to_register from
|
||||||
|
to = resolve_to_register to
|
||||||
|
SetSlot.new( from , to , index)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.save_return from , index
|
||||||
|
index = resolve_index( from , index)
|
||||||
|
from = resolve_to_register from
|
||||||
|
SaveReturn.new( from , index )
|
||||||
|
end
|
||||||
|
|
||||||
def self.resolve_index( clazz_name , instance_name )
|
def self.resolve_index( clazz_name , instance_name )
|
||||||
return instance_name unless instance_name.is_a? Symbol
|
return instance_name unless instance_name.is_a? Symbol
|
||||||
real_name = "#{clazz_name}".capitalize.to_sym
|
real_name = clazz_name.to_s.split('_').last.capitalize.to_sym
|
||||||
clazz = Parfait::Space.object_space.get_class_by_name(real_name)
|
clazz = Parfait::Space.object_space.get_class_by_name(real_name)
|
||||||
raise "Class name not given #{real_name}" unless clazz
|
raise "Class name not given #{real_name}" unless clazz
|
||||||
index = clazz.object_layout.index_of( instance_name )
|
index = clazz.object_layout.index_of( instance_name )
|
||||||
raise "Instance name=#{instance_name} not found on #{real_name}" unless index
|
raise "Instance name=#{instance_name} not found on #{real_name}" unless index.is_a?(Numeric)
|
||||||
return index
|
return index
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -100,6 +114,8 @@ module Register
|
|||||||
case reference
|
case reference
|
||||||
when :message
|
when :message
|
||||||
register = message_reg
|
register = message_reg
|
||||||
|
when :new_message
|
||||||
|
register = new_message_reg
|
||||||
when :self
|
when :self
|
||||||
register = self_reg
|
register = self_reg
|
||||||
when :frame
|
when :frame
|
||||||
|
Loading…
Reference in New Issue
Block a user