diff --git a/lib/risc/register_value.rb b/lib/risc/register_value.rb index 2d6b5180..916aea20 100644 --- a/lib/risc/register_value.rb +++ b/lib/risc/register_value.rb @@ -116,6 +116,8 @@ module Risc case right when Parfait::Object , Symbol ins = Risc.load_constant("#{right.class} to #{self.type}" , right , self) + when Fixnum + ins = Risc.load_data("#{right.class} to #{self.type}" , right , self) when RegisterValue ins = Risc.transfer("#{right.type} to #{self.type}" , right , self) when RValue @@ -137,11 +139,18 @@ module Risc # generate a Function return instruction # using the register as the parameter where the return address is passed def function_return - ret = Risc::FunctionReturn.new("return", self) + ret = Risc.function_return("return", self) builder.add_code(ret) if builder ret end + # create operator instruction for self and add + # doesn't read quite as smoothly as one would like, but better than the compiler version + def op( operator , right) + ret = Risc.op( "operator #{operator}" , :>> , self , right) + builder.add_code(ret) if builder + ret + end # just capture the values in an intermediary object (RValue) # The RValue then gets used in a RegToSlot ot SlotToReg, where # the values are unpacked to call Risc.reg_to_slot or Risc.slot_to_reg diff --git a/test/risc/test_register_value.rb b/test/risc/test_register_value.rb index 4c484814..b8c8c815 100644 --- a/test/risc/test_register_value.rb +++ b/test/risc/test_register_value.rb @@ -46,6 +46,12 @@ module Risc assert_equal FunctionReturn , ret.class assert_equal @r0 , ret.register end + def test_operator + ret = @r0.op :<< , @r1 + assert_equal OperatorInstruction , ret.class + assert_equal @r0 , ret.left + assert_equal @r1 , ret.right + end def test_slot_to_reg instr = @r0 << @r1[:next_message] assert_equal SlotToReg , instr.class