fix bug in slot_load and definition

move parfait helper for reuse
This commit is contained in:
Torsten Ruger
2018-08-19 15:36:51 +03:00
parent 253d2fead8
commit f85fe8a2cb
7 changed files with 73 additions and 24 deletions

View File

@ -65,8 +65,8 @@ module Mom
compiler.add_code const
raise "Can't have slots into Constants" if slots.length > 0
when Parfait::Object , Risc::Label
const = Risc::SlotToReg.new( source , right ,index, right)
compiler.add_code const Risc.load_constant(source, known_object , right)
const = const = Risc.load_constant(source, known_object , right)
compiler.add_code const
if slots.length > 0
# desctructively replace the existing value to be loaded if more slots
compiler.add_code Risc.slot_to_reg( source , right ,slots[0], right)

View File

@ -39,7 +39,6 @@ module Mom
end
def to_risc(compiler)
#puts "RISC #{self}"
const_reg = @right.to_register(compiler , original_source)
left_slots = @left.slots
case @left.known_object
@ -48,7 +47,7 @@ module Mom
when Parfait::CacheEntry
left = compiler.use_reg( :CacheEntry )
compiler.add_code Risc.load_constant(original_source, @left.known_object , left)
compiler.add_code Risc.reg_to_slot(original_source, const.register , left, left_slots.first)
compiler.add_code Risc.reg_to_slot(original_source, const_reg , left, left_slots.first)
else
raise "We have left #{@left.known_object}"
end