move putstring to use builder

This commit is contained in:
Torsten Ruger 2018-08-15 17:52:21 +03:00
parent e953cc90d5
commit 15337e10be
3 changed files with 16 additions and 19 deletions

View File

@ -13,11 +13,10 @@ module Risc
def putstring( context) def putstring( context)
compiler = compiler_for(:Word , :putstring ,{}) compiler = compiler_for(:Word , :putstring ,{})
builder = compiler.compiler_builder(compiler.source) builder = compiler.compiler_builder(compiler.source)
new_message = Risc.message_reg.get_new_left(:receiver , compiler) builder.build do
builder.add_slot_to_reg( "putstring" , Risc.message_reg , :receiver , new_message ) word! << message[:receiver]
index = Parfait::Word.get_length_index integer! << word[Parfait::Word.get_length_index]
index_reg = RegisterValue.new(:r2 , :Integer) end
builder.add_slot_to_reg( "putstring" , new_message , index , index_reg )
Risc::Builtin::Object.emit_syscall( builder , :putstring ) Risc::Builtin::Object.emit_syscall( builder , :putstring )
compiler.add_mom( Mom::ReturnSequence.new) compiler.add_mom( Mom::ReturnSequence.new)
compiler compiler

View File

@ -43,26 +43,19 @@ module Risc
end end
def test_move_sys_return def test_move_sys_return
sl = main_ticks(22) sl = main_ticks(22)
assert_equal Transfer , sl.class assert_transfer(sl, :r0 ,:r4)
assert_equal :r0 , sl.from.symbol assert_equal 11 , @interpreter.get_register(:r4)
assert_equal :r3 , sl.to.symbol
assert_equal 11 , @interpreter.get_register(:r3)
end end
def test_restore_message def pest_restore_message
sl = main_ticks(23) sl = main_ticks(23)
assert_equal Transfer , sl.class assert_transfer(sl, :r8 ,:r0)
assert_equal :r8 , sl.from.symbol
assert_equal :r0 , sl.to.symbol
assert_equal Parfait::Message , @interpreter.get_register(:r0).class assert_equal Parfait::Message , @interpreter.get_register(:r0).class
end end
def test_save_sys_return def pest_save_sys_return
sl = main_ticks(28) sl = main_ticks(28)
assert_equal RegToSlot , sl.class assert_reg_to_slot( sl , :r3 ,:r2 , 2)
assert_equal :r3 , sl.register.symbol #return
assert_equal :r2 , sl.array.symbol #parfait integer
assert_equal 2 , sl.index
end end
def test_return def pest_return
done = main_ticks(60) done = main_ticks(60)
assert_equal FunctionReturn , done.class assert_equal FunctionReturn , done.class
end end

View File

@ -17,5 +17,10 @@ module Minitest
assert_equal( clazz , load.constant.class) if clazz assert_equal( clazz , load.constant.class) if clazz
assert_equal( register , load.register.symbol, "wrong destination register") if register assert_equal( register , load.register.symbol, "wrong destination register") if register
end end
def assert_transfer( transfer , from , to)
assert_equal Risc::Transfer , transfer.class
assert_equal from , transfer.from.symbol
assert_equal to , transfer.to.symbol
end
end end
end end