operator also fell into ssa trap
relying on register identity in fact the whole operator concept was geared towards this, using 2 regs instead of one to avoid the whole issue better now
This commit is contained in:
parent
3145547315
commit
7232c28ecd
@ -192,7 +192,7 @@ module Risc
|
|||||||
right = right.to_reg() if(right.is_a?(RegisterSlot))
|
right = right.to_reg() if(right.is_a?(RegisterSlot))
|
||||||
ret = Risc.op( "operator #{operator}" , operator , self , right , result)
|
ret = Risc.op( "operator #{operator}" , operator , self , right , result)
|
||||||
compiler.add_code(ret) if compiler
|
compiler.add_code(ret) if compiler
|
||||||
ret
|
ret.result
|
||||||
end
|
end
|
||||||
|
|
||||||
# just capture the values in an intermediary object (RegisterSlot)
|
# just capture the values in an intermediary object (RegisterSlot)
|
||||||
|
@ -13,8 +13,8 @@ module SlotMachine
|
|||||||
builder.build do
|
builder.build do
|
||||||
integer = message[:receiver].reduce_int(false)
|
integer = message[:receiver].reduce_int(false)
|
||||||
integer_reg = message[:arg1].reduce_int(false)
|
integer_reg = message[:arg1].reduce_int(false)
|
||||||
integer.op operator , integer_reg
|
result = integer.op operator , integer_reg
|
||||||
integer_tmp[Parfait::Integer.integer_index] << integer
|
integer_tmp[Parfait::Integer.integer_index] << result
|
||||||
message[:return_value] << integer_tmp
|
message[:return_value] << integer_tmp
|
||||||
end
|
end
|
||||||
return compiler
|
return compiler
|
||||||
|
@ -51,11 +51,15 @@ module Risc
|
|||||||
assert_equal @r0 , message.register
|
assert_equal @r0 , message.register
|
||||||
end
|
end
|
||||||
def test_operator
|
def test_operator
|
||||||
ret = @r0.op :<< , @r1
|
@r0.set_compiler( fake = SuperFakeCompiler.new)
|
||||||
|
result = @r0.op :<< , @r1
|
||||||
|
ret = fake.code
|
||||||
assert_operator ret , :<< , :message , "id_" , "op_<<_"
|
assert_operator ret , :<< , :message , "id_" , "op_<<_"
|
||||||
end
|
end
|
||||||
def test_operator_slot
|
def test_operator_slot
|
||||||
ret = @r0.op :<< , @r1[:type]
|
@r0.set_compiler( fake = SuperFakeCompiler.new)
|
||||||
|
result = @r0.op :<< , @r1[:type]
|
||||||
|
ret = fake.code
|
||||||
assert_operator ret , :<< , :message , "id_.type" , "op_<<_"
|
assert_operator ret , :<< , :message , "id_.type" , "op_<<_"
|
||||||
end
|
end
|
||||||
def test_byte_to_reg
|
def test_byte_to_reg
|
||||||
|
@ -41,7 +41,7 @@ module SlotMachine
|
|||||||
assert_slot_to_reg s + 3 ,:message , 9 , "message.arg1"
|
assert_slot_to_reg s + 3 ,:message , 9 , "message.arg1"
|
||||||
assert_slot_to_reg s + 4 , "message.arg1" , 2 , "message.arg1.data_1"
|
assert_slot_to_reg s + 4 , "message.arg1" , 2 , "message.arg1.data_1"
|
||||||
assert_operator s + 5 , :| , "message.receiver.data_1" , "message.arg1.data_1" , "op_|_"
|
assert_operator s + 5 , :| , "message.receiver.data_1" , "message.arg1.data_1" , "op_|_"
|
||||||
assert_reg_to_slot s + 6 , "message.receiver.data_1" , "id_factory_.next_object" , 2
|
assert_reg_to_slot s + 6 , "op_|_" , "id_factory_.next_object" , 2
|
||||||
assert_reg_to_slot s + 7 , "id_factory_.next_object" , :message , 5
|
assert_reg_to_slot s + 7 , "id_factory_.next_object" , :message , 5
|
||||||
assert_slot_to_reg s + 8 ,:message , 5 , "message.return_value"
|
assert_slot_to_reg s + 8 ,:message , 5 , "message.return_value"
|
||||||
assert_reg_to_slot s + 9 , "message.return_value" , :message , 5
|
assert_reg_to_slot s + 9 , "message.return_value" , :message , 5
|
||||||
|
Loading…
Reference in New Issue
Block a user