change return sequence to return messages to space

as it was before blocks
(thought blocks would make reuse of messages impossible, but was wrong, this only appilies to lambdas)
(too) many tests affected
This commit is contained in:
Torsten Ruger
2018-08-06 14:07:17 +03:00
parent 77cbc0ad6a
commit 393ac873c9
31 changed files with 193 additions and 399 deletions

View File

@ -12,8 +12,9 @@ module Risc
[ Label ]
end
def postamble
[Label, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, Label]
[Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg,
SlotToReg , FunctionReturn, Label]
end
# test hack to in place change object type
def add_space_field(name,type)

View File

@ -10,32 +10,58 @@ module Risc
@expect = "something"
@produced = produce_instructions
end
def main_ends
24
def instruction(num) # 24 is the main, see test/mom/send/test_setup_simple.rb
@produced.next( 24 + num)
end
def test_postamble_classes
postamble.each_with_index do |ins , index|
assert_equal ins , @produced.next( main_ends + index).class
assert_equal ins , instruction( index).class , "wrong at #{index}"
end
end
def test_main_label
assert_equal Label , @produced.next(main_ends).class
assert_equal "return_label" , @produced.next(main_ends).name
assert_equal Label , instruction(0).class
assert_equal "return_label" , instruction(0).name
end
def test_move_ret
assert_slot_to_reg( @produced.next(main_ends + 1) , :r0 , 5 , :r1 )
assert_slot_to_reg( instruction( 1 ) , :r0 , 5 , :r1 )
end
def test_move_caller
assert_slot_to_reg( @produced.next(main_ends + 2) , :r0 , 6 , :r2 )
assert_slot_to_reg( instruction( 2 ) , :r0 , 6 , :r2 )
end
def test_save_ret
assert_reg_to_slot( @produced.next(main_ends + 3) , :r1 , :r2 , 5 )
assert_reg_to_slot( instruction( 3 ) , :r1 , :r2 , 5 )
end
def test_load_space
assert_load( instruction(4) , Parfait::Space )
end
def test_get_next
assert_slot_to_reg( instruction( 5 ) , :r3 , 3 , :r4 )
end
def test_save_next
assert_reg_to_slot( instruction( 6 ) , :r4 , :r0 , 1 )
end
def test_save_this
assert_reg_to_slot( instruction( 7 ) , :r0 , :r3 , 3 )
end
def test_save_addr
assert_slot_to_reg( @produced.next(main_ends + 4) , :r0 , 4 , :r1 )
assert_slot_to_reg( instruction( 8 ) , :r0 , 4 , :r1 )
end
def test_reduce_addr
assert_slot_to_reg( @produced.next(main_ends + 5) , :r1 , 2 , :r1 )
assert_slot_to_reg( instruction( 9 ) , :r1 , 2 , :r1 )
end
def test_reduce_caller
assert_slot_to_reg( instruction( 10 ) , :r0 , 6 , :r0 )
end
def test_function_return
ret = instruction(11)
assert_equal FunctionReturn , ret.class
assert_equal :r1 , ret.register.symbol
end
def test_unreachable
assert_equal Label , instruction(12).class
assert_equal "unreachable" , instruction(12).name
end
end
end