did block yield
This commit is contained in:
parent
a4c0b8e5f9
commit
7f5ebab800
@ -21,12 +21,11 @@ module SlotMachine
|
||||
def to_risc(compiler)
|
||||
return_label = Risc.label("block_yield", "continue_#{object_id}")
|
||||
index = arg_index
|
||||
compiler.build("BlockYield") do
|
||||
next_message! << message[:next_message]
|
||||
return_address! << return_label
|
||||
next_message[:return_address] << return_address
|
||||
return_address = compiler.load_object return_label
|
||||
compiler.build(to_s) do
|
||||
message[: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]
|
||||
add_code Risc::DynamicJump.new("block_yield", block_reg )
|
||||
|
@ -8,25 +8,25 @@ module SlotMachine
|
||||
def test_len
|
||||
assert_equal 8 , all.length , all_str
|
||||
end
|
||||
def test_1_slot
|
||||
assert_slot_to_reg risc(1) ,:r0 , 1 , :r1
|
||||
def test_1_load
|
||||
assert_load risc(1) , Risc::Label , "id_"
|
||||
assert_label risc(1).constant , "continue_"
|
||||
end
|
||||
def test_2_load
|
||||
assert_load risc(2) , Risc::Label , :r2
|
||||
assert_label risc(2).constant , "continue_"
|
||||
def test_2_slot
|
||||
assert_slot_to_reg risc(2) ,:message , 1 , "message.next_message"
|
||||
end
|
||||
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
|
||||
def test_4_slot
|
||||
assert_slot_to_reg risc(4) ,:r0 , 9 , :r3
|
||||
assert_slot_to_reg risc(4) ,:message , 9 , "message.arg1"
|
||||
end
|
||||
def test_5_slot
|
||||
assert_slot_to_reg risc(5) ,:r0 , 1 , :r0
|
||||
def test_5_swap
|
||||
assert_slot_to_reg risc(5) ,:message , 1 , :message
|
||||
end
|
||||
def test_6_jump
|
||||
assert_equal Risc::DynamicJump , risc(6).class
|
||||
assert_equal :r3 , risc(6).register.symbol
|
||||
assert_equal :"message.arg1" , risc(6).register.symbol
|
||||
end
|
||||
def test_7_label
|
||||
assert_label risc(7) , "continue_"
|
||||
|
Loading…
Reference in New Issue
Block a user