fix comparison test and helpers

moving to passing the instruction number, not the instruction
so in the error message we can say where the error is
(otherwise minitest is good enough to supress the trace of asserts calling asserts)
This commit is contained in:
2020-03-06 21:26:23 +02:00
parent 3575aada17
commit 1760b5b203
4 changed files with 132 additions and 102 deletions

View File

@ -13,8 +13,8 @@ module SlotMachine
def to_risc(compiler)
builder = compiler.builder(compiler.source)
operator = @operator # make accessible in block
false_label = Risc.label("false" , "false")
merge_label = Risc.label("merge" , "merge")
false_label = Risc.label("false" , "false_label_#{object_id}")
merge_label = Risc.label("merge" , "merge_label_#{object_id}")
result = Risc::RegisterValue.new(:result , :Object)
builder.build do
left = message[:receiver].to_reg.reduce_int
@ -26,7 +26,7 @@ module SlotMachine
left.op :- , right
end
if_minus false_label
if_zero( false_label ) if operator.to_s.length == 1
if_not_zero( false_label ) if operator.to_s.length == 1
add_code Risc::LoadConstant.new(to_s , Parfait.object_space.true_object, result)
branch merge_label
add_code false_label