move putstring to use builder
This commit is contained in:
parent
e953cc90d5
commit
15337e10be
@ -13,11 +13,10 @@ module Risc
|
||||
def putstring( context)
|
||||
compiler = compiler_for(:Word , :putstring ,{})
|
||||
builder = compiler.compiler_builder(compiler.source)
|
||||
new_message = Risc.message_reg.get_new_left(:receiver , compiler)
|
||||
builder.add_slot_to_reg( "putstring" , Risc.message_reg , :receiver , new_message )
|
||||
index = Parfait::Word.get_length_index
|
||||
index_reg = RegisterValue.new(:r2 , :Integer)
|
||||
builder.add_slot_to_reg( "putstring" , new_message , index , index_reg )
|
||||
builder.build do
|
||||
word! << message[:receiver]
|
||||
integer! << word[Parfait::Word.get_length_index]
|
||||
end
|
||||
Risc::Builtin::Object.emit_syscall( builder , :putstring )
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
compiler
|
||||
|
@ -43,26 +43,19 @@ module Risc
|
||||
end
|
||||
def test_move_sys_return
|
||||
sl = main_ticks(22)
|
||||
assert_equal Transfer , sl.class
|
||||
assert_equal :r0 , sl.from.symbol
|
||||
assert_equal :r3 , sl.to.symbol
|
||||
assert_equal 11 , @interpreter.get_register(:r3)
|
||||
assert_transfer(sl, :r0 ,:r4)
|
||||
assert_equal 11 , @interpreter.get_register(:r4)
|
||||
end
|
||||
def test_restore_message
|
||||
def pest_restore_message
|
||||
sl = main_ticks(23)
|
||||
assert_equal Transfer , sl.class
|
||||
assert_equal :r8 , sl.from.symbol
|
||||
assert_equal :r0 , sl.to.symbol
|
||||
assert_transfer(sl, :r8 ,:r0)
|
||||
assert_equal Parfait::Message , @interpreter.get_register(:r0).class
|
||||
end
|
||||
def test_save_sys_return
|
||||
def pest_save_sys_return
|
||||
sl = main_ticks(28)
|
||||
assert_equal RegToSlot , sl.class
|
||||
assert_equal :r3 , sl.register.symbol #return
|
||||
assert_equal :r2 , sl.array.symbol #parfait integer
|
||||
assert_equal 2 , sl.index
|
||||
assert_reg_to_slot( sl , :r3 ,:r2 , 2)
|
||||
end
|
||||
def test_return
|
||||
def pest_return
|
||||
done = main_ticks(60)
|
||||
assert_equal FunctionReturn , done.class
|
||||
end
|
||||
|
@ -17,5 +17,10 @@ module Minitest
|
||||
assert_equal( clazz , load.constant.class) if clazz
|
||||
assert_equal( register , load.register.symbol, "wrong destination register") if register
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user