fix slot_to_reg to allow register indexes

we mostly use pre-calculated indexes, ie integers
but registers are allowed (in arm/risc), so we try to check the registers type at least is right.
The return is really a machine word, but we call it Object (yes, more work that way)
This commit is contained in:
2020-03-09 13:51:41 +02:00
parent 62d8d92b50
commit 6267bf3ad0
3 changed files with 19 additions and 11 deletions

View File

@ -14,5 +14,13 @@ module Risc
def test_slot_reg
assert_equal :"message.type" , slot.register.symbol
end
def test_reg_as_index
reg = RegisterValue.new(:name , :Integer)
Risc.slot_to_reg("source" , Risc.message_named_reg , reg)
end
def test_reg_as_index_fail
reg = Risc.message_named_reg
assert_raises {Risc.slot_to_reg("source" , reg , reg)}
end
end
end