fix most of slot_load to_risc
higher orders not working yet
This commit is contained in:
parent
cddc25a595
commit
9c052c78a7
@ -28,27 +28,39 @@ module Mom
|
|||||||
def initialize(left , right)
|
def initialize(left , right)
|
||||||
left = SlotDefinition.new(left.shift , left) if left.is_a? Array
|
left = SlotDefinition.new(left.shift , left) if left.is_a? Array
|
||||||
right = SlotDefinition.new(right.shift , right) if right.is_a? Array
|
right = SlotDefinition.new(right.shift , right) if right.is_a? Array
|
||||||
raise "right not Mom, #{right.to_s}" unless right.is_a?( SlotDefinition )or right.is_a? Mom::Constant
|
raise "right not Mom, #{right.to_s}" unless right.is_a?( SlotDefinition )#or right.is_a? Mom::Constant
|
||||||
@left , @right = left , right
|
@left , @right = left , right
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_risc(compiler)
|
def to_risc(compiler)
|
||||||
reg = compiler.use_reg( @right.ct_type)
|
type = @right.respond_to?(:ct_type) ? @right.ct_type : :int
|
||||||
const = Risc.load_constant(self, @right , reg)
|
right = compiler.use_reg( type )
|
||||||
const << Risc.reg_to_slot(self, reg , @left.known_object, @left.slots.first)
|
case @right.known_object
|
||||||
compiler.release_reg(reg)
|
when Constant
|
||||||
|
const = Risc.load_constant(self, @right , right)
|
||||||
|
when Symbol
|
||||||
|
const = Risc::SlotToReg.new( self , Risc.message_reg ,
|
||||||
|
Risc.resolve_to_index(:message , @right.slots[0]), right)
|
||||||
|
puts "more slots #{@right.slots}" if @right.slots.length > 1
|
||||||
|
else
|
||||||
|
raise "We have a #{@right} #{@right.known_object}"
|
||||||
|
end
|
||||||
|
case @left.known_object
|
||||||
|
when Symbol
|
||||||
|
left = Risc.message_reg
|
||||||
|
left_index = Risc.resolve_to_index(@left.known_object , @left.slots.first)
|
||||||
|
when Parfait::CacheEntry
|
||||||
|
left = compiler.use_reg( :int )
|
||||||
|
left_index = Risc.resolve_to_index(:cache_entry , @left.slots.first)
|
||||||
|
else
|
||||||
|
raise "We have left #{@left.known_object}"
|
||||||
|
end
|
||||||
|
const << Risc.reg_to_slot(self, right , left, left_index)
|
||||||
|
compiler.release_reg(left) unless @left.known_object.is_a?(Symbol)
|
||||||
|
compiler.release_reg(right)
|
||||||
return const
|
return const
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_risc_move(context)
|
|
||||||
reg = context.use_reg(:int)#( @right.ct_type)
|
|
||||||
const = Risc.load_constant(self, @right , reg)
|
|
||||||
# const.set_next Risc.reg_to_slot(self, reg , @left.known_object, @left.slots.first)
|
|
||||||
# context.release_reg(reg)
|
|
||||||
return const
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class SlotDefinition
|
class SlotDefinition
|
||||||
@ -61,6 +73,7 @@ module Mom
|
|||||||
def initialize( object , slots)
|
def initialize( object , slots)
|
||||||
@known_object , @slots = object , slots
|
@known_object , @slots = object , slots
|
||||||
slot = [slot] unless slot.is_a?(Array)
|
slot = [slot] unless slot.is_a?(Array)
|
||||||
|
raise "Not known #{slots}" unless object
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -84,7 +84,7 @@ module Risc
|
|||||||
# The class can be mapped to a register, and so we get a memory address (reg+index)
|
# The class can be mapped to a register, and so we get a memory address (reg+index)
|
||||||
def self.resolve_to_index( clazz_name , instance_name )
|
def self.resolve_to_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.to_s.split('_').last.capitalize.to_sym
|
real_name = clazz_name.to_s.split('_').collect{|p|p.capitalize}.join.to_sym
|
||||||
clazz = Parfait.object_space.get_class_by_name(real_name)
|
clazz = Parfait.object_space.get_class_by_name(real_name)
|
||||||
raise "Class name not given #{real_name} #{clazz_name} #{instance_name}" unless clazz
|
raise "Class name not given #{real_name} #{clazz_name} #{instance_name}" unless clazz
|
||||||
index = clazz.instance_type.variable_index( instance_name )
|
index = clazz.instance_type.variable_index( instance_name )
|
||||||
|
@ -14,8 +14,9 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_type_update
|
def test_type_update
|
||||||
load = @ins.next(2)
|
load = @ins.next(2)
|
||||||
assert_equal :receiver , load.right.known_object , load
|
assert_equal :message , load.right.known_object , load
|
||||||
assert_equal :type , load.right.slots[0] , load
|
assert_equal :receiver , load.right.slots[0] , load
|
||||||
|
assert_equal :type , load.right.slots[1] , load
|
||||||
end
|
end
|
||||||
def test_check_resolve_call
|
def test_check_resolve_call
|
||||||
assert_equal SimpleCall , @ins.next(6).class , @ins
|
assert_equal SimpleCall , @ins.next(6).class , @ins
|
||||||
|
Loading…
Reference in New Issue
Block a user