From 10fa61aa9fdc184893b945eb0ef1a2aa581a69e1 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 1 Apr 2018 14:56:01 +0300 Subject: [PATCH] fix integer plus mostly forgot the return sequence --- lib/risc/builtin/integer.rb | 6 +++--- test/risc/interpreter/test_plus.rb | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/risc/builtin/integer.rb b/lib/risc/builtin/integer.rb index ece2f56e..5e388360 100644 --- a/lib/risc/builtin/integer.rb +++ b/lib/risc/builtin/integer.rb @@ -20,13 +20,13 @@ module Risc compiler = compiler_for(:Integer,:+ ,{other: :Integer}) me , other = compiler.self_and_int_arg(source + "1") # reduce me and other to integers - compiler.add_slot_to_reg( source + "2" , me , Parfait::Integer.integer_index , me) - compiler.add_slot_to_reg( source + "3", other , Parfait::Integer.integer_index , other) + compiler.reduce_int( source + "2", me ) + compiler.reduce_int( source + "3", other ) compiler.add_code Risc.op( source + "4", :+ , me , other) compiler.add_new_int(me , other) compiler.add_reg_to_slot( source + "5" , other , :message , :return_value) + compiler.add_mom( Mom::ReturnSequence.new) return compiler.method - end def div10( context ) s = "div_10 " diff --git a/test/risc/interpreter/test_plus.rb b/test/risc/interpreter/test_plus.rb index 1526511f..63fbf62e 100644 --- a/test/risc/interpreter/test_plus.rb +++ b/test/risc/interpreter/test_plus.rb @@ -24,7 +24,11 @@ module Risc SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label, SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, - RegToSlot, RegToSlot, RegToSlot, Label, NilClass] + RegToSlot, RegToSlot, RegToSlot, SlotToReg, SlotToReg, + RegToSlot, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, + SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, + SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, + FunctionReturn, Transfer, Syscall, NilClass] assert_equal Parfait::Integer , get_return.class assert_equal 10 , get_return.value end @@ -99,5 +103,10 @@ module Risc assert_equal 5 , sl.index assert_equal :r4 , sl.register.symbol end + def test_sys + sys = ticks(88) + assert_equal Syscall , sys.class + assert_equal :exit , sys.name + end end end