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)
|
||||
left = SlotDefinition.new(left.shift , left) if left.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
|
||||
end
|
||||
|
||||
def to_risc(compiler)
|
||||
reg = compiler.use_reg( @right.ct_type)
|
||||
const = Risc.load_constant(self, @right , reg)
|
||||
const << Risc.reg_to_slot(self, reg , @left.known_object, @left.slots.first)
|
||||
compiler.release_reg(reg)
|
||||
type = @right.respond_to?(:ct_type) ? @right.ct_type : :int
|
||||
right = compiler.use_reg( type )
|
||||
case @right.known_object
|
||||
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
|
||||
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
|
||||
|
||||
class SlotDefinition
|
||||
@ -61,6 +73,7 @@ module Mom
|
||||
def initialize( object , slots)
|
||||
@known_object , @slots = object , slots
|
||||
slot = [slot] unless slot.is_a?(Array)
|
||||
raise "Not known #{slots}" unless object
|
||||
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)
|
||||
def self.resolve_to_index( clazz_name , instance_name )
|
||||
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)
|
||||
raise "Class name not given #{real_name} #{clazz_name} #{instance_name}" unless clazz
|
||||
index = clazz.instance_type.variable_index( instance_name )
|
||||
|
@ -14,8 +14,9 @@ module Vool
|
||||
end
|
||||
def test_type_update
|
||||
load = @ins.next(2)
|
||||
assert_equal :receiver , load.right.known_object , load
|
||||
assert_equal :type , load.right.slots[0] , load
|
||||
assert_equal :message , load.right.known_object , load
|
||||
assert_equal :receiver , load.right.slots[0] , load
|
||||
assert_equal :type , load.right.slots[1] , load
|
||||
end
|
||||
def test_check_resolve_call
|
||||
assert_equal SimpleCall , @ins.next(6).class , @ins
|
||||
|
Loading…
Reference in New Issue
Block a user