fix get_internal word register names

seems previous commits broke the return
This commit is contained in:
Torsten 2020-03-09 13:53:02 +02:00
parent 6267bf3ad0
commit 05ddc70fd6
2 changed files with 12 additions and 15 deletions

View File

@ -2,11 +2,8 @@ module SlotMachine
class GetInternalWord < Macro
def to_risc(compiler)
compiler.builder(compiler.source).build do
object! << message[:receiver]
integer! << message[:arg1] #"at" is at index 0
integer.reduce_int
object << object[integer]
message[:return_value] << object
integer = message[:arg1].to_reg.reduce_int(false)
message[:return_value] << message[:receiver][integer]
end
end
end

View File

@ -15,18 +15,18 @@ module SlotMachine
assert_equal Risc::MethodCompiler , @method.to_risc.class
end
def test_risc_length
assert_equal 18 , @method.to_risc.risc_instructions.length
assert_equal 17 , @method.to_risc.risc_instructions.length
end
def test_all
assert_slot_to_reg risc(1),:r0 , 2 , :r1
assert_slot_to_reg risc(2),:r0 , 9 , :r2
assert_slot_to_reg risc(3),:r2 , 2 , :r2
assert_slot_to_reg risc(4),:r1 , :r2 , :r1
assert_reg_to_slot risc(5) , :r1 , :r0 , 5
assert_slot_to_reg risc(6),:r0 , 5 , :r2
assert_reg_to_slot risc(7) , :r2 , :r0 , 5
assert_branch risc(8) , "return_label"
assert_label risc(9) , "return_label"
assert_slot_to_reg 1 ,:message , 9 , "message.arg1"
assert_slot_to_reg 2 , "message.arg1" , 2 , "message.arg1.data_1"
assert_slot_to_reg 3 , :message , 2 , "message.receiver"
assert_slot_to_reg 4 , :"message.receiver" , :"message.arg1.data_1" , "message.receiver.indexed"
assert_reg_to_slot 5 , "message.receiver.indexed" , :message , 5
assert_slot_to_reg 6 , :message , 5 , "message.return_value"
assert_reg_to_slot 7 , "message.return_value" , :message , 5
assert_branch 8 , "return_label"
assert_label 9 , "return_label"
end
def test_return
assert_return(9)