fix get_internal word register names
seems previous commits broke the return
This commit is contained in:
parent
6267bf3ad0
commit
05ddc70fd6
@ -2,11 +2,8 @@ module SlotMachine
|
|||||||
class GetInternalWord < Macro
|
class GetInternalWord < Macro
|
||||||
def to_risc(compiler)
|
def to_risc(compiler)
|
||||||
compiler.builder(compiler.source).build do
|
compiler.builder(compiler.source).build do
|
||||||
object! << message[:receiver]
|
integer = message[:arg1].to_reg.reduce_int(false)
|
||||||
integer! << message[:arg1] #"at" is at index 0
|
message[:return_value] << message[:receiver][integer]
|
||||||
integer.reduce_int
|
|
||||||
object << object[integer]
|
|
||||||
message[:return_value] << object
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -15,18 +15,18 @@ module SlotMachine
|
|||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||||
end
|
end
|
||||||
def test_risc_length
|
def test_risc_length
|
||||||
assert_equal 18 , @method.to_risc.risc_instructions.length
|
assert_equal 17 , @method.to_risc.risc_instructions.length
|
||||||
end
|
end
|
||||||
def test_all
|
def test_all
|
||||||
assert_slot_to_reg risc(1),:r0 , 2 , :r1
|
assert_slot_to_reg 1 ,:message , 9 , "message.arg1"
|
||||||
assert_slot_to_reg risc(2),:r0 , 9 , :r2
|
assert_slot_to_reg 2 , "message.arg1" , 2 , "message.arg1.data_1"
|
||||||
assert_slot_to_reg risc(3),:r2 , 2 , :r2
|
assert_slot_to_reg 3 , :message , 2 , "message.receiver"
|
||||||
assert_slot_to_reg risc(4),:r1 , :r2 , :r1
|
assert_slot_to_reg 4 , :"message.receiver" , :"message.arg1.data_1" , "message.receiver.indexed"
|
||||||
assert_reg_to_slot risc(5) , :r1 , :r0 , 5
|
assert_reg_to_slot 5 , "message.receiver.indexed" , :message , 5
|
||||||
assert_slot_to_reg risc(6),:r0 , 5 , :r2
|
assert_slot_to_reg 6 , :message , 5 , "message.return_value"
|
||||||
assert_reg_to_slot risc(7) , :r2 , :r0 , 5
|
assert_reg_to_slot 7 , "message.return_value" , :message , 5
|
||||||
assert_branch risc(8) , "return_label"
|
assert_branch 8 , "return_label"
|
||||||
assert_label risc(9) , "return_label"
|
assert_label 9 , "return_label"
|
||||||
end
|
end
|
||||||
def test_return
|
def test_return
|
||||||
assert_return(9)
|
assert_return(9)
|
||||||
|
Loading…
Reference in New Issue
Block a user