did block yield

This commit is contained in:
Torsten 2020-03-03 16:22:50 +02:00
parent a4c0b8e5f9
commit 7f5ebab800
2 changed files with 14 additions and 15 deletions

View File

@ -21,12 +21,11 @@ module SlotMachine
def to_risc(compiler) def to_risc(compiler)
return_label = Risc.label("block_yield", "continue_#{object_id}") return_label = Risc.label("block_yield", "continue_#{object_id}")
index = arg_index index = arg_index
compiler.build("BlockYield") do return_address = compiler.load_object return_label
next_message! << message[:next_message] compiler.build(to_s) do
return_address! << return_label message[:next_message][:return_address] << return_address
next_message[:return_address] << return_address
block_reg! << message["arg#{index}".to_sym] block_reg = message["arg#{index}".to_sym].to_reg
message << message[:next_message] message << message[:next_message]
add_code Risc::DynamicJump.new("block_yield", block_reg ) add_code Risc::DynamicJump.new("block_yield", block_reg )

View File

@ -8,25 +8,25 @@ module SlotMachine
def test_len def test_len
assert_equal 8 , all.length , all_str assert_equal 8 , all.length , all_str
end end
def test_1_slot def test_1_load
assert_slot_to_reg risc(1) ,:r0 , 1 , :r1 assert_load risc(1) , Risc::Label , "id_"
assert_label risc(1).constant , "continue_"
end end
def test_2_load def test_2_slot
assert_load risc(2) , Risc::Label , :r2 assert_slot_to_reg risc(2) ,:message , 1 , "message.next_message"
assert_label risc(2).constant , "continue_"
end end
def test_3_reg def test_3_reg
assert_reg_to_slot risc(3) , :r2 , :r1 , 4 assert_reg_to_slot risc(3) , "id_" , "message.next_message" , 4
end end
def test_4_slot def test_4_slot
assert_slot_to_reg risc(4) ,:r0 , 9 , :r3 assert_slot_to_reg risc(4) ,:message , 9 , "message.arg1"
end end
def test_5_slot def test_5_swap
assert_slot_to_reg risc(5) ,:r0 , 1 , :r0 assert_slot_to_reg risc(5) ,:message , 1 , :message
end end
def test_6_jump def test_6_jump
assert_equal Risc::DynamicJump , risc(6).class assert_equal Risc::DynamicJump , risc(6).class
assert_equal :r3 , risc(6).register.symbol assert_equal :"message.arg1" , risc(6).register.symbol
end end
def test_7_label def test_7_label
assert_label risc(7) , "continue_" assert_label risc(7) , "continue_"